summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_editor.cpp3270
-rw-r--r--editor/animation_editor.h64
-rw-r--r--editor/array_property_edit.cpp220
-rw-r--r--editor/array_property_edit.h16
-rw-r--r--editor/asset_library_editor_plugin.cpp994
-rw-r--r--editor/asset_library_editor_plugin.h111
-rw-r--r--editor/call_dialog.cpp2
-rw-r--r--editor/call_dialog.h6
-rw-r--r--editor/code_editor.cpp602
-rw-r--r--editor/code_editor.h63
-rw-r--r--editor/collada/collada.cpp1935
-rw-r--r--editor/collada/collada.h375
-rw-r--r--editor/connections_dialog.cpp484
-rw-r--r--editor/connections_dialog.h34
-rw-r--r--editor/create_dialog.cpp507
-rw-r--r--editor/create_dialog.h47
-rw-r--r--editor/dependency_editor.cpp456
-rw-r--r--editor/dependency_editor.h52
-rw-r--r--editor/doc/doc_data.cpp886
-rw-r--r--editor/doc/doc_data.h36
-rw-r--r--editor/doc/doc_dump.cpp269
-rw-r--r--editor/doc/doc_dump.h4
-rw-r--r--editor/doc_code_font.h8
-rw-r--r--editor/doc_font.h8
-rw-r--r--editor/doc_title_font.h8
-rw-r--r--editor/editor_asset_installer.cpp236
-rw-r--r--editor/editor_asset_installer.h13
-rw-r--r--editor/editor_audio_buses.cpp830
-rw-r--r--editor/editor_audio_buses.h80
-rw-r--r--editor/editor_autoload_settings.cpp77
-rw-r--r--editor/editor_autoload_settings.h18
-rw-r--r--editor/editor_data.cpp499
-rw-r--r--editor/editor_data.h87
-rw-r--r--editor/editor_dir_dialog.cpp150
-rw-r--r--editor/editor_dir_dialog.h13
-rw-r--r--editor/editor_export.cpp560
-rw-r--r--editor/editor_export.h150
-rw-r--r--editor/editor_file_dialog.cpp1018
-rw-r--r--editor/editor_file_dialog.h51
-rw-r--r--editor/editor_file_system.cpp1038
-rw-r--r--editor/editor_file_system.h73
-rw-r--r--editor/editor_fonts.cpp106
-rw-r--r--editor/editor_help.cpp1002
-rw-r--r--editor/editor_help.h97
-rw-r--r--editor/editor_initialize_ssl.cpp13
-rw-r--r--editor/editor_log.cpp103
-rw-r--r--editor/editor_log.h17
-rw-r--r--editor/editor_name_dialog.cpp21
-rw-r--r--editor/editor_name_dialog.h8
-rw-r--r--editor/editor_node.cpp3353
-rw-r--r--editor/editor_node.h312
-rw-r--r--editor/editor_path.cpp119
-rw-r--r--editor/editor_path.h12
-rw-r--r--editor/editor_plugin.cpp232
-rw-r--r--editor/editor_plugin.h89
-rw-r--r--editor/editor_plugin_settings.cpp152
-rw-r--r--editor/editor_plugin_settings.h14
-rw-r--r--editor/editor_profiler.cpp563
-rw-r--r--editor/editor_profiler.h36
-rw-r--r--editor/editor_resource_preview.cpp227
-rw-r--r--editor/editor_resource_preview.h42
-rw-r--r--editor/editor_run.cpp104
-rw-r--r--editor/editor_run.h10
-rw-r--r--editor/editor_run_native.cpp34
-rw-r--r--editor/editor_run_native.h9
-rw-r--r--editor/editor_run_script.cpp32
-rw-r--r--editor/editor_run_script.h7
-rw-r--r--editor/editor_scale.cpp2
-rw-r--r--editor/editor_settings.cpp651
-rw-r--r--editor/editor_settings.h74
-rw-r--r--editor/editor_sub_scene.cpp122
-rw-r--r--editor/editor_sub_scene.h19
-rw-r--r--editor/editor_themes.cpp40
-rw-r--r--editor/file_type_cache.cpp37
-rw-r--r--editor/file_type_cache.h17
-rw-r--r--editor/fileserver/editor_file_server.cpp266
-rw-r--r--editor/fileserver/editor_file_server.h20
-rw-r--r--editor/filesystem_dock.cpp1026
-rw-r--r--editor/filesystem_dock.h72
-rw-r--r--editor/groups_editor.cpp90
-rw-r--r--editor/groups_editor.h16
-rw-r--r--editor/import/editor_import_collada.cpp1450
-rw-r--r--editor/import/editor_import_collada.h12
-rw-r--r--editor/import/resource_importer_csv_translation.cpp60
-rw-r--r--editor/import/resource_importer_csv_translation.h9
-rw-r--r--editor/import/resource_importer_obj.cpp162
-rw-r--r--editor/import/resource_importer_obj.h10
-rw-r--r--editor/import/resource_importer_scene.cpp764
-rw-r--r--editor/import/resource_importer_scene.h69
-rw-r--r--editor/import/resource_importer_texture.cpp232
-rw-r--r--editor/import/resource_importer_texture.h30
-rw-r--r--editor/import/resource_importer_wav.cpp434
-rw-r--r--editor/import/resource_importer_wav.h12
-rw-r--r--editor/import_dock.cpp177
-rw-r--r--editor/import_dock.h15
-rw-r--r--editor/inspector_dock.h3
-rw-r--r--editor/io_plugins/editor_atlas.cpp92
-rw-r--r--editor/io_plugins/editor_atlas.h5
-rw-r--r--editor/io_plugins/editor_bitmask_import_plugin.cpp8
-rw-r--r--editor/io_plugins/editor_export_scene.cpp4
-rw-r--r--editor/io_plugins/editor_font_import_plugin.cpp6
-rw-r--r--editor/io_plugins/editor_mesh_import_plugin.cpp4
-rw-r--r--editor/io_plugins/editor_sample_import_plugin.cpp6
-rw-r--r--editor/io_plugins/editor_scene_import_plugin.cpp25
-rw-r--r--editor/io_plugins/editor_scene_import_plugin.h16
-rw-r--r--editor/io_plugins/editor_scene_importer_fbxconv.cpp2
-rw-r--r--editor/io_plugins/editor_texture_import_plugin.cpp12
-rw-r--r--editor/io_plugins/editor_texture_import_plugin.h15
-rw-r--r--editor/io_plugins/editor_translation_import_plugin.cpp6
-rw-r--r--editor/multi_node_edit.cpp90
-rw-r--r--editor/multi_node_edit.h19
-rw-r--r--editor/node_dock.cpp40
-rw-r--r--editor/node_dock.h8
-rw-r--r--editor/output_strings.cpp139
-rw-r--r--editor/output_strings.h20
-rw-r--r--editor/pane_drag.cpp34
-rw-r--r--editor/pane_drag.h7
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp790
-rw-r--r--editor/plugins/animation_player_editor_plugin.h50
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp1166
-rw-r--r--editor/plugins/animation_tree_editor_plugin.h49
-rw-r--r--editor/plugins/baked_light_baker.cpp6
-rw-r--r--editor/plugins/baked_light_baker.h2
-rw-r--r--editor/plugins/baked_light_baker_cmpxchg.cpp58
-rw-r--r--editor/plugins/baked_light_editor_plugin.cpp7
-rw-r--r--editor/plugins/baked_light_editor_plugin.h5
-rw-r--r--editor/plugins/camera_editor_plugin.cpp50
-rw-r--r--editor/plugins/camera_editor_plugin.h13
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp2381
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h138
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.cpp301
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.h18
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.cpp6
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.h4
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp222
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.h32
-rw-r--r--editor/plugins/color_ramp_editor_plugin.cpp44
-rw-r--r--editor/plugins/color_ramp_editor_plugin.h7
-rw-r--r--editor/plugins/cube_grid_theme_editor_plugin.cpp8
-rw-r--r--editor/plugins/cube_grid_theme_editor_plugin.h3
-rw-r--r--editor/plugins/editor_preview_plugins.cpp38
-rw-r--r--editor/plugins/gi_probe_editor_plugin.cpp22
-rw-r--r--editor/plugins/gi_probe_editor_plugin.h13
-rw-r--r--editor/plugins/item_list_editor_plugin.cpp189
-rw-r--r--editor/plugins/item_list_editor_plugin.h96
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.cpp334
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.h20
-rw-r--r--editor/plugins/line_2d_editor_plugin.cpp88
-rw-r--r--editor/plugins/line_2d_editor_plugin.h20
-rw-r--r--editor/plugins/material_editor_plugin.cpp52
-rw-r--r--editor/plugins/material_editor_plugin.h6
-rw-r--r--editor/plugins/mesh_editor_plugin.h6
-rw-r--r--editor/plugins/mesh_instance_editor_plugin.cpp141
-rw-r--r--editor/plugins/mesh_instance_editor_plugin.h15
-rw-r--r--editor/plugins/multimesh_editor_plugin.cpp208
-rw-r--r--editor/plugins/multimesh_editor_plugin.h16
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.cpp396
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.h20
-rw-r--r--editor/plugins/particles_2d_editor_plugin.cpp110
-rw-r--r--editor/plugins/particles_2d_editor_plugin.h13
-rw-r--r--editor/plugins/particles_editor_plugin.cpp3
-rw-r--r--editor/plugins/particles_editor_plugin.h2
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp306
-rw-r--r--editor/plugins/path_2d_editor_plugin.h20
-rw-r--r--editor/plugins/path_editor_plugin.cpp4
-rw-r--r--editor/plugins/path_editor_plugin.h3
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp741
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.h19
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp296
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.h31
-rw-r--r--editor/plugins/rich_text_editor_plugin.cpp62
-rw-r--r--editor/plugins/rich_text_editor_plugin.h18
-rw-r--r--editor/plugins/sample_editor_plugin.cpp4
-rw-r--r--editor/plugins/sample_editor_plugin.h2
-rw-r--r--editor/plugins/sample_library_editor_plugin.cpp6
-rw-r--r--editor/plugins/sample_library_editor_plugin.h9
-rw-r--r--editor/plugins/sample_player_editor_plugin.cpp2
-rw-r--r--editor/plugins/sample_player_editor_plugin.h4
-rw-r--r--editor/plugins/script_editor_plugin.cpp1171
-rw-r--r--editor/plugins/script_editor_plugin.h145
-rw-r--r--editor/plugins/script_text_editor.cpp644
-rw-r--r--editor/plugins/script_text_editor.h50
-rw-r--r--editor/plugins/shader_editor_plugin.cpp250
-rw-r--r--editor/plugins/shader_editor_plugin.h32
-rw-r--r--editor/plugins/shader_graph_editor_plugin.cpp6
-rw-r--r--editor/plugins/shader_graph_editor_plugin.h9
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp2678
-rw-r--r--editor/plugins/spatial_editor_plugin.h166
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp611
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h35
-rw-r--r--editor/plugins/stream_editor_plugin.h2
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp44
-rw-r--r--editor/plugins/style_box_editor_plugin.h22
-rw-r--r--editor/plugins/texture_editor_plugin.cpp84
-rw-r--r--editor/plugins/texture_editor_plugin.h13
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp755
-rw-r--r--editor/plugins/texture_region_editor_plugin.h23
-rw-r--r--editor/plugins/theme_editor_plugin.cpp610
-rw-r--r--editor/plugins/theme_editor_plugin.h34
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp781
-rw-r--r--editor/plugins/tile_map_editor_plugin.h54
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp156
-rw-r--r--editor/plugins/tile_set_editor_plugin.h27
-rw-r--r--editor/progress_dialog.cpp133
-rw-r--r--editor/progress_dialog.h43
-rw-r--r--editor/project_export.cpp453
-rw-r--r--editor/project_export.h53
-rw-r--r--editor/project_manager.cpp776
-rw-r--r--editor/project_manager.h32
-rw-r--r--editor/project_settings.cpp1070
-rw-r--r--editor/project_settings.h48
-rw-r--r--editor/property_editor.cpp3137
-rw-r--r--editor/property_editor.h164
-rw-r--r--editor/property_selector.cpp528
-rw-r--r--editor/property_selector.h32
-rw-r--r--editor/pvrtc_compress.cpp63
-rw-r--r--editor/pvrtc_compress.h1
-rw-r--r--editor/quick_open.cpp82
-rw-r--r--editor/quick_open.h19
-rw-r--r--editor/register_exporters.h1
-rw-r--r--editor/reparent_dialog.cpp45
-rw-r--r--editor/reparent_dialog.h16
-rw-r--r--editor/resources_dock.cpp216
-rw-r--r--editor/resources_dock.h39
-rw-r--r--editor/run_settings_dialog.cpp25
-rw-r--r--editor/run_settings_dialog.h15
-rw-r--r--editor/scene_tree_dock.cpp1172
-rw-r--r--editor/scene_tree_dock.h80
-rw-r--r--editor/scene_tree_editor.cpp786
-rw-r--r--editor/scene_tree_editor.h83
-rw-r--r--editor/script_create_dialog.cpp235
-rw-r--r--editor/script_create_dialog.h25
-rw-r--r--editor/script_editor_debugger.cpp1189
-rw-r--r--editor/script_editor_debugger.h70
-rw-r--r--editor/settings_config_dialog.cpp229
-rw-r--r--editor/settings_config_dialog.h19
-rw-r--r--editor/spatial_editor_gizmos.cpp2418
-rw-r--r--editor/spatial_editor_gizmos.h327
238 files changed, 26633 insertions, 32601 deletions
diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp
index d65f229fca..1a65014634 100644
--- a/editor/animation_editor.cpp
+++ b/editor/animation_editor.cpp
@@ -28,14 +28,14 @@
/*************************************************************************/
#include "animation_editor.h"
+#include "editor/plugins/animation_player_editor_plugin.h"
+#include "editor_node.h"
#include "editor_settings.h"
+#include "io/resource_saver.h"
#include "os/keyboard.h"
#include "os/os.h"
-#include "io/resource_saver.h"
#include "pair.h"
#include "scene/gui/separator.h"
-#include "editor_node.h"
-#include "editor/plugins/animation_player_editor_plugin.h"
#include "scene/main/viewport.h"
/* Missing to fix:
@@ -47,177 +47,174 @@
*when create track do undo/redo
*/
-
class AnimationCurveEdit : public Control {
- GDCLASS( AnimationCurveEdit, Control );
+ GDCLASS(AnimationCurveEdit, Control);
+
public:
enum Mode {
MODE_DISABLED,
MODE_SINGLE,
MODE_MULTIPLE
};
-private:
+private:
Set<float> multiples;
float transition;
Mode mode;
void _notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
-
+ if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
Size2 s = get_size();
- Rect2 r(Point2(),s);
+ Rect2 r(Point2(), s);
//r=r.grow(3);
- Ref<StyleBox> sb = get_stylebox("normal","LineEdit");
- sb->draw(ci,r);
- r.size-=sb->get_minimum_size();
- r.pos+=sb->get_offset();
+ Ref<StyleBox> sb = get_stylebox("normal", "LineEdit");
+ sb->draw(ci, r);
+ r.size -= sb->get_minimum_size();
+ r.pos += sb->get_offset();
//VisualServer::get_singleton()->canvas_item_add
- Ref<Font> f = get_font("font","Label");
- r=r.grow(-2);
- Color color = get_color("font_color","Label");
+ Ref<Font> f = get_font("font", "Label");
+ r = r.grow(-2);
+ Color color = get_color("font_color", "Label");
int points = 48;
- if (mode==MODE_MULTIPLE) {
+ if (mode == MODE_MULTIPLE) {
- Color mcolor=color;
- mcolor.a*=0.3;
+ Color mcolor = color;
+ mcolor.a *= 0.3;
- Set<float>::Element *E=multiples.front();
- for(int j=0;j<16;j++) {
+ Set<float>::Element *E = multiples.front();
+ for (int j = 0; j < 16; j++) {
if (!E)
break;
- float prev=1.0;
- float exp=E->get();
- bool flip=false;//hint_text=="attenuation";
+ float prev = 1.0;
+ float exp = E->get();
+ bool flip = false; //hint_text=="attenuation";
+ for (int i = 1; i <= points; i++) {
- for(int i=1;i<=points;i++) {
+ float ifl = i / float(points);
+ float iflp = (i - 1) / float(points);
- float ifl = i/float(points);
- float iflp = (i-1)/float(points);
-
- float h = 1.0-Math::ease(ifl,exp);
+ float h = 1.0 - Math::ease(ifl, exp);
if (flip) {
- ifl=1.0-ifl;
- iflp=1.0-iflp;
+ ifl = 1.0 - ifl;
+ iflp = 1.0 - iflp;
}
- VisualServer::get_singleton()->canvas_item_add_line(ci,r.pos+Point2(iflp*r.size.width,prev*r.size.height),r.pos+Point2(ifl*r.size.width,h*r.size.height),mcolor);
- prev=h;
+ VisualServer::get_singleton()->canvas_item_add_line(ci, r.pos + Point2(iflp * r.size.width, prev * r.size.height), r.pos + Point2(ifl * r.size.width, h * r.size.height), mcolor);
+ prev = h;
}
- E=E->next();
+ E = E->next();
}
}
- float exp=transition;
- if (mode!=MODE_DISABLED) {
-
-
- float prev=1.0;
+ float exp = transition;
+ if (mode != MODE_DISABLED) {
- bool flip=false;//hint_text=="attenuation";
+ float prev = 1.0;
+ bool flip = false; //hint_text=="attenuation";
- for(int i=1;i<=points;i++) {
+ for (int i = 1; i <= points; i++) {
- float ifl = i/float(points);
- float iflp = (i-1)/float(points);
+ float ifl = i / float(points);
+ float iflp = (i - 1) / float(points);
- float h = 1.0-Math::ease(ifl,exp);
+ float h = 1.0 - Math::ease(ifl, exp);
if (flip) {
- ifl=1.0-ifl;
- iflp=1.0-iflp;
+ ifl = 1.0 - ifl;
+ iflp = 1.0 - iflp;
}
- VisualServer::get_singleton()->canvas_item_add_line(ci,r.pos+Point2(iflp*r.size.width,prev*r.size.height),r.pos+Point2(ifl*r.size.width,h*r.size.height),color);
- prev=h;
+ VisualServer::get_singleton()->canvas_item_add_line(ci, r.pos + Point2(iflp * r.size.width, prev * r.size.height), r.pos + Point2(ifl * r.size.width, h * r.size.height), color);
+ prev = h;
}
}
- String txt=String::num(exp,2);
- if (mode==MODE_DISABLED) {
- txt=TTR("Disabled");
- } else if (mode==MODE_MULTIPLE) {
- txt+=" - "+TTR("All Selection");
+ String txt = String::num(exp, 2);
+ if (mode == MODE_DISABLED) {
+ txt = TTR("Disabled");
+ } else if (mode == MODE_MULTIPLE) {
+ txt += " - " + TTR("All Selection");
}
- f->draw(ci,Point2(10,10+f->get_ascent()),txt,color);
-
+ f->draw(ci, Point2(10, 10 + f->get_ascent()), txt, color);
}
}
- void _gui_input(const InputEvent& p_ev) {
- if (p_ev.type==InputEvent::MOUSE_MOTION && p_ev.mouse_motion.button_mask&BUTTON_MASK_LEFT) {
+ void _gui_input(const InputEvent &p_ev) {
+ if (p_ev.type == InputEvent::MOUSE_MOTION && p_ev.mouse_motion.button_mask & BUTTON_MASK_LEFT) {
- if (mode==MODE_DISABLED)
+ if (mode == MODE_DISABLED)
return;
float rel = p_ev.mouse_motion.relative_x;
- if (rel==0)
- return;
+ if (rel == 0)
+ return;
- bool flip=false;
+ bool flip = false;
if (flip)
- rel=-rel;
+ rel = -rel;
float val = transition;
- if (val==0)
+ if (val == 0)
return;
bool sg = val < 0;
val = Math::absf(val);
- val = Math::log(val)/Math::log((float)2.0);
+ val = Math::log(val) / Math::log((float)2.0);
//logspace
- val+=rel*0.05;
+ val += rel * 0.05;
//
- val = Math::pow((float)2.0,val);
+ val = Math::pow((float)2.0, val);
if (sg)
- val=-val;
+ val = -val;
- transition=val;
+ transition = val;
update();
//emit_signal("variant_changed");
- emit_signal("transition_changed",transition);
+ emit_signal("transition_changed", transition);
}
}
public:
-
static void _bind_methods() {
//ClassDB::bind_method("_update_obj",&AnimationKeyEdit::_update_obj);
- ClassDB::bind_method("_gui_input",&AnimationCurveEdit::_gui_input);
+ ClassDB::bind_method("_gui_input", &AnimationCurveEdit::_gui_input);
ADD_SIGNAL(MethodInfo("transition_changed"));
}
void set_mode(Mode p_mode) {
- mode=p_mode;
+ mode = p_mode;
update();
}
- void clear_multiples() { multiples.clear(); update();}
+ void clear_multiples() {
+ multiples.clear();
+ update();
+ }
void set_multiple(float p_transition) {
multiples.insert(p_transition);
}
void set_transition(float p_transition) {
- transition=p_transition;
+ transition = p_transition;
update();
}
@@ -226,341 +223,318 @@ public:
}
void force_transition(float p_value) {
- if (mode==MODE_DISABLED)
+ if (mode == MODE_DISABLED)
return;
- transition=p_value;
- emit_signal("transition_changed",p_value);
+ transition = p_value;
+ emit_signal("transition_changed", p_value);
update();
}
AnimationCurveEdit() {
- transition=1.0;
+ transition = 1.0;
set_default_cursor_shape(CURSOR_HSPLIT);
- mode=MODE_DISABLED;
+ mode = MODE_DISABLED;
}
-
};
class AnimationKeyEdit : public Object {
- GDCLASS(AnimationKeyEdit,Object);
+ GDCLASS(AnimationKeyEdit, Object);
+
public:
bool setting;
bool hidden;
static void _bind_methods() {
- ClassDB::bind_method("_update_obj",&AnimationKeyEdit::_update_obj);
- ClassDB::bind_method("_key_ofs_changed",&AnimationKeyEdit::_key_ofs_changed);
+ ClassDB::bind_method("_update_obj", &AnimationKeyEdit::_update_obj);
+ ClassDB::bind_method("_key_ofs_changed", &AnimationKeyEdit::_key_ofs_changed);
}
//PopupDialog *ke_dialog;
void _fix_node_path(Variant &value) {
+ NodePath np = value;
- NodePath np=value;
-
- if (np==NodePath())
+ if (np == NodePath())
return;
- Node* root = EditorNode::get_singleton()->get_tree()->get_root();
+ Node *root = EditorNode::get_singleton()->get_tree()->get_root();
- Node* np_node = root->get_node(np);
+ Node *np_node = root->get_node(np);
ERR_FAIL_COND(!np_node);
- Node* edited_node = root->get_node(base);
+ Node *edited_node = root->get_node(base);
ERR_FAIL_COND(!edited_node);
-
-
value = edited_node->get_path_to(np_node);
}
-
void _update_obj(const Ref<Animation> &p_anim) {
if (setting)
return;
if (hidden)
return;
- if (!(animation==p_anim))
+ if (!(animation == p_anim))
return;
notify_change();
}
- void _key_ofs_changed(const Ref<Animation> &p_anim,float from, float to) {
+ void _key_ofs_changed(const Ref<Animation> &p_anim, float from, float to) {
if (hidden)
return;
- if (!(animation==p_anim))
+ if (!(animation == p_anim))
return;
- if (from!=key_ofs)
+ if (from != key_ofs)
return;
- key_ofs=to;
+ key_ofs = to;
if (setting)
return;
notify_change();
}
- bool _set(const StringName& p_name, const Variant& p_value) {
+ bool _set(const StringName &p_name, const Variant &p_value) {
- int key = animation->track_find_key(track,key_ofs,true);
- ERR_FAIL_COND_V(key==-1,false);
+ int key = animation->track_find_key(track, key_ofs, true);
+ ERR_FAIL_COND_V(key == -1, false);
- String name=p_name;
- if (name=="time") {
+ String name = p_name;
+ if (name == "time") {
float new_time = p_value;
- if (new_time==key_ofs)
+ if (new_time == key_ofs)
return true;
- int existing = animation->track_find_key(track,new_time,true);
-
- setting=true;
- undo_redo->create_action(TTR("Move Add Key"),UndoRedo::MERGE_ENDS);
+ int existing = animation->track_find_key(track, new_time, true);
- Variant val = animation->track_get_key_value(track,key);
- float trans = animation->track_get_key_transition(track,key);
+ setting = true;
+ undo_redo->create_action(TTR("Move Add Key"), UndoRedo::MERGE_ENDS);
- undo_redo->add_do_method(animation.ptr(),"track_remove_key",track,key);
- undo_redo->add_do_method(animation.ptr(),"track_insert_key",track,new_time,val,trans);
- undo_redo->add_do_method(this,"_key_ofs_changed",animation,key_ofs,new_time);
- undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",track,new_time);
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",track,key_ofs,val,trans);
- undo_redo->add_undo_method(this,"_key_ofs_changed",animation,new_time,key_ofs);
+ Variant val = animation->track_get_key_value(track, key);
+ float trans = animation->track_get_key_transition(track, key);
+ undo_redo->add_do_method(animation.ptr(), "track_remove_key", track, key);
+ undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, new_time, val, trans);
+ undo_redo->add_do_method(this, "_key_ofs_changed", animation, key_ofs, new_time);
+ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_pos", track, new_time);
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, key_ofs, val, trans);
+ undo_redo->add_undo_method(this, "_key_ofs_changed", animation, new_time, key_ofs);
- if (existing!=-1) {
- Variant v = animation->track_get_key_value(track,existing);
- float trans = animation->track_get_key_transition(track,existing);
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",track,new_time,v,trans);
+ if (existing != -1) {
+ Variant v = animation->track_get_key_value(track, existing);
+ float trans = animation->track_get_key_transition(track, existing);
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, new_time, v, trans);
}
undo_redo->commit_action();
- setting=false;
+ setting = false;
return true;
- } else if (name=="easing") {
+ } else if (name == "easing") {
float val = p_value;
- float prev_val = animation->track_get_key_transition(track,key);
- setting=true;
- undo_redo->create_action(TTR("Anim Change Transition"),UndoRedo::MERGE_ENDS);
- undo_redo->add_do_method(animation.ptr(),"track_set_key_transition",track,key,val);
- undo_redo->add_undo_method(animation.ptr(),"track_set_key_transition",track,key,prev_val);
- undo_redo->add_do_method(this,"_update_obj",animation);
- undo_redo->add_undo_method(this,"_update_obj",animation);
+ float prev_val = animation->track_get_key_transition(track, key);
+ setting = true;
+ undo_redo->create_action(TTR("Anim Change Transition"), UndoRedo::MERGE_ENDS);
+ undo_redo->add_do_method(animation.ptr(), "track_set_key_transition", track, key, val);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_key_transition", track, key, prev_val);
+ undo_redo->add_do_method(this, "_update_obj", animation);
+ undo_redo->add_undo_method(this, "_update_obj", animation);
undo_redo->commit_action();
- setting=false;
+ setting = false;
return true;
}
-
-
- switch(animation->track_get_type(track)) {
-
+ switch (animation->track_get_type(track)) {
case Animation::TYPE_TRANSFORM: {
- Dictionary d_old = animation->track_get_key_value(track,key);
+ Dictionary d_old = animation->track_get_key_value(track, key);
Dictionary d_new = d_old;
- d_new[p_name]=p_value;
- setting=true;
+ d_new[p_name] = p_value;
+ setting = true;
undo_redo->create_action(TTR("Anim Change Transform"));
- undo_redo->add_do_method(animation.ptr(),"track_set_key_value",track,key,d_new);
- undo_redo->add_undo_method(animation.ptr(),"track_set_key_value",track,key,d_old);
- undo_redo->add_do_method(this,"_update_obj",animation);
- undo_redo->add_undo_method(this,"_update_obj",animation);
+ undo_redo->add_do_method(animation.ptr(), "track_set_key_value", track, key, d_new);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_key_value", track, key, d_old);
+ undo_redo->add_do_method(this, "_update_obj", animation);
+ undo_redo->add_undo_method(this, "_update_obj", animation);
undo_redo->commit_action();
- setting=false;
+ setting = false;
return true;
} break;
case Animation::TYPE_VALUE: {
- if (name=="value") {
+ if (name == "value") {
Variant value = p_value;
- if (value.get_type()==Variant::NODE_PATH) {
+ if (value.get_type() == Variant::NODE_PATH) {
_fix_node_path(value);
}
- setting=true;
- undo_redo->create_action(TTR("Anim Change Value"),UndoRedo::MERGE_ENDS);
- Variant prev = animation->track_get_key_value(track,key);
- undo_redo->add_do_method(animation.ptr(),"track_set_key_value",track,key,value);
- undo_redo->add_undo_method(animation.ptr(),"track_set_key_value",track,key,prev);
- undo_redo->add_do_method(this,"_update_obj",animation);
- undo_redo->add_undo_method(this,"_update_obj",animation);
+ setting = true;
+ undo_redo->create_action(TTR("Anim Change Value"), UndoRedo::MERGE_ENDS);
+ Variant prev = animation->track_get_key_value(track, key);
+ undo_redo->add_do_method(animation.ptr(), "track_set_key_value", track, key, value);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_key_value", track, key, prev);
+ undo_redo->add_do_method(this, "_update_obj", animation);
+ undo_redo->add_undo_method(this, "_update_obj", animation);
undo_redo->commit_action();
- setting=false;
+ setting = false;
return true;
}
-
-
} break;
case Animation::TYPE_METHOD: {
- Dictionary d_old = animation->track_get_key_value(track,key);
+ Dictionary d_old = animation->track_get_key_value(track, key);
Dictionary d_new = d_old;
- bool change_notify_deserved=false;
- bool mergeable=false;
+ bool change_notify_deserved = false;
+ bool mergeable = false;
- if (name=="name") {
-
- d_new["method"]=p_value;
+ if (name == "name") {
+ d_new["method"] = p_value;
}
- if (name=="arg_count") {
+ if (name == "arg_count") {
Vector<Variant> args = d_old["args"];
args.resize(p_value);
- d_new["args"]=args;
- change_notify_deserved=true;
+ d_new["args"] = args;
+ change_notify_deserved = true;
}
if (name.begins_with("args/")) {
-
Vector<Variant> args = d_old["args"];
- int idx = name.get_slice("/",1).to_int();
- ERR_FAIL_INDEX_V(idx,args.size(),false);
+ int idx = name.get_slice("/", 1).to_int();
+ ERR_FAIL_INDEX_V(idx, args.size(), false);
- String what = name.get_slice("/",2);
- if (what=="type") {
+ String what = name.get_slice("/", 2);
+ if (what == "type") {
Variant::Type t = Variant::Type(int(p_value));
- if (t!=args[idx].get_type()) {
+ if (t != args[idx].get_type()) {
Variant::CallError err;
- if (Variant::can_convert(args[idx].get_type(),t)) {
- Variant old=args[idx];
- Variant *ptrs[1]={&old};
- args[idx]=Variant::construct(t,(const Variant**)ptrs,1,err);
+ if (Variant::can_convert(args[idx].get_type(), t)) {
+ Variant old = args[idx];
+ Variant *ptrs[1] = { &old };
+ args[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err);
} else {
- args[idx]=Variant::construct(t,NULL,0,err);
+ args[idx] = Variant::construct(t, NULL, 0, err);
}
- change_notify_deserved=true;
- d_new["args"]=args;
+ change_notify_deserved = true;
+ d_new["args"] = args;
}
-
}
- if (what=="value") {
+ if (what == "value") {
- Variant value=p_value;
- if (value.get_type()==Variant::NODE_PATH) {
+ Variant value = p_value;
+ if (value.get_type() == Variant::NODE_PATH) {
_fix_node_path(value);
}
- args[idx]=value;
- d_new["args"]=args;
- mergeable=true;
+ args[idx] = value;
+ d_new["args"] = args;
+ mergeable = true;
}
}
if (mergeable)
- undo_redo->create_action(TTR("Anim Change Call"),UndoRedo::MERGE_ENDS);
+ undo_redo->create_action(TTR("Anim Change Call"), UndoRedo::MERGE_ENDS);
else
undo_redo->create_action(TTR("Anim Change Call"));
- Variant prev = animation->track_get_key_value(track,key);
- setting=true;
- undo_redo->add_do_method(animation.ptr(),"track_set_key_value",track,key,d_new);
- undo_redo->add_undo_method(animation.ptr(),"track_set_key_value",track,key,d_old);
- undo_redo->add_do_method(this,"_update_obj",animation);
- undo_redo->add_undo_method(this,"_update_obj",animation);
+ Variant prev = animation->track_get_key_value(track, key);
+ setting = true;
+ undo_redo->add_do_method(animation.ptr(), "track_set_key_value", track, key, d_new);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_key_value", track, key, d_old);
+ undo_redo->add_do_method(this, "_update_obj", animation);
+ undo_redo->add_undo_method(this, "_update_obj", animation);
undo_redo->commit_action();
- setting=false;
+ setting = false;
if (change_notify_deserved)
notify_change();
return true;
} break;
}
-
-
return false;
-
}
- bool _get(const StringName& p_name,Variant &r_ret) const {
+ bool _get(const StringName &p_name, Variant &r_ret) const {
- int key = animation->track_find_key(track,key_ofs,true);
- ERR_FAIL_COND_V(key==-1,false);
+ int key = animation->track_find_key(track, key_ofs, true);
+ ERR_FAIL_COND_V(key == -1, false);
- String name=p_name;
- if (name=="time") {
+ String name = p_name;
+ if (name == "time") {
r_ret = key_ofs;
return true;
- } else if (name=="easing") {
- r_ret = animation->track_get_key_transition(track,key);
+ } else if (name == "easing") {
+ r_ret = animation->track_get_key_transition(track, key);
return true;
}
-
-
- switch(animation->track_get_type(track)) {
-
+ switch (animation->track_get_type(track)) {
case Animation::TYPE_TRANSFORM: {
- Dictionary d = animation->track_get_key_value(track,key);
- ERR_FAIL_COND_V(!d.has(name),false);
+ Dictionary d = animation->track_get_key_value(track, key);
+ ERR_FAIL_COND_V(!d.has(name), false);
r_ret = d[p_name];
return true;
} break;
case Animation::TYPE_VALUE: {
- if (name=="value") {
- r_ret = animation->track_get_key_value(track,key);
+ if (name == "value") {
+ r_ret = animation->track_get_key_value(track, key);
return true;
}
-
-
} break;
case Animation::TYPE_METHOD: {
- Dictionary d = animation->track_get_key_value(track,key);
+ Dictionary d = animation->track_get_key_value(track, key);
- if (name=="name") {
+ if (name == "name") {
- ERR_FAIL_COND_V(!d.has("method"),false);
- r_ret=d["method"];
+ ERR_FAIL_COND_V(!d.has("method"), false);
+ r_ret = d["method"];
return true;
}
- ERR_FAIL_COND_V(!d.has("args"),false);
+ ERR_FAIL_COND_V(!d.has("args"), false);
Vector<Variant> args = d["args"];
+ if (name == "arg_count") {
- if (name=="arg_count") {
-
- r_ret=args.size();
+ r_ret = args.size();
return true;
}
-
if (name.begins_with("args/")) {
- int idx = name.get_slice("/",1).to_int();
- ERR_FAIL_INDEX_V(idx,args.size(),false);
+ int idx = name.get_slice("/", 1).to_int();
+ ERR_FAIL_INDEX_V(idx, args.size(), false);
- String what = name.get_slice("/",2);
- if (what=="type") {
- r_ret=args[idx].get_type();
+ String what = name.get_slice("/", 2);
+ if (what == "type") {
+ r_ret = args[idx].get_type();
return true;
}
- if (what=="value") {
- r_ret=args[idx];
+ if (what == "value") {
+ r_ret = args[idx];
return true;
}
}
@@ -570,79 +544,76 @@ public:
return false;
}
- void _get_property_list( List<PropertyInfo> *p_list) const {
+ void _get_property_list(List<PropertyInfo> *p_list) const {
if (animation.is_null())
return;
- ERR_FAIL_INDEX(track,animation->get_track_count());
- int key = animation->track_find_key(track,key_ofs,true);
- ERR_FAIL_COND(key==-1);
+ ERR_FAIL_INDEX(track, animation->get_track_count());
+ int key = animation->track_find_key(track, key_ofs, true);
+ ERR_FAIL_COND(key == -1);
- p_list->push_back( PropertyInfo( Variant::REAL, "time", PROPERTY_HINT_RANGE,"0,"+rtos(animation->get_length())+",0.01") );
-
- switch(animation->track_get_type(track)) {
+ p_list->push_back(PropertyInfo(Variant::REAL, "time", PROPERTY_HINT_RANGE, "0," + rtos(animation->get_length()) + ",0.01"));
+ switch (animation->track_get_type(track)) {
case Animation::TYPE_TRANSFORM: {
- p_list->push_back( PropertyInfo( Variant::VECTOR3, "loc"));
- p_list->push_back( PropertyInfo( Variant::QUAT, "rot"));
- p_list->push_back( PropertyInfo( Variant::VECTOR3, "scale"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR3, "loc"));
+ p_list->push_back(PropertyInfo(Variant::QUAT, "rot"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale"));
} break;
case Animation::TYPE_VALUE: {
- Variant v = animation->track_get_key_value(track,key);
-
+ Variant v = animation->track_get_key_value(track, key);
+ if (hint.type != Variant::NIL) {
- if (hint.type!=Variant::NIL) {
-
- PropertyInfo pi=hint;
- pi.name="value";
- p_list->push_back( pi );
+ PropertyInfo pi = hint;
+ pi.name = "value";
+ p_list->push_back(pi);
} else {
- PropertyHint hint= PROPERTY_HINT_NONE;
+ PropertyHint hint = PROPERTY_HINT_NONE;
String hint_string;
- if (v.get_type()==Variant::OBJECT) {
+ if (v.get_type() == Variant::OBJECT) {
//could actually check the object property if exists..? yes i will!
Ref<Resource> res = v;
if (res.is_valid()) {
- hint=PROPERTY_HINT_RESOURCE_TYPE;
- hint_string=res->get_class();
+ hint = PROPERTY_HINT_RESOURCE_TYPE;
+ hint_string = res->get_class();
}
}
- if (v.get_type()!=Variant::NIL)
- p_list->push_back( PropertyInfo( v.get_type(), "value", hint,hint_string));
+ if (v.get_type() != Variant::NIL)
+ p_list->push_back(PropertyInfo(v.get_type(), "value", hint, hint_string));
}
} break;
case Animation::TYPE_METHOD: {
- p_list->push_back( PropertyInfo( Variant::STRING, "name"));
- p_list->push_back( PropertyInfo( Variant::INT, "arg_count",PROPERTY_HINT_RANGE,"0,5,1"));
+ p_list->push_back(PropertyInfo(Variant::STRING, "name"));
+ p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,5,1"));
- Dictionary d = animation->track_get_key_value(track,key);
+ Dictionary d = animation->track_get_key_value(track, key);
ERR_FAIL_COND(!d.has("args"));
- Vector<Variant> args=d["args"];
+ Vector<Variant> args = d["args"];
String vtypes;
- for(int i=0;i<Variant::VARIANT_MAX;i++) {
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- if (i>0)
- vtypes+=",";
- vtypes+=Variant::get_type_name( Variant::Type(i) );
+ if (i > 0)
+ vtypes += ",";
+ vtypes += Variant::get_type_name(Variant::Type(i));
}
- for(int i=0;i<args.size();i++) {
+ for (int i = 0; i < args.size(); i++) {
- p_list->push_back( PropertyInfo( Variant::INT, "args/"+itos(i)+"/type", PROPERTY_HINT_ENUM,vtypes));
- if (args[i].get_type()!=Variant::NIL)
- p_list->push_back( PropertyInfo( args[i].get_type(), "args/"+itos(i)+"/value"));
+ p_list->push_back(PropertyInfo(Variant::INT, "args/" + itos(i) + "/type", PROPERTY_HINT_ENUM, vtypes));
+ if (args[i].get_type() != Variant::NIL)
+ p_list->push_back(PropertyInfo(args[i].get_type(), "args/" + itos(i) + "/value"));
}
} break;
@@ -662,23 +633,24 @@ public:
PropertyInfo hint;
NodePath base;
-
void notify_change() {
_change_notify();
}
- AnimationKeyEdit() { hidden=true; key_ofs=0; track=-1; setting=false; }
-
+ AnimationKeyEdit() {
+ hidden = true;
+ key_ofs = 0;
+ track = -1;
+ setting = false;
+ }
};
-
void AnimationKeyEditor::_menu_add_track(int p_type) {
ERR_FAIL_COND(!animation.is_valid());
-
- switch(p_type) {
+ switch (p_type) {
case ADD_TRACK_MENU_ADD_CALL_TRACK: {
if (root) {
@@ -690,34 +662,32 @@ void AnimationKeyEditor::_menu_add_track(int p_type) {
case ADD_TRACK_MENU_ADD_TRANSFORM_TRACK: {
undo_redo->create_action(TTR("Anim Add Track"));
- undo_redo->add_do_method(animation.ptr(),"add_track",p_type);
- undo_redo->add_do_method(animation.ptr(),"track_set_path",animation->get_track_count(),".");
- undo_redo->add_undo_method(animation.ptr(),"remove_track",animation->get_track_count());
+ undo_redo->add_do_method(animation.ptr(), "add_track", p_type);
+ undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), ".");
+ undo_redo->add_undo_method(animation.ptr(), "remove_track", animation->get_track_count());
undo_redo->commit_action();
-
} break;
}
}
void AnimationKeyEditor::_anim_duplicate_keys(bool transpose) {
//duplicait!
- if (selection.size() && animation.is_valid() && selected_track>=0 && selected_track<animation->get_track_count()) {
+ if (selection.size() && animation.is_valid() && selected_track >= 0 && selected_track < animation->get_track_count()) {
- int top_track=0x7FFFFFFF;
+ int top_track = 0x7FFFFFFF;
float top_time = 1e10;
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
const SelectedKey &sk = E->key();
- float t = animation->track_get_key_time(sk.track,sk.key);
- if (t<top_time)
- top_time=t;
- if (sk.track<top_track)
- top_track=sk.track;
-
+ float t = animation->track_get_key_time(sk.track, sk.key);
+ if (t < top_time)
+ top_time = t;
+ if (sk.track < top_track)
+ top_track = sk.track;
}
- ERR_FAIL_COND( top_track == 0x7FFFFFFF || top_time==1e10 );
+ ERR_FAIL_COND(top_track == 0x7FFFFFFF || top_time == 1e10);
//
@@ -725,71 +695,66 @@ void AnimationKeyEditor::_anim_duplicate_keys(bool transpose) {
undo_redo->create_action(TTR("Anim Duplicate Keys"));
- List<Pair<int,float> > new_selection_values;
+ List<Pair<int, float> > new_selection_values;
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
const SelectedKey &sk = E->key();
- float t = animation->track_get_key_time(sk.track,sk.key);
+ float t = animation->track_get_key_time(sk.track, sk.key);
- float dst_time = t+(timeline_pos - top_time);
+ float dst_time = t + (timeline_pos - top_time);
int dst_track = sk.track + (start_track - top_track);
- if (dst_track < 0 || dst_track>= animation->get_track_count())
+ if (dst_track < 0 || dst_track >= animation->get_track_count())
continue;
if (animation->track_get_type(dst_track) != animation->track_get_type(sk.track))
continue;
- int existing_idx = animation->track_find_key(dst_track,dst_time,true);
-
- undo_redo->add_do_method(animation.ptr(),"track_insert_key",dst_track,dst_time,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key));
- undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",dst_track,dst_time);
+ int existing_idx = animation->track_find_key(dst_track, dst_time, true);
- Pair<int,float> p;
- p.first=dst_track;
- p.second=dst_time;
- new_selection_values.push_back( p );
+ undo_redo->add_do_method(animation.ptr(), "track_insert_key", dst_track, dst_time, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
+ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_pos", dst_track, dst_time);
- if (existing_idx!=-1) {
+ Pair<int, float> p;
+ p.first = dst_track;
+ p.second = dst_time;
+ new_selection_values.push_back(p);
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",dst_track,dst_time,animation->track_get_key_value(dst_track,existing_idx),animation->track_get_key_transition(dst_track,existing_idx));
+ if (existing_idx != -1) {
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", dst_track, dst_time, animation->track_get_key_value(dst_track, existing_idx), animation->track_get_key_transition(dst_track, existing_idx));
}
-
}
undo_redo->commit_action();
//reselect duplicated
- Map<SelectedKey,KeyInfo> new_selection;
- for (List<Pair<int,float> >::Element *E=new_selection_values.front();E;E=E->next()) {
+ Map<SelectedKey, KeyInfo> new_selection;
+ for (List<Pair<int, float> >::Element *E = new_selection_values.front(); E; E = E->next()) {
- int track=E->get().first;
+ int track = E->get().first;
float time = E->get().second;
- int existing_idx = animation->track_find_key(track,time,true);
+ int existing_idx = animation->track_find_key(track, time, true);
- if (existing_idx==-1)
+ if (existing_idx == -1)
continue;
SelectedKey sk2;
- sk2.track=track;
- sk2.key=existing_idx;
+ sk2.track = track;
+ sk2.key = existing_idx;
KeyInfo ki;
- ki.pos=time;
-
- new_selection[sk2]=ki;
+ ki.pos = time;
+ new_selection[sk2] = ki;
}
-
- selection=new_selection;
+ selection = new_selection;
track_editor->update();
_edit_if_single_selection();
-
}
}
@@ -797,74 +762,70 @@ void AnimationKeyEditor::_menu_track(int p_type) {
ERR_FAIL_COND(!animation.is_valid());
- last_menu_track_opt=p_type;
- switch(p_type) {
+ last_menu_track_opt = p_type;
+ switch (p_type) {
case TRACK_MENU_SCALE:
case TRACK_MENU_SCALE_PIVOT: {
- scale_dialog->popup_centered(Size2(200,100));
+ scale_dialog->popup_centered(Size2(200, 100));
} break;
case TRACK_MENU_MOVE_UP: {
- int idx=selected_track;
- if (idx>0 && idx<animation->get_track_count()) {
+ int idx = selected_track;
+ if (idx > 0 && idx < animation->get_track_count()) {
undo_redo->create_action(TTR("Move Anim Track Up"));
- undo_redo->add_do_method(animation.ptr(),"track_move_down",idx);
- undo_redo->add_undo_method(animation.ptr(),"track_move_up",idx-1);
+ undo_redo->add_do_method(animation.ptr(), "track_move_down", idx);
+ undo_redo->add_undo_method(animation.ptr(), "track_move_up", idx - 1);
undo_redo->commit_action();
- selected_track=idx-1;
+ selected_track = idx - 1;
}
} break;
case TRACK_MENU_MOVE_DOWN: {
-
- int idx=selected_track;
- if (idx>=0 && idx<animation->get_track_count()-1) {
+ int idx = selected_track;
+ if (idx >= 0 && idx < animation->get_track_count() - 1) {
undo_redo->create_action(TTR("Move Anim Track Down"));
- undo_redo->add_do_method(animation.ptr(),"track_move_up",idx);
- undo_redo->add_undo_method(animation.ptr(),"track_move_down",idx+1);
+ undo_redo->add_do_method(animation.ptr(), "track_move_up", idx);
+ undo_redo->add_undo_method(animation.ptr(), "track_move_down", idx + 1);
undo_redo->commit_action();
- selected_track=idx+1;
+ selected_track = idx + 1;
}
} break;
case TRACK_MENU_REMOVE: {
- int idx=selected_track;
- if (idx>=0 && idx<animation->get_track_count()) {
+ int idx = selected_track;
+ if (idx >= 0 && idx < animation->get_track_count()) {
undo_redo->create_action(TTR("Remove Anim Track"));
- undo_redo->add_do_method(animation.ptr(),"remove_track",idx);
- undo_redo->add_undo_method(animation.ptr(),"add_track",animation->track_get_type(idx),idx);
- undo_redo->add_undo_method(animation.ptr(),"track_set_path",idx,animation->track_get_path(idx));
+ undo_redo->add_do_method(animation.ptr(), "remove_track", idx);
+ undo_redo->add_undo_method(animation.ptr(), "add_track", animation->track_get_type(idx), idx);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_path", idx, animation->track_get_path(idx));
//todo interpolation
- for(int i=0;i<animation->track_get_key_count(idx);i++) {
+ for (int i = 0; i < animation->track_get_key_count(idx); i++) {
- Variant v = animation->track_get_key_value(idx,i);
- float time = animation->track_get_key_time(idx,i);
- float trans = animation->track_get_key_transition(idx,i);
-
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",idx,time,v);
- undo_redo->add_undo_method(animation.ptr(),"track_set_key_transition",idx,i,trans);
+ Variant v = animation->track_get_key_value(idx, i);
+ float time = animation->track_get_key_time(idx, i);
+ float trans = animation->track_get_key_transition(idx, i);
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", idx, time, v);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_key_transition", idx, i, trans);
}
- undo_redo->add_undo_method(animation.ptr(),"track_set_interpolation_type",idx,animation->track_get_interpolation_type(idx));
- if (animation->track_get_type(idx)==Animation::TYPE_VALUE) {
- undo_redo->add_undo_method(animation.ptr(),"value_track_set_update_mode",idx,animation->value_track_get_update_mode(idx));
-
+ undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_type", idx, animation->track_get_interpolation_type(idx));
+ if (animation->track_get_type(idx) == Animation::TYPE_VALUE) {
+ undo_redo->add_undo_method(animation.ptr(), "value_track_set_update_mode", idx, animation->value_track_get_update_mode(idx));
}
undo_redo->commit_action();
}
-
} break;
case TRACK_MENU_DUPLICATE:
case TRACK_MENU_DUPLICATE_TRANSPOSE: {
- _anim_duplicate_keys(p_type==TRACK_MENU_DUPLICATE_TRANSPOSE);
+ _anim_duplicate_keys(p_type == TRACK_MENU_DUPLICATE_TRANSPOSE);
} break;
case TRACK_MENU_SET_ALL_TRANS_LINEAR:
case TRACK_MENU_SET_ALL_TRANS_CONSTANT:
@@ -876,25 +837,24 @@ void AnimationKeyEditor::_menu_track(int p_type) {
if (!selection.size() || !animation.is_valid())
break;
- float t=0;
- switch(p_type) {
- case TRACK_MENU_SET_ALL_TRANS_LINEAR: t=1.0; break;
- case TRACK_MENU_SET_ALL_TRANS_CONSTANT: t=0.0; break;
- case TRACK_MENU_SET_ALL_TRANS_OUT: t=0.5; break;
- case TRACK_MENU_SET_ALL_TRANS_IN: t=2.0; break;
- case TRACK_MENU_SET_ALL_TRANS_INOUT: t=-0.5; break;
- case TRACK_MENU_SET_ALL_TRANS_OUTIN: t=-2.0; break;
+ float t = 0;
+ switch (p_type) {
+ case TRACK_MENU_SET_ALL_TRANS_LINEAR: t = 1.0; break;
+ case TRACK_MENU_SET_ALL_TRANS_CONSTANT: t = 0.0; break;
+ case TRACK_MENU_SET_ALL_TRANS_OUT: t = 0.5; break;
+ case TRACK_MENU_SET_ALL_TRANS_IN: t = 2.0; break;
+ case TRACK_MENU_SET_ALL_TRANS_INOUT: t = -0.5; break;
+ case TRACK_MENU_SET_ALL_TRANS_OUTIN: t = -2.0; break;
}
- undo_redo->create_action(TTR("Set Transitions to:")+" "+rtos(t));
+ undo_redo->create_action(TTR("Set Transitions to:") + " " + rtos(t));
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
const SelectedKey &sk = E->key();
- undo_redo->add_do_method(animation.ptr(),"track_set_key_transition",sk.track,sk.key,t);
- undo_redo->add_undo_method(animation.ptr(),"track_set_key_transition",sk.track,sk.key,animation->track_get_key_transition(sk.track,sk.key));
-
+ undo_redo->add_do_method(animation.ptr(), "track_set_key_transition", sk.track, sk.key, t);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_key_transition", sk.track, sk.key, animation->track_get_key_transition(sk.track, sk.key));
}
undo_redo->commit_action();
@@ -905,56 +865,54 @@ void AnimationKeyEditor::_menu_track(int p_type) {
if (animation.is_null())
break;
float step = animation->get_step();
- if (step==0)
- step=1;
+ if (step == 0)
+ step = 1;
- float pos=timeline_pos;
+ float pos = timeline_pos;
- pos=Math::stepify(pos+step,step);
- if (pos>animation->get_length())
- pos=animation->get_length();
- timeline_pos=pos;
+ pos = Math::stepify(pos + step, step);
+ if (pos > animation->get_length())
+ pos = animation->get_length();
+ timeline_pos = pos;
track_pos->update();
- emit_signal("timeline_changed",pos,true);
+ emit_signal("timeline_changed", pos, true);
} break;
case TRACK_MENU_PREV_STEP: {
if (animation.is_null())
break;
float step = animation->get_step();
- if (step==0)
- step=1;
-
- float pos=timeline_pos;
- pos=Math::stepify(pos-step,step);
- if (pos<0)
- pos=0;
- timeline_pos=pos;
+ if (step == 0)
+ step = 1;
+
+ float pos = timeline_pos;
+ pos = Math::stepify(pos - step, step);
+ if (pos < 0)
+ pos = 0;
+ timeline_pos = pos;
track_pos->update();
- emit_signal("timeline_changed",pos,true);
-
+ emit_signal("timeline_changed", pos, true);
} break;
case TRACK_MENU_OPTIMIZE: {
- optimize_dialog->popup_centered(Size2(250,180));
+ optimize_dialog->popup_centered(Size2(250, 180));
} break;
case TRACK_MENU_CLEAN_UP: {
- cleanup_dialog->popup_centered_minsize(Size2(300,0));
+ cleanup_dialog->popup_centered_minsize(Size2(300, 0));
} break;
case TRACK_MENU_CLEAN_UP_CONFIRM: {
if (cleanup_all->is_pressed()) {
List<StringName> names;
AnimationPlayerEditor::singleton->get_player()->get_animation_list(&names);
- for (List<StringName>::Element *E=names.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
_cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E->get()));
}
} else {
_cleanup_animation(animation);
-
}
} break;
case CURVE_SET_LINEAR: {
@@ -982,31 +940,28 @@ void AnimationKeyEditor::_menu_track(int p_type) {
curve_edit->force_transition(0);
} break;
-
}
-
}
void AnimationKeyEditor::_cleanup_animation(Ref<Animation> p_animation) {
+ for (int i = 0; i < p_animation->get_track_count(); i++) {
- for(int i=0;i<p_animation->get_track_count();i++) {
-
- bool prop_exists=false;
- Variant::Type valid_type=Variant::NIL;
- Object *obj=NULL;
+ bool prop_exists = false;
+ Variant::Type valid_type = Variant::NIL;
+ Object *obj = NULL;
RES res;
- Node *node = root->get_node_and_resource(p_animation->track_get_path(i),res);
+ Node *node = root->get_node_and_resource(p_animation->track_get_path(i), res);
if (res.is_valid()) {
- obj=res.ptr();
+ obj = res.ptr();
} else if (node) {
- obj=node;
+ obj = node;
}
- if (obj && p_animation->track_get_type(i)==Animation::TYPE_VALUE) {
- valid_type=obj->get_static_property_type(p_animation->track_get_path(i).get_property(),&prop_exists);
+ if (obj && p_animation->track_get_type(i) == Animation::TYPE_VALUE) {
+ valid_type = obj->get_static_property_type(p_animation->track_get_path(i).get_property(), &prop_exists);
}
if (!obj && cleanup_tracks->is_pressed()) {
@@ -1016,20 +971,20 @@ void AnimationKeyEditor::_cleanup_animation(Ref<Animation> p_animation) {
continue;
}
- if (!prop_exists || p_animation->track_get_type(i)!=Animation::TYPE_VALUE || cleanup_keys->is_pressed()==false)
+ if (!prop_exists || p_animation->track_get_type(i) != Animation::TYPE_VALUE || cleanup_keys->is_pressed() == false)
continue;
- for(int j=0;j<p_animation->track_get_key_count(i);j++) {
+ for (int j = 0; j < p_animation->track_get_key_count(i); j++) {
- Variant v = p_animation->track_get_key_value(i,j);
+ Variant v = p_animation->track_get_key_value(i, j);
- if (!Variant::can_convert(v.get_type(),valid_type)) {
- p_animation->track_remove_key(i,j);
+ if (!Variant::can_convert(v.get_type(), valid_type)) {
+ p_animation->track_remove_key(i, j);
j--;
}
}
- if (p_animation->track_get_key_count(i)==0 && cleanup_tracks->is_pressed()) {
+ if (p_animation->track_get_key_count(i) == 0 && cleanup_tracks->is_pressed()) {
p_animation->remove_track(i);
i--;
}
@@ -1039,25 +994,21 @@ void AnimationKeyEditor::_cleanup_animation(Ref<Animation> p_animation) {
_update_paths();
}
-void AnimationKeyEditor::_animation_optimize() {
-
+void AnimationKeyEditor::_animation_optimize() {
-
- animation->optimize(optimize_linear_error->get_value(),optimize_angular_error->get_value(),optimize_max_angle->get_value());
+ animation->optimize(optimize_linear_error->get_value(), optimize_angular_error->get_value(), optimize_max_angle->get_value());
track_editor->update();
undo_redo->clear_history();
-
}
-
float AnimationKeyEditor::_get_zoom_scale() const {
float zv = zoom->get_value();
- if (zv<1) {
- zv = 1.0-zv;
- return Math::pow(1.0f+zv,8.0f)*100;
+ if (zv < 1) {
+ zv = 1.0 - zv;
+ return Math::pow(1.0f + zv, 8.0f) * 100;
} else {
- return 1.0/Math::pow(zv,8.0f)*100;
+ return 1.0 / Math::pow(zv, 8.0f) * 100;
}
}
@@ -1067,47 +1018,42 @@ void AnimationKeyEditor::_track_pos_draw() {
return;
}
-
- Ref<StyleBox> style = get_stylebox("normal","TextEdit");
- Size2 size= track_editor->get_size() - style->get_minimum_size();
+ Ref<StyleBox> style = get_stylebox("normal", "TextEdit");
+ Size2 size = track_editor->get_size() - style->get_minimum_size();
Size2 ofs = style->get_offset();
int settings_limit = size.width - right_data_size_cache;
int name_limit = settings_limit * name_column_ratio;
- float keys_from= h_scroll->get_value();
+ float keys_from = h_scroll->get_value();
float zoom_scale = _get_zoom_scale();
- float keys_to=keys_from+(settings_limit-name_limit) / zoom_scale;
-
-
+ float keys_to = keys_from + (settings_limit - name_limit) / zoom_scale;
//will move to separate control! (for speedup)
- if (timeline_pos >= keys_from && timeline_pos<keys_to) {
+ if (timeline_pos >= keys_from && timeline_pos < keys_to) {
//draw position
int pixel = (timeline_pos - h_scroll->get_value()) * zoom_scale;
- pixel+=name_limit;
- track_pos->draw_line(ofs+Point2(pixel,0),ofs+Point2(pixel,size.height),Color(1,0.3,0.3,0.8));
-
+ pixel += name_limit;
+ track_pos->draw_line(ofs + Point2(pixel, 0), ofs + Point2(pixel, size.height), Color(1, 0.3, 0.3, 0.8));
}
}
void AnimationKeyEditor::_track_editor_draw() {
-
if (animation.is_valid() && animation->get_track_count()) {
if (selected_track < 0)
- selected_track=0;
- else if (selected_track>=animation->get_track_count())
- selected_track=animation->get_track_count()-1;
+ selected_track = 0;
+ else if (selected_track >= animation->get_track_count())
+ selected_track = animation->get_track_count() - 1;
}
track_pos->update();
- Control *te=track_editor;
- Ref<StyleBox> style = get_stylebox("normal","TextEdit");
- te->draw_style_box(style,Rect2(Point2(),track_editor->get_size()));
+ Control *te = track_editor;
+ Ref<StyleBox> style = get_stylebox("normal", "TextEdit");
+ te->draw_style_box(style, Rect2(Point2(), track_editor->get_size()));
if (te->has_focus()) {
- te->draw_style_box(get_stylebox("bg_focus","Tree"),Rect2(Point2(),track_editor->get_size()));
+ te->draw_style_box(get_stylebox("bg_focus", "Tree"), Rect2(Point2(), track_editor->get_size()));
}
if (!animation.is_valid()) {
@@ -1133,289 +1079,267 @@ void AnimationKeyEditor::_track_editor_draw() {
if (edit_button->is_pressed())
key_editor_tab->show();
- te_drawing=true;
+ te_drawing = true;
- Size2 size= te->get_size() - style->get_minimum_size();
+ Size2 size = te->get_size() - style->get_minimum_size();
Size2 ofs = style->get_offset();
- Ref<Font> font = te->get_font("font","Tree");
- int sep = get_constant("vseparation","Tree");
- int hsep = get_constant("hseparation","Tree");
- Color color = get_color("font_color","Tree");
- Color sepcolor = get_color("guide_color","Tree");
- Color timecolor = get_color("prop_subsection","Editor");
+ Ref<Font> font = te->get_font("font", "Tree");
+ int sep = get_constant("vseparation", "Tree");
+ int hsep = get_constant("hseparation", "Tree");
+ Color color = get_color("font_color", "Tree");
+ Color sepcolor = get_color("guide_color", "Tree");
+ Color timecolor = get_color("prop_subsection", "Editor");
timecolor = Color::html("ff4a414f");
- Color hover_color = Color(1,1,1,0.05);
- Color select_color = Color(1,1,1,0.1);
- Color invalid_path_color = Color(1,0.6,0.4,0.5);
- Color track_select_color =Color::html("ffbd8e8e");
-
- Ref<Texture> remove_icon = get_icon("Remove","EditorIcons");
- Ref<Texture> move_up_icon = get_icon("MoveUp","EditorIcons");
- Ref<Texture> move_down_icon = get_icon("MoveDown","EditorIcons");
- Ref<Texture> remove_icon_hl = get_icon("RemoveHl","EditorIcons");
- Ref<Texture> move_up_icon_hl = get_icon("MoveUpHl","EditorIcons");
- Ref<Texture> move_down_icon_hl = get_icon("MoveDownHl","EditorIcons");
- Ref<Texture> add_key_icon = get_icon("TrackAddKey","EditorIcons");
- Ref<Texture> add_key_icon_hl = get_icon("TrackAddKeyHl","EditorIcons");
- Ref<Texture> down_icon = get_icon("select_arrow","Tree");
-
- Ref<Texture> wrap_icon[2]={
- get_icon("InterpWrapClamp","EditorIcons"),
- get_icon("InterpWrapLoop","EditorIcons"),
+ Color hover_color = Color(1, 1, 1, 0.05);
+ Color select_color = Color(1, 1, 1, 0.1);
+ Color invalid_path_color = Color(1, 0.6, 0.4, 0.5);
+ Color track_select_color = Color::html("ffbd8e8e");
+
+ Ref<Texture> remove_icon = get_icon("Remove", "EditorIcons");
+ Ref<Texture> move_up_icon = get_icon("MoveUp", "EditorIcons");
+ Ref<Texture> move_down_icon = get_icon("MoveDown", "EditorIcons");
+ Ref<Texture> remove_icon_hl = get_icon("RemoveHl", "EditorIcons");
+ Ref<Texture> move_up_icon_hl = get_icon("MoveUpHl", "EditorIcons");
+ Ref<Texture> move_down_icon_hl = get_icon("MoveDownHl", "EditorIcons");
+ Ref<Texture> add_key_icon = get_icon("TrackAddKey", "EditorIcons");
+ Ref<Texture> add_key_icon_hl = get_icon("TrackAddKeyHl", "EditorIcons");
+ Ref<Texture> down_icon = get_icon("select_arrow", "Tree");
+
+ Ref<Texture> wrap_icon[2] = {
+ get_icon("InterpWrapClamp", "EditorIcons"),
+ get_icon("InterpWrapLoop", "EditorIcons"),
};
- Ref<Texture> interp_icon[3]={
- get_icon("InterpRaw","EditorIcons"),
- get_icon("InterpLinear","EditorIcons"),
- get_icon("InterpCubic","EditorIcons")
+ Ref<Texture> interp_icon[3] = {
+ get_icon("InterpRaw", "EditorIcons"),
+ get_icon("InterpLinear", "EditorIcons"),
+ get_icon("InterpCubic", "EditorIcons")
};
- Ref<Texture> cont_icon[3]={
- get_icon("TrackContinuous","EditorIcons"),
- get_icon("TrackDiscrete","EditorIcons"),
- get_icon("TrackTrigger","EditorIcons")
+ Ref<Texture> cont_icon[3] = {
+ get_icon("TrackContinuous", "EditorIcons"),
+ get_icon("TrackDiscrete", "EditorIcons"),
+ get_icon("TrackTrigger", "EditorIcons")
};
- Ref<Texture> type_icon[3]={
- get_icon("KeyValue","EditorIcons"),
- get_icon("KeyXform","EditorIcons"),
- get_icon("KeyCall","EditorIcons")
+ Ref<Texture> type_icon[3] = {
+ get_icon("KeyValue", "EditorIcons"),
+ get_icon("KeyXform", "EditorIcons"),
+ get_icon("KeyCall", "EditorIcons")
};
- Ref<Texture> invalid_icon = get_icon("KeyInvalid","EditorIcons");
- Ref<Texture> invalid_icon_hover = get_icon("KeyInvalidHover","EditorIcons");
+ Ref<Texture> invalid_icon = get_icon("KeyInvalid", "EditorIcons");
+ Ref<Texture> invalid_icon_hover = get_icon("KeyInvalidHover", "EditorIcons");
- Ref<Texture> hsize_icon = get_icon("Hsize","EditorIcons");
+ Ref<Texture> hsize_icon = get_icon("Hsize", "EditorIcons");
- Ref<Texture> type_hover=get_icon("KeyHover","EditorIcons");
- Ref<Texture> type_selected=get_icon("KeySelected","EditorIcons");
+ Ref<Texture> type_hover = get_icon("KeyHover", "EditorIcons");
+ Ref<Texture> type_selected = get_icon("KeySelected", "EditorIcons");
- int right_separator_ofs = down_icon->get_width() *3 + add_key_icon->get_width() + interp_icon[0]->get_width() + wrap_icon[0]->get_width() + cont_icon[0]->get_width() + hsep*9;
+ int right_separator_ofs = down_icon->get_width() * 3 + add_key_icon->get_width() + interp_icon[0]->get_width() + wrap_icon[0]->get_width() + cont_icon[0]->get_width() + hsep * 9;
- int h = font->get_height()+sep;
+ int h = font->get_height() + sep;
-
- int fit = (size.height / h)-1;
+ int fit = (size.height / h) - 1;
int total = animation->get_track_count();
if (total < fit) {
v_scroll->hide();
- v_scroll->set_max( total );
- v_scroll->set_page( fit );
+ v_scroll->set_max(total);
+ v_scroll->set_page(fit);
} else {
v_scroll->show();
- v_scroll->set_max( total );
- v_scroll->set_page( fit );
+ v_scroll->set_max(total);
+ v_scroll->set_page(fit);
}
-
int settings_limit = size.width - right_separator_ofs;
int name_limit = settings_limit * name_column_ratio;
- te->draw_line(ofs+Point2(name_limit,0),ofs+Point2(name_limit,size.height),color);
- te->draw_line(ofs+Point2(settings_limit,0),ofs+Point2(settings_limit,size.height),color);
- te->draw_texture(hsize_icon,ofs+Point2(name_limit-hsize_icon->get_width()-hsep,(h-hsize_icon->get_height())/2));
+ te->draw_line(ofs + Point2(name_limit, 0), ofs + Point2(name_limit, size.height), color);
+ te->draw_line(ofs + Point2(settings_limit, 0), ofs + Point2(settings_limit, size.height), color);
+ te->draw_texture(hsize_icon, ofs + Point2(name_limit - hsize_icon->get_width() - hsep, (h - hsize_icon->get_height()) / 2));
- te->draw_line(ofs+Point2(0,h),ofs+Point2(size.width,h),color);
+ te->draw_line(ofs + Point2(0, h), ofs + Point2(size.width, h), color);
// draw time
float keys_from;
float keys_to;
float zoom_scale;
-
{
- int zoomw = settings_limit-name_limit;
-
+ int zoomw = settings_limit - name_limit;
float scale = _get_zoom_scale();
- zoom_scale=scale;
-
+ zoom_scale = scale;
float l = animation->get_length();
- if (l<=0)
- l=0.001; //avoid crashor
+ if (l <= 0)
+ l = 0.001; //avoid crashor
int end_px = (l - h_scroll->get_value()) * scale;
int begin_px = -h_scroll->get_value() * scale;
Color notimecol;
- notimecol.r=timecolor.gray();
- notimecol.g=notimecol.r;
- notimecol.b=notimecol.r;
- notimecol.a=timecolor.a;
+ notimecol.r = timecolor.gray();
+ notimecol.g = notimecol.r;
+ notimecol.b = notimecol.r;
+ notimecol.a = timecolor.a;
{
- te->draw_rect(Rect2( ofs + Point2(name_limit,0), Point2(zoomw-1,h)), notimecol);
+ te->draw_rect(Rect2(ofs + Point2(name_limit, 0), Point2(zoomw - 1, h)), notimecol);
+ if (begin_px < zoomw && end_px > 0) {
- if (begin_px < zoomw && end_px >0) {
+ if (begin_px < 0)
+ begin_px = 0;
+ if (end_px > zoomw)
+ end_px = zoomw;
- if (begin_px<0)
- begin_px=0;
- if (end_px>zoomw)
- end_px=zoomw;
-
- te->draw_rect(Rect2( ofs + Point2(name_limit+begin_px,0), Point2(end_px-begin_px-1,h)), timecolor);
+ te->draw_rect(Rect2(ofs + Point2(name_limit + begin_px, 0), Point2(end_px - begin_px - 1, h)), timecolor);
}
-
}
-
-
- keys_from= h_scroll->get_value();
- keys_to=keys_from+zoomw / scale;
+ keys_from = h_scroll->get_value();
+ keys_to = keys_from + zoomw / scale;
{
- float time_min=0;
- float time_max=animation->get_length();
- for(int i=0;i<animation->get_track_count();i++) {
-
- if (animation->track_get_key_count(i)>0) {
-
- float beg = animation->track_get_key_time(i,0);
- if (beg<time_min)
- time_min=beg;
- float end = animation->track_get_key_time(i,animation->track_get_key_count(i)-1);
- if (end>time_max)
- time_max=end;
+ float time_min = 0;
+ float time_max = animation->get_length();
+ for (int i = 0; i < animation->get_track_count(); i++) {
+
+ if (animation->track_get_key_count(i) > 0) {
+
+ float beg = animation->track_get_key_time(i, 0);
+ if (beg < time_min)
+ time_min = beg;
+ float end = animation->track_get_key_time(i, animation->track_get_key_count(i) - 1);
+ if (end > time_max)
+ time_max = end;
}
}
+ float extra = (zoomw / scale) * 0.5;
-
-
-
- float extra = (zoomw / scale)*0.5;
-
- if (time_min<-0.001)
- time_min-=extra;
- time_max+=extra;
+ if (time_min < -0.001)
+ time_min -= extra;
+ time_max += extra;
h_scroll->set_min(time_min);
h_scroll->set_max(time_max);
- if (zoomw / scale < (time_max-time_min)) {
+ if (zoomw / scale < (time_max - time_min)) {
h_scroll->show();
} else {
h_scroll->hide();
}
-
-
}
h_scroll->set_page(zoomw / scale);
Color color_time_sec = color;
Color color_time_dec = color;
- color_time_dec.a*=0.5;
+ color_time_dec.a *= 0.5;
#define SC_ADJ 100
- int min=30;
- int dec=1;
- int step=1;
- int decimals=2;
- bool step_found=false;
+ int min = 30;
+ int dec = 1;
+ int step = 1;
+ int decimals = 2;
+ bool step_found = false;
- while(!step_found) {
+ while (!step_found) {
- static const int _multp[3]={1,2,5};
- for(int i=0;i<3;i++) {
+ static const int _multp[3] = { 1, 2, 5 };
+ for (int i = 0; i < 3; i++) {
step = (_multp[i] * dec);
- if (step*scale/SC_ADJ> min) {
- step_found=true;
+ if (step * scale / SC_ADJ > min) {
+ step_found = true;
break;
}
-
}
if (step_found)
break;
- dec*=10;
+ dec *= 10;
decimals--;
- if (decimals<0)
- decimals=0;
+ if (decimals < 0)
+ decimals = 0;
}
+ for (int i = 0; i < zoomw; i++) {
- for(int i=0;i<zoomw;i++) {
-
- float pos = h_scroll->get_value() + double(i)/scale;
- float prev = h_scroll->get_value() + (double(i)-1.0)/scale;
-
+ float pos = h_scroll->get_value() + double(i) / scale;
+ float prev = h_scroll->get_value() + (double(i) - 1.0) / scale;
- int sc = int(Math::floor(pos*SC_ADJ));
- int prev_sc = int(Math::floor(prev*SC_ADJ));
+ int sc = int(Math::floor(pos * SC_ADJ));
+ int prev_sc = int(Math::floor(prev * SC_ADJ));
bool sub = (sc % SC_ADJ);
- if ((sc/step)!=(prev_sc/step) || (prev_sc<0 && sc>=0)) {
+ if ((sc / step) != (prev_sc / step) || (prev_sc < 0 && sc >= 0)) {
int scd = sc < 0 ? prev_sc : sc;
- te->draw_line( ofs + Point2(name_limit+i,0), ofs+Point2(name_limit+i,h), color);
- te->draw_string( font,ofs + Point2(name_limit+i+3,(h-font->get_height())/2+font->get_ascent()).floor(),String::num((scd-(scd%step))/double(SC_ADJ),decimals),sub?color_time_dec:color_time_sec,zoomw-i);
+ te->draw_line(ofs + Point2(name_limit + i, 0), ofs + Point2(name_limit + i, h), color);
+ te->draw_string(font, ofs + Point2(name_limit + i + 3, (h - font->get_height()) / 2 + font->get_ascent()).floor(), String::num((scd - (scd % step)) / double(SC_ADJ), decimals), sub ? color_time_dec : color_time_sec, zoomw - i);
}
-
-
}
}
- color.a*=0.5;
+ color.a *= 0.5;
- for(int i=0;i<fit;i++) {
+ for (int i = 0; i < fit; i++) {
//this code sucks, i always forget how it works
int idx = v_scroll->get_value() + i;
- if (idx>=animation->get_track_count())
+ if (idx >= animation->get_track_count())
break;
- int y = h+i*h+sep;
+ int y = h + i * h + sep;
- bool prop_exists=false;
- Variant::Type valid_type=Variant::NIL;
- Object *obj=NULL;
+ bool prop_exists = false;
+ Variant::Type valid_type = Variant::NIL;
+ Object *obj = NULL;
RES res;
- Node *node = root->get_node_and_resource(animation->track_get_path(idx),res);
+ Node *node = root->get_node_and_resource(animation->track_get_path(idx), res);
if (res.is_valid()) {
- obj=res.ptr();
+ obj = res.ptr();
} else if (node) {
- obj=node;
+ obj = node;
}
- if (obj && animation->track_get_type(idx)==Animation::TYPE_VALUE) {
- valid_type=obj->get_static_property_type(animation->track_get_path(idx).get_property(),&prop_exists);
+ if (obj && animation->track_get_type(idx) == Animation::TYPE_VALUE) {
+ valid_type = obj->get_static_property_type(animation->track_get_path(idx).get_property(), &prop_exists);
}
-
- if (/*mouse_over.over!=MouseOver::OVER_NONE &&*/ idx==mouse_over.track) {
- Color sepc=hover_color;
- te->draw_rect(Rect2(ofs+Point2(0,y),Size2(size.width,h-1)),sepc);
+ if (/*mouse_over.over!=MouseOver::OVER_NONE &&*/ idx == mouse_over.track) {
+ Color sepc = hover_color;
+ te->draw_rect(Rect2(ofs + Point2(0, y), Size2(size.width, h - 1)), sepc);
}
- if (selected_track==idx) {
+ if (selected_track == idx) {
Color tc = select_color;
//tc.a*=0.7;
- te->draw_rect(Rect2(ofs+Point2(0,y),Size2(size.width-1,h-1)),tc);
+ te->draw_rect(Rect2(ofs + Point2(0, y), Size2(size.width - 1, h - 1)), tc);
}
- te->draw_texture(type_icon[animation->track_get_type(idx)],ofs+Point2(0,y+(h-type_icon[0]->get_height())/2).floor());
+ te->draw_texture(type_icon[animation->track_get_type(idx)], ofs + Point2(0, y + (h - type_icon[0]->get_height()) / 2).floor());
NodePath np = animation->track_get_path(idx);
Node *n = root->get_node(np);
Color ncol = color;
if (n && editor_selection->is_selected(n))
- ncol=track_select_color;
- te->draw_string(font,Point2(ofs+Point2(type_icon[0]->get_width()+sep,y+font->get_ascent()+(sep/2))).floor(),np,ncol,name_limit-(type_icon[0]->get_width()+sep)-5);
+ ncol = track_select_color;
+ te->draw_string(font, Point2(ofs + Point2(type_icon[0]->get_width() + sep, y + font->get_ascent() + (sep / 2))).floor(), np, ncol, name_limit - (type_icon[0]->get_width() + sep) - 5);
if (!obj)
- te->draw_line(ofs+Point2(0,y+h/2),ofs+Point2(name_limit,y+h/2),invalid_path_color);
+ te->draw_line(ofs + Point2(0, y + h / 2), ofs + Point2(name_limit, y + h / 2), invalid_path_color);
- te->draw_line(ofs+Point2(0,y+h),ofs+Point2(size.width,y+h),sepcolor);
+ te->draw_line(ofs + Point2(0, y + h), ofs + Point2(size.width, y + h), sepcolor);
- Point2 icon_ofs = ofs + Point2( size.width, y + (h - remove_icon->get_height() )/2).floor();
- icon_ofs.y+=4;
+ Point2 icon_ofs = ofs + Point2(size.width, y + (h - remove_icon->get_height()) / 2).floor();
+ icon_ofs.y += 4;
-
-/* icon_ofs.x-=remove_icon->get_width();
+ /* icon_ofs.x-=remove_icon->get_width();
te->draw_texture((mouse_over.over==MouseOver::OVER_REMOVE && mouse_over.track==idx)?remove_icon_hl:remove_icon,icon_ofs);
icon_ofs.x-=hsep;
@@ -1429,246 +1353,235 @@ void AnimationKeyEditor::_track_editor_draw() {
icon_ofs.x-=hsep;
*/
- track_ofs[0]=size.width-icon_ofs.x;
- icon_ofs.x-=down_icon->get_width();
- te->draw_texture(down_icon,icon_ofs);
+ track_ofs[0] = size.width - icon_ofs.x;
+ icon_ofs.x -= down_icon->get_width();
+ te->draw_texture(down_icon, icon_ofs);
- int wrap_type = animation->track_get_interpolation_loop_wrap(idx)?1:0;
- icon_ofs.x-=hsep;
- icon_ofs.x-=wrap_icon[wrap_type]->get_width();
- te->draw_texture(wrap_icon[wrap_type],icon_ofs);
+ int wrap_type = animation->track_get_interpolation_loop_wrap(idx) ? 1 : 0;
+ icon_ofs.x -= hsep;
+ icon_ofs.x -= wrap_icon[wrap_type]->get_width();
+ te->draw_texture(wrap_icon[wrap_type], icon_ofs);
- icon_ofs.x-=hsep;
- te->draw_line(Point2(icon_ofs.x,ofs.y+y),Point2(icon_ofs.x,ofs.y+y+h),sepcolor);
+ icon_ofs.x -= hsep;
+ te->draw_line(Point2(icon_ofs.x, ofs.y + y), Point2(icon_ofs.x, ofs.y + y + h), sepcolor);
- track_ofs[1]=size.width-icon_ofs.x;
+ track_ofs[1] = size.width - icon_ofs.x;
- icon_ofs.x-=down_icon->get_width();
- te->draw_texture(down_icon,icon_ofs);
+ icon_ofs.x -= down_icon->get_width();
+ te->draw_texture(down_icon, icon_ofs);
int interp_type = animation->track_get_interpolation_type(idx);
- ERR_CONTINUE(interp_type<0 || interp_type>=3);
- icon_ofs.x-=hsep;
- icon_ofs.x-=interp_icon[interp_type]->get_width();
- te->draw_texture(interp_icon[interp_type],icon_ofs);
-
- icon_ofs.x-=hsep;
- te->draw_line(Point2(icon_ofs.x,ofs.y+y),Point2(icon_ofs.x,ofs.y+y+h),sepcolor);
+ ERR_CONTINUE(interp_type < 0 || interp_type >= 3);
+ icon_ofs.x -= hsep;
+ icon_ofs.x -= interp_icon[interp_type]->get_width();
+ te->draw_texture(interp_icon[interp_type], icon_ofs);
- track_ofs[2]=size.width-icon_ofs.x;
+ icon_ofs.x -= hsep;
+ te->draw_line(Point2(icon_ofs.x, ofs.y + y), Point2(icon_ofs.x, ofs.y + y + h), sepcolor);
- if (animation->track_get_type(idx)==Animation::TYPE_VALUE) {
+ track_ofs[2] = size.width - icon_ofs.x;
+ if (animation->track_get_type(idx) == Animation::TYPE_VALUE) {
int umode = animation->value_track_get_update_mode(idx);
- icon_ofs.x-=hsep;
- icon_ofs.x-=down_icon->get_width();
- te->draw_texture(down_icon,icon_ofs);
+ icon_ofs.x -= hsep;
+ icon_ofs.x -= down_icon->get_width();
+ te->draw_texture(down_icon, icon_ofs);
- icon_ofs.x-=hsep;
- icon_ofs.x-=cont_icon[umode]->get_width();
- te->draw_texture(cont_icon[umode],icon_ofs);
+ icon_ofs.x -= hsep;
+ icon_ofs.x -= cont_icon[umode]->get_width();
+ te->draw_texture(cont_icon[umode], icon_ofs);
} else {
- icon_ofs.x -= hsep*2 + cont_icon[0]->get_width() + down_icon->get_width();
+ icon_ofs.x -= hsep * 2 + cont_icon[0]->get_width() + down_icon->get_width();
}
- icon_ofs.x-=hsep;
- te->draw_line(Point2(icon_ofs.x,ofs.y+y),Point2(icon_ofs.x,ofs.y+y+h),sepcolor);
+ icon_ofs.x -= hsep;
+ te->draw_line(Point2(icon_ofs.x, ofs.y + y), Point2(icon_ofs.x, ofs.y + y + h), sepcolor);
- track_ofs[3]=size.width-icon_ofs.x;
+ track_ofs[3] = size.width - icon_ofs.x;
- icon_ofs.x-=hsep;
- icon_ofs.x-=add_key_icon->get_width();
- te->draw_texture((mouse_over.over==MouseOver::OVER_ADD_KEY && mouse_over.track==idx)?add_key_icon_hl:add_key_icon,icon_ofs);
+ icon_ofs.x -= hsep;
+ icon_ofs.x -= add_key_icon->get_width();
+ te->draw_texture((mouse_over.over == MouseOver::OVER_ADD_KEY && mouse_over.track == idx) ? add_key_icon_hl : add_key_icon, icon_ofs);
- track_ofs[4]=size.width-icon_ofs.x;
+ track_ofs[4] = size.width - icon_ofs.x;
//draw the keys;
int tt = animation->track_get_type(idx);
- float key_vofs = Math::floor((float)(h - type_icon[tt]->get_height())/2);
- float key_hofs = -Math::floor((float)type_icon[tt]->get_height()/2);
-
- int kc=animation->track_get_key_count(idx);
- bool first=true;
+ float key_vofs = Math::floor((float)(h - type_icon[tt]->get_height()) / 2);
+ float key_hofs = -Math::floor((float)type_icon[tt]->get_height() / 2);
+ int kc = animation->track_get_key_count(idx);
+ bool first = true;
+ for (int i = 0; i < kc; i++) {
- for(int i=0;i<kc;i++) {
-
-
- float time = animation->track_get_key_time(idx,i);
- if (time<keys_from)
+ float time = animation->track_get_key_time(idx, i);
+ if (time < keys_from)
continue;
- if (time>keys_to) {
+ if (time > keys_to) {
- if (first && i>0 && animation->track_get_key_value(idx,i)==animation->track_get_key_value(idx,i-1)) {
+ if (first && i > 0 && animation->track_get_key_value(idx, i) == animation->track_get_key_value(idx, i - 1)) {
//draw whole line
- te->draw_line(ofs+Vector2(name_limit,y+h/2),ofs+Point2(settings_limit,y+h/2),color);
+ te->draw_line(ofs + Vector2(name_limit, y + h / 2), ofs + Point2(settings_limit, y + h / 2), color);
}
break;
}
- float x = key_hofs + name_limit + (time-keys_from)*zoom_scale;
+ float x = key_hofs + name_limit + (time - keys_from) * zoom_scale;
Ref<Texture> tex = type_icon[tt];
SelectedKey sk;
- sk.key=i;
- sk.track=idx;
+ sk.key = i;
+ sk.track = idx;
if (selection.has(sk)) {
- if (click.click==ClickOver::CLICK_MOVE_KEYS)
+ if (click.click == ClickOver::CLICK_MOVE_KEYS)
continue;
- tex=type_selected;
+ tex = type_selected;
}
- if (mouse_over.over==MouseOver::OVER_KEY && mouse_over.track==idx && mouse_over.over_key==i)
- tex=type_hover;
+ if (mouse_over.over == MouseOver::OVER_KEY && mouse_over.track == idx && mouse_over.over_key == i)
+ tex = type_hover;
- Variant value = animation->track_get_key_value(idx,i);
- if (first && i>0 && value==animation->track_get_key_value(idx,i-1)) {
+ Variant value = animation->track_get_key_value(idx, i);
+ if (first && i > 0 && value == animation->track_get_key_value(idx, i - 1)) {
- te->draw_line(ofs+Vector2(name_limit,y+h/2),ofs+Point2(x,y+h/2),color);
+ te->draw_line(ofs + Vector2(name_limit, y + h / 2), ofs + Point2(x, y + h / 2), color);
}
- if (i<kc-1 && value==animation->track_get_key_value(idx,i+1)) {
- float x_n = key_hofs + name_limit + (animation->track_get_key_time(idx,i+1)-keys_from)*zoom_scale;
-
- x_n = MIN( x_n, settings_limit);
- te->draw_line(ofs+Point2(x_n,y+h/2),ofs+Point2(x,y+h/2),color);
+ if (i < kc - 1 && value == animation->track_get_key_value(idx, i + 1)) {
+ float x_n = key_hofs + name_limit + (animation->track_get_key_time(idx, i + 1) - keys_from) * zoom_scale;
+ x_n = MIN(x_n, settings_limit);
+ te->draw_line(ofs + Point2(x_n, y + h / 2), ofs + Point2(x, y + h / 2), color);
}
- if (prop_exists && !Variant::can_convert(value.get_type(),valid_type)) {
- te->draw_texture(invalid_icon,ofs+Point2(x,y+key_vofs).floor());
+ if (prop_exists && !Variant::can_convert(value.get_type(), valid_type)) {
+ te->draw_texture(invalid_icon, ofs + Point2(x, y + key_vofs).floor());
}
- if (prop_exists && !Variant::can_convert(value.get_type(),valid_type)) {
- if (tex==type_hover)
- te->draw_texture(invalid_icon_hover,ofs+Point2(x,y+key_vofs).floor());
+ if (prop_exists && !Variant::can_convert(value.get_type(), valid_type)) {
+ if (tex == type_hover)
+ te->draw_texture(invalid_icon_hover, ofs + Point2(x, y + key_vofs).floor());
else
- te->draw_texture(invalid_icon,ofs+Point2(x,y+key_vofs).floor());
+ te->draw_texture(invalid_icon, ofs + Point2(x, y + key_vofs).floor());
} else {
- te->draw_texture(tex,ofs+Point2(x,y+key_vofs).floor());
+ te->draw_texture(tex, ofs + Point2(x, y + key_vofs).floor());
}
-
- first=false;
+ first = false;
}
-
}
- switch(click.click) {
+ switch (click.click) {
case ClickOver::CLICK_SELECT_KEYS: {
- te->draw_rect(Rect2(click.at,click.to-click.at),Color(0.7,0.7,1.0,0.5));
+ te->draw_rect(Rect2(click.at, click.to - click.at), Color(0.7, 0.7, 1.0, 0.5));
} break;
case ClickOver::CLICK_MOVE_KEYS: {
float from_t = 1e20;
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.front();E;E=E->next()) {
- float t = animation->track_get_key_time(E->key().track,E->key().key);
- if (t<from_t)
- from_t=t;
-
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.front(); E; E = E->next()) {
+ float t = animation->track_get_key_time(E->key().track, E->key().key);
+ if (t < from_t)
+ from_t = t;
}
- float motion = from_t+(click.to.x - click.at.x)/zoom_scale;
+ float motion = from_t + (click.to.x - click.at.x) / zoom_scale;
if (step->get_value())
- motion = Math::stepify(motion,step->get_value());
-
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.front();E;E=E->next()) {
+ motion = Math::stepify(motion, step->get_value());
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.front(); E; E = E->next()) {
int idx = E->key().track;
- int i = idx-v_scroll->get_value();
- if (i<0 || i>=fit)
+ int i = idx - v_scroll->get_value();
+ if (i < 0 || i >= fit)
continue;
- int y = h+i*h+sep;
+ int y = h + i * h + sep;
- float key_vofs = Math::floor((float)(h - type_selected->get_height())/2);
- float key_hofs = -Math::floor((float)type_selected->get_height()/2);
+ float key_vofs = Math::floor((float)(h - type_selected->get_height()) / 2);
+ float key_hofs = -Math::floor((float)type_selected->get_height() / 2);
- float time = animation->track_get_key_time(idx,E->key().key);
- float diff = time-from_t;
+ float time = animation->track_get_key_time(idx, E->key().key);
+ float diff = time - from_t;
float t = motion + diff;
- float x = (t-keys_from)*zoom_scale;
+ float x = (t - keys_from) * zoom_scale;
//x+=click.to.x - click.at.x;
- if (x<0 || x>=(settings_limit-name_limit))
+ if (x < 0 || x >= (settings_limit - name_limit))
continue;
- x+=name_limit;
-
- te->draw_texture(type_selected,ofs+Point2(x+key_hofs,y+key_vofs).floor());
+ x += name_limit;
+ te->draw_texture(type_selected, ofs + Point2(x + key_hofs, y + key_vofs).floor());
}
} break;
default: {};
}
-
- te_drawing=false;
+ te_drawing = false;
}
-void AnimationKeyEditor::_track_name_changed(const String& p_name) {
+void AnimationKeyEditor::_track_name_changed(const String &p_name) {
ERR_FAIL_COND(!animation.is_valid());
undo_redo->create_action(TTR("Anim Track Rename"));
- undo_redo->add_do_method(animation.ptr(),"track_set_path",track_name_editing,p_name);
- undo_redo->add_undo_method(animation.ptr(),"track_set_path",track_name_editing,animation->track_get_path(track_name_editing));
+ undo_redo->add_do_method(animation.ptr(), "track_set_path", track_name_editing, p_name);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_path", track_name_editing, animation->track_get_path(track_name_editing));
undo_redo->commit_action();
track_name->hide();
-
}
void AnimationKeyEditor::_track_menu_selected(int p_idx) {
-
ERR_FAIL_COND(!animation.is_valid());
- if (interp_editing!=-1) {
+ if (interp_editing != -1) {
- ERR_FAIL_INDEX(interp_editing,animation->get_track_count());
+ ERR_FAIL_INDEX(interp_editing, animation->get_track_count());
undo_redo->create_action(TTR("Anim Track Change Interpolation"));
- undo_redo->add_do_method(animation.ptr(),"track_set_interpolation_type",interp_editing,p_idx);
- undo_redo->add_undo_method(animation.ptr(),"track_set_interpolation_type",interp_editing,animation->track_get_interpolation_type(interp_editing));
+ undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", interp_editing, p_idx);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_type", interp_editing, animation->track_get_interpolation_type(interp_editing));
undo_redo->commit_action();
- } else if (cont_editing!=-1) {
+ } else if (cont_editing != -1) {
- ERR_FAIL_INDEX(cont_editing,animation->get_track_count());
+ ERR_FAIL_INDEX(cont_editing, animation->get_track_count());
undo_redo->create_action(TTR("Anim Track Change Value Mode"));
- undo_redo->add_do_method(animation.ptr(),"value_track_set_update_mode",cont_editing,p_idx);
- undo_redo->add_undo_method(animation.ptr(),"value_track_set_update_mode",cont_editing,animation->value_track_get_update_mode(cont_editing));
+ undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", cont_editing, p_idx);
+ undo_redo->add_undo_method(animation.ptr(), "value_track_set_update_mode", cont_editing, animation->value_track_get_update_mode(cont_editing));
undo_redo->commit_action();
- } else if (wrap_editing!=-1) {
+ } else if (wrap_editing != -1) {
- ERR_FAIL_INDEX(wrap_editing,animation->get_track_count());
+ ERR_FAIL_INDEX(wrap_editing, animation->get_track_count());
undo_redo->create_action(TTR("Anim Track Change Wrap Mode"));
- undo_redo->add_do_method(animation.ptr(),"track_set_interpolation_loop_wrap",wrap_editing,p_idx?true:false);
- undo_redo->add_undo_method(animation.ptr(),"track_set_interpolation_loop_wrap",wrap_editing,animation->track_get_interpolation_loop_wrap(wrap_editing));
+ undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_loop_wrap", wrap_editing, p_idx ? true : false);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_loop_wrap", wrap_editing, animation->track_get_interpolation_loop_wrap(wrap_editing));
undo_redo->commit_action();
} else {
switch (p_idx) {
case RIGHT_MENU_DUPLICATE:
- _anim_duplicate_keys(); break;
+ _anim_duplicate_keys();
+ break;
case RIGHT_MENU_DUPLICATE_TRANSPOSE:
- _anim_duplicate_keys(true); break;
+ _anim_duplicate_keys(true);
+ break;
case RIGHT_MENU_REMOVE:
- _anim_delete_keys(); break;
+ _anim_delete_keys();
+ break;
}
}
-
}
struct _AnimMoveRestore {
@@ -1679,59 +1592,54 @@ struct _AnimMoveRestore {
float transition;
};
-void AnimationKeyEditor::_clear_selection_for_anim(const Ref<Animation>& p_anim) {
+void AnimationKeyEditor::_clear_selection_for_anim(const Ref<Animation> &p_anim) {
- if (!(animation==p_anim))
+ if (!(animation == p_anim))
return;
//selection.clear();
_clear_selection();
-
}
-void AnimationKeyEditor::_select_at_anim(const Ref<Animation>& p_anim,int p_track,float p_pos){
+void AnimationKeyEditor::_select_at_anim(const Ref<Animation> &p_anim, int p_track, float p_pos) {
- if (!(animation==p_anim))
+ if (!(animation == p_anim))
return;
- int idx = animation->track_find_key(p_track,p_pos,true);
- ERR_FAIL_COND(idx<0);
+ int idx = animation->track_find_key(p_track, p_pos, true);
+ ERR_FAIL_COND(idx < 0);
SelectedKey sk;
- sk.track=p_track;
- sk.key=idx;
+ sk.track = p_track;
+ sk.key = idx;
KeyInfo ki;
- ki.pos=p_pos;
-
- selection.insert(sk,ki);
+ ki.pos = p_pos;
+ selection.insert(sk, ki);
}
+PropertyInfo AnimationKeyEditor::_find_hint_for_track(int p_idx, NodePath &r_base_path) {
-PropertyInfo AnimationKeyEditor::_find_hint_for_track(int p_idx,NodePath& r_base_path) {
-
- r_base_path=NodePath();
- ERR_FAIL_COND_V(!animation.is_valid(),PropertyInfo());
- ERR_FAIL_INDEX_V(p_idx,animation->get_track_count(),PropertyInfo());
+ r_base_path = NodePath();
+ ERR_FAIL_COND_V(!animation.is_valid(), PropertyInfo());
+ ERR_FAIL_INDEX_V(p_idx, animation->get_track_count(), PropertyInfo());
if (!root)
return PropertyInfo();
NodePath path = animation->track_get_path(p_idx);
-
if (!root->has_node_and_resource(path))
return PropertyInfo();
RES res;
- Node *node = root->get_node_and_resource(path,res);
-
+ Node *node = root->get_node_and_resource(path, res);
if (node) {
- r_base_path=node->get_path();
+ r_base_path = node->get_path();
}
String property = path.get_property();
- if (property=="")
+ if (property == "")
return PropertyInfo();
List<PropertyInfo> pinfo;
@@ -1740,36 +1648,34 @@ PropertyInfo AnimationKeyEditor::_find_hint_for_track(int p_idx,NodePath& r_base
else
node->get_property_list(&pinfo);
- for(List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- if (E->get().name==property)
+ if (E->get().name == property)
return E->get();
}
return PropertyInfo();
}
-
void AnimationKeyEditor::_curve_transition_changed(float p_what) {
- if (selection.size()==0)
+ if (selection.size() == 0)
return;
- if (selection.size()==1)
- undo_redo->create_action(TTR("Edit Node Curve"),UndoRedo::MERGE_ENDS);
+ if (selection.size() == 1)
+ undo_redo->create_action(TTR("Edit Node Curve"), UndoRedo::MERGE_ENDS);
else
- undo_redo->create_action(TTR("Edit Selection Curve"),UndoRedo::MERGE_ENDS);
+ undo_redo->create_action(TTR("Edit Selection Curve"), UndoRedo::MERGE_ENDS);
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.front(); E; E = E->next()) {
int track = E->key().track;
int key = E->key().key;
- float prev_val = animation->track_get_key_transition(track,key);
- undo_redo->add_do_method(animation.ptr(),"track_set_key_transition",track,key,p_what);
- undo_redo->add_undo_method(animation.ptr(),"track_set_key_transition",track,key,prev_val);
+ float prev_val = animation->track_get_key_transition(track, key);
+ undo_redo->add_do_method(animation.ptr(), "track_set_key_transition", track, key, p_what);
+ undo_redo->add_undo_method(animation.ptr(), "track_set_key_transition", track, key, prev_val);
}
undo_redo->commit_action();
-
}
void AnimationKeyEditor::_toggle_edit_curves() {
@@ -1780,12 +1686,11 @@ void AnimationKeyEditor::_toggle_edit_curves() {
key_editor_tab->hide();
}
-
bool AnimationKeyEditor::_edit_if_single_selection() {
- if (selection.size()!=1) {
+ if (selection.size() != 1) {
- if (selection.size()==0) {
+ if (selection.size() == 0) {
curve_edit->set_mode(AnimationCurveEdit::MODE_DISABLED);
//print_line("disable");
} else {
@@ -1794,12 +1699,11 @@ bool AnimationKeyEditor::_edit_if_single_selection() {
curve_edit->set_transition(1.0);
curve_edit->clear_multiples();
//add all
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.front(); E; E = E->next()) {
- curve_edit->set_multiple(animation->track_get_key_transition(E->key().track,E->key().key));
+ curve_edit->set_multiple(animation->track_get_key_transition(E->key().track, E->key().key));
}
//print_line("multiple");
-
}
return false;
}
@@ -1810,36 +1714,33 @@ bool AnimationKeyEditor::_edit_if_single_selection() {
int key = selection.front()->key().key;
{
- key_edit->animation=animation;
- key_edit->track=idx;
- key_edit->key_ofs=animation->track_get_key_time(idx,key);
- key_edit->hint=_find_hint_for_track(idx,key_edit->base);
+ key_edit->animation = animation;
+ key_edit->track = idx;
+ key_edit->key_ofs = animation->track_get_key_time(idx, key);
+ key_edit->hint = _find_hint_for_track(idx, key_edit->base);
key_edit->notify_change();
- curve_edit->set_transition(animation->track_get_key_transition(idx,key));
+ curve_edit->set_transition(animation->track_get_key_transition(idx, key));
/*key_edit_dialog->set_size( Size2( 200,200) );
key_edit_dialog->set_pos( track_editor->get_global_pos() + ofs + mpos +Point2(-100,20));
key_edit_dialog->popup();*/
-
}
return true;
-
}
void AnimationKeyEditor::_anim_delete_keys() {
if (selection.size()) {
undo_redo->create_action(TTR("Anim Delete Keys"));
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
-
- undo_redo->add_do_method(animation.ptr(),"track_remove_key",E->key().track,E->key().key);
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",E->key().track,E->get().pos,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key));
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
+ undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key);
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
- undo_redo->add_do_method(this,"_clear_selection_for_anim",animation);
- undo_redo->add_undo_method(this,"_clear_selection_for_anim",animation);
+ undo_redo->add_do_method(this, "_clear_selection_for_anim", animation);
+ undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation);
undo_redo->commit_action();
//selection.clear();
accept_event();
@@ -1847,70 +1748,69 @@ void AnimationKeyEditor::_anim_delete_keys() {
}
}
-void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
+void AnimationKeyEditor::_track_editor_gui_input(const InputEvent &p_input) {
- Control *te=track_editor;
- Ref<StyleBox> style = get_stylebox("normal","TextEdit");
+ Control *te = track_editor;
+ Ref<StyleBox> style = get_stylebox("normal", "TextEdit");
if (!animation.is_valid()) {
return;
}
- Size2 size= te->get_size() - style->get_minimum_size();
+ Size2 size = te->get_size() - style->get_minimum_size();
Size2 ofs = style->get_offset();
- Ref<Font> font = te->get_font("font","Tree");
- int sep = get_constant("vseparation","Tree");
- int hsep = get_constant("hseparation","Tree");
- Ref<Texture> remove_icon = get_icon("Remove","EditorIcons");
- Ref<Texture> move_up_icon = get_icon("MoveUp","EditorIcons");
- Ref<Texture> move_down_icon = get_icon("MoveDown","EditorIcons");
- Ref<Texture> down_icon = get_icon("select_arrow","Tree");
- Ref<Texture> hsize_icon = get_icon("Hsize","EditorIcons");
- Ref<Texture> add_key_icon = get_icon("TrackAddKey","EditorIcons");
-
- Ref<Texture> wrap_icon[2]={
- get_icon("InterpWrapClamp","EditorIcons"),
- get_icon("InterpWrapLoop","EditorIcons"),
+ Ref<Font> font = te->get_font("font", "Tree");
+ int sep = get_constant("vseparation", "Tree");
+ int hsep = get_constant("hseparation", "Tree");
+ Ref<Texture> remove_icon = get_icon("Remove", "EditorIcons");
+ Ref<Texture> move_up_icon = get_icon("MoveUp", "EditorIcons");
+ Ref<Texture> move_down_icon = get_icon("MoveDown", "EditorIcons");
+ Ref<Texture> down_icon = get_icon("select_arrow", "Tree");
+ Ref<Texture> hsize_icon = get_icon("Hsize", "EditorIcons");
+ Ref<Texture> add_key_icon = get_icon("TrackAddKey", "EditorIcons");
+
+ Ref<Texture> wrap_icon[2] = {
+ get_icon("InterpWrapClamp", "EditorIcons"),
+ get_icon("InterpWrapLoop", "EditorIcons"),
};
- Ref<Texture> interp_icon[3]={
- get_icon("InterpRaw","EditorIcons"),
- get_icon("InterpLinear","EditorIcons"),
- get_icon("InterpCubic","EditorIcons")
+ Ref<Texture> interp_icon[3] = {
+ get_icon("InterpRaw", "EditorIcons"),
+ get_icon("InterpLinear", "EditorIcons"),
+ get_icon("InterpCubic", "EditorIcons")
};
- Ref<Texture> cont_icon[3]={
- get_icon("TrackContinuous","EditorIcons"),
- get_icon("TrackDiscrete","EditorIcons"),
- get_icon("TrackTrigger","EditorIcons")
+ Ref<Texture> cont_icon[3] = {
+ get_icon("TrackContinuous", "EditorIcons"),
+ get_icon("TrackDiscrete", "EditorIcons"),
+ get_icon("TrackTrigger", "EditorIcons")
};
- Ref<Texture> type_icon[3]={
- get_icon("KeyValue","EditorIcons"),
- get_icon("KeyXform","EditorIcons"),
- get_icon("KeyCall","EditorIcons")
+ Ref<Texture> type_icon[3] = {
+ get_icon("KeyValue", "EditorIcons"),
+ get_icon("KeyXform", "EditorIcons"),
+ get_icon("KeyCall", "EditorIcons")
};
- int right_separator_ofs = down_icon->get_width() *3 + add_key_icon->get_width() + interp_icon[0]->get_width() + wrap_icon[0]->get_width() + cont_icon[0]->get_width() + hsep*9;
+ int right_separator_ofs = down_icon->get_width() * 3 + add_key_icon->get_width() + interp_icon[0]->get_width() + wrap_icon[0]->get_width() + cont_icon[0]->get_width() + hsep * 9;
- int h = font->get_height()+sep;
+ int h = font->get_height() + sep;
- int fit = (size.height / h)-1;
+ int fit = (size.height / h) - 1;
int total = animation->get_track_count();
if (total < fit) {
v_scroll->hide();
} else {
v_scroll->show();
- v_scroll->set_max( total );
- v_scroll->set_page( fit );
+ v_scroll->set_max(total);
+ v_scroll->set_page(fit);
}
int settings_limit = size.width - right_separator_ofs;
int name_limit = settings_limit * name_column_ratio;
-
- switch(p_input.type) {
+ switch (p_input.type) {
case InputEvent::KEY: {
- if (p_input.key.scancode==KEY_D && p_input.key.pressed && p_input.key.mod.command) {
+ if (p_input.key.scancode == KEY_D && p_input.key.pressed && p_input.key.mod.command) {
if (p_input.key.mod.shift)
_menu_track(TRACK_MENU_DUPLICATE_TRANSPOSE);
@@ -1919,10 +1819,10 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
accept_event();
- } else if (p_input.key.scancode==KEY_DELETE && p_input.key.pressed && click.click==ClickOver::CLICK_NONE) {
+ } else if (p_input.key.scancode == KEY_DELETE && p_input.key.pressed && click.click == ClickOver::CLICK_NONE) {
_anim_delete_keys();
- } else if (animation.is_valid() && animation->get_track_count()>0) {
+ } else if (animation.is_valid() && animation->get_track_count() > 0) {
if (p_input.is_pressed() && (p_input.is_action("ui_up") || p_input.is_action("ui_page_up"))) {
@@ -1931,19 +1831,16 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
if (v_scroll->is_visible_in_tree() && p_input.is_action("ui_page_up"))
selected_track--;
- if (selected_track<0)
- selected_track=0;
-
+ if (selected_track < 0)
+ selected_track = 0;
if (v_scroll->is_visible_in_tree()) {
if (v_scroll->get_value() > selected_track)
v_scroll->set_value(selected_track);
-
}
track_editor->update();
accept_event();
-
}
if (p_input.is_pressed() && (p_input.is_action("ui_down") || p_input.is_action("ui_page_down"))) {
@@ -1951,13 +1848,13 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
if (p_input.is_action("ui_down"))
selected_track++;
else if (v_scroll->is_visible_in_tree() && p_input.is_action("ui_page_down"))
- selected_track+=v_scroll->get_page();
+ selected_track += v_scroll->get_page();
if (selected_track >= animation->get_track_count())
- selected_track=animation->get_track_count()-1;
+ selected_track = animation->get_track_count() - 1;
- if (v_scroll->is_visible_in_tree() && v_scroll->get_page()+v_scroll->get_value() < selected_track+1) {
- v_scroll->set_value(selected_track-v_scroll->get_page()+1);
+ if (v_scroll->is_visible_in_tree() && v_scroll->get_page() + v_scroll->get_value() < selected_track + 1) {
+ v_scroll->set_value(selected_track - v_scroll->get_page() + 1);
}
track_editor->update();
@@ -1965,114 +1862,109 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
}
}
-
} break;
case InputEvent::MOUSE_BUTTON: {
const InputEventMouseButton &mb = p_input.mouse_button;
- if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) {
+ if (mb.button_index == BUTTON_WHEEL_UP && mb.pressed) {
if (mb.mod.command) {
zoom->set_value(zoom->get_value() + zoom->get_step());
} else {
- v_scroll->set_value( v_scroll->get_value() - v_scroll->get_page() / 8 );
+ v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() / 8);
}
}
- if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) {
+ if (mb.button_index == BUTTON_WHEEL_DOWN && mb.pressed) {
if (mb.mod.command) {
zoom->set_value(zoom->get_value() - zoom->get_step());
} else {
- v_scroll->set_value( v_scroll->get_value() + v_scroll->get_page() / 8 );
+ v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() / 8);
}
}
- if (mb.button_index==BUTTON_RIGHT && mb.pressed) {
+ if (mb.button_index == BUTTON_RIGHT && mb.pressed) {
- Point2 mpos = Point2(mb.x,mb.y)-ofs;
+ Point2 mpos = Point2(mb.x, mb.y) - ofs;
if (selection.size() == 0) {
// Auto-select on right-click if nothing is selected
// Note: This code is pretty much duplicated from the left click code,
// both codes could be moved into a function to avoid the duplicated code.
- Point2 mpos = Point2(mb.x,mb.y)-ofs;
+ Point2 mpos = Point2(mb.x, mb.y) - ofs;
- if (mpos.y < h ) {
+ if (mpos.y < h) {
return;
}
mpos.y -= h;
int idx = mpos.y / h;
- idx+=v_scroll->get_value();
- if (idx <0 || idx>=animation->get_track_count())
+ idx += v_scroll->get_value();
+ if (idx < 0 || idx >= animation->get_track_count())
break;
if (mpos.x < name_limit) {
} else if (mpos.x < settings_limit) {
float pos = mpos.x - name_limit;
- pos/=_get_zoom_scale();
- pos+=h_scroll->get_value();
- float w_time = (type_icon[0]->get_width() / _get_zoom_scale())/2.0;
+ pos /= _get_zoom_scale();
+ pos += h_scroll->get_value();
+ float w_time = (type_icon[0]->get_width() / _get_zoom_scale()) / 2.0;
- int kidx = animation->track_find_key(idx,pos);
- int kidx_n = kidx+1;
- int key=-1;
+ int kidx = animation->track_find_key(idx, pos);
+ int kidx_n = kidx + 1;
+ int key = -1;
- if (kidx>=0 && kidx<animation->track_get_key_count(idx)) {
+ if (kidx >= 0 && kidx < animation->track_get_key_count(idx)) {
- float kpos = animation->track_get_key_time(idx,kidx);
- if (ABS(pos-kpos)<=w_time) {
+ float kpos = animation->track_get_key_time(idx, kidx);
+ if (ABS(pos - kpos) <= w_time) {
- key=kidx;
+ key = kidx;
}
}
- if (key==-1 && kidx_n>=0 && kidx_n<animation->track_get_key_count(idx)) {
+ if (key == -1 && kidx_n >= 0 && kidx_n < animation->track_get_key_count(idx)) {
- float kpos = animation->track_get_key_time(idx,kidx_n);
- if (ABS(pos-kpos)<=w_time) {
+ float kpos = animation->track_get_key_time(idx, kidx_n);
+ if (ABS(pos - kpos) <= w_time) {
- key=kidx_n;
+ key = kidx_n;
}
}
- if (key==-1) {
+ if (key == -1) {
- click.click=ClickOver::CLICK_SELECT_KEYS;
- click.at=Point2(mb.x,mb.y);
- click.to=click.at;
- click.shift=mb.mod.shift;
- selected_track=idx;
+ click.click = ClickOver::CLICK_SELECT_KEYS;
+ click.at = Point2(mb.x, mb.y);
+ click.to = click.at;
+ click.shift = mb.mod.shift;
+ selected_track = idx;
track_editor->update();
//drag select region
return;
-
}
-
-
SelectedKey sk;
- sk.track=idx;
- sk.key=key;
+ sk.track = idx;
+ sk.key = key;
KeyInfo ki;
- ki.pos= animation->track_get_key_time(idx,key);
- click.shift=mb.mod.shift;
- click.selk=sk;
-
+ ki.pos = animation->track_get_key_time(idx, key);
+ click.shift = mb.mod.shift;
+ click.selk = sk;
if (!mb.mod.shift && !selection.has(sk))
_clear_selection();
- selection.insert(sk,ki);
+ selection.insert(sk, ki);
- click.click=ClickOver::CLICK_MOVE_KEYS;
- click.at=Point2(mb.x,mb.y);
- click.to=click.at;
+ click.click = ClickOver::CLICK_MOVE_KEYS;
+ click.at = Point2(mb.x, mb.y);
+ click.to = click.at;
update();
- selected_track=idx;
+ selected_track = idx;
track_editor->update();
if (_edit_if_single_selection() && mb.mod.command) {
@@ -2085,59 +1977,54 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
if (selection.size()) {
// User has right clicked and we have a selection, show a popup menu with options
track_menu->clear();
- track_menu->set_size(Point2(1,1));
+ track_menu->set_size(Point2(1, 1));
track_menu->add_item(TTR("Duplicate Selection"), RIGHT_MENU_DUPLICATE);
track_menu->add_item(TTR("Duplicate Transposed"), RIGHT_MENU_DUPLICATE_TRANSPOSE);
track_menu->add_item(TTR("Remove Selection"), RIGHT_MENU_REMOVE);
- track_menu->set_pos(te->get_global_pos()+mpos);
+ track_menu->set_pos(te->get_global_pos() + mpos);
- interp_editing=-1;
- cont_editing=-1;
- wrap_editing=-1;
+ interp_editing = -1;
+ cont_editing = -1;
+ wrap_editing = -1;
track_menu->popup();
}
}
- if (mb.button_index==BUTTON_LEFT && !(mb.button_mask&~BUTTON_MASK_LEFT)) {
-
+ if (mb.button_index == BUTTON_LEFT && !(mb.button_mask & ~BUTTON_MASK_LEFT)) {
if (mb.pressed) {
- Point2 mpos = Point2(mb.x,mb.y)-ofs;
-
- if (mpos.y < h ) {
-
+ Point2 mpos = Point2(mb.x, mb.y) - ofs;
- if (mpos.x<name_limit && mpos.x > (name_limit - hsep - hsize_icon->get_width())) {
+ if (mpos.y < h) {
+ if (mpos.x < name_limit && mpos.x > (name_limit - hsep - hsize_icon->get_width())) {
- click.click=ClickOver::CLICK_RESIZE_NAMES;
- click.at=Point2(mb.x,mb.y);
- click.to=click.at;
- click.at.y=name_limit;
-
+ click.click = ClickOver::CLICK_RESIZE_NAMES;
+ click.at = Point2(mb.x, mb.y);
+ click.to = click.at;
+ click.at.y = name_limit;
}
- if (mpos.x>=name_limit && mpos.x<settings_limit) {
+ if (mpos.x >= name_limit && mpos.x < settings_limit) {
//seek
//int zoomw = settings_limit-name_limit;
float scale = _get_zoom_scale();
- float pos = h_scroll->get_value() + (mpos.x-name_limit) / scale;
+ float pos = h_scroll->get_value() + (mpos.x - name_limit) / scale;
if (animation->get_step())
- pos=Math::stepify(pos,animation->get_step());
-
- if (pos<0 )
- pos=0;
- if (pos>=animation->get_length())
- pos=animation->get_length();
- timeline_pos=pos;
- click.click=ClickOver::CLICK_DRAG_TIMELINE;
- click.at=Point2(mb.x,mb.y);
- click.to=click.at;
- emit_signal("timeline_changed",pos,false);
-
+ pos = Math::stepify(pos, animation->get_step());
+
+ if (pos < 0)
+ pos = 0;
+ if (pos >= animation->get_length())
+ pos = animation->get_length();
+ timeline_pos = pos;
+ click.click = ClickOver::CLICK_DRAG_TIMELINE;
+ click.at = Point2(mb.x, mb.y);
+ click.to = click.at;
+ emit_signal("timeline_changed", pos, false);
}
return;
@@ -2146,17 +2033,17 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
mpos.y -= h;
int idx = mpos.y / h;
- idx+=v_scroll->get_value();
- if (idx <0)
+ idx += v_scroll->get_value();
+ if (idx < 0)
break;
- if (idx>=animation->get_track_count()) {
+ if (idx >= animation->get_track_count()) {
- if (mpos.x >= name_limit && mpos.x<settings_limit) {
+ if (mpos.x >= name_limit && mpos.x < settings_limit) {
- click.click=ClickOver::CLICK_SELECT_KEYS;
- click.at=Point2(mb.x,mb.y);
- click.to=click.at;
+ click.click = ClickOver::CLICK_SELECT_KEYS;
+ click.at = Point2(mb.x, mb.y);
+ click.to = click.at;
//drag select region
}
@@ -2167,85 +2054,81 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
//name column
// area
- if (idx!=selected_track) {
+ if (idx != selected_track) {
- selected_track=idx;
+ selected_track = idx;
track_editor->update();
break;
}
- Rect2 area(ofs.x,ofs.y+((int(mpos.y)/h)+1)*h,name_limit, h );
+ Rect2 area(ofs.x, ofs.y + ((int(mpos.y) / h) + 1) * h, name_limit, h);
track_name->set_text(animation->track_get_path(idx));
- track_name->set_pos( te->get_global_pos() + area.pos);
+ track_name->set_pos(te->get_global_pos() + area.pos);
track_name->set_size(area.size);
track_name->show_modal();
track_name->grab_focus();
track_name->select_all();
- track_name_editing=idx;
+ track_name_editing = idx;
} else if (mpos.x < settings_limit) {
float pos = mpos.x - name_limit;
- pos/=_get_zoom_scale();
- pos+=h_scroll->get_value();
- float w_time = (type_icon[0]->get_width() / _get_zoom_scale())/2.0;
+ pos /= _get_zoom_scale();
+ pos += h_scroll->get_value();
+ float w_time = (type_icon[0]->get_width() / _get_zoom_scale()) / 2.0;
- int kidx = animation->track_find_key(idx,pos);
- int kidx_n = kidx+1;
- int key=-1;
+ int kidx = animation->track_find_key(idx, pos);
+ int kidx_n = kidx + 1;
+ int key = -1;
- if (kidx>=0 && kidx<animation->track_get_key_count(idx)) {
+ if (kidx >= 0 && kidx < animation->track_get_key_count(idx)) {
- float kpos = animation->track_get_key_time(idx,kidx);
- if (ABS(pos-kpos)<=w_time) {
+ float kpos = animation->track_get_key_time(idx, kidx);
+ if (ABS(pos - kpos) <= w_time) {
- key=kidx;
+ key = kidx;
}
}
- if (key==-1 && kidx_n>=0 && kidx_n<animation->track_get_key_count(idx)) {
+ if (key == -1 && kidx_n >= 0 && kidx_n < animation->track_get_key_count(idx)) {
- float kpos = animation->track_get_key_time(idx,kidx_n);
- if (ABS(pos-kpos)<=w_time) {
+ float kpos = animation->track_get_key_time(idx, kidx_n);
+ if (ABS(pos - kpos) <= w_time) {
- key=kidx_n;
+ key = kidx_n;
}
}
- if (key==-1) {
+ if (key == -1) {
- click.click=ClickOver::CLICK_SELECT_KEYS;
- click.at=Point2(mb.x,mb.y);
- click.to=click.at;
- click.shift=mb.mod.shift;
- selected_track=idx;
+ click.click = ClickOver::CLICK_SELECT_KEYS;
+ click.at = Point2(mb.x, mb.y);
+ click.to = click.at;
+ click.shift = mb.mod.shift;
+ selected_track = idx;
track_editor->update();
//drag select region
return;
-
}
-
-
SelectedKey sk;
- sk.track=idx;
- sk.key=key;
+ sk.track = idx;
+ sk.key = key;
KeyInfo ki;
- ki.pos= animation->track_get_key_time(idx,key);
- click.shift=mb.mod.shift;
- click.selk=sk;
-
+ ki.pos = animation->track_get_key_time(idx, key);
+ click.shift = mb.mod.shift;
+ click.selk = sk;
if (!mb.mod.shift && !selection.has(sk))
_clear_selection();
- selection.insert(sk,ki);
+ selection.insert(sk, ki);
- click.click=ClickOver::CLICK_MOVE_KEYS;
- click.at=Point2(mb.x,mb.y);
- click.to=click.at;
+ click.click = ClickOver::CLICK_MOVE_KEYS;
+ click.at = Point2(mb.x, mb.y);
+ click.to = click.at;
update();
- selected_track=idx;
+ selected_track = idx;
track_editor->update();
if (_edit_if_single_selection() && mb.mod.command) {
@@ -2257,7 +2140,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
int ofsx = size.width - mpos.x;
if (ofsx < 0)
break;
-/*
+ /*
if (ofsx < remove_icon->get_width()) {
undo_redo->create_action("Remove Anim Track");
@@ -2318,50 +2201,46 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
ofsx-=hsep*3+move_up_icon->get_width();
*/
-
if (ofsx < track_ofs[1]) {
track_menu->clear();
- track_menu->set_size(Point2(1,1));
- static const char *interp_name[2]={"Clamp Loop Interp","Wrap Loop Interp"};
- for(int i=0;i<2;i++) {
- track_menu->add_icon_item(wrap_icon[i],interp_name[i]);
+ track_menu->set_size(Point2(1, 1));
+ static const char *interp_name[2] = { "Clamp Loop Interp", "Wrap Loop Interp" };
+ for (int i = 0; i < 2; i++) {
+ track_menu->add_icon_item(wrap_icon[i], interp_name[i]);
}
- int popup_y = ofs.y+((int(mpos.y)/h)+2)*h;
- int popup_x = size.width-track_ofs[1];
+ int popup_y = ofs.y + ((int(mpos.y) / h) + 2) * h;
+ int popup_x = size.width - track_ofs[1];
- track_menu->set_pos(te->get_global_pos()+Point2(popup_x,popup_y));
+ track_menu->set_pos(te->get_global_pos() + Point2(popup_x, popup_y));
-
- wrap_editing=idx;
- interp_editing=-1;
- cont_editing=-1;
+ wrap_editing = idx;
+ interp_editing = -1;
+ cont_editing = -1;
track_menu->popup();
return;
}
-
if (ofsx < track_ofs[2]) {
track_menu->clear();
- track_menu->set_size(Point2(1,1));
- static const char *interp_name[3]={"Nearest","Linear","Cubic"};
- for(int i=0;i<3;i++) {
- track_menu->add_icon_item(interp_icon[i],interp_name[i]);
+ track_menu->set_size(Point2(1, 1));
+ static const char *interp_name[3] = { "Nearest", "Linear", "Cubic" };
+ for (int i = 0; i < 3; i++) {
+ track_menu->add_icon_item(interp_icon[i], interp_name[i]);
}
- int popup_y = ofs.y+((int(mpos.y)/h)+2)*h;
- int popup_x = size.width-track_ofs[2];
+ int popup_y = ofs.y + ((int(mpos.y) / h) + 2) * h;
+ int popup_x = size.width - track_ofs[2];
- track_menu->set_pos(te->get_global_pos()+Point2(popup_x,popup_y));
+ track_menu->set_pos(te->get_global_pos() + Point2(popup_x, popup_y));
-
- interp_editing=idx;
- cont_editing=-1;
- wrap_editing=-1;
+ interp_editing = idx;
+ cont_editing = -1;
+ wrap_editing = -1;
track_menu->popup();
@@ -2371,21 +2250,20 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
if (ofsx < track_ofs[3]) {
track_menu->clear();
- track_menu->set_size(Point2(1,1));
- String cont_name[3]={TTR("Continuous"),TTR("Discrete"),TTR("Trigger")};
- for(int i=0;i<3;i++) {
- track_menu->add_icon_item(cont_icon[i],cont_name[i]);
+ track_menu->set_size(Point2(1, 1));
+ String cont_name[3] = { TTR("Continuous"), TTR("Discrete"), TTR("Trigger") };
+ for (int i = 0; i < 3; i++) {
+ track_menu->add_icon_item(cont_icon[i], cont_name[i]);
}
+ int popup_y = ofs.y + ((int(mpos.y) / h) + 2) * h;
+ int popup_x = size.width - track_ofs[3];
- int popup_y = ofs.y+((int(mpos.y)/h)+2)*h;
- int popup_x = size.width-track_ofs[3];
-
- track_menu->set_pos(te->get_global_pos()+Point2(popup_x,popup_y));
+ track_menu->set_pos(te->get_global_pos() + Point2(popup_x, popup_y));
- interp_editing=-1;
- wrap_editing=-1;
- cont_editing=idx;
+ interp_editing = -1;
+ wrap_editing = -1;
+ cont_editing = idx;
track_menu->popup();
@@ -2397,85 +2275,76 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
Animation::TrackType tt = animation->track_get_type(idx);
float pos = timeline_pos;
- int existing = animation->track_find_key(idx,pos,true);
-
-
+ int existing = animation->track_find_key(idx, pos, true);
Variant newval;
- if (tt==Animation::TYPE_TRANSFORM) {
+ if (tt == Animation::TYPE_TRANSFORM) {
Dictionary d;
- d["loc"]=Vector3();
- d["rot"]=Quat();
- d["scale"]=Vector3();
- newval=d;
+ d["loc"] = Vector3();
+ d["rot"] = Quat();
+ d["scale"] = Vector3();
+ newval = d;
- } else if (tt==Animation::TYPE_METHOD) {
+ } else if (tt == Animation::TYPE_METHOD) {
Dictionary d;
- d["method"]="";
- d["args"]=Vector<Variant>();
-
+ d["method"] = "";
+ d["args"] = Vector<Variant>();
- newval=d;
- } else if (tt==Animation::TYPE_VALUE) {
+ newval = d;
+ } else if (tt == Animation::TYPE_VALUE) {
NodePath np;
- PropertyInfo inf = _find_hint_for_track(idx,np);
- if (inf.type!=Variant::NIL) {
+ PropertyInfo inf = _find_hint_for_track(idx, np);
+ if (inf.type != Variant::NIL) {
Variant::CallError err;
- newval=Variant::construct(inf.type,NULL,0,err);
-
+ newval = Variant::construct(inf.type, NULL, 0, err);
}
- if (newval.get_type()==Variant::NIL) {
+ if (newval.get_type() == Variant::NIL) {
//popup a new type
- cvi_track=idx;
- cvi_pos=pos;
+ cvi_track = idx;
+ cvi_pos = pos;
- type_menu->set_pos( get_global_pos() + mpos +ofs );
+ type_menu->set_pos(get_global_pos() + mpos + ofs);
type_menu->popup();
return;
}
-
}
undo_redo->create_action(TTR("Anim Add Key"));
- undo_redo->add_do_method(animation.ptr(),"track_insert_key",idx,pos,newval,1);
- undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",idx,pos);
+ undo_redo->add_do_method(animation.ptr(), "track_insert_key", idx, pos, newval, 1);
+ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_pos", idx, pos);
- if (existing!=-1) {
- Variant v = animation->track_get_key_value(idx,existing);
- float trans = animation->track_get_key_transition(idx,existing);
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",idx,pos,v,trans);
+ if (existing != -1) {
+ Variant v = animation->track_get_key_value(idx, existing);
+ float trans = animation->track_get_key_transition(idx, existing);
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", idx, pos, v, trans);
}
undo_redo->commit_action();
-
return;
}
-
}
} else {
- switch(click.click) {
+ switch (click.click) {
case ClickOver::CLICK_SELECT_KEYS: {
-
- float zoom_scale=_get_zoom_scale();
+ float zoom_scale = _get_zoom_scale();
float keys_from = h_scroll->get_value();
- float keys_to = keys_from + (settings_limit-name_limit) / zoom_scale;
-
- float from_time = keys_from + ( click.at.x - (name_limit+ofs.x)) / zoom_scale;
- float to_time = keys_from + (click.to.x - (name_limit+ofs.x)) / zoom_scale;
+ float keys_to = keys_from + (settings_limit - name_limit) / zoom_scale;
+ float from_time = keys_from + (click.at.x - (name_limit + ofs.x)) / zoom_scale;
+ float to_time = keys_from + (click.to.x - (name_limit + ofs.x)) / zoom_scale;
if (to_time < from_time)
- SWAP(from_time,to_time);
+ SWAP(from_time, to_time);
if (from_time > keys_to || to_time < keys_from)
break;
@@ -2486,30 +2355,26 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
if (to_time >= keys_to)
to_time = keys_to;
-
- int from_track = int(click.at.y-ofs.y-h-sep) / h + v_scroll->get_value();
- int to_track = int(click.to.y-ofs.y-h-sep) / h + v_scroll->get_value();
- int from_mod = int(click.at.y-ofs.y-sep) % h;
- int to_mod = int(click.to.y-ofs.y-sep) % h;
+ int from_track = int(click.at.y - ofs.y - h - sep) / h + v_scroll->get_value();
+ int to_track = int(click.to.y - ofs.y - h - sep) / h + v_scroll->get_value();
+ int from_mod = int(click.at.y - ofs.y - sep) % h;
+ int to_mod = int(click.to.y - ofs.y - sep) % h;
if (to_track < from_track) {
- SWAP(from_track,to_track);
- SWAP(from_mod,to_mod);
+ SWAP(from_track, to_track);
+ SWAP(from_mod, to_mod);
}
-
-
-
- if ((from_mod > (h/2)) && ((click.at.y-ofs.y)>=(h+sep))) {
+ if ((from_mod > (h / 2)) && ((click.at.y - ofs.y) >= (h + sep))) {
from_track++;
}
- if (to_mod < h/2) {
+ if (to_mod < h / 2) {
to_track--;
}
- if (from_track>to_track) {
+ if (from_track > to_track) {
if (!click.shift)
_clear_selection();
_edit_if_single_selection();
@@ -2517,18 +2382,18 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
}
int tracks_from = v_scroll->get_value();
- int tracks_to = v_scroll->get_value()+fit-1;
- if (tracks_to>=animation->get_track_count())
- tracks_to=animation->get_track_count()-1;
+ int tracks_to = v_scroll->get_value() + fit - 1;
+ if (tracks_to >= animation->get_track_count())
+ tracks_to = animation->get_track_count() - 1;
- tracks_from=0;
- tracks_to=animation->get_track_count()-1;
- if (to_track >tracks_to)
+ tracks_from = 0;
+ tracks_to = animation->get_track_count() - 1;
+ if (to_track > tracks_to)
to_track = tracks_to;
- if (from_track<tracks_from)
- from_track=tracks_from;
+ if (from_track < tracks_from)
+ from_track = tracks_from;
- if (from_track > tracks_to || to_track < tracks_from) {
+ if (from_track > tracks_to || to_track < tracks_from) {
if (!click.shift)
_clear_selection();
_edit_if_single_selection();
@@ -2538,52 +2403,49 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
if (!click.shift)
_clear_selection();
+ int higher_track = 0x7FFFFFFF;
+ for (int i = from_track; i <= to_track; i++) {
- int higher_track=0x7FFFFFFF;
- for(int i=from_track;i<=to_track;i++) {
-
- int kc=animation->track_get_key_count(i);
- for(int j=0;j<kc;j++) {
+ int kc = animation->track_get_key_count(i);
+ for (int j = 0; j < kc; j++) {
- float t = animation->track_get_key_time(i,j);
- if (t<from_time)
+ float t = animation->track_get_key_time(i, j);
+ if (t < from_time)
continue;
- if (t>to_time)
+ if (t > to_time)
break;
- if (i<higher_track)
- higher_track=i;
+ if (i < higher_track)
+ higher_track = i;
SelectedKey sk;
- sk.track=i;
- sk.key=j;
+ sk.track = i;
+ sk.key = j;
KeyInfo ki;
- ki.pos=t;
- selection[sk]=ki;
+ ki.pos = t;
+ selection[sk] = ki;
}
}
- if (higher_track!=0x7FFFFFFF) {
- selected_track=higher_track;
+ if (higher_track != 0x7FFFFFFF) {
+ selected_track = higher_track;
track_editor->update();
}
-
_edit_if_single_selection();
-
} break;
case ClickOver::CLICK_MOVE_KEYS: {
if (selection.empty())
break;
- if (click.at==click.to) {
+ if (click.at == click.to) {
if (!click.shift) {
- KeyInfo ki=selection[click.selk];
+ KeyInfo ki = selection[click.selk];
_clear_selection();
- selection[click.selk]=ki;
+ selection[click.selk] = ki;
_edit_if_single_selection();
}
@@ -2592,114 +2454,103 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
float from_t = 1e20;
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.front();E;E=E->next()) {
- float t = animation->track_get_key_time(E->key().track,E->key().key);
- if (t<from_t)
- from_t=t;
-
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.front(); E; E = E->next()) {
+ float t = animation->track_get_key_time(E->key().track, E->key().key);
+ if (t < from_t)
+ from_t = t;
}
- float motion = from_t+(click.to.x - click.at.x)/_get_zoom_scale();
+ float motion = from_t + (click.to.x - click.at.x) / _get_zoom_scale();
if (step->get_value())
- motion = Math::stepify(motion,step->get_value());
-
-
-
+ motion = Math::stepify(motion, step->get_value());
undo_redo->create_action(TTR("Anim Move Keys"));
List<_AnimMoveRestore> to_restore;
// 1-remove the keys
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
- undo_redo->add_do_method(animation.ptr(),"track_remove_key",E->key().track,E->key().key);
+ undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key);
}
// 2- remove overlapped keys
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
- float newtime = E->get().pos-from_t+motion;
- int idx = animation->track_find_key(E->key().track,newtime,true);
- if (idx==-1)
+ float newtime = E->get().pos - from_t + motion;
+ int idx = animation->track_find_key(E->key().track, newtime, true);
+ if (idx == -1)
continue;
SelectedKey sk;
- sk.key=idx;
- sk.track=E->key().track;
+ sk.key = idx;
+ sk.track = E->key().track;
if (selection.has(sk))
continue; //already in selection, don't save
- undo_redo->add_do_method(animation.ptr(),"track_remove_key_at_pos",E->key().track,newtime);
+ undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_pos", E->key().track, newtime);
_AnimMoveRestore amr;
- amr.key=animation->track_get_key_value(E->key().track,idx);
- amr.track=E->key().track;
- amr.time=newtime;
- amr.transition=animation->track_get_key_transition(E->key().track,idx);
+ amr.key = animation->track_get_key_value(E->key().track, idx);
+ amr.track = E->key().track;
+ amr.time = newtime;
+ amr.transition = animation->track_get_key_transition(E->key().track, idx);
to_restore.push_back(amr);
-
}
// 3-move the keys (re insert them)
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
- float newpos=E->get().pos-from_t+motion;
+ float newpos = E->get().pos - from_t + motion;
/*
if (newpos<0)
continue; //no add at the begining
*/
- undo_redo->add_do_method(animation.ptr(),"track_insert_key",E->key().track,newpos,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key));
-
+ undo_redo->add_do_method(animation.ptr(), "track_insert_key", E->key().track, newpos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
// 4-(undo) remove inserted keys
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
- float newpos=E->get().pos+-from_t+motion;
+ float newpos = E->get().pos + -from_t + motion;
/*
if (newpos<0)
continue; //no remove what no inserted
*/
- undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",E->key().track,newpos);
-
+ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_pos", E->key().track, newpos);
}
// 5-(undo) reinsert keys
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
-
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",E->key().track,E->get().pos,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key));
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
// 6-(undo) reinsert overlapped keys
- for(List<_AnimMoveRestore>::Element *E=to_restore.front();E;E=E->next()) {
+ for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) {
_AnimMoveRestore &amr = E->get();
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",amr.track,amr.time,amr.key,amr.transition);
-
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition);
}
// 6-(undo) reinsert overlapped keys
- for(List<_AnimMoveRestore>::Element *E=to_restore.front();E;E=E->next()) {
+ for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) {
_AnimMoveRestore &amr = E->get();
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",amr.track,amr.time,amr.key,amr.transition);
-
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition);
}
- undo_redo->add_do_method(this,"_clear_selection_for_anim",animation);
- undo_redo->add_undo_method(this,"_clear_selection_for_anim",animation);
+ undo_redo->add_do_method(this, "_clear_selection_for_anim", animation);
+ undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation);
// 7-reselect
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
- float oldpos=E->get().pos;
- float newpos=oldpos-from_t+motion;
+ float oldpos = E->get().pos;
+ float newpos = oldpos - from_t + motion;
//if (newpos>=0)
- undo_redo->add_do_method(this,"_select_at_anim",animation,E->key().track,newpos);
- undo_redo->add_undo_method(this,"_select_at_anim",animation,E->key().track,oldpos);
-
+ undo_redo->add_do_method(this, "_select_at_anim", animation, E->key().track, newpos);
+ undo_redo->add_undo_method(this, "_select_at_anim", animation, E->key().track, oldpos);
}
undo_redo->commit_action();
@@ -2710,10 +2561,8 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
}
//button released
- click.click=ClickOver::CLICK_NONE;
+ click.click = ClickOver::CLICK_NONE;
track_editor->update();
-
-
}
}
@@ -2723,41 +2572,38 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
const InputEventMouseMotion &mb = p_input.mouse_motion;
- mouse_over.over=MouseOver::OVER_NONE;
- mouse_over.track=-1;
+ mouse_over.over = MouseOver::OVER_NONE;
+ mouse_over.track = -1;
te->update();
track_editor->set_tooltip("");
- if (!track_editor->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
+ if (!track_editor->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
track_editor->call_deferred("grab_focus");
+ if (click.click != ClickOver::CLICK_NONE) {
- if (click.click!=ClickOver::CLICK_NONE) {
-
- switch(click.click) {
+ switch (click.click) {
case ClickOver::CLICK_RESIZE_NAMES: {
-
float base = click.at.y;
- float clickp = click.at.x-ofs.x;
+ float clickp = click.at.x - ofs.x;
float dif = base - clickp;
- float target = mb.x+dif-ofs.x;
+ float target = mb.x + dif - ofs.x;
float ratio = target / settings_limit;
- if (ratio>0.9)
- ratio=0.9;
- else if (ratio<0.2)
- ratio=0.2;
-
- name_column_ratio=ratio;
+ if (ratio > 0.9)
+ ratio = 0.9;
+ else if (ratio < 0.2)
+ ratio = 0.2;
+ name_column_ratio = ratio;
} break;
case ClickOver::CLICK_DRAG_TIMELINE: {
- Point2 mpos = Point2(mb.x,mb.y)-ofs;
+ Point2 mpos = Point2(mb.x, mb.y) - ofs;
/*
if (mpos.x<name_limit)
mpos.x=name_limit;
@@ -2765,73 +2611,66 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
mpos.x=settings_limit;
*/
-
//int zoomw = settings_limit-name_limit;
float scale = _get_zoom_scale();
- float pos = h_scroll->get_value() + (mpos.x-name_limit) / scale;
+ float pos = h_scroll->get_value() + (mpos.x - name_limit) / scale;
if (animation->get_step()) {
- pos=Math::stepify(pos,animation->get_step());
-
+ pos = Math::stepify(pos, animation->get_step());
}
- if (pos<0)
- pos=0;
- if (pos>=animation->get_length())
- pos=animation->get_length();
+ if (pos < 0)
+ pos = 0;
+ if (pos >= animation->get_length())
+ pos = animation->get_length();
if (pos < h_scroll->get_value()) {
h_scroll->set_value(pos);
} else if (pos > h_scroll->get_value() + (settings_limit - name_limit) / scale) {
- h_scroll->set_value( pos - (settings_limit - name_limit) / scale );
+ h_scroll->set_value(pos - (settings_limit - name_limit) / scale);
}
- timeline_pos=pos;
- emit_signal("timeline_changed",pos,true);
-
-
+ timeline_pos = pos;
+ emit_signal("timeline_changed", pos, true);
} break;
case ClickOver::CLICK_SELECT_KEYS: {
- click.to=Point2(mb.x,mb.y);
- if (click.to.y<h && click.at.y>h && mb.relative_y<0) {
+ click.to = Point2(mb.x, mb.y);
+ if (click.to.y < h && click.at.y > h && mb.relative_y < 0) {
float prev = v_scroll->get_value();
- v_scroll->set_value( v_scroll->get_value() -1 );
- if (prev!=v_scroll->get_value())
- click.at.y+=h;
-
-
+ v_scroll->set_value(v_scroll->get_value() - 1);
+ if (prev != v_scroll->get_value())
+ click.at.y += h;
}
- if (click.to.y>size.height && click.at.y<size.height && mb.relative_y>0) {
+ if (click.to.y > size.height && click.at.y < size.height && mb.relative_y > 0) {
float prev = v_scroll->get_value();
- v_scroll->set_value( v_scroll->get_value() +1 );
- if (prev!=v_scroll->get_value())
- click.at.y-=h;
+ v_scroll->set_value(v_scroll->get_value() + 1);
+ if (prev != v_scroll->get_value())
+ click.at.y -= h;
}
} break;
case ClickOver::CLICK_MOVE_KEYS: {
- click.to=Point2(mb.x,mb.y);
+ click.to = Point2(mb.x, mb.y);
} break;
default: {}
}
return;
- } else if (mb.button_mask&BUTTON_MASK_MIDDLE) {
+ } else if (mb.button_mask & BUTTON_MASK_MIDDLE) {
int rel = mb.relative_x;
float relf = rel / _get_zoom_scale();
- h_scroll->set_value( h_scroll->get_value() - relf );
+ h_scroll->set_value(h_scroll->get_value() - relf);
}
- if (mb.button_mask==0) {
-
+ if (mb.button_mask == 0) {
- Point2 mpos = Point2(mb.x,mb.y)-ofs;
+ Point2 mpos = Point2(mb.x, mb.y) - ofs;
- if (mpos.y < h ) {
+ if (mpos.y < h) {
#if 0
//seek
//int zoomw = settings_limit-name_limit;
@@ -2849,130 +2688,123 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
mpos.y -= h;
int idx = mpos.y / h;
- idx+=v_scroll->get_value();
- if (idx <0 || idx>=animation->get_track_count())
+ idx += v_scroll->get_value();
+ if (idx < 0 || idx >= animation->get_track_count())
break;
- mouse_over.track=idx;
+ mouse_over.track = idx;
if (mpos.x < name_limit) {
//name column
-
- mouse_over.over=MouseOver::OVER_NAME;
+ mouse_over.over = MouseOver::OVER_NAME;
} else if (mpos.x < settings_limit) {
float pos = mpos.x - name_limit;
- pos/=_get_zoom_scale();
- pos+=h_scroll->get_value();
- float w_time = (type_icon[0]->get_width() / _get_zoom_scale())/2.0;
+ pos /= _get_zoom_scale();
+ pos += h_scroll->get_value();
+ float w_time = (type_icon[0]->get_width() / _get_zoom_scale()) / 2.0;
- int kidx = animation->track_find_key(idx,pos);
- int kidx_n = kidx+1;
+ int kidx = animation->track_find_key(idx, pos);
+ int kidx_n = kidx + 1;
bool found = false;
- if (kidx>=0 && kidx<animation->track_get_key_count(idx)) {
+ if (kidx >= 0 && kidx < animation->track_get_key_count(idx)) {
- float kpos = animation->track_get_key_time(idx,kidx);
- if (ABS(pos-kpos)<=w_time) {
+ float kpos = animation->track_get_key_time(idx, kidx);
+ if (ABS(pos - kpos) <= w_time) {
- mouse_over.over=MouseOver::OVER_KEY;
- mouse_over.track=idx;
- mouse_over.over_key=kidx;
- found=true;
+ mouse_over.over = MouseOver::OVER_KEY;
+ mouse_over.track = idx;
+ mouse_over.over_key = kidx;
+ found = true;
}
}
- if (!found && kidx_n>=0 && kidx_n<animation->track_get_key_count(idx)) {
+ if (!found && kidx_n >= 0 && kidx_n < animation->track_get_key_count(idx)) {
- float kpos = animation->track_get_key_time(idx,kidx_n);
- if (ABS(pos-kpos)<=w_time) {
+ float kpos = animation->track_get_key_time(idx, kidx_n);
+ if (ABS(pos - kpos) <= w_time) {
- mouse_over.over=MouseOver::OVER_KEY;
- mouse_over.track=idx;
- mouse_over.over_key=kidx_n;
- found=true;
+ mouse_over.over = MouseOver::OVER_KEY;
+ mouse_over.track = idx;
+ mouse_over.over_key = kidx_n;
+ found = true;
}
}
-
if (found) {
String text;
- text="time: "+rtos(animation->track_get_key_time(idx,mouse_over.over_key))+"\n";
-
+ text = "time: " + rtos(animation->track_get_key_time(idx, mouse_over.over_key)) + "\n";
- switch(animation->track_get_type(idx)) {
+ switch (animation->track_get_type(idx)) {
case Animation::TYPE_TRANSFORM: {
- Dictionary d = animation->track_get_key_value(idx,mouse_over.over_key);
+ Dictionary d = animation->track_get_key_value(idx, mouse_over.over_key);
if (d.has("loc"))
- text+="loc: "+String(d["loc"])+"\n";
+ text += "loc: " + String(d["loc"]) + "\n";
if (d.has("rot"))
- text+="rot: "+String(d["rot"])+"\n";
+ text += "rot: " + String(d["rot"]) + "\n";
if (d.has("scale"))
- text+="scale: "+String(d["scale"])+"\n";
+ text += "scale: " + String(d["scale"]) + "\n";
} break;
case Animation::TYPE_VALUE: {
- Variant v = animation->track_get_key_value(idx,mouse_over.over_key);
+ Variant v = animation->track_get_key_value(idx, mouse_over.over_key);
//text+="value: "+String(v)+"\n";
- bool prop_exists=false;
- Variant::Type valid_type=Variant::NIL;
- Object *obj=NULL;
+ bool prop_exists = false;
+ Variant::Type valid_type = Variant::NIL;
+ Object *obj = NULL;
RES res;
- Node *node = root->get_node_and_resource(animation->track_get_path(idx),res);
+ Node *node = root->get_node_and_resource(animation->track_get_path(idx), res);
if (res.is_valid()) {
- obj=res.ptr();
+ obj = res.ptr();
} else if (node) {
- obj=node;
+ obj = node;
}
if (obj) {
- valid_type=obj->get_static_property_type(animation->track_get_path(idx).get_property(),&prop_exists);
+ valid_type = obj->get_static_property_type(animation->track_get_path(idx).get_property(), &prop_exists);
}
- text+="type: "+Variant::get_type_name(v.get_type())+"\n";
- if (prop_exists && !Variant::can_convert(v.get_type(),valid_type)) {
- text+="value: "+String(v)+" (Invalid, expected type: "+Variant::get_type_name(valid_type)+")\n";
+ text += "type: " + Variant::get_type_name(v.get_type()) + "\n";
+ if (prop_exists && !Variant::can_convert(v.get_type(), valid_type)) {
+ text += "value: " + String(v) + " (Invalid, expected type: " + Variant::get_type_name(valid_type) + ")\n";
} else {
- text+="value: "+String(v)+"\n";
+ text += "value: " + String(v) + "\n";
}
} break;
case Animation::TYPE_METHOD: {
-
- Dictionary d = animation->track_get_key_value(idx,mouse_over.over_key);
+ Dictionary d = animation->track_get_key_value(idx, mouse_over.over_key);
if (d.has("method"))
- text+=String(d["method"]);
- text+="(";
+ text += String(d["method"]);
+ text += "(";
Vector<Variant> args;
if (d.has("args"))
- args=d["args"];
- for(int i=0;i<args.size();i++) {
+ args = d["args"];
+ for (int i = 0; i < args.size(); i++) {
- if (i>0)
- text+=", ";
- text+=String(args[i]);
+ if (i > 0)
+ text += ", ";
+ text += String(args[i]);
}
- text+=")\n";
+ text += ")\n";
} break;
}
- text+="easing: "+rtos(animation->track_get_key_transition(idx,mouse_over.over_key));
-
-
+ text += "easing: " + rtos(animation->track_get_key_transition(idx, mouse_over.over_key));
track_editor->set_tooltip(text);
return;
-
}
} else {
@@ -2980,7 +2812,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
int ofsx = size.width - mpos.x;
if (ofsx < 0)
break;
-/*
+ /*
if (ofsx < remove_icon->get_width()) {
mouse_over.over=MouseOver::OVER_REMOVE;
@@ -3008,51 +2840,45 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
*/
- if (ofsx < down_icon->get_width() + wrap_icon[0]->get_width() + hsep*3) {
+ if (ofsx < down_icon->get_width() + wrap_icon[0]->get_width() + hsep * 3) {
- mouse_over.over=MouseOver::OVER_WRAP;
+ mouse_over.over = MouseOver::OVER_WRAP;
return;
}
- ofsx-=hsep*3+wrap_icon[0]->get_width() + down_icon->get_width();
+ ofsx -= hsep * 3 + wrap_icon[0]->get_width() + down_icon->get_width();
- if (ofsx < down_icon->get_width() + interp_icon[0]->get_width() + hsep*3) {
+ if (ofsx < down_icon->get_width() + interp_icon[0]->get_width() + hsep * 3) {
- mouse_over.over=MouseOver::OVER_INTERP;
+ mouse_over.over = MouseOver::OVER_INTERP;
return;
}
+ ofsx -= hsep * 2 + interp_icon[0]->get_width() + down_icon->get_width();
- ofsx-=hsep*2+interp_icon[0]->get_width() + down_icon->get_width();
-
- if (ofsx < down_icon->get_width() + cont_icon[0]->get_width() +hsep*3) {
+ if (ofsx < down_icon->get_width() + cont_icon[0]->get_width() + hsep * 3) {
- mouse_over.over=MouseOver::OVER_VALUE;
+ mouse_over.over = MouseOver::OVER_VALUE;
return;
}
- ofsx-=hsep*3+cont_icon[0]->get_width() + down_icon->get_width();
+ ofsx -= hsep * 3 + cont_icon[0]->get_width() + down_icon->get_width();
if (ofsx < add_key_icon->get_width()) {
- mouse_over.over=MouseOver::OVER_ADD_KEY;
+ mouse_over.over = MouseOver::OVER_ADD_KEY;
return;
}
-
-
}
-
}
} break;
-
}
}
void AnimationKeyEditor::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
EditorNode::get_singleton()->update_keying();
@@ -3061,102 +2887,99 @@ void AnimationKeyEditor::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- key_editor->edit(key_edit);
-
- zoomicon->set_texture( get_icon("Zoom","EditorIcons") );
-
- menu_add_track->set_icon(get_icon("AddTrack","EditorIcons"));
- menu_add_track->get_popup()->add_icon_item(get_icon("KeyValue","EditorIcons"),"Add Normal Track",ADD_TRACK_MENU_ADD_VALUE_TRACK);
- menu_add_track->get_popup()->add_icon_item(get_icon("KeyXform","EditorIcons"),"Add Transform Track",ADD_TRACK_MENU_ADD_TRANSFORM_TRACK);
- menu_add_track->get_popup()->add_icon_item(get_icon("KeyCall","EditorIcons"),"Add Call Func Track",ADD_TRACK_MENU_ADD_CALL_TRACK);
-
- menu_track->set_icon(get_icon("Tools","EditorIcons"));
- menu_track->get_popup()->add_item(TTR("Scale Selection"),TRACK_MENU_SCALE);
- menu_track->get_popup()->add_item(TTR("Scale From Cursor"),TRACK_MENU_SCALE_PIVOT);
- menu_track->get_popup()->add_separator();
- menu_track->get_popup()->add_item(TTR("Duplicate Selection"),TRACK_MENU_DUPLICATE);
- menu_track->get_popup()->add_item(TTR("Duplicate Transposed"),TRACK_MENU_DUPLICATE_TRANSPOSE);
- menu_track->get_popup()->add_separator();
- menu_track->get_popup()->add_item(TTR("Goto Next Step"),TRACK_MENU_NEXT_STEP,KEY_MASK_CMD|KEY_RIGHT);
- menu_track->get_popup()->add_item(TTR("Goto Prev Step"),TRACK_MENU_PREV_STEP,KEY_MASK_CMD|KEY_LEFT);
- menu_track->get_popup()->add_separator();
- PopupMenu *tpp = memnew( PopupMenu );
- tpp->add_item(TTR("Linear"),TRACK_MENU_SET_ALL_TRANS_LINEAR);
- tpp->add_item(TTR("Constant"),TRACK_MENU_SET_ALL_TRANS_CONSTANT);
- tpp->add_item(TTR("In"),TRACK_MENU_SET_ALL_TRANS_IN);
- tpp->add_item(TTR("Out"),TRACK_MENU_SET_ALL_TRANS_OUT);
- tpp->add_item(TTR("In-Out"),TRACK_MENU_SET_ALL_TRANS_INOUT);
- tpp->add_item(TTR("Out-In"),TRACK_MENU_SET_ALL_TRANS_OUTIN);
- tpp->set_name(TTR("Transitions"));
- tpp->connect("id_pressed",this,"_menu_track");
- optimize_dialog->connect("confirmed",this,"_animation_optimize");
-
- menu_track->get_popup()->add_child(tpp);
- //menu_track->get_popup()->add_submenu_item("Set Transitions..","Transitions");
- //menu_track->get_popup()->add_separator();
- menu_track->get_popup()->add_item(TTR("Optimize Animation"),TRACK_MENU_OPTIMIZE);
- menu_track->get_popup()->add_item(TTR("Clean-Up Animation"),TRACK_MENU_CLEAN_UP);
-
- curve_linear->set_icon(get_icon("CurveLinear","EditorIcons"));
- curve_in->set_icon(get_icon("CurveIn","EditorIcons"));
- curve_out->set_icon(get_icon("CurveOut","EditorIcons"));
- curve_inout->set_icon(get_icon("CurveInOut","EditorIcons"));
- curve_outin->set_icon(get_icon("CurveOutIn","EditorIcons"));
- curve_constant->set_icon(get_icon("CurveConstant","EditorIcons"));
-
- curve_linear->connect("pressed",this,"_menu_track",varray(CURVE_SET_LINEAR));
- curve_in->connect("pressed",this,"_menu_track",varray(CURVE_SET_IN));
- curve_out->connect("pressed",this,"_menu_track",varray(CURVE_SET_OUT));
- curve_inout->connect("pressed",this,"_menu_track",varray(CURVE_SET_INOUT));
- curve_outin->connect("pressed",this,"_menu_track",varray(CURVE_SET_OUTIN));
- curve_constant->connect("pressed",this,"_menu_track",varray(CURVE_SET_CONSTANT));
-
-
- move_up_button->set_icon(get_icon("MoveUp","EditorIcons"));
- move_down_button->set_icon(get_icon("MoveDown","EditorIcons"));
- remove_button->set_icon(get_icon("Remove","EditorIcons"));
- edit_button->set_icon(get_icon("EditKey","EditorIcons"));
- edit_button->connect("pressed",this,"_toggle_edit_curves");
-
- loop->set_icon(get_icon("Loop","EditorIcons"));
- curve_edit->connect("transition_changed",this,"_curve_transition_changed");
-
- //edit_button->add_color_override("font_color",get_color("font_color","Tree"));
- //edit_button->add_color_override("font_color_hover",get_color("font_color","Tree"));
-
- {
-
- right_data_size_cache=0;
- int hsep = get_constant("hseparation","Tree");
- Ref<Texture> remove_icon = get_icon("Remove","EditorIcons");
- Ref<Texture> move_up_icon = get_icon("MoveUp","EditorIcons");
- Ref<Texture> move_down_icon = get_icon("MoveDown","EditorIcons");
- Ref<Texture> down_icon = get_icon("select_arrow","Tree");
- Ref<Texture> add_key_icon = get_icon("TrackAddKey","EditorIcons");
- Ref<Texture> interp_icon[3]={
- get_icon("InterpRaw","EditorIcons"),
- get_icon("InterpLinear","EditorIcons"),
- get_icon("InterpCubic","EditorIcons")
- };
- Ref<Texture> cont_icon[3]={
- get_icon("TrackContinuous","EditorIcons"),
- get_icon("TrackDiscrete","EditorIcons"),
- get_icon("TrackTrigger","EditorIcons")
- };
-
- Ref<Texture> wrap_icon[2]={
- get_icon("InterpWrapClamp","EditorIcons"),
- get_icon("InterpWrapLoop","EditorIcons"),
- };
-
- //right_data_size_cache = remove_icon->get_width() + move_up_icon->get_width() + move_down_icon->get_width() + down_icon->get_width() *2 + interp_icon[0]->get_width() + cont_icon[0]->get_width() + add_key_icon->get_width() + hsep*11;
- right_data_size_cache = down_icon->get_width() *3 + add_key_icon->get_width() + interp_icon[0]->get_width() + cont_icon[0]->get_width() + wrap_icon[0]->get_width() + hsep*8;
+ key_editor->edit(key_edit);
+
+ zoomicon->set_texture(get_icon("Zoom", "EditorIcons"));
+
+ menu_add_track->set_icon(get_icon("AddTrack", "EditorIcons"));
+ menu_add_track->get_popup()->add_icon_item(get_icon("KeyValue", "EditorIcons"), "Add Normal Track", ADD_TRACK_MENU_ADD_VALUE_TRACK);
+ menu_add_track->get_popup()->add_icon_item(get_icon("KeyXform", "EditorIcons"), "Add Transform Track", ADD_TRACK_MENU_ADD_TRANSFORM_TRACK);
+ menu_add_track->get_popup()->add_icon_item(get_icon("KeyCall", "EditorIcons"), "Add Call Func Track", ADD_TRACK_MENU_ADD_CALL_TRACK);
+
+ menu_track->set_icon(get_icon("Tools", "EditorIcons"));
+ menu_track->get_popup()->add_item(TTR("Scale Selection"), TRACK_MENU_SCALE);
+ menu_track->get_popup()->add_item(TTR("Scale From Cursor"), TRACK_MENU_SCALE_PIVOT);
+ menu_track->get_popup()->add_separator();
+ menu_track->get_popup()->add_item(TTR("Duplicate Selection"), TRACK_MENU_DUPLICATE);
+ menu_track->get_popup()->add_item(TTR("Duplicate Transposed"), TRACK_MENU_DUPLICATE_TRANSPOSE);
+ menu_track->get_popup()->add_separator();
+ menu_track->get_popup()->add_item(TTR("Goto Next Step"), TRACK_MENU_NEXT_STEP, KEY_MASK_CMD | KEY_RIGHT);
+ menu_track->get_popup()->add_item(TTR("Goto Prev Step"), TRACK_MENU_PREV_STEP, KEY_MASK_CMD | KEY_LEFT);
+ menu_track->get_popup()->add_separator();
+ PopupMenu *tpp = memnew(PopupMenu);
+ tpp->add_item(TTR("Linear"), TRACK_MENU_SET_ALL_TRANS_LINEAR);
+ tpp->add_item(TTR("Constant"), TRACK_MENU_SET_ALL_TRANS_CONSTANT);
+ tpp->add_item(TTR("In"), TRACK_MENU_SET_ALL_TRANS_IN);
+ tpp->add_item(TTR("Out"), TRACK_MENU_SET_ALL_TRANS_OUT);
+ tpp->add_item(TTR("In-Out"), TRACK_MENU_SET_ALL_TRANS_INOUT);
+ tpp->add_item(TTR("Out-In"), TRACK_MENU_SET_ALL_TRANS_OUTIN);
+ tpp->set_name(TTR("Transitions"));
+ tpp->connect("id_pressed", this, "_menu_track");
+ optimize_dialog->connect("confirmed", this, "_animation_optimize");
+
+ menu_track->get_popup()->add_child(tpp);
+ //menu_track->get_popup()->add_submenu_item("Set Transitions..","Transitions");
+ //menu_track->get_popup()->add_separator();
+ menu_track->get_popup()->add_item(TTR("Optimize Animation"), TRACK_MENU_OPTIMIZE);
+ menu_track->get_popup()->add_item(TTR("Clean-Up Animation"), TRACK_MENU_CLEAN_UP);
+
+ curve_linear->set_icon(get_icon("CurveLinear", "EditorIcons"));
+ curve_in->set_icon(get_icon("CurveIn", "EditorIcons"));
+ curve_out->set_icon(get_icon("CurveOut", "EditorIcons"));
+ curve_inout->set_icon(get_icon("CurveInOut", "EditorIcons"));
+ curve_outin->set_icon(get_icon("CurveOutIn", "EditorIcons"));
+ curve_constant->set_icon(get_icon("CurveConstant", "EditorIcons"));
+
+ curve_linear->connect("pressed", this, "_menu_track", varray(CURVE_SET_LINEAR));
+ curve_in->connect("pressed", this, "_menu_track", varray(CURVE_SET_IN));
+ curve_out->connect("pressed", this, "_menu_track", varray(CURVE_SET_OUT));
+ curve_inout->connect("pressed", this, "_menu_track", varray(CURVE_SET_INOUT));
+ curve_outin->connect("pressed", this, "_menu_track", varray(CURVE_SET_OUTIN));
+ curve_constant->connect("pressed", this, "_menu_track", varray(CURVE_SET_CONSTANT));
+
+ move_up_button->set_icon(get_icon("MoveUp", "EditorIcons"));
+ move_down_button->set_icon(get_icon("MoveDown", "EditorIcons"));
+ remove_button->set_icon(get_icon("Remove", "EditorIcons"));
+ edit_button->set_icon(get_icon("EditKey", "EditorIcons"));
+ edit_button->connect("pressed", this, "_toggle_edit_curves");
+
+ loop->set_icon(get_icon("Loop", "EditorIcons"));
+ curve_edit->connect("transition_changed", this, "_curve_transition_changed");
+
+ //edit_button->add_color_override("font_color",get_color("font_color","Tree"));
+ //edit_button->add_color_override("font_color_hover",get_color("font_color","Tree"));
+ {
- }
- call_select->connect("selected",this,"_add_call_track");
- //rename_anim->set_icon( get_icon("Rename","EditorIcons") );
-/*
+ right_data_size_cache = 0;
+ int hsep = get_constant("hseparation", "Tree");
+ Ref<Texture> remove_icon = get_icon("Remove", "EditorIcons");
+ Ref<Texture> move_up_icon = get_icon("MoveUp", "EditorIcons");
+ Ref<Texture> move_down_icon = get_icon("MoveDown", "EditorIcons");
+ Ref<Texture> down_icon = get_icon("select_arrow", "Tree");
+ Ref<Texture> add_key_icon = get_icon("TrackAddKey", "EditorIcons");
+ Ref<Texture> interp_icon[3] = {
+ get_icon("InterpRaw", "EditorIcons"),
+ get_icon("InterpLinear", "EditorIcons"),
+ get_icon("InterpCubic", "EditorIcons")
+ };
+ Ref<Texture> cont_icon[3] = {
+ get_icon("TrackContinuous", "EditorIcons"),
+ get_icon("TrackDiscrete", "EditorIcons"),
+ get_icon("TrackTrigger", "EditorIcons")
+ };
+
+ Ref<Texture> wrap_icon[2] = {
+ get_icon("InterpWrapClamp", "EditorIcons"),
+ get_icon("InterpWrapLoop", "EditorIcons"),
+ };
+
+ //right_data_size_cache = remove_icon->get_width() + move_up_icon->get_width() + move_down_icon->get_width() + down_icon->get_width() *2 + interp_icon[0]->get_width() + cont_icon[0]->get_width() + add_key_icon->get_width() + hsep*11;
+ right_data_size_cache = down_icon->get_width() * 3 + add_key_icon->get_width() + interp_icon[0]->get_width() + cont_icon[0]->get_width() + wrap_icon[0]->get_width() + hsep * 8;
+ }
+ call_select->connect("selected", this, "_add_call_track");
+ //rename_anim->set_icon( get_icon("Rename","EditorIcons") );
+ /*
edit_anim->set_icon( get_icon("Edit","EditorIcons") );
blend_anim->set_icon( get_icon("Blend","EditorIcons") );
play->set_icon( get_icon("Play","EditorIcons") );
@@ -3169,14 +2992,9 @@ void AnimationKeyEditor::_notification(int p_what) {
_update_menu();
} break;
-
-
}
-
}
-
-
void AnimationKeyEditor::_scroll_changed(double) {
if (te_drawing)
@@ -3185,8 +3003,6 @@ void AnimationKeyEditor::_scroll_changed(double) {
track_editor->update();
}
-
-
void AnimationKeyEditor::_update_paths() {
if (animation.is_valid()) {
@@ -3198,16 +3014,14 @@ void AnimationKeyEditor::_update_paths() {
}
}
-
void AnimationKeyEditor::_root_removed() {
- root=NULL;
+ root = NULL;
}
void AnimationKeyEditor::_update_menu() {
-
- updating=true;
+ updating = true;
if (animation.is_valid()) {
@@ -3217,36 +3031,33 @@ void AnimationKeyEditor::_update_menu() {
}
track_editor->update();
- updating=false;
-
+ updating = false;
}
void AnimationKeyEditor::_clear_selection() {
selection.clear();
- key_edit->animation=Ref<Animation>();
- key_edit->track=0;
- key_edit->key_ofs=0;
- key_edit->hint=PropertyInfo();
- key_edit->base=NodePath();
+ key_edit->animation = Ref<Animation>();
+ key_edit->track = 0;
+ key_edit->key_ofs = 0;
+ key_edit->hint = PropertyInfo();
+ key_edit->base = NodePath();
key_edit->notify_change();
-
}
-
-void AnimationKeyEditor::set_animation(const Ref<Animation>& p_anim) {
+void AnimationKeyEditor::set_animation(const Ref<Animation> &p_anim) {
if (animation.is_valid())
- animation->disconnect("changed",this,"_update_paths");
- animation=p_anim;
+ animation->disconnect("changed", this, "_update_paths");
+ animation = p_anim;
if (animation.is_valid())
- animation->connect("changed",this,"_update_paths");
+ animation->connect("changed", this, "_update_paths");
- timeline_pos=0;
+ timeline_pos = 0;
_clear_selection();
_update_paths();
_update_menu();
- selected_track=-1;
+ selected_track = -1;
_edit_if_single_selection();
EditorNode::get_singleton()->update_keying();
@@ -3255,14 +3066,12 @@ void AnimationKeyEditor::set_animation(const Ref<Animation>& p_anim) {
void AnimationKeyEditor::set_root(Node *p_root) {
if (root)
- root->disconnect("tree_exited",this,"_root_removed");
+ root->disconnect("tree_exited", this, "_root_removed");
- root=p_root;
+ root = p_root;
if (root)
- root->connect("tree_exited",this,"_root_removed",make_binds(),CONNECT_ONESHOT);
-
-
+ root->connect("tree_exited", this, "_root_removed", make_binds(), CONNECT_ONESHOT);
}
Node *AnimationKeyEditor::get_root() const {
@@ -3270,22 +3079,16 @@ Node *AnimationKeyEditor::get_root() const {
return root;
}
-
-
-
-
-
void AnimationKeyEditor::update_keying() {
- bool keying_enabled=is_visible_in_tree() && animation.is_valid();
+ bool keying_enabled = is_visible_in_tree() && animation.is_valid();
- if (keying_enabled==keying)
+ if (keying_enabled == keying)
return;
- keying=keying_enabled;
+ keying = keying_enabled;
_update_menu();
emit_signal("keying_changed");
-
}
bool AnimationKeyEditor::has_keying() const {
@@ -3293,98 +3096,93 @@ bool AnimationKeyEditor::has_keying() const {
return keying;
}
-void AnimationKeyEditor::_query_insert(const InsertData& p_id) {
-
+void AnimationKeyEditor::_query_insert(const InsertData &p_id) {
- if (insert_frame!=Engine::get_singleton()->get_frames_drawn()) {
+ if (insert_frame != Engine::get_singleton()->get_frames_drawn()) {
//clear insert list for the frame if frame changed
if (insert_confirm->is_visible_in_tree())
return; //do nothing
insert_data.clear();
- insert_query=false;
+ insert_query = false;
}
- insert_frame=Engine::get_singleton()->get_frames_drawn();
+ insert_frame = Engine::get_singleton()->get_frames_drawn();
- for (List<InsertData>::Element *E=insert_data.front();E;E=E->next()) {
+ for (List<InsertData>::Element *E = insert_data.front(); E; E = E->next()) {
//prevent insertion of multiple tracks
- if (E->get().path==p_id.path)
+ if (E->get().path == p_id.path)
return; //already inserted a track for this on this frame
}
insert_data.push_back(p_id);
- if (p_id.track_idx==-1) {
- if (bool(EDITOR_DEF("editors/animation/confirm_insert_track",true))) {
+ if (p_id.track_idx == -1) {
+ if (bool(EDITOR_DEF("editors/animation/confirm_insert_track", true))) {
//potential new key, does not exist
- if (insert_data.size()==1)
- insert_confirm->set_text(vformat(TTR("Create NEW track for %s and insert key?"),p_id.query));
+ if (insert_data.size() == 1)
+ insert_confirm->set_text(vformat(TTR("Create NEW track for %s and insert key?"), p_id.query));
else
- insert_confirm->set_text(vformat(TTR("Create %d NEW tracks and insert keys?"),insert_data.size()));
+ insert_confirm->set_text(vformat(TTR("Create %d NEW tracks and insert keys?"), insert_data.size()));
insert_confirm->get_ok()->set_text(TTR("Create"));
insert_confirm->popup_centered_minsize();
- insert_query=true;
+ insert_query = true;
} else {
call_deferred("_insert_delay");
- insert_queue=true;
+ insert_queue = true;
}
} else {
if (!insert_query && !insert_queue) {
call_deferred("_insert_delay");
- insert_queue=true;
+ insert_queue = true;
}
}
-
}
-void AnimationKeyEditor::insert_transform_key(Spatial *p_node,const String& p_sub,const Transform& p_xform) {
+void AnimationKeyEditor::insert_transform_key(Spatial *p_node, const String &p_sub, const Transform &p_xform) {
if (!keying)
return;
if (!animation.is_valid())
return;
-
ERR_FAIL_COND(!root);
//let's build a node path
String path = root->get_path_to(p_node);
- if (p_sub!="")
- path+=":"+p_sub;
+ if (p_sub != "")
+ path += ":" + p_sub;
- NodePath np=path;
+ NodePath np = path;
- int track_idx=-1;
+ int track_idx = -1;
- for(int i=0;i<animation->get_track_count();i++) {
+ for (int i = 0; i < animation->get_track_count(); i++) {
- if (animation->track_get_type(i)!=Animation::TYPE_TRANSFORM)
+ if (animation->track_get_type(i) != Animation::TYPE_TRANSFORM)
continue;
- if (animation->track_get_path(i)!=np)
+ if (animation->track_get_path(i) != np)
continue;
- track_idx=i;
+ track_idx = i;
break;
}
InsertData id;
Dictionary val;
- id.path=np;
- id.track_idx=track_idx;
- id.value=p_xform;
- id.type=Animation::TYPE_TRANSFORM;
- id.query="node '"+p_node->get_name()+"'";
- id.advance=false;
+ id.path = np;
+ id.track_idx = track_idx;
+ id.value = p_xform;
+ id.type = Animation::TYPE_TRANSFORM;
+ id.query = "node '" + p_node->get_name() + "'";
+ id.advance = false;
//dialog insert
_query_insert(id);
-
}
-
-void AnimationKeyEditor::insert_node_value_key(Node* p_node, const String& p_property,const Variant& p_value,bool p_only_if_exists) {
+void AnimationKeyEditor::insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists) {
ERR_FAIL_COND(!root);
//let's build a node path
@@ -3393,54 +3191,50 @@ void AnimationKeyEditor::insert_node_value_key(Node* p_node, const String& p_pro
String path = root->get_path_to(node);
- for(int i=1;i<history->get_path_size();i++) {
+ for (int i = 1; i < history->get_path_size(); i++) {
String prop = history->get_path_property(i);
- ERR_FAIL_COND(prop=="");
- path+=":"+prop;
+ ERR_FAIL_COND(prop == "");
+ path += ":" + prop;
}
-
- path+=":"+p_property;
+ path += ":" + p_property;
NodePath np = path;
//locate track
- int track_idx=-1;
+ int track_idx = -1;
- for(int i=0;i<animation->get_track_count();i++) {
+ for (int i = 0; i < animation->get_track_count(); i++) {
- if (animation->track_get_type(i)!=Animation::TYPE_VALUE)
+ if (animation->track_get_type(i) != Animation::TYPE_VALUE)
continue;
- if (animation->track_get_path(i)!=np)
+ if (animation->track_get_path(i) != np)
continue;
- track_idx=i;
+ track_idx = i;
break;
}
- if (p_only_if_exists && track_idx==-1)
+ if (p_only_if_exists && track_idx == -1)
return;
InsertData id;
- id.path=np;
- id.track_idx=track_idx;
- id.value=p_value;
- id.type=Animation::TYPE_VALUE;
- id.query="property '"+p_property+"'";
- id.advance=false;
+ id.path = np;
+ id.track_idx = track_idx;
+ id.value = p_value;
+ id.type = Animation::TYPE_VALUE;
+ id.query = "property '" + p_property + "'";
+ id.advance = false;
//dialog insert
_query_insert(id);
-
-
-
}
-void AnimationKeyEditor::insert_value_key(const String& p_property,const Variant& p_value,bool p_advance) {
+void AnimationKeyEditor::insert_value_key(const String &p_property, const Variant &p_value, bool p_advance) {
ERR_FAIL_COND(!root);
//let's build a node path
- ERR_FAIL_COND(history->get_path_size()==0);
+ ERR_FAIL_COND(history->get_path_size() == 0);
Object *obj = ObjectDB::get_instance(history->get_path_object(0));
ERR_FAIL_COND(!obj || !obj->cast_to<Node>());
@@ -3448,110 +3242,104 @@ void AnimationKeyEditor::insert_value_key(const String& p_property,const Variant
String path = root->get_path_to(node);
- for(int i=1;i<history->get_path_size();i++) {
+ for (int i = 1; i < history->get_path_size(); i++) {
String prop = history->get_path_property(i);
- ERR_FAIL_COND(prop=="");
- path+=":"+prop;
+ ERR_FAIL_COND(prop == "");
+ path += ":" + prop;
}
-
-
- path+=":"+p_property;
+ path += ":" + p_property;
NodePath np = path;
//locate track
- int track_idx=-1;
+ int track_idx = -1;
- for(int i=0;i<animation->get_track_count();i++) {
+ for (int i = 0; i < animation->get_track_count(); i++) {
- if (animation->track_get_type(i)!=Animation::TYPE_VALUE)
+ if (animation->track_get_type(i) != Animation::TYPE_VALUE)
continue;
- if (animation->track_get_path(i)!=np)
+ if (animation->track_get_path(i) != np)
continue;
- track_idx=i;
+ track_idx = i;
break;
}
InsertData id;
- id.path=np;
- id.track_idx=track_idx;
- id.value=p_value;
- id.type=Animation::TYPE_VALUE;
- id.query="property '"+p_property+"'";
- id.advance=p_advance;
+ id.path = np;
+ id.track_idx = track_idx;
+ id.value = p_value;
+ id.type = Animation::TYPE_VALUE;
+ id.query = "property '" + p_property + "'";
+ id.advance = p_advance;
//dialog insert
_query_insert(id);
-
-
-
}
void AnimationKeyEditor::_confirm_insert_list() {
-
undo_redo->create_action(TTR("Anim Create & Insert"));
int last_track = animation->get_track_count();
- while(insert_data.size()) {
+ while (insert_data.size()) {
- last_track=_confirm_insert(insert_data.front()->get(),last_track);
+ last_track = _confirm_insert(insert_data.front()->get(), last_track);
insert_data.pop_front();
}
undo_redo->commit_action();
}
-int AnimationKeyEditor::_confirm_insert(InsertData p_id,int p_last_track) {
+int AnimationKeyEditor::_confirm_insert(InsertData p_id, int p_last_track) {
- if (p_last_track==-1)
- p_last_track=animation->get_track_count();
+ if (p_last_track == -1)
+ p_last_track = animation->get_track_count();
- bool created=false;
- if (p_id.track_idx<0) {
+ bool created = false;
+ if (p_id.track_idx < 0) {
- created=true;
+ created = true;
undo_redo->create_action(TTR("Anim Insert Track & Key"));
- Animation::UpdateMode update_mode=Animation::UPDATE_DISCRETE;
+ Animation::UpdateMode update_mode = Animation::UPDATE_DISCRETE;
- if (p_id.type==Animation::TYPE_VALUE) {
+ if (p_id.type == Animation::TYPE_VALUE) {
//wants a new tack
{
//shitty hack
NodePath np;
animation->add_track(p_id.type);
- animation->track_set_path(animation->get_track_count()-1,p_id.path);
- PropertyInfo h = _find_hint_for_track(animation->get_track_count()-1,np);
- animation->remove_track(animation->get_track_count()-1); //hack
-
- if ( h.type==Variant::REAL ||
- h.type==Variant::VECTOR2 ||
- h.type==Variant::RECT2 ||
- h.type==Variant::VECTOR3 ||
- h.type==Variant::RECT3 ||
- h.type==Variant::QUAT ||
- h.type==Variant::COLOR ||
- h.type==Variant::TRANSFORM ) {
-
- update_mode=Animation::UPDATE_CONTINUOUS;
+ animation->track_set_path(animation->get_track_count() - 1, p_id.path);
+ PropertyInfo h = _find_hint_for_track(animation->get_track_count() - 1, np);
+ animation->remove_track(animation->get_track_count() - 1); //hack
+
+ if (h.type == Variant::REAL ||
+ h.type == Variant::VECTOR2 ||
+ h.type == Variant::RECT2 ||
+ h.type == Variant::VECTOR3 ||
+ h.type == Variant::RECT3 ||
+ h.type == Variant::QUAT ||
+ h.type == Variant::COLOR ||
+ h.type == Variant::TRANSFORM) {
+
+ update_mode = Animation::UPDATE_CONTINUOUS;
}
- if (h.usage&PROPERTY_USAGE_ANIMATE_AS_TRIGGER) {
- update_mode=Animation::UPDATE_TRIGGER;
+ if (h.usage & PROPERTY_USAGE_ANIMATE_AS_TRIGGER) {
+ update_mode = Animation::UPDATE_TRIGGER;
}
}
}
- p_id.track_idx=p_last_track;
+ p_id.track_idx = p_last_track;
- undo_redo->add_do_method(animation.ptr(),"add_track",p_id.type);
- undo_redo->add_do_method(animation.ptr(),"track_set_path",p_id.track_idx,p_id.path);
- if (p_id.type==Animation::TYPE_VALUE)
- undo_redo->add_do_method(animation.ptr(),"value_track_set_update_mode",p_id.track_idx,update_mode);
+ undo_redo->add_do_method(animation.ptr(), "add_track", p_id.type);
+ undo_redo->add_do_method(animation.ptr(), "track_set_path", p_id.track_idx, p_id.path);
+ if (p_id.type == Animation::TYPE_VALUE)
+ undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", p_id.track_idx, update_mode);
} else {
undo_redo->create_action(TTR("Anim Insert Key"));
@@ -3560,64 +3348,55 @@ int AnimationKeyEditor::_confirm_insert(InsertData p_id,int p_last_track) {
float time = timeline_pos;
Variant value;
-
- switch(p_id.type) {
+ switch (p_id.type) {
case Animation::TYPE_VALUE: {
value = p_id.value;
-
} break;
case Animation::TYPE_TRANSFORM: {
-
Transform tr = p_id.value;
Dictionary d;
- d["loc"]=tr.origin;
- d["scale"]=tr.basis.get_scale();
- d["rot"]=Quat(tr.basis);//.orthonormalized();
- value=d;
+ d["loc"] = tr.origin;
+ d["scale"] = tr.basis.get_scale();
+ d["rot"] = Quat(tr.basis); //.orthonormalized();
+ value = d;
} break;
- default:{}
+ default: {}
}
-
-
- undo_redo->add_do_method(animation.ptr(),"track_insert_key",p_id.track_idx,time,value);
+ undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_id.track_idx, time, value);
if (created) {
//just remove the track
- undo_redo->add_undo_method(animation.ptr(),"remove_track",p_last_track);
+ undo_redo->add_undo_method(animation.ptr(), "remove_track", p_last_track);
p_last_track++;
} else {
- undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",p_id.track_idx,time);
- int existing = animation->track_find_key(p_id.track_idx,time,true);
- if (existing!=-1) {
- Variant v = animation->track_get_key_value(p_id.track_idx,existing);
- float trans = animation->track_get_key_transition(p_id.track_idx,existing);
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",p_id.track_idx,time,v,trans);
+ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_pos", p_id.track_idx, time);
+ int existing = animation->track_find_key(p_id.track_idx, time, true);
+ if (existing != -1) {
+ Variant v = animation->track_get_key_value(p_id.track_idx, existing);
+ float trans = animation->track_get_key_transition(p_id.track_idx, existing);
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", p_id.track_idx, time, v, trans);
}
}
- undo_redo->add_do_method(this,"update");
- undo_redo->add_undo_method(this,"update");
- undo_redo->add_do_method(track_editor,"update");
- undo_redo->add_undo_method(track_editor,"update");
- undo_redo->add_do_method(track_pos,"update");
- undo_redo->add_undo_method(track_pos,"update");
+ undo_redo->add_do_method(this, "update");
+ undo_redo->add_undo_method(this, "update");
+ undo_redo->add_do_method(track_editor, "update");
+ undo_redo->add_undo_method(track_editor, "update");
+ undo_redo->add_do_method(track_pos, "update");
+ undo_redo->add_undo_method(track_pos, "update");
undo_redo->commit_action();
return p_last_track;
-
}
-
-
-
Ref<Animation> AnimationKeyEditor::get_current_animation() const {
return animation;
@@ -3625,32 +3404,30 @@ Ref<Animation> AnimationKeyEditor::get_current_animation() const {
void AnimationKeyEditor::_animation_len_changed(float p_len) {
-
if (updating)
return;
if (!animation.is_null()) {
undo_redo->create_action(TTR("Change Anim Len"));
- undo_redo->add_do_method(animation.ptr(),"set_length",p_len);
- undo_redo->add_undo_method(animation.ptr(),"set_length",animation->get_length());
- undo_redo->add_do_method(this,"_animation_len_update");
- undo_redo->add_undo_method(this,"_animation_len_update");
+ undo_redo->add_do_method(animation.ptr(), "set_length", p_len);
+ undo_redo->add_undo_method(animation.ptr(), "set_length", animation->get_length());
+ undo_redo->add_do_method(this, "_animation_len_update");
+ undo_redo->add_undo_method(this, "_animation_len_update");
undo_redo->commit_action();
}
}
void AnimationKeyEditor::_animation_len_update() {
- if (!animation.is_null())
- emit_signal(alc,animation->get_length());
+ if (!animation.is_null())
+ emit_signal(alc, animation->get_length());
}
void AnimationKeyEditor::_animation_changed() {
if (updating)
return;
_update_menu();
-
}
void AnimationKeyEditor::_animation_loop_changed() {
@@ -3661,73 +3438,68 @@ void AnimationKeyEditor::_animation_loop_changed() {
if (!animation.is_null()) {
undo_redo->create_action(TTR("Change Anim Loop"));
- undo_redo->add_do_method(animation.ptr(),"set_loop",loop->is_pressed());
- undo_redo->add_undo_method(animation.ptr(),"set_loop",!loop->is_pressed());
+ undo_redo->add_do_method(animation.ptr(), "set_loop", loop->is_pressed());
+ undo_redo->add_undo_method(animation.ptr(), "set_loop", !loop->is_pressed());
undo_redo->commit_action();
}
-
}
-
void AnimationKeyEditor::_create_value_item(int p_type) {
undo_redo->create_action(TTR("Anim Create Typed Value Key"));
Variant::CallError ce;
- Variant v = Variant::construct(Variant::Type(p_type),NULL,0,ce);
- undo_redo->add_do_method(animation.ptr(),"track_insert_key",cvi_track,cvi_pos,v);
- undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",cvi_track,cvi_pos);
+ Variant v = Variant::construct(Variant::Type(p_type), NULL, 0, ce);
+ undo_redo->add_do_method(animation.ptr(), "track_insert_key", cvi_track, cvi_pos, v);
+ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_pos", cvi_track, cvi_pos);
- int existing = animation->track_find_key(cvi_track,cvi_pos,true);
+ int existing = animation->track_find_key(cvi_track, cvi_pos, true);
- if (existing!=-1) {
- Variant v = animation->track_get_key_value(cvi_track,existing);
- float trans = animation->track_get_key_transition(cvi_track,existing);
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",cvi_track,cvi_pos,v,trans);
+ if (existing != -1) {
+ Variant v = animation->track_get_key_value(cvi_track, existing);
+ float trans = animation->track_get_key_transition(cvi_track, existing);
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", cvi_track, cvi_pos, v, trans);
}
undo_redo->commit_action();
-
}
-
void AnimationKeyEditor::set_anim_pos(float p_pos) {
if (animation.is_null())
return;
- timeline_pos=p_pos;
+ timeline_pos = p_pos;
update();
track_pos->update();
track_editor->update();
}
-void AnimationKeyEditor::_pane_drag(const Point2& p_delta) {
+void AnimationKeyEditor::_pane_drag(const Point2 &p_delta) {
Size2 ecs = ec->get_custom_minimum_size();
- ecs.y-=p_delta.y;
- if (ecs.y<100)
- ecs.y=100;
+ ecs.y -= p_delta.y;
+ if (ecs.y < 100)
+ ecs.y = 100;
ec->set_custom_minimum_size(ecs);
-
}
void AnimationKeyEditor::_insert_delay() {
if (insert_query) {
//discard since it's entered into query mode
- insert_queue=false;
+ insert_queue = false;
return;
}
undo_redo->create_action(TTR("Anim Insert"));
int last_track = animation->get_track_count();
- bool advance=false;
- while(insert_data.size()) {
+ bool advance = false;
+ while (insert_data.size()) {
if (insert_data.front()->get().advance)
- advance=true;
- last_track=_confirm_insert(insert_data.front()->get(),last_track);
+ advance = true;
+ last_track = _confirm_insert(insert_data.front()->get(), last_track);
insert_data.pop_front();
}
@@ -3735,170 +3507,154 @@ void AnimationKeyEditor::_insert_delay() {
if (advance) {
float step = animation->get_step();
- if (step==0)
- step=1;
+ if (step == 0)
+ step = 1;
- float pos=timeline_pos;
+ float pos = timeline_pos;
- pos=Math::stepify(pos+step,step);
- if (pos>animation->get_length())
- pos=animation->get_length();
- timeline_pos=pos;
+ pos = Math::stepify(pos + step, step);
+ if (pos > animation->get_length())
+ pos = animation->get_length();
+ timeline_pos = pos;
track_pos->update();
- emit_signal("timeline_changed",pos,true);
+ emit_signal("timeline_changed", pos, true);
}
- insert_queue=false;
+ insert_queue = false;
}
void AnimationKeyEditor::_step_changed(float p_len) {
- updating=true;
+ updating = true;
if (!animation.is_null()) {
animation->set_step(p_len);
- emit_signal("animation_step_changed",animation->get_step());
+ emit_signal("animation_step_changed", animation->get_step());
}
- updating=false;
+ updating = false;
}
void AnimationKeyEditor::_scale() {
-
if (selection.empty())
return;
-
float from_t = 1e20;
float to_t = -1e20;
float len = -1e20;
- float pivot=0;
-
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.front();E;E=E->next()) {
- float t = animation->track_get_key_time(E->key().track,E->key().key);
- if (t<from_t)
- from_t=t;
- if (t>to_t)
- to_t=t;
+ float pivot = 0;
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.front(); E; E = E->next()) {
+ float t = animation->track_get_key_time(E->key().track, E->key().key);
+ if (t < from_t)
+ from_t = t;
+ if (t > to_t)
+ to_t = t;
}
- len=to_t-from_t;
- if (last_menu_track_opt==TRACK_MENU_SCALE_PIVOT) {
+ len = to_t - from_t;
+ if (last_menu_track_opt == TRACK_MENU_SCALE_PIVOT) {
pivot = timeline_pos;
} else {
- pivot=from_t;
-
+ pivot = from_t;
}
float s = scale->get_value();
- if (s==0) {
+ if (s == 0) {
ERR_PRINT("Can't scale to 0");
}
-
-
undo_redo->create_action(TTR("Anim Scale Keys"));
List<_AnimMoveRestore> to_restore;
// 1-remove the keys
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
- undo_redo->add_do_method(animation.ptr(),"track_remove_key",E->key().track,E->key().key);
+ undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key);
}
// 2- remove overlapped keys
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
- float newtime = (E->get().pos-from_t)*s+from_t;
- int idx = animation->track_find_key(E->key().track,newtime,true);
- if (idx==-1)
+ float newtime = (E->get().pos - from_t) * s + from_t;
+ int idx = animation->track_find_key(E->key().track, newtime, true);
+ if (idx == -1)
continue;
SelectedKey sk;
- sk.key=idx;
- sk.track=E->key().track;
+ sk.key = idx;
+ sk.track = E->key().track;
if (selection.has(sk))
continue; //already in selection, don't save
- undo_redo->add_do_method(animation.ptr(),"track_remove_key_at_pos",E->key().track,newtime);
+ undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_pos", E->key().track, newtime);
_AnimMoveRestore amr;
- amr.key=animation->track_get_key_value(E->key().track,idx);
- amr.track=E->key().track;
- amr.time=newtime;
- amr.transition=animation->track_get_key_transition(E->key().track,idx);
+ amr.key = animation->track_get_key_value(E->key().track, idx);
+ amr.track = E->key().track;
+ amr.time = newtime;
+ amr.transition = animation->track_get_key_transition(E->key().track, idx);
to_restore.push_back(amr);
-
}
-#define _NEW_POS(m_ofs) (((s>0)?m_ofs:from_t+(len-(m_ofs-from_t)))-pivot)*ABS(s)+from_t
+#define _NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * ABS(s) + from_t
// 3-move the keys (re insert them)
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
-
- float newpos=_NEW_POS(E->get().pos);
- undo_redo->add_do_method(animation.ptr(),"track_insert_key",E->key().track,newpos,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key));
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
+ float newpos = _NEW_POS(E->get().pos);
+ undo_redo->add_do_method(animation.ptr(), "track_insert_key", E->key().track, newpos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
// 4-(undo) remove inserted keys
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
-
- float newpos=_NEW_POS(E->get().pos);
- undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",E->key().track,newpos);
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
+ float newpos = _NEW_POS(E->get().pos);
+ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_pos", E->key().track, newpos);
}
// 5-(undo) reinsert keys
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
-
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",E->key().track,E->get().pos,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key));
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key));
}
// 6-(undo) reinsert overlapped keys
- for(List<_AnimMoveRestore>::Element *E=to_restore.front();E;E=E->next()) {
+ for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) {
_AnimMoveRestore &amr = E->get();
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",amr.track,amr.time,amr.key,amr.transition);
-
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition);
}
// 6-(undo) reinsert overlapped keys
- for(List<_AnimMoveRestore>::Element *E=to_restore.front();E;E=E->next()) {
+ for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) {
_AnimMoveRestore &amr = E->get();
- undo_redo->add_undo_method(animation.ptr(),"track_insert_key",amr.track,amr.time,amr.key,amr.transition);
-
+ undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition);
}
- undo_redo->add_do_method(this,"_clear_selection_for_anim",animation);
- undo_redo->add_undo_method(this,"_clear_selection_for_anim",animation);
+ undo_redo->add_do_method(this, "_clear_selection_for_anim", animation);
+ undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation);
// 7-reselect
- for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
-
- float oldpos=E->get().pos;
- float newpos=_NEW_POS(oldpos);
- if (newpos>=0)
- undo_redo->add_do_method(this,"_select_at_anim",animation,E->key().track,newpos);
- undo_redo->add_undo_method(this,"_select_at_anim",animation,E->key().track,oldpos);
+ for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) {
+ float oldpos = E->get().pos;
+ float newpos = _NEW_POS(oldpos);
+ if (newpos >= 0)
+ undo_redo->add_do_method(this, "_select_at_anim", animation, E->key().track, newpos);
+ undo_redo->add_undo_method(this, "_select_at_anim", animation, E->key().track, oldpos);
}
#undef _NEW_POS
undo_redo->commit_action();
-
}
+void AnimationKeyEditor::_add_call_track(const NodePath &p_base) {
-void AnimationKeyEditor::_add_call_track(const NodePath& p_base) {
-
-
- Node* base = EditorNode::get_singleton()->get_edited_scene();
+ Node *base = EditorNode::get_singleton()->get_edited_scene();
if (!base)
return;
- Node* from=base->get_node(p_base);
+ Node *from = base->get_node(p_base);
if (!from || !root)
return;
@@ -3908,11 +3664,10 @@ void AnimationKeyEditor::_add_call_track(const NodePath& p_base) {
//print_line("path: "+String(path));
undo_redo->create_action(TTR("Anim Add Call Track"));
- undo_redo->add_do_method(animation.ptr(),"add_track",Animation::TYPE_METHOD);
- undo_redo->add_do_method(animation.ptr(),"track_set_path",animation->get_track_count(),path);
- undo_redo->add_undo_method(animation.ptr(),"remove_track",animation->get_track_count());
+ undo_redo->add_do_method(animation.ptr(), "add_track", Animation::TYPE_METHOD);
+ undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), path);
+ undo_redo->add_undo_method(animation.ptr(), "remove_track", animation->get_track_count());
undo_redo->commit_action();
-
}
void AnimationKeyEditor::cleanup() {
@@ -3922,97 +3677,85 @@ void AnimationKeyEditor::cleanup() {
void AnimationKeyEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_root_removed"),&AnimationKeyEditor::_root_removed);
- ClassDB::bind_method(D_METHOD("_scale"),&AnimationKeyEditor::_scale);
- ClassDB::bind_method(D_METHOD("set_root"),&AnimationKeyEditor::set_root);
-
+ ClassDB::bind_method(D_METHOD("_root_removed"), &AnimationKeyEditor::_root_removed);
+ ClassDB::bind_method(D_METHOD("_scale"), &AnimationKeyEditor::_scale);
+ ClassDB::bind_method(D_METHOD("set_root"), &AnimationKeyEditor::set_root);
//ClassDB::bind_method(D_METHOD("_confirm_insert"),&AnimationKeyEditor::_confirm_insert);
- ClassDB::bind_method(D_METHOD("_confirm_insert_list"),&AnimationKeyEditor::_confirm_insert_list);
-
-
-
- ClassDB::bind_method(D_METHOD("_update_paths"),&AnimationKeyEditor::_update_paths);
- ClassDB::bind_method(D_METHOD("_track_editor_draw"),&AnimationKeyEditor::_track_editor_draw);
-
-
-
-
- ClassDB::bind_method(D_METHOD("_animation_changed"),&AnimationKeyEditor::_animation_changed);
- ClassDB::bind_method(D_METHOD("_scroll_changed"),&AnimationKeyEditor::_scroll_changed);
- ClassDB::bind_method(D_METHOD("_track_editor_gui_input"),&AnimationKeyEditor::_track_editor_gui_input);
- ClassDB::bind_method(D_METHOD("_track_name_changed"),&AnimationKeyEditor::_track_name_changed);
- ClassDB::bind_method(D_METHOD("_track_menu_selected"),&AnimationKeyEditor::_track_menu_selected);
- ClassDB::bind_method(D_METHOD("_menu_add_track"),&AnimationKeyEditor::_menu_add_track);
- ClassDB::bind_method(D_METHOD("_menu_track"),&AnimationKeyEditor::_menu_track);
- ClassDB::bind_method(D_METHOD("_clear_selection_for_anim"),&AnimationKeyEditor::_clear_selection_for_anim);
- ClassDB::bind_method(D_METHOD("_select_at_anim"),&AnimationKeyEditor::_select_at_anim);
- ClassDB::bind_method(D_METHOD("_track_pos_draw"),&AnimationKeyEditor::_track_pos_draw);
- ClassDB::bind_method(D_METHOD("_insert_delay"),&AnimationKeyEditor::_insert_delay);
- ClassDB::bind_method(D_METHOD("_step_changed"),&AnimationKeyEditor::_step_changed);
-
-
- ClassDB::bind_method(D_METHOD("_animation_loop_changed"),&AnimationKeyEditor::_animation_loop_changed);
- ClassDB::bind_method(D_METHOD("_animation_len_changed"),&AnimationKeyEditor::_animation_len_changed);
- ClassDB::bind_method(D_METHOD("_create_value_item"),&AnimationKeyEditor::_create_value_item);
- ClassDB::bind_method(D_METHOD("_pane_drag"),&AnimationKeyEditor::_pane_drag);
-
- ClassDB::bind_method(D_METHOD("_animation_len_update"),&AnimationKeyEditor::_animation_len_update);
-
- ClassDB::bind_method(D_METHOD("set_animation"),&AnimationKeyEditor::set_animation);
- ClassDB::bind_method(D_METHOD("_animation_optimize"),&AnimationKeyEditor::_animation_optimize);
- ClassDB::bind_method(D_METHOD("_curve_transition_changed"),&AnimationKeyEditor::_curve_transition_changed);
- ClassDB::bind_method(D_METHOD("_toggle_edit_curves"),&AnimationKeyEditor::_toggle_edit_curves);
- ClassDB::bind_method(D_METHOD("_add_call_track"),&AnimationKeyEditor::_add_call_track);
-
-
- ADD_SIGNAL( MethodInfo("resource_selected", PropertyInfo( Variant::OBJECT, "res"),PropertyInfo( Variant::STRING, "prop") ) );
- ADD_SIGNAL( MethodInfo("keying_changed" ) );
- ADD_SIGNAL( MethodInfo("timeline_changed", PropertyInfo(Variant::REAL,"pos"), PropertyInfo(Variant::BOOL,"drag") ) );
- ADD_SIGNAL( MethodInfo("animation_len_changed", PropertyInfo(Variant::REAL,"len") ) );
- ADD_SIGNAL( MethodInfo("animation_step_changed", PropertyInfo(Variant::REAL,"step") ) );
- ADD_SIGNAL( MethodInfo("key_edited", PropertyInfo(Variant::INT,"track"), PropertyInfo(Variant::INT,"key") ) );
-
+ ClassDB::bind_method(D_METHOD("_confirm_insert_list"), &AnimationKeyEditor::_confirm_insert_list);
+
+ ClassDB::bind_method(D_METHOD("_update_paths"), &AnimationKeyEditor::_update_paths);
+ ClassDB::bind_method(D_METHOD("_track_editor_draw"), &AnimationKeyEditor::_track_editor_draw);
+
+ ClassDB::bind_method(D_METHOD("_animation_changed"), &AnimationKeyEditor::_animation_changed);
+ ClassDB::bind_method(D_METHOD("_scroll_changed"), &AnimationKeyEditor::_scroll_changed);
+ ClassDB::bind_method(D_METHOD("_track_editor_gui_input"), &AnimationKeyEditor::_track_editor_gui_input);
+ ClassDB::bind_method(D_METHOD("_track_name_changed"), &AnimationKeyEditor::_track_name_changed);
+ ClassDB::bind_method(D_METHOD("_track_menu_selected"), &AnimationKeyEditor::_track_menu_selected);
+ ClassDB::bind_method(D_METHOD("_menu_add_track"), &AnimationKeyEditor::_menu_add_track);
+ ClassDB::bind_method(D_METHOD("_menu_track"), &AnimationKeyEditor::_menu_track);
+ ClassDB::bind_method(D_METHOD("_clear_selection_for_anim"), &AnimationKeyEditor::_clear_selection_for_anim);
+ ClassDB::bind_method(D_METHOD("_select_at_anim"), &AnimationKeyEditor::_select_at_anim);
+ ClassDB::bind_method(D_METHOD("_track_pos_draw"), &AnimationKeyEditor::_track_pos_draw);
+ ClassDB::bind_method(D_METHOD("_insert_delay"), &AnimationKeyEditor::_insert_delay);
+ ClassDB::bind_method(D_METHOD("_step_changed"), &AnimationKeyEditor::_step_changed);
+
+ ClassDB::bind_method(D_METHOD("_animation_loop_changed"), &AnimationKeyEditor::_animation_loop_changed);
+ ClassDB::bind_method(D_METHOD("_animation_len_changed"), &AnimationKeyEditor::_animation_len_changed);
+ ClassDB::bind_method(D_METHOD("_create_value_item"), &AnimationKeyEditor::_create_value_item);
+ ClassDB::bind_method(D_METHOD("_pane_drag"), &AnimationKeyEditor::_pane_drag);
+
+ ClassDB::bind_method(D_METHOD("_animation_len_update"), &AnimationKeyEditor::_animation_len_update);
+
+ ClassDB::bind_method(D_METHOD("set_animation"), &AnimationKeyEditor::set_animation);
+ ClassDB::bind_method(D_METHOD("_animation_optimize"), &AnimationKeyEditor::_animation_optimize);
+ ClassDB::bind_method(D_METHOD("_curve_transition_changed"), &AnimationKeyEditor::_curve_transition_changed);
+ ClassDB::bind_method(D_METHOD("_toggle_edit_curves"), &AnimationKeyEditor::_toggle_edit_curves);
+ ClassDB::bind_method(D_METHOD("_add_call_track"), &AnimationKeyEditor::_add_call_track);
+
+ ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "res"), PropertyInfo(Variant::STRING, "prop")));
+ ADD_SIGNAL(MethodInfo("keying_changed"));
+ ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::REAL, "pos"), PropertyInfo(Variant::BOOL, "drag")));
+ ADD_SIGNAL(MethodInfo("animation_len_changed", PropertyInfo(Variant::REAL, "len")));
+ ADD_SIGNAL(MethodInfo("animation_step_changed", PropertyInfo(Variant::REAL, "step")));
+ ADD_SIGNAL(MethodInfo("key_edited", PropertyInfo(Variant::INT, "track"), PropertyInfo(Variant::INT, "key")));
}
-
AnimationKeyEditor::AnimationKeyEditor() {
- alc="animation_len_changed";
- editor_selection=EditorNode::get_singleton()->get_editor_selection();
+ alc = "animation_len_changed";
+ editor_selection = EditorNode::get_singleton()->get_editor_selection();
- selected_track=-1;
- updating=false;
- te_drawing=false;
- undo_redo=EditorNode::get_singleton()->get_undo_redo();
- history=EditorNode::get_singleton()->get_editor_history();
+ selected_track = -1;
+ updating = false;
+ te_drawing = false;
+ undo_redo = EditorNode::get_singleton()->get_undo_redo();
+ history = EditorNode::get_singleton()->get_editor_history();
- ec = memnew (Control);
- ec->set_custom_minimum_size(Size2(0,150));
+ ec = memnew(Control);
+ ec->set_custom_minimum_size(Size2(0, 150));
add_child(ec);
ec->set_v_size_flags(SIZE_EXPAND_FILL);
- h_scroll = memnew( HScrollBar );
- h_scroll->connect("value_changed",this,"_scroll_changed");
+ h_scroll = memnew(HScrollBar);
+ h_scroll->connect("value_changed", this, "_scroll_changed");
add_child(h_scroll);
h_scroll->set_value(0);
-
- HBoxContainer *hb = memnew( HBoxContainer );
+ HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
-
- root=NULL;
+ root = NULL;
//menu = memnew( MenuButton );
//menu->set_flat(true);
//menu->set_pos(Point2());
//add_child(menu);
- zoomicon = memnew( TextureRect );
+ zoomicon = memnew(TextureRect);
hb->add_child(zoomicon);
zoomicon->set_tooltip(TTR("Animation zoom."));
- zoom = memnew( HSlider );
+ zoom = memnew(HSlider);
//hb->add_child(zoom);
zoom->set_step(0.01);
zoom->set_min(0.0);
@@ -4021,16 +3764,16 @@ AnimationKeyEditor::AnimationKeyEditor() {
zoom->set_h_size_flags(SIZE_EXPAND_FILL);
zoom->set_stretch_ratio(2);
hb->add_child(zoom);
- zoom->connect("value_changed",this,"_scroll_changed");
+ zoom->connect("value_changed", this, "_scroll_changed");
zoom->set_tooltip(TTR("Animation zoom."));
- hb->add_child( memnew( VSeparator ) );
+ hb->add_child(memnew(VSeparator));
- Label *l = memnew( Label );
+ Label *l = memnew(Label);
l->set_text(TTR("Length (s):"));
hb->add_child(l);
- length = memnew( SpinBox );
+ length = memnew(SpinBox);
length->set_min(0.01);
length->set_max(10000);
length->set_step(0.01);
@@ -4039,13 +3782,13 @@ AnimationKeyEditor::AnimationKeyEditor() {
length->set_tooltip(TTR("Animation length (in seconds)."));
hb->add_child(length);
- length->connect("value_changed",this,"_animation_len_changed");
+ length->connect("value_changed", this, "_animation_len_changed");
- l = memnew( Label );
+ l = memnew(Label);
l->set_text(TTR("Step (s):"));
hb->add_child(l);
- step = memnew( SpinBox );
+ step = memnew(SpinBox);
step->set_min(0.00);
step->set_max(128);
step->set_step(0.01);
@@ -4055,50 +3798,50 @@ AnimationKeyEditor::AnimationKeyEditor() {
step->set_tooltip(TTR("Cursor step snap (in seconds)."));
hb->add_child(step);
- step->connect("value_changed",this,"_step_changed");
+ step->connect("value_changed", this, "_step_changed");
- loop = memnew( ToolButton );
+ loop = memnew(ToolButton);
loop->set_toggle_mode(true);
- loop->connect("pressed",this,"_animation_loop_changed");
+ loop->connect("pressed", this, "_animation_loop_changed");
hb->add_child(loop);
loop->set_tooltip(TTR("Enable/Disable looping in animation."));
- hb->add_child( memnew( VSeparator ) );
+ hb->add_child(memnew(VSeparator));
- menu_add_track = memnew( MenuButton );
+ menu_add_track = memnew(MenuButton);
hb->add_child(menu_add_track);
- menu_add_track->get_popup()->connect("id_pressed",this,"_menu_add_track");
+ menu_add_track->get_popup()->connect("id_pressed", this, "_menu_add_track");
menu_add_track->set_tooltip(TTR("Add new tracks."));
- move_up_button = memnew( ToolButton );
+ move_up_button = memnew(ToolButton);
hb->add_child(move_up_button);
- move_up_button->connect("pressed",this,"_menu_track",make_binds(TRACK_MENU_MOVE_UP));
+ move_up_button->connect("pressed", this, "_menu_track", make_binds(TRACK_MENU_MOVE_UP));
move_up_button->set_focus_mode(FOCUS_NONE);
move_up_button->set_disabled(true);
move_up_button->set_tooltip(TTR("Move current track up."));
- move_down_button = memnew( ToolButton );
+ move_down_button = memnew(ToolButton);
hb->add_child(move_down_button);
- move_down_button->connect("pressed",this,"_menu_track",make_binds(TRACK_MENU_MOVE_DOWN));
+ move_down_button->connect("pressed", this, "_menu_track", make_binds(TRACK_MENU_MOVE_DOWN));
move_down_button->set_focus_mode(FOCUS_NONE);
move_down_button->set_disabled(true);
move_down_button->set_tooltip(TTR("Move current track down."));
- remove_button = memnew( ToolButton );
+ remove_button = memnew(ToolButton);
hb->add_child(remove_button);
- remove_button->connect("pressed",this,"_menu_track",make_binds(TRACK_MENU_REMOVE));
+ remove_button->connect("pressed", this, "_menu_track", make_binds(TRACK_MENU_REMOVE));
remove_button->set_focus_mode(FOCUS_NONE);
remove_button->set_disabled(true);
remove_button->set_tooltip(TTR("Remove selected track."));
- hb->add_child(memnew( VSeparator ));
+ hb->add_child(memnew(VSeparator));
- menu_track = memnew( MenuButton );
+ menu_track = memnew(MenuButton);
hb->add_child(menu_track);
- menu_track->get_popup()->connect("id_pressed",this,"_menu_track");
+ menu_track->get_popup()->connect("id_pressed", this, "_menu_track");
menu_track->set_tooltip(TTR("Track tools"));
- edit_button = memnew( ToolButton );
+ edit_button = memnew(ToolButton);
edit_button->set_toggle_mode(true);
edit_button->set_focus_mode(FOCUS_NONE);
edit_button->set_disabled(true);
@@ -4106,27 +3849,27 @@ AnimationKeyEditor::AnimationKeyEditor() {
hb->add_child(edit_button);
edit_button->set_tooltip(TTR("Enable editing of individual keys by clicking them."));
- optimize_dialog = memnew( ConfirmationDialog );
+ optimize_dialog = memnew(ConfirmationDialog);
add_child(optimize_dialog);
optimize_dialog->set_title(TTR("Anim. Optimizer"));
- VBoxContainer *optimize_vb = memnew( VBoxContainer );
+ VBoxContainer *optimize_vb = memnew(VBoxContainer);
optimize_dialog->add_child(optimize_vb);
- optimize_linear_error = memnew( SpinBox );
+ optimize_linear_error = memnew(SpinBox);
optimize_linear_error->set_max(1.0);
optimize_linear_error->set_min(0.001);
optimize_linear_error->set_step(0.001);
optimize_linear_error->set_value(0.05);
- optimize_vb->add_margin_child(TTR("Max. Linear Error:"),optimize_linear_error);
- optimize_angular_error = memnew( SpinBox );
+ optimize_vb->add_margin_child(TTR("Max. Linear Error:"), optimize_linear_error);
+ optimize_angular_error = memnew(SpinBox);
optimize_angular_error->set_max(1.0);
optimize_angular_error->set_min(0.001);
optimize_angular_error->set_step(0.001);
optimize_angular_error->set_value(0.01);
- optimize_vb->add_margin_child(TTR("Max. Angular Error:"),optimize_angular_error);
- optimize_max_angle = memnew( SpinBox );
- optimize_vb->add_margin_child(TTR("Max Optimizable Angle:"),optimize_max_angle);
+ optimize_vb->add_margin_child(TTR("Max. Angular Error:"), optimize_angular_error);
+ optimize_max_angle = memnew(SpinBox);
+ optimize_vb->add_margin_child(TTR("Max Optimizable Angle:"), optimize_max_angle);
optimize_max_angle->set_max(360.0);
optimize_max_angle->set_min(0.0);
optimize_max_angle->set_step(0.1);
@@ -4134,8 +3877,6 @@ AnimationKeyEditor::AnimationKeyEditor() {
optimize_dialog->get_ok()->set_text(TTR("Optimize"));
-
-
/*keying = memnew( Button );
keying->set_toggle_mode(true);
//keying->set_text("Keys");
@@ -4147,35 +3888,32 @@ AnimationKeyEditor::AnimationKeyEditor() {
keying->connect("pressed",this,"_keying_toggled");
*/
-/* l = memnew( Label );
+ /* l = memnew( Label );
l->set_text("Base: ");
l->set_pos(Point2(0,3));
//dr_panel->add_child(l);*/
//menu->get_popup()->connect("id_pressed",this,"_menu_callback");
-
- hb = memnew( HBoxContainer);
+ hb = memnew(HBoxContainer);
hb->set_area_as_parent_rect();
ec->add_child(hb);
hb->set_v_size_flags(SIZE_EXPAND_FILL);
- track_editor = memnew( Control );
- track_editor->connect("draw",this,"_track_editor_draw");
+ track_editor = memnew(Control);
+ track_editor->connect("draw", this, "_track_editor_draw");
hb->add_child(track_editor);
- track_editor->connect("gui_input",this,"_track_editor_gui_input");
+ track_editor->connect("gui_input", this, "_track_editor_gui_input");
track_editor->set_focus_mode(Control::FOCUS_ALL);
track_editor->set_h_size_flags(SIZE_EXPAND_FILL);
-
-
- track_pos = memnew( Control );
+ track_pos = memnew(Control);
track_pos->set_area_as_parent_rect();
track_pos->set_mouse_filter(MOUSE_FILTER_IGNORE);
track_editor->add_child(track_pos);
- track_pos->connect("draw",this,"_track_pos_draw");
+ track_pos->connect("draw", this, "_track_pos_draw");
- select_anim_warning = memnew( Label );
+ select_anim_warning = memnew(Label);
track_editor->add_child(select_anim_warning);
select_anim_warning->set_area_as_parent_rect();
select_anim_warning->set_text(TTR("Select an AnimationPlayer from the Scene Tree to edit animations."));
@@ -4183,149 +3921,137 @@ AnimationKeyEditor::AnimationKeyEditor() {
select_anim_warning->set_align(Label::ALIGN_CENTER);
select_anim_warning->set_valign(Label::VALIGN_CENTER);
-
-
- v_scroll = memnew( VScrollBar );
+ v_scroll = memnew(VScrollBar);
hb->add_child(v_scroll);
- v_scroll->connect("value_changed",this,"_scroll_changed");
+ v_scroll->connect("value_changed", this, "_scroll_changed");
v_scroll->set_value(0);
key_editor_tab = memnew(TabContainer);
hb->add_child(key_editor_tab);
- key_editor_tab->set_custom_minimum_size(Size2(200,0));
+ key_editor_tab->set_custom_minimum_size(Size2(200, 0));
- key_editor = memnew( PropertyEditor );
+ key_editor = memnew(PropertyEditor);
key_editor->set_area_as_parent_rect();
key_editor->hide_top_label();
key_editor->set_name(TTR("Key"));
key_editor_tab->add_child(key_editor);
- key_edit = memnew( AnimationKeyEdit );
- key_edit->undo_redo=undo_redo;
+ key_edit = memnew(AnimationKeyEdit);
+ key_edit->undo_redo = undo_redo;
//key_edit->ke_dialog=key_edit_dialog;
- type_menu = memnew( PopupMenu );
+ type_menu = memnew(PopupMenu);
add_child(type_menu);
- for(int i=0;i<Variant::VARIANT_MAX;i++)
- type_menu->add_item(Variant::get_type_name(Variant::Type(i)),i);
- type_menu->connect("id_pressed",this,"_create_value_item");
+ for (int i = 0; i < Variant::VARIANT_MAX; i++)
+ type_menu->add_item(Variant::get_type_name(Variant::Type(i)), i);
+ type_menu->connect("id_pressed", this, "_create_value_item");
- VBoxContainer *curve_vb = memnew( VBoxContainer );
+ VBoxContainer *curve_vb = memnew(VBoxContainer);
curve_vb->set_name(TTR("Transition"));
- HBoxContainer *curve_hb = memnew( HBoxContainer );
+ HBoxContainer *curve_hb = memnew(HBoxContainer);
curve_vb->add_child(curve_hb);
- curve_linear = memnew( ToolButton );
+ curve_linear = memnew(ToolButton);
curve_linear->set_focus_mode(FOCUS_NONE);
curve_hb->add_child(curve_linear);
- curve_in = memnew( ToolButton );
+ curve_in = memnew(ToolButton);
curve_in->set_focus_mode(FOCUS_NONE);
curve_hb->add_child(curve_in);
- curve_out = memnew( ToolButton );
+ curve_out = memnew(ToolButton);
curve_out->set_focus_mode(FOCUS_NONE);
curve_hb->add_child(curve_out);
- curve_inout = memnew( ToolButton );
+ curve_inout = memnew(ToolButton);
curve_inout->set_focus_mode(FOCUS_NONE);
curve_hb->add_child(curve_inout);
- curve_outin = memnew( ToolButton );
+ curve_outin = memnew(ToolButton);
curve_outin->set_focus_mode(FOCUS_NONE);
curve_hb->add_child(curve_outin);
- curve_constant = memnew( ToolButton );
+ curve_constant = memnew(ToolButton);
curve_constant->set_focus_mode(FOCUS_NONE);
curve_hb->add_child(curve_constant);
-
- curve_edit = memnew( AnimationCurveEdit );
+ curve_edit = memnew(AnimationCurveEdit);
curve_vb->add_child(curve_edit);
curve_edit->set_v_size_flags(SIZE_EXPAND_FILL);
key_editor_tab->add_child(curve_vb);
- track_name = memnew( LineEdit );
+ track_name = memnew(LineEdit);
track_name->set_as_toplevel(true);
track_name->hide();
add_child(track_name);
- track_name->connect("text_entered",this,"_track_name_changed");
- track_menu = memnew( PopupMenu );
+ track_name->connect("text_entered", this, "_track_name_changed");
+ track_menu = memnew(PopupMenu);
add_child(track_menu);
- track_menu->connect("id_pressed",this,"_track_menu_selected");
+ track_menu->connect("id_pressed", this, "_track_menu_selected");
key_editor_tab->hide();
- last_idx =1;
+ last_idx = 1;
_update_menu();
-
-
- insert_confirm = memnew( ConfirmationDialog );
+ insert_confirm = memnew(ConfirmationDialog);
add_child(insert_confirm);
- insert_confirm->connect("confirmed",this,"_confirm_insert_list");
-
- click.click=ClickOver::CLICK_NONE;
-
+ insert_confirm->connect("confirmed", this, "_confirm_insert_list");
- name_column_ratio=0.3;
- timeline_pos=0;
+ click.click = ClickOver::CLICK_NONE;
+ name_column_ratio = 0.3;
+ timeline_pos = 0;
- keying=false;
- insert_frame=0;
- insert_query=false;
- insert_queue=false;
+ keying = false;
+ insert_frame = 0;
+ insert_query = false;
+ insert_queue = false;
- editor_selection->connect("selection_changed",track_editor,"update");
+ editor_selection->connect("selection_changed", track_editor, "update");
-
- scale_dialog = memnew( ConfirmationDialog );
- VBoxContainer *vbc = memnew( VBoxContainer );
+ scale_dialog = memnew(ConfirmationDialog);
+ VBoxContainer *vbc = memnew(VBoxContainer);
scale_dialog->add_child(vbc);
- scale = memnew( SpinBox );
+ scale = memnew(SpinBox);
scale->set_min(-99999);
scale->set_max(99999);
scale->set_step(0.001);
- vbc->add_margin_child(TTR("Scale Ratio:"),scale);
- scale_dialog->connect("confirmed",this,"_scale");
+ vbc->add_margin_child(TTR("Scale Ratio:"), scale);
+ scale_dialog->connect("confirmed", this, "_scale");
add_child(scale_dialog);
- call_select = memnew( SceneTreeDialog );
+ call_select = memnew(SceneTreeDialog);
add_child(call_select);
call_select->set_title(TTR("Call Functions in Which Node?"));
- cleanup_dialog = memnew( ConfirmationDialog );
+ cleanup_dialog = memnew(ConfirmationDialog);
add_child(cleanup_dialog);
- VBoxContainer *cleanup_vb = memnew( VBoxContainer );
+ VBoxContainer *cleanup_vb = memnew(VBoxContainer);
cleanup_dialog->add_child(cleanup_vb);
- cleanup_keys = memnew( CheckButton );
+ cleanup_keys = memnew(CheckButton);
cleanup_keys->set_text(TTR("Remove invalid keys"));
cleanup_keys->set_pressed(true);
cleanup_vb->add_child(cleanup_keys);
- cleanup_tracks = memnew( CheckButton );
+ cleanup_tracks = memnew(CheckButton);
cleanup_tracks->set_text(TTR("Remove unresolved and empty tracks"));
cleanup_tracks->set_pressed(true);
cleanup_vb->add_child(cleanup_tracks);
- cleanup_all = memnew( CheckButton );
+ cleanup_all = memnew(CheckButton);
cleanup_all->set_text(TTR("Clean-up all animations"));
cleanup_vb->add_child(cleanup_all);
cleanup_dialog->set_title(TTR("Clean-Up Animation(s) (NO UNDO!)"));
cleanup_dialog->get_ok()->set_text(TTR("Clean-Up"));
- cleanup_dialog->connect("confirmed",this,"_menu_track",varray(TRACK_MENU_CLEAN_UP_CONFIRM));
+ cleanup_dialog->connect("confirmed", this, "_menu_track", varray(TRACK_MENU_CLEAN_UP_CONFIRM));
- add_constant_override("separation",get_constant("separation","VBoxContainer"));
+ add_constant_override("separation", get_constant("separation", "VBoxContainer"));
track_editor->set_clip_contents(true);
-
}
AnimationKeyEditor::~AnimationKeyEditor() {
-
-
- memdelete( key_edit );
-
+ memdelete(key_edit);
}
diff --git a/editor/animation_editor.h b/editor/animation_editor.h
index c4539cd763..a775ad160b 100644
--- a/editor/animation_editor.h
+++ b/editor/animation_editor.h
@@ -30,30 +30,30 @@
#define ANIMATION_EDITOR_H
#include "scene/gui/control.h"
-#include "scene/gui/slider.h"
+#include "scene/gui/file_dialog.h"
#include "scene/gui/menu_button.h"
+#include "scene/gui/scroll_bar.h"
+#include "scene/gui/slider.h"
#include "scene/gui/spin_box.h"
+#include "scene/gui/tab_container.h"
#include "scene/gui/texture_rect.h"
-#include "scene/gui/scroll_bar.h"
#include "scene/gui/tool_button.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/tab_container.h"
-#include "scene/resources/animation.h"
-#include "scene/animation/animation_cache.h"
-#include "scene_tree_editor.h"
#include "editor_data.h"
#include "property_editor.h"
+#include "scene/animation/animation_cache.h"
+#include "scene/resources/animation.h"
+#include "scene_tree_editor.h"
#include "scene_tree_editor.h"
class AnimationKeyEdit;
class AnimationCurveEdit;
-class AnimationKeyEditor : public VBoxContainer {
+class AnimationKeyEditor : public VBoxContainer {
- GDCLASS( AnimationKeyEditor, VBoxContainer );
+ GDCLASS(AnimationKeyEditor, VBoxContainer);
-/*
+ /*
enum {
MENU_NEW_ANIMATION,
@@ -130,7 +130,7 @@ class AnimationKeyEditor : public VBoxContainer {
int track;
int key;
- bool operator<(const SelectedKey& p_key) const { return track==p_key.track ? key < p_key.key : track < p_key.track; };
+ bool operator<(const SelectedKey &p_key) const { return track == p_key.track ? key < p_key.key : track < p_key.track; };
};
struct KeyInfo {
@@ -138,7 +138,7 @@ class AnimationKeyEditor : public VBoxContainer {
float pos;
};
- Map<SelectedKey,KeyInfo> selection;
+ Map<SelectedKey, KeyInfo> selection;
struct ClickOver {
@@ -159,7 +159,6 @@ class AnimationKeyEditor : public VBoxContainer {
Point2 to;
} click;
-
float timeline_pos;
float name_column_ratio;
@@ -195,7 +194,6 @@ class AnimationKeyEditor : public VBoxContainer {
ToolButton *curve_outin;
ToolButton *curve_constant;
-
ConfirmationDialog *optimize_dialog;
SpinBox *optimize_linear_error;
SpinBox *optimize_angular_error;
@@ -233,10 +231,9 @@ class AnimationKeyEditor : public VBoxContainer {
Node *root;
UndoRedo *undo_redo;
- EditorHistory* history;
+ EditorHistory *history;
ConfirmationDialog *insert_confirm;
-
AnimationKeyEdit *key_edit;
AnimationCurveEdit *curve_edit;
@@ -257,7 +254,7 @@ class AnimationKeyEditor : public VBoxContainer {
Variant value;
String query;
bool advance;
- };/* insert_data;*/
+ }; /* insert_data;*/
bool insert_query;
List<InsertData> insert_data;
@@ -266,37 +263,32 @@ class AnimationKeyEditor : public VBoxContainer {
int cvi_track;
float cvi_pos;
-
int right_data_size_cache;
EditorSelection *editor_selection;
Label *select_anim_warning;
-
float _get_zoom_scale() const;
void _track_editor_draw();
- void _track_editor_gui_input(const InputEvent& p_input);
+ void _track_editor_gui_input(const InputEvent &p_input);
void _track_pos_draw();
-
- void _track_name_changed(const String& p_name);
+ void _track_name_changed(const String &p_name);
void _track_menu_selected(int p_idx);
void _confirm_insert_list();
- int _confirm_insert(InsertData p_id,int p_at_track=-1);
- void _query_insert(const InsertData& p_id);
+ int _confirm_insert(InsertData p_id, int p_at_track = -1);
+ void _query_insert(const InsertData &p_id);
void _update_menu();
bool insert_queue;
void _insert_delay();
void _scale();
-
void _clear_selection();
//void _browse_path();
-
StringName alc;
void _animation_changed();
@@ -308,32 +300,32 @@ class AnimationKeyEditor : public VBoxContainer {
void _menu_add_track(int p_type);
void _menu_track(int p_type);
- void _clear_selection_for_anim(const Ref<Animation>& p_anim);
- void _select_at_anim(const Ref<Animation>& p_anim,int p_track,float p_pos);
+ void _clear_selection_for_anim(const Ref<Animation> &p_anim);
+ void _select_at_anim(const Ref<Animation> &p_anim, int p_track, float p_pos);
void _curve_transition_changed(float p_what);
PropertyInfo _find_hint_for_track(int p_idx, NodePath &r_base_path);
void _create_value_item(int p_type);
- void _pane_drag(const Point2& p_delta);
+ void _pane_drag(const Point2 &p_delta);
bool _edit_if_single_selection();
void _toggle_edit_curves();
void _animation_len_update();
- void _add_call_track(const NodePath& p_base);
+ void _add_call_track(const NodePath &p_base);
void _anim_duplicate_keys(bool transpose = false);
void _anim_delete_keys();
void _root_removed();
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_animation(const Ref<Animation>& p_anim);
+public:
+ void set_animation(const Ref<Animation> &p_anim);
Ref<Animation> get_current_animation() const;
void set_root(Node *p_root);
Node *get_root() const;
@@ -343,9 +335,9 @@ public:
void cleanup();
void set_anim_pos(float p_pos);
- void insert_node_value_key(Node* p_node, const String& p_property,const Variant& p_value,bool p_only_if_exists=false);
- void insert_value_key(const String& p_property, const Variant& p_value, bool p_advance);
- void insert_transform_key(Spatial *p_node,const String& p_sub,const Transform& p_xform);
+ void insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists = false);
+ void insert_value_key(const String &p_property, const Variant &p_value, bool p_advance);
+ void insert_transform_key(Spatial *p_node, const String &p_sub, const Transform &p_xform);
void show_select_node_warning(bool p_show) { select_anim_warning->set_visible(p_show); }
AnimationKeyEditor();
diff --git a/editor/array_property_edit.cpp b/editor/array_property_edit.cpp
index 7304d8dddf..62415f4993 100644
--- a/editor/array_property_edit.cpp
+++ b/editor/array_property_edit.cpp
@@ -32,15 +32,15 @@
#define ITEMS_PER_PAGE 100
-Variant ArrayPropertyEdit::get_array() const{
+Variant ArrayPropertyEdit::get_array() const {
- Object*o = ObjectDB::get_instance(obj);
+ Object *o = ObjectDB::get_instance(obj);
if (!o)
return Array();
- Variant arr=o->get(property);
+ Variant arr = o->get(property);
if (!arr.is_array()) {
Variant::CallError ce;
- arr=Variant::construct(default_type,NULL,0,ce);
+ arr = Variant::construct(default_type, NULL, 0, ce);
}
return arr;
}
@@ -48,7 +48,7 @@ Variant ArrayPropertyEdit::get_array() const{
void ArrayPropertyEdit::_notif_change() {
_change_notify();
}
-void ArrayPropertyEdit::_notif_changev(const String& p_v) {
+void ArrayPropertyEdit::_notif_changev(const String &p_v) {
_change_notify(p_v.utf8().get_data());
}
@@ -56,115 +56,111 @@ void ArrayPropertyEdit::_notif_changev(const String& p_v) {
void ArrayPropertyEdit::_set_size(int p_size) {
Variant arr = get_array();
- arr.call("resize",p_size);
- Object*o = ObjectDB::get_instance(obj);
+ arr.call("resize", p_size);
+ Object *o = ObjectDB::get_instance(obj);
if (!o)
return;
- o->set(property,arr);
-
+ o->set(property, arr);
}
-void ArrayPropertyEdit::_set_value(int p_idx,const Variant& p_value) {
+void ArrayPropertyEdit::_set_value(int p_idx, const Variant &p_value) {
Variant arr = get_array();
- arr.set(p_idx,p_value);
- Object*o = ObjectDB::get_instance(obj);
+ arr.set(p_idx, p_value);
+ Object *o = ObjectDB::get_instance(obj);
if (!o)
return;
- o->set(property,arr);
+ o->set(property, arr);
}
-bool ArrayPropertyEdit::_set(const StringName& p_name, const Variant& p_value){
+bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) {
- String pn=p_name;
+ String pn = p_name;
if (pn.begins_with("array/")) {
- if (pn=="array/size") {
+ if (pn == "array/size") {
Variant arr = get_array();
int size = arr.call("size");
- int newsize=p_value;
- if (newsize==size)
+ int newsize = p_value;
+ if (newsize == size)
return true;
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action(TTR("Resize Array"));
- ur->add_do_method(this,"_set_size",newsize);
- ur->add_undo_method(this,"_set_size",size);
- if (newsize<size) {
- for(int i=newsize;i<size;i++) {
- ur->add_undo_method(this,"_set_value",i,arr.get(i));
-
+ ur->add_do_method(this, "_set_size", newsize);
+ ur->add_undo_method(this, "_set_size", size);
+ if (newsize < size) {
+ for (int i = newsize; i < size; i++) {
+ ur->add_undo_method(this, "_set_value", i, arr.get(i));
}
- } else if (newsize>size) {
+ } else if (newsize > size) {
Variant init;
Variant::CallError ce;
Variant::Type new_type = subtype;
- if(new_type==Variant::NIL && size) {
- new_type = arr.get(size-1).get_type();
+ if (new_type == Variant::NIL && size) {
+ new_type = arr.get(size - 1).get_type();
}
- if(new_type!=Variant::NIL) {
- init = Variant::construct(new_type,NULL,0,ce);
- for(int i=size;i<newsize;i++) {
- ur->add_do_method(this,"_set_value",i,init);
+ if (new_type != Variant::NIL) {
+ init = Variant::construct(new_type, NULL, 0, ce);
+ for (int i = size; i < newsize; i++) {
+ ur->add_do_method(this, "_set_value", i, init);
}
}
-
}
- ur->add_do_method(this,"_notif_change");
- ur->add_undo_method(this,"_notif_change");
+ ur->add_do_method(this, "_notif_change");
+ ur->add_undo_method(this, "_notif_change");
ur->commit_action();
return true;
}
- if (pn=="array/page") {
- page=p_value;
+ if (pn == "array/page") {
+ page = p_value;
_change_notify();
return true;
}
} else if (pn.begins_with("indices")) {
- if (pn.find("_")!=-1) {
+ if (pn.find("_") != -1) {
//type
- int idx=pn.get_slicec('/',1).get_slicec('_',0).to_int();
+ int idx = pn.get_slicec('/', 1).get_slicec('_', 0).to_int();
int type = p_value;
Variant arr = get_array();
Variant value = arr.get(idx);
- if (value.get_type()!=type && type>=0 && type<Variant::VARIANT_MAX) {
+ if (value.get_type() != type && type >= 0 && type < Variant::VARIANT_MAX) {
Variant::CallError ce;
- Variant new_value=Variant::construct(Variant::Type(type),NULL,0,ce);
+ Variant new_value = Variant::construct(Variant::Type(type), NULL, 0, ce);
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Array Value Type"));
- ur->add_do_method(this,"_set_value",idx,new_value);
- ur->add_undo_method(this,"_set_value",idx,value);
- ur->add_do_method(this,"_notif_change");
- ur->add_undo_method(this,"_notif_change");
+ ur->add_do_method(this, "_set_value", idx, new_value);
+ ur->add_undo_method(this, "_set_value", idx, value);
+ ur->add_do_method(this, "_notif_change");
+ ur->add_undo_method(this, "_notif_change");
ur->commit_action();
-
}
return true;
} else {
- int idx=pn.get_slicec('/',1).to_int();
+ int idx = pn.get_slicec('/', 1).to_int();
Variant arr = get_array();
Variant value = arr.get(idx);
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Array Value"));
- ur->add_do_method(this,"_set_value",idx,p_value);
- ur->add_undo_method(this,"_set_value",idx,value);
- ur->add_do_method(this,"_notif_changev",p_name);
- ur->add_undo_method(this,"_notif_changev",p_name);
+ ur->add_do_method(this, "_set_value", idx, p_value);
+ ur->add_undo_method(this, "_set_value", idx, value);
+ ur->add_do_method(this, "_notif_changev", p_name);
+ ur->add_undo_method(this, "_notif_changev", p_name);
ur->commit_action();
return true;
}
@@ -173,37 +169,37 @@ bool ArrayPropertyEdit::_set(const StringName& p_name, const Variant& p_value){
return false;
}
-bool ArrayPropertyEdit::_get(const StringName& p_name,Variant &r_ret) const {
+bool ArrayPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const {
Variant arr = get_array();
//int size = arr.call("size");
- String pn=p_name;
+ String pn = p_name;
if (pn.begins_with("array/")) {
- if (pn=="array/size") {
- r_ret=arr.call("size");
+ if (pn == "array/size") {
+ r_ret = arr.call("size");
return true;
}
- if (pn=="array/page") {
- r_ret=page;
+ if (pn == "array/page") {
+ r_ret = page;
return true;
}
} else if (pn.begins_with("indices")) {
- if (pn.find("_")!=-1) {
+ if (pn.find("_") != -1) {
//type
- int idx=pn.get_slicec('/',1).get_slicec('_',0).to_int();
+ int idx = pn.get_slicec('/', 1).get_slicec('_', 0).to_int();
bool valid;
- r_ret=arr.get(idx,&valid);
+ r_ret = arr.get(idx, &valid);
if (valid)
- r_ret=r_ret.get_type();
+ r_ret = r_ret.get_type();
return valid;
} else {
- int idx=pn.get_slicec('/',1).to_int();
+ int idx = pn.get_slicec('/', 1).to_int();
bool valid;
- r_ret=arr.get(idx,&valid);
+ r_ret = arr.get(idx, &valid);
return valid;
}
}
@@ -211,70 +207,67 @@ bool ArrayPropertyEdit::_get(const StringName& p_name,Variant &r_ret) const {
return false;
}
-void ArrayPropertyEdit::_get_property_list( List<PropertyInfo> *p_list) const{
+void ArrayPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) const {
Variant arr = get_array();
int size = arr.call("size");
- p_list->push_back( PropertyInfo(Variant::INT,"array/size",PROPERTY_HINT_RANGE,"0,100000,1") );
- int pages = size/ITEMS_PER_PAGE;
- if (pages>0)
- p_list->push_back( PropertyInfo(Variant::INT,"array/page",PROPERTY_HINT_RANGE,"0,"+itos(pages)+",1") );
+ p_list->push_back(PropertyInfo(Variant::INT, "array/size", PROPERTY_HINT_RANGE, "0,100000,1"));
+ int pages = size / ITEMS_PER_PAGE;
+ if (pages > 0)
+ p_list->push_back(PropertyInfo(Variant::INT, "array/page", PROPERTY_HINT_RANGE, "0," + itos(pages) + ",1"));
- int offset=page*ITEMS_PER_PAGE;
+ int offset = page * ITEMS_PER_PAGE;
- int items=MIN(size-offset,ITEMS_PER_PAGE);
+ int items = MIN(size - offset, ITEMS_PER_PAGE);
+ for (int i = 0; i < items; i++) {
- for(int i=0;i<items;i++) {
+ Variant v = arr.get(i + offset);
+ bool is_typed = arr.get_type() != Variant::ARRAY || subtype != Variant::NIL;
- Variant v=arr.get(i+offset);
- bool is_typed = arr.get_type()!=Variant::ARRAY || subtype!=Variant::NIL;
-
if (!is_typed) {
- p_list->push_back(PropertyInfo(Variant::INT,"indices/"+itos(i+offset)+"_type",PROPERTY_HINT_ENUM,vtypes));
+ p_list->push_back(PropertyInfo(Variant::INT, "indices/" + itos(i + offset) + "_type", PROPERTY_HINT_ENUM, vtypes));
}
-
- if (is_typed || v.get_type()!=Variant::NIL ) {
- PropertyInfo pi(v.get_type(),"indices/"+itos(i+offset));
- if(subtype!=Variant::NIL) {
+
+ if (is_typed || v.get_type() != Variant::NIL) {
+ PropertyInfo pi(v.get_type(), "indices/" + itos(i + offset));
+ if (subtype != Variant::NIL) {
pi.type = Variant::Type(subtype);
pi.hint = PropertyHint(subtype_hint);
pi.hint_string = subtype_hint_string;
- } else if (v.get_type()==Variant::OBJECT) {
- pi.hint=PROPERTY_HINT_RESOURCE_TYPE;
- pi.hint_string="Resource";
+ } else if (v.get_type() == Variant::OBJECT) {
+ pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
+ pi.hint_string = "Resource";
}
-
+
p_list->push_back(pi);
}
}
-
}
-void ArrayPropertyEdit::edit(Object* p_obj,const StringName& p_prop,const String& p_hint_string,Variant::Type p_deftype) {
+void ArrayPropertyEdit::edit(Object *p_obj, const StringName &p_prop, const String &p_hint_string, Variant::Type p_deftype) {
- page=0;
- property=p_prop;
- obj=p_obj->get_instance_ID();
- default_type=p_deftype;
+ page = 0;
+ property = p_prop;
+ obj = p_obj->get_instance_ID();
+ default_type = p_deftype;
- if(!p_hint_string.empty()) {
+ if (!p_hint_string.empty()) {
int hint_subtype_seperator = p_hint_string.find(":");
- if(hint_subtype_seperator >= 0) {
- String subtype_string = p_hint_string.substr(0,hint_subtype_seperator);
-
+ if (hint_subtype_seperator >= 0) {
+ String subtype_string = p_hint_string.substr(0, hint_subtype_seperator);
+
int slash_pos = subtype_string.find("/");
- if(slash_pos >= 0) {
- subtype_hint = PropertyHint(subtype_string.substr(slash_pos+1, subtype_string.size()-slash_pos-1).to_int());
- subtype_string = subtype_string.substr(0,slash_pos);
+ if (slash_pos >= 0) {
+ subtype_hint = PropertyHint(subtype_string.substr(slash_pos + 1, subtype_string.size() - slash_pos - 1).to_int());
+ subtype_string = subtype_string.substr(0, slash_pos);
}
-
- subtype_hint_string = p_hint_string.substr(hint_subtype_seperator+1, p_hint_string.size() - hint_subtype_seperator-1);
- subtype=Variant::Type(subtype_string.to_int());
+
+ subtype_hint_string = p_hint_string.substr(hint_subtype_seperator + 1, p_hint_string.size() - hint_subtype_seperator - 1);
+ subtype = Variant::Type(subtype_string.to_int());
}
}
-
}
Node *ArrayPropertyEdit::get_node() {
@@ -288,23 +281,22 @@ Node *ArrayPropertyEdit::get_node() {
void ArrayPropertyEdit::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_set_size"),&ArrayPropertyEdit::_set_size);
- ClassDB::bind_method(D_METHOD("_set_value"),&ArrayPropertyEdit::_set_value);
- ClassDB::bind_method(D_METHOD("_notif_change"),&ArrayPropertyEdit::_notif_change);
- ClassDB::bind_method(D_METHOD("_notif_changev"),&ArrayPropertyEdit::_notif_changev);
+ ClassDB::bind_method(D_METHOD("_set_size"), &ArrayPropertyEdit::_set_size);
+ ClassDB::bind_method(D_METHOD("_set_value"), &ArrayPropertyEdit::_set_value);
+ ClassDB::bind_method(D_METHOD("_notif_change"), &ArrayPropertyEdit::_notif_change);
+ ClassDB::bind_method(D_METHOD("_notif_changev"), &ArrayPropertyEdit::_notif_changev);
}
-ArrayPropertyEdit::ArrayPropertyEdit()
-{
- page=0;
- for(int i=0;i<Variant::VARIANT_MAX;i++) {
+ArrayPropertyEdit::ArrayPropertyEdit() {
+ page = 0;
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- if (i>0)
- vtypes+=",";
- vtypes+=Variant::get_type_name( Variant::Type(i) );
+ if (i > 0)
+ vtypes += ",";
+ vtypes += Variant::get_type_name(Variant::Type(i));
}
- default_type=Variant::NIL;
- subtype=Variant::NIL;
- subtype_hint=PROPERTY_HINT_NONE;
- subtype_hint_string="";
+ default_type = Variant::NIL;
+ subtype = Variant::NIL;
+ subtype_hint = PROPERTY_HINT_NONE;
+ subtype_hint_string = "";
}
diff --git a/editor/array_property_edit.h b/editor/array_property_edit.h
index 6ca700bf80..1461aa52a3 100644
--- a/editor/array_property_edit.h
+++ b/editor/array_property_edit.h
@@ -33,7 +33,7 @@
class ArrayPropertyEdit : public Reference {
- GDCLASS(ArrayPropertyEdit,Reference);
+ GDCLASS(ArrayPropertyEdit, Reference);
int page;
ObjectID obj;
@@ -46,20 +46,18 @@ class ArrayPropertyEdit : public Reference {
Variant::Type default_type;
void _notif_change();
- void _notif_changev(const String& p_v);
+ void _notif_changev(const String &p_v);
void _set_size(int p_size);
- void _set_value(int p_idx,const Variant& p_value);
+ void _set_value(int p_idx, const Variant &p_value);
protected:
-
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 edit(Object* p_obj, const StringName& p_prop, const String& p_hint_string, Variant::Type p_deftype);
+ void edit(Object *p_obj, const StringName &p_prop, const String &p_hint_string, Variant::Type p_deftype);
Node *get_node();
diff --git a/editor/asset_library_editor_plugin.cpp b/editor/asset_library_editor_plugin.cpp
index 1c1b6c91e3..7bfe52d1b4 100644
--- a/editor/asset_library_editor_plugin.cpp
+++ b/editor/asset_library_editor_plugin.cpp
@@ -32,72 +32,65 @@
#include "editor_settings.h"
#include "io/json.h"
-
-void EditorAssetLibraryItem::configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost) {
+void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost) {
title->set_text(p_title);
- asset_id=p_asset_id;
+ asset_id = p_asset_id;
category->set_text(p_category);
- category_id=p_category_id;
+ category_id = p_category_id;
author->set_text(p_author);
- author_id=p_author_id;
+ author_id = p_author_id;
price->set_text(p_cost);
- for(int i=0;i<5;i++) {
- if (i<p_rating)
- stars[i]->set_texture(get_icon("RatingStar","EditorIcons"));
+ for (int i = 0; i < 5; i++) {
+ if (i < p_rating)
+ stars[i]->set_texture(get_icon("RatingStar", "EditorIcons"));
else
- stars[i]->set_texture(get_icon("RatingNoStar","EditorIcons"));
+ stars[i]->set_texture(get_icon("RatingNoStar", "EditorIcons"));
}
-
-
}
-void EditorAssetLibraryItem::set_image(int p_type,int p_index,const Ref<Texture>& p_image) {
+void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture> &p_image) {
- ERR_FAIL_COND(p_type!=EditorAssetLibrary::IMAGE_QUEUE_ICON);
- ERR_FAIL_COND(p_index!=0);
+ ERR_FAIL_COND(p_type != EditorAssetLibrary::IMAGE_QUEUE_ICON);
+ ERR_FAIL_COND(p_index != 0);
icon->set_normal_texture(p_image);
}
void EditorAssetLibraryItem::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
-
- icon->set_normal_texture(get_icon("GodotAssetDefault","EditorIcons"));
- category->add_color_override("font_color", Color(0.5,0.5,0.5) );
- author->add_color_override("font_color", Color(0.5,0.5,0.5) );
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ icon->set_normal_texture(get_icon("GodotAssetDefault", "EditorIcons"));
+ category->add_color_override("font_color", Color(0.5, 0.5, 0.5));
+ author->add_color_override("font_color", Color(0.5, 0.5, 0.5));
}
}
void EditorAssetLibraryItem::_asset_clicked() {
- emit_signal("asset_selected",asset_id);
+ emit_signal("asset_selected", asset_id);
}
-void EditorAssetLibraryItem::_category_clicked(){
+void EditorAssetLibraryItem::_category_clicked() {
- emit_signal("category_selected",category_id);
+ emit_signal("category_selected", category_id);
}
-void EditorAssetLibraryItem::_author_clicked(){
-
- emit_signal("author_selected",author_id);
+void EditorAssetLibraryItem::_author_clicked() {
+ emit_signal("author_selected", author_id);
}
void EditorAssetLibraryItem::_bind_methods() {
- ClassDB::bind_method("set_image",&EditorAssetLibraryItem::set_image);
- ClassDB::bind_method("_asset_clicked",&EditorAssetLibraryItem::_asset_clicked);
- ClassDB::bind_method("_category_clicked",&EditorAssetLibraryItem::_category_clicked);
- ClassDB::bind_method("_author_clicked",&EditorAssetLibraryItem::_author_clicked);
- ADD_SIGNAL( MethodInfo("asset_selected"));
- ADD_SIGNAL( MethodInfo("category_selected"));
- ADD_SIGNAL( MethodInfo("author_selected"));
-
-
+ ClassDB::bind_method("set_image", &EditorAssetLibraryItem::set_image);
+ ClassDB::bind_method("_asset_clicked", &EditorAssetLibraryItem::_asset_clicked);
+ ClassDB::bind_method("_category_clicked", &EditorAssetLibraryItem::_category_clicked);
+ ClassDB::bind_method("_author_clicked", &EditorAssetLibraryItem::_author_clicked);
+ ADD_SIGNAL(MethodInfo("asset_selected"));
+ ADD_SIGNAL(MethodInfo("category_selected"));
+ ADD_SIGNAL(MethodInfo("author_selected"));
}
EditorAssetLibraryItem::EditorAssetLibraryItem() {
@@ -108,53 +101,52 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
border->set_default_margin(MARGIN_RIGHT,5);
border->set_default_margin(MARGIN_BOTTOM,5);
border->set_default_margin(MARGIN_TOP,5);*/
- add_style_override("panel",border);
+ add_style_override("panel", border);
- HBoxContainer *hb = memnew( HBoxContainer );
+ HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
- icon = memnew( TextureButton );
+ icon = memnew(TextureButton);
icon->set_default_cursor_shape(CURSOR_POINTING_HAND);
- icon->connect("pressed",this,"_asset_clicked");
+ icon->connect("pressed", this, "_asset_clicked");
hb->add_child(icon);
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
hb->add_child(vb);
vb->set_h_size_flags(SIZE_EXPAND_FILL);
- title = memnew( LinkButton );
+ title = memnew(LinkButton);
title->set_text("My Awesome Addon");
title->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
- title->connect("pressed",this,"_asset_clicked");
+ title->connect("pressed", this, "_asset_clicked");
vb->add_child(title);
-
- category = memnew( LinkButton );
+ category = memnew(LinkButton);
category->set_text("Editor Tools");
category->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
- category->connect("pressed",this,"_category_clicked");
+ category->connect("pressed", this, "_category_clicked");
vb->add_child(category);
- author = memnew( LinkButton );
+ author = memnew(LinkButton);
author->set_text("Johny Tolengo");
author->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
- author->connect("pressed",this,"_author_clicked");
+ author->connect("pressed", this, "_author_clicked");
vb->add_child(author);
- HBoxContainer *rating_hb = memnew( HBoxContainer );
+ HBoxContainer *rating_hb = memnew(HBoxContainer);
vb->add_child(rating_hb);
- for(int i=0;i<5;i++) {
- stars[i]=memnew(TextureRect);
+ for (int i = 0; i < 5; i++) {
+ stars[i] = memnew(TextureRect);
rating_hb->add_child(stars[i]);
}
- price = memnew( Label );
+ price = memnew(Label);
price->set_text("Free");
vb->add_child(price);
- set_custom_minimum_size(Size2(250,100));
+ set_custom_minimum_size(Size2(250, 100));
set_h_size_flags(SIZE_EXPAND_FILL);
set_mouse_filter(MOUSE_FILTER_PASS);
@@ -162,20 +154,19 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
//////////////////////////////////////////////////////////////////////////////
+void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const Ref<Texture> &p_image) {
-void EditorAssetLibraryItemDescription::set_image(int p_type,int p_index,const Ref<Texture>& p_image) {
-
- switch(p_type) {
+ switch (p_type) {
case EditorAssetLibrary::IMAGE_QUEUE_ICON: {
- item->call("set_image",p_type,p_index,p_image);
- icon=p_image;
+ item->call("set_image", p_type, p_index, p_image);
+ icon = p_image;
} break;
case EditorAssetLibrary::IMAGE_QUEUE_THUMBNAIL: {
- for(int i=0;i<preview_images.size();i++) {
- if (preview_images[i].id==p_index) {
+ for (int i = 0; i < preview_images.size(); i++) {
+ if (preview_images[i].id == p_index) {
preview_images[i].button->set_icon(p_image);
break;
}
@@ -184,10 +175,10 @@ void EditorAssetLibraryItemDescription::set_image(int p_type,int p_index,const R
} break;
case EditorAssetLibrary::IMAGE_QUEUE_SCREENSHOT: {
- for(int i=0;i<preview_images.size();i++) {
- if (preview_images[i].id==p_index) {
+ for (int i = 0; i < preview_images.size(); i++) {
+ if (preview_images[i].id == p_index) {
preview_images[i].image = p_image;
- if(preview_images[i].button->is_pressed()) {
+ if (preview_images[i].button->is_pressed()) {
_preview_click(p_index);
}
break;
@@ -199,23 +190,22 @@ void EditorAssetLibraryItemDescription::set_image(int p_type,int p_index,const R
}
void EditorAssetLibraryItemDescription::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_image"),&EditorAssetLibraryItemDescription::set_image);
- ClassDB::bind_method(D_METHOD("_link_click"),&EditorAssetLibraryItemDescription::_link_click);
- ClassDB::bind_method(D_METHOD("_preview_click"),&EditorAssetLibraryItemDescription::_preview_click);
-
+ ClassDB::bind_method(D_METHOD("set_image"), &EditorAssetLibraryItemDescription::set_image);
+ ClassDB::bind_method(D_METHOD("_link_click"), &EditorAssetLibraryItemDescription::_link_click);
+ ClassDB::bind_method(D_METHOD("_preview_click"), &EditorAssetLibraryItemDescription::_preview_click);
}
-void EditorAssetLibraryItemDescription::_link_click(const String& p_url) {
+void EditorAssetLibraryItemDescription::_link_click(const String &p_url) {
ERR_FAIL_COND(!p_url.begins_with("http"));
OS::get_singleton()->shell_open(p_url);
}
void EditorAssetLibraryItemDescription::_preview_click(int p_id) {
- for(int i=0;i<preview_images.size();i++) {
- if(preview_images[i].id==p_id) {
+ for (int i = 0; i < preview_images.size(); i++) {
+ if (preview_images[i].id == p_id) {
preview_images[i].button->set_pressed(true);
- if(!preview_images[i].is_video) {
- if(preview_images[i].image.is_valid()) {
+ if (!preview_images[i].is_video) {
+ if (preview_images[i].image.is_valid()) {
preview->set_texture(preview_images[i].image);
}
} else {
@@ -227,40 +217,40 @@ void EditorAssetLibraryItemDescription::_preview_click(int p_id) {
}
}
-void EditorAssetLibraryItemDescription::configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost,int p_version,const String& p_version_string,const String& p_description,const String& p_download_url,const String& p_browse_url,const String& p_sha256_hash) {
+void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash) {
- asset_id=p_asset_id;
- title=p_title;
- download_url=p_download_url;
- sha256=p_sha256_hash;
- item->configure(p_title,p_asset_id,p_category,p_category_id,p_author,p_author_id,p_rating,p_cost);
+ asset_id = p_asset_id;
+ title = p_title;
+ download_url = p_download_url;
+ sha256 = p_sha256_hash;
+ item->configure(p_title, p_asset_id, p_category, p_category_id, p_author, p_author_id, p_rating, p_cost);
description->clear();
- description->add_text("Version: "+p_version_string+"\n");
+ description->add_text("Version: " + p_version_string + "\n");
description->add_text("Contents: ");
description->push_meta(p_browse_url);
description->add_text("View Files");
description->pop();
description->add_text("\nDescription:\n\n");
- description->append_bbcode(p_description);
+ description->append_bbcode(p_description);
set_title(p_title);
}
-void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video,const String& p_url){
+void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, const String &p_url) {
Preview preview;
- preview.id=p_id;
- preview.video_link=p_url;
- preview.is_video=p_video;
- preview.button = memnew( Button );
+ preview.id = p_id;
+ preview.video_link = p_url;
+ preview.is_video = p_video;
+ preview.button = memnew(Button);
preview.button->set_flat(true);
- preview.button->set_icon(get_icon("ThumbnailWait","EditorIcons"));
+ preview.button->set_icon(get_icon("ThumbnailWait", "EditorIcons"));
preview.button->set_toggle_mode(true);
preview.button->connect("pressed", this, "_preview_click", varray(p_id));
preview_hb->add_child(preview.button);
- if(!p_video) {
- preview.image=get_icon("ThumbnailWait","EditorIcons");
+ if (!p_video) {
+ preview.image = get_icon("ThumbnailWait", "EditorIcons");
}
- if(preview_images.size()==0 && !p_video) {
+ if (preview_images.size() == 0 && !p_video) {
_preview_click(p_id);
}
preview_images.push_back(preview);
@@ -268,158 +258,147 @@ void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video,const
EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
- VBoxContainer *vbox = memnew( VBoxContainer );
+ VBoxContainer *vbox = memnew(VBoxContainer);
add_child(vbox);
-
-
- HBoxContainer *hbox = memnew( HBoxContainer);
+ HBoxContainer *hbox = memnew(HBoxContainer);
vbox->add_child(hbox);
- vbox->add_constant_override("separation",15);
- VBoxContainer *desc_vbox = memnew( VBoxContainer );
+ vbox->add_constant_override("separation", 15);
+ VBoxContainer *desc_vbox = memnew(VBoxContainer);
hbox->add_child(desc_vbox);
- hbox->add_constant_override("separation",15);
+ hbox->add_constant_override("separation", 15);
- item = memnew( EditorAssetLibraryItem );
+ item = memnew(EditorAssetLibraryItem);
desc_vbox->add_child(item);
- desc_vbox->set_custom_minimum_size(Size2(300,0));
+ desc_vbox->set_custom_minimum_size(Size2(300, 0));
-
- PanelContainer * desc_bg = memnew( PanelContainer );
+ PanelContainer *desc_bg = memnew(PanelContainer);
desc_vbox->add_child(desc_bg);
desc_bg->set_v_size_flags(SIZE_EXPAND_FILL);
- description = memnew( RichTextLabel );
- description->connect("meta_clicked",this,"_link_click");
+ description = memnew(RichTextLabel);
+ description->connect("meta_clicked", this, "_link_click");
//desc_vbox->add_child(description);
desc_bg->add_child(description);
- desc_bg->add_style_override("panel",get_stylebox("normal","TextEdit"));
+ desc_bg->add_style_override("panel", get_stylebox("normal", "TextEdit"));
- preview = memnew( TextureRect );
- preview->set_custom_minimum_size(Size2(640,345));
+ preview = memnew(TextureRect);
+ preview->set_custom_minimum_size(Size2(640, 345));
hbox->add_child(preview);
- PanelContainer * previews_bg = memnew( PanelContainer );
+ PanelContainer *previews_bg = memnew(PanelContainer);
vbox->add_child(previews_bg);
- previews_bg->set_custom_minimum_size(Size2(0,85));
- previews_bg->add_style_override("panel",get_stylebox("normal","TextEdit"));
+ previews_bg->set_custom_minimum_size(Size2(0, 85));
+ previews_bg->add_style_override("panel", get_stylebox("normal", "TextEdit"));
- previews = memnew( ScrollContainer );
+ previews = memnew(ScrollContainer);
previews_bg->add_child(previews);
previews->set_enable_v_scroll(false);
previews->set_enable_h_scroll(true);
- preview_hb = memnew( HBoxContainer );
+ preview_hb = memnew(HBoxContainer);
preview_hb->set_v_size_flags(SIZE_EXPAND_FILL);
previews->add_child(preview_hb);
get_ok()->set_text("Install");
get_cancel()->set_text("Close");
-
-
-
}
///////////////////////////////////////////////////////////////////////////////////
-void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int p_code, const PoolStringArray& headers, const PoolByteArray& p_data) {
-
+void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data) {
String error_text;
- print_line("COMPLETED: "+itos(p_status)+" code: "+itos(p_code)+" data size: "+itos(p_data.size()));
+ print_line("COMPLETED: " + itos(p_status) + " code: " + itos(p_code) + " data size: " + itos(p_data.size()));
- switch(p_status) {
+ switch (p_status) {
case HTTPRequest::RESULT_CANT_RESOLVE: {
- error_text=("Can't resolve hostname: "+host);
+ error_text = ("Can't resolve hostname: " + host);
status->set_text("Can't resolve.");
} break;
case HTTPRequest::RESULT_BODY_SIZE_LIMIT_EXCEEDED:
case HTTPRequest::RESULT_CONNECTION_ERROR:
case HTTPRequest::RESULT_CHUNKED_BODY_SIZE_MISMATCH: {
- error_text=("Connection error, please try again.");
+ error_text = ("Connection error, please try again.");
status->set_text("Can't connect.");
} break;
case HTTPRequest::RESULT_SSL_HANDSHAKE_ERROR:
case HTTPRequest::RESULT_CANT_CONNECT: {
- error_text=("Can't connect to host: "+host);
+ error_text = ("Can't connect to host: " + host);
status->set_text("Can't connect.");
} break;
case HTTPRequest::RESULT_NO_RESPONSE: {
- error_text=("No response from host: "+host);
+ error_text = ("No response from host: " + host);
status->set_text("No response.");
} break;
case HTTPRequest::RESULT_REQUEST_FAILED: {
- error_text=("Request failed, return code: "+itos(p_code));
+ error_text = ("Request failed, return code: " + itos(p_code));
status->set_text("Req. Failed.");
} break;
case HTTPRequest::RESULT_REDIRECT_LIMIT_REACHED: {
- error_text=("Request failed, too many redirects");
+ error_text = ("Request failed, too many redirects");
status->set_text("Redirect Loop.");
} break;
default: {
- if (p_code!=200) {
- error_text=("Request failed, return code: "+itos(p_code));
- status->set_text("Failed: "+itos(p_code));
- } else if(sha256 != "") {
+ if (p_code != 200) {
+ error_text = ("Request failed, return code: " + itos(p_code));
+ status->set_text("Failed: " + itos(p_code));
+ } else if (sha256 != "") {
String download_sha256 = FileAccess::get_sha256(download->get_download_file());
- if(sha256 != download_sha256) {
- error_text="Bad download hash, assuming file has been tampered with.\nExpected: " + sha256 + "\nGot: " + download_sha256;
+ if (sha256 != download_sha256) {
+ error_text = "Bad download hash, assuming file has been tampered with.\nExpected: " + sha256 + "\nGot: " + download_sha256;
status->set_text("Failed sha256 hash check");
}
}
} break;
-
}
- if (error_text!=String()) {
- download_error->set_text("Asset Download Error:\n"+error_text);
+ if (error_text != String()) {
+ download_error->set_text("Asset Download Error:\n" + error_text);
download_error->popup_centered_minsize();
return;
-
}
- progress->set_max( download->get_body_size() );
+ progress->set_max(download->get_body_size());
progress->set_value(download->get_downloaded_bytes());
- print_line("max: "+itos(download->get_body_size())+" bytes: "+itos(download->get_downloaded_bytes()));
+ print_line("max: " + itos(download->get_body_size()) + " bytes: " + itos(download->get_downloaded_bytes()));
install->set_disabled(false);
progress->set_value(download->get_downloaded_bytes());
- status->set_text("Success! ("+String::humanize_size(download->get_downloaded_bytes())+")");
+ status->set_text("Success! (" + String::humanize_size(download->get_downloaded_bytes()) + ")");
set_process(false);
}
-
-void EditorAssetLibraryItemDownload::configure(const String& p_title,int p_asset_id,const Ref<Texture>& p_preview, const String& p_download_url, const String& p_sha256_hash) {
+void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asset_id, const Ref<Texture> &p_preview, const String &p_download_url, const String &p_sha256_hash) {
title->set_text(p_title);
icon->set_texture(p_preview);
- asset_id=p_asset_id;
+ asset_id = p_asset_id;
if (!p_preview.is_valid())
- icon->set_texture(get_icon("GodotAssetDefault","EditorIcons"));
- host=p_download_url;
- sha256=p_sha256_hash;
- asset_installer->connect("confirmed",this,"_close");
- dismiss->set_normal_texture( get_icon("Close","EditorIcons"));
+ icon->set_texture(get_icon("GodotAssetDefault", "EditorIcons"));
+ host = p_download_url;
+ sha256 = p_sha256_hash;
+ asset_installer->connect("confirmed", this, "_close");
+ dismiss->set_normal_texture(get_icon("Close", "EditorIcons"));
_make_request();
}
-
void EditorAssetLibraryItemDownload::_notification(int p_what) {
- if (p_what==NOTIFICATION_PROCESS) {
+ if (p_what == NOTIFICATION_PROCESS) {
- progress->set_max( download->get_body_size() );
+ progress->set_max(download->get_body_size());
progress->set_value(download->get_downloaded_bytes());
int cstatus = download->get_http_client_status();
- if (cstatus==HTTPClient::STATUS_BODY)
- status->set_text("Fetching: "+String::humanize_size(download->get_downloaded_bytes()));
+ if (cstatus == HTTPClient::STATUS_BODY)
+ status->set_text("Fetching: " + String::humanize_size(download->get_downloaded_bytes()));
- if (cstatus!=prev_status) {
- switch(cstatus) {
+ if (cstatus != prev_status) {
+ switch (cstatus) {
case HTTPClient::STATUS_RESOLVING: {
status->set_text("Resolving..");
@@ -432,9 +411,8 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) {
} break;
default: {}
}
- prev_status=cstatus;
+ prev_status = cstatus;
}
-
}
}
void EditorAssetLibraryItemDownload::_close() {
@@ -450,20 +428,19 @@ void EditorAssetLibraryItemDownload::_install() {
String file = download->get_download_file();
if (external_install) {
- emit_signal("install_asset",file,title->get_text());
+ emit_signal("install_asset", file, title->get_text());
return;
}
-
- asset_installer->open(file,1);
+ asset_installer->open(file, 1);
}
void EditorAssetLibraryItemDownload::_make_request() {
download->cancel_request();
- download->set_download_file(EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("tmp_asset_"+itos(asset_id))+".zip");
+ download->set_download_file(EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("tmp_asset_" + itos(asset_id)) + ".zip");
Error err = download->request(host);
- if(err!=OK) {
+ if (err != OK) {
status->set_text("Error making request");
} else {
set_process(true);
@@ -472,114 +449,107 @@ void EditorAssetLibraryItemDownload::_make_request() {
void EditorAssetLibraryItemDownload::_bind_methods() {
- ClassDB::bind_method("_http_download_completed",&EditorAssetLibraryItemDownload::_http_download_completed);
- ClassDB::bind_method("_install",&EditorAssetLibraryItemDownload::_install);
- ClassDB::bind_method("_close",&EditorAssetLibraryItemDownload::_close);
- ClassDB::bind_method("_make_request",&EditorAssetLibraryItemDownload::_make_request);
-
- ADD_SIGNAL(MethodInfo("install_asset",PropertyInfo(Variant::STRING,"zip_path"),PropertyInfo(Variant::STRING,"name")));
+ ClassDB::bind_method("_http_download_completed", &EditorAssetLibraryItemDownload::_http_download_completed);
+ ClassDB::bind_method("_install", &EditorAssetLibraryItemDownload::_install);
+ ClassDB::bind_method("_close", &EditorAssetLibraryItemDownload::_close);
+ ClassDB::bind_method("_make_request", &EditorAssetLibraryItemDownload::_make_request);
+ ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name")));
}
EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
- HBoxContainer *hb = memnew( HBoxContainer);
+ HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
- icon = memnew( TextureRect );
+ icon = memnew(TextureRect);
hb->add_child(icon);
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
hb->add_child(vb);
vb->set_h_size_flags(SIZE_EXPAND_FILL);
- HBoxContainer *title_hb = memnew( HBoxContainer);
+ HBoxContainer *title_hb = memnew(HBoxContainer);
vb->add_child(title_hb);
- title = memnew( Label );
+ title = memnew(Label);
title_hb->add_child(title);
title->set_h_size_flags(SIZE_EXPAND_FILL);
- dismiss = memnew( TextureButton );
- dismiss->connect("pressed",this,"_close");
+ dismiss = memnew(TextureButton);
+ dismiss->connect("pressed", this, "_close");
title_hb->add_child(dismiss);
title->set_clip_text(true);
vb->add_spacer();
- status = memnew (Label("Idle"));
+ status = memnew(Label("Idle"));
vb->add_child(status);
- status->add_color_override("font_color", Color(0.5,0.5,0.5) );
- progress = memnew( ProgressBar );
+ status->add_color_override("font_color", Color(0.5, 0.5, 0.5));
+ progress = memnew(ProgressBar);
vb->add_child(progress);
-
-
- HBoxContainer *hb2 = memnew( HBoxContainer );
+ HBoxContainer *hb2 = memnew(HBoxContainer);
vb->add_child(hb2);
hb2->add_spacer();
- install = memnew( Button );
+ install = memnew(Button);
install->set_text("Install");
install->set_disabled(true);
- install->connect("pressed",this,"_install");
+ install->connect("pressed", this, "_install");
- retry = memnew( Button );
+ retry = memnew(Button);
retry->set_text("Retry");
- retry->connect("pressed",this,"_make_request");
+ retry->connect("pressed", this, "_make_request");
hb2->add_child(retry);
hb2->add_child(install);
- set_custom_minimum_size(Size2(250,0));
+ set_custom_minimum_size(Size2(250, 0));
- download = memnew( HTTPRequest );
+ download = memnew(HTTPRequest);
add_child(download);
- download->connect("request_completed",this,"_http_download_completed");
+ download->connect("request_completed", this, "_http_download_completed");
- download_error = memnew( AcceptDialog );
+ download_error = memnew(AcceptDialog);
add_child(download_error);
download_error->set_title("Download Error");
- asset_installer = memnew( EditorAssetInstaller );
+ asset_installer = memnew(EditorAssetInstaller);
add_child(asset_installer);
- prev_status=-1;
-
- external_install=false;
-
+ prev_status = -1;
+ external_install = false;
}
-
-
////////////////////////////////////////////////////////////////////////////////
void EditorAssetLibrary::_notification(int p_what) {
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
TextureRect *tf = memnew(TextureRect);
- tf->set_texture(get_icon("Error","EditorIcons"));
- reverse->set_icon(get_icon("Updown","EditorIcons"));
+ tf->set_texture(get_icon("Error", "EditorIcons"));
+ reverse->set_icon(get_icon("Updown", "EditorIcons"));
error_hb->add_child(tf);
error_label->raise();
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if(is_visible()) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+ if (is_visible()) {
_repository_changed(0); // Update when shown for the first time
}
}
- if (p_what==NOTIFICATION_PROCESS) {
+ if (p_what == NOTIFICATION_PROCESS) {
HTTPClient::Status s = request->get_http_client_status();
- bool visible = s!=HTTPClient::STATUS_DISCONNECTED;
+ bool visible = s != HTTPClient::STATUS_DISCONNECTED;
if (visible != load_status->is_visible()) {
load_status->set_visible(visible);
}
if (visible) {
- switch(s) {
+ switch (s) {
case HTTPClient::STATUS_RESOLVING: {
load_status->set_value(0.1);
@@ -594,26 +564,23 @@ void EditorAssetLibrary::_notification(int p_what) {
load_status->set_value(0.4);
} break;
default: {}
-
}
}
- bool no_downloads = downloads_hb->get_child_count()==0;
+ bool no_downloads = downloads_hb->get_child_count() == 0;
if (no_downloads == downloads_scroll->is_visible()) {
downloads_scroll->set_visible(!no_downloads);
}
}
-
}
-
void EditorAssetLibrary::_install_asset() {
ERR_FAIL_COND(!description);
- for(int i=0;i<downloads_hb->get_child_count();i++) {
+ for (int i = 0; i < downloads_hb->get_child_count(); i++) {
- EditorAssetLibraryItemDownload *d = downloads_hb->get_child(i)->cast_to<EditorAssetLibraryItemDownload>();
+ EditorAssetLibraryItemDownload *d = downloads_hb->get_child(i)->cast_to<EditorAssetLibraryItemDownload>();
if (d && d->get_asset_id() == description->get_asset_id()) {
if (EditorNode::get_singleton() != NULL)
@@ -622,19 +589,17 @@ void EditorAssetLibrary::_install_asset() {
}
}
-
- EditorAssetLibraryItemDownload * download = memnew( EditorAssetLibraryItemDownload );
+ EditorAssetLibraryItemDownload *download = memnew(EditorAssetLibraryItemDownload);
downloads_hb->add_child(download);
- download->configure(description->get_title(),description->get_asset_id(),description->get_preview_icon(),description->get_download_url(),description->get_sha256());
+ download->configure(description->get_title(), description->get_asset_id(), description->get_preview_icon(), description->get_download_url(), description->get_sha256());
if (templates_only) {
download->set_external_install(true);
- download->connect("install_asset",this,"_install_external_asset");
+ download->connect("install_asset", this, "_install_external_asset");
}
-
}
-const char* EditorAssetLibrary::sort_key[SORT_MAX]={
+const char *EditorAssetLibrary::sort_key[SORT_MAX] = {
"rating",
"downloads",
"name",
@@ -642,7 +607,7 @@ const char* EditorAssetLibrary::sort_key[SORT_MAX]={
"updated"
};
-const char* EditorAssetLibrary::sort_text[SORT_MAX]={
+const char *EditorAssetLibrary::sort_text[SORT_MAX] = {
"Rating",
"Downloads",
"Name",
@@ -650,35 +615,34 @@ const char* EditorAssetLibrary::sort_text[SORT_MAX]={
"Updated"
};
-const char* EditorAssetLibrary::support_key[SUPPORT_MAX]={
+const char *EditorAssetLibrary::support_key[SUPPORT_MAX] = {
"official",
"community",
"testing"
};
-
void EditorAssetLibrary::_select_author(int p_id) {
//opemn author window
}
-void EditorAssetLibrary::_select_category(int p_id){
+void EditorAssetLibrary::_select_category(int p_id) {
- for(int i=0;i<categories->get_item_count();i++) {
+ for (int i = 0; i < categories->get_item_count(); i++) {
- if (i==0)
+ if (i == 0)
continue;
int id = categories->get_item_metadata(i);
- if (id==p_id) {
+ if (id == p_id) {
categories->select(i);
_search();
break;
}
}
}
-void EditorAssetLibrary::_select_asset(int p_id){
+void EditorAssetLibrary::_select_asset(int p_id) {
- _api_request("asset/"+itos(p_id), REQUESTING_ASSET);
+ _api_request("asset/" + itos(p_id), REQUESTING_ASSET);
/*
if (description) {
@@ -691,43 +655,43 @@ void EditorAssetLibrary::_select_asset(int p_id){
description->popup_centered_minsize();*/
}
-void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByteArray& p_data, int p_queue_id) {
+void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByteArray &p_data, int p_queue_id) {
Object *obj = ObjectDB::get_instance(image_queue[p_queue_id].target);
if (obj) {
bool image_set = false;
PoolByteArray image_data = p_data;
-
- if(use_cache) {
- String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_"+image_queue[p_queue_id].image_url.md5_text());
-
- FileAccess* file = FileAccess::open(cache_filename_base+".data", FileAccess::READ);
-
- if(file) {
+
+ if (use_cache) {
+ String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text());
+
+ FileAccess *file = FileAccess::open(cache_filename_base + ".data", FileAccess::READ);
+
+ if (file) {
PoolByteArray cached_data;
- int len=file->get_32();
+ int len = file->get_32();
cached_data.resize(len);
-
- PoolByteArray::Write w=cached_data.write();
+
+ PoolByteArray::Write w = cached_data.write();
file->get_buffer(w.ptr(), len);
-
+
image_data = cached_data;
file->close();
}
}
-
- int len=image_data.size();
- PoolByteArray::Read r=image_data.read();
- Image image(r.ptr(),len);
+
+ int len = image_data.size();
+ PoolByteArray::Read r = image_data.read();
+ Image image(r.ptr(), len);
if (!image.empty()) {
float max_height = 10000;
- switch(image_queue[p_queue_id].image_type) {
- case IMAGE_QUEUE_ICON: max_height=80; break;
- case IMAGE_QUEUE_THUMBNAIL: max_height=80; break;
- case IMAGE_QUEUE_SCREENSHOT: max_height=345; break;
+ switch (image_queue[p_queue_id].image_type) {
+ case IMAGE_QUEUE_ICON: max_height = 80; break;
+ case IMAGE_QUEUE_THUMBNAIL: max_height = 80; break;
+ case IMAGE_QUEUE_SCREENSHOT: max_height = 345; break;
}
float scale_ratio = max_height / image.get_height();
- if(scale_ratio < 1) {
+ if (scale_ratio < 1) {
image.resize(image.get_width() * scale_ratio, image.get_height() * scale_ratio, Image::INTERPOLATE_CUBIC);
}
@@ -735,57 +699,57 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt
tex.instance();
tex->create_from_image(image);
- obj->call("set_image",image_queue[p_queue_id].image_type,image_queue[p_queue_id].image_index,tex);
+ obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, tex);
image_set = true;
}
-
- if(!image_set && final) {
- obj->call("set_image",image_queue[p_queue_id].image_type,image_queue[p_queue_id].image_index,get_icon("ErrorSign","EditorIcons"));
+
+ if (!image_set && final) {
+ obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_icon("ErrorSign", "EditorIcons"));
}
}
}
-void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, const PoolStringArray& headers, const PoolByteArray& p_data,int p_queue_id) {
+void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data, int p_queue_id) {
+
+ ERR_FAIL_COND(!image_queue.has(p_queue_id));
- ERR_FAIL_COND( !image_queue.has(p_queue_id) );
+ if (p_status == HTTPRequest::RESULT_SUCCESS) {
- if (p_status==HTTPRequest::RESULT_SUCCESS) {
-
print_line("GOT IMAGE YAY!");
-
- if(p_code != HTTPClient::RESPONSE_NOT_MODIFIED) {
- for(int i=0;i<headers.size();i++) {
- if (headers[i].findn("ETag:")==0) { // Save etag
- String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_"+image_queue[p_queue_id].image_url.md5_text());
- String new_etag = headers[i].substr(headers[i].find(":")+1,headers[i].length()).strip_edges();
- FileAccess* file;
-
- file = FileAccess::open(cache_filename_base+".etag", FileAccess::WRITE);
- if(file) {
+
+ if (p_code != HTTPClient::RESPONSE_NOT_MODIFIED) {
+ for (int i = 0; i < headers.size(); i++) {
+ if (headers[i].findn("ETag:") == 0) { // Save etag
+ String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text());
+ String new_etag = headers[i].substr(headers[i].find(":") + 1, headers[i].length()).strip_edges();
+ FileAccess *file;
+
+ file = FileAccess::open(cache_filename_base + ".etag", FileAccess::WRITE);
+ if (file) {
file->store_line(new_etag);
file->close();
}
-
- int len=p_data.size();
- PoolByteArray::Read r=p_data.read();
- file = FileAccess::open(cache_filename_base+".data", FileAccess::WRITE);
- if(file) {
+
+ int len = p_data.size();
+ PoolByteArray::Read r = p_data.read();
+ file = FileAccess::open(cache_filename_base + ".data", FileAccess::WRITE);
+ if (file) {
file->store_32(len);
- file->store_buffer(r.ptr(),len);
+ file->store_buffer(r.ptr(), len);
file->close();
}
-
+
break;
}
}
}
_image_update(p_code == HTTPClient::RESPONSE_NOT_MODIFIED, true, p_data, p_queue_id);
-
+
} else {
- WARN_PRINTS("Error getting PNG file for asset id "+itos(image_queue[p_queue_id].asset_id));
+ WARN_PRINTS("Error getting PNG file for asset id " + itos(image_queue[p_queue_id].asset_id));
Object *obj = ObjectDB::get_instance(image_queue[p_queue_id].target);
if (obj) {
- obj->call("set_image",image_queue[p_queue_id].image_type,image_queue[p_queue_id].image_index,get_icon("ErrorSign","EditorIcons"));
+ obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_icon("ErrorSign", "EditorIcons"));
}
}
@@ -793,35 +757,34 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
image_queue.erase(p_queue_id);
_update_image_queue();
-
}
void EditorAssetLibrary::_update_image_queue() {
- int max_images=2;
- int current_images=0;
+ int max_images = 2;
+ int current_images = 0;
List<int> to_delete;
- for (Map<int,ImageQueue>::Element *E=image_queue.front();E;E=E->next()) {
- if (!E->get().active && current_images<max_images) {
-
- String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_"+E->get().image_url.md5_text());
+ for (Map<int, ImageQueue>::Element *E = image_queue.front(); E; E = E->next()) {
+ if (!E->get().active && current_images < max_images) {
+
+ String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_" + E->get().image_url.md5_text());
Vector<String> headers;
-
- if(FileAccess::exists(cache_filename_base+".etag") && FileAccess::exists(cache_filename_base+".data")) {
- FileAccess* file = FileAccess::open(cache_filename_base+".etag", FileAccess::READ);
+
+ if (FileAccess::exists(cache_filename_base + ".etag") && FileAccess::exists(cache_filename_base + ".data")) {
+ FileAccess *file = FileAccess::open(cache_filename_base + ".etag", FileAccess::READ);
if (file) {
headers.push_back("If-None-Match: " + file->get_line());
file->close();
}
}
- print_line("REQUEST ICON FOR: "+itos(E->get().asset_id));
+ print_line("REQUEST ICON FOR: " + itos(E->get().asset_id));
Error err = E->get().request->request(E->get().image_url, headers);
- if (err!=OK) {
+ if (err != OK) {
to_delete.push_back(E->key());
} else {
- E->get().active=true;
+ E->get().active = true;
}
current_images++;
} else if (E->get().active) {
@@ -829,42 +792,39 @@ void EditorAssetLibrary::_update_image_queue() {
}
}
- while(to_delete.size()) {
+ while (to_delete.size()) {
image_queue[to_delete.front()->get()].request->queue_delete();
image_queue.erase(to_delete.front()->get());
to_delete.pop_front();
}
}
-void EditorAssetLibrary::_request_image(ObjectID p_for,String p_image_url,ImageType p_type,int p_image_index) {
-
+void EditorAssetLibrary::_request_image(ObjectID p_for, String p_image_url, ImageType p_type, int p_image_index) {
ImageQueue iq;
- iq.image_url=p_image_url;
- iq.image_index=p_image_index;
- iq.image_type=p_type;
- iq.request = memnew( HTTPRequest );
+ iq.image_url = p_image_url;
+ iq.image_index = p_image_index;
+ iq.image_type = p_type;
+ iq.request = memnew(HTTPRequest);
- iq.target=p_for;
- iq.queue_id=++last_queue_id;
- iq.active=false;
+ iq.target = p_for;
+ iq.queue_id = ++last_queue_id;
+ iq.active = false;
- iq.request->connect("request_completed",this,"_image_request_completed",varray(iq.queue_id));
+ iq.request->connect("request_completed", this, "_image_request_completed", varray(iq.queue_id));
- image_queue[iq.queue_id]=iq;
+ image_queue[iq.queue_id] = iq;
add_child(iq.request);
_image_update(true, false, PoolByteArray(), iq.queue_id);
_update_image_queue();
-
-
}
void EditorAssetLibrary::_repository_changed(int p_repository_id) {
- host=repository->get_item_metadata(p_repository_id);
+ host = repository->get_item_metadata(p_repository_id);
print_line(".." + host);
- if(templates_only) {
+ if (templates_only) {
_api_request("configure", REQUESTING_CONFIG, "?type=project");
} else {
_api_request("configure", REQUESTING_CONFIG);
@@ -884,121 +844,119 @@ void EditorAssetLibrary::_search(int p_page) {
String args;
- if(templates_only) {
+ if (templates_only) {
args += "?type=project&";
} else {
args += "?";
}
- args+=String()+"sort="+sort_key[sort->get_selected()];
+ args += String() + "sort=" + sort_key[sort->get_selected()];
-
String support_list;
- for(int i = 0; i < SUPPORT_MAX; i++) {
- if(support->get_popup()->is_item_checked(i)) {
+ for (int i = 0; i < SUPPORT_MAX; i++) {
+ if (support->get_popup()->is_item_checked(i)) {
support_list += String(support_key[i]) + "+";
}
}
- if(support_list != String()) {
+ if (support_list != String()) {
args += "&support=" + support_list.substr(0, support_list.length() - 1);
}
- if (categories->get_selected()>0) {
+ if (categories->get_selected() > 0) {
- args+="&category="+itos(categories->get_item_metadata(categories->get_selected()));
+ args += "&category=" + itos(categories->get_item_metadata(categories->get_selected()));
}
-
+
if (reverse->is_pressed()) {
- args+="&reverse=true";
+ args += "&reverse=true";
}
-
- if (filter->get_text()!=String()) {
- args+="&filter="+filter->get_text().http_escape();
+
+ if (filter->get_text() != String()) {
+ args += "&filter=" + filter->get_text().http_escape();
}
- if (p_page>0) {
- args+="&page="+itos(p_page);
+ if (p_page > 0) {
+ args += "&page=" + itos(p_page);
}
- _api_request("asset",REQUESTING_SEARCH,args);
+ _api_request("asset", REQUESTING_SEARCH, args);
}
-HBoxContainer* EditorAssetLibrary::_make_pages(int p_page,int p_page_count,int p_page_len,int p_total_items,int p_current_items) {
+HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int p_page_len, int p_total_items, int p_current_items) {
- HBoxContainer * hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
//do the mario
- int from = p_page-5;
- if (from<0)
- from=0;
- int to = from+10;
- if (to>p_page_count)
- to=p_page_count;
+ int from = p_page - 5;
+ if (from < 0)
+ from = 0;
+ int to = from + 10;
+ if (to > p_page_count)
+ to = p_page_count;
- Color gray = Color(0.65,0.65,0.65);
+ Color gray = Color(0.65, 0.65, 0.65);
hbc->add_spacer();
- hbc->add_constant_override("separation",10);
+ hbc->add_constant_override("separation", 10);
- if(p_page != 0) {
- LinkButton *first = memnew( LinkButton );
+ if (p_page != 0) {
+ LinkButton *first = memnew(LinkButton);
first->set_text("first");
- first->add_color_override("font_color", gray );
+ first->add_color_override("font_color", gray);
first->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
- first->connect("pressed",this,"_search",varray(0));
+ first->connect("pressed", this, "_search", varray(0));
hbc->add_child(first);
}
- if (p_page>0) {
- LinkButton *prev = memnew( LinkButton );
+ if (p_page > 0) {
+ LinkButton *prev = memnew(LinkButton);
prev->set_text("prev");
- prev->add_color_override("font_color", gray );
+ prev->add_color_override("font_color", gray);
prev->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
- prev->connect("pressed",this,"_search",varray(p_page-1));
+ prev->connect("pressed", this, "_search", varray(p_page - 1));
hbc->add_child(prev);
}
- for(int i=from;i<to;i++) {
+ for (int i = from; i < to; i++) {
- if (i==p_page) {
+ if (i == p_page) {
Label *current = memnew(Label);
- current->set_text(itos(i+1));
+ current->set_text(itos(i + 1));
hbc->add_child(current);
} else {
- LinkButton *current = memnew( LinkButton );
- current->add_color_override("font_color", gray );
+ LinkButton *current = memnew(LinkButton);
+ current->add_color_override("font_color", gray);
current->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
- current->set_text(itos(i+1));
- current->connect("pressed",this,"_search",varray(i));
+ current->set_text(itos(i + 1));
+ current->connect("pressed", this, "_search", varray(i));
hbc->add_child(current);
-
}
}
- if (p_page<p_page_count-1) {
- LinkButton *next = memnew( LinkButton );
+ if (p_page < p_page_count - 1) {
+ LinkButton *next = memnew(LinkButton);
next->set_text("next");
- next->add_color_override("font_color", gray );
+ next->add_color_override("font_color", gray);
next->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
- next->connect("pressed",this,"_search",varray(p_page+1));
+ next->connect("pressed", this, "_search", varray(p_page + 1));
hbc->add_child(next);
}
- if(p_page != p_page_count-1) {
- LinkButton *last = memnew( LinkButton );
+ if (p_page != p_page_count - 1) {
+ LinkButton *last = memnew(LinkButton);
last->set_text("last");
- last->add_color_override("font_color", gray );
+ last->add_color_override("font_color", gray);
last->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
hbc->add_child(last);
- last->connect("pressed",this,"_search",varray(p_page_count-1));
+ last->connect("pressed", this, "_search", varray(p_page_count - 1));
}
- Label *totals = memnew( Label );
- totals->set_text("( "+itos(from*p_page_len)+" - "+itos(from*p_page_len+p_current_items-1)+" / "+itos(p_total_items)+" )");
+ Label *totals = memnew(Label);
+ totals->set_text("( " + itos(from * p_page_len) + " - " + itos(from * p_page_len + p_current_items - 1) + " / " + itos(p_total_items) + " )");
hbc->add_child(totals);
hbc->add_spacer();
@@ -1006,38 +964,34 @@ HBoxContainer* EditorAssetLibrary::_make_pages(int p_page,int p_page_count,int p
return hbc;
}
+void EditorAssetLibrary::_api_request(const String &p_request, RequestType p_request_type, const String &p_arguments) {
-void EditorAssetLibrary::_api_request(const String& p_request, RequestType p_request_type, const String& p_arguments) {
-
- if (requesting!=REQUESTING_NONE) {
+ if (requesting != REQUESTING_NONE) {
request->cancel_request();
}
- requesting=p_request_type;
+ requesting = p_request_type;
error_hb->hide();
- request->request(host+"/"+p_request+p_arguments);
+ request->request(host + "/" + p_request + p_arguments);
}
-
-
-void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const PoolStringArray& headers, const PoolByteArray& p_data) {
-
+void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data) {
String str;
{
- int datalen=p_data.size();
+ int datalen = p_data.size();
PoolByteArray::Read r = p_data.read();
- str.parse_utf8((const char*)r.ptr(),datalen);
+ str.parse_utf8((const char *)r.ptr(), datalen);
}
- bool error_abort=true;
+ bool error_abort = true;
- switch(p_status) {
+ switch (p_status) {
case HTTPRequest::RESULT_CANT_RESOLVE: {
- error_label->set_text("Can't resolve hostname: "+host);
+ error_label->set_text("Can't resolve hostname: " + host);
} break;
case HTTPRequest::RESULT_BODY_SIZE_LIMIT_EXCEEDED:
case HTTPRequest::RESULT_CONNECTION_ERROR:
@@ -1046,68 +1000,65 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
} break;
case HTTPRequest::RESULT_SSL_HANDSHAKE_ERROR:
case HTTPRequest::RESULT_CANT_CONNECT: {
- error_label->set_text("Can't connect to host: "+host);
+ error_label->set_text("Can't connect to host: " + host);
} break;
case HTTPRequest::RESULT_NO_RESPONSE: {
- error_label->set_text("No response from host: "+host);
+ error_label->set_text("No response from host: " + host);
} break;
case HTTPRequest::RESULT_REQUEST_FAILED: {
- error_label->set_text("Request failed, return code: "+itos(p_code));
+ error_label->set_text("Request failed, return code: " + itos(p_code));
} break;
case HTTPRequest::RESULT_REDIRECT_LIMIT_REACHED: {
error_label->set_text("Request failed, too many redirects");
} break;
default: {
- if (p_code!=200) {
- error_label->set_text("Request failed, return code: "+itos(p_code));
+ if (p_code != 200) {
+ error_label->set_text("Request failed, return code: " + itos(p_code));
} else {
- error_abort=false;
+ error_abort = false;
}
} break;
-
}
-
if (error_abort) {
error_hb->show();
return;
}
- print_line("response: "+itos(p_status)+" code: "+itos(p_code));
+ print_line("response: " + itos(p_status) + " code: " + itos(p_code));
Dictionary d;
{
Variant js;
String errs;
int errl;
- JSON::parse(str,js,errs,errl);
- d=js;
+ JSON::parse(str, js, errs, errl);
+ d = js;
}
-
print_line(Variant(d).get_construct_string());
RequestType requested = requesting;
- requesting=REQUESTING_NONE;
+ requesting = REQUESTING_NONE;
- switch(requested) {
+ switch (requested) {
case REQUESTING_CONFIG: {
categories->clear();
categories->add_item("All");
- categories->set_item_metadata(0,0);
+ categories->set_item_metadata(0, 0);
if (d.has("categories")) {
Array clist = d["categories"];
- for(int i=0;i<clist.size();i++) {
+ for (int i = 0; i < clist.size(); i++) {
Dictionary cat = clist[i];
if (!cat.has("name") || !cat.has("id"))
continue;
- String name=cat["name"];
- int id=cat["id"];
+ String name = cat["name"];
+ int id = cat["id"];
categories->add_item(name);
- categories->set_item_metadata( categories->get_item_count() -1, id);
+ categories->set_item_metadata(categories->get_item_count() - 1, id);
category_map[cat["id"]] = name;
}
}
@@ -1127,43 +1078,42 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
memdelete(asset_bottom_page);
}
- int page=0;
- int pages=1;
- int page_len=10;
- int total_items=1;
+ int page = 0;
+ int pages = 1;
+ int page_len = 10;
+ int total_items = 1;
Array result;
-
if (d.has("page")) {
- page=d["page"];
+ page = d["page"];
}
if (d.has("pages")) {
- pages=d["pages"];
+ pages = d["pages"];
}
if (d.has("page_length")) {
- page_len=d["page_length"];
+ page_len = d["page_length"];
}
if (d.has("total")) {
- total_items=d["total"];
+ total_items = d["total"];
}
if (d.has("result")) {
- result=d["result"];
+ result = d["result"];
}
- asset_top_page = _make_pages(page,pages,page_len,total_items,result.size());
+ asset_top_page = _make_pages(page, pages, page_len, total_items, result.size());
library_vb->add_child(asset_top_page);
- asset_items = memnew( GridContainer );
+ asset_items = memnew(GridContainer);
asset_items->set_columns(2);
- asset_items->add_constant_override("hseparation",10);
- asset_items->add_constant_override("vseparation",10);
+ asset_items->add_constant_override("hseparation", 10);
+ asset_items->add_constant_override("vseparation", 10);
library_vb->add_child(asset_items);
- asset_bottom_page = _make_pages(page,pages,page_len,total_items,result.size());
+ asset_bottom_page = _make_pages(page, pages, page_len, total_items, result.size());
library_vb->add_child(asset_bottom_page);
- for(int i=0;i<result.size();i++) {
+ for (int i = 0; i < result.size(); i++) {
Dictionary r = result[i];
@@ -1176,16 +1126,15 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
ERR_CONTINUE(!r.has("rating"));
ERR_CONTINUE(!r.has("cost"));
-
- EditorAssetLibraryItem *item = memnew( EditorAssetLibraryItem );
+ EditorAssetLibraryItem *item = memnew(EditorAssetLibraryItem);
asset_items->add_child(item);
- item->configure(r["title"],r["asset_id"],category_map[r["category_id"]],r["category_id"],r["author"],r["author_id"],r["rating"],r["cost"]);
- item->connect("asset_selected",this,"_select_asset");
- item->connect("author_selected",this,"_select_author");
- item->connect("category_selected",this,"_select_category");
+ item->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["rating"], r["cost"]);
+ item->connect("asset_selected", this, "_select_asset");
+ item->connect("author_selected", this, "_select_author");
+ item->connect("category_selected", this, "_select_category");
- if(r.has("icon_url") && r["icon_url"] != "") {
- _request_image(item->get_instance_ID(),r["icon_url"],IMAGE_QUEUE_ICON,0);
+ if (r.has("icon_url") && r["icon_url"] != "") {
+ _request_image(item->get_instance_ID(), r["icon_url"], IMAGE_QUEUE_ICON, 0);
}
}
} break;
@@ -1211,69 +1160,63 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
memdelete(description);
}
- description = memnew( EditorAssetLibraryItemDescription );
+ description = memnew(EditorAssetLibraryItemDescription);
add_child(description);
description->popup_centered_minsize();
- description->connect("confirmed",this,"_install_asset");
+ description->connect("confirmed", this, "_install_asset");
- description->configure(r["title"],r["asset_id"],category_map[r["category_id"]],r["category_id"],r["author"],r["author_id"],r["rating"],r["cost"],r["version"],r["version_string"],r["description"],r["download_url"],r["browse_url"], r["download_hash"]);
+ description->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["rating"], r["cost"], r["version"], r["version_string"], r["description"], r["download_url"], r["browse_url"], r["download_hash"]);
/*item->connect("asset_selected",this,"_select_asset");
item->connect("author_selected",this,"_select_author");
item->connect("category_selected",this,"_category_selected");*/
- if(r.has("icon_url") && r["icon_url"] != "") {
- _request_image(description->get_instance_ID(),r["icon_url"],IMAGE_QUEUE_ICON,0);
+ if (r.has("icon_url") && r["icon_url"] != "") {
+ _request_image(description->get_instance_ID(), r["icon_url"], IMAGE_QUEUE_ICON, 0);
}
if (d.has("previews")) {
Array previews = d["previews"];
- for(int i=0;i<previews.size();i++) {
+ for (int i = 0; i < previews.size(); i++) {
-
- Dictionary p=previews[i];
+ Dictionary p = previews[i];
ERR_CONTINUE(!p.has("type"));
ERR_CONTINUE(!p.has("link"));
- bool is_video=p.has("type") && String(p["type"])=="video";
+ bool is_video = p.has("type") && String(p["type"]) == "video";
String video_url;
if (is_video && p.has("link")) {
- video_url=p["link"];
+ video_url = p["link"];
}
- description->add_preview(i,is_video,video_url);
+ description->add_preview(i, is_video, video_url);
- if(p.has("thumbnail")) {
- _request_image(description->get_instance_ID(),p["thumbnail"],IMAGE_QUEUE_THUMBNAIL,i);
+ if (p.has("thumbnail")) {
+ _request_image(description->get_instance_ID(), p["thumbnail"], IMAGE_QUEUE_THUMBNAIL, i);
}
- if(is_video) {
+ if (is_video) {
//_request_image(description->get_instance_ID(),p["link"],IMAGE_QUEUE_SCREENSHOT,i);
} else {
- _request_image(description->get_instance_ID(),p["link"],IMAGE_QUEUE_SCREENSHOT,i);
+ _request_image(description->get_instance_ID(), p["link"], IMAGE_QUEUE_SCREENSHOT, i);
}
-
}
}
} break;
default: break;
}
-
}
-
-void EditorAssetLibrary::_asset_file_selected(const String& p_file) {
+void EditorAssetLibrary::_asset_file_selected(const String &p_file) {
if (asset_installer) {
- memdelete( asset_installer );
- asset_installer=NULL;
+ memdelete(asset_installer);
+ asset_installer = NULL;
}
- asset_installer = memnew( EditorAssetInstaller );
+ asset_installer = memnew(EditorAssetInstaller);
add_child(asset_installer);
asset_installer->open(p_file);
-
-
}
void EditorAssetLibrary::_asset_open() {
@@ -1287,94 +1230,86 @@ void EditorAssetLibrary::_manage_plugins() {
ProjectSettings::get_singleton()->set_plugins_page();
}
+void EditorAssetLibrary::_install_external_asset(String p_zip_path, String p_title) {
-
-void EditorAssetLibrary::_install_external_asset(String p_zip_path,String p_title) {
-
- emit_signal("install_asset",p_zip_path,p_title);
+ emit_signal("install_asset", p_zip_path, p_title);
}
void EditorAssetLibrary::_bind_methods() {
- ClassDB::bind_method("_http_request_completed",&EditorAssetLibrary::_http_request_completed);
- ClassDB::bind_method("_select_asset",&EditorAssetLibrary::_select_asset);
- ClassDB::bind_method("_select_author",&EditorAssetLibrary::_select_author);
- ClassDB::bind_method("_select_category",&EditorAssetLibrary::_select_category);
- ClassDB::bind_method("_image_request_completed",&EditorAssetLibrary::_image_request_completed);
- ClassDB::bind_method("_search",&EditorAssetLibrary::_search,DEFVAL(0));
- ClassDB::bind_method("_install_asset",&EditorAssetLibrary::_install_asset);
- ClassDB::bind_method("_manage_plugins",&EditorAssetLibrary::_manage_plugins);
- ClassDB::bind_method("_asset_open",&EditorAssetLibrary::_asset_open);
- ClassDB::bind_method("_asset_file_selected",&EditorAssetLibrary::_asset_file_selected);
- ClassDB::bind_method("_repository_changed",&EditorAssetLibrary::_repository_changed);
- ClassDB::bind_method("_support_toggled",&EditorAssetLibrary::_support_toggled);
- ClassDB::bind_method("_rerun_search",&EditorAssetLibrary::_rerun_search);
- ClassDB::bind_method("_install_external_asset",&EditorAssetLibrary::_install_external_asset);
-
-
-
- ADD_SIGNAL(MethodInfo("install_asset",PropertyInfo(Variant::STRING,"zip_path"),PropertyInfo(Variant::STRING,"name")));
-
+ ClassDB::bind_method("_http_request_completed", &EditorAssetLibrary::_http_request_completed);
+ ClassDB::bind_method("_select_asset", &EditorAssetLibrary::_select_asset);
+ ClassDB::bind_method("_select_author", &EditorAssetLibrary::_select_author);
+ ClassDB::bind_method("_select_category", &EditorAssetLibrary::_select_category);
+ ClassDB::bind_method("_image_request_completed", &EditorAssetLibrary::_image_request_completed);
+ ClassDB::bind_method("_search", &EditorAssetLibrary::_search, DEFVAL(0));
+ ClassDB::bind_method("_install_asset", &EditorAssetLibrary::_install_asset);
+ ClassDB::bind_method("_manage_plugins", &EditorAssetLibrary::_manage_plugins);
+ ClassDB::bind_method("_asset_open", &EditorAssetLibrary::_asset_open);
+ ClassDB::bind_method("_asset_file_selected", &EditorAssetLibrary::_asset_file_selected);
+ ClassDB::bind_method("_repository_changed", &EditorAssetLibrary::_repository_changed);
+ ClassDB::bind_method("_support_toggled", &EditorAssetLibrary::_support_toggled);
+ ClassDB::bind_method("_rerun_search", &EditorAssetLibrary::_rerun_search);
+ ClassDB::bind_method("_install_external_asset", &EditorAssetLibrary::_install_external_asset);
+
+ ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name")));
}
EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
- templates_only=p_templates_only;
+ templates_only = p_templates_only;
Ref<StyleBoxEmpty> border;
border.instance();
- border->set_default_margin(MARGIN_LEFT,15);
- border->set_default_margin(MARGIN_RIGHT,15);
- border->set_default_margin(MARGIN_BOTTOM,5);
- border->set_default_margin(MARGIN_TOP,5);
+ border->set_default_margin(MARGIN_LEFT, 15);
+ border->set_default_margin(MARGIN_RIGHT, 15);
+ border->set_default_margin(MARGIN_BOTTOM, 5);
+ border->set_default_margin(MARGIN_TOP, 5);
- add_style_override("panel",border);
+ add_style_override("panel", border);
- VBoxContainer *library_main = memnew( VBoxContainer );
+ VBoxContainer *library_main = memnew(VBoxContainer);
add_child(library_main);
- HBoxContainer *search_hb = memnew( HBoxContainer );
+ HBoxContainer *search_hb = memnew(HBoxContainer);
library_main->add_child(search_hb);
- library_main->add_constant_override("separation",10);
-
-
+ library_main->add_constant_override("separation", 10);
- search_hb->add_child( memnew( Label(TTR("Search:")+" ")));
- filter =memnew( LineEdit );
+ search_hb->add_child(memnew(Label(TTR("Search:") + " ")));
+ filter = memnew(LineEdit);
search_hb->add_child(filter);
filter->set_h_size_flags(SIZE_EXPAND_FILL);
- filter->connect("text_entered",this,"_search");
- search = memnew( Button("Search"));
- search->connect("pressed",this,"_search");
+ filter->connect("text_entered", this, "_search");
+ search = memnew(Button("Search"));
+ search->connect("pressed", this, "_search");
search_hb->add_child(search);
if (!p_templates_only)
- search_hb->add_child(memnew( VSeparator ));
+ search_hb->add_child(memnew(VSeparator));
- Button * open_asset = memnew( Button );
+ Button *open_asset = memnew(Button);
open_asset->set_text("Import");
search_hb->add_child(open_asset);
- open_asset->connect("pressed",this,"_asset_open");
+ open_asset->connect("pressed", this, "_asset_open");
- Button * plugins = memnew( Button );
+ Button *plugins = memnew(Button);
plugins->set_text("Plugins");
search_hb->add_child(plugins);
- plugins->connect("pressed",this,"_manage_plugins");
+ plugins->connect("pressed", this, "_manage_plugins");
if (p_templates_only) {
open_asset->hide();
plugins->hide();
}
-
- HBoxContainer *search_hb2 = memnew( HBoxContainer );
+ HBoxContainer *search_hb2 = memnew(HBoxContainer);
library_main->add_child(search_hb2);
- search_hb2->add_child( memnew( Label(TTR("Sort:")+" ")));
- sort = memnew( OptionButton );
- for(int i=0;i<SORT_MAX;i++) {
+ search_hb2->add_child(memnew(Label(TTR("Sort:") + " ")));
+ sort = memnew(OptionButton);
+ for (int i = 0; i < SORT_MAX; i++) {
sort->add_item(sort_text[i]);
}
@@ -1383,7 +1318,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
sort->set_h_size_flags(SIZE_EXPAND_FILL);
sort->connect("item_selected", this, "_rerun_search");
- reverse = memnew( ToolButton );
+ reverse = memnew(ToolButton);
reverse->set_toggle_mode(true);
reverse->connect("toggled", this, "_rerun_search");
//reverse->set_text(TTR("Reverse"));
@@ -1393,8 +1328,8 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
//search_hb2->add_spacer();
- search_hb2->add_child( memnew( Label(TTR("Category:")+" ")));
- categories = memnew( OptionButton );
+ search_hb2->add_child(memnew(Label(TTR("Category:") + " ")));
+ categories = memnew(OptionButton);
categories->add_item(TTR("All"));
search_hb2->add_child(categories);
categories->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -1403,128 +1338,120 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search_hb2->add_child(memnew(VSeparator));
- search_hb2->add_child( memnew( Label(TTR("Site:")+" ")));
- repository = memnew( OptionButton );
+ search_hb2->add_child(memnew(Label(TTR("Site:") + " ")));
+ repository = memnew(OptionButton);
repository->add_item("Godot");
repository->set_item_metadata(0, "https://godotengine.org/asset-library/api");
repository->add_item("Localhost"); // TODO: Maybe remove?
repository->set_item_metadata(1, "http://127.0.0.1/asset-library/api");
- repository->connect("item_selected",this,"_repository_changed");
+ repository->connect("item_selected", this, "_repository_changed");
search_hb2->add_child(repository);
repository->set_h_size_flags(SIZE_EXPAND_FILL);
-
search_hb2->add_child(memnew(VSeparator));
- support = memnew( MenuButton );
+ support = memnew(MenuButton);
search_hb2->add_child(support);
support->set_text(TTR("Support.."));
- support->get_popup()->add_check_item(TTR("Official"),SUPPORT_OFFICIAL);
- support->get_popup()->add_check_item(TTR("Community"),SUPPORT_COMMUNITY);
- support->get_popup()->add_check_item(TTR("Testing"),SUPPORT_TESTING);
- support->get_popup()->set_item_checked(SUPPORT_OFFICIAL,true);
- support->get_popup()->set_item_checked(SUPPORT_COMMUNITY,true);
- support->get_popup()->connect("id_pressed",this,"_support_toggled");
+ support->get_popup()->add_check_item(TTR("Official"), SUPPORT_OFFICIAL);
+ support->get_popup()->add_check_item(TTR("Community"), SUPPORT_COMMUNITY);
+ support->get_popup()->add_check_item(TTR("Testing"), SUPPORT_TESTING);
+ support->get_popup()->set_item_checked(SUPPORT_OFFICIAL, true);
+ support->get_popup()->set_item_checked(SUPPORT_COMMUNITY, true);
+ support->get_popup()->connect("id_pressed", this, "_support_toggled");
/////////
- PanelContainer * library_scroll_bg = memnew( PanelContainer );
+ PanelContainer *library_scroll_bg = memnew(PanelContainer);
library_main->add_child(library_scroll_bg);
- library_scroll_bg->add_style_override("panel",get_stylebox("normal","TextEdit"));
+ library_scroll_bg->add_style_override("panel", get_stylebox("normal", "TextEdit"));
library_scroll_bg->set_v_size_flags(SIZE_EXPAND_FILL);
- library_scroll = memnew( ScrollContainer );
+ library_scroll = memnew(ScrollContainer);
library_scroll->set_enable_v_scroll(true);
library_scroll->set_enable_h_scroll(false);
library_scroll_bg->add_child(library_scroll);
-
Ref<StyleBoxEmpty> border2;
border2.instance();
- border2->set_default_margin(MARGIN_LEFT,15);
- border2->set_default_margin(MARGIN_RIGHT,35);
- border2->set_default_margin(MARGIN_BOTTOM,15);
- border2->set_default_margin(MARGIN_TOP,15);
+ border2->set_default_margin(MARGIN_LEFT, 15);
+ border2->set_default_margin(MARGIN_RIGHT, 35);
+ border2->set_default_margin(MARGIN_BOTTOM, 15);
+ border2->set_default_margin(MARGIN_TOP, 15);
-
- PanelContainer * library_vb_border = memnew( PanelContainer );
+ PanelContainer *library_vb_border = memnew(PanelContainer);
library_scroll->add_child(library_vb_border);
- library_vb_border->add_style_override("panel",border2);
+ library_vb_border->add_style_override("panel", border2);
library_vb_border->set_h_size_flags(SIZE_EXPAND_FILL);
library_vb_border->set_mouse_filter(MOUSE_FILTER_PASS);
-
-
- library_vb = memnew( VBoxContainer );
+ library_vb = memnew(VBoxContainer);
library_vb->set_h_size_flags(SIZE_EXPAND_FILL);
library_vb_border->add_child(library_vb);
//margin_panel->set_stop_mouse(false);
- asset_top_page = memnew( HBoxContainer );
+ asset_top_page = memnew(HBoxContainer);
library_vb->add_child(asset_top_page);
- asset_items = memnew( GridContainer );
+ asset_items = memnew(GridContainer);
asset_items->set_columns(2);
- asset_items->add_constant_override("hseparation",10);
- asset_items->add_constant_override("vseparation",10);
+ asset_items->add_constant_override("hseparation", 10);
+ asset_items->add_constant_override("vseparation", 10);
library_vb->add_child(asset_items);
- asset_bottom_page = memnew( HBoxContainer );
+ asset_bottom_page = memnew(HBoxContainer);
library_vb->add_child(asset_bottom_page);
- request = memnew( HTTPRequest );
+ request = memnew(HTTPRequest);
add_child(request);
- request->set_use_threads(EDITOR_DEF("asset_library/use_threads",true));
- request->connect("request_completed",this,"_http_request_completed");
+ request->set_use_threads(EDITOR_DEF("asset_library/use_threads", true));
+ request->connect("request_completed", this, "_http_request_completed");
- last_queue_id=0;
+ last_queue_id = 0;
- library_vb->add_constant_override("separation",20);
+ library_vb->add_constant_override("separation", 20);
- load_status = memnew( ProgressBar );
+ load_status = memnew(ProgressBar);
load_status->set_min(0);
load_status->set_max(1);
load_status->set_step(0.001);
library_main->add_child(load_status);
- error_hb = memnew( HBoxContainer );
+ error_hb = memnew(HBoxContainer);
library_main->add_child(error_hb);
- error_label = memnew( Label );
- error_label->add_color_override("color",Color(1,0.4,0.3));
+ error_label = memnew(Label);
+ error_label->add_color_override("color", Color(1, 0.4, 0.3));
error_hb->add_child(error_label);
description = NULL;
set_process(true);
- downloads_scroll = memnew( ScrollContainer );
+ downloads_scroll = memnew(ScrollContainer);
downloads_scroll->set_enable_h_scroll(true);
downloads_scroll->set_enable_v_scroll(false);
library_main->add_child(downloads_scroll);
- downloads_hb = memnew( HBoxContainer );
+ downloads_hb = memnew(HBoxContainer);
downloads_scroll->add_child(downloads_hb);
- asset_open = memnew( EditorFileDialog );
+ asset_open = memnew(EditorFileDialog);
asset_open->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
- asset_open->add_filter("*.zip ; "+TTR("Assets ZIP File"));
+ asset_open->add_filter("*.zip ; " + TTR("Assets ZIP File"));
asset_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
add_child(asset_open);
- asset_open->connect("file_selected",this,"_asset_file_selected");
-
- asset_installer=NULL;
+ asset_open->connect("file_selected", this, "_asset_file_selected");
+ asset_installer = NULL;
}
-
///////
-
void AssetLibraryEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
@@ -1534,20 +1461,17 @@ void AssetLibraryEditorPlugin::make_visible(bool p_visible) {
addon_library->hide();
}
-
}
AssetLibraryEditorPlugin::AssetLibraryEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- addon_library = memnew( EditorAssetLibrary );
+ editor = p_node;
+ addon_library = memnew(EditorAssetLibrary);
addon_library->set_v_size_flags(Control::SIZE_EXPAND_FILL);
editor->get_viewport()->add_child(addon_library);
addon_library->set_area_as_parent_rect();
addon_library->hide();
-
}
AssetLibraryEditorPlugin::~AssetLibraryEditorPlugin() {
-
}
diff --git a/editor/asset_library_editor_plugin.h b/editor/asset_library_editor_plugin.h
index 0598ea90ea..bdfd52cf4f 100644
--- a/editor/asset_library_editor_plugin.h
+++ b/editor/asset_library_editor_plugin.h
@@ -29,63 +29,57 @@
#ifndef ASSET_LIBRARY_EDITOR_PLUGIN_H
#define ASSET_LIBRARY_EDITOR_PLUGIN_H
-
#include "editor_plugin.h"
#include "scene/gui/box_container.h"
+#include "scene/gui/check_box.h"
#include "scene/gui/line_edit.h"
+#include "scene/gui/link_button.h"
#include "scene/gui/option_button.h"
-#include "scene/gui/tab_container.h"
#include "scene/gui/panel_container.h"
-#include "scene/gui/link_button.h"
-#include "scene/gui/check_box.h"
#include "scene/gui/progress_bar.h"
#include "scene/gui/separator.h"
+#include "scene/gui/tab_container.h"
+#include "editor_plugin_settings.h"
#include "scene/gui/grid_container.h"
+#include "scene/gui/rich_text_label.h"
#include "scene/gui/scroll_container.h"
#include "scene/gui/texture_button.h"
-#include "scene/gui/rich_text_label.h"
-#include "editor_plugin_settings.h"
-#include "scene/main/http_request.h"
#include "editor_asset_installer.h"
+#include "scene/main/http_request.h"
class EditorAssetLibraryItem : public PanelContainer {
- GDCLASS( EditorAssetLibraryItem, PanelContainer );
+ GDCLASS(EditorAssetLibraryItem, PanelContainer);
TextureButton *icon;
- LinkButton* title;
- LinkButton* category;
- LinkButton* author;
+ LinkButton *title;
+ LinkButton *category;
+ LinkButton *author;
TextureRect *stars[5];
- Label* price;
+ Label *price;
int asset_id;
int category_id;
int author_id;
-
void _asset_clicked();
void _category_clicked();
void _author_clicked();
-
- void set_image(int p_type,int p_index,const Ref<Texture>& p_image);
+ void set_image(int p_type, int p_index, const Ref<Texture> &p_image);
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
-
- void configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost);
+public:
+ void configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost);
EditorAssetLibraryItem();
};
-
class EditorAssetLibraryItemDescription : public ConfirmationDialog {
GDCLASS(EditorAssetLibraryItemDescription, ConfirmationDialog);
@@ -106,7 +100,7 @@ class EditorAssetLibraryItemDescription : public ConfirmationDialog {
Vector<Preview> preview_images;
TextureRect *preview;
- void set_image(int p_type,int p_index,const Ref<Texture>& p_image);
+ void set_image(int p_type, int p_index, const Ref<Texture> &p_image);
int asset_id;
String download_url;
@@ -114,15 +108,15 @@ class EditorAssetLibraryItemDescription : public ConfirmationDialog {
String sha256;
Ref<Texture> icon;
- void _link_click(const String& p_url);
+ void _link_click(const String &p_url);
void _preview_click(int p_index);
-protected:
+protected:
static void _bind_methods();
-public:
- void configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost,int p_version,const String& p_version_string,const String& p_description,const String& p_download_url,const String& p_browse_url,const String& p_sha256_hash);
- void add_preview(int p_id, bool p_video,const String& p_url);
+public:
+ void configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash);
+ void add_preview(int p_id, bool p_video, const String &p_url);
String get_title() { return title; }
Ref<Texture> get_preview_icon() { return icon; }
@@ -130,16 +124,14 @@ public:
int get_asset_id() { return asset_id; }
String get_sha256() { return sha256; }
EditorAssetLibraryItemDescription();
-
};
class EditorAssetLibraryItemDownload : public PanelContainer {
GDCLASS(EditorAssetLibraryItemDownload, PanelContainer);
-
TextureRect *icon;
- Label* title;
+ Label *title;
ProgressBar *progress;
Button *install;
Button *retry;
@@ -162,33 +154,29 @@ class EditorAssetLibraryItemDownload : public PanelContainer {
void _close();
void _install();
void _make_request();
- void _http_download_completed(int p_status, int p_code, const PoolStringArray& headers, const PoolByteArray& p_data);
+ void _http_download_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_external_install(bool p_enable) { external_install=p_enable; }
+public:
+ void set_external_install(bool p_enable) { external_install = p_enable; }
int get_asset_id() { return asset_id; }
- void configure(const String& p_title,int p_asset_id,const Ref<Texture>& p_preview, const String& p_download_url, const String& p_sha256_hash);
+ void configure(const String &p_title, int p_asset_id, const Ref<Texture> &p_preview, const String &p_download_url, const String &p_sha256_hash);
EditorAssetLibraryItemDownload();
-
};
class EditorAssetLibrary : public PanelContainer {
- GDCLASS(EditorAssetLibrary,PanelContainer);
+ GDCLASS(EditorAssetLibrary, PanelContainer);
String host;
EditorFileDialog *asset_open;
EditorAssetInstaller *asset_installer;
-
void _asset_open();
- void _asset_file_selected(const String& p_file);
-
+ void _asset_file_selected(const String &p_file);
ScrollContainer *library_scroll;
VBoxContainer *library_vb;
@@ -229,11 +217,9 @@ class EditorAssetLibrary : public PanelContainer {
SORT_MAX
};
-
- static const char* sort_key[SORT_MAX];
- static const char* sort_text[SORT_MAX];
- static const char* support_key[SUPPORT_MAX];
-
+ static const char *sort_key[SORT_MAX];
+ static const char *sort_text[SORT_MAX];
+ static const char *support_key[SUPPORT_MAX];
///MainListing
@@ -257,14 +243,14 @@ class EditorAssetLibrary : public PanelContainer {
};
int last_queue_id;
- Map<int,ImageQueue> image_queue;
+ Map<int, ImageQueue> image_queue;
- void _image_update(bool use_cache, bool final, const PoolByteArray& p_data, int p_queue_id);
- void _image_request_completed(int p_status, int p_code, const PoolStringArray& headers, const PoolByteArray& p_data, int p_queue_id);
- void _request_image(ObjectID p_for,String p_image_url,ImageType p_type,int p_image_index);
+ void _image_update(bool use_cache, bool final, const PoolByteArray &p_data, int p_queue_id);
+ void _image_request_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data, int p_queue_id);
+ void _request_image(ObjectID p_for, String p_image_url, ImageType p_type, int p_image_index);
void _update_image_queue();
- HBoxContainer* _make_pages(int p_page, int p_page_count, int p_page_len, int p_total_items, int p_current_items);
+ HBoxContainer *_make_pages(int p_page, int p_page_count, int p_page_len, int p_total_items, int p_current_items);
//
EditorAssetLibraryItemDescription *description;
@@ -277,16 +263,12 @@ class EditorAssetLibrary : public PanelContainer {
REQUESTING_ASSET,
};
-
RequestType requesting;
Dictionary category_map;
-
ScrollContainer *downloads_scroll;
HBoxContainer *downloads_hb;
-
-
void _install_asset();
void _select_author(int p_id);
@@ -295,36 +277,36 @@ class EditorAssetLibrary : public PanelContainer {
void _manage_plugins();
- void _search(int p_page=0);
+ void _search(int p_page = 0);
void _rerun_search(int p_ignore);
- void _api_request(const String& p_request, RequestType p_request_type, const String &p_arguments="");
- void _http_request_completed(int p_status, int p_code, const PoolStringArray& headers, const PoolByteArray& p_data);
- void _http_download_completed(int p_status, int p_code, const PoolStringArray& headers, const PoolByteArray& p_data);
+ void _api_request(const String &p_request, RequestType p_request_type, const String &p_arguments = "");
+ void _http_request_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
+ void _http_download_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
void _repository_changed(int p_repository_id);
void _support_toggled(int p_support);
- void _install_external_asset(String p_zip_path,String p_title);
+ void _install_external_asset(String p_zip_path, String p_title);
-friend class EditorAssetLibraryItemDescription;
-friend class EditorAssetLibraryItem;
-protected:
+ friend class EditorAssetLibraryItemDescription;
+ friend class EditorAssetLibraryItem;
+protected:
static void _bind_methods();
void _notification(int p_what);
+
public:
- EditorAssetLibrary(bool p_templates_only=false);
+ EditorAssetLibrary(bool p_templates_only = false);
};
class AssetLibraryEditorPlugin : public EditorPlugin {
- GDCLASS( AssetLibraryEditorPlugin, EditorPlugin );
+ GDCLASS(AssetLibraryEditorPlugin, EditorPlugin);
EditorAssetLibrary *addon_library;
EditorNode *editor;
public:
-
virtual String get_name() const { return "AssetLib"; }
bool has_main_screen() const { return true; }
virtual void edit(Object *p_object) {}
@@ -336,7 +318,6 @@ public:
AssetLibraryEditorPlugin(EditorNode *p_node);
~AssetLibraryEditorPlugin();
-
};
#endif // EDITORASSETLIBRARY_H
diff --git a/editor/call_dialog.cpp b/editor/call_dialog.cpp
index 6dfeb87dfd..7a8290c58d 100644
--- a/editor/call_dialog.cpp
+++ b/editor/call_dialog.cpp
@@ -29,9 +29,9 @@
#include "call_dialog.h"
#if 0
-#include "scene/gui/label.h"
#include "class_db.h"
#include "print_string.h"
+#include "scene/gui/label.h"
class CallDialogParams : public Object {
diff --git a/editor/call_dialog.h b/editor/call_dialog.h
index 56fc07c3df..f3dbe6458b 100644
--- a/editor/call_dialog.h
+++ b/editor/call_dialog.h
@@ -29,12 +29,12 @@
#ifndef CALL_DIALOG_H
#define CALL_DIALOG_H
-#include "scene/gui/popup.h"
+#include "editor/property_editor.h"
#include "scene/gui/button.h"
-#include "scene/gui/tree.h"
#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
-#include "editor/property_editor.h"
+#include "scene/gui/popup.h"
+#include "scene/gui/tree.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 8e9925a0d3..c71c2cc608 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -28,35 +28,33 @@
/*************************************************************************/
#include "code_editor.h"
+#include "editor/editor_scale.h"
#include "editor_settings.h"
+#include "os/keyboard.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/separator.h"
#include "scene/resources/dynamic_font.h"
-#include "os/keyboard.h"
-#include "editor/editor_scale.h"
void GotoLineDialog::popup_find_line(TextEdit *p_edit) {
- text_editor=p_edit;
+ text_editor = p_edit;
line->set_text(itos(text_editor->cursor_get_line()));
line->select_all();
- popup_centered(Size2(180,80));
+ popup_centered(Size2(180, 80));
line->grab_focus();
}
-
int GotoLineDialog::get_line() const {
return line->get_text().to_int();
}
-
void GotoLineDialog::ok_pressed() {
- if (get_line()<1 || get_line()>text_editor->get_line_count())
+ if (get_line() < 1 || get_line() > text_editor->get_line_count())
return;
- text_editor->cursor_set_line(get_line()-1);
+ text_editor->cursor_set_line(get_line() - 1);
hide();
}
@@ -65,30 +63,29 @@ GotoLineDialog::GotoLineDialog() {
set_title(TTR("Go to Line"));
Label *l = memnew(Label);
l->set_text(TTR("Line Number:"));
- l->set_pos(Point2(5,5));
+ l->set_pos(Point2(5, 5));
add_child(l);
- line = memnew( LineEdit );
- line->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- line->set_begin( Point2(15,22) );
- line->set_end( Point2(15,35) );
+ line = memnew(LineEdit);
+ line->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ line->set_begin(Point2(15, 22));
+ line->set_end(Point2(15, 35));
add_child(line);
register_text_enter(line);
- text_editor=NULL;
+ text_editor = NULL;
set_hide_on_ok(false);
}
-
void FindReplaceBar::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
find_prev->set_icon(get_icon("MoveUp", "EditorIcons"));
find_next->set_icon(get_icon("MoveDown", "EditorIcons"));
- hide_button->set_normal_texture(get_icon("Close","EditorIcons"));
- hide_button->set_hover_texture(get_icon("CloseHover","EditorIcons"));
- hide_button->set_pressed_texture(get_icon("Close","EditorIcons"));
+ hide_button->set_normal_texture(get_icon("Close", "EditorIcons"));
+ hide_button->set_hover_texture(get_icon("CloseHover", "EditorIcons"));
+ hide_button->set_pressed_texture(get_icon("Close", "EditorIcons"));
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
@@ -100,7 +97,7 @@ void FindReplaceBar::_unhandled_input(const InputEvent &p_event) {
if (p_event.type == InputEvent::KEY) {
- const InputEventKey& k = p_event.key;
+ const InputEventKey &k = p_event.key;
if (k.pressed && (text_edit->has_focus() || text_vbc->is_a_parent_of(get_focus_owner()))) {
@@ -128,30 +125,30 @@ void FindReplaceBar::_unhandled_input(const InputEvent &p_event) {
bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col) {
int line, col;
- String text=get_search_text();
+ String text = get_search_text();
- bool found=text_edit->search(text,p_flags,p_from_line,p_from_col,line,col);
+ bool found = text_edit->search(text, p_flags, p_from_line, p_from_col, line, col);
if (found) {
if (!preserve_cursor) {
text_edit->cursor_set_line(line, false);
- text_edit->cursor_set_column(col+text.length(), false);
+ text_edit->cursor_set_column(col + text.length(), false);
text_edit->center_viewport_to_cursor();
}
text_edit->set_search_text(text);
text_edit->set_search_flags(p_flags);
- text_edit->set_current_search_result(line,col);
+ text_edit->set_current_search_result(line, col);
- result_line=line;
- result_col=col;
+ result_line = line;
+ result_col = col;
set_error("");
} else {
- result_line=-1;
- result_col=-1;
+ result_line = -1;
+ result_col = -1;
text_edit->set_search_text("");
- set_error(text.empty()?"":TTR("No Matches"));
+ set_error(text.empty() ? "" : TTR("No Matches"));
}
return found;
@@ -159,10 +156,10 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col)
void FindReplaceBar::_replace() {
- if (result_line!=-1 && result_col!=-1) {
+ if (result_line != -1 && result_col != -1) {
text_edit->begin_complex_operation();
- text_edit->select(result_line,result_col,result_line,result_col+get_search_text().length());
+ text_edit->select(result_line, result_col, result_line, result_col + get_search_text().length());
text_edit->insert_text_at_cursor(get_replace_text());
text_edit->end_complex_operation();
@@ -174,14 +171,14 @@ void FindReplaceBar::_replace() {
void FindReplaceBar::_replace_all() {
// line as x so it gets priority in comparison, column as y
- Point2i orig_cursor(text_edit->cursor_get_line(),text_edit->cursor_get_column());
- Point2i prev_match=Point2(-1,-1);
+ Point2i orig_cursor(text_edit->cursor_get_line(), text_edit->cursor_get_column());
+ Point2i prev_match = Point2(-1, -1);
bool selection_enabled = text_edit->is_selection_active();
- Point2i selection_begin,selection_end;
+ Point2i selection_begin, selection_end;
if (selection_enabled) {
- selection_begin=Point2i(text_edit->get_selection_from_line(),text_edit->get_selection_from_column());
- selection_end=Point2i(text_edit->get_selection_to_line(),text_edit->get_selection_to_column());
+ selection_begin = Point2i(text_edit->get_selection_from_line(), text_edit->get_selection_from_column());
+ selection_end = Point2i(text_edit->get_selection_to_line(), text_edit->get_selection_to_column());
}
int vsval = text_edit->get_v_scroll();
@@ -189,10 +186,10 @@ void FindReplaceBar::_replace_all() {
text_edit->cursor_set_line(0);
text_edit->cursor_set_column(0);
- String replace_text=get_replace_text();
- int search_text_len=get_search_text().length();
+ String replace_text = get_replace_text();
+ int search_text_len = get_search_text().length();
- int rc=0;
+ int rc = 0;
replace_all_mode = true;
@@ -201,25 +198,25 @@ void FindReplaceBar::_replace_all() {
while (search_next()) {
// replace area
- Point2i match_from(result_line,result_col);
- Point2i match_to(result_line,result_col+search_text_len);
+ Point2i match_from(result_line, result_col);
+ Point2i match_to(result_line, result_col + search_text_len);
if (match_from < prev_match)
break; // done
- prev_match=Point2i(result_line,result_col+replace_text.length());
+ prev_match = Point2i(result_line, result_col + replace_text.length());
- text_edit->select(result_line,result_col,result_line,match_to.y);
+ text_edit->select(result_line, result_col, result_line, match_to.y);
if (selection_enabled && is_selection_only()) {
- if (match_from<selection_begin || match_to>selection_end)
+ if (match_from < selection_begin || match_to > selection_end)
continue;
// replace but adjust selection bounds
text_edit->insert_text_at_cursor(replace_text);
- if (match_to.x==selection_end.x)
- selection_end.y+=replace_text.length()-search_text_len;
+ if (match_to.x == selection_end.x)
+ selection_end.y += replace_text.length() - search_text_len;
} else {
// just replace
text_edit->insert_text_at_cursor(replace_text);
@@ -238,7 +235,7 @@ void FindReplaceBar::_replace_all() {
if (selection_enabled && is_selection_only()) {
// reselect
- text_edit->select(selection_begin.x,selection_begin.y,selection_end.x,selection_end.y);
+ text_edit->select(selection_begin.x, selection_begin.y, selection_end.x, selection_end.y);
} else {
text_edit->deselect();
}
@@ -247,96 +244,96 @@ void FindReplaceBar::_replace_all() {
set_error(vformat(TTR("Replaced %d Ocurrence(s)."), rc));
}
-void FindReplaceBar::_get_search_from(int& r_line, int& r_col) {
+void FindReplaceBar::_get_search_from(int &r_line, int &r_col) {
- r_line=text_edit->cursor_get_line();
- r_col=text_edit->cursor_get_column();
+ r_line = text_edit->cursor_get_line();
+ r_col = text_edit->cursor_get_column();
if (text_edit->is_selection_active() && !replace_all_mode) {
- int selection_line=text_edit->get_selection_from_line();
+ int selection_line = text_edit->get_selection_from_line();
- if (text_edit->get_selection_text()==get_search_text() && r_line==selection_line) {
+ if (text_edit->get_selection_text() == get_search_text() && r_line == selection_line) {
- int selection_from_col=text_edit->get_selection_from_column();
+ int selection_from_col = text_edit->get_selection_from_column();
- if (r_col>=selection_from_col && r_col<=text_edit->get_selection_to_column()) {
- r_col=selection_line;
- r_col=selection_from_col;
+ if (r_col >= selection_from_col && r_col <= text_edit->get_selection_to_column()) {
+ r_col = selection_line;
+ r_col = selection_from_col;
}
}
}
- if (r_line==result_line && r_col>=result_col && r_col<=result_col+get_search_text().length()) {
- r_col=result_col;
+ if (r_line == result_line && r_col >= result_col && r_col <= result_col + get_search_text().length()) {
+ r_col = result_col;
}
}
bool FindReplaceBar::search_current() {
- uint32_t flags=0;
+ uint32_t flags = 0;
if (is_whole_words())
- flags|=TextEdit::SEARCH_WHOLE_WORDS;
+ flags |= TextEdit::SEARCH_WHOLE_WORDS;
if (is_case_sensitive())
- flags|=TextEdit::SEARCH_MATCH_CASE;
+ flags |= TextEdit::SEARCH_MATCH_CASE;
int line, col;
_get_search_from(line, col);
- return _search(flags,line,col);
+ return _search(flags, line, col);
}
bool FindReplaceBar::search_prev() {
- uint32_t flags=0;
+ uint32_t flags = 0;
String text = get_search_text();
if (is_whole_words())
- flags|=TextEdit::SEARCH_WHOLE_WORDS;
+ flags |= TextEdit::SEARCH_WHOLE_WORDS;
if (is_case_sensitive())
- flags|=TextEdit::SEARCH_MATCH_CASE;
+ flags |= TextEdit::SEARCH_MATCH_CASE;
- flags|=TextEdit::SEARCH_BACKWARDS;
+ flags |= TextEdit::SEARCH_BACKWARDS;
int line, col;
_get_search_from(line, col);
- col-=text.length();
- if (col<0) {
- line-=1;
- if (line<0)
- line=text_edit->get_line_count()-1;
- col=text_edit->get_line(line).length();
+ col -= text.length();
+ if (col < 0) {
+ line -= 1;
+ if (line < 0)
+ line = text_edit->get_line_count() - 1;
+ col = text_edit->get_line(line).length();
}
- return _search(flags,line,col);
+ return _search(flags, line, col);
}
bool FindReplaceBar::search_next() {
- uint32_t flags=0;
+ uint32_t flags = 0;
String text = get_search_text();
if (is_whole_words())
- flags|=TextEdit::SEARCH_WHOLE_WORDS;
+ flags |= TextEdit::SEARCH_WHOLE_WORDS;
if (is_case_sensitive())
- flags|=TextEdit::SEARCH_MATCH_CASE;
+ flags |= TextEdit::SEARCH_MATCH_CASE;
int line, col;
_get_search_from(line, col);
- if (line==result_line && col==result_col) {
- col+=text.length();
- if (col>text_edit->get_line(line).length()) {
- line+=1;
- if (line>=text_edit->get_line_count())
- line=0;
- col=0;
+ if (line == result_line && col == result_col) {
+ col += text.length();
+ if (col > text_edit->get_line(line).length()) {
+ line += 1;
+ if (line >= text_edit->get_line_count())
+ line = 0;
+ col = 0;
}
}
- return _search(flags,line,col);
+ return _search(flags, line, col);
}
void FindReplaceBar::_hide_bar() {
@@ -377,15 +374,13 @@ void FindReplaceBar::popup_search() {
void FindReplaceBar::popup_replace() {
-
if (!replace_hbc->is_visible_in_tree() || !replace_options_hbc->is_visible_in_tree()) {
replace_text->clear();
replace_hbc->show();
replace_options_hbc->show();
-
}
- selection_only->set_pressed( (text_edit->is_selection_active() && text_edit->get_selection_from_line() < text_edit->get_selection_to_line()) );
+ selection_only->set_pressed((text_edit->is_selection_active() && text_edit->get_selection_from_line() < text_edit->get_selection_to_line()));
_show_search();
}
@@ -398,23 +393,23 @@ void FindReplaceBar::_search_options_changed(bool p_pressed) {
void FindReplaceBar::_editor_text_changed() {
if (is_visible_in_tree()) {
- preserve_cursor=true;
+ preserve_cursor = true;
search_current();
- preserve_cursor=false;
+ preserve_cursor = false;
}
}
-void FindReplaceBar::_search_text_changed(const String& p_text) {
+void FindReplaceBar::_search_text_changed(const String &p_text) {
search_current();
}
-void FindReplaceBar::_search_text_entered(const String& p_text) {
+void FindReplaceBar::_search_text_entered(const String &p_text) {
search_next();
}
-void FindReplaceBar::_replace_text_entered(const String& p_text) {
+void FindReplaceBar::_replace_text_entered(const String &p_text) {
if (selection_only->is_pressed() && text_edit->is_selection_active()) {
_replace_all();
@@ -455,32 +450,32 @@ void FindReplaceBar::set_error(const String &p_label) {
void FindReplaceBar::set_text_edit(TextEdit *p_text_edit) {
text_edit = p_text_edit;
- text_edit->connect("text_changed",this,"_editor_text_changed");
+ text_edit->connect("text_changed", this, "_editor_text_changed");
}
void FindReplaceBar::_bind_methods() {
- ClassDB::bind_method("_unhandled_input",&FindReplaceBar::_unhandled_input);
+ ClassDB::bind_method("_unhandled_input", &FindReplaceBar::_unhandled_input);
- ClassDB::bind_method("_editor_text_changed",&FindReplaceBar::_editor_text_changed);
- ClassDB::bind_method("_search_text_changed",&FindReplaceBar::_search_text_changed);
- ClassDB::bind_method("_search_text_entered",&FindReplaceBar::_search_text_entered);
- ClassDB::bind_method("_replace_text_entered",&FindReplaceBar::_replace_text_entered);
- ClassDB::bind_method("_search_current",&FindReplaceBar::search_current);
- ClassDB::bind_method("_search_next",&FindReplaceBar::search_next);
- ClassDB::bind_method("_search_prev",&FindReplaceBar::search_prev);
- ClassDB::bind_method("_replace_pressed",&FindReplaceBar::_replace);
- ClassDB::bind_method("_replace_all_pressed",&FindReplaceBar::_replace_all);
- ClassDB::bind_method("_search_options_changed",&FindReplaceBar::_search_options_changed);
- ClassDB::bind_method("_hide_pressed",&FindReplaceBar::_hide_bar);
+ ClassDB::bind_method("_editor_text_changed", &FindReplaceBar::_editor_text_changed);
+ ClassDB::bind_method("_search_text_changed", &FindReplaceBar::_search_text_changed);
+ ClassDB::bind_method("_search_text_entered", &FindReplaceBar::_search_text_entered);
+ ClassDB::bind_method("_replace_text_entered", &FindReplaceBar::_replace_text_entered);
+ ClassDB::bind_method("_search_current", &FindReplaceBar::search_current);
+ ClassDB::bind_method("_search_next", &FindReplaceBar::search_next);
+ ClassDB::bind_method("_search_prev", &FindReplaceBar::search_prev);
+ ClassDB::bind_method("_replace_pressed", &FindReplaceBar::_replace);
+ ClassDB::bind_method("_replace_all_pressed", &FindReplaceBar::_replace_all);
+ ClassDB::bind_method("_search_options_changed", &FindReplaceBar::_search_options_changed);
+ ClassDB::bind_method("_hide_pressed", &FindReplaceBar::_hide_bar);
ADD_SIGNAL(MethodInfo("search"));
}
FindReplaceBar::FindReplaceBar() {
- replace_all_mode=false;
- preserve_cursor=false;
+ replace_all_mode = false;
+ preserve_cursor = false;
text_vbc = memnew(VBoxContainer);
add_child(text_vbc);
@@ -491,18 +486,18 @@ FindReplaceBar::FindReplaceBar() {
search_text = memnew(LineEdit);
search_hbc->add_child(search_text);
search_text->set_custom_minimum_size(Size2(200, 0));
- search_text->connect("text_changed",this,"_search_text_changed");
- search_text->connect("text_entered",this,"_search_text_entered");
+ search_text->connect("text_changed", this, "_search_text_changed");
+ search_text->connect("text_entered", this, "_search_text_entered");
find_prev = memnew(ToolButton);
search_hbc->add_child(find_prev);
find_prev->set_focus_mode(FOCUS_NONE);
- find_prev->connect("pressed",this,"_search_prev");
+ find_prev->connect("pressed", this, "_search_prev");
find_next = memnew(ToolButton);
search_hbc->add_child(find_next);
find_next->set_focus_mode(FOCUS_NONE);
- find_next->connect("pressed",this,"_search_next");
+ find_next->connect("pressed", this, "_search_next");
replace_hbc = memnew(HBoxContainer);
text_vbc->add_child(replace_hbc);
@@ -511,22 +506,21 @@ FindReplaceBar::FindReplaceBar() {
replace_text = memnew(LineEdit);
replace_hbc->add_child(replace_text);
replace_text->set_custom_minimum_size(Size2(200, 0));
- replace_text->connect("text_entered",this,"_replace_text_entered");
-
+ replace_text->connect("text_entered", this, "_replace_text_entered");
replace = memnew(Button);
replace_hbc->add_child(replace);
replace->set_text(TTR("Replace"));
//replace->set_focus_mode(FOCUS_NONE);
- replace->connect("pressed",this,"_replace_pressed");
+ replace->connect("pressed", this, "_replace_pressed");
replace_all = memnew(Button);
replace_hbc->add_child(replace_all);
replace_all->set_text(TTR("Replace All"));
//replace_all->set_focus_mode(FOCUS_NONE);
- replace_all->connect("pressed",this,"_replace_all_pressed");
+ replace_all->connect("pressed", this, "_replace_all_pressed");
- Control *spacer_split = memnew( Control );
+ Control *spacer_split = memnew(Control);
spacer_split->set_custom_minimum_size(Size2(0, 1));
text_vbc->add_child(spacer_split);
@@ -541,18 +535,18 @@ FindReplaceBar::FindReplaceBar() {
search_options->add_child(case_sensitive);
case_sensitive->set_text(TTR("Match Case"));
case_sensitive->set_focus_mode(FOCUS_NONE);
- case_sensitive->connect("toggled",this,"_search_options_changed");
+ case_sensitive->connect("toggled", this, "_search_options_changed");
whole_words = memnew(CheckBox);
search_options->add_child(whole_words);
whole_words->set_text(TTR("Whole Words"));
whole_words->set_focus_mode(FOCUS_NONE);
- whole_words->connect("toggled",this,"_search_options_changed");
+ whole_words->connect("toggled", this, "_search_options_changed");
error_label = memnew(Label);
search_options->add_child(error_label);
- error_label->add_color_override("font_color", Color(1,1,0,1));
- error_label->add_color_override("font_color_shadow", Color(0,0,0,1));
+ error_label->add_color_override("font_color", Color(1, 1, 0, 1));
+ error_label->add_color_override("font_color_shadow", Color(0, 0, 0, 1));
error_label->add_constant_override("shadow_as_outline", 1);
search_options->add_spacer();
@@ -560,7 +554,7 @@ FindReplaceBar::FindReplaceBar() {
hide_button = memnew(TextureButton);
search_options->add_child(hide_button);
hide_button->set_focus_mode(FOCUS_NONE);
- hide_button->connect("pressed",this,"_hide_pressed");
+ hide_button->connect("pressed", this, "_hide_pressed");
replace_options_hbc = memnew(HBoxContainer);
options_vbc->add_child(replace_options_hbc);
@@ -570,10 +564,9 @@ FindReplaceBar::FindReplaceBar() {
replace_options_hbc->add_child(selection_only);
selection_only->set_text(TTR("Selection Only"));
selection_only->set_focus_mode(FOCUS_NONE);
- selection_only->connect("toggled",this,"_search_options_changed");
+ selection_only->connect("toggled", this, "_search_options_changed");
}
-
void FindReplaceDialog::popup_search() {
set_title(TTR("Search"));
@@ -581,24 +574,22 @@ void FindReplaceDialog::popup_search() {
replace_label->hide();
replace_vb->hide();
skip->hide();
- popup_centered(Point2(300,190));
+ popup_centered(Point2(300, 190));
get_ok()->set_text(TTR("Find"));
search_text->grab_focus();
- if (text_edit->is_selection_active() && ( text_edit->get_selection_from_line() == text_edit->get_selection_to_line())) {
+ if (text_edit->is_selection_active() && (text_edit->get_selection_from_line() == text_edit->get_selection_to_line())) {
- search_text->set_text( text_edit->get_selection_text() );
+ search_text->set_text(text_edit->get_selection_text());
}
search_text->select_all();
error_label->set_text("");
-
}
void FindReplaceDialog::popup_replace() {
-
set_title(TTR("Replace"));
- bool do_selection=(text_edit->is_selection_active() && text_edit->get_selection_from_line() < text_edit->get_selection_to_line());
+ bool do_selection = (text_edit->is_selection_active() && text_edit->get_selection_from_line() < text_edit->get_selection_to_line());
set_replace_selection_only(do_selection);
@@ -609,9 +600,9 @@ void FindReplaceDialog::popup_replace() {
replace_mc->show();
replace_label->show();
replace_vb->show();
- popup_centered(Point2(300,300));
- if (search_text->get_text()!="" && replace_text->get_text()=="") {
- search_text->select(0,0);
+ popup_centered(Point2(300, 300));
+ if (search_text->get_text() != "" && replace_text->get_text() == "") {
+ search_text->select(0, 0);
replace_text->grab_focus();
} else {
search_text->grab_focus();
@@ -629,7 +620,6 @@ void FindReplaceDialog::popup_replace() {
get_ok()->set_text(TTR("Replace"));
selection_only->set_disabled(false);
}
-
}
void FindReplaceDialog::_search_callback() {
@@ -638,7 +628,6 @@ void FindReplaceDialog::_search_callback() {
_replace();
else
_search();
-
}
void FindReplaceDialog::_replace_skip_callback() {
@@ -652,15 +641,14 @@ void FindReplaceDialog::_replace() {
if (is_replace_all_mode()) {
//line as x so it gets priority in comparison, column as y
- Point2i orig_cursor(text_edit->cursor_get_line(),text_edit->cursor_get_column());
- Point2i prev_match=Point2(-1,-1);
-
+ Point2i orig_cursor(text_edit->cursor_get_line(), text_edit->cursor_get_column());
+ Point2i prev_match = Point2(-1, -1);
bool selection_enabled = text_edit->is_selection_active();
- Point2i selection_begin,selection_end;
+ Point2i selection_begin, selection_end;
if (selection_enabled) {
- selection_begin=Point2i(text_edit->get_selection_from_line(),text_edit->get_selection_from_column());
- selection_end=Point2i(text_edit->get_selection_to_line(),text_edit->get_selection_to_column());
+ selection_begin = Point2i(text_edit->get_selection_from_line(), text_edit->get_selection_from_column());
+ selection_end = Point2i(text_edit->get_selection_to_line(), text_edit->get_selection_to_column());
}
int vsval = text_edit->get_v_scroll();
//int hsval = text_edit->get_h_scroll();
@@ -668,9 +656,9 @@ void FindReplaceDialog::_replace() {
text_edit->cursor_set_line(0);
text_edit->cursor_set_column(0);
- int rc=0;
+ int rc = 0;
- while(_search()) {
+ while (_search()) {
if (!text_edit->is_selection_active()) {
//search selects
@@ -678,30 +666,29 @@ void FindReplaceDialog::_replace() {
}
//replace area
- Point2i match_from(text_edit->get_selection_from_line(),text_edit->get_selection_from_column());
- Point2i match_to(text_edit->get_selection_to_line(),text_edit->get_selection_to_column());
+ Point2i match_from(text_edit->get_selection_from_line(), text_edit->get_selection_from_column());
+ Point2i match_to(text_edit->get_selection_to_line(), text_edit->get_selection_to_column());
if (match_from < prev_match)
break; //done
- prev_match=match_to;
+ prev_match = match_to;
if (selection_enabled && is_replace_selection_only()) {
- if (match_from<selection_begin || match_to>selection_end)
+ if (match_from < selection_begin || match_to > selection_end)
continue;
//replace but adjust selection bounds
text_edit->insert_text_at_cursor(get_replace_text());
- if (match_to.x==selection_end.x)
- selection_end.y+=get_replace_text().length() - get_search_text().length();
+ if (match_to.x == selection_end.x)
+ selection_end.y += get_replace_text().length() - get_search_text().length();
} else {
//just replace
text_edit->insert_text_at_cursor(get_replace_text());
}
rc++;
-
}
//restore editor state (selection, cursor, scroll)
text_edit->cursor_set_line(orig_cursor.x);
@@ -709,20 +696,19 @@ void FindReplaceDialog::_replace() {
if (selection_enabled && is_replace_selection_only()) {
//reselect
- text_edit->select(selection_begin.x,selection_begin.y,selection_end.x,selection_end.y);
+ text_edit->select(selection_begin.x, selection_begin.y, selection_end.x, selection_end.y);
} else {
text_edit->deselect();
}
text_edit->set_v_scroll(vsval);
//text_edit->set_h_scroll(hsval);
- error_label->set_text(vformat(TTR("Replaced %d ocurrence(s)."),rc));
-
+ error_label->set_text(vformat(TTR("Replaced %d ocurrence(s)."), rc));
//hide();
} else {
- if (text_edit->get_selection_text()==get_search_text()) {
+ if (text_edit->get_selection_text() == get_search_text()) {
text_edit->insert_text_at_cursor(get_replace_text());
}
@@ -732,35 +718,31 @@ void FindReplaceDialog::_replace() {
text_edit->end_complex_operation();
}
-
-
bool FindReplaceDialog::_search() {
-
- String text=get_search_text();
- uint32_t flags=0;
+ String text = get_search_text();
+ uint32_t flags = 0;
if (is_whole_words())
- flags|=TextEdit::SEARCH_WHOLE_WORDS;
+ flags |= TextEdit::SEARCH_WHOLE_WORDS;
if (is_case_sensitive())
- flags|=TextEdit::SEARCH_MATCH_CASE;
+ flags |= TextEdit::SEARCH_MATCH_CASE;
if (is_backwards())
- flags|=TextEdit::SEARCH_BACKWARDS;
+ flags |= TextEdit::SEARCH_BACKWARDS;
- int line=text_edit->cursor_get_line(),col=text_edit->cursor_get_column();
+ int line = text_edit->cursor_get_line(), col = text_edit->cursor_get_column();
if (is_backwards()) {
- col-=1;
- if (col<0) {
- line-=1;
- if (line<0) {
- line=text_edit->get_line_count()-1;
+ col -= 1;
+ if (col < 0) {
+ line -= 1;
+ if (line < 0) {
+ line = text_edit->get_line_count() - 1;
}
- col=text_edit->get_line(line).length();
+ col = text_edit->get_line(line).length();
}
}
- bool found = text_edit->search(text,flags,line,col,line,col);
-
+ bool found = text_edit->search(text, flags, line, col, line, col);
if (found) {
// print_line("found");
@@ -768,8 +750,8 @@ bool FindReplaceDialog::_search() {
if (is_backwards())
text_edit->cursor_set_column(col);
else
- text_edit->cursor_set_column(col+text.length());
- text_edit->select(line,col,line,col+text.length());
+ text_edit->cursor_set_column(col + text.length());
+ text_edit->select(line, col, line, col + text.length());
set_error("");
return true;
} else {
@@ -777,7 +759,6 @@ bool FindReplaceDialog::_search() {
set_error(TTR("Not found!"));
return false;
}
-
}
void FindReplaceDialog::_prompt_changed() {
@@ -794,7 +775,6 @@ void FindReplaceDialog::_prompt_changed() {
}
}
-
void FindReplaceDialog::_skip_pressed() {
_replace_skip_callback();
@@ -812,39 +792,35 @@ bool FindReplaceDialog::is_replace_all_mode() const {
bool FindReplaceDialog::is_replace_selection_only() const {
- return selection_only->is_pressed();
+ return selection_only->is_pressed();
}
-void FindReplaceDialog::set_replace_selection_only(bool p_enable){
+void FindReplaceDialog::set_replace_selection_only(bool p_enable) {
selection_only->set_pressed(p_enable);
}
-
void FindReplaceDialog::ok_pressed() {
_search_callback();
}
-void FindReplaceDialog::_search_text_entered(const String& p_text) {
+void FindReplaceDialog::_search_text_entered(const String &p_text) {
if (replace_text->is_visible_in_tree())
return;
emit_signal("search");
_search();
-
}
-void FindReplaceDialog::_replace_text_entered(const String& p_text) {
+void FindReplaceDialog::_replace_text_entered(const String &p_text) {
if (!replace_text->is_visible_in_tree())
return;
emit_signal("search");
_replace();
-
}
-
String FindReplaceDialog::get_search_text() const {
return search_text->get_text();
@@ -860,157 +836,141 @@ bool FindReplaceDialog::is_whole_words() const {
bool FindReplaceDialog::is_case_sensitive() const {
return case_sensitive->is_pressed();
-
}
bool FindReplaceDialog::is_backwards() const {
return backwards->is_pressed();
-
}
-void FindReplaceDialog::set_error(const String& p_error) {
+void FindReplaceDialog::set_error(const String &p_error) {
error_label->set_text(p_error);
}
void FindReplaceDialog::set_text_edit(TextEdit *p_text_edit) {
- text_edit=p_text_edit;
+ text_edit = p_text_edit;
}
void FindReplaceDialog::search_next() {
_search();
}
-
void FindReplaceDialog::_bind_methods() {
- ClassDB::bind_method("_search_text_entered",&FindReplaceDialog::_search_text_entered);
- ClassDB::bind_method("_replace_text_entered",&FindReplaceDialog::_replace_text_entered);
- ClassDB::bind_method("_prompt_changed",&FindReplaceDialog::_prompt_changed);
- ClassDB::bind_method("_skip_pressed",&FindReplaceDialog::_skip_pressed);
+ ClassDB::bind_method("_search_text_entered", &FindReplaceDialog::_search_text_entered);
+ ClassDB::bind_method("_replace_text_entered", &FindReplaceDialog::_replace_text_entered);
+ ClassDB::bind_method("_prompt_changed", &FindReplaceDialog::_prompt_changed);
+ ClassDB::bind_method("_skip_pressed", &FindReplaceDialog::_skip_pressed);
ADD_SIGNAL(MethodInfo("search"));
ADD_SIGNAL(MethodInfo("skip"));
-
}
FindReplaceDialog::FindReplaceDialog() {
- set_self_modulate(Color(1,1,1,0.8));
+ set_self_modulate(Color(1, 1, 1, 0.8));
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
-
-
- search_text = memnew( LineEdit );
- vb->add_margin_child(TTR("Search"),search_text);
- search_text->connect("text_entered", this,"_search_text_entered");
+ search_text = memnew(LineEdit);
+ vb->add_margin_child(TTR("Search"), search_text);
+ search_text->connect("text_entered", this, "_search_text_entered");
//search_text->set_self_opacity(0.7);
-
-
- replace_label = memnew( Label);
+ replace_label = memnew(Label);
replace_label->set_text(TTR("Replace By"));
vb->add_child(replace_label);
- replace_mc= memnew( MarginContainer);
+ replace_mc = memnew(MarginContainer);
vb->add_child(replace_mc);
- replace_text = memnew( LineEdit );
- replace_text->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- replace_text->set_begin( Point2(15,132) );
- replace_text->set_end( Point2(15,135) );
+ replace_text = memnew(LineEdit);
+ replace_text->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ replace_text->set_begin(Point2(15, 132));
+ replace_text->set_end(Point2(15, 135));
//replace_text->set_self_opacity(0.7);
replace_mc->add_child(replace_text);
+ replace_text->connect("text_entered", this, "_replace_text_entered");
- replace_text->connect("text_entered", this,"_replace_text_entered");
-
-
-
- MarginContainer *opt_mg = memnew( MarginContainer );
+ MarginContainer *opt_mg = memnew(MarginContainer);
vb->add_child(opt_mg);
- VBoxContainer *svb = memnew( VBoxContainer);
+ VBoxContainer *svb = memnew(VBoxContainer);
opt_mg->add_child(svb);
- svb ->add_child(memnew(Label));
+ svb->add_child(memnew(Label));
- whole_words = memnew( CheckButton );
+ whole_words = memnew(CheckButton);
whole_words->set_text(TTR("Whole Words"));
svb->add_child(whole_words);
- case_sensitive = memnew( CheckButton );
+ case_sensitive = memnew(CheckButton);
case_sensitive->set_text(TTR("Case Sensitive"));
svb->add_child(case_sensitive);
- backwards = memnew( CheckButton );
+ backwards = memnew(CheckButton);
backwards->set_text(TTR("Backwards"));
svb->add_child(backwards);
- opt_mg = memnew( MarginContainer );
+ opt_mg = memnew(MarginContainer);
vb->add_child(opt_mg);
- VBoxContainer *rvb = memnew( VBoxContainer);
+ VBoxContainer *rvb = memnew(VBoxContainer);
opt_mg->add_child(rvb);
- replace_vb=rvb;
+ replace_vb = rvb;
//rvb ->add_child(memnew(HSeparator));
- rvb ->add_child(memnew(Label));
+ rvb->add_child(memnew(Label));
- prompt = memnew( CheckButton );
+ prompt = memnew(CheckButton);
prompt->set_text(TTR("Prompt On Replace"));
rvb->add_child(prompt);
- prompt->connect("pressed", this,"_prompt_changed");
+ prompt->connect("pressed", this, "_prompt_changed");
- selection_only = memnew( CheckButton );
+ selection_only = memnew(CheckButton);
selection_only->set_text(TTR("Selection Only"));
rvb->add_child(selection_only);
+ 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");
-
- skip = memnew( Button );
- skip->set_anchor( MARGIN_LEFT, ANCHOR_END );
- skip->set_anchor( MARGIN_TOP, ANCHOR_END );
- skip->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- skip->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
- skip->set_begin( Point2( 70, button_margin ) );
- skip->set_end( Point2( 10, margin ) );
+ skip = memnew(Button);
+ skip->set_anchor(MARGIN_LEFT, ANCHOR_END);
+ skip->set_anchor(MARGIN_TOP, ANCHOR_END);
+ skip->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ skip->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
+ skip->set_begin(Point2(70, button_margin));
+ skip->set_end(Point2(10, margin));
skip->set_text(TTR("Skip"));
add_child(skip);
- skip->connect("pressed", this,"_skip_pressed");
-
+ skip->connect("pressed", this, "_skip_pressed");
- error_label = memnew( Label );
+ error_label = memnew(Label);
error_label->set_align(Label::ALIGN_CENTER);
- error_label->add_color_override("font_color",Color(1,0.4,0.3));
- error_label->add_color_override("font_color_shadow",Color(0,0,0,0.2));
- error_label->add_constant_override("shadow_as_outline",1);
+ error_label->add_color_override("font_color", Color(1, 0.4, 0.3));
+ error_label->add_color_override("font_color_shadow", Color(0, 0, 0, 0.2));
+ error_label->add_constant_override("shadow_as_outline", 1);
vb->add_child(error_label);
-
set_hide_on_ok(false);
-
}
-
/*** CODE EDITOR ****/
-void CodeTextEditor::_text_editor_gui_input(const InputEvent& p_event) {
+void CodeTextEditor::_text_editor_gui_input(const InputEvent &p_event) {
- 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.pressed && mb.mod.command) {
- if (mb.button_index==BUTTON_WHEEL_UP) {
+ if (mb.button_index == BUTTON_WHEEL_UP) {
_zoom_in();
- } else if (mb.button_index==BUTTON_WHEEL_DOWN) {
+ } else if (mb.button_index == BUTTON_WHEEL_DOWN) {
_zoom_out();
}
}
- } else if (p_event.type==InputEvent::KEY) {
+ } else if (p_event.type == InputEvent::KEY) {
if (p_event.key.pressed) {
if (ED_IS_SHORTCUT("script_editor/zoom_in", p_event)) {
@@ -1027,16 +987,16 @@ void CodeTextEditor::_text_editor_gui_input(const InputEvent& p_event) {
}
void CodeTextEditor::_zoom_in() {
- font_resize_val+=1;
+ font_resize_val += 1;
- if (font_resize_timer->get_time_left()==0)
+ if (font_resize_timer->get_time_left() == 0)
font_resize_timer->start();
}
void CodeTextEditor::_zoom_out() {
- font_resize_val-=1;
+ font_resize_val -= 1;
- if (font_resize_timer->get_time_left()==0)
+ if (font_resize_timer->get_time_left() == 0)
font_resize_timer->start();
}
@@ -1044,7 +1004,7 @@ void CodeTextEditor::_reset_zoom() {
Ref<DynamicFont> font = text_editor->get_font("font"); // reset source font size to default
if (font.is_valid()) {
- EditorSettings::get_singleton()->set("interface/source_font_size",14);
+ EditorSettings::get_singleton()->set("interface/source_font_size", 14);
font->set_size(14);
}
}
@@ -1072,19 +1032,19 @@ void CodeTextEditor::_complete_request() {
List<String> entries;
String ctext = text_editor->get_text_for_completion();
- _code_complete_script(ctext,&entries);
+ _code_complete_script(ctext, &entries);
if (code_complete_func) {
- code_complete_func(code_complete_ud,ctext,&entries);
+ code_complete_func(code_complete_ud, ctext, &entries);
}
// print_line("COMPLETE: "+p_request);
- if (entries.size()==0)
+ if (entries.size() == 0)
return;
Vector<String> strs;
strs.resize(entries.size());
- int i=0;
- for(List<String>::Element *E=entries.front();E;E=E->next()) {
+ int i = 0;
+ for (List<String>::Element *E = entries.front(); E; E = E->next()) {
- strs[i++]=E->get();
+ strs[i++] = E->get();
}
text_editor->code_complete(strs);
@@ -1095,14 +1055,14 @@ void CodeTextEditor::_font_resize_timeout() {
Ref<DynamicFont> font = text_editor->get_font("font");
if (font.is_valid()) {
- int size=font->get_size()+font_resize_val;
+ int size = font->get_size() + font_resize_val;
- if (size>=8 && size<=96) {
- EditorSettings::get_singleton()->set("interface/source_font_size",size);
+ if (size >= 8 && size <= 96) {
+ EditorSettings::get_singleton()->set("interface/source_font_size", size);
font->set_size(size);
}
- font_resize_val=0;
+ font_resize_val = 0;
}
}
@@ -1124,15 +1084,14 @@ void CodeTextEditor::update_editor_settings() {
text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
}
-void CodeTextEditor::set_error(const String& p_error) {
+void CodeTextEditor::set_error(const String &p_error) {
- if (p_error!="") {
+ if (p_error != "") {
error->set_text(p_error);
error->show();
} else {
error->hide();
}
-
}
void CodeTextEditor::_update_font() {
@@ -1140,16 +1099,16 @@ void CodeTextEditor::_update_font() {
// FONTS
String editor_font = EDITOR_DEF("text_editor/theme/font", "");
bool font_overridden = false;
- if (editor_font!="") {
+ if (editor_font != "") {
Ref<Font> fnt = ResourceLoader::load(editor_font);
if (fnt.is_valid()) {
- text_editor->add_font_override("font",fnt);
+ text_editor->add_font_override("font", fnt);
font_overridden = true;
}
}
- if(!font_overridden) {
+ if (!font_overridden) {
- text_editor->add_font_override("font",get_font("source","EditorFonts"));
+ text_editor->add_font_override("font", get_font("source", "EditorFonts"));
}
}
@@ -1159,76 +1118,69 @@ void CodeTextEditor::_on_settings_change() {
// AUTO BRACE COMPLETION
text_editor->set_auto_brace_completion(
- EDITOR_DEF("text_editor/completion/auto_brace_complete", true)
- );
+ EDITOR_DEF("text_editor/completion/auto_brace_complete", true));
code_complete_timer->set_wait_time(
- EDITOR_DEF("text_editor/completion/code_complete_delay",.3f)
- );
+ EDITOR_DEF("text_editor/completion/code_complete_delay", .3f));
- enable_complete_timer = EDITOR_DEF("text_editor/completion/enable_code_completion_delay",true);
+ enable_complete_timer = EDITOR_DEF("text_editor/completion/enable_code_completion_delay", true);
// call hint settings
text_editor->set_callhint_settings(
- EDITOR_DEF("text_editor/completion/put_callhint_tooltip_below_current_line", true),
- EDITOR_DEF("text_editor/completion/callhint_tooltip_offset", Vector2())
- );
+ EDITOR_DEF("text_editor/completion/put_callhint_tooltip_below_current_line", true),
+ EDITOR_DEF("text_editor/completion/callhint_tooltip_offset", Vector2()));
}
void CodeTextEditor::_text_changed_idle_timeout() {
-
_validate_script();
emit_signal("validate_script");
}
void CodeTextEditor::_notification(int p_what) {
-
- if (p_what==EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
+ if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
_load_theme_settings();
emit_signal("load_theme_settings");
}
- if (p_what==NOTIFICATION_THEME_CHANGED) {
+ if (p_what == NOTIFICATION_THEME_CHANGED) {
_update_font();
}
}
void CodeTextEditor::_bind_methods() {
- ClassDB::bind_method("_text_editor_gui_input",&CodeTextEditor::_text_editor_gui_input);
- ClassDB::bind_method("_line_col_changed",&CodeTextEditor::_line_col_changed);
- ClassDB::bind_method("_text_changed",&CodeTextEditor::_text_changed);
- ClassDB::bind_method("_on_settings_change",&CodeTextEditor::_on_settings_change);
- ClassDB::bind_method("_text_changed_idle_timeout",&CodeTextEditor::_text_changed_idle_timeout);
- ClassDB::bind_method("_code_complete_timer_timeout",&CodeTextEditor::_code_complete_timer_timeout);
- ClassDB::bind_method("_complete_request",&CodeTextEditor::_complete_request);
- ClassDB::bind_method("_font_resize_timeout",&CodeTextEditor::_font_resize_timeout);
+ ClassDB::bind_method("_text_editor_gui_input", &CodeTextEditor::_text_editor_gui_input);
+ ClassDB::bind_method("_line_col_changed", &CodeTextEditor::_line_col_changed);
+ ClassDB::bind_method("_text_changed", &CodeTextEditor::_text_changed);
+ ClassDB::bind_method("_on_settings_change", &CodeTextEditor::_on_settings_change);
+ ClassDB::bind_method("_text_changed_idle_timeout", &CodeTextEditor::_text_changed_idle_timeout);
+ ClassDB::bind_method("_code_complete_timer_timeout", &CodeTextEditor::_code_complete_timer_timeout);
+ ClassDB::bind_method("_complete_request", &CodeTextEditor::_complete_request);
+ ClassDB::bind_method("_font_resize_timeout", &CodeTextEditor::_font_resize_timeout);
ADD_SIGNAL(MethodInfo("validate_script"));
ADD_SIGNAL(MethodInfo("load_theme_settings"));
-
}
-void CodeTextEditor::set_code_complete_func(CodeTextEditorCodeCompleteFunc p_code_complete_func,void * p_ud) {
- code_complete_func=p_code_complete_func;
- code_complete_ud=p_ud;
+void CodeTextEditor::set_code_complete_func(CodeTextEditorCodeCompleteFunc p_code_complete_func, void *p_ud) {
+ code_complete_func = p_code_complete_func;
+ code_complete_ud = p_ud;
}
-
CodeTextEditor::CodeTextEditor() {
- code_complete_func=NULL;
- ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD|KEY_EQUAL);
- ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD|KEY_MINUS);
- ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KEY_MASK_CMD|KEY_0);
+ code_complete_func = NULL;
+ ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD | KEY_EQUAL);
+ ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD | KEY_MINUS);
+ ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KEY_MASK_CMD | KEY_0);
- find_replace_bar = memnew( FindReplaceBar );
+ find_replace_bar = memnew(FindReplaceBar);
add_child(find_replace_bar);
find_replace_bar->set_h_size_flags(SIZE_EXPAND_FILL);
find_replace_bar->hide();
- text_editor = memnew( TextEdit );
+ text_editor = memnew(TextEdit);
add_child(text_editor);
text_editor->set_v_size_flags(SIZE_EXPAND_FILL);
@@ -1238,86 +1190,86 @@ CodeTextEditor::CodeTextEditor() {
text_editor->set_brace_matching(true);
text_editor->set_auto_indent(true);
- MarginContainer *status_mc = memnew( MarginContainer );
+ MarginContainer *status_mc = memnew(MarginContainer);
add_child(status_mc);
status_mc->set("custom_constants/margin_left", 2);
status_mc->set("custom_constants/margin_top", 5);
status_mc->set("custom_constants/margin_right", 2);
status_mc->set("custom_constants/margin_bottom", 1);
- HBoxContainer *status_bar = memnew( HBoxContainer );
+ HBoxContainer *status_bar = memnew(HBoxContainer);
status_mc->add_child(status_bar);
status_bar->set_h_size_flags(SIZE_EXPAND_FILL);
- status_bar->add_child( memnew( Label ) ); //to keep the height if the other labels are not visible
+ status_bar->add_child(memnew(Label)); //to keep the height if the other labels are not visible
- idle = memnew( Timer );
+ idle = memnew(Timer);
add_child(idle);
idle->set_one_shot(true);
- idle->set_wait_time(EDITOR_DEF("text_editor/completion/idle_parse_delay",2));
+ idle->set_wait_time(EDITOR_DEF("text_editor/completion/idle_parse_delay", 2));
code_complete_timer = memnew(Timer);
add_child(code_complete_timer);
code_complete_timer->set_one_shot(true);
- enable_complete_timer = EDITOR_DEF("text_editor/completion/enable_code_completion_delay",true);
+ enable_complete_timer = EDITOR_DEF("text_editor/completion/enable_code_completion_delay", true);
- code_complete_timer->set_wait_time(EDITOR_DEF("text_editor/completion/code_complete_delay",.3f));
+ code_complete_timer->set_wait_time(EDITOR_DEF("text_editor/completion/code_complete_delay", .3f));
- error = memnew( Label );
+ error = memnew(Label);
status_bar->add_child(error);
error->hide();
error->set_valign(Label::VALIGN_CENTER);
- error->add_color_override("font_color",Color(1,0.7,0.6,0.9));
+ error->add_color_override("font_color", Color(1, 0.7, 0.6, 0.9));
status_bar->add_spacer();
- Label *line_txt = memnew( Label );
+ Label *line_txt = memnew(Label);
status_bar->add_child(line_txt);
line_txt->set_align(Label::ALIGN_RIGHT);
line_txt->set_valign(Label::VALIGN_CENTER);
line_txt->set_v_size_flags(SIZE_FILL);
line_txt->set_text(TTR("Line:"));
- line_nb = memnew( Label );
+ line_nb = memnew(Label);
status_bar->add_child(line_nb);
line_nb->set_valign(Label::VALIGN_CENTER);
line_nb->set_v_size_flags(SIZE_FILL);
line_nb->set_autowrap(true); // workaround to prevent resizing the label on each change
- line_nb->set_custom_minimum_size(Size2(40,1)*EDSCALE);
+ line_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE);
- Label *col_txt = memnew( Label );
+ Label *col_txt = memnew(Label);
status_bar->add_child(col_txt);
col_txt->set_align(Label::ALIGN_RIGHT);
col_txt->set_valign(Label::VALIGN_CENTER);
col_txt->set_v_size_flags(SIZE_FILL);
col_txt->set_text(TTR("Col:"));
- col_nb = memnew( Label );
+ col_nb = memnew(Label);
status_bar->add_child(col_nb);
col_nb->set_valign(Label::VALIGN_CENTER);
col_nb->set_v_size_flags(SIZE_FILL);
col_nb->set_autowrap(true); // workaround to prevent resizing the label on each change
- col_nb->set_custom_minimum_size(Size2(40,1)*EDSCALE);
+ col_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE);
- text_editor->connect("gui_input", this,"_text_editor_gui_input");
- text_editor->connect("cursor_changed", this,"_line_col_changed");
- text_editor->connect("text_changed", this,"_text_changed");
- text_editor->connect("request_completion", this,"_complete_request");
+ text_editor->connect("gui_input", this, "_text_editor_gui_input");
+ text_editor->connect("cursor_changed", this, "_line_col_changed");
+ text_editor->connect("text_changed", this, "_text_changed");
+ text_editor->connect("request_completion", this, "_complete_request");
Vector<String> cs;
cs.push_back(".");
cs.push_back(",");
cs.push_back("(");
cs.push_back("$");
- text_editor->set_completion(true,cs);
- idle->connect("timeout", this,"_text_changed_idle_timeout");
+ text_editor->set_completion(true, cs);
+ idle->connect("timeout", this, "_text_changed_idle_timeout");
- code_complete_timer->connect("timeout", this,"_code_complete_timer_timeout");
+ code_complete_timer->connect("timeout", this, "_code_complete_timer_timeout");
- font_resize_val=0;
+ font_resize_val = 0;
font_resize_timer = memnew(Timer);
add_child(font_resize_timer);
font_resize_timer->set_one_shot(true);
font_resize_timer->set_wait_time(0.07);
font_resize_timer->connect("timeout", this, "_font_resize_timeout");
- EditorSettings::get_singleton()->connect("settings_changed",this,"_on_settings_change");
+ EditorSettings::get_singleton()->connect("settings_changed", this, "_on_settings_change");
}
diff --git a/editor/code_editor.h b/editor/code_editor.h
index 7582985d4c..8fa52b03f7 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -30,19 +30,17 @@
#define CODE_EDITOR_H
#include "editor/editor_plugin.h"
-#include "scene/gui/text_edit.h"
-#include "scene/gui/dialogs.h"
-#include "scene/main/timer.h"
-#include "scene/gui/tool_button.h"
-#include "scene/gui/check_button.h"
#include "scene/gui/check_box.h"
+#include "scene/gui/check_button.h"
+#include "scene/gui/dialogs.h"
#include "scene/gui/line_edit.h"
-
-
+#include "scene/gui/text_edit.h"
+#include "scene/gui/tool_button.h"
+#include "scene/main/timer.h"
class GotoLineDialog : public ConfirmationDialog {
- GDCLASS(GotoLineDialog,ConfirmationDialog);
+ GDCLASS(GotoLineDialog, ConfirmationDialog);
Label *line_label;
LineEdit *line;
@@ -50,19 +48,18 @@ class GotoLineDialog : public ConfirmationDialog {
TextEdit *text_editor;
virtual void ok_pressed();
-public:
+public:
void popup_find_line(TextEdit *p_edit);
int get_line() const;
-
void set_text_editor(TextEdit *p_text_editor);
GotoLineDialog();
};
class FindReplaceBar : public HBoxContainer {
- GDCLASS(FindReplaceBar,HBoxContainer);
+ GDCLASS(FindReplaceBar, HBoxContainer);
LineEdit *search_text;
ToolButton *find_prev;
@@ -89,16 +86,16 @@ class FindReplaceBar : public HBoxContainer {
bool replace_all_mode;
bool preserve_cursor;
- void _get_search_from(int& r_line, int& r_col);
+ void _get_search_from(int &r_line, int &r_col);
void _show_search();
void _hide_bar();
void _editor_text_changed();
void _search_options_changed(bool p_pressed);
- void _search_text_changed(const String& p_text);
- void _search_text_entered(const String& p_text);
- void _replace_text_entered(const String& p_text);
+ void _search_text_changed(const String &p_text);
+ void _search_text_entered(const String &p_text);
+ void _replace_text_entered(const String &p_text);
protected:
void _notification(int p_what);
@@ -118,7 +115,7 @@ public:
bool is_case_sensitive() const;
bool is_whole_words() const;
bool is_selection_only() const;
- void set_error(const String& p_label);
+ void set_error(const String &p_label);
void set_text_edit(TextEdit *p_text_edit);
@@ -134,7 +131,7 @@ public:
class FindReplaceDialog : public ConfirmationDialog {
- GDCLASS(FindReplaceDialog,ConfirmationDialog);
+ GDCLASS(FindReplaceDialog, ConfirmationDialog);
LineEdit *search_text;
LineEdit *replace_text;
@@ -149,15 +146,14 @@ class FindReplaceDialog : public ConfirmationDialog {
Label *replace_label;
VBoxContainer *replace_vb;
- void _search_text_entered(const String& p_text);
- void _replace_text_entered(const String& p_text);
+ void _search_text_entered(const String &p_text);
+ void _replace_text_entered(const String &p_text);
void _prompt_changed();
void _skip_pressed();
-
TextEdit *text_edit;
-protected:
+protected:
void _search_callback();
void _replace_skip_callback();
@@ -166,8 +162,8 @@ protected:
virtual void ok_pressed();
static void _bind_methods();
-public:
+public:
String get_search_text() const;
String get_replace_text() const;
bool is_whole_words() const;
@@ -178,7 +174,7 @@ public:
bool is_replace_selection_only() const;
void set_replace_selection_only(bool p_enable);
- void set_error(const String& p_error);
+ void set_error(const String &p_error);
void popup_search();
void popup_replace();
@@ -189,12 +185,11 @@ public:
FindReplaceDialog();
};
-
-typedef void (*CodeTextEditorCodeCompleteFunc)(void* p_ud,const String& p_code, List<String>* r_options);
+typedef void (*CodeTextEditorCodeCompleteFunc)(void *p_ud, const String &p_code, List<String> *r_options);
class CodeTextEditor : public VBoxContainer {
- GDCLASS(CodeTextEditor,VBoxContainer);
+ GDCLASS(CodeTextEditor, VBoxContainer);
TextEdit *text_editor;
FindReplaceBar *find_replace_bar;
@@ -217,21 +212,18 @@ class CodeTextEditor : public VBoxContainer {
void _complete_request();
void _font_resize_timeout();
- void _text_editor_gui_input(const InputEvent& p_event);
+ void _text_editor_gui_input(const InputEvent &p_event);
void _zoom_in();
void _zoom_out();
void _reset_zoom();
-
CodeTextEditorCodeCompleteFunc code_complete_func;
void *code_complete_ud;
protected:
-
-
virtual void _load_theme_settings() {}
virtual void _validate_script() {}
- virtual void _code_complete_script(const String& p_code, List<String>* r_options) {}
+ virtual void _code_complete_script(const String &p_code, List<String> *r_options) {}
void _text_changed_idle_timeout();
void _code_complete_timer_timeout();
@@ -241,21 +233,16 @@ protected:
static void _bind_methods();
public:
-
void update_editor_settings();
- void set_error(const String& p_error);
+ void set_error(const String &p_error);
void update_line_and_column() { _line_col_changed(); }
TextEdit *get_text_edit() { return text_editor; }
FindReplaceBar *get_find_replace_bar() { return find_replace_bar; }
virtual void apply_code() {}
-
- void set_code_complete_func(CodeTextEditorCodeCompleteFunc p_code_complete_func, void * p_ud);
-
+ void set_code_complete_func(CodeTextEditorCodeCompleteFunc p_code_complete_func, void *p_ud);
CodeTextEditor();
};
-
-
#endif // CODE_EDITOR_H
diff --git a/editor/collada/collada.cpp b/editor/collada/collada.cpp
index 2ba4f648a3..d96f1f4b6e 100644
--- a/editor/collada/collada.cpp
+++ b/editor/collada/collada.cpp
@@ -44,12 +44,10 @@
/* HELPERS */
+String Collada::Effect::get_texture_path(const String &p_source, Collada &state) const {
-
-String Collada::Effect::get_texture_path(const String& p_source,Collada& state) const {
-
- String image=p_source;
- ERR_FAIL_COND_V(!state.state.image_map.has(image),"");
+ String image = p_source;
+ ERR_FAIL_COND_V(!state.state.image_map.has(image), "");
return state.state.image_map[image].path;
}
@@ -57,50 +55,47 @@ Transform Collada::get_root_transform() const {
Transform unit_scale_transform;
#ifndef COLLADA_IMPORT_SCALE_SCENE
- unit_scale_transform.scale(Vector3(state.unit_scale,state.unit_scale,state.unit_scale));
+ unit_scale_transform.scale(Vector3(state.unit_scale, state.unit_scale, state.unit_scale));
#endif
return unit_scale_transform;
}
-
-
void Collada::Vertex::fix_unit_scale(Collada &state) {
#ifdef COLLADA_IMPORT_SCALE_SCENE
- vertex*=state.state.unit_scale;
+ vertex *= state.state.unit_scale;
#endif
}
-static String _uri_to_id(const String& p_uri) {
+static String _uri_to_id(const String &p_uri) {
if (p_uri.begins_with("#"))
- return p_uri.substr(1,p_uri.size()-1);
+ return p_uri.substr(1, p_uri.size() - 1);
else
return p_uri;
-
}
/** HELPER FUNCTIONS **/
-Transform Collada::fix_transform(const Transform& p_transform) {
+Transform Collada::fix_transform(const Transform &p_transform) {
- Transform tr=p_transform;
+ Transform tr = p_transform;
#ifndef NO_UP_AXIS_SWAP
- if (state.up_axis!=Vector3::AXIS_Y) {
+ if (state.up_axis != Vector3::AXIS_Y) {
- for(int i=0;i<3;i++)
- SWAP(tr.basis[1][i],tr.basis[state.up_axis][i]);
- for(int i=0;i<3;i++)
- SWAP(tr.basis[i][1],tr.basis[i][state.up_axis]);
+ for (int i = 0; i < 3; i++)
+ SWAP(tr.basis[1][i], tr.basis[state.up_axis][i]);
+ for (int i = 0; i < 3; i++)
+ SWAP(tr.basis[i][1], tr.basis[i][state.up_axis]);
- SWAP(tr.origin[1],tr.origin[state.up_axis]);
+ SWAP(tr.origin[1], tr.origin[state.up_axis]);
- tr.basis[state.up_axis][0]=-tr.basis[state.up_axis][0];
- tr.basis[state.up_axis][1]=-tr.basis[state.up_axis][1];
- tr.basis[0][state.up_axis]=-tr.basis[0][state.up_axis];
- tr.basis[1][state.up_axis]=-tr.basis[1][state.up_axis];
- tr.origin[state.up_axis]=-tr.origin[state.up_axis];
+ tr.basis[state.up_axis][0] = -tr.basis[state.up_axis][0];
+ tr.basis[state.up_axis][1] = -tr.basis[state.up_axis][1];
+ tr.basis[0][state.up_axis] = -tr.basis[0][state.up_axis];
+ tr.basis[1][state.up_axis] = -tr.basis[1][state.up_axis];
+ tr.origin[state.up_axis] = -tr.origin[state.up_axis];
}
#endif
@@ -109,25 +104,23 @@ Transform Collada::fix_transform(const Transform& p_transform) {
//return state.matrix_fix * p_transform;
}
-
-static Transform _read_transform_from_array(const Vector<float>& array, int ofs=0) {
+static Transform _read_transform_from_array(const Vector<float> &array, int ofs = 0) {
Transform tr;
// i wonder why collada matrices are transposed, given that's opposed to opengl..
- tr.basis.elements[0][0]=array[0+ofs];
- tr.basis.elements[0][1]=array[1+ofs];
- tr.basis.elements[0][2]=array[2+ofs];
- tr.basis.elements[1][0]=array[4+ofs];
- tr.basis.elements[1][1]=array[5+ofs];
- tr.basis.elements[1][2]=array[6+ofs];
- tr.basis.elements[2][0]=array[8+ofs];
- tr.basis.elements[2][1]=array[9+ofs];
- tr.basis.elements[2][2]=array[10+ofs];
- tr.origin.x=array[3+ofs];
- tr.origin.y=array[7+ofs];
- tr.origin.z=array[11+ofs];
+ tr.basis.elements[0][0] = array[0 + ofs];
+ tr.basis.elements[0][1] = array[1 + ofs];
+ tr.basis.elements[0][2] = array[2 + ofs];
+ tr.basis.elements[1][0] = array[4 + ofs];
+ tr.basis.elements[1][1] = array[5 + ofs];
+ tr.basis.elements[1][2] = array[6 + ofs];
+ tr.basis.elements[2][0] = array[8 + ofs];
+ tr.basis.elements[2][1] = array[9 + ofs];
+ tr.basis.elements[2][2] = array[10 + ofs];
+ tr.origin.x = array[3 + ofs];
+ tr.origin.y = array[7 + ofs];
+ tr.origin.z = array[11 + ofs];
return tr;
-
}
/* STRUCTURES */
@@ -136,50 +129,49 @@ Transform Collada::Node::compute_transform(Collada &state) const {
Transform xform;
- for(int i=0;i<xform_list.size();i++) {
+ for (int i = 0; i < xform_list.size(); i++) {
Transform xform_step;
- const XForm& xf = xform_list[i];
- switch(xf.op) {
+ const XForm &xf = xform_list[i];
+ switch (xf.op) {
case XForm::OP_ROTATE: {
- if (xf.data.size()>=4) {
+ if (xf.data.size() >= 4) {
- xform_step.rotate(Vector3(xf.data[0],xf.data[1],xf.data[2]),Math::deg2rad(xf.data[3]));
+ xform_step.rotate(Vector3(xf.data[0], xf.data[1], xf.data[2]), Math::deg2rad(xf.data[3]));
}
} break;
case XForm::OP_SCALE: {
- if (xf.data.size()>=3) {
+ if (xf.data.size() >= 3) {
- xform_step.scale(Vector3(xf.data[0],xf.data[1],xf.data[2]));
+ xform_step.scale(Vector3(xf.data[0], xf.data[1], xf.data[2]));
}
} break;
case XForm::OP_TRANSLATE: {
- if (xf.data.size()>=3) {
+ if (xf.data.size() >= 3) {
- xform_step.origin=Vector3(xf.data[0],xf.data[1],xf.data[2]);
+ xform_step.origin = Vector3(xf.data[0], xf.data[1], xf.data[2]);
}
} break;
case XForm::OP_MATRIX: {
- if (xf.data.size()>=16) {
- xform_step = _read_transform_from_array(xf.data,0);
+ if (xf.data.size() >= 16) {
+ xform_step = _read_transform_from_array(xf.data, 0);
}
} break;
default: {}
-
}
xform = xform * xform_step;
}
#ifdef COLLADA_IMPORT_SCALE_SCENE
- xform.origin*=state.state.unit_scale;
+ xform.origin *= state.state.unit_scale;
#endif
return xform;
}
@@ -195,69 +187,67 @@ Transform Collada::Node::get_global_transform() const {
return parent->get_global_transform() * default_transform;
else
return default_transform;
-
}
Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) {
- ERR_FAIL_COND_V(keys.size()==0,Vector<float>());
- int i=0;
+ ERR_FAIL_COND_V(keys.size() == 0, Vector<float>());
+ int i = 0;
- for(i=0;i<keys.size();i++) {
+ for (i = 0; i < keys.size(); i++) {
- if (keys[i].time>p_time)
+ if (keys[i].time > p_time)
break;
}
- if (i==0)
+ if (i == 0)
return keys[0].data;
- if (i==keys.size())
- return keys[keys.size()-1].data;
+ if (i == keys.size())
+ return keys[keys.size() - 1].data;
- switch(keys[i].interp_type) {
+ switch (keys[i].interp_type) {
case INTERP_BEZIER: //wait for bezier
case INTERP_LINEAR: {
- float c = (p_time-keys[i-1].time)/(keys[i].time-keys[i-1].time);
+ float c = (p_time - keys[i - 1].time) / (keys[i].time - keys[i - 1].time);
- if (keys[i].data.size()==16) {
+ if (keys[i].data.size() == 16) {
//interpolate a matrix
- Transform src = _read_transform_from_array(keys[i-1].data);
+ Transform src = _read_transform_from_array(keys[i - 1].data);
Transform dst = _read_transform_from_array(keys[i].data);
-
- Transform interp = c<0.001 ? src : src.interpolate_with(dst,c);
+ Transform interp = c < 0.001 ? src : src.interpolate_with(dst, c);
Vector<float> ret;
ret.resize(16);
Transform tr;
// i wonder why collada matrices are transposed, given that's opposed to opengl..
- ret[0]=interp.basis.elements[0][0];
- ret[1]=interp.basis.elements[0][1];
- ret[2]=interp.basis.elements[0][2];
- ret[4]=interp.basis.elements[1][0];
- ret[5]=interp.basis.elements[1][1];
- ret[6]=interp.basis.elements[1][2];
- ret[8]=interp.basis.elements[2][0];
- ret[9]=interp.basis.elements[2][1];
- ret[10]=interp.basis.elements[2][2];
- ret[3]=interp.origin.x;
- ret[7]=interp.origin.y;
- ret[11]=interp.origin.z;
- ret[12]=0;
- ret[13]=0;
- ret[14]=0;
- ret[15]=1;
+ ret[0] = interp.basis.elements[0][0];
+ ret[1] = interp.basis.elements[0][1];
+ ret[2] = interp.basis.elements[0][2];
+ ret[4] = interp.basis.elements[1][0];
+ ret[5] = interp.basis.elements[1][1];
+ ret[6] = interp.basis.elements[1][2];
+ ret[8] = interp.basis.elements[2][0];
+ ret[9] = interp.basis.elements[2][1];
+ ret[10] = interp.basis.elements[2][2];
+ ret[3] = interp.origin.x;
+ ret[7] = interp.origin.y;
+ ret[11] = interp.origin.z;
+ ret[12] = 0;
+ ret[13] = 0;
+ ret[14] = 0;
+ ret[15] = 1;
return ret;
} else {
Vector<float> dest;
dest.resize(keys[i].data.size());
- for(int j=0;j<dest.size();j++) {
+ for (int j = 0; j < dest.size(); j++) {
- dest[j]=keys[i].data[j]*c+keys[i-1].data[j]*(1.0-c);
+ dest[j] = keys[i].data[j] * c + keys[i - 1].data[j] * (1.0 - c);
}
return dest;
//interpolate one by one
@@ -268,140 +258,128 @@ Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) {
ERR_FAIL_V(Vector<float>());
}
+void Collada::_parse_asset(XMLParser &parser) {
+ while (parser.read() == OK) {
-
-void Collada::_parse_asset(XMLParser& parser) {
-
- while(parser.read()==OK) {
-
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
String name = parser.get_node_name();
- if (name=="up_axis") {
+ if (name == "up_axis") {
parser.read();
- if (parser.get_node_data()=="X_UP")
- state.up_axis=Vector3::AXIS_X;
- if (parser.get_node_data()=="Y_UP")
- state.up_axis=Vector3::AXIS_Y;
- if (parser.get_node_data()=="Z_UP")
- state.up_axis=Vector3::AXIS_Z;
+ if (parser.get_node_data() == "X_UP")
+ state.up_axis = Vector3::AXIS_X;
+ if (parser.get_node_data() == "Y_UP")
+ state.up_axis = Vector3::AXIS_Y;
+ if (parser.get_node_data() == "Z_UP")
+ state.up_axis = Vector3::AXIS_Z;
- COLLADA_PRINT("up axis: "+parser.get_node_data());
- } else if (name=="unit") {
+ COLLADA_PRINT("up axis: " + parser.get_node_data());
+ } else if (name == "unit") {
state.unit_scale = parser.get_attribute_value("meter").to_double();
- COLLADA_PRINT("unit scale: "+rtos(state.unit_scale));
+ COLLADA_PRINT("unit scale: " + rtos(state.unit_scale));
}
-
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="asset")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "asset")
break; //end of <asset>
}
}
+void Collada::_parse_image(XMLParser &parser) {
-void Collada::_parse_image(XMLParser& parser) {
-
- String id=parser.get_attribute_value("id");
+ String id = parser.get_attribute_value("id");
-
- if (!(state.import_flags&IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
+ if (!parser.is_empty())
parser.skip_section();
return;
}
-
Image image;
-
- if (state.version<State::Version(1,4,0)) {
+ if (state.version < State::Version(1, 4, 0)) {
/* <1.4 */
String path = parser.get_attribute_value("source").strip_edges();
- 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
- image.path=GlobalConfig::get_singleton()->localize_path(state.local_path.get_base_dir()+"/"+path.percent_decode());
-
+ image.path = GlobalConfig::get_singleton()->localize_path(state.local_path.get_base_dir() + "/" + path.percent_decode());
}
} else {
+ while (parser.read() == OK) {
- while(parser.read()==OK) {
-
-
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
String name = parser.get_node_name();
- if (name=="init_from") {
+ if (name == "init_from") {
parser.read();
String path = parser.get_node_data().strip_edges().percent_decode();
- 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=GlobalConfig::get_singleton()->localize_path(state.local_path.get_base_dir()+"/"+path);
+ path = GlobalConfig::get_singleton()->localize_path(state.local_path.get_base_dir() + "/" + path);
- } else if (path.find("file:///")==0) {
- path=path.replace_first("file:///","");
- path=GlobalConfig::get_singleton()->localize_path(path);
+ } else if (path.find("file:///") == 0) {
+ path = path.replace_first("file:///", "");
+ path = GlobalConfig::get_singleton()->localize_path(path);
}
- image.path=path;
+ image.path = path;
- } else if (name=="data") {
+ } else if (name == "data") {
ERR_PRINT("COLLADA Embedded image data not supported!");
- } else if (name=="extra" && !parser.is_empty())
+ } else if (name == "extra" && !parser.is_empty())
parser.skip_section();
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="image")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "image")
break; //end of <asset>
-
}
}
- state.image_map[id]=image;
+ state.image_map[id] = image;
}
-void Collada::_parse_material(XMLParser& parser) {
+void Collada::_parse_material(XMLParser &parser) {
- if (!(state.import_flags&IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
+ if (!parser.is_empty())
parser.skip_section();
return;
}
Material material;
- String id=parser.get_attribute_value("id");
+ String id = parser.get_attribute_value("id");
if (parser.has_attribute("name"))
- material.name=parser.get_attribute_value("name");
+ material.name = parser.get_attribute_value("name");
- if (state.version<State::Version(1,4,0)) {
+ if (state.version < State::Version(1, 4, 0)) {
/* <1.4 */
ERR_PRINT("Collada Materials < 1.4 are not supported (yet)");
} else {
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT && parser.get_node_name()=="instance_effect") {
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT && parser.get_node_name() == "instance_effect") {
- material.instance_effect=_uri_to_id(parser.get_attribute_value("url"));
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="material")
+ material.instance_effect = _uri_to_id(parser.get_attribute_value("url"));
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "material")
break; //end of <asset>
}
}
- state.material_map[id]=material;
+ state.material_map[id] = material;
}
//! reads floats from inside of xml element until end of xml element
-Vector<float> Collada::_read_float_array(XMLParser& parser) {
+Vector<float> Collada::_read_float_array(XMLParser &parser) {
if (parser.is_empty())
return Vector<float>();
@@ -413,103 +391,93 @@ Vector<float> Collada::_read_float_array(XMLParser& parser) {
splitters.push_back("\t");
Vector<float> array;
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
// TODO: check for comments inside the element
// and ignore them.
if (parser.get_node_type() == XMLParser::NODE_TEXT) {
// parse float data
String str = parser.get_node_data();
- array=str.split_floats_mk(splitters,false);
+ array = str.split_floats_mk(splitters, false);
//array=str.split_floats(" ",false);
- }
- else
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
break; // end parsing text
}
return array;
}
-Vector<String> Collada::_read_string_array(XMLParser& parser) {
+Vector<String> Collada::_read_string_array(XMLParser &parser) {
if (parser.is_empty())
return Vector<String>();
Vector<String> array;
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
// TODO: check for comments inside the element
// and ignore them.
if (parser.get_node_type() == XMLParser::NODE_TEXT) {
// parse String data
String str = parser.get_node_data();
- array=str.split_spaces();
+ array = str.split_spaces();
/*
for(int i=0;i<array.size();i++) {
print_line(itos(i)+": "+array[i]);
}
*/
- }
- else
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
break; // end parsing text
}
return array;
}
-
-
-Transform Collada::_read_transform(XMLParser& parser) {
+Transform Collada::_read_transform(XMLParser &parser) {
if (parser.is_empty())
return Transform();
Vector<String> array;
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
// TODO: check for comments inside the element
// and ignore them.
if (parser.get_node_type() == XMLParser::NODE_TEXT) {
// parse float data
String str = parser.get_node_data();
- array=str.split_spaces();
- }
- else
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
+ array = str.split_spaces();
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
break; // end parsing text
}
- ERR_FAIL_COND_V(array.size()!=16,Transform());
+ ERR_FAIL_COND_V(array.size() != 16, Transform());
Vector<float> farr;
farr.resize(16);
- for(int i=0;i<16;i++) {
- farr[i]=array[i].to_double();
+ for (int i = 0; i < 16; i++) {
+ farr[i] = array[i].to_double();
}
return _read_transform_from_array(farr);
}
-String Collada::_read_empty_draw_type(XMLParser& parser) {
+String Collada::_read_empty_draw_type(XMLParser &parser) {
String empty_draw_type = "";
-
+
if (parser.is_empty())
return empty_draw_type;
-
- while (parser.read()==OK) {
+
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_TEXT) {
empty_draw_type = parser.get_node_data();
- }
- else
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
break; // end parsing text
}
return empty_draw_type;
}
-Variant Collada::_parse_param(XMLParser& parser) {
+Variant Collada::_parse_param(XMLParser &parser) {
if (parser.is_empty())
return Variant();
@@ -517,197 +485,182 @@ Variant Collada::_parse_param(XMLParser& parser) {
String from = parser.get_node_name();
Variant data;
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
if (parser.get_node_name() == "float") {
parser.read();
- if (parser.get_node_type()==XMLParser::NODE_TEXT) {
+ if (parser.get_node_type() == XMLParser::NODE_TEXT) {
- data=parser.get_node_data().to_double();
+ data = parser.get_node_data().to_double();
}
} else if (parser.get_node_name() == "float2") {
Vector<float> v2 = _read_float_array(parser);
- if (v2.size()>=2) {
+ if (v2.size() >= 2) {
- data=Vector2(v2[0],v2[1]);
+ data = Vector2(v2[0], v2[1]);
}
} else if (parser.get_node_name() == "float3") {
Vector<float> v3 = _read_float_array(parser);
- if (v3.size()>=3) {
+ if (v3.size() >= 3) {
- data=Vector3(v3[0],v3[1],v3[2]);
+ data = Vector3(v3[0], v3[1], v3[2]);
}
} else if (parser.get_node_name() == "float4") {
Vector<float> v4 = _read_float_array(parser);
- if (v4.size()>=4) {
+ if (v4.size() >= 4) {
- data=Color(v4[0],v4[1],v4[2],v4[3]);
+ data = Color(v4[0], v4[1], v4[2], v4[3]);
}
} else if (parser.get_node_name() == "sampler2D") {
- while(parser.read()==OK) {
-
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="source") {
+ if (parser.get_node_name() == "source") {
parser.read();
if (parser.get_node_type() == XMLParser::NODE_TEXT) {
- data=parser.get_node_data();
+ data = parser.get_node_data();
}
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="sampler2D")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "sampler2D")
break;
-
}
} else if (parser.get_node_name() == "surface") {
- while(parser.read()==OK) {
-
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="init_from") {
+ if (parser.get_node_name() == "init_from") {
parser.read();
if (parser.get_node_type() == XMLParser::NODE_TEXT) {
- data=parser.get_node_data();
+ data = parser.get_node_data();
}
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="surface")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "surface")
break;
-
}
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()==from)
- break;
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == from)
+ break;
}
- COLLADA_PRINT("newparam ending "+parser.get_node_name());
+ COLLADA_PRINT("newparam ending " + parser.get_node_name());
return data;
-
}
+void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String &id) {
-
-void Collada::_parse_effect_material(XMLParser& parser,Effect &effect,String &id) {
-
-
- if (!(state.import_flags&IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
+ if (!parser.is_empty())
parser.skip_section();
return;
}
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
// first come the tags we descend, but ignore the top-levels
- COLLADA_PRINT("node name: "+parser.get_node_name());
+ COLLADA_PRINT("node name: " + parser.get_node_name());
if (!parser.is_empty() && (parser.get_node_name() == "profile_COMMON" || parser.get_node_name() == "technique" || parser.get_node_name() == "extra")) {
- _parse_effect_material(parser,effect,id); // try again
+ _parse_effect_material(parser, effect, id); // try again
} else if (parser.get_node_name() == "newparam") {
String name = parser.get_attribute_value("sid");
Variant value = _parse_param(parser);
- effect.params[name]=value;
- COLLADA_PRINT("param: "+name+" value:"+String(value));
+ effect.params[name] = value;
+ COLLADA_PRINT("param: " + name + " value:" + String(value));
} else if (parser.get_node_name() == "constant" ||
- parser.get_node_name() == "lambert" ||
- parser.get_node_name() == "phong" ||
- parser.get_node_name() == "blinn" )
- {
-
- COLLADA_PRINT("shade model: "+parser.get_node_name());
- while(parser.read()==OK) {
+ parser.get_node_name() == "lambert" ||
+ parser.get_node_name() == "phong" ||
+ parser.get_node_name() == "blinn") {
+ COLLADA_PRINT("shade model: " + parser.get_node_name());
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
String what = parser.get_node_name();
- if ( what=="emission" ||
- what=="diffuse" ||
- what=="specular" ||
- what=="reflective") {
-
-
+ if (what == "emission" ||
+ what == "diffuse" ||
+ what == "specular" ||
+ what == "reflective") {
// color or texture types
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="color") {
+ if (parser.get_node_name() == "color") {
Vector<float> colorarr = _read_float_array(parser);
- COLLADA_PRINT("colorarr size: "+rtos(colorarr.size()));
+ COLLADA_PRINT("colorarr size: " + rtos(colorarr.size()));
- if (colorarr.size()>=3) {
+ if (colorarr.size() >= 3) {
// alpha strangely not allright? maybe it needs to be multiplied by value as a channel intensity
- Color color(colorarr[0],colorarr[1],colorarr[2],1.0);
- if (what=="diffuse")
- effect.diffuse.color=color;
- if (what=="specular")
- effect.specular.color=color;
- if (what=="emission")
- effect.emission.color=color;
-
- COLLADA_PRINT(what+" color: "+color);
-
+ Color color(colorarr[0], colorarr[1], colorarr[2], 1.0);
+ if (what == "diffuse")
+ effect.diffuse.color = color;
+ if (what == "specular")
+ effect.specular.color = color;
+ if (what == "emission")
+ effect.emission.color = color;
+
+ COLLADA_PRINT(what + " color: " + color);
}
- } else if (parser.get_node_name()=="texture") {
+ } else if (parser.get_node_name() == "texture") {
String sampler = parser.get_attribute_value("texture");
if (!effect.params.has(sampler)) {
- ERR_PRINT(String("Couldn't find sampler: "+sampler+" in material:"+id).utf8().get_data());
+ ERR_PRINT(String("Couldn't find sampler: " + sampler + " in material:" + id).utf8().get_data());
} else {
String surface = effect.params[sampler];
if (!effect.params.has(surface)) {
- ERR_PRINT(String("Couldn't find surface: "+surface+" in material:"+id).utf8().get_data());
+ ERR_PRINT(String("Couldn't find surface: " + surface + " in material:" + id).utf8().get_data());
} else {
String uri = effect.params[surface];
-
- if (what=="diffuse") {
- effect.diffuse.texture=uri;
- } else if (what=="specular") {
- effect.specular.texture=uri;
- } else if (what=="emission") {
- effect.emission.texture=uri;
- } else if (what=="bump") {
- if (parser.has_attribute("bumptype") && parser.get_attribute_value("bumptype")!="NORMALMAP") {
+ if (what == "diffuse") {
+ effect.diffuse.texture = uri;
+ } else if (what == "specular") {
+ effect.specular.texture = uri;
+ } else if (what == "emission") {
+ effect.emission.texture = uri;
+ } else if (what == "bump") {
+ if (parser.has_attribute("bumptype") && parser.get_attribute_value("bumptype") != "NORMALMAP") {
WARN_PRINT("'bump' texture type is not NORMALMAP, only NORMALMAP is supported.")
}
- effect.bump.texture=uri;
+ effect.bump.texture = uri;
}
- COLLADA_PRINT(what+" texture: "+uri);
+ COLLADA_PRINT(what + " texture: " + uri);
}
-
}
} else if (!parser.is_empty())
parser.skip_section();
@@ -716,63 +669,60 @@ void Collada::_parse_effect_material(XMLParser& parser,Effect &effect,String &id
break;
}
- } else if (what=="shininess") {
+ } else if (what == "shininess") {
#if 1
- effect.shininess=_parse_param(parser);
+ effect.shininess = _parse_param(parser);
#else
parser.read();
float shininess = parser.get_node_data().to_double();
- effect.shininess=shininess;
- COLLADA_PRINT("shininess: "+rtos(shininess));
+ effect.shininess = shininess;
+ COLLADA_PRINT("shininess: " + rtos(shininess));
#endif
-
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && (
- parser.get_node_name()=="constant" ||
- parser.get_node_name()=="lambert" ||
- parser.get_node_name()=="phong" ||
- parser.get_node_name()=="blinn"))
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && (parser.get_node_name() == "constant" ||
+ parser.get_node_name() == "lambert" ||
+ parser.get_node_name() == "phong" ||
+ parser.get_node_name() == "blinn"))
break;
}
- } else if (parser.get_node_name()=="double_sided" || parser.get_node_name()=="show_double_sided") { // colladamax / google earth
+ } else if (parser.get_node_name() == "double_sided" || parser.get_node_name() == "show_double_sided") { // colladamax / google earth
// 3DS Max / Google Earth double sided extension
parser.read();
- effect.found_double_sided=true;
- effect.double_sided=parser.get_node_data().to_int();
- COLLADA_PRINT("double sided: "+itos(parser.get_node_data().to_int()));
- } else if (parser.get_node_name()=="unshaded") {
+ effect.found_double_sided = true;
+ effect.double_sided = parser.get_node_data().to_int();
+ COLLADA_PRINT("double sided: " + itos(parser.get_node_data().to_int()));
+ } else if (parser.get_node_name() == "unshaded") {
parser.read();
- effect.unshaded=parser.get_node_data().to_int();
- } else if (parser.get_node_name()=="bump") {
+ effect.unshaded = parser.get_node_data().to_int();
+ } else if (parser.get_node_name() == "bump") {
// color or texture types
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="texture") {
+ if (parser.get_node_name() == "texture") {
String sampler = parser.get_attribute_value("texture");
if (!effect.params.has(sampler)) {
- ERR_PRINT(String("Couldn't find sampler: "+sampler+" in material:"+id).utf8().get_data());
+ ERR_PRINT(String("Couldn't find sampler: " + sampler + " in material:" + id).utf8().get_data());
} else {
String surface = effect.params[sampler];
if (!effect.params.has(surface)) {
- ERR_PRINT(String("Couldn't find surface: "+surface+" in material:"+id).utf8().get_data());
+ ERR_PRINT(String("Couldn't find surface: " + surface + " in material:" + id).utf8().get_data());
} else {
String uri = effect.params[surface];
- if (parser.has_attribute("bumptype") && parser.get_attribute_value("bumptype")!="NORMALMAP") {
+ if (parser.has_attribute("bumptype") && parser.get_attribute_value("bumptype") != "NORMALMAP") {
WARN_PRINT("'bump' texture type is not NORMALMAP, only NORMALMAP is supported.")
}
- effect.bump.texture=uri;
- COLLADA_PRINT(" bump: "+uri);
+ effect.bump.texture = uri;
+ COLLADA_PRINT(" bump: " + uri);
}
-
}
} else if (!parser.is_empty())
parser.skip_section();
@@ -784,204 +734,189 @@ void Collada::_parse_effect_material(XMLParser& parser,Effect &effect,String &id
} else if (!parser.is_empty())
parser.skip_section();
} else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END &&
- (parser.get_node_name() == "effect" ||
- parser.get_node_name() == "profile_COMMON" ||
- parser.get_node_name() == "technique" ||
- parser.get_node_name() == "extra"))
+ (parser.get_node_name() == "effect" ||
+ parser.get_node_name() == "profile_COMMON" ||
+ parser.get_node_name() == "technique" ||
+ parser.get_node_name() == "extra"))
break;
}
-
}
-void Collada::_parse_effect(XMLParser& parser) {
+void Collada::_parse_effect(XMLParser &parser) {
- if (!(state.import_flags&IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
+ if (!parser.is_empty())
parser.skip_section();
return;
}
- String id=parser.get_attribute_value("id");
+ String id = parser.get_attribute_value("id");
Effect effect;
if (parser.has_attribute("name"))
- effect.name=parser.get_attribute_value("name");
- _parse_effect_material(parser,effect,id);
-
-
+ effect.name = parser.get_attribute_value("name");
+ _parse_effect_material(parser, effect, id);
- state.effect_map[id]=effect;
-
- COLLADA_PRINT("Effect ID:"+id);
+ state.effect_map[id] = effect;
+ COLLADA_PRINT("Effect ID:" + id);
}
-void Collada::_parse_camera(XMLParser& parser) {
+void Collada::_parse_camera(XMLParser &parser) {
- if (!(state.import_flags&IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
+ if (!parser.is_empty())
parser.skip_section();
return;
}
- String id=parser.get_attribute_value("id");
-
-
- state.camera_data_map[id]=CameraData();
- CameraData &camera=state.camera_data_map[id];
+ String id = parser.get_attribute_value("id");
+ state.camera_data_map[id] = CameraData();
+ CameraData &camera = state.camera_data_map[id];
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
-
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
String name = parser.get_node_name();
- if (name=="perspective") {
+ if (name == "perspective") {
- camera.mode=CameraData::MODE_PERSPECTIVE;
- } else if (name=="orthographic") {
+ camera.mode = CameraData::MODE_PERSPECTIVE;
+ } else if (name == "orthographic") {
- camera.mode=CameraData::MODE_ORTHOGONAL;
- } else if (name=="xfov") {
+ camera.mode = CameraData::MODE_ORTHOGONAL;
+ } else if (name == "xfov") {
parser.read();
camera.perspective.x_fov = parser.get_node_data().to_double();
- } else if (name=="yfov") {
+ } else if (name == "yfov") {
parser.read();
camera.perspective.y_fov = parser.get_node_data().to_double();
- } else if (name=="xmag") {
+ } else if (name == "xmag") {
parser.read();
camera.orthogonal.x_mag = parser.get_node_data().to_double();
- } else if (name=="ymag") {
+ } else if (name == "ymag") {
parser.read();
camera.orthogonal.y_mag = parser.get_node_data().to_double();
- } else if (name=="aspect_ratio") {
+ } else if (name == "aspect_ratio") {
parser.read();
camera.aspect = parser.get_node_data().to_double();
- } else if (name=="znear") {
+ } else if (name == "znear") {
parser.read();
camera.z_near = parser.get_node_data().to_double();
- } else if (name=="zfar") {
+ } else if (name == "zfar") {
parser.read();
camera.z_far = parser.get_node_data().to_double();
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="camera")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "camera")
break; //end of <asset>
}
- COLLADA_PRINT("Camera ID:"+id);
-
+ COLLADA_PRINT("Camera ID:" + id);
}
-void Collada::_parse_light(XMLParser& parser) {
+void Collada::_parse_light(XMLParser &parser) {
- if (!(state.import_flags&IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
+ if (!parser.is_empty())
parser.skip_section();
return;
}
- String id=parser.get_attribute_value("id");
-
+ String id = parser.get_attribute_value("id");
- state.light_data_map[id]=LightData();
- LightData &light=state.light_data_map[id];
+ state.light_data_map[id] = LightData();
+ LightData &light = state.light_data_map[id];
+ while (parser.read() == OK) {
- while(parser.read()==OK) {
-
-
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
String name = parser.get_node_name();
- if (name=="ambient") {
+ if (name == "ambient") {
- light.mode=LightData::MODE_AMBIENT;
- } else if (name=="directional") {
+ light.mode = LightData::MODE_AMBIENT;
+ } else if (name == "directional") {
- light.mode=LightData::MODE_DIRECTIONAL;
- } else if (name=="point") {
+ light.mode = LightData::MODE_DIRECTIONAL;
+ } else if (name == "point") {
- light.mode=LightData::MODE_OMNI;
- } else if (name=="spot") {
+ light.mode = LightData::MODE_OMNI;
+ } else if (name == "spot") {
- light.mode=LightData::MODE_SPOT;
- } else if (name=="color") {
+ light.mode = LightData::MODE_SPOT;
+ } else if (name == "color") {
parser.read();
Vector<float> colorarr = _read_float_array(parser);
- COLLADA_PRINT("colorarr size: "+rtos(colorarr.size()));
+ COLLADA_PRINT("colorarr size: " + rtos(colorarr.size()));
- if (colorarr.size()>=4) {
+ if (colorarr.size() >= 4) {
// alpha strangely not allright? maybe it needs to be multiplied by value as a channel intensity
- Color color(colorarr[0],colorarr[1],colorarr[2],1.0);
- light.color=color;
+ Color color(colorarr[0], colorarr[1], colorarr[2], 1.0);
+ light.color = color;
}
- } else if (name=="constant_attenuation") {
+ } else if (name == "constant_attenuation") {
parser.read();
- light.constant_att=parser.get_node_data().to_double();
- } else if (name=="linear_attenuation") {
+ light.constant_att = parser.get_node_data().to_double();
+ } else if (name == "linear_attenuation") {
parser.read();
- light.linear_att=parser.get_node_data().to_double();
- } else if (name=="quadratic_attenuation") {
+ light.linear_att = parser.get_node_data().to_double();
+ } else if (name == "quadratic_attenuation") {
parser.read();
- light.quad_att=parser.get_node_data().to_double();
- } else if (name=="falloff_angle") {
+ light.quad_att = parser.get_node_data().to_double();
+ } else if (name == "falloff_angle") {
parser.read();
- light.spot_angle= parser.get_node_data().to_double();
+ light.spot_angle = parser.get_node_data().to_double();
- } else if (name=="falloff_exponent") {
+ } else if (name == "falloff_exponent") {
parser.read();
- light.spot_exp= parser.get_node_data().to_double();
+ light.spot_exp = parser.get_node_data().to_double();
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="light")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "light")
break; //end of <asset>
}
- COLLADA_PRINT("Light ID:"+id);
-
+ COLLADA_PRINT("Light ID:" + id);
}
+void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_name) {
-void Collada::_parse_curve_geometry(XMLParser& parser,String p_id,String p_name) {
-
-
- if (!(state.import_flags&IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
+ if (!parser.is_empty())
parser.skip_section();
return;
}
//load everything into a pre dictionary
- state.curve_data_map[p_id]=CurveData();
+ state.curve_data_map[p_id] = CurveData();
CurveData &curvedata = state.curve_data_map[p_id];
- curvedata.name=p_name;
-
- COLLADA_PRINT("curve name: "+p_name);
+ curvedata.name = p_name;
+ COLLADA_PRINT("curve name: " + p_name);
String current_source;
// handles geometry node and the curve childs in this loop
@@ -990,32 +925,32 @@ void Collada::_parse_curve_geometry(XMLParser& parser,String p_id,String p_name)
return;
}
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- String section = parser.get_node_name();
+ String section = parser.get_node_name();
if (section == "source") {
- String id=parser.get_attribute_value("id");
- curvedata.sources[id]=CurveData::Source();
- current_source=id;
- COLLADA_PRINT("source data: "+id);
+ String id = parser.get_attribute_value("id");
+ curvedata.sources[id] = CurveData::Source();
+ current_source = id;
+ COLLADA_PRINT("source data: " + id);
- } else if (section=="float_array" || section=="array") {
+ } else if (section == "float_array" || section == "array") {
// create a new array and read it.
if (curvedata.sources.has(current_source)) {
curvedata.sources[current_source].array = _read_float_array(parser);
- COLLADA_PRINT("section: "+current_source+" read "+itos(curvedata.sources[current_source].array.size())+" values.");
+ COLLADA_PRINT("section: " + current_source + " read " + itos(curvedata.sources[current_source].array.size()) + " values.");
}
- } else if (section=="Name_array") {
+ } else if (section == "Name_array") {
// create a new array and read it.
if (curvedata.sources.has(current_source)) {
curvedata.sources[current_source].sarray = _read_string_array(parser);
- COLLADA_PRINT("section: "+current_source+" read "+itos(curvedata.sources[current_source].array.size())+" values.");
+ COLLADA_PRINT("section: " + current_source + " read " + itos(curvedata.sources[current_source].array.size()) + " values.");
}
} else if (section == "technique_common") {
@@ -1023,61 +958,53 @@ void Collada::_parse_curve_geometry(XMLParser& parser,String p_id,String p_name)
} else if (section == "accessor") { // child of source (below a technique tag)
if (curvedata.sources.has(current_source)) {
- curvedata.sources[current_source].stride=parser.get_attribute_value("stride").to_int();
- COLLADA_PRINT("section: "+current_source+" stride "+itos(curvedata.sources[current_source].stride));
+ curvedata.sources[current_source].stride = parser.get_attribute_value("stride").to_int();
+ COLLADA_PRINT("section: " + current_source + " stride " + itos(curvedata.sources[current_source].stride));
}
} else if (section == "control_vertices") {
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="input") {
+ if (parser.get_node_name() == "input") {
String semantic = parser.get_attribute_value("semantic");
- String source =_uri_to_id( parser.get_attribute_value("source") );
-
- curvedata.control_vertices[semantic]=source;
+ String source = _uri_to_id(parser.get_attribute_value("source"));
- COLLADA_PRINT(section+" input semantic: "+semantic+" source: "+source);
+ curvedata.control_vertices[semantic] = source;
+ COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()==section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
break;
}
- } else if (!parser.is_empty()){
+ } else if (!parser.is_empty()) {
parser.skip_section();
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="spline")
- break;
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "spline")
+ break;
}
-
-
-
}
+void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name) {
-
-void Collada::_parse_mesh_geometry(XMLParser& parser,String p_id,String p_name) {
-
-
- if (!(state.import_flags&IMPORT_FLAG_SCENE)) {
- if (!parser.is_empty())
+ if (!(state.import_flags & IMPORT_FLAG_SCENE)) {
+ if (!parser.is_empty())
parser.skip_section();
return;
}
//load everything into a pre dictionary
- state.mesh_data_map[p_id]=MeshData();
+ state.mesh_data_map[p_id] = MeshData();
MeshData &meshdata = state.mesh_data_map[p_id];
- meshdata.name=p_name;
-
- COLLADA_PRINT("mesh name: "+p_name);
+ meshdata.name = p_name;
+ COLLADA_PRINT("mesh name: " + p_name);
String current_source;
// handles geometry node and the mesh childs in this loop
@@ -1086,130 +1013,124 @@ void Collada::_parse_mesh_geometry(XMLParser& parser,String p_id,String p_name)
return;
}
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
-
- String section = parser.get_node_name();
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
+ String section = parser.get_node_name();
if (section == "source") {
- String id=parser.get_attribute_value("id");
- meshdata.sources[id]=MeshData::Source();
- current_source=id;
- COLLADA_PRINT("source data: "+id);
+ String id = parser.get_attribute_value("id");
+ meshdata.sources[id] = MeshData::Source();
+ current_source = id;
+ COLLADA_PRINT("source data: " + id);
- } else if (section=="float_array" || section=="array") {
+ } else if (section == "float_array" || section == "array") {
// create a new array and read it.
if (meshdata.sources.has(current_source)) {
meshdata.sources[current_source].array = _read_float_array(parser);
- COLLADA_PRINT("section: "+current_source+" read "+itos(meshdata.sources[current_source].array.size())+" values.");
+ COLLADA_PRINT("section: " + current_source + " read " + itos(meshdata.sources[current_source].array.size()) + " values.");
}
} else if (section == "technique_common") {
//skip it
} else if (section == "accessor") { // child of source (below a technique tag)
if (meshdata.sources.has(current_source)) {
- meshdata.sources[current_source].stride=parser.get_attribute_value("stride").to_int();
- COLLADA_PRINT("section: "+current_source+" stride "+itos(meshdata.sources[current_source].stride));
+ meshdata.sources[current_source].stride = parser.get_attribute_value("stride").to_int();
+ COLLADA_PRINT("section: " + current_source + " stride " + itos(meshdata.sources[current_source].stride));
}
} else if (section == "vertices") {
MeshData::Vertices vert;
- String id = parser.get_attribute_value("id");
+ String id = parser.get_attribute_value("id");
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="input") {
+ if (parser.get_node_name() == "input") {
String semantic = parser.get_attribute_value("semantic");
- String source =_uri_to_id( parser.get_attribute_value("source") );
-
- vert.sources[semantic]=source;
+ String source = _uri_to_id(parser.get_attribute_value("source"));
- COLLADA_PRINT(section+" input semantic: "+semantic+" source: "+source);
+ vert.sources[semantic] = source;
+ COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()==section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
break;
}
- meshdata.vertices[id]=vert;
+ meshdata.vertices[id] = vert;
- } else if (section =="triangles" || section=="polylist" || section=="polygons") {
+ } else if (section == "triangles" || section == "polylist" || section == "polygons") {
- bool polygons=(section=="polygons");
+ bool polygons = (section == "polygons");
if (polygons) {
WARN_PRINT("Primitive type \"polygons\" is not well supported (concave shapes may fail). To ensure that the geometry is properly imported, please re-export using \"triangles\" or \"polylist\".");
}
MeshData::Primitives prim;
if (parser.has_attribute("material"))
- prim.material=parser.get_attribute_value("material");
- prim.count=parser.get_attribute_value("count").to_int();
- prim.vertex_size=0;
- int last_ref=0;
+ prim.material = parser.get_attribute_value("material");
+ prim.count = parser.get_attribute_value("count").to_int();
+ prim.vertex_size = 0;
+ int last_ref = 0;
-
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="input") {
+ if (parser.get_node_name() == "input") {
String semantic = parser.get_attribute_value("semantic");
- String source =_uri_to_id( parser.get_attribute_value("source") );
+ String source = _uri_to_id(parser.get_attribute_value("source"));
- if (semantic=="TEXCOORD") {
+ if (semantic == "TEXCOORD") {
/*
if (parser.has_attribute("set"))// a texcoord
semantic+=parser.get_attribute_value("set");
else
semantic="TEXCOORD0";*/
- semantic="TEXCOORD"+itos(last_ref++);
+ semantic = "TEXCOORD" + itos(last_ref++);
}
int offset = parser.get_attribute_value("offset").to_int();
-
MeshData::Primitives::SourceRef sref;
- sref.source=source;
- sref.offset=offset;
- prim.sources[semantic]=sref;
- prim.vertex_size=MAX(prim.vertex_size,offset+1);
+ sref.source = source;
+ sref.offset = offset;
+ prim.sources[semantic] = sref;
+ prim.vertex_size = MAX(prim.vertex_size, offset + 1);
- COLLADA_PRINT(section+" input semantic: "+semantic+" source: "+source+" offset: "+itos(offset));
+ COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source + " offset: " + itos(offset));
-
- } else if (parser.get_node_name()=="p") { //indices
+ } else if (parser.get_node_name() == "p") { //indices
Vector<float> values = _read_float_array(parser);
if (polygons) {
- prim.polygons.push_back(values.size()/prim.vertex_size);
+ prim.polygons.push_back(values.size() / prim.vertex_size);
int from = prim.indices.size();
- prim.indices.resize(from+values.size());
- for(int i=0;i<values.size();i++)
- prim.indices[from+i]=values[i];
+ prim.indices.resize(from + values.size());
+ for (int i = 0; i < values.size(); i++)
+ prim.indices[from + i] = values[i];
- } else if (prim.vertex_size>0){
- prim.indices=values;
+ } else if (prim.vertex_size > 0) {
+ prim.indices = values;
}
- COLLADA_PRINT("read "+itos(values.size())+" index values");
+ COLLADA_PRINT("read " + itos(values.size()) + " index values");
- } else if (parser.get_node_name()=="vcount") { // primitive
+ } else if (parser.get_node_name() == "vcount") { // primitive
Vector<float> values = _read_float_array(parser);
- prim.polygons=values;
- COLLADA_PRINT("read "+itos(values.size())+" polygon values");
+ prim.polygons = values;
+ COLLADA_PRINT("read " + itos(values.size()) + " polygon values");
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()==section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
break;
-
}
meshdata.primitives.push_back(prim);
@@ -1217,76 +1138,72 @@ void Collada::_parse_mesh_geometry(XMLParser& parser,String p_id,String p_name)
} else if (parser.get_node_name() == "double_sided") {
parser.read();
- meshdata.found_double_sided=true;
- meshdata.double_sided=parser.get_node_data().to_int();
+ meshdata.found_double_sided = true;
+ meshdata.double_sided = parser.get_node_data().to_int();
} else if (parser.get_node_name() == "polygons") {
ERR_PRINT("Primitive type \"polygons\" not supported, re-export using \"polylist\" or \"triangles\".");
- } else if (!parser.is_empty()){
+ } else if (!parser.is_empty()) {
parser.skip_section();
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="mesh")
- break;
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "mesh")
+ break;
}
-
-
-
}
-void Collada::_parse_skin_controller(XMLParser& parser,String p_id) {
+void Collada::_parse_skin_controller(XMLParser &parser, String p_id) {
- state.skin_controller_data_map[p_id]=SkinControllerData();
+ state.skin_controller_data_map[p_id] = SkinControllerData();
SkinControllerData &skindata = state.skin_controller_data_map[p_id];
- skindata.base=_uri_to_id(parser.get_attribute_value("source"));
+ skindata.base = _uri_to_id(parser.get_attribute_value("source"));
String current_source;
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT){
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- String section = parser.get_node_name();
+ String section = parser.get_node_name();
- if (section=="bind_shape_matrix") {
+ if (section == "bind_shape_matrix") {
- skindata.bind_shape=_read_transform(parser);
+ skindata.bind_shape = _read_transform(parser);
#ifdef COLLADA_IMPORT_SCALE_SCENE
skindata.bind_shape.origin *= state.unit_scale;
#endif
- COLLADA_PRINT("skeleton bind shape transform: "+skindata.bind_shape);
-
+ COLLADA_PRINT("skeleton bind shape transform: " + skindata.bind_shape);
} else if (section == "source") {
- String id=parser.get_attribute_value("id");
- skindata.sources[id]=SkinControllerData::Source();
- current_source=id;
- COLLADA_PRINT("source data: "+id);
+ String id = parser.get_attribute_value("id");
+ skindata.sources[id] = SkinControllerData::Source();
+ current_source = id;
+ COLLADA_PRINT("source data: " + id);
- } else if (section=="float_array" || section=="array") {
+ } else if (section == "float_array" || section == "array") {
// create a new array and read it.
if (skindata.sources.has(current_source)) {
skindata.sources[current_source].array = _read_float_array(parser);
- COLLADA_PRINT("section: "+current_source+" read "+itos(skindata.sources[current_source].array.size())+" values.");
+ COLLADA_PRINT("section: " + current_source + " read " + itos(skindata.sources[current_source].array.size()) + " values.");
}
- } else if (section=="Name_array" || section=="IDREF_array") {
+ } else if (section == "Name_array" || section == "IDREF_array") {
// create a new array and read it.
- if (section=="IDREF_array")
- skindata.use_idrefs=true;
+ if (section == "IDREF_array")
+ skindata.use_idrefs = true;
if (skindata.sources.has(current_source)) {
skindata.sources[current_source].sarray = _read_string_array(parser);
- if (section=="IDREF_array") {
+ if (section == "IDREF_array") {
Vector<String> sa = skindata.sources[current_source].sarray;
- for(int i=0;i<sa.size();i++)
+ for (int i = 0; i < sa.size(); i++)
state.idref_joints.insert(sa[i]);
}
- COLLADA_PRINT("section: "+current_source+" read "+itos(skindata.sources[current_source].array.size())+" values.");
+ COLLADA_PRINT("section: " + current_source + " read " + itos(skindata.sources[current_source].array.size()) + " values.");
}
} else if (section == "technique_common") {
//skip it
@@ -1294,90 +1211,86 @@ void Collada::_parse_skin_controller(XMLParser& parser,String p_id) {
if (skindata.sources.has(current_source)) {
- int stride=1;
+ int stride = 1;
if (parser.has_attribute("stride"))
- stride=parser.get_attribute_value("stride").to_int();
+ stride = parser.get_attribute_value("stride").to_int();
- skindata.sources[current_source].stride=stride;
- COLLADA_PRINT("section: "+current_source+" stride "+itos(skindata.sources[current_source].stride));
+ skindata.sources[current_source].stride = stride;
+ COLLADA_PRINT("section: " + current_source + " stride " + itos(skindata.sources[current_source].stride));
}
} else if (section == "joints") {
SkinControllerData::Joints joint;
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="input") {
+ if (parser.get_node_name() == "input") {
String semantic = parser.get_attribute_value("semantic");
- String source =_uri_to_id( parser.get_attribute_value("source") );
-
- joint.sources[semantic]=source;
+ String source = _uri_to_id(parser.get_attribute_value("source"));
- COLLADA_PRINT(section+" input semantic: "+semantic+" source: "+source);
+ joint.sources[semantic] = source;
+ COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()==section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
break;
}
- skindata.joints=joint;
+ skindata.joints = joint;
- } else if (section=="vertex_weights") {
+ } else if (section == "vertex_weights") {
SkinControllerData::Weights weights;
- weights.count=parser.get_attribute_value("count").to_int();
+ weights.count = parser.get_attribute_value("count").to_int();
-
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="input") {
+ if (parser.get_node_name() == "input") {
String semantic = parser.get_attribute_value("semantic");
- String source =_uri_to_id( parser.get_attribute_value("source") );
+ String source = _uri_to_id(parser.get_attribute_value("source"));
int offset = parser.get_attribute_value("offset").to_int();
SkinControllerData::Weights::SourceRef sref;
- sref.source=source;
- sref.offset=offset;
- weights.sources[semantic]=sref;
+ sref.source = source;
+ sref.offset = offset;
+ weights.sources[semantic] = sref;
- COLLADA_PRINT(section+" input semantic: "+semantic+" source: "+source+" offset: "+itos(offset));
+ COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source + " offset: " + itos(offset));
- } else if (parser.get_node_name()=="v") { //indices
+ } else if (parser.get_node_name() == "v") { //indices
Vector<float> values = _read_float_array(parser);
- weights.indices=values;
- COLLADA_PRINT("read "+itos(values.size())+" index values");
+ weights.indices = values;
+ COLLADA_PRINT("read " + itos(values.size()) + " index values");
- } else if (parser.get_node_name()=="vcount") { // weightsitive
+ } else if (parser.get_node_name() == "vcount") { // weightsitive
Vector<float> values = _read_float_array(parser);
- weights.sets=values;
- COLLADA_PRINT("read "+itos(values.size())+" polygon values");
+ weights.sets = values;
+ COLLADA_PRINT("read " + itos(values.size()) + " polygon values");
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()==section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
break;
-
}
- skindata.weights=weights;
-
+ skindata.weights = weights;
}
/*
else if (!parser.is_empty())
parser.skip_section();
*/
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="skin")
- break;
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "skin")
+ break;
}
/* STORE REST MATRICES */
@@ -1395,57 +1308,53 @@ void Collada::_parse_skin_controller(XMLParser& parser,String p_id) {
SkinControllerData::Source &joint_source = skindata.sources[joint_arr];
SkinControllerData::Source &ibm_source = skindata.sources[ibm];
+ ERR_FAIL_COND(joint_source.sarray.size() != ibm_source.array.size() / 16);
-
- ERR_FAIL_COND(joint_source.sarray.size() != ibm_source.array.size()/16);
-
- for(int i=0;i<joint_source.sarray.size();i++) {
+ for (int i = 0; i < joint_source.sarray.size(); i++) {
String name = joint_source.sarray[i];
- Transform xform = _read_transform_from_array(ibm_source.array,i*16); //<- this is a mistake, it must be applied to vertices
+ Transform xform = _read_transform_from_array(ibm_source.array, i * 16); //<- this is a mistake, it must be applied to vertices
xform.affine_invert(); // inverse for rest, because it's an inverse
#ifdef COLLADA_IMPORT_SCALE_SCENE
- xform.origin*=state.unit_scale;
+ xform.origin *= state.unit_scale;
#endif
- skindata.bone_rest_map[name]=xform;
+ skindata.bone_rest_map[name] = xform;
}
-
-
}
-void Collada::_parse_morph_controller(XMLParser& parser, String p_id) {
+void Collada::_parse_morph_controller(XMLParser &parser, String p_id) {
- state.morph_controller_data_map[p_id]=MorphControllerData();
+ state.morph_controller_data_map[p_id] = MorphControllerData();
MorphControllerData &morphdata = state.morph_controller_data_map[p_id];
- print_line("morph source: "+parser.get_attribute_value("source")+" id: "+p_id);
- morphdata.mesh=_uri_to_id(parser.get_attribute_value("source"));
- print_line("morph source2: "+morphdata.mesh);
- morphdata.mode=parser.get_attribute_value("method");
- printf("JJmorph: %p\n",&morphdata);
+ print_line("morph source: " + parser.get_attribute_value("source") + " id: " + p_id);
+ morphdata.mesh = _uri_to_id(parser.get_attribute_value("source"));
+ print_line("morph source2: " + morphdata.mesh);
+ morphdata.mode = parser.get_attribute_value("method");
+ printf("JJmorph: %p\n", &morphdata);
String current_source;
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT){
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- String section = parser.get_node_name();
+ String section = parser.get_node_name();
if (section == "source") {
- String id=parser.get_attribute_value("id");
- morphdata.sources[id]=MorphControllerData::Source();
- current_source=id;
- COLLADA_PRINT("source data: "+id);
+ String id = parser.get_attribute_value("id");
+ morphdata.sources[id] = MorphControllerData::Source();
+ current_source = id;
+ COLLADA_PRINT("source data: " + id);
- } else if (section=="float_array" || section=="array") {
+ } else if (section == "float_array" || section == "array") {
// create a new array and read it.
if (morphdata.sources.has(current_source)) {
morphdata.sources[current_source].array = _read_float_array(parser);
- COLLADA_PRINT("section: "+current_source+" read "+itos(morphdata.sources[current_source].array.size())+" values.");
+ COLLADA_PRINT("section: " + current_source + " read " + itos(morphdata.sources[current_source].array.size()) + " values.");
}
- } else if (section=="Name_array" || section=="IDREF_array") {
+ } else if (section == "Name_array" || section == "IDREF_array") {
// create a new array and read it.
/*
@@ -1461,7 +1370,7 @@ void Collada::_parse_morph_controller(XMLParser& parser, String p_id) {
for(int i=0;i<sa.size();i++)
state.idref_joints.insert(sa[i]);
}*/
- COLLADA_PRINT("section: "+current_source+" read "+itos(morphdata.sources[current_source].array.size())+" values.");
+ COLLADA_PRINT("section: " + current_source + " read " + itos(morphdata.sources[current_source].array.size()) + " values.");
}
} else if (section == "technique_common") {
//skip it
@@ -1469,119 +1378,106 @@ void Collada::_parse_morph_controller(XMLParser& parser, String p_id) {
if (morphdata.sources.has(current_source)) {
- int stride=1;
+ int stride = 1;
if (parser.has_attribute("stride"))
- stride=parser.get_attribute_value("stride").to_int();
+ stride = parser.get_attribute_value("stride").to_int();
- morphdata.sources[current_source].stride=stride;
- COLLADA_PRINT("section: "+current_source+" stride "+itos(morphdata.sources[current_source].stride));
+ morphdata.sources[current_source].stride = stride;
+ COLLADA_PRINT("section: " + current_source + " stride " + itos(morphdata.sources[current_source].stride));
}
} else if (section == "targets") {
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="input") {
+ if (parser.get_node_name() == "input") {
String semantic = parser.get_attribute_value("semantic");
- String source =_uri_to_id( parser.get_attribute_value("source") );
-
- morphdata.targets[semantic]=source;
+ String source = _uri_to_id(parser.get_attribute_value("source"));
- COLLADA_PRINT(section+" input semantic: "+semantic+" source: "+source);
+ morphdata.targets[semantic] = source;
+ COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()==section)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section)
break;
}
-
-
}
/*
else if (!parser.is_empty())
parser.skip_section();
*/
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="morph")
- break;
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "morph")
+ break;
}
-
if (morphdata.targets.has("MORPH_WEIGHT")) {
- state.morph_name_map[ morphdata.targets["MORPH_WEIGHT"] ] = p_id;
+ state.morph_name_map[morphdata.targets["MORPH_WEIGHT"]] = p_id;
}
-
}
-void Collada::_parse_controller(XMLParser& parser) {
+void Collada::_parse_controller(XMLParser &parser) {
- String id=parser.get_attribute_value("id");
+ String id = parser.get_attribute_value("id");
if (parser.is_empty()) {
return;
}
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT){
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- String section = parser.get_node_name();
+ String section = parser.get_node_name();
- if (section=="skin") {
- _parse_skin_controller(parser,id);
+ if (section == "skin") {
+ _parse_skin_controller(parser, id);
} else if (section == "morph") {
- _parse_morph_controller(parser,id);
+ _parse_morph_controller(parser, id);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="controller")
- break;
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "controller")
+ break;
}
-
-
}
-
-Collada::Node* Collada::_parse_visual_instance_geometry(XMLParser& parser) {
+Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) {
String type = parser.get_node_name();
- NodeGeometry *geom=memnew( NodeGeometry );
- geom->controller=type=="instance_controller";
+ NodeGeometry *geom = memnew(NodeGeometry);
+ geom->controller = type == "instance_controller";
geom->source = _uri_to_id(parser.get_attribute_value_safe("url"));
-
-
if (parser.is_empty()) //nothing else to parse...
return geom;
// try to find also many materials and skeletons!
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="instance_material") {
+ if (parser.get_node_name() == "instance_material") {
- String symbol=parser.get_attribute_value("symbol");
- String target=_uri_to_id(parser.get_attribute_value("target"));
+ String symbol = parser.get_attribute_value("symbol");
+ String target = _uri_to_id(parser.get_attribute_value("target"));
NodeGeometry::Material mat;
- mat.target=target;
- geom->material_map[symbol]=mat;
- COLLADA_PRINT("uses material: '"+target+"' on primitive'"+symbol+"'");
- } else if (parser.get_node_name()=="skeleton") {
+ mat.target = target;
+ geom->material_map[symbol] = mat;
+ COLLADA_PRINT("uses material: '" + target + "' on primitive'" + symbol + "'");
+ } else if (parser.get_node_name() == "skeleton") {
parser.read();
String uri = _uri_to_id(parser.get_node_data());
- if (uri!="") {
+ if (uri != "") {
geom->skeletons.push_back(uri);
}
-
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()==type)
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == type)
break;
-
-
}
if (geom->controller) {
@@ -1592,223 +1488,214 @@ Collada::Node* Collada::_parse_visual_instance_geometry(XMLParser& parser) {
if (state.skin_controller_data_map.has(geom->source)) {
SkinControllerData *skin = &state.skin_controller_data_map[geom->source];
//case where skeletons reference bones with IDREF (XSI)
- ERR_FAIL_COND_V(!skin->joints.sources.has("JOINT"),geom);
+ ERR_FAIL_COND_V(!skin->joints.sources.has("JOINT"), geom);
String joint_arr = skin->joints.sources["JOINT"];
- ERR_FAIL_COND_V(!skin->sources.has(joint_arr),geom);
+ ERR_FAIL_COND_V(!skin->sources.has(joint_arr), geom);
Collada::SkinControllerData::Source &joint_source = skin->sources[joint_arr];
- geom->skeletons=joint_source.sarray; //quite crazy, but should work.
+ geom->skeletons = joint_source.sarray; //quite crazy, but should work.
}
-
}
-
}
return geom;
}
-
-Collada::Node* Collada::_parse_visual_instance_camera(XMLParser& parser) {
+Collada::Node *Collada::_parse_visual_instance_camera(XMLParser &parser) {
String type = parser.get_node_name();
- NodeCamera *cam=memnew( NodeCamera );
- cam->camera= _uri_to_id(parser.get_attribute_value_safe("url"));
+ NodeCamera *cam = memnew(NodeCamera);
+ cam->camera = _uri_to_id(parser.get_attribute_value_safe("url"));
- if (state.up_axis==Vector3::AXIS_Z) //collada weirdness
- cam->post_transform.basis.rotate(Vector3(1,0,0),-Math_PI*0.5);
+ if (state.up_axis == Vector3::AXIS_Z) //collada weirdness
+ cam->post_transform.basis.rotate(Vector3(1, 0, 0), -Math_PI * 0.5);
if (parser.is_empty()) //nothing else to parse...
return cam;
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="instance_camera")
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "instance_camera")
break;
}
return cam;
}
-Collada::Node* Collada::_parse_visual_instance_light(XMLParser& parser) {
+Collada::Node *Collada::_parse_visual_instance_light(XMLParser &parser) {
String type = parser.get_node_name();
- NodeLight *cam=memnew( NodeLight );
- cam->light= _uri_to_id(parser.get_attribute_value_safe("url"));
+ NodeLight *cam = memnew(NodeLight);
+ cam->light = _uri_to_id(parser.get_attribute_value_safe("url"));
- if (state.up_axis==Vector3::AXIS_Z) //collada weirdness
- cam->post_transform.basis.rotate(Vector3(1,0,0),-Math_PI*0.5);
+ if (state.up_axis == Vector3::AXIS_Z) //collada weirdness
+ cam->post_transform.basis.rotate(Vector3(1, 0, 0), -Math_PI * 0.5);
if (parser.is_empty()) //nothing else to parse...
return cam;
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="instance_light")
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "instance_light")
break;
}
return cam;
}
-
-Collada::Node* Collada::_parse_visual_node_instance_data(XMLParser& parser) {
+Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &parser) {
String instance_type = parser.get_node_name();
-
- if (instance_type=="instance_geometry" || instance_type=="instance_controller") {
+ if (instance_type == "instance_geometry" || instance_type == "instance_controller") {
return _parse_visual_instance_geometry(parser);
- } else if (instance_type=="instance_camera") {
+ } else if (instance_type == "instance_camera") {
return _parse_visual_instance_camera(parser);
- } else if (instance_type=="instance_light") {
+ } else if (instance_type == "instance_light") {
return _parse_visual_instance_light(parser);
}
-
if (parser.is_empty()) //nothing else to parse...
return NULL;
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()==instance_type)
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == instance_type)
break;
}
return NULL;
}
-Collada::Node* Collada::_parse_visual_scene_node(XMLParser& parser) {
+Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) {
String name;
String id = parser.get_attribute_value_safe("id");
- bool found_name=false;
+ bool found_name = false;
- if (id=="") {
+ if (id == "") {
- id="%NODEID%"+itos(Math::rand());
+ id = "%NODEID%" + itos(Math::rand());
} else {
- found_name=true;
+ found_name = true;
}
Vector<Node::XForm> xform_list;
- Vector<Node*> children;
-
- String empty_draw_type="";
+ Vector<Node *> children;
+
+ String empty_draw_type = "";
- Node *node=NULL;
+ Node *node = NULL;
- name=parser.has_attribute("name")?parser.get_attribute_value_safe("name"):parser.get_attribute_value_safe("id");
- if (name=="") {
+ name = parser.has_attribute("name") ? parser.get_attribute_value_safe("name") : parser.get_attribute_value_safe("id");
+ if (name == "") {
- name=id;
+ name = id;
} else {
- found_name=true;
+ found_name = true;
}
- if ((parser.has_attribute("type") && parser.get_attribute_value("type")=="JOINT") || state.idref_joints.has(name)) {
+ if ((parser.has_attribute("type") && parser.get_attribute_value("type") == "JOINT") || state.idref_joints.has(name)) {
// handle a bone
- NodeJoint *joint = memnew( NodeJoint );
+ NodeJoint *joint = memnew(NodeJoint);
- if ( parser.has_attribute("sid") ) { //bones may not have sid
- joint->sid=parser.get_attribute_value("sid");
+ if (parser.has_attribute("sid")) { //bones may not have sid
+ joint->sid = parser.get_attribute_value("sid");
//state.bone_map[joint->sid]=joint;
} else if (state.idref_joints.has(name)) {
- joint->sid=name; //kind of a cheat but..
+ joint->sid = name; //kind of a cheat but..
} else if (parser.has_attribute("name")) {
- joint->sid=parser.get_attribute_value_safe("name");
+ joint->sid = parser.get_attribute_value_safe("name");
}
-
- if (joint->sid!="") {
- state.sid_to_node_map[joint->sid]=id;
+ if (joint->sid != "") {
+ state.sid_to_node_map[joint->sid] = id;
}
- node=joint;
-
-
+ node = joint;
}
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- String section = parser.get_node_name();
+ String section = parser.get_node_name();
- if (section=="translate") {
+ if (section == "translate") {
Node::XForm xf;
if (parser.has_attribute("sid")) {
- xf.id=parser.get_attribute_value("sid");
+ xf.id = parser.get_attribute_value("sid");
}
- xf.op=Node::XForm::OP_TRANSLATE;
+ xf.op = Node::XForm::OP_TRANSLATE;
Vector<float> xlt = _read_float_array(parser);
- xf.data=xlt;
+ xf.data = xlt;
xform_list.push_back(xf);
- } else if (section=="rotate") {
+ } else if (section == "rotate") {
Node::XForm xf;
if (parser.has_attribute("sid")) {
- xf.id=parser.get_attribute_value("sid");
+ xf.id = parser.get_attribute_value("sid");
}
- xf.op=Node::XForm::OP_ROTATE;
+ xf.op = Node::XForm::OP_ROTATE;
Vector<float> rot = _read_float_array(parser);
- xf.data=rot;
+ xf.data = rot;
xform_list.push_back(xf);
- } else if (section=="scale") {
+ } else if (section == "scale") {
Node::XForm xf;
if (parser.has_attribute("sid")) {
- xf.id=parser.get_attribute_value("sid");
+ xf.id = parser.get_attribute_value("sid");
}
- xf.op=Node::XForm::OP_SCALE;
+ xf.op = Node::XForm::OP_SCALE;
Vector<float> scale = _read_float_array(parser);
- xf.data=scale;
+ xf.data = scale;
xform_list.push_back(xf);
- } else if (section=="matrix") {
+ } else if (section == "matrix") {
Node::XForm xf;
if (parser.has_attribute("sid")) {
- xf.id=parser.get_attribute_value("sid");
+ xf.id = parser.get_attribute_value("sid");
}
- xf.op=Node::XForm::OP_MATRIX;
+ xf.op = Node::XForm::OP_MATRIX;
Vector<float> matrix = _read_float_array(parser);
- xf.data=matrix;
+ xf.data = matrix;
String mtx;
- for(int i=0;i<matrix.size();i++)
- mtx+=" "+rtos(matrix[i]);
+ for (int i = 0; i < matrix.size(); i++)
+ mtx += " " + rtos(matrix[i]);
xform_list.push_back(xf);
- } else if (section=="visibility") {
- Node::XForm xf;
- if (parser.has_attribute("sid")) {
- xf.id=parser.get_attribute_value("sid");
- }
- xf.op=Node::XForm::OP_VISIBILITY;
+ } else if (section == "visibility") {
+ Node::XForm xf;
+ if (parser.has_attribute("sid")) {
+ xf.id = parser.get_attribute_value("sid");
+ }
+ xf.op = Node::XForm::OP_VISIBILITY;
- Vector<float> visible = _read_float_array(parser);
+ Vector<float> visible = _read_float_array(parser);
- xf.data=visible;
+ xf.data = visible;
- xform_list.push_back(xf);
+ xform_list.push_back(xf);
- } else if (section=="empty_draw_type") {
+ } else if (section == "empty_draw_type") {
empty_draw_type = _read_empty_draw_type(parser);
- } else if (section == "technique" || section=="extra") {
+ } else if (section == "technique" || section == "extra") {
- } else if (section!="node") {
+ } else if (section != "node") {
//usually what defines the type of node
//print_line(" dont know what to do with "+section);
if (section.begins_with("instance_")) {
@@ -1820,149 +1707,137 @@ Collada::Node* Collada::_parse_visual_scene_node(XMLParser& parser) {
} else {
ERR_PRINT("Multiple instance_* not supported.");
}
-
}
- } else if (section=="node") {
+ } else if (section == "node") {
/* Found a child node!! what to do..*/
Node *child = _parse_visual_scene_node(parser);
children.push_back(child);
-
-
-
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="node")
- break;
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "node")
+ break;
}
if (!node) {
- node = memnew( Node ); //generic node, nothing of relevance found
+ node = memnew(Node); //generic node, nothing of relevance found
}
- node->noname=!found_name;
- node->xform_list=xform_list;
- node->children=children;
- for(int i=0;i<children.size();i++) {
- node->children[i]->parent=node;
+ node->noname = !found_name;
+ node->xform_list = xform_list;
+ node->children = children;
+ for (int i = 0; i < children.size(); i++) {
+ node->children[i]->parent = node;
}
- node->name=name;
- node->id=id;
- node->empty_draw_type=empty_draw_type;
+ node->name = name;
+ node->id = id;
+ node->empty_draw_type = empty_draw_type;
- if (node->children.size()==1) {
+ if (node->children.size() == 1) {
if (node->children[0]->noname && !node->noname) {
- node->children[0]->name=node->name;
- node->name=node->name+"-base";
+ node->children[0]->name = node->name;
+ node->name = node->name + "-base";
}
}
-
-
node->default_transform = node->compute_transform(*this);
- state.scene_map[id]=node;
-
+ state.scene_map[id] = node;
return node;
}
-void Collada::_parse_visual_scene(XMLParser& parser) {
+void Collada::_parse_visual_scene(XMLParser &parser) {
- String id=parser.get_attribute_value("id");
+ String id = parser.get_attribute_value("id");
if (parser.is_empty()) {
return;
}
- state.visual_scene_map[id]=VisualScene();
+ state.visual_scene_map[id] = VisualScene();
VisualScene &vscene = state.visual_scene_map[id];
if (parser.has_attribute("name"))
- vscene.name=parser.get_attribute_value("name");
+ vscene.name = parser.get_attribute_value("name");
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- String section = parser.get_node_name();
+ String section = parser.get_node_name();
- if (section=="node") {
+ if (section == "node") {
vscene.root_nodes.push_back(_parse_visual_scene_node(parser));
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="visual_scene")
- break;
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "visual_scene")
+ break;
}
-
- COLLADA_PRINT("Scene ID:"+id);
-
-
+ COLLADA_PRINT("Scene ID:" + id);
}
-void Collada::_parse_animation(XMLParser& parser) {
+void Collada::_parse_animation(XMLParser &parser) {
- if (!(state.import_flags&IMPORT_FLAG_ANIMATION)) {
- if (!parser.is_empty())
+ if (!(state.import_flags & IMPORT_FLAG_ANIMATION)) {
+ if (!parser.is_empty())
parser.skip_section();
-
return;
}
- Map<String,Vector<float> > float_sources;
- Map<String,Vector<String> > string_sources;
- Map<String,int > source_strides;
- Map<String, Map<String,String> > samplers;
- Map<String,Vector<String> > source_param_names;
- Map<String,Vector<String> > source_param_types;
+ Map<String, Vector<float> > float_sources;
+ Map<String, Vector<String> > string_sources;
+ Map<String, int> source_strides;
+ Map<String, Map<String, String> > samplers;
+ Map<String, Vector<String> > source_param_names;
+ Map<String, Vector<String> > source_param_types;
- String id="";
+ String id = "";
if (parser.has_attribute("id"))
- id=parser.get_attribute_value("id");
+ id = parser.get_attribute_value("id");
String current_source;
String current_sampler;
Vector<String> channel_sources;
Vector<String> channel_targets;
- while(parser.read()==OK) {
-
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
String name = parser.get_node_name();
- if (name=="source") {
+ if (name == "source") {
- current_source=parser.get_attribute_value("id");
- source_param_names[current_source]=Vector<String>();
- source_param_types[current_source]=Vector<String>();
+ current_source = parser.get_attribute_value("id");
+ source_param_names[current_source] = Vector<String>();
+ source_param_types[current_source] = Vector<String>();
- } else if (name=="float_array") {
+ } else if (name == "float_array") {
- if (current_source!="") {
- float_sources[current_source]=_read_float_array(parser);
+ if (current_source != "") {
+ float_sources[current_source] = _read_float_array(parser);
}
- } else if (name=="Name_array") {
+ } else if (name == "Name_array") {
- if (current_source!="") {
- string_sources[current_source]=_read_string_array(parser);
+ if (current_source != "") {
+ string_sources[current_source] = _read_string_array(parser);
}
- } else if (name=="accessor") {
+ } else if (name == "accessor") {
- if (current_source!="" && parser.has_attribute("stride")) {
- source_strides[current_source]=parser.get_attribute_value("stride").to_int();
+ if (current_source != "" && parser.has_attribute("stride")) {
+ source_strides[current_source] = parser.get_attribute_value("stride").to_int();
}
- } else if (name=="sampler") {
+ } else if (name == "sampler") {
- current_sampler=parser.get_attribute_value("id");
- samplers[current_sampler]=Map<String,String>();
- } else if (name=="param") {
+ current_sampler = parser.get_attribute_value("id");
+ samplers[current_sampler] = Map<String, String>();
+ } else if (name == "param") {
if (parser.has_attribute("name"))
source_param_names[current_source].push_back(parser.get_attribute_value("name"));
@@ -1974,294 +1849,276 @@ void Collada::_parse_animation(XMLParser& parser) {
else
source_param_types[current_source].push_back("");
- } else if (name=="input") {
+ } else if (name == "input") {
- if (current_sampler!="") {
+ if (current_sampler != "") {
- samplers[current_sampler][parser.get_attribute_value("semantic")]=parser.get_attribute_value("source");
+ samplers[current_sampler][parser.get_attribute_value("semantic")] = parser.get_attribute_value("source");
}
- } else if (name=="channel") {
+ } else if (name == "channel") {
channel_sources.push_back(parser.get_attribute_value("source"));
channel_targets.push_back(parser.get_attribute_value("target"));
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="animation")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "animation")
break; //end of <asset>
-
-
}
+ for (int i = 0; i < channel_sources.size(); i++) {
- for(int i=0;i<channel_sources.size();i++) {
-
- String source=_uri_to_id(channel_sources[i]);
- String target=channel_targets[i];
+ String source = _uri_to_id(channel_sources[i]);
+ String target = channel_targets[i];
if (!samplers.has(source)) {
- print_line("channel lacks source: "+source);
+ print_line("channel lacks source: " + source);
}
ERR_CONTINUE(!samplers.has(source));
- Map<String,String>& sampler=samplers[source];
+ Map<String, String> &sampler = samplers[source];
ERR_CONTINUE(!sampler.has("INPUT")); //no input semantic? wtf?
- String input_id=_uri_to_id(sampler["INPUT"]);
- COLLADA_PRINT("input id is "+input_id);
+ String input_id = _uri_to_id(sampler["INPUT"]);
+ COLLADA_PRINT("input id is " + input_id);
ERR_CONTINUE(!float_sources.has(input_id));
ERR_CONTINUE(!sampler.has("OUTPUT"));
- String output_id=_uri_to_id(sampler["OUTPUT"]);
+ String output_id = _uri_to_id(sampler["OUTPUT"]);
ERR_CONTINUE(!float_sources.has(output_id));
ERR_CONTINUE(!source_param_names.has(output_id));
Vector<String> &names = source_param_names[output_id];
- for(int l=0;l<names.size();l++) {
+ for (int l = 0; l < names.size(); l++) {
String name = names[l];
- Vector<float> &time_keys=float_sources[input_id];
+ Vector<float> &time_keys = float_sources[input_id];
int key_count = time_keys.size();
AnimationTrack track; //begin crating track
- track.id=id;
+ track.id = id;
track.keys.resize(key_count);
- for(int j=0;j<key_count;j++) {
- track.keys[j].time=time_keys[j];
- state.animation_length = MAX(state.animation_length,time_keys[j] );
+ for (int j = 0; j < key_count; j++) {
+ track.keys[j].time = time_keys[j];
+ state.animation_length = MAX(state.animation_length, time_keys[j]);
}
//now read actual values
- int stride=1;
+ int stride = 1;
if (source_strides.has(output_id))
- stride=source_strides[output_id];
- int output_len=stride / names.size();
+ stride = source_strides[output_id];
+ int output_len = stride / names.size();
- ERR_CONTINUE(output_len==0);
+ ERR_CONTINUE(output_len == 0);
ERR_CONTINUE(!float_sources.has(output_id));
Vector<float> &output = float_sources[output_id];
ERR_EXPLAIN("Wrong number of keys in output");
- ERR_CONTINUE( (output.size()/stride) != key_count );
+ ERR_CONTINUE((output.size() / stride) != key_count);
- for(int j=0;j<key_count;j++) {
+ for (int j = 0; j < key_count; j++) {
track.keys[j].data.resize(output_len);
- for(int k=0;k<output_len;k++)
- track.keys[j].data[k]=output[l+j*stride+k]; //super weird but should work
+ for (int k = 0; k < output_len; k++)
+ track.keys[j].data[k] = output[l + j * stride + k]; //super weird but should work
}
- if(sampler.has("INTERPOLATION")) {
+ if (sampler.has("INTERPOLATION")) {
- String interp_id=_uri_to_id(sampler["INTERPOLATION"]);
+ String interp_id = _uri_to_id(sampler["INTERPOLATION"]);
ERR_CONTINUE(!string_sources.has(interp_id));
- Vector<String> &interps=string_sources[interp_id];
- ERR_CONTINUE(interps.size()!=key_count);
+ Vector<String> &interps = string_sources[interp_id];
+ ERR_CONTINUE(interps.size() != key_count);
- for(int j=0;j<key_count;j++) {
- if (interps[j]=="BEZIER")
- track.keys[j].interp_type=AnimationTrack::INTERP_BEZIER;
+ for (int j = 0; j < key_count; j++) {
+ if (interps[j] == "BEZIER")
+ track.keys[j].interp_type = AnimationTrack::INTERP_BEZIER;
else
- track.keys[j].interp_type=AnimationTrack::INTERP_LINEAR;
+ track.keys[j].interp_type = AnimationTrack::INTERP_LINEAR;
}
}
if (sampler.has("IN_TANGENT") && sampler.has("OUT_TANGENT")) {
//bezier control points..
- String intangent_id=_uri_to_id(sampler["IN_TANGENT"]);
+ String intangent_id = _uri_to_id(sampler["IN_TANGENT"]);
ERR_CONTINUE(!float_sources.has(intangent_id));
- Vector<float> &intangents=float_sources[intangent_id];
-
+ Vector<float> &intangents = float_sources[intangent_id];
+ ERR_CONTINUE(intangents.size() != key_count * 2 * names.size());
-
- ERR_CONTINUE(intangents.size()!=key_count*2*names.size());
-
- String outangent_id=_uri_to_id(sampler["OUT_TANGENT"]);
+ String outangent_id = _uri_to_id(sampler["OUT_TANGENT"]);
ERR_CONTINUE(!float_sources.has(outangent_id));
- Vector<float> &outangents=float_sources[outangent_id];
- ERR_CONTINUE(outangents.size()!=key_count*2*names.size());
+ Vector<float> &outangents = float_sources[outangent_id];
+ ERR_CONTINUE(outangents.size() != key_count * 2 * names.size());
- for(int j=0;j<key_count;j++) {
- track.keys[j].in_tangent=Vector2( intangents[j*2*names.size()+0+l*2],intangents[j*2*names.size()+1+l*2] );
- track.keys[j].out_tangent=Vector2( outangents[j*2*names.size()+0+l*2],outangents[j*2*names.size()+1+l*2] );
+ for (int j = 0; j < key_count; j++) {
+ track.keys[j].in_tangent = Vector2(intangents[j * 2 * names.size() + 0 + l * 2], intangents[j * 2 * names.size() + 1 + l * 2]);
+ track.keys[j].out_tangent = Vector2(outangents[j * 2 * names.size() + 0 + l * 2], outangents[j * 2 * names.size() + 1 + l * 2]);
}
}
- if (target.find("/")!=-1) { //transform component
- track.target=target.get_slicec('/',0);
- track.param=target.get_slicec('/',1);
- if (track.param.find(".")!=-1)
- track.component=track.param.get_slice(".",1).to_upper();
- track.param=track.param.get_slice(".",0);
- if (names.size()>1 && track.component=="") {
+ if (target.find("/") != -1) { //transform component
+ track.target = target.get_slicec('/', 0);
+ track.param = target.get_slicec('/', 1);
+ if (track.param.find(".") != -1)
+ track.component = track.param.get_slice(".", 1).to_upper();
+ track.param = track.param.get_slice(".", 0);
+ if (names.size() > 1 && track.component == "") {
//this is a guess because the collada spec is ambiguous here...
//i suppose if you have many names (outputs) you can't use a component and i should abide to that.
- track.component=name;
-
+ track.component = name;
}
} else {
- track.target=target;
+ track.target = target;
}
- print_line("TARGET: "+track.target);
+ print_line("TARGET: " + track.target);
state.animation_tracks.push_back(track);
if (!state.referenced_tracks.has(target))
- state.referenced_tracks[target]=Vector<int>();
+ state.referenced_tracks[target] = Vector<int>();
- state.referenced_tracks[target].push_back(state.animation_tracks.size()-1);
+ state.referenced_tracks[target].push_back(state.animation_tracks.size() - 1);
- if (id!="") {
+ if (id != "") {
if (!state.by_id_tracks.has(id))
- state.by_id_tracks[id]=Vector<int>();
+ state.by_id_tracks[id] = Vector<int>();
- state.by_id_tracks[id].push_back(state.animation_tracks.size()-1);
+ state.by_id_tracks[id].push_back(state.animation_tracks.size() - 1);
}
- COLLADA_PRINT("loaded animation with "+itos(key_count)+" keys");
+ COLLADA_PRINT("loaded animation with " + itos(key_count) + " keys");
}
-
}
}
-void Collada::_parse_animation_clip(XMLParser& parser) {
+void Collada::_parse_animation_clip(XMLParser &parser) {
- if (!(state.import_flags&IMPORT_FLAG_ANIMATION)) {
- if (!parser.is_empty())
+ if (!(state.import_flags & IMPORT_FLAG_ANIMATION)) {
+ if (!parser.is_empty())
parser.skip_section();
-
return;
}
-
AnimationClip clip;
if (parser.has_attribute("name"))
- clip.name=parser.get_attribute_value("name");
+ clip.name = parser.get_attribute_value("name");
else if (parser.has_attribute("id"))
- clip.name=parser.get_attribute_value("id");
+ clip.name = parser.get_attribute_value("id");
if (parser.has_attribute("start"))
- clip.begin=parser.get_attribute_value("start").to_double();
+ clip.begin = parser.get_attribute_value("start").to_double();
if (parser.has_attribute("end"))
- clip.end=parser.get_attribute_value("end").to_double();
-
+ clip.end = parser.get_attribute_value("end").to_double();
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
-
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
String name = parser.get_node_name();
- if (name=="instance_animation") {
+ if (name == "instance_animation") {
String url = _uri_to_id(parser.get_attribute_value("url"));
clip.tracks.push_back(url);
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="animation_clip")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "animation_clip")
break; //end of <asset>
-
}
state.animation_clips.push_back(clip);
- print_line("found anim clip: "+clip.name);
-
+ print_line("found anim clip: " + clip.name);
}
-void Collada::_parse_scene(XMLParser& parser) {
+void Collada::_parse_scene(XMLParser &parser) {
if (parser.is_empty()) {
return;
}
- while(parser.read()==OK) {
-
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
String name = parser.get_node_name();
- if (name=="instance_visual_scene") {
-
- state.root_visual_scene=_uri_to_id(parser.get_attribute_value("url"));
- print_line("***ROOT VISUAL SCENE: "+state.root_visual_scene);
- } else if (name=="instance_physics_scene") {
+ if (name == "instance_visual_scene") {
- state.root_physics_scene=_uri_to_id(parser.get_attribute_value("url"));
+ state.root_visual_scene = _uri_to_id(parser.get_attribute_value("url"));
+ print_line("***ROOT VISUAL SCENE: " + state.root_visual_scene);
+ } else if (name == "instance_physics_scene") {
+ state.root_physics_scene = _uri_to_id(parser.get_attribute_value("url"));
}
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="scene")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "scene")
break; //end of <asset>
}
}
-void Collada::_parse_library(XMLParser& parser) {
-
+void Collada::_parse_library(XMLParser &parser) {
if (parser.is_empty()) {
return;
}
- while(parser.read()==OK) {
-
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
String name = parser.get_node_name();
- COLLADA_PRINT("library name is: "+name);
- if (name=="image") {
+ COLLADA_PRINT("library name is: " + name);
+ if (name == "image") {
_parse_image(parser);
- } else if (name=="material") {
+ } else if (name == "material") {
_parse_material(parser);
- } else if (name=="effect") {
+ } else if (name == "effect") {
_parse_effect(parser);
- } else if (name=="camera") {
+ } else if (name == "camera") {
_parse_camera(parser);
- } else if (name=="light") {
+ } else if (name == "light") {
_parse_light(parser);
- } else if (name=="geometry") {
+ } else if (name == "geometry") {
String id = parser.get_attribute_value("id");
String name = parser.get_attribute_value_safe("name");
- while(parser.read()==OK) {
+ while (parser.read() == OK) {
- if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser.get_node_name()=="mesh") {
- state.mesh_name_map[id]=(name!="")?name:id;
- _parse_mesh_geometry(parser,id,name);
- } else if (parser.get_node_name()=="spline") {
- state.mesh_name_map[id]=(name!="")?name:id;
- _parse_curve_geometry(parser,id,name);
+ if (parser.get_node_name() == "mesh") {
+ state.mesh_name_map[id] = (name != "") ? name : id;
+ _parse_mesh_geometry(parser, id, name);
+ } else if (parser.get_node_name() == "spline") {
+ state.mesh_name_map[id] = (name != "") ? name : id;
+ _parse_curve_geometry(parser, id, name);
} else if (!parser.is_empty())
parser.skip_section();
- } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="geometry")
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "geometry")
break;
}
- } else if (name=="controller") {
+ } else if (name == "controller") {
_parse_controller(parser);
- } else if (name=="animation") {
+ } else if (name == "animation") {
_parse_animation(parser);
- } else if (name=="animation_clip") {
+ } else if (name == "animation_clip") {
_parse_animation_clip(parser);
- } else if (name=="visual_scene") {
+ } else if (name == "visual_scene") {
COLLADA_PRINT("visual scene");
_parse_visual_scene(parser);
@@ -2270,158 +2127,144 @@ void Collada::_parse_library(XMLParser& parser) {
} else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name().begins_with("library_"))
break; //end of <asset>
-
-
}
-
}
void Collada::_joint_set_owner(Collada::Node *p_node, NodeSkeleton *p_owner) {
- if (p_node->type==Node::TYPE_JOINT) {
+ if (p_node->type == Node::TYPE_JOINT) {
- NodeJoint *nj = static_cast<NodeJoint*>(p_node);
- nj->owner=p_owner;
+ NodeJoint *nj = static_cast<NodeJoint *>(p_node);
+ nj->owner = p_owner;
- for(int i=0;i<nj->children.size();i++) {
+ for (int i = 0; i < nj->children.size(); i++) {
- _joint_set_owner(nj->children[i],p_owner);
+ _joint_set_owner(nj->children[i], p_owner);
}
}
}
-void Collada::_create_skeletons(Collada::Node **p_node,NodeSkeleton *p_skeleton) {
-
+void Collada::_create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton) {
Node *node = *p_node;
- if (node->type==Node::TYPE_JOINT) {
+ if (node->type == Node::TYPE_JOINT) {
if (!p_skeleton) {
// ohohohoohoo it's a joint node, time to work!
- NodeSkeleton *sk = memnew( NodeSkeleton );
- *p_node=sk;
+ NodeSkeleton *sk = memnew(NodeSkeleton);
+ *p_node = sk;
sk->children.push_back(node);
- sk->parent=node->parent;
- node->parent=sk;
- p_skeleton=sk;
+ sk->parent = node->parent;
+ node->parent = sk;
+ p_skeleton = sk;
}
- NodeJoint *nj = static_cast<NodeJoint*>(node);
- nj->owner=p_skeleton;
+ NodeJoint *nj = static_cast<NodeJoint *>(node);
+ nj->owner = p_skeleton;
} else {
- p_skeleton=NULL;
+ p_skeleton = NULL;
}
-
- for(int i=0;i<node->children.size();i++) {
- _create_skeletons(&node->children[i],p_skeleton);
+ for (int i = 0; i < node->children.size(); i++) {
+ _create_skeletons(&node->children[i], p_skeleton);
}
-
}
-bool Collada::_remove_node(Node *p_parent,Node *p_node) {
+bool Collada::_remove_node(Node *p_parent, Node *p_node) {
- for(int i=0;i<p_parent->children.size();i++) {
+ for (int i = 0; i < p_parent->children.size(); i++) {
- if (p_parent->children[i]==p_node) {
+ if (p_parent->children[i] == p_node) {
p_parent->children.remove(i);
return true;
}
- if (_remove_node(p_parent->children[i],p_node))
+ if (_remove_node(p_parent->children[i], p_node))
return true;
}
return false;
}
-void Collada::_remove_node(VisualScene *p_vscene,Node *p_node) {
+void Collada::_remove_node(VisualScene *p_vscene, Node *p_node) {
- for(int i=0;i<p_vscene->root_nodes.size();i++) {
- if (p_vscene->root_nodes[i]==p_node) {
+ for (int i = 0; i < p_vscene->root_nodes.size(); i++) {
+ if (p_vscene->root_nodes[i] == p_node) {
p_vscene->root_nodes.remove(i);
return;
}
- if (_remove_node(p_vscene->root_nodes[i],p_node))
+ if (_remove_node(p_vscene->root_nodes[i], p_node))
return;
}
ERR_PRINT("ERROR: Not found node to remove?");
-
}
+void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) {
-void Collada::_merge_skeletons(VisualScene *p_vscene,Node *p_node) {
-
- if (p_node->type==Node::TYPE_GEOMETRY) {
+ if (p_node->type == Node::TYPE_GEOMETRY) {
- NodeGeometry *gnode = static_cast<NodeGeometry*>(p_node);
+ NodeGeometry *gnode = static_cast<NodeGeometry *>(p_node);
if (gnode->controller) {
// recount skeletons used
- Set<NodeSkeleton*> skeletons;
+ Set<NodeSkeleton *> skeletons;
- for(int i=0;i<gnode->skeletons.size();i++) {
+ for (int i = 0; i < gnode->skeletons.size(); i++) {
String nodeid = gnode->skeletons[i];
- ERR_CONTINUE( !state.scene_map.has( nodeid )); //weird, it should have it...
+ ERR_CONTINUE(!state.scene_map.has(nodeid)); //weird, it should have it...
-
- NodeJoint *nj = SAFE_CAST<NodeJoint*>(state.scene_map[nodeid]);
+ NodeJoint *nj = SAFE_CAST<NodeJoint *>(state.scene_map[nodeid]);
if (!nj->owner) {
- print_line("no owner for: "+String(nodeid));
+ print_line("no owner for: " + String(nodeid));
}
- ERR_CONTINUE( !nj->owner ); //weird, node should have a skeleton owner
+ ERR_CONTINUE(!nj->owner); //weird, node should have a skeleton owner
skeletons.insert(nj->owner);
}
- if (skeletons.size()>1) {
+ if (skeletons.size() > 1) {
//do the merger!!
- Set<NodeSkeleton*>::Element *E=skeletons.front();
+ Set<NodeSkeleton *>::Element *E = skeletons.front();
NodeSkeleton *base = E->get();
- for(E=E->next();E;E=E->next() ) {
+ for (E = E->next(); E; E = E->next()) {
NodeSkeleton *merged = E->get();
- _remove_node(p_vscene,merged);
- for(int i=0;i<merged->children.size();i++) {
-
- _joint_set_owner(merged->children[i],base);
- base->children.push_back( merged->children[i] );
- merged->children[i]->parent=base;
-
+ _remove_node(p_vscene, merged);
+ for (int i = 0; i < merged->children.size(); i++) {
+ _joint_set_owner(merged->children[i], base);
+ base->children.push_back(merged->children[i]);
+ merged->children[i]->parent = base;
}
merged->children.clear(); //take children from it
- memdelete( merged );
+ memdelete(merged);
}
-
}
}
}
- for(int i=0;i<p_node->children.size();i++) {
- _merge_skeletons(p_vscene,p_node->children[i]);
+ for (int i = 0; i < p_node->children.size(); i++) {
+ _merge_skeletons(p_vscene, p_node->children[i]);
}
-
}
-
void Collada::_merge_skeletons2(VisualScene *p_vscene) {
- for (Map<String,SkinControllerData>::Element *E=state.skin_controller_data_map.front();E;E=E->next()) {
+ for (Map<String, SkinControllerData>::Element *E = state.skin_controller_data_map.front(); E; E = E->next()) {
- SkinControllerData &cd=E->get();
+ SkinControllerData &cd = E->get();
- NodeSkeleton *skeleton=NULL;
+ NodeSkeleton *skeleton = NULL;
- for (Map<String,Transform>::Element *F=cd.bone_rest_map.front();F;F=F->next()) {
+ for (Map<String, Transform>::Element *F = cd.bone_rest_map.front(); F; F = F->next()) {
String name;
@@ -2432,84 +2275,79 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) {
name = state.sid_to_node_map[F->key()];
if (!state.scene_map.has(name)) {
- print_line("no foundie node for: "+name);
+ print_line("no foundie node for: " + name);
}
- ERR_CONTINUE( !state.scene_map.has(name) );
+ ERR_CONTINUE(!state.scene_map.has(name));
- Node *node=state.scene_map[name];
- ERR_CONTINUE( node->type!=Node::TYPE_JOINT );
- if (node->type!=Node::TYPE_JOINT)
+ Node *node = state.scene_map[name];
+ ERR_CONTINUE(node->type != Node::TYPE_JOINT);
+ if (node->type != Node::TYPE_JOINT)
continue;
- NodeSkeleton *sk=NULL;
+ NodeSkeleton *sk = NULL;
- while(node && !sk) {
+ while (node && !sk) {
- if (node->type==Node::TYPE_SKELETON) {
- sk=static_cast<NodeSkeleton*>(node);
+ if (node->type == Node::TYPE_SKELETON) {
+ sk = static_cast<NodeSkeleton *>(node);
}
- node=node->parent;
+ node = node->parent;
}
- ERR_CONTINUE( !sk );
+ ERR_CONTINUE(!sk);
if (!sk)
continue; //bleh
if (!skeleton) {
- skeleton=sk;
+ skeleton = sk;
continue;
}
- if (skeleton!=sk) {
+ if (skeleton != sk) {
//whoa.. wtf, merge.
print_line("MERGED BONES!!");
//NodeSkeleton *merged = E->get();
- _remove_node(p_vscene,sk);
- for(int i=0;i<sk->children.size();i++) {
-
- _joint_set_owner(sk->children[i],skeleton);
- skeleton->children.push_back( sk->children[i] );
- sk->children[i]->parent=skeleton;
-
+ _remove_node(p_vscene, sk);
+ for (int i = 0; i < sk->children.size(); i++) {
+ _joint_set_owner(sk->children[i], skeleton);
+ skeleton->children.push_back(sk->children[i]);
+ sk->children[i]->parent = skeleton;
}
sk->children.clear(); //take children from it
- memdelete( sk );
+ memdelete(sk);
}
}
}
-
-
-
}
-bool Collada::_optimize_skeletons(VisualScene *p_vscene,Node *p_node) {
+bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) {
- Node *node=p_node;
+ Node *node = p_node;
- if (node->type==Node::TYPE_SKELETON && node->parent && node->parent->type==Node::TYPE_NODE && node->parent->children.size()==1) {
+ if (node->type == Node::TYPE_SKELETON && node->parent && node->parent->type == Node::TYPE_NODE && node->parent->children.size() == 1) {
//replace parent by this...
Node *parent = node->parent;
//i wonder if this is allright.. i think it is since created skeleton (first joint) is already animated by bone..
- node->id=parent->id;
- node->name=parent->name;
- node->xform_list=parent->xform_list;
- node->default_transform=parent->default_transform;
+ node->id = parent->id;
+ node->name = parent->name;
+ node->xform_list = parent->xform_list;
+ node->default_transform = parent->default_transform;
- state.scene_map[node->id]=node;
- node->parent=parent->parent;
+ state.scene_map[node->id] = node;
+ node->parent = parent->parent;
if (parent->parent) {
Node *gp = parent->parent;
- bool found=false;
- for(int i=0;i<gp->children.size();i++) {
+ bool found = false;
+ for (int i = 0; i < gp->children.size(); i++) {
- if (gp->children[i]==parent) {
- gp->children[i]=node;
- found=true;
+ if (gp->children[i] == parent) {
+ gp->children[i] = node;
+ found = true;
break;
}
}
@@ -2518,21 +2356,20 @@ bool Collada::_optimize_skeletons(VisualScene *p_vscene,Node *p_node) {
}
} else {
- bool found=false;
+ bool found = false;
- for(int i=0;i<p_vscene->root_nodes.size();i++) {
+ for (int i = 0; i < p_vscene->root_nodes.size(); i++) {
- if (p_vscene->root_nodes[i]==parent) {
+ if (p_vscene->root_nodes[i] == parent) {
- p_vscene->root_nodes[i]=node;
- found=true;
+ p_vscene->root_nodes[i] = node;
+ found = true;
break;
}
}
if (!found) {
ERR_PRINT("BUG");
}
-
}
parent->children.clear();
@@ -2540,26 +2377,24 @@ bool Collada::_optimize_skeletons(VisualScene *p_vscene,Node *p_node) {
return true;
}
- for(int i=0;i<node->children.size();i++) {
+ for (int i = 0; i < node->children.size(); i++) {
- if (_optimize_skeletons(p_vscene,node->children[i]))
+ if (_optimize_skeletons(p_vscene, node->children[i]))
return false; //stop processing, go up
}
return false;
-
}
-
-bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene,Node *p_node,List<Node*> *p_mgeom) {
+bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, List<Node *> *p_mgeom) {
// bind shape matrix escala los huesos y los hace gigantes, asi la matriz despues achica
// al modelo?
// solucion: aplicarle la bind shape matrix a los VERTICES, y si el objeto viene con escala, se la dejo me parece!
- if (p_node->type==Node::TYPE_GEOMETRY) {
+ if (p_node->type == Node::TYPE_GEOMETRY) {
- NodeGeometry *ng = static_cast<NodeGeometry*>(p_node);
+ NodeGeometry *ng = static_cast<NodeGeometry *>(p_node);
if (ng->ignore_anim)
return false; //already made child of skeleton and processeg
@@ -2567,59 +2402,57 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene,Node *p_node,Lis
String nodeid = ng->skeletons[0];
- ERR_FAIL_COND_V( !state.scene_map.has( nodeid ), false); //weird, it should have it...
- NodeJoint *nj = SAFE_CAST<NodeJoint*>(state.scene_map[nodeid]);
- ERR_FAIL_COND_V(!nj,false);
+ ERR_FAIL_COND_V(!state.scene_map.has(nodeid), false); //weird, it should have it...
+ NodeJoint *nj = SAFE_CAST<NodeJoint *>(state.scene_map[nodeid]);
+ ERR_FAIL_COND_V(!nj, false);
if (!nj->owner) {
- print_line("Has no owner: "+nj->name);
+ print_line("Has no owner: " + nj->name);
}
- ERR_FAIL_COND_V( !nj->owner,false ); //weird, node should have a skeleton owner
+ ERR_FAIL_COND_V(!nj->owner, false); //weird, node should have a skeleton owner
NodeSkeleton *sk = nj->owner;
- Node *p =sk->parent;
- bool node_is_parent_of_skeleton=false;
+ Node *p = sk->parent;
+ bool node_is_parent_of_skeleton = false;
while (p) {
- if (p==p_node) {
- node_is_parent_of_skeleton=true;
+ if (p == p_node) {
+ node_is_parent_of_skeleton = true;
break;
}
- p=p->parent; // try again
+ p = p->parent; // try again
}
- ERR_FAIL_COND_V( node_is_parent_of_skeleton, false);
+ ERR_FAIL_COND_V(node_is_parent_of_skeleton, false);
//this should be correct
- ERR_FAIL_COND_V( !state.skin_controller_data_map.has(ng->source), false);
- SkinControllerData &skin=state.skin_controller_data_map[ng->source];
+ ERR_FAIL_COND_V(!state.skin_controller_data_map.has(ng->source), false);
+ SkinControllerData &skin = state.skin_controller_data_map[ng->source];
Transform skel_inv = sk->get_global_transform().affine_inverse();
- p_node->default_transform = skel_inv * (skin.bind_shape /* p_node->get_global_transform()*/); // i honestly have no idea what to do with a previous model xform.. most exporters ignore it
+ p_node->default_transform = skel_inv * (skin.bind_shape /* p_node->get_global_transform()*/); // i honestly have no idea what to do with a previous model xform.. most exporters ignore it
//make rests relative to the skeleton (they seem to be always relative to world)
- for(Map<String,Transform>::Element *E=skin.bone_rest_map.front();E;E=E->next()) {
+ for (Map<String, Transform>::Element *E = skin.bone_rest_map.front(); E; E = E->next()) {
E->get() = skel_inv * E->get(); //make the bone rest local to the skeleton
- state.bone_rest_map[E->key()]=E->get(); // make it remember where the bone is globally, now that it's relative
+ state.bone_rest_map[E->key()] = E->get(); // make it remember where the bone is globally, now that it's relative
}
//but most exporters seem to work only if i do this..
//p_node->default_transform = p_node->get_global_transform();
-
-
//p_node->default_transform=Transform(); //this seems to be correct, because bind shape makes the object local to the skeleton
- p_node->ignore_anim=true; // collada may animate this later, if it does, then this is not supported (redo your original asset and don't animate the base mesh)
- p_node->parent=sk;
+ p_node->ignore_anim = true; // collada may animate this later, if it does, then this is not supported (redo your original asset and don't animate the base mesh)
+ p_node->parent = sk;
//sk->children.push_back(0,p_node); //avoid INFINIT loop
p_mgeom->push_back(p_node);
return true;
}
}
- for(int i=0;i<p_node->children.size();i++) {
+ for (int i = 0; i < p_node->children.size(); i++) {
- if (_move_geometry_to_skeletons(p_vscene,p_node->children[i],p_mgeom)) {
+ if (_move_geometry_to_skeletons(p_vscene, p_node->children[i], p_mgeom)) {
p_node->children.remove(i);
i--;
}
@@ -2628,139 +2461,129 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene,Node *p_node,Lis
return false;
}
-void Collada::_find_morph_nodes(VisualScene *p_vscene,Node *p_node) {
+void Collada::_find_morph_nodes(VisualScene *p_vscene, Node *p_node) {
- if (p_node->type==Node::TYPE_GEOMETRY) {
+ if (p_node->type == Node::TYPE_GEOMETRY) {
- NodeGeometry *nj = static_cast<NodeGeometry*>(p_node);
+ NodeGeometry *nj = static_cast<NodeGeometry *>(p_node);
if (nj->controller) {
String base = nj->source;
- while(base!="" && !state.mesh_data_map.has(base)) {
+ while (base != "" && !state.mesh_data_map.has(base)) {
if (state.skin_controller_data_map.has(base)) {
SkinControllerData &sk = state.skin_controller_data_map[base];
- base=sk.base;
+ base = sk.base;
} else if (state.morph_controller_data_map.has(base)) {
- state.morph_ownership_map[base]=nj->id;
+ state.morph_ownership_map[base] = nj->id;
break;
} else {
ERR_EXPLAIN("Invalid scene");
ERR_FAIL();
}
}
-
}
}
- for(int i=0;i<p_node->children.size();i++) {
+ for (int i = 0; i < p_node->children.size(); i++) {
- _find_morph_nodes(p_vscene,p_node->children[i]);
+ _find_morph_nodes(p_vscene, p_node->children[i]);
}
-
}
void Collada::_optimize() {
-
- for(Map<String,VisualScene>::Element *E=state.visual_scene_map.front();E;E=E->next()) {
+ for (Map<String, VisualScene>::Element *E = state.visual_scene_map.front(); E; E = E->next()) {
VisualScene &vs = E->get();
- for(int i=0;i<vs.root_nodes.size();i++) {
+ for (int i = 0; i < vs.root_nodes.size(); i++) {
_create_skeletons(&vs.root_nodes[i]);
-
}
#if 1
- for(int i=0;i<vs.root_nodes.size();i++) {
- _merge_skeletons(&vs,vs.root_nodes[i]);
+ for (int i = 0; i < vs.root_nodes.size(); i++) {
+ _merge_skeletons(&vs, vs.root_nodes[i]);
}
_merge_skeletons2(&vs);
-
- for(int i=0;i<vs.root_nodes.size();i++) {
- _optimize_skeletons(&vs,vs.root_nodes[i]);
+ for (int i = 0; i < vs.root_nodes.size(); i++) {
+ _optimize_skeletons(&vs, vs.root_nodes[i]);
}
- for(int i=0;i<vs.root_nodes.size();i++) {
+ for (int i = 0; i < vs.root_nodes.size(); i++) {
- List<Node*> mgeom;
- if (_move_geometry_to_skeletons(&vs,vs.root_nodes[i],&mgeom)) {
+ List<Node *> mgeom;
+ if (_move_geometry_to_skeletons(&vs, vs.root_nodes[i], &mgeom)) {
vs.root_nodes.remove(i);
i--;
}
- while(!mgeom.empty()) {
+ while (!mgeom.empty()) {
- Node * n= mgeom.front()->get();
+ Node *n = mgeom.front()->get();
n->parent->children.push_back(n);
mgeom.pop_front();
}
-
}
#endif
- for(int i=0;i<vs.root_nodes.size();i++) {
- _find_morph_nodes(&vs,vs.root_nodes[i]);
+ for (int i = 0; i < vs.root_nodes.size(); i++) {
+ _find_morph_nodes(&vs, vs.root_nodes[i]);
}
-
}
}
-
int Collada::get_uv_channel(String p_name) {
if (!channel_map.has(p_name)) {
- ERR_FAIL_COND_V(channel_map.size()==2,0);
+ ERR_FAIL_COND_V(channel_map.size() == 2, 0);
- channel_map[p_name]=channel_map.size();
+ channel_map[p_name] = channel_map.size();
}
return channel_map[p_name];
}
-Error Collada::load(const String& p_path, int p_flags) {
+Error Collada::load(const String &p_path, int p_flags) {
- Ref<XMLParser> parserr = memnew( XMLParser );
+ Ref<XMLParser> parserr = memnew(XMLParser);
XMLParser &parser = *parserr.ptr();
Error err = parser.open(p_path);
- ERR_FAIL_COND_V(err,err);
+ ERR_FAIL_COND_V(err, err);
state.local_path = GlobalConfig::get_singleton()->localize_path(p_path);
- state.import_flags=p_flags;
+ state.import_flags = p_flags;
/* Skip headers */
- err=OK;
- while((err=parser.read())==OK) {
+ err = OK;
+ while ((err = parser.read()) == OK) {
if (parser.get_node_type() == XMLParser::NODE_ELEMENT) {
if (parser.get_node_name() == "COLLADA") {
break;
} else if (!parser.is_empty())
- parser.skip_section();// unknown section, likely headers
+ parser.skip_section(); // unknown section, likely headers
}
}
- ERR_FAIL_COND_V(err!=OK, ERR_FILE_CORRUPT);
+ ERR_FAIL_COND_V(err != OK, ERR_FILE_CORRUPT);
/* Start loading Collada */
{
//version
String version = parser.get_attribute_value("version");
- state.version.major=version.get_slice(".",0).to_int();
- state.version.minor=version.get_slice(".",1).to_int();
- state.version.rev=version.get_slice(".",2).to_int();
- COLLADA_PRINT("Collada VERSION: "+version);
+ state.version.major = version.get_slice(".", 0).to_int();
+ state.version.minor = version.get_slice(".", 1).to_int();
+ state.version.rev = version.get_slice(".", 2).to_int();
+ COLLADA_PRINT("Collada VERSION: " + version);
}
-
-
- while((err=parser.read())==OK) {
+ while ((err = parser.read()) == OK) {
/* Read all the main sections.. */
@@ -2769,33 +2592,27 @@ Error Collada::load(const String& p_path, int p_flags) {
String section = parser.get_node_name();
- COLLADA_PRINT("section: "+section);
+ COLLADA_PRINT("section: " + section);
- if (section=="asset") {
+ if (section == "asset") {
_parse_asset(parser);
} else if (section.begins_with("library_")) {
_parse_library(parser);
- } else if (section=="scene") {
+ } else if (section == "scene") {
_parse_scene(parser);
} else if (!parser.is_empty()) {
parser.skip_section(); // unknown section, likely headers
}
-
}
_optimize();
return OK;
}
-
-
-
Collada::Collada() {
-
-
}
#endif
diff --git a/editor/collada/collada.h b/editor/collada/collada.h
index 2de2d22935..23b3aef670 100644
--- a/editor/collada/collada.h
+++ b/editor/collada/collada.h
@@ -31,21 +31,18 @@
#ifndef COLLADA_H
#define COLLADA_H
-
-#include "scene/resources/material.h"
#include "global_config.h"
#include "io/xml_parser.h"
#include "map.h"
+#include "scene/resources/material.h"
class Collada {
public:
-
enum ImportFlags {
- IMPORT_FLAG_SCENE=1,
- IMPORT_FLAG_ANIMATION=2
+ IMPORT_FLAG_SCENE = 1,
+ IMPORT_FLAG_ANIMATION = 2
};
-
struct Image {
String path;
@@ -57,7 +54,6 @@ public:
String instance_effect;
};
-
struct Effect {
String name;
@@ -68,23 +64,23 @@ public:
int uv_idx;
String texture;
Color color;
- Channel() { uv_idx=0; }
+ Channel() { uv_idx = 0; }
};
- Channel diffuse,specular,emission,bump;
+ Channel diffuse, specular, emission, bump;
float shininess;
bool found_double_sided;
bool double_sided;
bool unshaded;
- String get_texture_path(const String& p_source,Collada& state) const;
+ String get_texture_path(const String &p_source, Collada &state) const;
Effect() {
- diffuse.color=Color(1,1,1,1);
- double_sided=true;
- found_double_sided=false;
- shininess=40;
- unshaded=false;
+ diffuse.color = Color(1, 1, 1, 1);
+ double_sided = true;
+ found_double_sided = false;
+ shininess = 40;
+ unshaded = false;
}
};
@@ -114,12 +110,12 @@ public:
CameraData() {
- mode=MODE_PERSPECTIVE;
- perspective.y_fov=0;
- perspective.x_fov=0;
- aspect=1;
- z_near=0.1;
- z_far=100;
+ mode = MODE_PERSPECTIVE;
+ perspective.y_fov = 0;
+ perspective.x_fov = 0;
+ aspect = 1;
+ z_near = 0.1;
+ z_far = 100;
}
};
@@ -145,37 +141,34 @@ public:
LightData() {
- mode=MODE_AMBIENT;
- color=Color(1,1,1,1);
- constant_att=0;
- linear_att=0;
- quad_att=0;
+ mode = MODE_AMBIENT;
+ color = Color(1, 1, 1, 1);
+ constant_att = 0;
+ linear_att = 0;
+ quad_att = 0;
- spot_angle=45;
- spot_exp=1;
+ spot_angle = 45;
+ spot_exp = 1;
}
};
-
struct MeshData {
-
String name;
struct Source {
Vector<float> array;
int stride;
-
};
- Map<String,Source> sources;
+ Map<String, Source> sources;
struct Vertices {
- Map<String,String> sources;
+ Map<String, String> sources;
};
- Map<String,Vertices> vertices;
+ Map<String, Vertices> vertices;
struct Primitives {
@@ -183,12 +176,10 @@ public:
String source;
int offset;
-
-
};
String material;
- Map<String,SourceRef> sources;
+ Map<String, SourceRef> sources;
Vector<float> polygons;
Vector<float> indices;
int count;
@@ -200,12 +191,14 @@ public:
bool found_double_sided;
bool double_sided;
- MeshData() { found_double_sided=false; double_sided=true; }
+ MeshData() {
+ found_double_sided = false;
+ double_sided = true;
+ }
};
struct CurveData {
-
String name;
bool closed;
@@ -216,16 +209,14 @@ public:
int stride;
};
- Map<String,Source> sources;
-
+ Map<String, Source> sources;
- Map<String,String> control_vertices;
+ Map<String, String> control_vertices;
CurveData() {
- closed=false;
+ closed = false;
}
-
};
struct SkinControllerData {
@@ -240,15 +231,15 @@ public:
Vector<float> array;
int stride;
Source() {
- stride=1;
+ stride = 1;
}
};
- Map<String,Source> sources;
+ Map<String, Source> sources;
struct Joints {
- Map<String,String> sources;
+ Map<String, String> sources;
} joints;
struct Weights {
@@ -257,23 +248,20 @@ public:
String source;
int offset;
-
-
};
String material;
- Map<String,SourceRef> sources;
+ Map<String, SourceRef> sources;
Vector<float> sets;
Vector<float> indices;
int count;
} weights;
- Map<String,Transform> bone_rest_map;
+ Map<String, Transform> bone_rest_map;
- SkinControllerData() { use_idrefs=false; }
+ SkinControllerData() { use_idrefs = false; }
};
-
struct MorphControllerData {
String mesh;
@@ -284,21 +272,20 @@ public:
int stride;
Vector<String> sarray; //maybe for names
Vector<float> array;
- Source() { stride=1; }
+ Source() { stride = 1; }
};
- Map<String,Source> sources;
+ Map<String, Source> sources;
- Map<String,String> targets;
- MorphControllerData() { }
+ Map<String, String> targets;
+ MorphControllerData() {}
};
-
struct Vertex {
int idx;
Vector3 vertex;
- Vector3 normal;
+ Vector3 normal;
Vector3 uv;
Vector3 uv2;
Plane tangent;
@@ -307,8 +294,7 @@ public:
struct Weight {
int bone_idx;
float weight;
- bool operator<(const Weight w) const { return weight>w.weight; } //heaviest first
-
+ bool operator<(const Weight w) const { return weight > w.weight; } //heaviest first
};
Vector<Weight> weights;
@@ -316,61 +302,61 @@ public:
void fix_weights() {
weights.sort();
- if (weights.size()>4) {
+ if (weights.size() > 4) {
//cap to 4 and make weights add up 1
weights.resize(4);
- float total=0;
- for(int i=0;i<4;i++)
- total+=weights[i].weight;
+ float total = 0;
+ for (int i = 0; i < 4; i++)
+ total += weights[i].weight;
if (total)
- for(int i=0;i<4;i++)
- weights[i].weight/=total;
-
+ for (int i = 0; i < 4; i++)
+ weights[i].weight /= total;
}
}
void fix_unit_scale(Collada &state);
- bool operator<(const Vertex& p_vert) const {
+ bool operator<(const Vertex &p_vert) const {
- if (uid==p_vert.uid) {
- if (vertex==p_vert.vertex) {
- if(normal==p_vert.normal) {
- if(uv==p_vert.uv) {
- if(uv2==p_vert.uv2) {
+ if (uid == p_vert.uid) {
+ if (vertex == p_vert.vertex) {
+ if (normal == p_vert.normal) {
+ if (uv == p_vert.uv) {
+ if (uv2 == p_vert.uv2) {
if (!weights.empty() || !p_vert.weights.empty()) {
- if (weights.size()==p_vert.weights.size()) {
+ if (weights.size() == p_vert.weights.size()) {
- for(int i=0;i<weights.size();i++) {
- if (weights[i].bone_idx!=p_vert.weights[i].bone_idx)
- return weights[i].bone_idx<p_vert.weights[i].bone_idx;
+ for (int i = 0; i < weights.size(); i++) {
+ if (weights[i].bone_idx != p_vert.weights[i].bone_idx)
+ return weights[i].bone_idx < p_vert.weights[i].bone_idx;
- if (weights[i].weight!=p_vert.weights[i].weight)
- return weights[i].weight<p_vert.weights[i].weight;
+ if (weights[i].weight != p_vert.weights[i].weight)
+ return weights[i].weight < p_vert.weights[i].weight;
}
- } else {
+ } else {
return weights.size() < p_vert.weights.size();
}
-
}
- return (color<p_vert.color);
+ return (color < p_vert.color);
} else
- return (uv2<p_vert.uv2);
+ return (uv2 < p_vert.uv2);
} else
- return (uv<p_vert.uv);
+ return (uv < p_vert.uv);
} else
- return (normal<p_vert.normal);
+ return (normal < p_vert.normal);
} else
- return vertex<p_vert.vertex;
+ return vertex < p_vert.vertex;
} else
return uid < p_vert.uid;
-
}
- Vertex() { uid=0; idx=0; }
+ Vertex() {
+ uid = 0;
+ idx = 0;
+ }
};
struct Node {
@@ -384,7 +370,6 @@ public:
TYPE_GEOMETRY
};
-
struct XForm {
enum Op {
@@ -409,9 +394,9 @@ public:
Vector<XForm> xform_list;
Transform default_transform;
Transform post_transform;
- Vector<Node*> children;
+ Vector<Node *> children;
- Node* parent;
+ Node *parent;
Transform compute_transform(Collada &state) const;
Transform get_global_transform() const;
@@ -419,26 +404,33 @@ public:
bool ignore_anim;
-
- Node() {noname=false; type=TYPE_NODE; parent=NULL; ignore_anim=false; }
- virtual ~Node() { for(int i=0;i<children.size();i++) memdelete( children[i] ); };
-
+ Node() {
+ noname = false;
+ type = TYPE_NODE;
+ parent = NULL;
+ ignore_anim = false;
+ }
+ virtual ~Node() {
+ for (int i = 0; i < children.size(); i++)
+ memdelete(children[i]);
+ };
};
struct NodeSkeleton : public Node {
-
- NodeSkeleton() { type=TYPE_SKELETON; }
+ NodeSkeleton() { type = TYPE_SKELETON; }
};
struct NodeJoint : public Node {
NodeSkeleton *owner;
String sid;
- NodeJoint() { type=TYPE_JOINT; owner=NULL; }
+ NodeJoint() {
+ type = TYPE_JOINT;
+ owner = NULL;
+ }
};
-
struct NodeGeometry : public Node {
bool controller;
@@ -448,36 +440,37 @@ public:
String target;
};
- Map<String,Material> material_map;
+ Map<String, Material> material_map;
Vector<String> skeletons;
- NodeGeometry() { type=TYPE_GEOMETRY; }
+ NodeGeometry() { type = TYPE_GEOMETRY; }
};
struct NodeCamera : public Node {
String camera;
- NodeCamera() { type=TYPE_CAMERA; }
+ NodeCamera() { type = TYPE_CAMERA; }
};
struct NodeLight : public Node {
String light;
- NodeLight() { type=TYPE_LIGHT; }
+ NodeLight() { type = TYPE_LIGHT; }
};
-
struct VisualScene {
String name;
- Vector<Node*> root_nodes;
+ Vector<Node *> root_nodes;
- ~VisualScene() { for(int i=0;i<root_nodes.size();i++) memdelete( root_nodes[i] ); }
+ ~VisualScene() {
+ for (int i = 0; i < root_nodes.size(); i++)
+ memdelete(root_nodes[i]);
+ }
};
-
struct AnimationClip {
String name;
@@ -485,7 +478,10 @@ public:
float end;
Vector<String> tracks;
- AnimationClip() { begin=0; end=1; }
+ AnimationClip() {
+ begin = 0;
+ end = 1;
+ }
};
struct AnimationTrack {
@@ -514,26 +510,22 @@ public:
Point2 out_tangent;
InterpolationType interp_type;
- Key() { interp_type=INTERP_LINEAR; }
+ Key() { interp_type = INTERP_LINEAR; }
};
-
Vector<float> get_value_at_time(float p_time);
Vector<Key> keys;
- AnimationTrack() { property=false; }
+ AnimationTrack() { property = false; }
};
-
/****************/
/* IMPORT STATE */
/****************/
-
struct State {
-
int import_flags;
float unit_scale;
@@ -542,38 +534,38 @@ public:
struct Version {
- int major,minor,rev;
+ int major, minor, rev;
- bool operator<(const Version& p_ver) const { return (major==p_ver.major)?((minor==p_ver.minor)?(rev<p_ver.rev):minor<p_ver.minor):major<p_ver.major; }
- Version(int p_major=0,int p_minor=0,int p_rev=0) { major=p_major; minor=p_minor; rev=p_rev; }
+ bool operator<(const Version &p_ver) const { return (major == p_ver.major) ? ((minor == p_ver.minor) ? (rev < p_ver.rev) : minor < p_ver.minor) : major < p_ver.major; }
+ Version(int p_major = 0, int p_minor = 0, int p_rev = 0) {
+ major = p_major;
+ minor = p_minor;
+ rev = p_rev;
+ }
} version;
+ Map<String, CameraData> camera_data_map;
+ Map<String, MeshData> mesh_data_map;
+ Map<String, LightData> light_data_map;
+ Map<String, CurveData> curve_data_map;
- Map<String,CameraData> camera_data_map;
- Map<String,MeshData> mesh_data_map;
- Map<String,LightData> light_data_map;
- Map<String,CurveData> curve_data_map;
-
-
- Map<String,String> mesh_name_map;
- Map<String,String> morph_name_map;
- Map<String,String> morph_ownership_map;
- Map<String,SkinControllerData> skin_controller_data_map;
- Map<String,MorphControllerData> morph_controller_data_map;
+ Map<String, String> mesh_name_map;
+ Map<String, String> morph_name_map;
+ Map<String, String> morph_ownership_map;
+ Map<String, SkinControllerData> skin_controller_data_map;
+ Map<String, MorphControllerData> morph_controller_data_map;
+ Map<String, Image> image_map;
+ Map<String, Material> material_map;
+ Map<String, Effect> effect_map;
-
- Map<String,Image > image_map;
- Map<String,Material> material_map;
- Map<String,Effect> effect_map;
-
- Map<String,VisualScene> visual_scene_map;
- Map<String,Node*> scene_map;
+ Map<String, VisualScene> visual_scene_map;
+ Map<String, Node *> scene_map;
Set<String> idref_joints;
- Map<String,String> sid_to_node_map;
+ Map<String, String> sid_to_node_map;
//Map<String,NodeJoint*> bone_map;
- Map<String,Transform> bone_rest_map;
+ Map<String, Transform> bone_rest_map;
String local_path;
String root_visual_scene;
@@ -581,81 +573,78 @@ public:
Vector<AnimationClip> animation_clips;
Vector<AnimationTrack> animation_tracks;
- Map<String,Vector<int> > referenced_tracks;
- Map<String,Vector<int> > by_id_tracks;
+ Map<String, Vector<int> > referenced_tracks;
+ Map<String, Vector<int> > by_id_tracks;
float animation_length;
- State() { unit_scale=1.0; up_axis=Vector3::AXIS_Y; import_flags=0; animation_length=0; }
+ State() {
+ unit_scale = 1.0;
+ up_axis = Vector3::AXIS_Y;
+ import_flags = 0;
+ animation_length = 0;
+ }
} state;
-
- Error load(const String& p_path, int p_flags=0);
+ Error load(const String &p_path, int p_flags = 0);
Collada();
- Transform fix_transform(const Transform& p_transform);
+ Transform fix_transform(const Transform &p_transform);
Transform get_root_transform() const;
int get_uv_channel(String p_name);
private: // private stuff
-
- Map<String,int> channel_map;
-
- void _parse_asset(XMLParser& parser);
- void _parse_image(XMLParser& parser);
- void _parse_material(XMLParser& parser);
- void _parse_effect_material(XMLParser& parser,Effect &effect,String &id);
- void _parse_effect(XMLParser& parser);
- void _parse_camera(XMLParser& parser);
- void _parse_light(XMLParser& parser);
- void _parse_animation_clip(XMLParser& parser);
-
- void _parse_mesh_geometry(XMLParser& parser,String p_id,String p_name);
- void _parse_curve_geometry(XMLParser& parser,String p_id,String p_name);
-
- void _parse_skin_controller(XMLParser& parser,String p_id);
- void _parse_morph_controller(XMLParser& parser, String id);
- void _parse_controller(XMLParser& parser);
-
- Node* _parse_visual_instance_geometry(XMLParser& parser);
- Node* _parse_visual_instance_camera(XMLParser& parser);
- Node* _parse_visual_instance_light(XMLParser& parser);
-
- Node* _parse_visual_node_instance_data(XMLParser& parser);
- Node* _parse_visual_scene_node(XMLParser& parser);
- void _parse_visual_scene(XMLParser& parser);
-
- void _parse_animation(XMLParser& parser);
- void _parse_scene(XMLParser& parser);
- void _parse_library(XMLParser& parser);
-
-
- Variant _parse_param(XMLParser& parser);
- Vector<float> _read_float_array(XMLParser& parser);
- Vector<String> _read_string_array(XMLParser& parser);
- Transform _read_transform(XMLParser& parser);
- String _read_empty_draw_type(XMLParser& parser);
+ Map<String, int> channel_map;
+
+ void _parse_asset(XMLParser &parser);
+ void _parse_image(XMLParser &parser);
+ void _parse_material(XMLParser &parser);
+ void _parse_effect_material(XMLParser &parser, Effect &effect, String &id);
+ void _parse_effect(XMLParser &parser);
+ void _parse_camera(XMLParser &parser);
+ void _parse_light(XMLParser &parser);
+ void _parse_animation_clip(XMLParser &parser);
+
+ void _parse_mesh_geometry(XMLParser &parser, String p_id, String p_name);
+ void _parse_curve_geometry(XMLParser &parser, String p_id, String p_name);
+
+ void _parse_skin_controller(XMLParser &parser, String p_id);
+ void _parse_morph_controller(XMLParser &parser, String id);
+ void _parse_controller(XMLParser &parser);
+
+ Node *_parse_visual_instance_geometry(XMLParser &parser);
+ Node *_parse_visual_instance_camera(XMLParser &parser);
+ Node *_parse_visual_instance_light(XMLParser &parser);
+
+ Node *_parse_visual_node_instance_data(XMLParser &parser);
+ Node *_parse_visual_scene_node(XMLParser &parser);
+ void _parse_visual_scene(XMLParser &parser);
+
+ void _parse_animation(XMLParser &parser);
+ void _parse_scene(XMLParser &parser);
+ void _parse_library(XMLParser &parser);
+
+ Variant _parse_param(XMLParser &parser);
+ Vector<float> _read_float_array(XMLParser &parser);
+ Vector<String> _read_string_array(XMLParser &parser);
+ Transform _read_transform(XMLParser &parser);
+ String _read_empty_draw_type(XMLParser &parser);
void _joint_set_owner(Collada::Node *p_node, NodeSkeleton *p_owner);
- void _create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton=NULL);
- void _find_morph_nodes(VisualScene *p_vscene,Node *p_node);
- bool _remove_node(Node *p_parent,Node *p_node);
- void _remove_node(VisualScene *p_vscene,Node *p_node);
+ void _create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton = NULL);
+ void _find_morph_nodes(VisualScene *p_vscene, Node *p_node);
+ bool _remove_node(Node *p_parent, Node *p_node);
+ void _remove_node(VisualScene *p_vscene, Node *p_node);
void _merge_skeletons2(VisualScene *p_vscene);
- void _merge_skeletons(VisualScene *p_vscene,Node *p_node);
- bool _optimize_skeletons(VisualScene *p_vscene,Node *p_node);
-
-
- bool _move_geometry_to_skeletons(VisualScene *p_vscene,Node *p_node,List<Node*> *p_mgeom);
-
+ void _merge_skeletons(VisualScene *p_vscene, Node *p_node);
+ bool _optimize_skeletons(VisualScene *p_vscene, Node *p_node);
+ bool _move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, List<Node *> *p_mgeom);
void _optimize();
-
-
};
#endif // COLLADA_H
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 91ba419c97..03f77dbe94 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -28,41 +28,40 @@
/*************************************************************************/
#include "connections_dialog.h"
-#include "scene/gui/label.h"
-#include "print_string.h"
-#include "editor_settings.h"
#include "editor_node.h"
+#include "editor_settings.h"
#include "plugins/script_editor_plugin.h"
+#include "print_string.h"
+#include "scene/gui/label.h"
class ConnectDialogBinds : public Object {
- GDCLASS( ConnectDialogBinds, Object );
-public:
+ GDCLASS(ConnectDialogBinds, Object);
+public:
Vector<Variant> params;
- bool _set(const StringName& p_name, const Variant& p_value) {
+ bool _set(const StringName &p_name, const Variant &p_value) {
- String name=p_name;
+ String name = p_name;
if (name.begins_with("bind/")) {
- int which = name.get_slice("/",1).to_int()-1;
- ERR_FAIL_INDEX_V(which,params.size(),false);
- params[which]=p_value;
+ int which = name.get_slice("/", 1).to_int() - 1;
+ ERR_FAIL_INDEX_V(which, params.size(), false);
+ params[which] = p_value;
} else
return false;
return true;
}
+ bool _get(const StringName &p_name, Variant &r_ret) const {
- bool _get(const StringName& p_name,Variant &r_ret) const {
-
- String name=p_name;
+ String name = p_name;
if (name.begins_with("bind/")) {
- int which = name.get_slice("/",1).to_int()-1;
- ERR_FAIL_INDEX_V(which,params.size(),false);
+ int which = name.get_slice("/", 1).to_int() - 1;
+ ERR_FAIL_INDEX_V(which, params.size(), false);
r_ret = params[which];
} else
return false;
@@ -72,8 +71,8 @@ public:
void _get_property_list(List<PropertyInfo> *p_list) const {
- for(int i=0;i<params.size();i++) {
- p_list->push_back( PropertyInfo( params[i].get_type(), "bind/"+itos(i+1)) );
+ for (int i = 0; i < params.size(); i++) {
+ p_list->push_back(PropertyInfo(params[i].get_type(), "bind/" + itos(i + 1)));
}
}
@@ -83,20 +82,18 @@ public:
}
ConnectDialogBinds() {
-
-
}
};
void ConnectDialog::_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()));
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
bind_editor->edit(cdbinds);
}
}
@@ -104,14 +101,13 @@ void ConnectDialog::_notification(int p_what) {
void ConnectDialog::_tree_node_selected() {
//dst_method_list->get_popup()->clear();
- Node *current=tree->get_selected();
+ Node *current = tree->get_selected();
if (!current) {
make_callback->hide();
return;
}
-
if (current->get_script().is_null())
make_callback->hide();
else
@@ -144,8 +140,6 @@ void ConnectDialog::_tree_node_selected() {
}
#endif
dst_path->set_text(node->get_path_to(current));
-
-
}
void ConnectDialog::_dst_method_list_selected(int p_idx) {
@@ -155,13 +149,12 @@ void ConnectDialog::_dst_method_list_selected(int p_idx) {
void ConnectDialog::edit(Node *p_node) {
- node=p_node;
+ node = p_node;
//dst_method_list->get_popup()->clear();
-
tree->set_selected(NULL);
- tree->set_marked(node,true);
+ tree->set_marked(node, true);
dst_path->set_text("");
dst_method->set_text("");
deferred->set_pressed(false);
@@ -172,13 +165,13 @@ void ConnectDialog::edit(Node *p_node) {
void ConnectDialog::ok_pressed() {
- if (dst_method->get_text()=="") {
+ if (dst_method->get_text() == "") {
error->set_text(TTR("Method in target Node must be specified!"));
error->popup_centered_minsize();
return;
}
- Node* target = tree->get_selected();
+ Node *target = tree->get_selected();
if (target->get_script().is_null()) {
if (!target->has_method(dst_method->get_text())) {
error->set_text(TTR("Target method not found! Specify a valid method or attach a script to target Node."));
@@ -188,20 +181,17 @@ void ConnectDialog::ok_pressed() {
}
emit_signal("connected");
hide();
-
}
void ConnectDialog::_cancel_pressed() {
hide();
}
-
NodePath ConnectDialog::get_dst_path() const {
return dst_path->get_text();
}
-
bool ConnectDialog::get_deferred() const {
return deferred->is_pressed();
@@ -214,16 +204,14 @@ bool ConnectDialog::get_oneshot() const {
StringName ConnectDialog::get_dst_method() const {
- String txt=dst_method->get_text();
- if (txt.find("(")!=-1)
- txt=txt.left( txt.find("(")).strip_edges();
+ String txt = dst_method->get_text();
+ if (txt.find("(") != -1)
+ txt = txt.left(txt.find("(")).strip_edges();
return txt;
}
-
Vector<Variant> ConnectDialog::get_binds() const {
-
return cdbinds->params;
}
@@ -235,9 +223,9 @@ void ConnectDialog::_add_bind() {
Variant value;
- switch(vt) {
+ switch (vt) {
- case Variant::BOOL: value = false ; break;
+ case Variant::BOOL: value = false; break;
case Variant::INT: value = 0; break;
case Variant::REAL: value = 0.0; break;
case Variant::STRING: value = ""; break;
@@ -255,32 +243,30 @@ void ConnectDialog::_add_bind() {
default: { ERR_FAIL(); } break;
}
- ERR_FAIL_COND(value.get_type()==Variant::NIL);
+ ERR_FAIL_COND(value.get_type() == Variant::NIL);
cdbinds->params.push_back(value);
cdbinds->notify_changed();
-
}
void ConnectDialog::_remove_bind() {
String st = bind_editor->get_selected_path();
- if (st=="")
+ if (st == "")
return;
- int idx = st.get_slice("/",1).to_int()-1;
+ int idx = st.get_slice("/", 1).to_int() - 1;
- ERR_FAIL_INDEX(idx,cdbinds->params.size());
+ ERR_FAIL_INDEX(idx, cdbinds->params.size());
cdbinds->params.remove(idx);
cdbinds->notify_changed();
-
}
-void ConnectDialog::set_dst_node(Node* p_node) {
+void ConnectDialog::set_dst_node(Node *p_node) {
tree->set_selected(p_node);
}
-void ConnectDialog::set_dst_method(const StringName& p_method) {
+void ConnectDialog::set_dst_method(const StringName &p_method) {
dst_method->set_text(p_method);
}
@@ -288,92 +274,84 @@ void ConnectDialog::set_dst_method(const StringName& p_method) {
void ConnectDialog::_bind_methods() {
//ClassDB::bind_method("_ok",&ConnectDialog::_ok_pressed);
- ClassDB::bind_method("_cancel",&ConnectDialog::_cancel_pressed);
+ ClassDB::bind_method("_cancel", &ConnectDialog::_cancel_pressed);
//ClassDB::bind_method("_dst_method_list_selected",&ConnectDialog::_dst_method_list_selected);
- ClassDB::bind_method("_tree_node_selected",&ConnectDialog::_tree_node_selected);
+ ClassDB::bind_method("_tree_node_selected", &ConnectDialog::_tree_node_selected);
- ClassDB::bind_method("_add_bind",&ConnectDialog::_add_bind);
- ClassDB::bind_method("_remove_bind",&ConnectDialog::_remove_bind);
+ ClassDB::bind_method("_add_bind", &ConnectDialog::_add_bind);
+ ClassDB::bind_method("_remove_bind", &ConnectDialog::_remove_bind);
- ADD_SIGNAL( MethodInfo("connected") );
+ ADD_SIGNAL(MethodInfo("connected"));
}
ConnectDialog::ConnectDialog() {
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
-
- HBoxContainer *main_hb = memnew( HBoxContainer );
+ HBoxContainer *main_hb = memnew(HBoxContainer);
vbc->add_child(main_hb);
main_hb->set_v_size_flags(SIZE_EXPAND_FILL);
- VBoxContainer *vbc_left = memnew( VBoxContainer );
+ VBoxContainer *vbc_left = memnew(VBoxContainer);
main_hb->add_child(vbc_left);
vbc_left->set_h_size_flags(SIZE_EXPAND_FILL);
-
tree = memnew(SceneTreeEditor(false));
- tree->get_scene_tree()->connect("item_activated",this,"_ok");
- vbc_left->add_margin_child(TTR("Connect To Node:"),tree,true);
-
+ tree->get_scene_tree()->connect("item_activated", this, "_ok");
+ vbc_left->add_margin_child(TTR("Connect To Node:"), tree, true);
-
- VBoxContainer *vbc_right = memnew( VBoxContainer );
+ VBoxContainer *vbc_right = memnew(VBoxContainer);
main_hb->add_child(vbc_right);
vbc_right->set_h_size_flags(SIZE_EXPAND_FILL);
- HBoxContainer *add_bind_hb = memnew( HBoxContainer );
+ HBoxContainer *add_bind_hb = memnew(HBoxContainer);
- type_list = memnew( OptionButton );
+ type_list = memnew(OptionButton);
type_list->set_h_size_flags(SIZE_EXPAND_FILL);
add_bind_hb->add_child(type_list);
-
- type_list->add_item("bool",Variant::BOOL);
- type_list->add_item("int",Variant::INT);
- type_list->add_item("real",Variant::REAL);
- type_list->add_item("string",Variant::STRING);
+ type_list->add_item("bool", Variant::BOOL);
+ type_list->add_item("int", Variant::INT);
+ type_list->add_item("real", Variant::REAL);
+ type_list->add_item("string", Variant::STRING);
//type_list->add_separator();
- type_list->add_item("Vector2",Variant::VECTOR2);
- type_list->add_item("Rect2",Variant::RECT2);
- type_list->add_item("Vector3",Variant::VECTOR3);
- type_list->add_item("Plane",Variant::PLANE);
- type_list->add_item("Quat",Variant::QUAT);
- type_list->add_item("Rect3",Variant::RECT3);
- type_list->add_item("Basis",Variant::BASIS);
- type_list->add_item("Transform",Variant::TRANSFORM);
+ type_list->add_item("Vector2", Variant::VECTOR2);
+ type_list->add_item("Rect2", Variant::RECT2);
+ type_list->add_item("Vector3", Variant::VECTOR3);
+ type_list->add_item("Plane", Variant::PLANE);
+ type_list->add_item("Quat", Variant::QUAT);
+ type_list->add_item("Rect3", Variant::RECT3);
+ type_list->add_item("Basis", Variant::BASIS);
+ type_list->add_item("Transform", Variant::TRANSFORM);
//type_list->add_separator();
- type_list->add_item("Color",Variant::COLOR);
- type_list->add_item("Image",Variant::IMAGE);
+ type_list->add_item("Color", Variant::COLOR);
+ type_list->add_item("Image", Variant::IMAGE);
type_list->select(0);
- Button *add_bind = memnew( Button );
+ Button *add_bind = memnew(Button);
add_bind->set_text(TTR("Add"));
add_bind_hb->add_child(add_bind);
- add_bind->connect("pressed",this,"_add_bind");
+ add_bind->connect("pressed", this, "_add_bind");
- Button *del_bind = memnew( Button );
+ Button *del_bind = memnew(Button);
del_bind->set_text(TTR("Remove"));
add_bind_hb->add_child(del_bind);
- del_bind->connect("pressed",this,"_remove_bind");
+ del_bind->connect("pressed", this, "_remove_bind");
- vbc_right->add_margin_child(TTR("Add Extra Call Argument:"),add_bind_hb);
+ vbc_right->add_margin_child(TTR("Add Extra Call Argument:"), add_bind_hb);
- bind_editor = memnew( PropertyEditor );
+ bind_editor = memnew(PropertyEditor);
bind_editor->hide_top_label();
- vbc_right->add_margin_child(TTR("Extra Call Arguments:"),bind_editor,true);
-
-
+ vbc_right->add_margin_child(TTR("Extra Call Arguments:"), bind_editor, true);
dst_path = memnew(LineEdit);
- vbc->add_margin_child(TTR("Path to Node:"),dst_path);
+ vbc->add_margin_child(TTR("Path to Node:"), dst_path);
-
- HBoxContainer *dstm_hb = memnew( HBoxContainer );
- vbc->add_margin_child("Method In Node:",dstm_hb);
+ HBoxContainer *dstm_hb = memnew(HBoxContainer);
+ vbc->add_margin_child("Method In Node:", dstm_hb);
dst_method = memnew(LineEdit);
dst_method->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -390,21 +368,21 @@ ConnectDialog::ConnectDialog() {
*/
//add_child(dst_method_list);
- make_callback = memnew( CheckButton );
+ make_callback = memnew(CheckButton);
make_callback->set_toggle_mode(true);
- make_callback->set_pressed( EDITOR_DEF("text_editor/tools/create_signal_callbacks",true));
+ make_callback->set_pressed(EDITOR_DEF("text_editor/tools/create_signal_callbacks", true));
make_callback->set_text(TTR("Make Function"));
dstm_hb->add_child(make_callback);
- deferred = memnew( CheckButton );
+ deferred = memnew(CheckButton);
deferred->set_text(TTR("Deferred"));
dstm_hb->add_child(deferred);
- oneshot = memnew( CheckButton );
+ oneshot = memnew(CheckButton);
oneshot->set_text(TTR("Oneshot"));
dstm_hb->add_child(oneshot);
-/*
+ /*
realtime = memnew( CheckButton );
realtime->set_anchor( MARGIN_TOP, ANCHOR_END );
realtime->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
@@ -415,38 +393,27 @@ ConnectDialog::ConnectDialog() {
add_child(realtime);
*/
-
-
-
//dst_method_list->get_popup()->connect("id_pressed", this,"_dst_method_list_selected");
- tree->connect("node_selected", this,"_tree_node_selected");
+ tree->connect("node_selected", this, "_tree_node_selected");
set_as_toplevel(true);
- cdbinds = memnew( ConnectDialogBinds );
+ cdbinds = memnew(ConnectDialogBinds);
- error = memnew( ConfirmationDialog );
+ error = memnew(ConfirmationDialog);
add_child(error);
error->get_ok()->set_text(TTR("Close"));
get_ok()->set_text(TTR("Connect"));
//error->get_cancel()->set_text("Close");
-
-
-
-
}
-
-ConnectDialog::~ConnectDialog()
-{
- memdelete( cdbinds );
+ConnectDialog::~ConnectDialog() {
+ memdelete(cdbinds);
}
-
-
void ConnectionsDock::_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()));
@@ -462,94 +429,88 @@ void ConnectionsDock::_connect() {
TreeItem *it = tree->get_selected();
ERR_FAIL_COND(!it);
- String signal=it->get_metadata(0).operator Dictionary()["name"];
+ String signal = it->get_metadata(0).operator Dictionary()["name"];
- NodePath dst_path=connect_dialog->get_dst_path();
+ NodePath dst_path = connect_dialog->get_dst_path();
Node *target = node->get_node(dst_path);
ERR_FAIL_COND(!target);
- StringName dst_method=connect_dialog->get_dst_method();
- bool defer=connect_dialog->get_deferred();
- bool oshot=connect_dialog->get_oneshot();
+ StringName dst_method = connect_dialog->get_dst_method();
+ bool defer = connect_dialog->get_deferred();
+ bool oshot = connect_dialog->get_oneshot();
Vector<Variant> binds = connect_dialog->get_binds();
- PoolStringArray args = it->get_metadata(0).operator Dictionary()["args"];
- int flags = CONNECT_PERSIST | (defer?CONNECT_DEFERRED:0) | (oshot?CONNECT_ONESHOT:0);
+ PoolStringArray args = it->get_metadata(0).operator Dictionary()["args"];
+ int flags = CONNECT_PERSIST | (defer ? CONNECT_DEFERRED : 0) | (oshot ? CONNECT_ONESHOT : 0);
- undo_redo->create_action(vformat(TTR("Connect '%s' to '%s'"),signal,String(dst_method)));
- undo_redo->add_do_method(node,"connect",signal,target,dst_method,binds,flags);
- undo_redo->add_undo_method(node,"disconnect",signal,target,dst_method);
- undo_redo->add_do_method(this,"update_tree");
- undo_redo->add_undo_method(this,"update_tree");
- undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(),"update_tree"); //to force redraw of scene tree
- undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(),"update_tree"); //to force redraw of scene tree
+ undo_redo->create_action(vformat(TTR("Connect '%s' to '%s'"), signal, String(dst_method)));
+ undo_redo->add_do_method(node, "connect", signal, target, dst_method, binds, flags);
+ undo_redo->add_undo_method(node, "disconnect", signal, target, dst_method);
+ undo_redo->add_do_method(this, "update_tree");
+ undo_redo->add_undo_method(this, "update_tree");
+ undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
+ undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
undo_redo->commit_action();
-
if (connect_dialog->get_make_callback()) {
print_line("request connect");
- editor->emit_signal("script_add_function_request",target,dst_method,args);
+ editor->emit_signal("script_add_function_request", target, dst_method, args);
hide();
}
update_tree();
-
}
-
-
-
void ConnectionsDock::_connect_pressed() {
-
TreeItem *item = tree->get_selected();
if (!item) {
//no idea how this happened, but disable
connect_button->set_disabled(true);
return;
}
- if (item->get_parent()==tree->get_root() || item->get_parent()->get_parent()==tree->get_root()) {
+ if (item->get_parent() == tree->get_root() || item->get_parent()->get_parent() == tree->get_root()) {
//a signal - connect
- String signal=item->get_metadata(0).operator Dictionary()["name"];
- String signalname=signal;
- String midname=node->get_name();
- for(int i=0;i<midname.length();i++) {
+ String signal = item->get_metadata(0).operator Dictionary()["name"];
+ String signalname = signal;
+ String midname = node->get_name();
+ for (int i = 0; i < midname.length(); i++) {
CharType c = midname[i];
- if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_') {
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_') {
//all good
- } else if (c==' ') {
- c='_';
+ } else if (c == ' ') {
+ c = '_';
} else {
midname.remove(i);
i--;
continue;
}
- midname[i]=c;
+ midname[i] = c;
}
connect_dialog->edit(node);
connect_dialog->popup_centered_ratio();
- connect_dialog->set_title(TTR("Connecting Signal:")+" "+signalname);
- connect_dialog->set_dst_method("_on_"+midname+"_"+signal);
- connect_dialog->set_dst_node(node->get_owner()?node->get_owner():node);
+ connect_dialog->set_title(TTR("Connecting Signal:") + " " + signalname);
+ connect_dialog->set_dst_method("_on_" + midname + "_" + signal);
+ connect_dialog->set_dst_node(node->get_owner() ? node->get_owner() : node);
} else {
//a slot- disconnect
- Connection c=item->get_metadata(0);
- ERR_FAIL_COND(c.source!=node); //shouldn't happen but...bugcheck
+ Connection c = item->get_metadata(0);
+ ERR_FAIL_COND(c.source != node); //shouldn't happen but...bugcheck
undo_redo->create_action(TTR("Create Subscription"));
- undo_redo->add_do_method(node,"disconnect",c.signal,c.target,c.method);
- undo_redo->add_undo_method(node,"connect",c.signal,c.target,c.method,Vector<Variant>(),c.flags);
- undo_redo->add_do_method(this,"update_tree");
- undo_redo->add_undo_method(this,"update_tree");
- undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(),"update_tree"); //to force redraw of scene tree
- undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(),"update_tree"); //to force redraw of scene tree
+ undo_redo->add_do_method(node, "disconnect", c.signal, c.target, c.method);
+ undo_redo->add_undo_method(node, "connect", c.signal, c.target, c.method, Vector<Variant>(), c.flags);
+ undo_redo->add_do_method(this, "update_tree");
+ undo_redo->add_undo_method(this, "update_tree");
+ undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
+ undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
undo_redo->commit_action();
- c.source->disconnect(c.signal,c.target,c.method);
+ c.source->disconnect(c.signal, c.target, c.method);
update_tree();
}
}
@@ -592,30 +553,29 @@ void ConnectionsDock::_remove_confirm() {
struct _ConnectionsDockMethodInfoSort {
- _FORCE_INLINE_ bool operator()(const MethodInfo& a, const MethodInfo& b) const {
+ _FORCE_INLINE_ bool operator()(const MethodInfo &a, const MethodInfo &b) const {
return a.name < b.name;
}
};
void ConnectionsDock::update_tree() {
- tree->clear();
+ tree->clear();
if (!node)
return;
-
- TreeItem *root=tree->create_item();
+ TreeItem *root = tree->create_item();
List<MethodInfo> node_signals;
node->get_signal_list(&node_signals);
//node_signals.sort_custom<_ConnectionsDockMethodInfoSort>();
- bool did_script=false;
+ bool did_script = false;
StringName base = node->get_class();
- while(base) {
+ while (base) {
List<MethodInfo> node_signals;
Ref<Texture> icon;
@@ -627,128 +587,122 @@ void ConnectionsDock::update_tree() {
if (scr.is_valid()) {
scr->get_script_signal_list(&node_signals);
if (scr->get_path().is_resource_file())
- name=scr->get_path().get_file();
+ name = scr->get_path().get_file();
else
- name=scr->get_class();
+ name = scr->get_class();
- if (has_icon(scr->get_class(),"EditorIcons")) {
- icon=get_icon(scr->get_class(),"EditorIcons");
+ if (has_icon(scr->get_class(), "EditorIcons")) {
+ icon = get_icon(scr->get_class(), "EditorIcons");
}
}
} else {
- ClassDB::get_signal_list(base,&node_signals,true);
- if (has_icon(base,"EditorIcons")) {
- icon=get_icon(base,"EditorIcons");
+ ClassDB::get_signal_list(base, &node_signals, true);
+ if (has_icon(base, "EditorIcons")) {
+ icon = get_icon(base, "EditorIcons");
}
- name=base;
+ name = base;
}
-
TreeItem *pitem = NULL;
if (node_signals.size()) {
- pitem=tree->create_item(root);
- pitem->set_text(0,name);
- pitem->set_icon(0,icon);
- pitem->set_selectable(0,false);
- pitem->set_editable(0,false);
- pitem->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
+ pitem = tree->create_item(root);
+ pitem->set_text(0, name);
+ pitem->set_icon(0, icon);
+ pitem->set_selectable(0, false);
+ pitem->set_editable(0, false);
+ pitem->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
node_signals.sort();
}
- for(List<MethodInfo>::Element *E=node_signals.front();E;E=E->next()) {
+ for (List<MethodInfo>::Element *E = node_signals.front(); E; E = E->next()) {
-
- MethodInfo &mi =E->get();
+ MethodInfo &mi = E->get();
String signaldesc;
- signaldesc=mi.name+"(";
+ signaldesc = mi.name + "(";
PoolStringArray argnames;
if (mi.arguments.size()) {
- signaldesc+=" ";
- for(int i=0;i<mi.arguments.size();i++) {
+ signaldesc += " ";
+ for (int i = 0; i < mi.arguments.size(); i++) {
PropertyInfo &pi = mi.arguments[i];
- if (i>0)
- signaldesc+=", ";
- String tname="var";
- if (pi.type!=Variant::NIL) {
- tname=Variant::get_type_name(pi.type);
+ if (i > 0)
+ signaldesc += ", ";
+ String tname = "var";
+ if (pi.type != Variant::NIL) {
+ tname = Variant::get_type_name(pi.type);
}
- signaldesc+=tname+" "+(pi.name==""?String("arg "+itos(i)):pi.name);
- argnames.push_back(pi.name+":"+tname);
-
+ signaldesc += tname + " " + (pi.name == "" ? String("arg " + itos(i)) : pi.name);
+ argnames.push_back(pi.name + ":" + tname);
}
- signaldesc+=" ";
+ signaldesc += " ";
}
- signaldesc+=")";
+ signaldesc += ")";
- TreeItem *item=tree->create_item(pitem);
- item->set_text(0,signaldesc);
+ TreeItem *item = tree->create_item(pitem);
+ item->set_text(0, signaldesc);
Dictionary sinfo;
- sinfo["name"]=mi.name;
- sinfo["args"]=argnames;
- item->set_metadata(0,sinfo);
- item->set_icon(0,get_icon("Signal","EditorIcons"));
+ sinfo["name"] = mi.name;
+ sinfo["args"] = argnames;
+ item->set_metadata(0, sinfo);
+ item->set_icon(0, get_icon("Signal", "EditorIcons"));
List<Object::Connection> connections;
- node->get_signal_connection_list(mi.name,&connections);
+ node->get_signal_connection_list(mi.name, &connections);
- for(List<Object::Connection>::Element *F=connections.front();F;F=F->next()) {
+ for (List<Object::Connection>::Element *F = connections.front(); F; F = F->next()) {
- Object::Connection&c = F->get();
- if (!(c.flags&CONNECT_PERSIST))
+ Object::Connection &c = F->get();
+ if (!(c.flags & CONNECT_PERSIST))
continue;
Node *target = c.target->cast_to<Node>();
if (!target)
continue;
- String path = String(node->get_path_to(target))+" :: "+c.method+"()";
- if (c.flags&CONNECT_DEFERRED)
- path+=" (deferred)";
- if (c.flags&CONNECT_ONESHOT)
- path+=" (oneshot)";
+ String path = String(node->get_path_to(target)) + " :: " + c.method + "()";
+ if (c.flags & CONNECT_DEFERRED)
+ path += " (deferred)";
+ if (c.flags & CONNECT_ONESHOT)
+ path += " (oneshot)";
if (c.binds.size()) {
- path+=" binds( ";
- for(int i=0;i<c.binds.size();i++) {
+ path += " binds( ";
+ for (int i = 0; i < c.binds.size(); i++) {
- if (i>0)
- path+=", ";
- path+=c.binds[i].operator String();
+ if (i > 0)
+ path += ", ";
+ path += c.binds[i].operator String();
}
- path+=" )";
+ path += " )";
}
- TreeItem *item2=tree->create_item(item);
- item2->set_text(0,path);
- item2->set_metadata(0,c);
- item2->set_icon(0,get_icon("Slot","EditorIcons"));
-
-
+ TreeItem *item2 = tree->create_item(item);
+ item2->set_text(0, path);
+ item2->set_metadata(0, c);
+ item2->set_icon(0, get_icon("Slot", "EditorIcons"));
}
}
if (!did_script) {
- did_script=true;
+ did_script = true;
} else {
- base=ClassDB::get_parent_class(base);
+ base = ClassDB::get_parent_class(base);
}
}
connect_button->set_text(TTR("Connect"));
connect_button->set_disabled(true);
-
}
-void ConnectionsDock::set_node(Node* p_node) {
+void ConnectionsDock::set_node(Node *p_node) {
- node=p_node;
+ node = p_node;
update_tree();
}
@@ -760,7 +714,7 @@ void ConnectionsDock::_something_selected() {
connect_button->set_text(TTR("Connect.."));
connect_button->set_disabled(true);
- } else if (item->get_parent()==tree->get_root() || item->get_parent()->get_parent()==tree->get_root()) {
+ } else if (item->get_parent() == tree->get_root() || item->get_parent()->get_parent() == tree->get_root()) {
//a signal - connect
connect_button->set_text(TTR("Connect.."));
connect_button->set_disabled(false);
@@ -770,7 +724,6 @@ void ConnectionsDock::_something_selected() {
connect_button->set_text(TTR("Disconnect"));
connect_button->set_disabled(false);
}
-
}
void ConnectionsDock::_something_activated() {
@@ -780,87 +733,83 @@ void ConnectionsDock::_something_activated() {
if (!item)
return;
- if (item->get_parent()==tree->get_root() || item->get_parent()->get_parent()==tree->get_root()) {
+ if (item->get_parent() == tree->get_root() || item->get_parent()->get_parent() == tree->get_root()) {
// a signal - connect
- String signal=item->get_metadata(0).operator Dictionary()["name"];
- String midname=node->get_name();
- for(int i=0;i<midname.length();i++) {
+ String signal = item->get_metadata(0).operator Dictionary()["name"];
+ String midname = node->get_name();
+ for (int i = 0; i < midname.length(); i++) {
CharType c = midname[i];
- if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_') {
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_') {
//all good
- } else if (c==' ') {
- c='_';
+ } else if (c == ' ') {
+ c = '_';
} else {
midname.remove(i);
i--;
continue;
}
- midname[i]=c;
+ midname[i] = c;
}
connect_dialog->edit(node);
connect_dialog->popup_centered_ratio();
- connect_dialog->set_dst_method("_on_"+midname+"_"+signal);
- connect_dialog->set_dst_node(node->get_owner()?node->get_owner():node);
+ connect_dialog->set_dst_method("_on_" + midname + "_" + signal);
+ connect_dialog->set_dst_node(node->get_owner() ? node->get_owner() : node);
} else {
// a slot - go to target method
- Connection c=item->get_metadata(0);
- ERR_FAIL_COND(c.source!=node); //shouldn't happen but...bugcheck
+ Connection c = item->get_metadata(0);
+ ERR_FAIL_COND(c.source != node); //shouldn't happen but...bugcheck
if (!c.target)
return;
Ref<Script> script = c.target->get_script();
- if (script.is_valid() && ScriptEditor::get_singleton()->script_go_to_method(script,c.method)) {
- editor->call("_editor_select",EditorNode::EDITOR_SCRIPT);
+ if (script.is_valid() && ScriptEditor::get_singleton()->script_go_to_method(script, c.method)) {
+ editor->call("_editor_select", EditorNode::EDITOR_SCRIPT);
}
}
}
void ConnectionsDock::_bind_methods() {
-
- ClassDB::bind_method("_connect",&ConnectionsDock::_connect);
- ClassDB::bind_method("_something_selected",&ConnectionsDock::_something_selected);
- ClassDB::bind_method("_something_activated",&ConnectionsDock::_something_activated);
- ClassDB::bind_method("_close",&ConnectionsDock::_close);
- ClassDB::bind_method("_connect_pressed",&ConnectionsDock::_connect_pressed);
- ClassDB::bind_method("update_tree",&ConnectionsDock::update_tree);
-
-
+ ClassDB::bind_method("_connect", &ConnectionsDock::_connect);
+ ClassDB::bind_method("_something_selected", &ConnectionsDock::_something_selected);
+ ClassDB::bind_method("_something_activated", &ConnectionsDock::_something_activated);
+ ClassDB::bind_method("_close", &ConnectionsDock::_close);
+ ClassDB::bind_method("_connect_pressed", &ConnectionsDock::_connect_pressed);
+ ClassDB::bind_method("update_tree", &ConnectionsDock::update_tree);
}
ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
- editor=p_editor;
+ editor = p_editor;
set_name(TTR("Signals"));
-
VBoxContainer *vbc = this;
- tree = memnew( Tree );
+ tree = memnew(Tree);
tree->set_columns(1);
tree->set_select_mode(Tree::SELECT_ROW);
tree->set_hide_root(true);
vbc->add_child(tree);
tree->set_v_size_flags(SIZE_EXPAND_FILL);
- connect_button = memnew( Button );
+ connect_button = memnew(Button);
connect_button->set_text("Connect");
- HBoxContainer *hb = memnew( HBoxContainer);
+ HBoxContainer *hb = memnew(HBoxContainer);
vbc->add_child(hb);
hb->add_spacer();
hb->add_child(connect_button);
- connect_button->connect("pressed",this,"_connect_pressed");
+ connect_button->connect("pressed", this, "_connect_pressed");
//add_child(tree);
- connect_dialog = memnew( ConnectDialog );
+ connect_dialog = memnew(ConnectDialog);
connect_dialog->set_as_toplevel(true);
add_child(connect_dialog);
- remove_confirm = memnew( ConfirmationDialog );
+ remove_confirm = memnew(ConfirmationDialog);
remove_confirm->set_as_toplevel(true);
add_child(remove_confirm);
@@ -873,18 +822,13 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
node_only->set_end( Point2( 10,44) );
*/
+ remove_confirm->connect("confirmed", this, "_remove_confirm");
+ connect_dialog->connect("connected", this, "_connect");
+ tree->connect("item_selected", this, "_something_selected");
+ tree->connect("item_activated", this, "_something_activated");
- remove_confirm->connect("confirmed", this,"_remove_confirm");
- connect_dialog->connect("connected", this,"_connect");
- tree->connect("item_selected", this,"_something_selected");
- tree->connect("item_activated", this,"_something_activated");
-
- add_constant_override("separation",3*EDSCALE);
+ add_constant_override("separation", 3 * EDSCALE);
}
-
-ConnectionsDock::~ConnectionsDock()
-{
+ConnectionsDock::~ConnectionsDock() {
}
-
-
diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h
index 6407b83f6e..240e3655ed 100644
--- a/editor/connections_dialog.h
+++ b/editor/connections_dialog.h
@@ -29,15 +29,15 @@
#ifndef CONNECTIONS_DIALOG_H
#define CONNECTIONS_DIALOG_H
-#include "scene/gui/popup.h"
+#include "editor/property_editor.h"
+#include "editor/scene_tree_editor.h"
#include "scene/gui/button.h"
#include "scene/gui/check_button.h"
-#include "scene/gui/tree.h"
#include "scene/gui/dialogs.h"
-#include "scene/gui/menu_button.h"
#include "scene/gui/line_edit.h"
-#include "editor/scene_tree_editor.h"
-#include "editor/property_editor.h"
+#include "scene/gui/menu_button.h"
+#include "scene/gui/popup.h"
+#include "scene/gui/tree.h"
#include "undo_redo.h"
/**
@@ -48,8 +48,7 @@ class ConnectDialogBinds;
class ConnectDialog : public ConfirmationDialog {
- GDCLASS( ConnectDialog, ConfirmationDialog );
-
+ GDCLASS(ConnectDialog, ConfirmationDialog);
ConfirmationDialog *error;
LineEdit *dst_path;
@@ -71,20 +70,18 @@ class ConnectDialog : public ConfirmationDialog {
void _remove_bind();
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
-
+public:
bool get_make_callback() { return make_callback->is_visible() && make_callback->is_pressed(); }
NodePath get_dst_path() const;
StringName get_dst_method() const;
bool get_deferred() const;
bool get_oneshot() const;
Vector<Variant> get_binds() const;
- void set_dst_method(const StringName& p_method);
- void set_dst_node(Node* p_node);
+ void set_dst_method(const StringName &p_method);
+ void set_dst_node(Node *p_node);
//Button *get_ok() { return ok; }
//Button *get_cancel() { return cancel; }
@@ -92,12 +89,11 @@ public:
ConnectDialog();
~ConnectDialog();
-
};
class ConnectionsDock : public VBoxContainer {
- GDCLASS( ConnectionsDock , VBoxContainer );
+ GDCLASS(ConnectionsDock, VBoxContainer);
Button *connect_button;
EditorNode *editor;
@@ -115,20 +111,18 @@ class ConnectionsDock : public VBoxContainer {
UndoRedo *undo_redo;
protected:
-
void _connect_pressed();
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_undoredo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; }
+public:
+ void set_undoredo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
- void set_node(Node* p_node);
+ void set_node(Node *p_node);
String get_selected_type();
- ConnectionsDock(EditorNode *p_editor=NULL);
+ ConnectionsDock(EditorNode *p_editor = NULL);
~ConnectionsDock();
-
};
#endif
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 58bb148ce1..af62a2293b 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -29,39 +29,38 @@
#include "create_dialog.h"
#include "class_db.h"
+#include "editor_node.h"
#include "print_string.h"
#include "scene/gui/box_container.h"
-#include "editor_node.h"
#if 1
-#include "os/keyboard.h"
-#include "editor_settings.h"
#include "editor_help.h"
-
+#include "editor_settings.h"
+#include "os/keyboard.h"
void CreateDialog::popup(bool p_dontclear) {
recent->clear();
- FileAccess *f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("create_recent."+base_type), FileAccess::READ );
+ FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_path().plus_file("create_recent." + base_type), FileAccess::READ);
if (f) {
TreeItem *root = recent->create_item();
- while(!f->eof_reached()) {
+ while (!f->eof_reached()) {
String l = f->get_line().strip_edges();
- if (l!=String()) {
+ if (l != String()) {
TreeItem *ti = recent->create_item(root);
- ti->set_text(0,l);
- if (has_icon(l,"EditorIcons")) {
+ ti->set_text(0, l);
+ if (has_icon(l, "EditorIcons")) {
- ti->set_icon(0,get_icon(l,"EditorIcons"));
+ ti->set_icon(0, get_icon(l, "EditorIcons"));
} else {
- ti->set_icon(0,get_icon("Object","EditorIcons"));
+ ti->set_icon(0, get_icon("Object", "EditorIcons"));
}
}
}
@@ -71,17 +70,16 @@ void CreateDialog::popup(bool p_dontclear) {
favorites->clear();
- f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("favorites."+base_type), FileAccess::READ );
+ f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_path().plus_file("favorites." + base_type), FileAccess::READ);
favorite_list.clear();
if (f) {
-
- while(!f->eof_reached()) {
+ while (!f->eof_reached()) {
String l = f->get_line().strip_edges();
- if (l!=String()) {
+ if (l != String()) {
favorite_list.push_back(l);
}
}
@@ -123,64 +121,57 @@ void CreateDialog::popup(bool p_dontclear) {
search_box->grab_focus();
_update_search();
-
-
}
-
-void CreateDialog::_text_changed(const String& p_newtext) {
+void CreateDialog::_text_changed(const String &p_newtext) {
_update_search();
}
-void CreateDialog::_sbox_input(const InputEvent& p_ie) {
+void CreateDialog::_sbox_input(const InputEvent &p_ie) {
- if (p_ie.type==InputEvent::KEY && (
- p_ie.key.scancode == KEY_UP ||
- p_ie.key.scancode == KEY_DOWN ||
- p_ie.key.scancode == KEY_PAGEUP ||
- p_ie.key.scancode == KEY_PAGEDOWN ) ) {
+ if (p_ie.type == InputEvent::KEY && (p_ie.key.scancode == KEY_UP ||
+ p_ie.key.scancode == KEY_DOWN ||
+ p_ie.key.scancode == KEY_PAGEUP ||
+ p_ie.key.scancode == KEY_PAGEDOWN)) {
- search_options->call("_gui_input",p_ie);
+ search_options->call("_gui_input", p_ie);
search_box->accept_event();
}
-
}
-void CreateDialog::add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root,TreeItem **to_select) {
+void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select) {
if (p_types.has(p_type))
return;
- if (!ClassDB::is_parent_class(p_type,base_type) || p_type==base_type)
+ if (!ClassDB::is_parent_class(p_type, base_type) || p_type == base_type)
return;
- String inherits=ClassDB::get_parent_class(p_type);
-
- TreeItem *parent=p_root;
+ String inherits = ClassDB::get_parent_class(p_type);
+ TreeItem *parent = p_root;
if (inherits.length()) {
if (!p_types.has(inherits)) {
- add_type(inherits,p_types,p_root,to_select);
+ add_type(inherits, p_types, p_root, to_select);
}
- if (p_types.has(inherits) )
- parent=p_types[inherits];
+ if (p_types.has(inherits))
+ parent = p_types[inherits];
}
TreeItem *item = search_options->create_item(parent);
- item->set_text(0,p_type);
+ item->set_text(0, p_type);
if (!ClassDB::can_instance(p_type)) {
- item->set_custom_color(0, Color(0.5,0.5,0.5) );
- item->set_selectable(0,false);
+ item->set_custom_color(0, Color(0.5, 0.5, 0.5));
+ item->set_selectable(0, false);
} else {
- if ((!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) || search_box->get_text()==p_type) {
- *to_select=item;
+ if ((!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) || search_box->get_text() == p_type) {
+ *to_select = item;
}
-
}
if (bool(EditorSettings::get_singleton()->get("docks/scene_tree/start_create_dialog_fully_expanded"))) {
@@ -195,23 +186,19 @@ void CreateDialog::add_type(const String& p_type,HashMap<String,TreeItem*>& p_ty
item->set_collapsed(collapse);
}
- const String& description = EditorHelp::get_doc_data()->class_list[p_type].brief_description;
- item->set_tooltip(0,description);
-
+ const String &description = EditorHelp::get_doc_data()->class_list[p_type].brief_description;
+ item->set_tooltip(0, description);
- if (has_icon(p_type,"EditorIcons")) {
+ if (has_icon(p_type, "EditorIcons")) {
- item->set_icon(0, get_icon(p_type,"EditorIcons"));
+ item->set_icon(0, get_icon(p_type, "EditorIcons"));
}
-
-
- p_types[p_type]=item;
+ p_types[p_type] = item;
}
void CreateDialog::_update_search() {
-
search_options->clear();
favorite->set_disabled(true);
@@ -224,58 +211,54 @@ void CreateDialog::_update_search() {
List<StringName> type_list;
ClassDB::get_class_list(&type_list);
- HashMap<String,TreeItem*> types;
+ HashMap<String, TreeItem *> types;
TreeItem *root = search_options->create_item();
- root->set_text(0,base_type);
- if (has_icon(base_type,"EditorIcons")) {
- root->set_icon(0,get_icon(base_type,"EditorIcons"));
+ root->set_text(0, base_type);
+ if (has_icon(base_type, "EditorIcons")) {
+ root->set_icon(0, get_icon(base_type, "EditorIcons"));
}
- List<StringName>::Element *I=type_list.front();
- TreeItem *to_select=NULL;
-
- for(;I;I=I->next()) {
-
+ List<StringName>::Element *I = type_list.front();
+ TreeItem *to_select = NULL;
+ for (; I; I = I->next()) {
- String type=I->get();
+ String type = I->get();
- if (base_type=="Node" && type.begins_with("Editor"))
+ if (base_type == "Node" && type.begins_with("Editor"))
continue; // do not show editor nodes
if (!ClassDB::can_instance(type))
continue; // cant create what can't be instanced
- if (search_box->get_text()=="") {
- add_type(type,types,root,&to_select);
+ if (search_box->get_text() == "") {
+ add_type(type, types, root, &to_select);
} else {
- bool found=false;
- String type=I->get();
- while(type!="" && ClassDB::is_parent_class(type,base_type) && type!=base_type) {
+ bool found = false;
+ String type = I->get();
+ while (type != "" && ClassDB::is_parent_class(type, base_type) && type != base_type) {
if (search_box->get_text().is_subsequence_ofi(type)) {
- found=true;
+ found = true;
break;
}
- type=ClassDB::get_parent_class(type);
+ type = ClassDB::get_parent_class(type);
}
-
if (found)
- add_type(I->get(),types,root,&to_select);
+ add_type(I->get(), types, root, &to_select);
}
if (EditorNode::get_editor_data().get_custom_types().has(type) && ClassDB::is_parent_class(type, base_type)) {
//there are custom types based on this... cool.
//print_line("there are custom types");
-
const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type];
- for(int i=0;i<ct.size();i++) {
+ for (int i = 0; i < ct.size(); i++) {
bool show = search_box->get_text().is_subsequence_ofi(ct[i].name);
@@ -283,40 +266,35 @@ void CreateDialog::_update_search() {
continue;
if (!types.has(type))
- add_type(type,types,root,&to_select);
+ add_type(type, types, root, &to_select);
TreeItem *ti;
- if (types.has(type) )
- ti=types[type];
+ if (types.has(type))
+ ti = types[type];
else
- ti=search_options->get_root();
-
+ ti = search_options->get_root();
TreeItem *item = search_options->create_item(ti);
- item->set_metadata(0,type);
- item->set_text(0,ct[i].name);
+ item->set_metadata(0, type);
+ item->set_text(0, ct[i].name);
if (ct[i].icon.is_valid()) {
- item->set_icon(0,ct[i].icon);
-
+ item->set_icon(0, ct[i].icon);
}
- if (!to_select || ct[i].name==search_box->get_text()) {
- to_select=item;
+ if (!to_select || ct[i].name == search_box->get_text()) {
+ to_select = item;
}
-
}
-
}
}
if (to_select) {
to_select->select(0);
favorite->set_disabled(false);
- favorite->set_pressed(favorite_list.find(to_select->get_text(0))!=-1);
+ favorite->set_pressed(favorite_list.find(to_select->get_text(0)) != -1);
}
- get_ok()->set_disabled(root->get_children()==NULL);
-
+ get_ok()->set_disabled(root->get_children() == NULL);
}
void CreateDialog::_confirmed() {
@@ -325,25 +303,25 @@ void CreateDialog::_confirmed() {
if (!ti)
return;
- FileAccess *f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("create_recent."+base_type), FileAccess::WRITE );
+ FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_path().plus_file("create_recent." + base_type), FileAccess::WRITE);
if (f) {
f->store_line(get_selected_type());
TreeItem *t = recent->get_root();
if (t)
- t=t->get_children();
- int count=0;
- while(t) {
- if (t->get_text(0)!=get_selected_type()) {
+ t = t->get_children();
+ int count = 0;
+ while (t) {
+ if (t->get_text(0) != get_selected_type()) {
f->store_line(t->get_text(0));
}
- if (count>32) {
+ if (count > 32) {
//limit it to 32 entries..
break;
}
- t=t->get_next();
+ t = t->get_next();
count++;
}
@@ -356,18 +334,17 @@ void CreateDialog::_confirmed() {
void CreateDialog::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- connect("confirmed",this,"_confirmed");
- favorite->set_icon(get_icon("Favorites","EditorIcons"));
+ connect("confirmed", this, "_confirmed");
+ favorite->set_icon(get_icon("Favorites", "EditorIcons"));
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
-
- disconnect("confirmed",this,"_confirmed");
+ if (p_what == NOTIFICATION_EXIT_TREE) {
+ disconnect("confirmed", this, "_confirmed");
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (is_visible_in_tree()) {
@@ -375,13 +352,12 @@ void CreateDialog::_notification(int p_what) {
search_box->select_all();
}
}
-
}
-void CreateDialog::set_base_type(const String& p_base) {
+void CreateDialog::set_base_type(const String &p_base) {
- base_type=p_base;
- set_title(TTR("Create New")+" "+p_base);
+ base_type = p_base;
+ set_title(TTR("Create New") + " " + p_base);
_update_search();
}
@@ -403,42 +379,38 @@ Object *CreateDialog::instance_selected() {
Variant md = selected->get_metadata(0);
String custom;
- if (md.get_type()!=Variant::NIL)
- custom=md;
+ if (md.get_type() != Variant::NIL)
+ custom = md;
- if (custom!=String()) {
+ if (custom != String()) {
if (EditorNode::get_editor_data().get_custom_types().has(custom)) {
- for(int i=0;i<EditorNode::get_editor_data().get_custom_types()[custom].size();i++) {
- if (EditorNode::get_editor_data().get_custom_types()[custom][i].name==selected->get_text(0)) {
+ for (int i = 0; i < EditorNode::get_editor_data().get_custom_types()[custom].size(); i++) {
+ if (EditorNode::get_editor_data().get_custom_types()[custom][i].name == selected->get_text(0)) {
Ref<Texture> icon = EditorNode::get_editor_data().get_custom_types()[custom][i].icon;
Ref<Script> script = EditorNode::get_editor_data().get_custom_types()[custom][i].script;
String name = selected->get_text(0);
Object *ob = ClassDB::instance(custom);
- ERR_FAIL_COND_V(!ob,NULL);
+ ERR_FAIL_COND_V(!ob, NULL);
if (ob->is_class("Node")) {
- ob->call("set_name",name);
+ ob->call("set_name", name);
}
ob->set_script(script.get_ref_ptr());
if (icon.is_valid())
- ob->set_meta("_editor_icon",icon);
+ ob->set_meta("_editor_icon", icon);
return ob;
-
}
}
-
}
} else {
return ClassDB::instance(selected->get_text(0));
}
}
-
return NULL;
}
-
String CreateDialog::get_base_type() const {
return base_type;
@@ -453,16 +425,14 @@ void CreateDialog::_item_selected() {
String name = item->get_text(0);
favorite->set_disabled(false);
- favorite->set_pressed(favorite_list.find(name)!=-1);
+ favorite->set_pressed(favorite_list.find(name) != -1);
if (!EditorHelp::get_doc_data()->class_list.has(name))
return;
help_bit->set_text(EditorHelp::get_doc_data()->class_list[name].brief_description);
-
}
-
void CreateDialog::_favorite_toggled() {
TreeItem *item = search_options->get_selected();
@@ -471,7 +441,7 @@ void CreateDialog::_favorite_toggled() {
String name = item->get_text(0);
- if (favorite_list.find(name)==-1) {
+ if (favorite_list.find(name) == -1) {
favorite_list.push_back(name);
favorite->set_pressed(true);
} else {
@@ -485,11 +455,11 @@ void CreateDialog::_favorite_toggled() {
void CreateDialog::_save_favorite_list() {
- FileAccess *f = FileAccess::open( EditorSettings::get_singleton()->get_project_settings_path().plus_file("favorites."+base_type), FileAccess::WRITE );
+ FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_path().plus_file("favorites." + base_type), FileAccess::WRITE);
if (f) {
- for(int i=0;i<favorite_list.size();i++) {
+ for (int i = 0; i < favorite_list.size(); i++) {
f->store_line(favorite_list[i]);
}
@@ -501,21 +471,20 @@ void CreateDialog::_update_favorite_list() {
favorites->clear();
TreeItem *root = favorites->create_item();
- for(int i=0;i<favorite_list.size();i++) {
+ for (int i = 0; i < favorite_list.size(); i++) {
TreeItem *ti = favorites->create_item(root);
String l = favorite_list[i];
- ti->set_text(0,l);
+ ti->set_text(0, l);
- if (has_icon(l,"EditorIcons")) {
+ if (has_icon(l, "EditorIcons")) {
- ti->set_icon(0,get_icon(l,"EditorIcons"));
+ ti->set_icon(0, get_icon(l, "EditorIcons"));
} else {
- ti->set_icon(0,get_icon("Object","EditorIcons"));
+ ti->set_icon(0, get_icon("Object", "EditorIcons"));
}
}
}
-
void CreateDialog::_history_selected() {
TreeItem *item = recent->get_selected();
@@ -524,10 +493,9 @@ void CreateDialog::_history_selected() {
search_box->set_text(item->get_text(0));
_update_search();
-
}
-void CreateDialog::_favorite_selected(){
+void CreateDialog::_favorite_selected() {
TreeItem *item = favorites->get_selected();
if (!item)
@@ -535,7 +503,6 @@ void CreateDialog::_favorite_selected(){
search_box->set_text(item->get_text(0));
_update_search();
-
}
void CreateDialog::_history_activated() {
@@ -543,20 +510,20 @@ void CreateDialog::_history_activated() {
_confirmed();
}
-void CreateDialog::_favorite_activated(){
+void CreateDialog::_favorite_activated() {
_confirmed();
}
-Variant CreateDialog::get_drag_data_fw(const Point2& p_point,Control* p_from) {
+Variant CreateDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
TreeItem *ti = favorites->get_item_at_pos(p_point);
if (ti) {
Dictionary d;
- d["type"]="create_favorite_drag";
- d["class"]=ti->get_text(0);
+ d["type"] = "create_favorite_drag";
+ d["class"] = ti->get_text(0);
- ToolButton *tb = memnew( ToolButton );
+ ToolButton *tb = memnew(ToolButton);
tb->set_icon(ti->get_icon(0));
tb->set_text(ti->get_text(0));
set_drag_preview(tb);
@@ -567,17 +534,17 @@ Variant CreateDialog::get_drag_data_fw(const Point2& p_point,Control* p_from) {
return Variant();
}
-bool CreateDialog::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{
+bool CreateDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
Dictionary d = p_data;
- if (d.has("type") && String(d["type"])=="create_favorite_drag") {
+ if (d.has("type") && String(d["type"]) == "create_favorite_drag") {
favorites->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
return true;
}
return false;
}
-void CreateDialog::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){
+void CreateDialog::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
Dictionary d = p_data;
@@ -589,139 +556,128 @@ void CreateDialog::drop_data_fw(const Point2& p_point,const Variant& p_data,Cont
int ds = favorites->get_drop_section_at_pos(p_point);
int drop_idx = favorite_list.find(drop_at);
- if (drop_idx<0)
+ if (drop_idx < 0)
return;
String type = d["class"];
int from_idx = favorite_list.find(type);
- if (from_idx<0)
+ if (from_idx < 0)
return;
- if (drop_idx==from_idx) {
- ds=-1; //cause it will be gone
- } else if (drop_idx>from_idx) {
+ if (drop_idx == from_idx) {
+ ds = -1; //cause it will be gone
+ } else if (drop_idx > from_idx) {
drop_idx--;
}
favorite_list.remove(from_idx);
- if (ds<0) {
- favorite_list.insert(drop_idx,type);
+ if (ds < 0) {
+ favorite_list.insert(drop_idx, type);
} else {
- if (drop_idx>=favorite_list.size()-1) {
+ if (drop_idx >= favorite_list.size() - 1) {
favorite_list.push_back(type);
} else {
- favorite_list.insert(drop_idx+1,type);
+ favorite_list.insert(drop_idx + 1, type);
}
}
_save_favorite_list();
_update_favorite_list();
-
-
}
void CreateDialog::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_text_changed"),&CreateDialog::_text_changed);
- ClassDB::bind_method(D_METHOD("_confirmed"),&CreateDialog::_confirmed);
- ClassDB::bind_method(D_METHOD("_sbox_input"),&CreateDialog::_sbox_input);
- ClassDB::bind_method(D_METHOD("_item_selected"),&CreateDialog::_item_selected);
- ClassDB::bind_method(D_METHOD("_favorite_toggled"),&CreateDialog::_favorite_toggled);
- ClassDB::bind_method(D_METHOD("_history_selected"),&CreateDialog::_history_selected);
- ClassDB::bind_method(D_METHOD("_favorite_selected"),&CreateDialog::_favorite_selected);
- ClassDB::bind_method(D_METHOD("_history_activated"),&CreateDialog::_history_activated);
- ClassDB::bind_method(D_METHOD("_favorite_activated"),&CreateDialog::_favorite_activated);
+ ClassDB::bind_method(D_METHOD("_text_changed"), &CreateDialog::_text_changed);
+ ClassDB::bind_method(D_METHOD("_confirmed"), &CreateDialog::_confirmed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"), &CreateDialog::_sbox_input);
+ ClassDB::bind_method(D_METHOD("_item_selected"), &CreateDialog::_item_selected);
+ ClassDB::bind_method(D_METHOD("_favorite_toggled"), &CreateDialog::_favorite_toggled);
+ ClassDB::bind_method(D_METHOD("_history_selected"), &CreateDialog::_history_selected);
+ ClassDB::bind_method(D_METHOD("_favorite_selected"), &CreateDialog::_favorite_selected);
+ ClassDB::bind_method(D_METHOD("_history_activated"), &CreateDialog::_history_activated);
+ ClassDB::bind_method(D_METHOD("_favorite_activated"), &CreateDialog::_favorite_activated);
-
- ClassDB::bind_method("get_drag_data_fw",&CreateDialog::get_drag_data_fw);
- ClassDB::bind_method("can_drop_data_fw",&CreateDialog::can_drop_data_fw);
- ClassDB::bind_method("drop_data_fw",&CreateDialog::drop_data_fw);
+ ClassDB::bind_method("get_drag_data_fw", &CreateDialog::get_drag_data_fw);
+ ClassDB::bind_method("can_drop_data_fw", &CreateDialog::can_drop_data_fw);
+ ClassDB::bind_method("drop_data_fw", &CreateDialog::drop_data_fw);
ADD_SIGNAL(MethodInfo("create"));
-
}
-
CreateDialog::CreateDialog() {
- HSplitContainer *hbc = memnew( HSplitContainer );
+ HSplitContainer *hbc = memnew(HSplitContainer);
add_child(hbc);
-
- VBoxContainer *lvbc = memnew( VBoxContainer);
+ VBoxContainer *lvbc = memnew(VBoxContainer);
hbc->add_child(lvbc);
- lvbc->set_custom_minimum_size(Size2(150,0)*EDSCALE);
+ lvbc->set_custom_minimum_size(Size2(150, 0) * EDSCALE);
- favorites = memnew (Tree );
- lvbc->add_margin_child(TTR("Favorites:"),favorites,true);
+ favorites = memnew(Tree);
+ lvbc->add_margin_child(TTR("Favorites:"), favorites, true);
favorites->set_hide_root(true);
favorites->set_hide_folding(true);
- favorites->connect("cell_selected",this,"_favorite_selected");
- favorites->connect("item_activated",this,"_favorite_activated");
+ favorites->connect("cell_selected", this, "_favorite_selected");
+ favorites->connect("item_activated", this, "_favorite_activated");
favorites->set_drag_forwarding(this);
-
- recent = memnew (Tree );
- lvbc->add_margin_child(TTR("Recent:"),recent,true);
+ recent = memnew(Tree);
+ lvbc->add_margin_child(TTR("Recent:"), recent, true);
recent->set_hide_root(true);
recent->set_hide_folding(true);
- recent->connect("cell_selected",this,"_history_selected");
- recent->connect("item_activated",this,"_history_activated");
+ recent->connect("cell_selected", this, "_history_selected");
+ recent->connect("item_activated", this, "_history_activated");
-
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
hbc->add_child(vbc);
vbc->set_h_size_flags(SIZE_EXPAND_FILL);
- HBoxContainer *search_hb = memnew( HBoxContainer );
- search_box = memnew( LineEdit );
+ HBoxContainer *search_hb = memnew(HBoxContainer);
+ search_box = memnew(LineEdit);
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
search_hb->add_child(search_box);
- favorite = memnew( Button );
+ favorite = memnew(Button);
favorite->set_toggle_mode(true);
search_hb->add_child(favorite);
- favorite->connect("pressed",this,"_favorite_toggled");
- vbc->add_margin_child(TTR("Search:"),search_hb);
- search_box->connect("text_changed",this,"_text_changed");
- search_box->connect("gui_input",this,"_sbox_input");
- search_options = memnew( Tree );
- vbc->add_margin_child(TTR("Matches:"),search_options,true);
+ favorite->connect("pressed", this, "_favorite_toggled");
+ vbc->add_margin_child(TTR("Search:"), search_hb);
+ search_box->connect("text_changed", this, "_text_changed");
+ search_box->connect("gui_input", this, "_sbox_input");
+ search_options = memnew(Tree);
+ vbc->add_margin_child(TTR("Matches:"), search_options, true);
get_ok()->set_text(TTR("Create"));
get_ok()->set_disabled(true);
register_text_enter(search_box);
set_hide_on_ok(false);
- search_options->connect("item_activated",this,"_confirmed");
- search_options->connect("cell_selected",this,"_item_selected");
+ search_options->connect("item_activated", this, "_confirmed");
+ search_options->connect("cell_selected", this, "_item_selected");
//search_options->set_hide_root(true);
- base_type="Object";
-
- help_bit = memnew( EditorHelpBit );
- vbc->add_margin_child(TTR("Description:"),help_bit);
- help_bit->connect("request_hide",this,"_closed");
+ base_type = "Object";
+ help_bit = memnew(EditorHelpBit);
+ vbc->add_margin_child(TTR("Description:"), help_bit);
+ help_bit->connect("request_hide", this, "_closed");
}
-
#else
//old create dialog, disabled
void CreateDialog::_notification(int p_what) {
- if (p_what==NOTIFICATION_READY) {
- connect("confirmed",this,"_create");
+ if (p_what == NOTIFICATION_READY) {
+ connect("confirmed", this, "_create");
update_tree();
}
- 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()));
}
}
-
void CreateDialog::_create() {
if (tree->get_selected())
@@ -739,45 +695,41 @@ void CreateDialog::_text_changed(String p_text) {
update_tree();
}
-void CreateDialog::add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root) {
+void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root) {
if (p_types.has(p_type))
return;
- if (!ClassDB::is_type(p_type,base) || p_type==base)
+ if (!ClassDB::is_type(p_type, base) || p_type == base)
return;
- String inherits=ClassDB::type_inherits_from(p_type);
-
- TreeItem *parent=p_root;
+ String inherits = ClassDB::type_inherits_from(p_type);
+ TreeItem *parent = p_root;
if (inherits.length()) {
if (!p_types.has(inherits)) {
- add_type(inherits,p_types,p_root);
+ add_type(inherits, p_types, p_root);
}
- if (p_types.has(inherits) )
- parent=p_types[inherits];
+ if (p_types.has(inherits))
+ parent = p_types[inherits];
}
TreeItem *item = tree->create_item(parent);
- item->set_text(0,p_type);
+ item->set_text(0, p_type);
if (!ClassDB::can_instance(p_type)) {
- item->set_custom_color(0, Color(0.5,0.5,0.5) );
- item->set_selectable(0,false);
+ item->set_custom_color(0, Color(0.5, 0.5, 0.5));
+ item->set_selectable(0, false);
}
+ if (has_icon(p_type, "EditorIcons")) {
- if (has_icon(p_type,"EditorIcons")) {
-
- item->set_icon(0, get_icon(p_type,"EditorIcons"));
+ item->set_icon(0, get_icon(p_type, "EditorIcons"));
}
-
-
- p_types[p_type]=item;
+ p_types[p_type] = item;
}
void CreateDialog::update_tree() {
@@ -787,137 +739,117 @@ void CreateDialog::update_tree() {
List<String> type_list;
ClassDB::get_type_list(&type_list);
- HashMap<String,TreeItem*> types;
+ HashMap<String, TreeItem *> types;
TreeItem *root = tree->create_item();
- root->set_text(0,base);
-
- List<String>::Element *I=type_list.front();
-
- for(;I;I=I->next()) {
+ root->set_text(0, base);
+ List<String>::Element *I = type_list.front();
- String type=I->get();
+ for (; I; I = I->next()) {
+ String type = I->get();
if (!ClassDB::can_instance(type))
continue; // cant create what can't be instanced
- if (filter->get_text()=="")
- add_type(type,types,root);
+ if (filter->get_text() == "")
+ add_type(type, types, root);
else {
- bool found=false;
- String type=I->get();
- while(type!="" && ClassDB::is_type(type,base) && type!=base) {
- if (type.findn(filter->get_text())!=-1) {
+ bool found = false;
+ String type = I->get();
+ while (type != "" && ClassDB::is_type(type, base) && type != base) {
+ if (type.findn(filter->get_text()) != -1) {
- found=true;
+ found = true;
break;
}
- type=ClassDB::type_inherits_from(type);
+ type = ClassDB::type_inherits_from(type);
}
-
if (found)
- add_type(I->get(),types,root);
+ add_type(I->get(), types, root);
}
if (EditorNode::get_editor_data().get_custom_types().has(type)) {
//there are custom types based on this... cool.
-
const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type];
- for(int i=0;i<ct.size();i++) {
+ for (int i = 0; i < ct.size(); i++) {
- bool show = filter->get_text()=="" || ct[i].name.findn(filter->get_text())!=-1;
+ bool show = filter->get_text() == "" || ct[i].name.findn(filter->get_text()) != -1;
if (!show)
continue;
if (!types.has(type))
- add_type(type,types,root);
+ add_type(type, types, root);
TreeItem *ti;
- if (types.has(type) )
- ti=types[type];
+ if (types.has(type))
+ ti = types[type];
else
- ti=tree->get_root();
-
+ ti = tree->get_root();
TreeItem *item = tree->create_item(ti);
- item->set_metadata(0,type);
- item->set_text(0,ct[i].name);
+ item->set_metadata(0, type);
+ item->set_text(0, ct[i].name);
if (ct[i].icon.is_valid()) {
- item->set_icon(0,ct[i].icon);
-
+ item->set_icon(0, ct[i].icon);
}
}
-
}
}
-
-
}
-
Object *CreateDialog::instance_selected() {
if (!tree->get_selected())
return NULL;
String base = String(tree->get_selected()->get_metadata(0));
- if (base!="") {
-
+ if (base != "") {
String name = tree->get_selected()->get_text(0);
if (EditorNode::get_editor_data().get_custom_types().has(base)) {
const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[base];
- for(int i=0;i<ct.size();i++) {
+ for (int i = 0; i < ct.size(); i++) {
- if (ct[i].name==name) {
+ if (ct[i].name == name) {
- Object* obj = ClassDB::instance(base);
- ERR_FAIL_COND_V(!obj,NULL);
+ Object *obj = ClassDB::instance(base);
+ ERR_FAIL_COND_V(!obj, NULL);
obj->set_script(ct[i].script.get_ref_ptr());
if (ct[i].icon.is_valid())
- obj->set_meta("_editor_icon",ct[i].icon);
+ obj->set_meta("_editor_icon", ct[i].icon);
return obj;
-
-
}
}
}
ERR_FAIL_V(NULL);
-
}
return ClassDB::instance(tree->get_selected()->get_text(0));
-
}
-
void CreateDialog::_bind_methods() {
- ClassDB::bind_method("_create",&CreateDialog::_create);
- ClassDB::bind_method("_cancel",&CreateDialog::_cancel);
+ ClassDB::bind_method("_create", &CreateDialog::_create);
+ ClassDB::bind_method("_cancel", &CreateDialog::_cancel);
ClassDB::bind_method("_text_changed", &CreateDialog::_text_changed);
- ADD_SIGNAL( MethodInfo("create"));
-
+ ADD_SIGNAL(MethodInfo("create"));
}
+void CreateDialog::set_base_type(const String &p_base) {
+ set_title(vformat("Create %s Type", p_base));
-
-void CreateDialog::set_base_type(const String& p_base) {
-
- set_title(vformat("Create %s Type",p_base));
-
- if (base==p_base)
+ if (base == p_base)
return;
- base=p_base;
+ base = p_base;
if (is_inside_scene())
update_tree();
}
@@ -929,33 +861,26 @@ String CreateDialog::get_base_type() const {
CreateDialog::CreateDialog() {
-
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
-
get_ok()->set_text("Create");
- tree = memnew( Tree );
- vbc->add_margin_child("Type:",tree,true);
+ tree = memnew(Tree);
+ vbc->add_margin_child("Type:", tree, true);
//tree->set_hide_root(true);
- filter = memnew( LineEdit );
- vbc->add_margin_child("Filter:",filter);
+ filter = memnew(LineEdit);
+ vbc->add_margin_child("Filter:", filter);
- base="Node";
+ base = "Node";
set_as_toplevel(true);
-
tree->connect("item_activated", this, "_create");
- filter->connect("text_changed", this,"_text_changed");
-
+ filter->connect("text_changed", this, "_text_changed");
}
-
-CreateDialog::~CreateDialog()
-{
+CreateDialog::~CreateDialog() {
}
-
#endif
diff --git a/editor/create_dialog.h b/editor/create_dialog.h
index 5ecb4db2c3..aff6b9c62b 100644
--- a/editor/create_dialog.h
+++ b/editor/create_dialog.h
@@ -29,24 +29,22 @@
#ifndef CREATE_DIALOG_H
#define CREATE_DIALOG_H
-#include "scene/gui/dialogs.h"
+#include "editor_help.h"
#include "scene/gui/button.h"
-#include "scene/gui/tree.h"
+#include "scene/gui/dialogs.h"
#include "scene/gui/item_list.h"
-#include "scene/gui/line_edit.h"
#include "scene/gui/label.h"
-#include "editor_help.h"
+#include "scene/gui/line_edit.h"
+#include "scene/gui/tree.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
#if 1
-
class CreateDialog : public ConfirmationDialog {
- GDCLASS(CreateDialog,ConfirmationDialog )
-
+ GDCLASS(CreateDialog, ConfirmationDialog)
Vector<String> favorite_list;
Tree *favorites;
@@ -72,74 +70,67 @@ class CreateDialog : public ConfirmationDialog {
void _history_activated();
void _favorite_activated();
- void _sbox_input(const InputEvent& p_ie);
+ void _sbox_input(const InputEvent &p_ie);
void _confirmed();
- void _text_changed(const String& p_newtext);
+ void _text_changed(const String &p_newtext);
- void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root,TreeItem **to_select);
+ void add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select);
- Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
- bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
- void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
Object *instance_selected();
String get_selected_type();
- void set_base_type(const String& p_base);
+ void set_base_type(const String &p_base);
String get_base_type() const;
void popup(bool p_dontclear);
-
CreateDialog();
};
-
#else
//old create dialog, disabled
class CreateDialog : public ConfirmationDialog {
- GDCLASS( CreateDialog, ConfirmationDialog );
+ GDCLASS(CreateDialog, ConfirmationDialog);
Tree *tree;
Button *create;
Button *cancel;
LineEdit *filter;
-
void update_tree();
void _create();
void _cancel();
- void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem
- *p_root);
+ void add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem
+ *p_root);
String base;
void _text_changed(String p_text);
- virtual void _post_popup() { tree->grab_focus();}
+ virtual void _post_popup() { tree->grab_focus(); }
protected:
static void _bind_methods();
void _notification(int p_what);
-public:
-
-
+public:
Object *instance_selected();
- void set_base_type(const String& p_base);
+ void set_base_type(const String &p_base);
String get_base_type() const;
CreateDialog();
~CreateDialog();
-
};
#endif
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index d7e04db86e..64c3cc1c00 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -28,53 +28,49 @@
/*************************************************************************/
#include "dependency_editor.h"
+#include "editor_node.h"
+#include "io/resource_loader.h"
#include "os/file_access.h"
#include "scene/gui/margin_container.h"
-#include "io/resource_loader.h"
-#include "editor_node.h"
-
-void DependencyEditor::_notification(int p_what){
-
+void DependencyEditor::_notification(int p_what) {
}
-void DependencyEditor::_searched(const String& p_path) {
+void DependencyEditor::_searched(const String &p_path) {
- Map<String,String> dep_rename;
- dep_rename[replacing]=p_path;
+ Map<String, String> dep_rename;
+ dep_rename[replacing] = p_path;
-
- ResourceLoader::rename_dependencies(editing,dep_rename);
+ ResourceLoader::rename_dependencies(editing, dep_rename);
_update_list();
_update_file();
}
-void DependencyEditor::_load_pressed(Object* p_item,int p_cell,int p_button){
+void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) {
- TreeItem *ti=p_item->cast_to<TreeItem>();
+ TreeItem *ti = p_item->cast_to<TreeItem>();
String fname = ti->get_text(0);
replacing = ti->get_text(1);
- search->set_title(TTR("Search Replacement For:")+" "+replacing.get_file());
+ search->set_title(TTR("Search Replacement For:") + " " + replacing.get_file());
search->clear_filters();
List<String> ext;
- ResourceLoader::get_recognized_extensions_for_type(ti->get_metadata(0),&ext);
- for (List<String>::Element *E=ext.front();E;E=E->next()) {
- search->add_filter("*"+E->get());
+ ResourceLoader::get_recognized_extensions_for_type(ti->get_metadata(0), &ext);
+ for (List<String>::Element *E = ext.front(); E; E = E->next()) {
+ search->add_filter("*" + E->get());
}
search->popup_centered_ratio();
-
}
-void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String,Map<String,String> >& candidates){
+void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String> > &candidates) {
- for(int i=0;i<efsd->get_subdir_count();i++) {
- _fix_and_find(efsd->get_subdir(i),candidates);
+ for (int i = 0; i < efsd->get_subdir_count(); i++) {
+ _fix_and_find(efsd->get_subdir(i), candidates);
}
- for(int i=0;i<efsd->get_file_count();i++) {
+ for (int i = 0; i < efsd->get_file_count(); i++) {
String file = efsd->get_file(i);
if (!candidates.has(file))
@@ -82,34 +78,34 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String
String path = efsd->get_file_path(i);
- for(Map<String,String>::Element *E=candidates[file].front();E;E=E->next()) {
+ for (Map<String, String>::Element *E = candidates[file].front(); E; E = E->next()) {
- if (E->get()==String()) {
- E->get()=path;
+ if (E->get() == String()) {
+ E->get() = path;
continue;
}
//must match the best, using subdirs
- String existing=E->get().replace_first("res://","");
- String current=path.replace_first("res://","");
- String lost=E->key().replace_first("res://","");
+ String existing = E->get().replace_first("res://", "");
+ String current = path.replace_first("res://", "");
+ String lost = E->key().replace_first("res://", "");
- Vector<String> existingv=existing.split("/");
+ Vector<String> existingv = existing.split("/");
existingv.invert();
- Vector<String> currentv=current.split("/");
+ Vector<String> currentv = current.split("/");
currentv.invert();
- Vector<String> lostv=lost.split("/");
+ Vector<String> lostv = lost.split("/");
lostv.invert();
- int existing_score=0;
- int current_score=0;
+ int existing_score = 0;
+ int current_score = 0;
- for(int j=0;j<lostv.size();j++) {
+ for (int j = 0; j < lostv.size(); j++) {
- if (j<existingv.size() && lostv[j]==existingv[j]) {
+ if (j < existingv.size() && lostv[j] == existingv[j]) {
existing_score++;
}
- if (j<currentv.size() && lostv[j]==currentv[j]) {
+ if (j < currentv.size() && lostv[j] == currentv[j]) {
current_score++;
}
}
@@ -118,51 +114,46 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String
//if it was the same, could track distance to new path but..
- E->get()=path; //replace by more accurate
+ E->get() = path; //replace by more accurate
}
-
}
-
}
-
}
-
-void DependencyEditor::_fix_all(){
+void DependencyEditor::_fix_all() {
if (!EditorFileSystem::get_singleton()->get_filesystem())
return;
- Map<String,Map<String,String> > candidates;
+ Map<String, Map<String, String> > candidates;
- for (List<String>::Element *E=missing.front();E;E=E->next()) {
+ for (List<String>::Element *E = missing.front(); E; E = E->next()) {
String base = E->get().get_file();
if (!candidates.has(base)) {
- candidates[base]=Map<String,String>();
+ candidates[base] = Map<String, String>();
}
- candidates[base][E->get()]="";
+ candidates[base][E->get()] = "";
}
- _fix_and_find(EditorFileSystem::get_singleton()->get_filesystem(),candidates);
+ _fix_and_find(EditorFileSystem::get_singleton()->get_filesystem(), candidates);
- Map<String,String> remaps;
+ Map<String, String> remaps;
- for (Map<String,Map<String,String> >::Element *E=candidates.front();E;E=E->next()) {
+ for (Map<String, Map<String, String> >::Element *E = candidates.front(); E; E = E->next()) {
- for (Map<String,String>::Element *F=E->get().front();F;F=F->next()) {
+ for (Map<String, String>::Element *F = E->get().front(); F; F = F->next()) {
- if (F->get()!=String()) {
- remaps[F->key()]=F->get();
+ if (F->get() != String()) {
+ remaps[F->key()] = F->get();
}
}
-
}
if (remaps.size()) {
- ResourceLoader::rename_dependencies(editing,remaps);
+ ResourceLoader::rename_dependencies(editing, remaps);
_update_list();
_update_file();
@@ -172,24 +163,23 @@ void DependencyEditor::_fix_all(){
void DependencyEditor::_update_file() {
EditorFileSystem::get_singleton()->update_file(editing);
-
}
void DependencyEditor::_update_list() {
List<String> deps;
- ResourceLoader::get_dependencies(editing,&deps,true);
+ ResourceLoader::get_dependencies(editing, &deps, true);
tree->clear();
missing.clear();
TreeItem *root = tree->create_item();
- Ref<Texture> folder = get_icon("folder","FileDialog");
+ Ref<Texture> folder = get_icon("folder", "FileDialog");
- bool broken=false;
+ bool broken = false;
- for(List<String>::Element *E=deps.front();E;E=E->next()) {
+ for (List<String>::Element *E = deps.front(); E; E = E->next()) {
TreeItem *item = tree->create_item(root);
@@ -197,129 +187,119 @@ void DependencyEditor::_update_list() {
String path;
String type;
- if (n.find("::")!=-1) {
- path = n.get_slice("::",0);
- type = n.get_slice("::",1);
+ if (n.find("::") != -1) {
+ path = n.get_slice("::", 0);
+ type = n.get_slice("::", 1);
} else {
- path=n;
- type="Resource";
+ path = n;
+ type = "Resource";
}
String name = path.get_file();
Ref<Texture> icon;
- if (has_icon(type,"EditorIcons")) {
- icon=get_icon(type,"EditorIcons");
+ if (has_icon(type, "EditorIcons")) {
+ icon = get_icon(type, "EditorIcons");
} else {
- icon=get_icon("Object","EditorIcons");
+ icon = get_icon("Object", "EditorIcons");
}
- item->set_text(0,name);
- item->set_icon(0,icon);
- item->set_metadata(0,type);
- item->set_text(1,path);
+ item->set_text(0, name);
+ item->set_icon(0, icon);
+ item->set_metadata(0, type);
+ item->set_text(1, path);
if (!FileAccess::exists(path)) {
- item->set_custom_color(1,Color(1,0.4,0.3));
+ item->set_custom_color(1, Color(1, 0.4, 0.3));
missing.push_back(path);
- broken=true;
+ broken = true;
}
- item->add_button(1,folder,0);
+ item->add_button(1, folder, 0);
}
fixdeps->set_disabled(!broken);
-
}
+void DependencyEditor::edit(const String &p_path) {
-
-void DependencyEditor::edit(const String& p_path) {
-
-
- editing=p_path;
- set_title(TTR("Dependencies For:")+" "+p_path.get_file());
+ editing = p_path;
+ set_title(TTR("Dependencies For:") + " " + p_path.get_file());
_update_list();
popup_centered_ratio();
if (EditorNode::get_singleton()->is_scene_open(p_path)) {
- EditorNode::get_singleton()->show_warning(vformat(TTR("Scene '%s' is currently being edited.\nChanges will not take effect unless reloaded."),p_path.get_file()));
+ EditorNode::get_singleton()->show_warning(vformat(TTR("Scene '%s' is currently being edited.\nChanges will not take effect unless reloaded."), p_path.get_file()));
} else if (ResourceCache::has(p_path)) {
- EditorNode::get_singleton()->show_warning(vformat(TTR("Resource '%s' is in use.\nChanges will take effect when reloaded."),p_path.get_file()));
+ EditorNode::get_singleton()->show_warning(vformat(TTR("Resource '%s' is in use.\nChanges will take effect when reloaded."), p_path.get_file()));
}
}
-
void DependencyEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_searched"),&DependencyEditor::_searched);
- ClassDB::bind_method(D_METHOD("_load_pressed"),&DependencyEditor::_load_pressed);
- ClassDB::bind_method(D_METHOD("_fix_all"),&DependencyEditor::_fix_all);
-
+ ClassDB::bind_method(D_METHOD("_searched"), &DependencyEditor::_searched);
+ ClassDB::bind_method(D_METHOD("_load_pressed"), &DependencyEditor::_load_pressed);
+ ClassDB::bind_method(D_METHOD("_fix_all"), &DependencyEditor::_fix_all);
}
DependencyEditor::DependencyEditor() {
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
vb->set_name(TTR("Dependencies"));
add_child(vb);
-
- tree = memnew( Tree );
+ tree = memnew(Tree);
tree->set_columns(2);
tree->set_column_titles_visible(true);
- tree->set_column_title(0,TTR("Resource"));
- tree->set_column_title(1,TTR("Path"));
+ tree->set_column_title(0, TTR("Resource"));
+ tree->set_column_title(1, TTR("Path"));
tree->set_hide_root(true);
- tree->connect("button_pressed",this,"_load_pressed");
+ tree->connect("button_pressed", this, "_load_pressed");
- HBoxContainer *hbc = memnew( HBoxContainer );
- Label *label = memnew( Label(TTR("Dependencies:")));
+ HBoxContainer *hbc = memnew(HBoxContainer);
+ Label *label = memnew(Label(TTR("Dependencies:")));
hbc->add_child(label);
hbc->add_spacer();
- fixdeps = memnew( Button(TTR("Fix Broken")));
+ fixdeps = memnew(Button(TTR("Fix Broken")));
hbc->add_child(fixdeps);
- fixdeps->connect("pressed",this,"_fix_all");
+ fixdeps->connect("pressed", this, "_fix_all");
vb->add_child(hbc);
- MarginContainer *mc = memnew( MarginContainer );
+ MarginContainer *mc = memnew(MarginContainer);
mc->set_v_size_flags(SIZE_EXPAND_FILL);
mc->add_child(tree);
vb->add_child(mc);
set_title(TTR("Dependency Editor"));
- search = memnew( EditorFileDialog );
- search->connect("file_selected",this,"_searched");
+ search = memnew(EditorFileDialog);
+ search->connect("file_selected", this, "_searched");
search->set_mode(EditorFileDialog::MODE_OPEN_FILE);
search->set_title(TTR("Search Replacement Resource:"));
add_child(search);
-
}
/////////////////////////////////////
-
-
void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {
if (!efsd)
return;
- for(int i=0;i<efsd->get_subdir_count();i++) {
+ for (int i = 0; i < efsd->get_subdir_count(); i++) {
_fill_owners(efsd->get_subdir(i));
}
- for(int i=0;i<efsd->get_file_count();i++) {
+ for (int i = 0; i < efsd->get_file_count(); i++) {
Vector<String> deps = efsd->get_file_deps(i);
//print_line(":::"+efsd->get_file_path(i));
- bool found=false;
- for(int j=0;j<deps.size();j++) {
+ bool found = false;
+ for (int j = 0; j < deps.size(); j++) {
//print_line("\t"+deps[j]+" vs "+editing);
- if (deps[j]==editing) {
+ if (deps[j] == editing) {
//print_line("found");
- found=true;
+ found = true;
break;
}
}
@@ -327,57 +307,50 @@ void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {
continue;
Ref<Texture> icon;
- String type=efsd->get_file_type(i);
- if (!has_icon(type,"EditorIcons")) {
- icon=get_icon("Object","EditorIcons");
+ String type = efsd->get_file_type(i);
+ if (!has_icon(type, "EditorIcons")) {
+ icon = get_icon("Object", "EditorIcons");
} else {
- icon=get_icon(type,"EditorIcons");
+ icon = get_icon(type, "EditorIcons");
}
- owners->add_item(efsd->get_file_path(i),icon);
+ owners->add_item(efsd->get_file_path(i), icon);
}
-
}
-void DependencyEditorOwners::show(const String& p_path) {
+void DependencyEditorOwners::show(const String &p_path) {
- editing=p_path;
+ editing = p_path;
owners->clear();
_fill_owners(EditorFileSystem::get_singleton()->get_filesystem());
popup_centered_ratio();
- set_title(TTR("Owners Of:")+" "+p_path.get_file());
-
+ set_title(TTR("Owners Of:") + " " + p_path.get_file());
}
DependencyEditorOwners::DependencyEditorOwners() {
-
- owners = memnew( ItemList );
+ owners = memnew(ItemList);
add_child(owners);
-
-
-
}
///////////////////////
-
void DependencyRemoveDialog::_fill_owners(EditorFileSystemDirectory *efsd) {
if (!efsd)
return;
- for(int i=0;i<efsd->get_subdir_count();i++) {
+ for (int i = 0; i < efsd->get_subdir_count(); i++) {
_fill_owners(efsd->get_subdir(i));
}
- for(int i=0;i<efsd->get_file_count();i++) {
+ for (int i = 0; i < efsd->get_file_count(); i++) {
Vector<String> deps = efsd->get_file_deps(i);
//print_line(":::"+efsd->get_file_path(i));
Set<String> met;
- for(int j=0;j<deps.size();j++) {
+ for (int j = 0; j < deps.size(); j++) {
if (files.has(deps[j])) {
met.insert(deps[j]);
}
@@ -385,65 +358,58 @@ void DependencyRemoveDialog::_fill_owners(EditorFileSystemDirectory *efsd) {
if (!met.size())
continue;
- exist=true;
+ exist = true;
Ref<Texture> icon;
- String type=efsd->get_file_type(i);
- if (!has_icon(type,"EditorIcons")) {
- icon=get_icon("Object","EditorIcons");
+ String type = efsd->get_file_type(i);
+ if (!has_icon(type, "EditorIcons")) {
+ icon = get_icon("Object", "EditorIcons");
} else {
- icon=get_icon(type,"EditorIcons");
+ icon = get_icon(type, "EditorIcons");
}
-
- for(Set<String>::Element *E=met.front();E;E=E->next()) {
+ for (Set<String>::Element *E = met.front(); E; E = E->next()) {
String which = E->get();
if (!files[which]) {
- TreeItem *ti=owners->create_item(owners->get_root());
- ti->set_text(0,which.get_file());
- files[which]=ti;
-
+ TreeItem *ti = owners->create_item(owners->get_root());
+ ti->set_text(0, which.get_file());
+ files[which] = ti;
}
- TreeItem *ti=owners->create_item(files[which]);
- ti->set_text(0,efsd->get_file_path(i));
- ti->set_icon(0,icon);
+ TreeItem *ti = owners->create_item(files[which]);
+ ti->set_text(0, efsd->get_file_path(i));
+ ti->set_icon(0, icon);
}
-
}
-
}
void DependencyRemoveDialog::show(const Vector<String> &to_erase) {
- exist=false;
+ exist = false;
owners->clear();
files.clear();
owners->create_item(); // root
- for(int i=0;i<to_erase.size();i++) {
- files[to_erase[i]]=NULL;
+ for (int i = 0; i < to_erase.size(); i++) {
+ files[to_erase[i]] = NULL;
}
_fill_owners(EditorFileSystem::get_singleton()->get_filesystem());
-
if (exist) {
owners->show();
text->set_text(TTR("The files being removed are required by other resources in order for them to work.\nRemove them anyway? (no undo)"));
- popup_centered_minsize(Size2(500,220));
+ popup_centered_minsize(Size2(500, 220));
} else {
owners->hide();
text->set_text(TTR("Remove selected files from the project? (no undo)"));
- popup_centered_minsize(Size2(400,100));
+ popup_centered_minsize(Size2(400, 100));
}
-
}
void DependencyRemoveDialog::ok_pressed() {
-
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- for (Map<String,TreeItem*>::Element *E=files.front();E;E=E->next()) {
+ for (Map<String, TreeItem *>::Element *E = files.front(); E; E = E->next()) {
if (ResourceCache::has(E->key())) {
Resource *res = ResourceCache::get(E->key());
@@ -453,225 +419,202 @@ void DependencyRemoveDialog::ok_pressed() {
EditorFileSystem::get_singleton()->update_file(E->key());
}
memdelete(da);
-
}
DependencyRemoveDialog::DependencyRemoveDialog() {
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
-
- text = memnew( Label );
+ text = memnew(Label);
vb->add_child(text);
- owners = memnew( Tree );
+ owners = memnew(Tree);
owners->set_hide_root(true);
vb->add_child(owners);
owners->set_v_size_flags(SIZE_EXPAND_FILL);
get_ok()->set_text(TTR("Remove"));
}
-
//////////////
+void DependencyErrorDialog::show(const String &p_for_file, const Vector<String> &report) {
-void DependencyErrorDialog::show(const String& p_for_file,const Vector<String> &report) {
-
-
- for_file=p_for_file;
- set_title(TTR("Error loading:")+" "+p_for_file.get_file());
+ for_file = p_for_file;
+ set_title(TTR("Error loading:") + " " + p_for_file.get_file());
files->clear();
TreeItem *root = files->create_item(NULL);
- for(int i=0;i<report.size();i++) {
+ for (int i = 0; i < report.size(); i++) {
String dep;
- String type="Object";
- dep=report[i].get_slice("::",0);
- if (report[i].get_slice_count("::")>0)
- type=report[i].get_slice("::",1);
+ String type = "Object";
+ dep = report[i].get_slice("::", 0);
+ if (report[i].get_slice_count("::") > 0)
+ type = report[i].get_slice("::", 1);
Ref<Texture> icon;
- if (!has_icon(type,"EditorIcons")) {
- icon=get_icon("Object","EditorIcons");
+ if (!has_icon(type, "EditorIcons")) {
+ icon = get_icon("Object", "EditorIcons");
} else {
- icon=get_icon(type,"EditorIcons");
+ icon = get_icon(type, "EditorIcons");
}
- TreeItem *ti=files->create_item(root);
- ti->set_text(0,dep);
- ti->set_icon(0,icon);
-
+ TreeItem *ti = files->create_item(root);
+ ti->set_text(0, dep);
+ ti->set_icon(0, icon);
}
- popup_centered_minsize(Size2(500,220));
-
+ popup_centered_minsize(Size2(500, 220));
}
void DependencyErrorDialog::ok_pressed() {
- EditorNode::get_singleton()->load_scene(for_file,true);
+ EditorNode::get_singleton()->load_scene(for_file, true);
}
-void DependencyErrorDialog::custom_action(const String&) {
+void DependencyErrorDialog::custom_action(const String &) {
EditorNode::get_singleton()->fix_dependencies(for_file);
}
DependencyErrorDialog::DependencyErrorDialog() {
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
-
-
- files = memnew( Tree );
+ files = memnew(Tree);
files->set_hide_root(true);
- vb->add_margin_child(TTR("Scene failed to load due to missing dependencies:"),files,true);
+ vb->add_margin_child(TTR("Scene failed to load due to missing dependencies:"), files, true);
files->set_v_size_flags(SIZE_EXPAND_FILL);
get_ok()->set_text(TTR("Open Anyway"));
- text = memnew( Label );
+ text = memnew(Label);
vb->add_child(text);
text->set_text(TTR("Which action should be taken?"));
-
- fdep=add_button(TTR("Fix Dependencies"),true,"fixdeps");
+ fdep = add_button(TTR("Fix Dependencies"), true, "fixdeps");
set_title(TTR("Errors loading!"));
-
}
//////////////////////////////////////////////////////////////////////
-
-
void OrphanResourcesDialog::ok_pressed() {
paths.clear();
- _find_to_delete(files->get_root(),paths);
+ _find_to_delete(files->get_root(), paths);
if (paths.empty())
return;
- delete_confirm->set_text(vformat(TTR("Permanently delete %d item(s)? (No undo!)"),paths.size()));
+ delete_confirm->set_text(vformat(TTR("Permanently delete %d item(s)? (No undo!)"), paths.size()));
delete_confirm->popup_centered_minsize();
}
-bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd,HashMap<String,int>& refs,TreeItem* p_parent){
-
+bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent) {
if (!efsd)
return false;
- bool has_childs=false;
+ bool has_childs = false;
- for(int i=0;i<efsd->get_subdir_count();i++) {
+ for (int i = 0; i < efsd->get_subdir_count(); i++) {
- TreeItem *dir_item=NULL;
+ TreeItem *dir_item = NULL;
if (p_parent) {
dir_item = files->create_item(p_parent);
- dir_item->set_text(0,efsd->get_subdir(i)->get_name());
- dir_item->set_icon(0,get_icon("folder","FileDialog"));
-
+ dir_item->set_text(0, efsd->get_subdir(i)->get_name());
+ dir_item->set_icon(0, get_icon("folder", "FileDialog"));
}
- bool children = _fill_owners(efsd->get_subdir(i),refs,dir_item);
+ bool children = _fill_owners(efsd->get_subdir(i), refs, dir_item);
if (p_parent) {
if (!children) {
memdelete(dir_item);
} else {
- has_childs=true;
+ has_childs = true;
}
}
-
}
-
- for(int i=0;i<efsd->get_file_count();i++) {
+ for (int i = 0; i < efsd->get_file_count(); i++) {
if (!p_parent) {
Vector<String> deps = efsd->get_file_deps(i);
//print_line(":::"+efsd->get_file_path(i));
- for(int j=0;j<deps.size();j++) {
+ for (int j = 0; j < deps.size(); j++) {
if (!refs.has(deps[j])) {
- refs[deps[j]]=1;
+ refs[deps[j]] = 1;
}
}
} else {
String path = efsd->get_file_path(i);
if (!refs.has(path)) {
- TreeItem *ti=files->create_item(p_parent);
- ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- ti->set_text(0,efsd->get_file(i));
- ti->set_editable(0,true);
+ TreeItem *ti = files->create_item(p_parent);
+ ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ ti->set_text(0, efsd->get_file(i));
+ ti->set_editable(0, true);
- String type=efsd->get_file_type(i);
+ String type = efsd->get_file_type(i);
Ref<Texture> icon;
- if (has_icon(type,"EditorIcons")) {
- icon=get_icon(type,"EditorIcons");
+ if (has_icon(type, "EditorIcons")) {
+ icon = get_icon(type, "EditorIcons");
} else {
- icon=get_icon("Object","EditorIcons");
+ icon = get_icon("Object", "EditorIcons");
}
- ti->set_icon(0,icon);
+ ti->set_icon(0, icon);
int ds = efsd->get_file_deps(i).size();
- ti->set_text(1,itos(ds));
+ ti->set_text(1, itos(ds));
if (ds) {
- ti->add_button(1,get_icon("Visible","EditorIcons"));
+ ti->add_button(1, get_icon("Visible", "EditorIcons"));
}
- ti->set_metadata(0,path);
- has_childs=true;
+ ti->set_metadata(0, path);
+ has_childs = true;
}
}
-
}
return has_childs;
}
-
void OrphanResourcesDialog::refresh() {
- HashMap<String,int> refs;
- _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(),refs,NULL);
+ HashMap<String, int> refs;
+ _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(), refs, NULL);
files->clear();
- TreeItem *root=files->create_item();
- _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(),refs,root);
+ TreeItem *root = files->create_item();
+ _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(), refs, root);
}
-
-void OrphanResourcesDialog::show(){
+void OrphanResourcesDialog::show() {
refresh();
popup_centered_ratio();
}
+void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &paths) {
-void OrphanResourcesDialog::_find_to_delete(TreeItem* p_item,List<String>& paths) {
+ while (p_item) {
- while(p_item) {
-
- if (p_item->get_cell_mode(0)==TreeItem::CELL_MODE_CHECK && p_item->is_checked(0)) {
+ if (p_item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK && p_item->is_checked(0)) {
paths.push_back(p_item->get_metadata(0));
}
if (p_item->get_children()) {
- _find_to_delete(p_item->get_children(),paths);
+ _find_to_delete(p_item->get_children(), paths);
}
- p_item=p_item->get_next();
+ p_item = p_item->get_next();
}
-
-
}
void OrphanResourcesDialog::_delete_confirm() {
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- for (List<String>::Element *E=paths.front();E;E=E->next()) {
+ for (List<String>::Element *E = paths.front(); E; E = E->next()) {
da->remove(E->get());
EditorFileSystem::get_singleton()->update_file(E->get());
@@ -680,46 +623,43 @@ void OrphanResourcesDialog::_delete_confirm() {
refresh();
}
-void OrphanResourcesDialog::_button_pressed(Object *p_item,int p_column, int p_id) {
+void OrphanResourcesDialog::_button_pressed(Object *p_item, int p_column, int p_id) {
- TreeItem *ti=p_item->cast_to<TreeItem>();
+ TreeItem *ti = p_item->cast_to<TreeItem>();
String path = ti->get_metadata(0);
dep_edit->edit(path);
-
}
void OrphanResourcesDialog::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_delete_confirm"),&OrphanResourcesDialog::_delete_confirm);
- ClassDB::bind_method(D_METHOD("_button_pressed"),&OrphanResourcesDialog::_button_pressed);
-
+ ClassDB::bind_method(D_METHOD("_delete_confirm"), &OrphanResourcesDialog::_delete_confirm);
+ ClassDB::bind_method(D_METHOD("_button_pressed"), &OrphanResourcesDialog::_button_pressed);
}
-OrphanResourcesDialog::OrphanResourcesDialog(){
+OrphanResourcesDialog::OrphanResourcesDialog() {
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
- files = memnew( Tree );
+ files = memnew(Tree);
files->set_columns(2);
files->set_column_titles_visible(true);
- files->set_column_min_width(1,100);
- files->set_column_expand(0,true);
- files->set_column_expand(1,false);
- files->set_column_title(0,TTR("Resource"));
- files->set_column_title(1,TTR("Owns"));
+ files->set_column_min_width(1, 100);
+ files->set_column_expand(0, true);
+ files->set_column_expand(1, false);
+ files->set_column_title(0, TTR("Resource"));
+ files->set_column_title(1, TTR("Owns"));
files->set_hide_root(true);
- vbc->add_margin_child(TTR("Resources Without Explicit Ownership:"),files,true);
+ vbc->add_margin_child(TTR("Resources Without Explicit Ownership:"), files, true);
set_title(TTR("Orphan Resource Explorer"));
- delete_confirm = memnew( ConfirmationDialog );
+ delete_confirm = memnew(ConfirmationDialog);
delete_confirm->set_text(TTR("Delete selected files?"));
get_ok()->set_text(TTR("Delete"));
add_child(delete_confirm);
- dep_edit = memnew( DependencyEditor );
+ dep_edit = memnew(DependencyEditor);
add_child(dep_edit);
- files->connect("button_pressed",this,"_button_pressed");
- delete_confirm->connect("confirmed",this,"_delete_confirm");
+ files->connect("button_pressed", this, "_button_pressed");
+ delete_confirm->connect("confirmed", this, "_delete_confirm");
set_hide_on_ok(false);
-
}
diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h
index a96ffe5fcf..bd0e1f8b07 100644
--- a/editor/dependency_editor.h
+++ b/editor/dependency_editor.h
@@ -29,16 +29,15 @@
#ifndef DEPENDENCY_EDITOR_H
#define DEPENDENCY_EDITOR_H
+#include "editor_file_dialog.h"
#include "scene/gui/dialogs.h"
-#include "scene/gui/tree.h"
#include "scene/gui/tab_container.h"
-#include "editor_file_dialog.h"
+#include "scene/gui/tree.h"
class EditorFileSystemDirectory;
class DependencyEditor : public AcceptDialog {
- GDCLASS(DependencyEditor,AcceptDialog);
-
+ GDCLASS(DependencyEditor, AcceptDialog);
Tree *tree;
Button *fixdeps;
@@ -49,97 +48,86 @@ class DependencyEditor : public AcceptDialog {
String editing;
List<String> missing;
+ void _fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String> > &candidates);
- void _fix_and_find(EditorFileSystemDirectory *efsd, Map<String,Map<String,String> >& candidates);
-
- void _searched(const String& p_path);
- void _load_pressed(Object* p_item,int p_cell,int p_button);
+ void _searched(const String &p_path);
+ void _load_pressed(Object *p_item, int p_cell, int p_button);
void _fix_all();
void _update_list();
void _update_file();
protected:
-
static void _bind_methods();
void _notification(int p_what);
-public:
-
- void edit(const String& p_path);
+public:
+ void edit(const String &p_path);
DependencyEditor();
};
class DependencyEditorOwners : public AcceptDialog {
- GDCLASS(DependencyEditorOwners,AcceptDialog);
+ GDCLASS(DependencyEditorOwners, AcceptDialog);
ItemList *owners;
String editing;
void _fill_owners(EditorFileSystemDirectory *efsd);
public:
-
- void show(const String& p_path);
+ void show(const String &p_path);
DependencyEditorOwners();
};
class DependencyRemoveDialog : public ConfirmationDialog {
- GDCLASS(DependencyRemoveDialog,ConfirmationDialog);
-
+ GDCLASS(DependencyRemoveDialog, ConfirmationDialog);
Label *text;
Tree *owners;
bool exist;
- Map<String,TreeItem*> files;
+ Map<String, TreeItem *> files;
void _fill_owners(EditorFileSystemDirectory *efsd);
void ok_pressed();
public:
-
void show(const Vector<String> &to_erase);
DependencyRemoveDialog();
};
-
class DependencyErrorDialog : public ConfirmationDialog {
- GDCLASS(DependencyErrorDialog,ConfirmationDialog);
-
+ GDCLASS(DependencyErrorDialog, ConfirmationDialog);
String for_file;
Button *fdep;
Label *text;
Tree *files;
void ok_pressed();
- void custom_action(const String&);
+ void custom_action(const String &);
public:
-
- void show(const String& p_for,const Vector<String> &report);
+ void show(const String &p_for, const Vector<String> &report);
DependencyErrorDialog();
};
-
-
class OrphanResourcesDialog : public ConfirmationDialog {
- GDCLASS(OrphanResourcesDialog,ConfirmationDialog);
+ GDCLASS(OrphanResourcesDialog, ConfirmationDialog);
DependencyEditor *dep_edit;
Tree *files;
ConfirmationDialog *delete_confirm;
void ok_pressed();
- bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String,int>& refs, TreeItem *p_parent);
+ bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent);
List<String> paths;
- void _find_to_delete(TreeItem* p_item,List<String>& paths);
+ void _find_to_delete(TreeItem *p_item, List<String> &paths);
void _delete_confirm();
- void _button_pressed(Object *p_item,int p_column, int p_id);
+ void _button_pressed(Object *p_item, int p_column, int p_id);
void refresh();
static void _bind_methods();
-public:
+public:
void show();
OrphanResourcesDialog();
};
diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp
index 47b8edfa04..4f1b85f236 100644
--- a/editor/doc/doc_data.cpp
+++ b/editor/doc/doc_data.cpp
@@ -28,18 +28,17 @@
/*************************************************************************/
#include "doc_data.h"
-#include "version.h"
-#include "global_constants.h"
#include "global_config.h"
-#include "script_language.h"
-#include "io/marshalls.h"
+#include "global_constants.h"
#include "io/compression.h"
+#include "io/marshalls.h"
#include "scene/resources/theme.h"
+#include "script_language.h"
+#include "version.h"
-void DocData::merge_from(const DocData& p_data) {
-
- for( Map<String,ClassDoc>::Element *E=class_list.front();E;E=E->next()) {
+void DocData::merge_from(const DocData &p_data) {
+ for (Map<String, ClassDoc>::Element *E = class_list.front(); E; E = E->next()) {
ClassDoc &c = E->get();
@@ -48,25 +47,26 @@ void DocData::merge_from(const DocData& p_data) {
const ClassDoc &cf = p_data.class_list[c.name];
- c.description=cf.description;
- c.brief_description=cf.brief_description;
+ c.description = cf.description;
+ c.brief_description = cf.brief_description;
- for(int i=0;i<c.methods.size();i++) {
+ for (int i = 0; i < c.methods.size(); i++) {
MethodDoc &m = c.methods[i];
- for(int j=0;j<cf.methods.size();j++) {
+ for (int j = 0; j < cf.methods.size(); j++) {
- if (cf.methods[j].name!=m.name)
+ if (cf.methods[j].name != m.name)
continue;
- if (cf.methods[j].arguments.size()!=m.arguments.size())
+ if (cf.methods[j].arguments.size() != m.arguments.size())
continue;
// since polymorphic functions are allowed we need to check the type of
// the arguments so we make sure they are different.
int arg_count = cf.methods[j].arguments.size();
Vector<bool> arg_used;
arg_used.resize(arg_count);
- for (int l = 0; l < arg_count; ++l) arg_used[l] = false;
+ for (int l = 0; l < arg_count; ++l)
+ arg_used[l] = false;
// also there is no guarantee that argument ordering will match, so we
// have to check one by one so we make sure we have an exact match
for (int k = 0; k < arg_count; ++k) {
@@ -85,234 +85,225 @@ void DocData::merge_from(const DocData& p_data) {
const MethodDoc &mf = cf.methods[j];
- m.description=mf.description;
+ m.description = mf.description;
break;
}
}
-
- for(int i=0;i<c.signals.size();i++) {
+ for (int i = 0; i < c.signals.size(); i++) {
MethodDoc &m = c.signals[i];
- for(int j=0;j<cf.signals.size();j++) {
+ for (int j = 0; j < cf.signals.size(); j++) {
- if (cf.signals[j].name!=m.name)
+ if (cf.signals[j].name != m.name)
continue;
const MethodDoc &mf = cf.signals[j];
- m.description=mf.description;
+ m.description = mf.description;
break;
}
}
- for(int i=0;i<c.constants.size();i++) {
+ for (int i = 0; i < c.constants.size(); i++) {
ConstantDoc &m = c.constants[i];
- for(int j=0;j<cf.constants.size();j++) {
+ for (int j = 0; j < cf.constants.size(); j++) {
- if (cf.constants[j].name!=m.name)
+ if (cf.constants[j].name != m.name)
continue;
const ConstantDoc &mf = cf.constants[j];
- m.description=mf.description;
+ m.description = mf.description;
break;
}
}
- for(int i=0;i<c.properties.size();i++) {
+ for (int i = 0; i < c.properties.size(); i++) {
PropertyDoc &p = c.properties[i];
- for(int j=0;j<cf.properties.size();j++) {
+ for (int j = 0; j < cf.properties.size(); j++) {
- if (cf.properties[j].name!=p.name)
+ if (cf.properties[j].name != p.name)
continue;
const PropertyDoc &pf = cf.properties[j];
- p.description=pf.description;
- p.setter=pf.setter;
- p.getter=pf.getter;
+ p.description = pf.description;
+ p.setter = pf.setter;
+ p.getter = pf.getter;
break;
}
}
- for(int i=0;i<c.theme_properties.size();i++) {
+ for (int i = 0; i < c.theme_properties.size(); i++) {
PropertyDoc &p = c.theme_properties[i];
- for(int j=0;j<cf.theme_properties.size();j++) {
+ for (int j = 0; j < cf.theme_properties.size(); j++) {
- if (cf.theme_properties[j].name!=p.name)
+ if (cf.theme_properties[j].name != p.name)
continue;
const PropertyDoc &pf = cf.theme_properties[j];
- p.description=pf.description;
+ p.description = pf.description;
break;
}
}
-
}
-
}
void DocData::remove_from(const DocData &p_data) {
- for(Map<String,ClassDoc>::Element* E=p_data.class_list.front(); E; E=E->next()) {
- if(class_list.has(E->key()))
+ for (Map<String, ClassDoc>::Element *E = p_data.class_list.front(); E; E = E->next()) {
+ if (class_list.has(E->key()))
class_list.erase(E->key());
}
}
void DocData::generate(bool p_basic_types) {
-
List<StringName> classes;
ClassDB::get_class_list(&classes);
classes.sort_custom<StringName::AlphCompare>();
- while(classes.size()) {
+ while (classes.size()) {
- String name=classes.front()->get();
- String cname=name;
+ String name = classes.front()->get();
+ String cname = name;
if (cname.begins_with("_")) //proxy class
- cname=cname.substr(1,name.length());
-
- class_list[cname]=ClassDoc();
- ClassDoc& c = class_list[cname];
- c.name=cname;
- c.inherits=ClassDB::get_parent_class(name);
- c.category=ClassDB::get_category(name);
+ cname = cname.substr(1, name.length());
+ class_list[cname] = ClassDoc();
+ ClassDoc &c = class_list[cname];
+ c.name = cname;
+ c.inherits = ClassDB::get_parent_class(name);
+ c.category = ClassDB::get_category(name);
List<PropertyInfo> properties;
- ClassDB::get_property_list(name,&properties,true);
+ ClassDB::get_property_list(name, &properties, true);
- for(List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) {
- if (E->get().usage& PROPERTY_USAGE_GROUP || E->get().usage& PROPERTY_USAGE_CATEGORY)
+ for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
+ if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_CATEGORY)
continue;
PropertyDoc prop;
- StringName setter = ClassDB::get_property_setter(name,E->get().name);
- StringName getter = ClassDB::get_property_getter(name,E->get().name);
-
- prop.name=E->get().name;
- prop.setter=setter;
- prop.getter=getter;
- if (E->get().type==Variant::OBJECT && E->get().hint==PROPERTY_HINT_RESOURCE_TYPE)
- prop.type=E->get().hint_string;
+ StringName setter = ClassDB::get_property_setter(name, E->get().name);
+ StringName getter = ClassDB::get_property_getter(name, E->get().name);
+
+ prop.name = E->get().name;
+ prop.setter = setter;
+ prop.getter = getter;
+ if (E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE)
+ prop.type = E->get().hint_string;
else
- prop.type=Variant::get_type_name(E->get().type);
+ prop.type = Variant::get_type_name(E->get().type);
c.properties.push_back(prop);
}
-
List<MethodInfo> method_list;
- ClassDB::get_method_list(name,&method_list,true);
+ ClassDB::get_method_list(name, &method_list, true);
method_list.sort();
+ for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
- for(List<MethodInfo>::Element *E=method_list.front();E;E=E->next()) {
-
- if (E->get().name=="" || (E->get().name[0]=='_' && !(E->get().flags&METHOD_FLAG_VIRTUAL)))
+ if (E->get().name == "" || (E->get().name[0] == '_' && !(E->get().flags & METHOD_FLAG_VIRTUAL)))
continue; //hiden, dont count
MethodDoc method;
- method.name=E->get().name;
-
- MethodBind *m = ClassDB::get_method(name,E->get().name);
+ method.name = E->get().name;
+ MethodBind *m = ClassDB::get_method(name, E->get().name);
- if (E->get().flags&METHOD_FLAG_VIRTUAL)
- method.qualifiers="virtual";
- if (E->get().flags&METHOD_FLAG_CONST) {
- if (method.qualifiers!="")
- method.qualifiers+=" ";
- method.qualifiers+="const";
+ if (E->get().flags & METHOD_FLAG_VIRTUAL)
+ method.qualifiers = "virtual";
+ if (E->get().flags & METHOD_FLAG_CONST) {
+ if (method.qualifiers != "")
+ method.qualifiers += " ";
+ method.qualifiers += "const";
- } else if (E->get().flags&METHOD_FLAG_VARARG) {
- if (method.qualifiers!="")
- method.qualifiers+=" ";
- method.qualifiers+="vararg";
+ } else if (E->get().flags & METHOD_FLAG_VARARG) {
+ if (method.qualifiers != "")
+ method.qualifiers += " ";
+ method.qualifiers += "vararg";
}
- for(int i=-1;i<E->get().arguments.size();i++) {
+ for (int i = -1; i < E->get().arguments.size(); i++) {
PropertyInfo arginfo;
- if (i==-1) {
+ if (i == -1) {
-
- arginfo=E->get().return_val;
+ arginfo = E->get().return_val;
#ifdef DEBUG_METHODS_ENABLED
- if (m && m->get_return_type()!=StringName())
- method.return_type=m->get_return_type();
- else if (method.name.find(":")!=-1) {
- method.return_type=method.name.get_slice(":",1);
- method.name=method.name.get_slice(":",0);
+ if (m && m->get_return_type() != StringName())
+ method.return_type = m->get_return_type();
+ else if (method.name.find(":") != -1) {
+ method.return_type = method.name.get_slice(":", 1);
+ method.name = method.name.get_slice(":", 0);
- } else if (arginfo.type!=Variant::NIL) // {
+ } else if (arginfo.type != Variant::NIL) // {
#endif
- method.return_type=(arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE)?arginfo.hint_string:Variant::get_type_name(arginfo.type);
+ method.return_type = (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) ? arginfo.hint_string : Variant::get_type_name(arginfo.type);
//}
} else {
ArgumentDoc argument;
- arginfo=E->get().arguments[i];
+ arginfo = E->get().arguments[i];
String type_name;
- if (arginfo.name.find(":")!=-1) {
- type_name=arginfo.name.get_slice(":",1);
- arginfo.name=arginfo.name.get_slice(":",0);
+ if (arginfo.name.find(":") != -1) {
+ type_name = arginfo.name.get_slice(":", 1);
+ arginfo.name = arginfo.name.get_slice(":", 0);
- } else if (arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE) {
- type_name=arginfo.hint_string;
- } else if (arginfo.type==Variant::NIL)
- type_name="Variant";
+ } else if (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) {
+ type_name = arginfo.hint_string;
+ } else if (arginfo.type == Variant::NIL)
+ type_name = "Variant";
else
- type_name=Variant::get_type_name(arginfo.type);
+ type_name = Variant::get_type_name(arginfo.type);
- if (arginfo.type==Variant::OBJECT) {
+ if (arginfo.type == Variant::OBJECT) {
//print_line("validate: "+cname+"::"+method.name);
}
if (m && m->has_default_argument(i)) {
- Variant default_arg=m->get_default_argument(i);
- String default_arg_text=m->get_default_argument(i);
+ Variant default_arg = m->get_default_argument(i);
+ String default_arg_text = m->get_default_argument(i);
- switch(default_arg.get_type()) {
+ switch (default_arg.get_type()) {
case Variant::NIL:
- default_arg_text="NULL";
+ default_arg_text = "NULL";
break;
// atomic types
case Variant::BOOL:
if (bool(default_arg))
- default_arg_text="true";
+ default_arg_text = "true";
else
- default_arg_text="false";
+ default_arg_text = "false";
break;
case Variant::INT:
case Variant::REAL:
//keep it
break;
- case Variant::STRING: // 15
- case Variant::NODE_PATH: // 15
- default_arg_text="\""+default_arg_text+"\"";
+ case Variant::STRING: // 15
+ case Variant::NODE_PATH: // 15
+ default_arg_text = "\"" + default_arg_text + "\"";
break;
case Variant::TRANSFORM:
- if (default_arg.operator Transform()==Transform()) {
- default_arg_text="";
+ if (default_arg.operator Transform() == Transform()) {
+ default_arg_text = "";
}
- default_arg_text=Variant::get_type_name(default_arg.get_type())+"("+default_arg_text+")";
+ default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")";
break;
case Variant::RECT3: //sorry naming convention fail :( not like it's used often // 10
@@ -321,48 +312,46 @@ void DocData::generate(bool p_basic_types) {
case Variant::POOL_BYTE_ARRAY:
case Variant::POOL_INT_ARRAY:
case Variant::POOL_REAL_ARRAY:
- case Variant::POOL_STRING_ARRAY: //25
+ case Variant::POOL_STRING_ARRAY: //25
case Variant::POOL_VECTOR2_ARRAY:
case Variant::POOL_VECTOR3_ARRAY:
case Variant::POOL_COLOR_ARRAY:
- default_arg_text=Variant::get_type_name(default_arg.get_type())+"("+default_arg_text+")";
+ default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")";
break;
- case Variant::VECTOR2: // 5
+ case Variant::VECTOR2: // 5
case Variant::RECT2:
case Variant::VECTOR3:
case Variant::QUAT:
case Variant::BASIS:
- default_arg_text=Variant::get_type_name(default_arg.get_type())+default_arg_text;
+ default_arg_text = Variant::get_type_name(default_arg.get_type()) + default_arg_text;
break;
case Variant::OBJECT:
if (default_arg.is_zero()) {
- default_arg_text="NULL";
+ default_arg_text = "NULL";
break;
}
case Variant::INPUT_EVENT:
- case Variant::DICTIONARY: // 20
+ case Variant::DICTIONARY: // 20
case Variant::ARRAY:
case Variant::_RID:
case Variant::IMAGE:
- //case Variant::RESOURCE:
+ //case Variant::RESOURCE:
- default_arg_text=Variant::get_type_name(default_arg.get_type())+"()";
+ default_arg_text = Variant::get_type_name(default_arg.get_type()) + "()";
break;
default: {}
-
}
-
- argument.type=type_name;
- argument.name=arginfo.name;
- argument.default_value=default_arg_text;
+ argument.type = type_name;
+ argument.name = arginfo.name;
+ argument.default_value = default_arg_text;
} else {
- argument.type=type_name;
- argument.name=arginfo.name;
+ argument.type = type_name;
+ argument.name = arginfo.name;
}
- if (arginfo.type==Variant::OBJECT) {
+ if (arginfo.type == Variant::OBJECT) {
//print_line("validate: "+cname+"::"+method.name);
}
@@ -370,7 +359,7 @@ void DocData::generate(bool p_basic_types) {
method.arguments.push_back(argument);
}
-/*
+ /*
String hint;
switch(arginfo.hint) {
case PROPERTY_HINT_DIR: hint="A directory."; break;
@@ -384,46 +373,41 @@ void DocData::generate(bool p_basic_types) {
if (hint!="")
_write_string(f,4,hint);
*/
-
-
}
c.methods.push_back(method);
}
List<MethodInfo> signal_list;
- ClassDB::get_signal_list(name,&signal_list,true);
+ ClassDB::get_signal_list(name, &signal_list, true);
if (signal_list.size()) {
-
- for(List<MethodInfo>::Element *EV=signal_list.front();EV;EV=EV->next()) {
+ for (List<MethodInfo>::Element *EV = signal_list.front(); EV; EV = EV->next()) {
MethodDoc signal;
- signal.name=EV->get().name;
- for(int i=0;i<EV->get().arguments.size();i++) {
+ signal.name = EV->get().name;
+ for (int i = 0; i < EV->get().arguments.size(); i++) {
- PropertyInfo arginfo=EV->get().arguments[i];
+ PropertyInfo arginfo = EV->get().arguments[i];
ArgumentDoc argument;
- argument.name=arginfo.name;
- argument.type=Variant::get_type_name(arginfo.type);
+ argument.name = arginfo.name;
+ argument.type = Variant::get_type_name(arginfo.type);
signal.arguments.push_back(argument);
}
c.signals.push_back(signal);
}
-
-
}
List<String> constant_list;
ClassDB::get_integer_constant_list(name, &constant_list, true);
- for(List<String>::Element *E=constant_list.front();E;E=E->next()) {
+ for (List<String>::Element *E = constant_list.front(); E; E = E->next()) {
ConstantDoc constant;
- constant.name=E->get();
- constant.value=itos(ClassDB::get_integer_constant(name, E->get()));
+ constant.name = E->get();
+ constant.value = itos(ClassDB::get_integer_constant(name, E->get()));
c.constants.push_back(constant);
}
@@ -431,187 +415,179 @@ void DocData::generate(bool p_basic_types) {
{
List<StringName> l;
- Theme::get_default()->get_constant_list(cname,&l);
- for (List<StringName>::Element*E=l.front();E;E=E->next()) {
+ Theme::get_default()->get_constant_list(cname, &l);
+ for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
PropertyDoc pd;
- pd.name=E->get();
- pd.type="int";
+ pd.name = E->get();
+ pd.type = "int";
c.theme_properties.push_back(pd);
}
l.clear();
- Theme::get_default()->get_color_list(cname,&l);
- for (List<StringName>::Element*E=l.front();E;E=E->next()) {
+ Theme::get_default()->get_color_list(cname, &l);
+ for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
PropertyDoc pd;
- pd.name=E->get();
- pd.type="Color";
+ pd.name = E->get();
+ pd.type = "Color";
c.theme_properties.push_back(pd);
}
l.clear();
- Theme::get_default()->get_icon_list(cname,&l);
- for (List<StringName>::Element*E=l.front();E;E=E->next()) {
+ Theme::get_default()->get_icon_list(cname, &l);
+ for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
PropertyDoc pd;
- pd.name=E->get();
- pd.type="Texture";
+ pd.name = E->get();
+ pd.type = "Texture";
c.theme_properties.push_back(pd);
}
l.clear();
- Theme::get_default()->get_font_list(cname,&l);
- for (List<StringName>::Element*E=l.front();E;E=E->next()) {
+ Theme::get_default()->get_font_list(cname, &l);
+ for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
PropertyDoc pd;
- pd.name=E->get();
- pd.type="Font";
+ pd.name = E->get();
+ pd.type = "Font";
c.theme_properties.push_back(pd);
}
l.clear();
- Theme::get_default()->get_stylebox_list(cname,&l);
- for (List<StringName>::Element*E=l.front();E;E=E->next()) {
+ Theme::get_default()->get_stylebox_list(cname, &l);
+ for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
PropertyDoc pd;
- pd.name=E->get();
- pd.type="StyleBox";
+ pd.name = E->get();
+ pd.type = "StyleBox";
c.theme_properties.push_back(pd);
}
-
}
-
classes.pop_front();
}
-
{
//so it can be documented that it does not exist
- class_list["Variant"]=ClassDoc();
- class_list["Variant"].name="Variant";
+ class_list["Variant"] = ClassDoc();
+ class_list["Variant"].name = "Variant";
}
if (!p_basic_types)
return;
- for (int i=0;i<Variant::VARIANT_MAX;i++) {
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- if (i==Variant::OBJECT)
+ if (i == Variant::OBJECT)
continue; //use the core type instead
- int loops=1;
+ int loops = 1;
- if (i==Variant::INPUT_EVENT)
- loops=InputEvent::TYPE_MAX;
+ if (i == Variant::INPUT_EVENT)
+ loops = InputEvent::TYPE_MAX;
- for(int j=0;j<loops;j++) {
+ for (int j = 0; j < loops; j++) {
- String cname=Variant::get_type_name(Variant::Type(i));
+ String cname = Variant::get_type_name(Variant::Type(i));
- if (i==Variant::INPUT_EVENT) {
- static const char* ie_type[InputEvent::TYPE_MAX]={
- "","Key","MouseMotion","MouseButton","JoypadMotion","JoypadButton","ScreenTouch","ScreenDrag","Action"
+ if (i == Variant::INPUT_EVENT) {
+ static const char *ie_type[InputEvent::TYPE_MAX] = {
+ "", "Key", "MouseMotion", "MouseButton", "JoypadMotion", "JoypadButton", "ScreenTouch", "ScreenDrag", "Action"
};
- cname+=ie_type[j];
+ cname += ie_type[j];
}
-
- class_list[cname]=ClassDoc();
- ClassDoc& c = class_list[cname];
- c.name=cname;
- c.category="Built-In Types";
+ class_list[cname] = ClassDoc();
+ ClassDoc &c = class_list[cname];
+ c.name = cname;
+ c.category = "Built-In Types";
Variant::CallError cerror;
- Variant v=Variant::construct(Variant::Type(i),NULL,0,cerror);
+ Variant v = Variant::construct(Variant::Type(i), NULL, 0, cerror);
- if (i==Variant::INPUT_EVENT) {
- v.set("type",j);
+ if (i == Variant::INPUT_EVENT) {
+ v.set("type", j);
}
List<MethodInfo> method_list;
v.get_method_list(&method_list);
method_list.sort();
- Variant::get_constructor_list(Variant::Type(i),&method_list);
+ Variant::get_constructor_list(Variant::Type(i), &method_list);
+ for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
- for(List<MethodInfo>::Element *E=method_list.front();E;E=E->next()) {
-
- MethodInfo &mi=E->get();
+ MethodInfo &mi = E->get();
MethodDoc method;
- method.name=mi.name;
+ method.name = mi.name;
- for(int i=0;i<mi.arguments.size();i++) {
+ for (int i = 0; i < mi.arguments.size(); i++) {
ArgumentDoc arg;
- PropertyInfo pi=mi.arguments[i];
+ PropertyInfo pi = mi.arguments[i];
- arg.name=pi.name;
+ arg.name = pi.name;
//print_line("arg name: "+arg.name);
- if (pi.type==Variant::NIL)
- arg.type="var";
+ if (pi.type == Variant::NIL)
+ arg.type = "var";
else
- arg.type=Variant::get_type_name(pi.type);
+ arg.type = Variant::get_type_name(pi.type);
int defarg = mi.default_arguments.size() - mi.arguments.size() + i;
- if (defarg >=0)
- arg.default_value=mi.default_arguments[defarg];
+ if (defarg >= 0)
+ arg.default_value = mi.default_arguments[defarg];
method.arguments.push_back(arg);
}
- if (mi.return_val.type==Variant::NIL) {
- if (mi.return_val.name!="")
- method.return_type="var";
+ if (mi.return_val.type == Variant::NIL) {
+ if (mi.return_val.name != "")
+ method.return_type = "var";
} else {
- method.return_type=Variant::get_type_name(mi.return_val.type);
+ method.return_type = Variant::get_type_name(mi.return_val.type);
}
c.methods.push_back(method);
}
-
List<PropertyInfo> properties;
v.get_property_list(&properties);
- for(List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
- PropertyInfo pi=E->get();
+ PropertyInfo pi = E->get();
PropertyDoc property;
- property.name=pi.name;
- property.type=Variant::get_type_name(pi.type);
+ property.name = pi.name;
+ property.type = Variant::get_type_name(pi.type);
c.properties.push_back(property);
}
List<StringName> constants;
- Variant::get_numeric_constants_for_type(Variant::Type(i),&constants);
+ Variant::get_numeric_constants_for_type(Variant::Type(i), &constants);
- for(List<StringName>::Element *E=constants.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
ConstantDoc constant;
- constant.name=E->get();
- constant.value=itos(Variant::get_numeric_constant_value(Variant::Type(i),E->get()));
+ constant.name = E->get();
+ constant.value = itos(Variant::get_numeric_constant_value(Variant::Type(i), E->get()));
c.constants.push_back(constant);
}
}
-
}
//built in constants and functions
{
- String cname="@Global Scope";
- class_list[cname]=ClassDoc();
- ClassDoc& c = class_list[cname];
- c.name=cname;
-
+ String cname = "@Global Scope";
+ class_list[cname] = ClassDoc();
+ ClassDoc &c = class_list[cname];
+ c.name = cname;
- for(int i=0;i<GlobalConstants::get_global_constant_count();i++) {
+ for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) {
ConstantDoc cd;
- cd.name=GlobalConstants::get_global_constant_name(i);
- cd.value=itos(GlobalConstants::get_global_constant_value(i));
+ cd.name = GlobalConstants::get_global_constant_name(i);
+ cd.value = itos(GlobalConstants::get_global_constant_value(i));
c.constants.push_back(cd);
}
@@ -619,524 +595,495 @@ void DocData::generate(bool p_basic_types) {
GlobalConfig::get_singleton()->get_singletons(&singletons);
//servers (this is kind of hackish)
- for(List<GlobalConfig::Singleton>::Element *E=singletons.front();E;E=E->next()) {
+ for (List<GlobalConfig::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
PropertyDoc pd;
- GlobalConfig::Singleton &s=E->get();
- pd.name=s.name;
- pd.type=s.ptr->get_class();
- while (String(ClassDB::get_parent_class(pd.type))!="Object")
- pd.type=ClassDB::get_parent_class(pd.type);
+ GlobalConfig::Singleton &s = E->get();
+ pd.name = s.name;
+ pd.type = s.ptr->get_class();
+ while (String(ClassDB::get_parent_class(pd.type)) != "Object")
+ pd.type = ClassDB::get_parent_class(pd.type);
if (pd.type.begins_with("_"))
- pd.type=pd.type.substr(1,pd.type.length());
+ pd.type = pd.type.substr(1, pd.type.length());
c.properties.push_back(pd);
-
}
-
}
//built in script reference
{
-
- for(int i=0;i<ScriptServer::get_language_count();i++) {
-
+ for (int i = 0; i < ScriptServer::get_language_count(); i++) {
ScriptLanguage *lang = ScriptServer::get_language(i);
- String cname="@"+lang->get_name();
- class_list[cname]=ClassDoc();
- ClassDoc& c = class_list[cname];
- c.name=cname;
+ String cname = "@" + lang->get_name();
+ class_list[cname] = ClassDoc();
+ ClassDoc &c = class_list[cname];
+ c.name = cname;
List<MethodInfo> minfo;
lang->get_public_functions(&minfo);
+ for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) {
- for(List<MethodInfo>::Element *E=minfo.front();E;E=E->next()) {
-
- MethodInfo &mi=E->get();
+ MethodInfo &mi = E->get();
MethodDoc md;
- md.name=mi.name;
- if (mi.return_val.name!="")
- md.return_type=mi.return_val.name;
- else if (mi.name.find(":")!=-1) {
- md.return_type=mi.name.get_slice(":",1);
- md.name=mi.name.get_slice(":",0);
+ md.name = mi.name;
+ if (mi.return_val.name != "")
+ md.return_type = mi.return_val.name;
+ else if (mi.name.find(":") != -1) {
+ md.return_type = mi.name.get_slice(":", 1);
+ md.name = mi.name.get_slice(":", 0);
} else
- md.return_type=Variant::get_type_name(mi.return_val.type);
+ md.return_type = Variant::get_type_name(mi.return_val.type);
- for(int i=0;i<mi.arguments.size();i++) {
+ for (int i = 0; i < mi.arguments.size(); i++) {
- PropertyInfo &pi=mi.arguments[i];
+ PropertyInfo &pi = mi.arguments[i];
ArgumentDoc ad;
- ad.name=pi.name;
+ ad.name = pi.name;
-
- if (pi.type==Variant::NIL)
- ad.type="Variant";
+ if (pi.type == Variant::NIL)
+ ad.type = "Variant";
else
- ad.type=Variant::get_type_name( pi.type );
+ ad.type = Variant::get_type_name(pi.type);
md.arguments.push_back(ad);
}
c.methods.push_back(md);
-
}
- List<Pair<String,Variant> > cinfo;
+ List<Pair<String, Variant> > cinfo;
lang->get_public_constants(&cinfo);
-
- for(List<Pair<String,Variant> >::Element *E=cinfo.front();E;E=E->next()) {
+ for (List<Pair<String, Variant> >::Element *E = cinfo.front(); E; E = E->next()) {
ConstantDoc cd;
- cd.name=E->get().first;
- cd.value=E->get().second;
+ cd.name = E->get().first;
+ cd.value = E->get().second;
c.constants.push_back(cd);
}
}
}
-
-
}
+static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &methods) {
-static Error _parse_methods(Ref<XMLParser>& parser,Vector<DocData::MethodDoc>& methods) {
-
- String section=parser->get_node_name();
- String element=section.substr(0,section.length()-1);
+ String section = parser->get_node_name();
+ String element = section.substr(0, section.length() - 1);
- while(parser->read()==OK) {
+ while (parser->read() == OK) {
- if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
- if (parser->get_node_name()==element) {
+ if (parser->get_node_name() == element) {
DocData::MethodDoc method;
- ERR_FAIL_COND_V(!parser->has_attribute("name"),ERR_FILE_CORRUPT);
- method.name=parser->get_attribute_value("name");
+ ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
+ method.name = parser->get_attribute_value("name");
if (parser->has_attribute("qualifiers"))
- method.qualifiers=parser->get_attribute_value("qualifiers");
-
+ method.qualifiers = parser->get_attribute_value("qualifiers");
- while(parser->read()==OK) {
+ while (parser->read() == OK) {
- if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
- String name=parser->get_node_name();
- if (name=="return") {
+ String name = parser->get_node_name();
+ if (name == "return") {
- ERR_FAIL_COND_V(!parser->has_attribute("type"),ERR_FILE_CORRUPT);
- method.return_type=parser->get_attribute_value("type");
- } else if (name=="argument") {
+ ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT);
+ method.return_type = parser->get_attribute_value("type");
+ } else if (name == "argument") {
DocData::ArgumentDoc argument;
- ERR_FAIL_COND_V(!parser->has_attribute("name"),ERR_FILE_CORRUPT);
- argument.name=parser->get_attribute_value("name");
- ERR_FAIL_COND_V(!parser->has_attribute("type"),ERR_FILE_CORRUPT);
- argument.type=parser->get_attribute_value("type");
+ ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
+ argument.name = parser->get_attribute_value("name");
+ ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT);
+ argument.type = parser->get_attribute_value("type");
method.arguments.push_back(argument);
- } else if (name=="description") {
+ } else if (name == "description") {
parser->read();
- if (parser->get_node_type()==XMLParser::NODE_TEXT)
- method.description=parser->get_node_data().strip_edges();
+ if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ method.description = parser->get_node_data().strip_edges();
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()==element)
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == element)
break;
}
methods.push_back(method);
} else {
- ERR_EXPLAIN("Invalid tag in doc file: "+parser->get_node_name());
+ ERR_EXPLAIN("Invalid tag in doc file: " + parser->get_node_name());
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()==section)
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == section)
break;
}
return OK;
}
-Error DocData::load(const String& p_path) {
+Error DocData::load(const String &p_path) {
- Ref<XMLParser> parser=memnew(XMLParser);
+ Ref<XMLParser> parser = memnew(XMLParser);
Error err = parser->open(p_path);
if (err)
return err;
return _load(parser);
-
}
Error DocData::_load(Ref<XMLParser> parser) {
- Error err=OK;
+ Error err = OK;
- while((err=parser->read())==OK) {
+ while ((err = parser->read()) == OK) {
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
if (parser->get_node_name() == "doc") {
break;
} else if (!parser->is_empty())
- parser->skip_section();// unknown section, likely headers
+ parser->skip_section(); // unknown section, likely headers
}
}
if (parser->has_attribute("version"))
- version=parser->get_attribute_value("version");
-
-
- while((err=parser->read())==OK) {
+ version = parser->get_attribute_value("version");
+ while ((err = parser->read()) == OK) {
- if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="doc")
+ if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "doc")
break; //end of <doc>
if (parser->get_node_type() != XMLParser::NODE_ELEMENT)
continue; //no idea what this may be, but skipping anyway
- ERR_FAIL_COND_V( parser->get_node_name()!="class", ERR_FILE_CORRUPT );
+ ERR_FAIL_COND_V(parser->get_node_name() != "class", ERR_FILE_CORRUPT);
- ERR_FAIL_COND_V( !parser->has_attribute("name"), ERR_FILE_CORRUPT);
+ ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
String name = parser->get_attribute_value("name");
- class_list[name]=ClassDoc();
- ClassDoc& c = class_list[name];
+ class_list[name] = ClassDoc();
+ ClassDoc &c = class_list[name];
//print_line("class: "+name);
- c.name=name;
+ c.name = name;
if (parser->has_attribute("inherits"))
c.inherits = parser->get_attribute_value("inherits");
if (parser->has_attribute("category"))
c.category = parser->get_attribute_value("category");
- while(parser->read()==OK) {
+ while (parser->read() == OK) {
- if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
String name = parser->get_node_name();
- if (name=="brief_description") {
+ if (name == "brief_description") {
parser->read();
- if (parser->get_node_type()==XMLParser::NODE_TEXT)
- c.brief_description=parser->get_node_data().strip_edges();
+ if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ c.brief_description = parser->get_node_data().strip_edges();
- } else if (name=="description") {
+ } else if (name == "description") {
parser->read();
- if (parser->get_node_type()==XMLParser::NODE_TEXT)
- c.description=parser->get_node_data().strip_edges();
- } else if (name=="methods") {
+ if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ c.description = parser->get_node_data().strip_edges();
+ } else if (name == "methods") {
- Error err = _parse_methods(parser,c.methods);
- ERR_FAIL_COND_V(err,err);
+ Error err = _parse_methods(parser, c.methods);
+ ERR_FAIL_COND_V(err, err);
- } else if (name=="signals") {
+ } else if (name == "signals") {
- Error err = _parse_methods(parser,c.signals);
- ERR_FAIL_COND_V(err,err);
- } else if (name=="members") {
+ Error err = _parse_methods(parser, c.signals);
+ ERR_FAIL_COND_V(err, err);
+ } else if (name == "members") {
- while(parser->read()==OK) {
+ while (parser->read() == OK) {
- if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
String name = parser->get_node_name();
- if (name=="member") {
+ if (name == "member") {
PropertyDoc prop;
- ERR_FAIL_COND_V(!parser->has_attribute("name"),ERR_FILE_CORRUPT);
- prop.name=parser->get_attribute_value("name");
- ERR_FAIL_COND_V(!parser->has_attribute("type"),ERR_FILE_CORRUPT);
- prop.type=parser->get_attribute_value("type");
+ ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
+ prop.name = parser->get_attribute_value("name");
+ ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT);
+ prop.type = parser->get_attribute_value("type");
if (parser->has_attribute("setter"))
- prop.setter=parser->get_attribute_value("setter");
+ prop.setter = parser->get_attribute_value("setter");
if (parser->has_attribute("getter"))
- prop.getter=parser->get_attribute_value("getter");
+ prop.getter = parser->get_attribute_value("getter");
if (parser->has_attribute("brief"))
- prop.brief_description=parser->get_attribute_value("brief").xml_unescape();
+ prop.brief_description = parser->get_attribute_value("brief").xml_unescape();
parser->read();
- if (parser->get_node_type()==XMLParser::NODE_TEXT)
- prop.description=parser->get_node_data().strip_edges();
+ if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ prop.description = parser->get_node_data().strip_edges();
c.properties.push_back(prop);
} else {
- ERR_EXPLAIN("Invalid tag in doc file: "+name);
+ ERR_EXPLAIN("Invalid tag in doc file: " + name);
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="members")
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "members")
break; //end of <constants>
}
- } else if (name=="theme_items") {
+ } else if (name == "theme_items") {
- while(parser->read()==OK) {
+ while (parser->read() == OK) {
- if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
String name = parser->get_node_name();
- if (name=="theme_item") {
+ if (name == "theme_item") {
PropertyDoc prop;
- ERR_FAIL_COND_V(!parser->has_attribute("name"),ERR_FILE_CORRUPT);
- prop.name=parser->get_attribute_value("name");
- ERR_FAIL_COND_V(!parser->has_attribute("type"),ERR_FILE_CORRUPT);
- prop.type=parser->get_attribute_value("type");
+ ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
+ prop.name = parser->get_attribute_value("name");
+ ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT);
+ prop.type = parser->get_attribute_value("type");
parser->read();
- if (parser->get_node_type()==XMLParser::NODE_TEXT)
- prop.description=parser->get_node_data().strip_edges();
+ if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ prop.description = parser->get_node_data().strip_edges();
c.theme_properties.push_back(prop);
} else {
- ERR_EXPLAIN("Invalid tag in doc file: "+name);
+ ERR_EXPLAIN("Invalid tag in doc file: " + name);
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="theme_items")
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "theme_items")
break; //end of <constants>
}
- } else if (name=="constants") {
+ } else if (name == "constants") {
- while(parser->read()==OK) {
+ while (parser->read() == OK) {
- if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
+ if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
- String name=parser->get_node_name();
+ String name = parser->get_node_name();
- if (name=="constant") {
+ if (name == "constant") {
ConstantDoc constant;
- ERR_FAIL_COND_V(!parser->has_attribute("name"),ERR_FILE_CORRUPT);
- constant.name=parser->get_attribute_value("name");
- ERR_FAIL_COND_V(!parser->has_attribute("value"),ERR_FILE_CORRUPT);
- constant.value=parser->get_attribute_value("value");
+ ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
+ constant.name = parser->get_attribute_value("name");
+ ERR_FAIL_COND_V(!parser->has_attribute("value"), ERR_FILE_CORRUPT);
+ constant.value = parser->get_attribute_value("value");
parser->read();
- if (parser->get_node_type()==XMLParser::NODE_TEXT)
- constant.description=parser->get_node_data().strip_edges();
+ if (parser->get_node_type() == XMLParser::NODE_TEXT)
+ constant.description = parser->get_node_data().strip_edges();
c.constants.push_back(constant);
} else {
- ERR_EXPLAIN("Invalid tag in doc file: "+name);
+ ERR_EXPLAIN("Invalid tag in doc file: " + name);
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="constants")
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "constants")
break; //end of <constants>
}
} else {
- ERR_EXPLAIN("Invalid tag in doc file: "+name);
+ ERR_EXPLAIN("Invalid tag in doc file: " + name);
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
-
- } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="class")
+ } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "class")
break; //end of <asset>
}
-
-
}
return OK;
}
-
-static void _write_string(FileAccess *f,int p_tablevel,const String& p_string) {
+static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) {
String tab;
- for(int i=0;i<p_tablevel;i++) tab+="\t";
- f->store_string(tab+p_string+"\n");
+ for (int i = 0; i < p_tablevel; i++)
+ tab += "\t";
+ f->store_string(tab + p_string + "\n");
}
-Error DocData::save(const String& p_path) {
+Error DocData::save(const String &p_path) {
Error err;
- FileAccess *f = FileAccess::open(p_path,FileAccess::WRITE,&err);
+ FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE, &err);
if (err) {
- ERR_EXPLAIN("Can't write doc file: "+p_path);
+ ERR_EXPLAIN("Can't write doc file: " + p_path);
ERR_FAIL_V(err);
-
}
- _write_string(f,0,"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
- _write_string(f,0,"<doc version=\""+String(VERSION_MKSTRING)+"\" name=\"Engine Types\">");
-
- for( Map<String,ClassDoc>::Element *E=class_list.front();E;E=E->next()) {
-
- ClassDoc &c=E->get();
-
- String header="<class name=\""+c.name+"\"";
- if (c.inherits!="")
- header+=" inherits=\""+c.inherits+"\"";
-
- String category=c.category;
- if (c.category=="")
- category="Core";
- header+=" category=\""+category+"\"";
- header+=">";
- _write_string(f,0,header);
- _write_string(f,1,"<brief_description>");
- if (c.brief_description!="")
- _write_string(f,2,c.brief_description.xml_escape());
- _write_string(f,1,"</brief_description>");
- _write_string(f,1,"<description>");
- if (c.description!="")
- _write_string(f,2,c.description.xml_escape());
- _write_string(f,1,"</description>");
- _write_string(f,1,"<methods>");
+ _write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
+ _write_string(f, 0, "<doc version=\"" + String(VERSION_MKSTRING) + "\" name=\"Engine Types\">");
+
+ for (Map<String, ClassDoc>::Element *E = class_list.front(); E; E = E->next()) {
+
+ ClassDoc &c = E->get();
+
+ String header = "<class name=\"" + c.name + "\"";
+ if (c.inherits != "")
+ header += " inherits=\"" + c.inherits + "\"";
+
+ String category = c.category;
+ if (c.category == "")
+ category = "Core";
+ header += " category=\"" + category + "\"";
+ header += ">";
+ _write_string(f, 0, header);
+ _write_string(f, 1, "<brief_description>");
+ if (c.brief_description != "")
+ _write_string(f, 2, c.brief_description.xml_escape());
+ _write_string(f, 1, "</brief_description>");
+ _write_string(f, 1, "<description>");
+ if (c.description != "")
+ _write_string(f, 2, c.description.xml_escape());
+ _write_string(f, 1, "</description>");
+ _write_string(f, 1, "<methods>");
c.methods.sort();
- for(int i=0;i<c.methods.size();i++) {
+ for (int i = 0; i < c.methods.size(); i++) {
- MethodDoc &m=c.methods[i];
+ MethodDoc &m = c.methods[i];
String qualifiers;
- if (m.qualifiers!="")
- qualifiers+=" qualifiers=\""+m.qualifiers.xml_escape()+"\"";
+ if (m.qualifiers != "")
+ qualifiers += " qualifiers=\"" + m.qualifiers.xml_escape() + "\"";
- _write_string(f,2,"<method name=\""+m.name+"\""+qualifiers+">");
+ _write_string(f, 2, "<method name=\"" + m.name + "\"" + qualifiers + ">");
- if (m.return_type!="") {
+ if (m.return_type != "") {
- _write_string(f,3,"<return type=\""+m.return_type+"\">");
- _write_string(f,3,"</return>");
+ _write_string(f, 3, "<return type=\"" + m.return_type + "\">");
+ _write_string(f, 3, "</return>");
}
- for(int j=0;j<m.arguments.size();j++) {
+ for (int j = 0; j < m.arguments.size(); j++) {
ArgumentDoc &a = m.arguments[j];
- if (a.default_value!="")
- _write_string(f,3,"<argument index=\""+itos(j)+"\" name=\""+a.name.xml_escape()+"\" type=\""+a.type.xml_escape()+"\" default=\""+a.default_value.xml_escape(true)+"\">");
+ if (a.default_value != "")
+ _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\" default=\"" + a.default_value.xml_escape(true) + "\">");
else
- _write_string(f,3,"<argument index=\""+itos(j)+"\" name=\""+a.name.xml_escape()+"\" type=\""+a.type.xml_escape()+"\">");
-
- _write_string(f,3,"</argument>");
+ _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\">");
+ _write_string(f, 3, "</argument>");
}
- _write_string(f,3,"<description>");
- if (m.description!="")
- _write_string(f,4,m.description.xml_escape());
- _write_string(f,3,"</description>");
-
- _write_string(f,2,"</method>");
+ _write_string(f, 3, "<description>");
+ if (m.description != "")
+ _write_string(f, 4, m.description.xml_escape());
+ _write_string(f, 3, "</description>");
+ _write_string(f, 2, "</method>");
}
- _write_string(f,1,"</methods>");
+ _write_string(f, 1, "</methods>");
if (c.properties.size()) {
- _write_string(f,1,"<members>");
+ _write_string(f, 1, "<members>");
c.properties.sort();
- for(int i=0;i<c.properties.size();i++) {
-
-
- PropertyDoc &p=c.properties[i];
- _write_string(f,2,"<member name=\""+p.name+"\" type=\""+p.type+"\" setter=\""+p.setter+"\" getter=\""+p.getter+"\" brief=\""+p.brief_description.xml_escape(true)+"\">");
- if (p.description!="")
- _write_string(f,3,p.description.xml_escape());
- _write_string(f,2,"</member>");
+ for (int i = 0; i < c.properties.size(); i++) {
+ PropertyDoc &p = c.properties[i];
+ _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\" brief=\"" + p.brief_description.xml_escape(true) + "\">");
+ if (p.description != "")
+ _write_string(f, 3, p.description.xml_escape());
+ _write_string(f, 2, "</member>");
}
- _write_string(f,1,"</members>");
+ _write_string(f, 1, "</members>");
}
if (c.signals.size()) {
c.signals.sort();
- _write_string(f,1,"<signals>");
- for(int i=0;i<c.signals.size();i++) {
+ _write_string(f, 1, "<signals>");
+ for (int i = 0; i < c.signals.size(); i++) {
- MethodDoc &m=c.signals[i];
- _write_string(f,2,"<signal name=\""+m.name+"\">");
- for(int j=0;j<m.arguments.size();j++) {
+ MethodDoc &m = c.signals[i];
+ _write_string(f, 2, "<signal name=\"" + m.name + "\">");
+ for (int j = 0; j < m.arguments.size(); j++) {
ArgumentDoc &a = m.arguments[j];
- _write_string(f,3,"<argument index=\""+itos(j)+"\" name=\""+a.name.xml_escape()+"\" type=\""+a.type.xml_escape()+"\">");
- _write_string(f,3,"</argument>");
-
+ _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\">");
+ _write_string(f, 3, "</argument>");
}
- _write_string(f,3,"<description>");
- if (m.description!="")
- _write_string(f,4,m.description.xml_escape());
- _write_string(f,3,"</description>");
+ _write_string(f, 3, "<description>");
+ if (m.description != "")
+ _write_string(f, 4, m.description.xml_escape());
+ _write_string(f, 3, "</description>");
- _write_string(f,2,"</signal>");
+ _write_string(f, 2, "</signal>");
}
- _write_string(f,1,"</signals>");
+ _write_string(f, 1, "</signals>");
}
- _write_string(f,1,"<constants>");
+ _write_string(f, 1, "<constants>");
+ for (int i = 0; i < c.constants.size(); i++) {
- for(int i=0;i<c.constants.size();i++) {
-
- ConstantDoc &k=c.constants[i];
- _write_string(f,2,"<constant name=\""+k.name+"\" value=\""+k.value+"\">");
- if (k.description!="")
- _write_string(f,3,k.description.xml_escape());
- _write_string(f,2,"</constant>");
+ ConstantDoc &k = c.constants[i];
+ _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\">");
+ if (k.description != "")
+ _write_string(f, 3, k.description.xml_escape());
+ _write_string(f, 2, "</constant>");
}
- _write_string(f,1,"</constants>");
+ _write_string(f, 1, "</constants>");
if (c.theme_properties.size()) {
c.theme_properties.sort();
- _write_string(f,1,"<theme_items>");
- for(int i=0;i<c.theme_properties.size();i++) {
-
-
- PropertyDoc &p=c.theme_properties[i];
- _write_string(f,2,"<theme_item name=\""+p.name+"\" type=\""+p.type+"\">");
- _write_string(f,2,"</theme_item>");
+ _write_string(f, 1, "<theme_items>");
+ for (int i = 0; i < c.theme_properties.size(); i++) {
+ PropertyDoc &p = c.theme_properties[i];
+ _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">");
+ _write_string(f, 2, "</theme_item>");
}
- _write_string(f,1,"</theme_items>");
+ _write_string(f, 1, "</theme_items>");
}
- _write_string(f,0,"</class>");
-
+ _write_string(f, 0, "</class>");
}
- _write_string(f,0,"</doc>");
+ _write_string(f, 0, "</doc>");
f->close();
memdelete(f);
return OK;
}
-
Error DocData::load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size) {
Vector<uint8_t> data;
data.resize(p_uncompressed_size);
- Compression::decompress(data.ptr(),p_uncompressed_size,p_data,p_compressed_size,Compression::MODE_DEFLATE);
+ Compression::decompress(data.ptr(), p_uncompressed_size, p_data, p_compressed_size, Compression::MODE_DEFLATE);
class_list.clear();
- Ref<XMLParser> parser = memnew( XMLParser );
+ Ref<XMLParser> parser = memnew(XMLParser);
Error err = parser->open_buffer(data);
if (err)
return err;
@@ -1144,5 +1091,4 @@ Error DocData::load_compressed(const uint8_t *p_data, int p_compressed_size, int
_load(parser);
return OK;
-
}
diff --git a/editor/doc/doc_data.h b/editor/doc/doc_data.h
index 7601013979..b4bd63e6ee 100644
--- a/editor/doc/doc_data.h
+++ b/editor/doc/doc_data.h
@@ -29,12 +29,11 @@
#ifndef DOC_DATA_H
#define DOC_DATA_H
-
-#include "variant.h"
-#include "map.h"
#include "io/xml_parser.h"
+#include "map.h"
+#include "variant.h"
-class DocData {
+class DocData {
public:
struct ArgumentDoc {
@@ -50,8 +49,8 @@ public:
String qualifiers;
String description;
Vector<ArgumentDoc> arguments;
- bool operator<(const MethodDoc& p_md) const {
- return name<p_md.name;
+ bool operator<(const MethodDoc &p_md) const {
+ return name < p_md.name;
}
};
@@ -68,13 +67,13 @@ public:
String type;
String brief_description;
String description;
- String setter,getter;
- bool operator<(const PropertyDoc& p_prop) const {
- return name<p_prop.name;
+ String setter, getter;
+ bool operator<(const PropertyDoc &p_prop) const {
+ return name < p_prop.name;
}
};
- struct ClassDoc {
+ struct ClassDoc {
String name;
String inherits;
@@ -86,26 +85,21 @@ public:
Vector<ConstantDoc> constants;
Vector<PropertyDoc> properties;
Vector<PropertyDoc> theme_properties;
-
};
String version;
- Map<String,ClassDoc> class_list;
+ Map<String, ClassDoc> class_list;
Error _load(Ref<XMLParser> parser);
-
public:
-
- void merge_from(const DocData& p_data);
- void remove_from(const DocData& p_data);
- void generate(bool p_basic_types=false);
- Error load(const String& p_path);
- Error save(const String& p_path);
+ void merge_from(const DocData &p_data);
+ void remove_from(const DocData &p_data);
+ void generate(bool p_basic_types = false);
+ Error load(const String &p_path);
+ Error save(const String &p_path);
Error load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size);
-
-
};
#endif // DOC_DATA_H
diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp
index 5ebba596e9..38b61d706d 100644
--- a/editor/doc/doc_dump.cpp
+++ b/editor/doc/doc_dump.cpp
@@ -28,162 +28,155 @@
/*************************************************************************/
#include "doc_dump.h"
-#include "version.h"
#include "os/file_access.h"
#include "scene/main/node.h"
+#include "version.h"
-
-static void _write_string(FileAccess *f,int p_tablevel,const String& p_string) {
+static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) {
String tab;
- for(int i=0;i<p_tablevel;i++) tab+="\t";
- f->store_string(tab+p_string+"\n");
+ for (int i = 0; i < p_tablevel; i++)
+ tab += "\t";
+ f->store_string(tab + p_string + "\n");
}
struct _ConstantSort {
String name;
int value;
- bool operator<(const _ConstantSort& p_c) const {
+ bool operator<(const _ConstantSort &p_c) const {
- String left_a=name.find("_")==-1?name:name.substr(0,name.find("_"));
- String left_b=p_c.name.find("_")==-1?p_c.name:p_c.name.substr(0,p_c.name.find("_"));
- if(left_a==left_b)
- return value<p_c.value;
+ String left_a = name.find("_") == -1 ? name : name.substr(0, name.find("_"));
+ String left_b = p_c.name.find("_") == -1 ? p_c.name : p_c.name.substr(0, p_c.name.find("_"));
+ if (left_a == left_b)
+ return value < p_c.value;
else
- return left_a<left_b;
-
+ return left_a < left_b;
}
-
};
+static String _escape_string(const String &p_str) {
-static String _escape_string(const String& p_str) {
-
- String ret=p_str;
- ret=ret.replace("&","&amp;");
- ret=ret.replace("<","&gt;");
- ret=ret.replace(">","&lt;");
- ret=ret.replace("'","&apos;");
- ret=ret.replace("\"","&quot;");
- for (char i=1;i<32;i++) {
+ String ret = p_str;
+ ret = ret.replace("&", "&amp;");
+ ret = ret.replace("<", "&gt;");
+ ret = ret.replace(">", "&lt;");
+ ret = ret.replace("'", "&apos;");
+ ret = ret.replace("\"", "&quot;");
+ for (char i = 1; i < 32; i++) {
- char chr[2]={i,0};
- ret=ret.replace(chr,"&#"+String::num(i)+";");
+ char chr[2] = { i, 0 };
+ ret = ret.replace(chr, "&#" + String::num(i) + ";");
}
- ret=ret.utf8();
+ ret = ret.utf8();
return ret;
}
-void DocDump::dump(const String& p_file) {
-
+void DocDump::dump(const String &p_file) {
List<StringName> class_list;
ClassDB::get_class_list(&class_list);
class_list.sort_custom<StringName::AlphCompare>();
+ FileAccess *f = FileAccess::open(p_file, FileAccess::WRITE);
- FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE);
-
- _write_string(f,0,"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
+ _write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
- _write_string(f,0,"<doc version=\""+String(VERSION_MKSTRING)+"\" name=\"Engine Types\">");
- while(class_list.size()) {
+ _write_string(f, 0, "<doc version=\"" + String(VERSION_MKSTRING) + "\" name=\"Engine Types\">");
+ while (class_list.size()) {
- String name=class_list.front()->get();
+ String name = class_list.front()->get();
- String header="<class name=\""+name+"\"";
- String inherits=ClassDB::get_parent_class(name);
- if (inherits!="")
- header+=" inherits=\""+inherits+"\"";
- String category=ClassDB::get_category(name);
- if (category=="")
- category="Core";
- header+=" category=\""+category+"\"";
- header+=">";
- _write_string(f,0,header);
- _write_string(f,1,"<brief_description>");
- _write_string(f,1,"</brief_description>");
- _write_string(f,1,"<description>");
- _write_string(f,1,"</description>");
- _write_string(f,1,"<methods>");
+ String header = "<class name=\"" + name + "\"";
+ String inherits = ClassDB::get_parent_class(name);
+ if (inherits != "")
+ header += " inherits=\"" + inherits + "\"";
+ String category = ClassDB::get_category(name);
+ if (category == "")
+ category = "Core";
+ header += " category=\"" + category + "\"";
+ header += ">";
+ _write_string(f, 0, header);
+ _write_string(f, 1, "<brief_description>");
+ _write_string(f, 1, "</brief_description>");
+ _write_string(f, 1, "<description>");
+ _write_string(f, 1, "</description>");
+ _write_string(f, 1, "<methods>");
List<MethodInfo> method_list;
- ClassDB::get_method_list(name,&method_list,true);
+ ClassDB::get_method_list(name, &method_list, true);
method_list.sort();
-
- for(List<MethodInfo>::Element *E=method_list.front();E;E=E->next()) {
- if (E->get().name=="" || E->get().name[0]=='_')
+ for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
+ if (E->get().name == "" || E->get().name[0] == '_')
continue; //hiden
- MethodBind *m = ClassDB::get_method(name,E->get().name);
+ MethodBind *m = ClassDB::get_method(name, E->get().name);
String qualifiers;
- if (E->get().flags&METHOD_FLAG_CONST)
- qualifiers+="qualifiers=\"const\"";
+ if (E->get().flags & METHOD_FLAG_CONST)
+ qualifiers += "qualifiers=\"const\"";
- _write_string(f,2,"<method name=\""+_escape_string(E->get().name)+"\" "+qualifiers+" >");
+ _write_string(f, 2, "<method name=\"" + _escape_string(E->get().name) + "\" " + qualifiers + " >");
- for(int i=-1;i<E->get().arguments.size();i++) {
+ for (int i = -1; i < E->get().arguments.size(); i++) {
PropertyInfo arginfo;
- if (i==-1) {
+ if (i == -1) {
- arginfo=E->get().return_val;
- String type_name=(arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE)?arginfo.hint_string:Variant::get_type_name(arginfo.type);
+ arginfo = E->get().return_val;
+ String type_name = (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) ? arginfo.hint_string : Variant::get_type_name(arginfo.type);
- if (arginfo.type==Variant::NIL)
+ if (arginfo.type == Variant::NIL)
continue;
- _write_string(f,3,"<return type=\""+type_name+"\">");
+ _write_string(f, 3, "<return type=\"" + type_name + "\">");
} else {
-
- arginfo=E->get().arguments[i];
+ arginfo = E->get().arguments[i];
String type_name;
- if (arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE)
- type_name=arginfo.hint_string;
- else if (arginfo.type==Variant::NIL)
- type_name="var";
+ if (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE)
+ type_name = arginfo.hint_string;
+ else if (arginfo.type == Variant::NIL)
+ type_name = "var";
else
- type_name=Variant::get_type_name(arginfo.type);
+ type_name = Variant::get_type_name(arginfo.type);
if (m && m->has_default_argument(i)) {
- Variant default_arg=m->get_default_argument(i);
- String default_arg_text=String(_escape_string(m->get_default_argument(i)));
+ Variant default_arg = m->get_default_argument(i);
+ String default_arg_text = String(_escape_string(m->get_default_argument(i)));
- switch(default_arg.get_type()) {
+ switch (default_arg.get_type()) {
case Variant::NIL:
- default_arg_text="NULL";
+ default_arg_text = "NULL";
break;
// atomic types
case Variant::BOOL:
if (bool(default_arg))
- default_arg_text="true";
+ default_arg_text = "true";
else
- default_arg_text="false";
+ default_arg_text = "false";
break;
case Variant::INT:
case Variant::REAL:
//keep it
break;
- case Variant::STRING: // 15
- case Variant::NODE_PATH: // 15
- default_arg_text="\""+default_arg_text+"\"";
+ case Variant::STRING: // 15
+ case Variant::NODE_PATH: // 15
+ default_arg_text = "\"" + default_arg_text + "\"";
break;
case Variant::TRANSFORM:
- if (default_arg.operator Transform()==Transform()) {
- default_arg_text="";
+ if (default_arg.operator Transform() == Transform()) {
+ default_arg_text = "";
}
- default_arg_text=Variant::get_type_name(default_arg.get_type())+"("+default_arg_text+")";
+ default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")";
break;
- case Variant::VECTOR2: // 5
+ case Variant::VECTOR2: // 5
case Variant::RECT2:
case Variant::VECTOR3:
case Variant::PLANE:
@@ -194,89 +187,90 @@ void DocDump::dump(const String& p_file) {
case Variant::POOL_BYTE_ARRAY:
case Variant::POOL_INT_ARRAY:
case Variant::POOL_REAL_ARRAY:
- case Variant::POOL_STRING_ARRAY: //25
+ case Variant::POOL_STRING_ARRAY: //25
case Variant::POOL_VECTOR3_ARRAY:
case Variant::POOL_COLOR_ARRAY:
- default_arg_text=Variant::get_type_name(default_arg.get_type())+"("+default_arg_text+")";
+ default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")";
break;
case Variant::OBJECT:
case Variant::INPUT_EVENT:
- case Variant::DICTIONARY: // 20
+ case Variant::DICTIONARY: // 20
case Variant::ARRAY:
case Variant::_RID:
case Variant::IMAGE:
- //case Variant::RESOURCE:
+ //case Variant::RESOURCE:
- default_arg_text=Variant::get_type_name(default_arg.get_type())+"()";
+ default_arg_text = Variant::get_type_name(default_arg.get_type()) + "()";
break;
default: {}
-
}
-
-
-
- _write_string(f,3,"<argument index=\""+itos(i)+"\" name=\""+_escape_string(arginfo.name)+"\" type=\""+type_name+"\" default=\""+_escape_string(default_arg_text)+"\">");
+ _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + _escape_string(arginfo.name) + "\" type=\"" + type_name + "\" default=\"" + _escape_string(default_arg_text) + "\">");
} else
- _write_string(f,3,"<argument index=\""+itos(i)+"\" name=\""+arginfo.name+"\" type=\""+type_name+"\">");
+ _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + arginfo.name + "\" type=\"" + type_name + "\">");
}
-
String hint;
- switch(arginfo.hint) {
- case PROPERTY_HINT_DIR: hint="A directory."; break;
- case PROPERTY_HINT_RANGE: hint="Range - min: "+arginfo.hint_string.get_slice(",",0)+" max: "+arginfo.hint_string.get_slice(",",1)+" step: "+arginfo.hint_string.get_slice(",",2); break;
- case PROPERTY_HINT_ENUM: hint="Values: "; for(int j=0;j<arginfo.hint_string.get_slice_count(",");j++) { if (j>0) hint+=", "; hint+=arginfo.hint_string.get_slice(",",j)+"="+itos(j); } break;
- case PROPERTY_HINT_LENGTH: hint="Length: "+arginfo.hint_string; break;
- case PROPERTY_HINT_FLAGS: hint="Values: "; for(int j=0;j<arginfo.hint_string.get_slice_count(",");j++) { if (j>0) hint+=", "; hint+=arginfo.hint_string.get_slice(",",j)+"="+itos(1<<j); } break;
- case PROPERTY_HINT_FILE: hint="A file:"; break;
+ switch (arginfo.hint) {
+ case PROPERTY_HINT_DIR: hint = "A directory."; break;
+ case PROPERTY_HINT_RANGE: hint = "Range - min: " + arginfo.hint_string.get_slice(",", 0) + " max: " + arginfo.hint_string.get_slice(",", 1) + " step: " + arginfo.hint_string.get_slice(",", 2); break;
+ case PROPERTY_HINT_ENUM:
+ hint = "Values: ";
+ for (int j = 0; j < arginfo.hint_string.get_slice_count(","); j++) {
+ if (j > 0) hint += ", ";
+ hint += arginfo.hint_string.get_slice(",", j) + "=" + itos(j);
+ }
+ break;
+ case PROPERTY_HINT_LENGTH: hint = "Length: " + arginfo.hint_string; break;
+ case PROPERTY_HINT_FLAGS:
+ hint = "Values: ";
+ for (int j = 0; j < arginfo.hint_string.get_slice_count(","); j++) {
+ if (j > 0) hint += ", ";
+ hint += arginfo.hint_string.get_slice(",", j) + "=" + itos(1 << j);
+ }
+ break;
+ case PROPERTY_HINT_FILE: hint = "A file:"; break;
default: {}
- //case PROPERTY_HINT_RESOURCE_TYPE: hint="Type: "+arginfo.hint_string; break;
+ //case PROPERTY_HINT_RESOURCE_TYPE: hint="Type: "+arginfo.hint_string; break;
};
- if (hint!="")
- _write_string(f,4,hint);
-
- _write_string(f,3,(i==-1)?"</return>":"</argument>");
-
+ if (hint != "")
+ _write_string(f, 4, hint);
+ _write_string(f, 3, (i == -1) ? "</return>" : "</argument>");
}
- _write_string(f,3,"<description>");
- _write_string(f,3,"</description>");
-
- _write_string(f,2,"</method>");
+ _write_string(f, 3, "<description>");
+ _write_string(f, 3, "</description>");
+ _write_string(f, 2, "</method>");
}
-
- _write_string(f,1,"</methods>");
+ _write_string(f, 1, "</methods>");
List<MethodInfo> signal_list;
- ClassDB::get_signal_list(name,&signal_list,true);
+ ClassDB::get_signal_list(name, &signal_list, true);
if (signal_list.size()) {
- _write_string(f,1,"<signals>");
- for(List<MethodInfo>::Element *EV=signal_list.front();EV;EV=EV->next()) {
+ _write_string(f, 1, "<signals>");
+ for (List<MethodInfo>::Element *EV = signal_list.front(); EV; EV = EV->next()) {
- _write_string(f,2,"<signal name=\""+EV->get().name+"\">");
- for(int i=0;i<EV->get().arguments.size();i++) {
- PropertyInfo arginfo=EV->get().arguments[i];
- _write_string(f,3,"<argument index=\""+itos(i)+"\" name=\""+arginfo.name+"\" type=\""+Variant::get_type_name(arginfo.type)+"\">");
- _write_string(f,3,"</argument>");
+ _write_string(f, 2, "<signal name=\"" + EV->get().name + "\">");
+ for (int i = 0; i < EV->get().arguments.size(); i++) {
+ PropertyInfo arginfo = EV->get().arguments[i];
+ _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + arginfo.name + "\" type=\"" + Variant::get_type_name(arginfo.type) + "\">");
+ _write_string(f, 3, "</argument>");
}
- _write_string(f,3,"<description>");
- _write_string(f,3,"</description>");
+ _write_string(f, 3, "<description>");
+ _write_string(f, 3, "</description>");
- _write_string(f,2,"</signal>");
+ _write_string(f, 2, "</signal>");
}
- _write_string(f,1,"</signals>");
+ _write_string(f, 1, "</signals>");
}
-
- _write_string(f,1,"<constants>");
-
+ _write_string(f, 1, "<constants>");
List<String> constant_list;
ClassDB::get_integer_constant_list(name, &constant_list, true);
@@ -285,29 +279,28 @@ void DocDump::dump(const String& p_file) {
List<_ConstantSort> constant_sort;
- for(List<String>::Element *E=constant_list.front();E;E=E->next()) {
+ for (List<String>::Element *E = constant_list.front(); E; E = E->next()) {
_ConstantSort cs;
- cs.name=E->get();
- cs.value=ClassDB::get_integer_constant(name, E->get());
+ cs.name = E->get();
+ cs.value = ClassDB::get_integer_constant(name, E->get());
constant_sort.push_back(cs);
}
constant_sort.sort();
- for(List<_ConstantSort>::Element *E=constant_sort.front();E;E=E->next()) {
+ for (List<_ConstantSort>::Element *E = constant_sort.front(); E; E = E->next()) {
- _write_string(f,2,"<constant name=\""+E->get().name+"\" value=\""+itos(E->get().value)+"\">");
- _write_string(f,2,"</constant>");
+ _write_string(f, 2, "<constant name=\"" + E->get().name + "\" value=\"" + itos(E->get().value) + "\">");
+ _write_string(f, 2, "</constant>");
}
- _write_string(f,1,"</constants>");
- _write_string(f,0,"</class>");
+ _write_string(f, 1, "</constants>");
+ _write_string(f, 0, "</class>");
class_list.erase(name);
}
- _write_string(f,0,"</doc>");
+ _write_string(f, 0, "</doc>");
f->close();
memdelete(f);
-
}
diff --git a/editor/doc/doc_dump.h b/editor/doc/doc_dump.h
index 84629b89c8..6d6782788f 100644
--- a/editor/doc/doc_dump.h
+++ b/editor/doc/doc_dump.h
@@ -33,9 +33,7 @@
class DocDump {
public:
-
- static void dump(const String& p_file);
-
+ static void dump(const String &p_file);
};
#endif // DOC_DUMP_H
diff --git a/editor/doc_code_font.h b/editor/doc_code_font.h
index 55f335ab78..e3874214f5 100644
--- a/editor/doc_code_font.h
+++ b/editor/doc_code_font.h
@@ -26,7 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-static const int _bi_font_doc_code_font_height=19;
-static const int _bi_font_doc_code_font_ascent=15;
-static const int _bi_font_doc_code_font_charcount=193;
-static const int _bi_font_doc_code_font_characters[]={0, 253, 53, 2, 2, -1, 14, 0, 13, 253, 56, 2, 2, -1, 14, 0, 32, 253, 59, 2, 2, -1, 14, 4, 33, 221, 29, 3, 12, 1, 3, 5, 34, 144, 77, 6, 5, 0, 3, 7, 35, 180, 55, 9, 11, -1, 4, 8, 36, 215, 0, 8, 15, 0, 2, 8, 37, 28, 45, 12, 11, -1, 4, 12, 38, 199, 16, 11, 12, 0, 3, 11, 39, 157, 77, 3, 5, 0, 3, 4, 40, 36, 16, 4, 15, 0, 3, 5, 41, 31, 16, 4, 15, 0, 3, 5, 42, 93, 79, 9, 7, -1, 3, 8, 43, 110, 68, 9, 9, -1, 5, 8, 44, 121, 78, 4, 6, -1, 12, 4, 45, 204, 76, 5, 3, -1, 9, 5, 46, 216, 75, 4, 3, 0, 12, 4, 47, 233, 0, 8, 15, -1, 2, 7, 48, 246, 29, 9, 11, -1, 4, 8, 49, 208, 54, 8, 11, 0, 4, 8, 50, 219, 42, 9, 11, -1, 4, 8, 51, 229, 41, 9, 11, -1, 4, 8, 52, 239, 41, 9, 11, -1, 4, 8, 53, 0, 57, 9, 11, -1, 4, 8, 54, 160, 55, 9, 11, -1, 4, 8, 55, 10, 57, 9, 11, -1, 4, 8, 56, 20, 57, 9, 11, -1, 4, 8, 57, 40, 57, 9, 11, -1, 4, 8, 58, 78, 80, 3, 8, 0, 7, 4, 59, 72, 68, 4, 11, -1, 7, 4, 60, 18, 69, 8, 11, 0, 4, 8, 61, 112, 78, 8, 7, 0, 6, 8, 62, 0, 69, 8, 11, 0, 4, 8, 63, 184, 30, 7, 12, 0, 3, 7, 64, 148, 16, 13, 13, 0, 4, 14, 65, 117, 44, 11, 11, -1, 4, 10, 66, 50, 57, 9, 11, 0, 4, 9, 67, 197, 42, 10, 11, -1, 4, 8, 68, 153, 43, 10, 11, 0, 4, 10, 69, 244, 53, 8, 11, 0, 4, 8, 70, 43, 69, 7, 11, 0, 4, 7, 71, 93, 44, 11, 11, -1, 4, 10, 72, 60, 56, 9, 11, 0, 4, 10, 73, 77, 68, 4, 11, 0, 4, 4, 74, 249, 41, 6, 11, -1, 4, 5, 75, 70, 56, 9, 11, 0, 4, 9, 76, 27, 69, 7, 11, 0, 4, 7, 77, 14, 45, 13, 11, 0, 4, 14, 78, 208, 42, 10, 11, 0, 4, 11, 79, 41, 45, 12, 11, -1, 4, 11, 80, 199, 54, 8, 11, 0, 4, 9, 81, 162, 16, 13, 13, -1, 4, 11, 82, 80, 56, 9, 11, 0, 4, 9, 83, 90, 56, 9, 11, -1, 4, 8, 84, 100, 56, 9, 11, -1, 4, 8, 85, 164, 43, 10, 11, 0, 4, 10, 86, 129, 44, 11, 11, -1, 4, 9, 87, 229, 29, 16, 11, -1, 4, 15, 88, 175, 43, 10, 11, -1, 4, 9, 89, 186, 43, 10, 11, -1, 4, 8, 90, 110, 56, 9, 11, -1, 4, 8, 91, 26, 16, 4, 15, 0, 3, 5, 92, 123, 0, 10, 15, -2, 2, 7, 93, 251, 0, 4, 15, 0, 3, 5, 94, 82, 79, 10, 7, -2, 4, 8, 95, 180, 76, 9, 3, -1, 15, 8, 96, 161, 77, 6, 4, -1, 3, 5, 97, 27, 81, 8, 8, -1, 7, 8, 98, 68, 31, 8, 12, 0, 3, 9, 99, 18, 81, 8, 8, -1, 7, 7, 100, 211, 16, 9, 12, -1, 3, 9, 101, 228, 66, 9, 8, -1, 7, 8, 102, 176, 30, 7, 12, -1, 3, 5, 103, 120, 56, 9, 11, -1, 7, 8, 104, 59, 31, 8, 12, 0, 3, 9, 105, 66, 68, 5, 11, -1, 4, 4, 106, 141, 16, 6, 14, -2, 4, 4, 107, 104, 31, 8, 12, 0, 3, 8, 108, 251, 16, 3, 12, 0, 3, 4, 109, 144, 68, 13, 8, 0, 7, 13, 110, 9, 81, 8, 8, 0, 7, 9, 111, 208, 66, 9, 8, -1, 7, 9, 112, 217, 54, 8, 11, 0, 7, 9, 113, 140, 56, 9, 11, -1, 7, 9, 114, 53, 81, 6, 8, 0, 7, 6, 115, 45, 81, 7, 8, -1, 7, 6, 116, 102, 68, 7, 10, -1, 5, 6, 117, 36, 81, 8, 8, 0, 7, 9, 118, 238, 65, 9, 8, -1, 7, 8, 119, 158, 68, 13, 8, -1, 7, 12, 120, 218, 66, 9, 8, -1, 7, 7, 121, 150, 56, 9, 11, -1, 7, 8, 122, 248, 65, 7, 8, -1, 7, 6, 123, 14, 16, 5, 15, 0, 3, 6, 124, 41, 16, 3, 15, 2, 3, 8, 125, 20, 16, 5, 15, 0, 3, 6, 126, 135, 78, 8, 5, -1, 4, 8, 160, 253, 62, 2, 2, -1, 14, 4, 161, 225, 29, 3, 12, 0, 5, 5, 162, 35, 69, 7, 11, 0, 4, 8, 163, 190, 55, 8, 11, 0, 4, 8, 164, 82, 68, 9, 10, -1, 5, 8, 165, 105, 44, 11, 11, -2, 4, 8, 166, 45, 16, 3, 15, 2, 3, 8, 167, 125, 16, 8, 14, 0, 3, 8, 168, 197, 76, 6, 3, 0, 4, 7, 169, 186, 16, 12, 12, 0, 3, 13, 170, 137, 68, 6, 9, 0, 4, 7, 171, 197, 67, 10, 8, -1, 6, 9, 172, 126, 78, 8, 5, -1, 8, 8, 173, 210, 75, 5, 3, -1, 9, 5, 174, 103, 79, 8, 7, 0, 3, 8, 175, 190, 76, 6, 3, 0, 4, 6, 176, 151, 77, 5, 5, 0, 3, 5, 177, 221, 16, 9, 12, -1, 3, 8, 178, 60, 81, 6, 8, -1, 2, 5, 179, 67, 80, 5, 8, -1, 2, 5, 180, 168, 77, 6, 4, -1, 3, 5, 181, 170, 55, 9, 11, 0, 7, 9, 182, 176, 16, 9, 13, 0, 4, 10, 183, 221, 75, 3, 3, 0, 9, 4, 184, 175, 76, 4, 4, 0, 14, 5, 185, 73, 80, 4, 8, 0, 2, 4, 186, 129, 68, 7, 9, 0, 4, 7, 187, 185, 67, 11, 8, -1, 6, 9, 188, 54, 44, 12, 11, -2, 4, 11, 189, 67, 44, 12, 11, -2, 4, 11, 190, 80, 44, 12, 11, -1, 4, 11, 191, 192, 29, 7, 12, -1, 5, 7, 192, 88, 0, 11, 15, -1, 0, 10, 193, 64, 0, 11, 15, -1, 0, 10, 194, 76, 0, 11, 15, -1, 0, 10, 195, 100, 0, 11, 15, -1, 0, 10, 196, 74, 16, 11, 14, -1, 1, 10, 197, 62, 16, 11, 14, -1, 1, 10, 198, 0, 45, 13, 11, -1, 4, 12, 199, 107, 16, 8, 14, 0, 4, 8, 200, 188, 0, 8, 15, 0, 0, 8, 201, 206, 0, 8, 15, 0, 0, 8, 202, 224, 0, 8, 15, 0, 0, 8, 203, 116, 16, 8, 14, 0, 1, 8, 204, 0, 16, 6, 15, -2, 0, 4, 205, 7, 16, 6, 15, -1, 0, 4, 206, 242, 0, 8, 15, -2, 0, 4, 207, 134, 16, 6, 14, -1, 1, 4, 208, 141, 44, 11, 11, -1, 4, 10, 209, 145, 0, 10, 15, 0, 0, 11, 210, 0, 0, 12, 15, -1, 0, 11, 211, 39, 0, 12, 15, -1, 0, 11, 212, 26, 0, 12, 15, -1, 0, 11, 213, 13, 0, 12, 15, -1, 0, 11, 214, 49, 16, 12, 14, -1, 1, 11, 215, 0, 81, 8, 8, 0, 6, 8, 216, 52, 0, 11, 15, 0, 2, 11, 217, 167, 0, 10, 15, 0, 0, 10, 218, 134, 0, 10, 15, 0, 0, 10, 219, 156, 0, 10, 15, 0, 0, 10, 220, 86, 16, 10, 14, 0, 1, 10, 221, 112, 0, 10, 15, -1, 0, 8, 222, 226, 54, 8, 11, 0, 4, 9, 223, 77, 31, 8, 12, 0, 3, 9, 224, 113, 31, 8, 12, -1, 3, 8, 225, 122, 31, 8, 12, -1, 3, 8, 226, 131, 31, 8, 12, -1, 3, 8, 227, 167, 30, 8, 12, -1, 3, 8, 228, 235, 53, 8, 11, -1, 4, 8, 229, 50, 31, 8, 12, -1, 3, 8, 230, 172, 67, 12, 8, 0, 7, 12, 231, 51, 69, 7, 11, 0, 7, 7, 232, 40, 32, 9, 12, -1, 3, 8, 233, 231, 16, 9, 12, -1, 3, 8, 234, 241, 16, 9, 12, -1, 3, 8, 235, 30, 57, 9, 11, -1, 4, 8, 236, 200, 29, 6, 12, -2, 3, 4, 237, 214, 29, 6, 12, -1, 3, 4, 238, 207, 29, 6, 12, -1, 3, 4, 239, 59, 69, 6, 11, -1, 4, 4, 240, 86, 31, 8, 12, 0, 3, 9, 241, 95, 31, 8, 12, 0, 3, 9, 242, 0, 32, 9, 12, -1, 3, 9, 243, 10, 32, 9, 12, -1, 3, 9, 244, 20, 32, 9, 12, -1, 3, 9, 245, 30, 32, 9, 12, -1, 3, 9, 246, 130, 56, 9, 11, -1, 4, 9, 247, 120, 68, 8, 9, -1, 5, 8, 248, 92, 68, 9, 10, 0, 6, 9, 249, 140, 31, 8, 12, 0, 3, 9, 250, 149, 30, 8, 12, 0, 3, 9, 251, 158, 30, 8, 12, 0, 3, 9, 252, 9, 69, 8, 11, 0, 4, 9, 253, 178, 0, 9, 15, -1, 3, 8, 254, 197, 0, 8, 15, 0, 3, 9, 255, 97, 16, 9, 14, -1, 4, 8};
+static const int _bi_font_doc_code_font_height = 19;
+static const int _bi_font_doc_code_font_ascent = 15;
+static const int _bi_font_doc_code_font_charcount = 193;
+static const int _bi_font_doc_code_font_characters[] = { 0, 253, 53, 2, 2, -1, 14, 0, 13, 253, 56, 2, 2, -1, 14, 0, 32, 253, 59, 2, 2, -1, 14, 4, 33, 221, 29, 3, 12, 1, 3, 5, 34, 144, 77, 6, 5, 0, 3, 7, 35, 180, 55, 9, 11, -1, 4, 8, 36, 215, 0, 8, 15, 0, 2, 8, 37, 28, 45, 12, 11, -1, 4, 12, 38, 199, 16, 11, 12, 0, 3, 11, 39, 157, 77, 3, 5, 0, 3, 4, 40, 36, 16, 4, 15, 0, 3, 5, 41, 31, 16, 4, 15, 0, 3, 5, 42, 93, 79, 9, 7, -1, 3, 8, 43, 110, 68, 9, 9, -1, 5, 8, 44, 121, 78, 4, 6, -1, 12, 4, 45, 204, 76, 5, 3, -1, 9, 5, 46, 216, 75, 4, 3, 0, 12, 4, 47, 233, 0, 8, 15, -1, 2, 7, 48, 246, 29, 9, 11, -1, 4, 8, 49, 208, 54, 8, 11, 0, 4, 8, 50, 219, 42, 9, 11, -1, 4, 8, 51, 229, 41, 9, 11, -1, 4, 8, 52, 239, 41, 9, 11, -1, 4, 8, 53, 0, 57, 9, 11, -1, 4, 8, 54, 160, 55, 9, 11, -1, 4, 8, 55, 10, 57, 9, 11, -1, 4, 8, 56, 20, 57, 9, 11, -1, 4, 8, 57, 40, 57, 9, 11, -1, 4, 8, 58, 78, 80, 3, 8, 0, 7, 4, 59, 72, 68, 4, 11, -1, 7, 4, 60, 18, 69, 8, 11, 0, 4, 8, 61, 112, 78, 8, 7, 0, 6, 8, 62, 0, 69, 8, 11, 0, 4, 8, 63, 184, 30, 7, 12, 0, 3, 7, 64, 148, 16, 13, 13, 0, 4, 14, 65, 117, 44, 11, 11, -1, 4, 10, 66, 50, 57, 9, 11, 0, 4, 9, 67, 197, 42, 10, 11, -1, 4, 8, 68, 153, 43, 10, 11, 0, 4, 10, 69, 244, 53, 8, 11, 0, 4, 8, 70, 43, 69, 7, 11, 0, 4, 7, 71, 93, 44, 11, 11, -1, 4, 10, 72, 60, 56, 9, 11, 0, 4, 10, 73, 77, 68, 4, 11, 0, 4, 4, 74, 249, 41, 6, 11, -1, 4, 5, 75, 70, 56, 9, 11, 0, 4, 9, 76, 27, 69, 7, 11, 0, 4, 7, 77, 14, 45, 13, 11, 0, 4, 14, 78, 208, 42, 10, 11, 0, 4, 11, 79, 41, 45, 12, 11, -1, 4, 11, 80, 199, 54, 8, 11, 0, 4, 9, 81, 162, 16, 13, 13, -1, 4, 11, 82, 80, 56, 9, 11, 0, 4, 9, 83, 90, 56, 9, 11, -1, 4, 8, 84, 100, 56, 9, 11, -1, 4, 8, 85, 164, 43, 10, 11, 0, 4, 10, 86, 129, 44, 11, 11, -1, 4, 9, 87, 229, 29, 16, 11, -1, 4, 15, 88, 175, 43, 10, 11, -1, 4, 9, 89, 186, 43, 10, 11, -1, 4, 8, 90, 110, 56, 9, 11, -1, 4, 8, 91, 26, 16, 4, 15, 0, 3, 5, 92, 123, 0, 10, 15, -2, 2, 7, 93, 251, 0, 4, 15, 0, 3, 5, 94, 82, 79, 10, 7, -2, 4, 8, 95, 180, 76, 9, 3, -1, 15, 8, 96, 161, 77, 6, 4, -1, 3, 5, 97, 27, 81, 8, 8, -1, 7, 8, 98, 68, 31, 8, 12, 0, 3, 9, 99, 18, 81, 8, 8, -1, 7, 7, 100, 211, 16, 9, 12, -1, 3, 9, 101, 228, 66, 9, 8, -1, 7, 8, 102, 176, 30, 7, 12, -1, 3, 5, 103, 120, 56, 9, 11, -1, 7, 8, 104, 59, 31, 8, 12, 0, 3, 9, 105, 66, 68, 5, 11, -1, 4, 4, 106, 141, 16, 6, 14, -2, 4, 4, 107, 104, 31, 8, 12, 0, 3, 8, 108, 251, 16, 3, 12, 0, 3, 4, 109, 144, 68, 13, 8, 0, 7, 13, 110, 9, 81, 8, 8, 0, 7, 9, 111, 208, 66, 9, 8, -1, 7, 9, 112, 217, 54, 8, 11, 0, 7, 9, 113, 140, 56, 9, 11, -1, 7, 9, 114, 53, 81, 6, 8, 0, 7, 6, 115, 45, 81, 7, 8, -1, 7, 6, 116, 102, 68, 7, 10, -1, 5, 6, 117, 36, 81, 8, 8, 0, 7, 9, 118, 238, 65, 9, 8, -1, 7, 8, 119, 158, 68, 13, 8, -1, 7, 12, 120, 218, 66, 9, 8, -1, 7, 7, 121, 150, 56, 9, 11, -1, 7, 8, 122, 248, 65, 7, 8, -1, 7, 6, 123, 14, 16, 5, 15, 0, 3, 6, 124, 41, 16, 3, 15, 2, 3, 8, 125, 20, 16, 5, 15, 0, 3, 6, 126, 135, 78, 8, 5, -1, 4, 8, 160, 253, 62, 2, 2, -1, 14, 4, 161, 225, 29, 3, 12, 0, 5, 5, 162, 35, 69, 7, 11, 0, 4, 8, 163, 190, 55, 8, 11, 0, 4, 8, 164, 82, 68, 9, 10, -1, 5, 8, 165, 105, 44, 11, 11, -2, 4, 8, 166, 45, 16, 3, 15, 2, 3, 8, 167, 125, 16, 8, 14, 0, 3, 8, 168, 197, 76, 6, 3, 0, 4, 7, 169, 186, 16, 12, 12, 0, 3, 13, 170, 137, 68, 6, 9, 0, 4, 7, 171, 197, 67, 10, 8, -1, 6, 9, 172, 126, 78, 8, 5, -1, 8, 8, 173, 210, 75, 5, 3, -1, 9, 5, 174, 103, 79, 8, 7, 0, 3, 8, 175, 190, 76, 6, 3, 0, 4, 6, 176, 151, 77, 5, 5, 0, 3, 5, 177, 221, 16, 9, 12, -1, 3, 8, 178, 60, 81, 6, 8, -1, 2, 5, 179, 67, 80, 5, 8, -1, 2, 5, 180, 168, 77, 6, 4, -1, 3, 5, 181, 170, 55, 9, 11, 0, 7, 9, 182, 176, 16, 9, 13, 0, 4, 10, 183, 221, 75, 3, 3, 0, 9, 4, 184, 175, 76, 4, 4, 0, 14, 5, 185, 73, 80, 4, 8, 0, 2, 4, 186, 129, 68, 7, 9, 0, 4, 7, 187, 185, 67, 11, 8, -1, 6, 9, 188, 54, 44, 12, 11, -2, 4, 11, 189, 67, 44, 12, 11, -2, 4, 11, 190, 80, 44, 12, 11, -1, 4, 11, 191, 192, 29, 7, 12, -1, 5, 7, 192, 88, 0, 11, 15, -1, 0, 10, 193, 64, 0, 11, 15, -1, 0, 10, 194, 76, 0, 11, 15, -1, 0, 10, 195, 100, 0, 11, 15, -1, 0, 10, 196, 74, 16, 11, 14, -1, 1, 10, 197, 62, 16, 11, 14, -1, 1, 10, 198, 0, 45, 13, 11, -1, 4, 12, 199, 107, 16, 8, 14, 0, 4, 8, 200, 188, 0, 8, 15, 0, 0, 8, 201, 206, 0, 8, 15, 0, 0, 8, 202, 224, 0, 8, 15, 0, 0, 8, 203, 116, 16, 8, 14, 0, 1, 8, 204, 0, 16, 6, 15, -2, 0, 4, 205, 7, 16, 6, 15, -1, 0, 4, 206, 242, 0, 8, 15, -2, 0, 4, 207, 134, 16, 6, 14, -1, 1, 4, 208, 141, 44, 11, 11, -1, 4, 10, 209, 145, 0, 10, 15, 0, 0, 11, 210, 0, 0, 12, 15, -1, 0, 11, 211, 39, 0, 12, 15, -1, 0, 11, 212, 26, 0, 12, 15, -1, 0, 11, 213, 13, 0, 12, 15, -1, 0, 11, 214, 49, 16, 12, 14, -1, 1, 11, 215, 0, 81, 8, 8, 0, 6, 8, 216, 52, 0, 11, 15, 0, 2, 11, 217, 167, 0, 10, 15, 0, 0, 10, 218, 134, 0, 10, 15, 0, 0, 10, 219, 156, 0, 10, 15, 0, 0, 10, 220, 86, 16, 10, 14, 0, 1, 10, 221, 112, 0, 10, 15, -1, 0, 8, 222, 226, 54, 8, 11, 0, 4, 9, 223, 77, 31, 8, 12, 0, 3, 9, 224, 113, 31, 8, 12, -1, 3, 8, 225, 122, 31, 8, 12, -1, 3, 8, 226, 131, 31, 8, 12, -1, 3, 8, 227, 167, 30, 8, 12, -1, 3, 8, 228, 235, 53, 8, 11, -1, 4, 8, 229, 50, 31, 8, 12, -1, 3, 8, 230, 172, 67, 12, 8, 0, 7, 12, 231, 51, 69, 7, 11, 0, 7, 7, 232, 40, 32, 9, 12, -1, 3, 8, 233, 231, 16, 9, 12, -1, 3, 8, 234, 241, 16, 9, 12, -1, 3, 8, 235, 30, 57, 9, 11, -1, 4, 8, 236, 200, 29, 6, 12, -2, 3, 4, 237, 214, 29, 6, 12, -1, 3, 4, 238, 207, 29, 6, 12, -1, 3, 4, 239, 59, 69, 6, 11, -1, 4, 4, 240, 86, 31, 8, 12, 0, 3, 9, 241, 95, 31, 8, 12, 0, 3, 9, 242, 0, 32, 9, 12, -1, 3, 9, 243, 10, 32, 9, 12, -1, 3, 9, 244, 20, 32, 9, 12, -1, 3, 9, 245, 30, 32, 9, 12, -1, 3, 9, 246, 130, 56, 9, 11, -1, 4, 9, 247, 120, 68, 8, 9, -1, 5, 8, 248, 92, 68, 9, 10, 0, 6, 9, 249, 140, 31, 8, 12, 0, 3, 9, 250, 149, 30, 8, 12, 0, 3, 9, 251, 158, 30, 8, 12, 0, 3, 9, 252, 9, 69, 8, 11, 0, 4, 9, 253, 178, 0, 9, 15, -1, 3, 8, 254, 197, 0, 8, 15, 0, 3, 9, 255, 97, 16, 9, 14, -1, 4, 8 };
diff --git a/editor/doc_font.h b/editor/doc_font.h
index b598ee26f8..c146f04cd8 100644
--- a/editor/doc_font.h
+++ b/editor/doc_font.h
@@ -26,7 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-static const int _bi_font_doc_font_height=18;
-static const int _bi_font_doc_font_ascent=14;
-static const int _bi_font_doc_font_charcount=193;
-static const int _bi_font_doc_font_characters[]={0, 253, 3, 2, 2, -1, 13, 0, 13, 253, 9, 2, 2, -1, 13, 0, 32, 253, 0, 2, 2, -1, 13, 3, 33, 220, 26, 3, 11, 1, 3, 5, 34, 187, 59, 5, 5, 0, 3, 6, 35, 88, 40, 9, 10, -1, 4, 7, 36, 50, 0, 8, 14, -1, 2, 7, 37, 175, 14, 11, 11, -1, 3, 11, 38, 187, 14, 11, 11, -1, 3, 10, 39, 198, 58, 3, 5, 0, 3, 3, 40, 98, 0, 4, 14, 0, 3, 5, 41, 103, 0, 4, 14, 0, 3, 5, 42, 146, 61, 7, 6, 0, 3, 7, 43, 246, 48, 8, 8, -1, 5, 7, 44, 193, 58, 4, 5, -1, 11, 4, 45, 13, 73, 5, 2, 0, 9, 5, 46, 241, 57, 3, 3, 0, 11, 4, 47, 84, 0, 7, 14, -1, 2, 6, 48, 246, 37, 8, 10, -1, 4, 7, 49, 33, 52, 7, 10, 0, 4, 7, 50, 237, 37, 8, 10, -1, 4, 7, 51, 219, 38, 8, 10, -1, 4, 7, 52, 128, 39, 9, 10, -1, 4, 7, 53, 41, 52, 7, 10, -1, 4, 7, 54, 9, 53, 7, 10, 0, 4, 7, 55, 228, 38, 8, 10, -1, 4, 7, 56, 57, 52, 7, 10, 0, 4, 7, 57, 65, 51, 7, 10, 0, 4, 7, 58, 98, 62, 4, 8, 0, 6, 4, 59, 162, 50, 5, 10, -1, 6, 4, 60, 174, 49, 8, 9, -1, 4, 7, 61, 179, 59, 7, 5, 0, 7, 7, 62, 228, 49, 8, 8, -1, 5, 7, 63, 89, 28, 7, 11, 0, 3, 7, 64, 54, 15, 12, 12, 0, 4, 13, 65, 36, 41, 10, 10, -1, 4, 9, 66, 97, 51, 7, 10, 0, 4, 8, 67, 174, 38, 8, 10, 0, 4, 8, 68, 156, 39, 8, 10, 0, 4, 9, 69, 105, 51, 7, 10, 0, 4, 7, 70, 121, 51, 6, 10, 0, 4, 7, 71, 0, 53, 8, 10, 0, 4, 9, 72, 192, 38, 8, 10, 0, 4, 9, 73, 251, 26, 3, 10, 0, 4, 4, 74, 156, 50, 5, 10, -1, 4, 5, 75, 147, 39, 8, 10, 0, 4, 8, 76, 135, 50, 6, 10, 0, 4, 6, 77, 13, 41, 11, 10, 0, 4, 12, 78, 210, 38, 8, 10, 0, 4, 10, 79, 68, 40, 9, 10, 0, 4, 10, 80, 113, 51, 7, 10, 0, 4, 8, 81, 199, 14, 10, 11, 0, 4, 10, 82, 183, 38, 8, 10, 0, 4, 8, 83, 128, 50, 6, 10, 0, 4, 7, 84, 108, 40, 9, 10, -1, 4, 7, 85, 165, 39, 8, 10, 0, 4, 9, 86, 25, 41, 10, 10, -1, 4, 9, 87, 236, 26, 14, 10, -1, 4, 13, 88, 98, 40, 9, 10, -1, 4, 8, 89, 118, 40, 9, 10, -1, 4, 7, 90, 138, 39, 8, 10, -1, 4, 7, 91, 49, 15, 4, 13, 0, 3, 5, 92, 76, 0, 7, 14, -1, 2, 6, 93, 43, 15, 5, 13, -1, 3, 5, 94, 137, 61, 8, 6, -1, 4, 7, 95, 245, 57, 9, 2, -1, 15, 7, 96, 230, 58, 5, 3, -1, 3, 4, 97, 57, 63, 7, 8, 0, 6, 7, 98, 81, 28, 7, 11, 0, 3, 8, 99, 79, 62, 6, 8, 0, 6, 6, 100, 33, 29, 7, 11, 0, 3, 8, 101, 9, 64, 7, 8, 0, 6, 8, 102, 200, 26, 6, 11, -1, 3, 5, 103, 153, 27, 7, 11, 0, 6, 7, 104, 121, 27, 7, 11, 0, 3, 8, 105, 224, 26, 3, 11, 0, 3, 4, 106, 92, 0, 5, 14, -2, 3, 4, 107, 25, 29, 7, 11, 0, 3, 7, 108, 228, 26, 3, 11, 0, 3, 4, 109, 204, 49, 11, 8, 0, 6, 12, 110, 17, 63, 7, 8, 0, 6, 8, 111, 33, 63, 7, 8, 0, 6, 8, 112, 17, 29, 7, 11, 0, 6, 8, 113, 9, 29, 7, 11, 0, 6, 8, 114, 86, 62, 5, 8, 0, 6, 5, 115, 92, 62, 5, 8, 0, 6, 6, 116, 168, 50, 5, 10, -1, 4, 5, 117, 49, 63, 7, 8, 0, 6, 8, 118, 0, 64, 8, 8, -1, 6, 7, 119, 216, 49, 11, 8, -1, 6, 10, 120, 41, 63, 7, 8, -1, 6, 7, 121, 0, 30, 8, 11, -1, 6, 7, 122, 72, 62, 6, 8, 0, 6, 6, 123, 8, 15, 6, 13, -1, 3, 5, 124, 0, 0, 3, 15, 1, 2, 7, 125, 15, 15, 6, 13, -1, 3, 5, 126, 202, 58, 8, 4, -1, 4, 7, 160, 253, 6, 2, 2, -1, 13, 3, 161, 232, 26, 3, 11, 0, 4, 5, 162, 149, 50, 6, 10, 0, 4, 7, 163, 17, 52, 7, 10, 0, 4, 7, 164, 183, 49, 8, 9, -1, 5, 7, 165, 47, 41, 10, 10, -2, 4, 7, 166, 4, 0, 3, 15, 2, 2, 7, 167, 122, 14, 7, 12, 0, 3, 7, 168, 0, 73, 6, 2, -1, 4, 6, 169, 162, 14, 12, 11, 0, 3, 13, 170, 65, 62, 6, 8, -1, 4, 6, 171, 112, 62, 8, 7, -1, 6, 8, 172, 211, 58, 7, 4, -1, 8, 7, 173, 19, 72, 5, 2, 0, 9, 5, 174, 103, 62, 8, 7, -1, 3, 8, 175, 7, 73, 5, 2, 0, 3, 6, 176, 171, 61, 7, 5, -1, 3, 5, 177, 58, 40, 9, 10, -1, 4, 7, 178, 154, 61, 5, 6, 0, 2, 5, 179, 160, 61, 5, 6, -1, 2, 5, 180, 224, 58, 5, 3, -1, 3, 4, 181, 241, 14, 8, 11, 0, 6, 8, 182, 97, 15, 8, 12, 0, 4, 9, 183, 236, 58, 4, 3, 0, 8, 4, 184, 219, 58, 4, 4, 0, 13, 5, 185, 166, 61, 4, 6, 0, 2, 4, 186, 25, 63, 7, 8, -1, 4, 6, 187, 129, 61, 7, 7, 0, 6, 8, 188, 221, 14, 9, 11, 0, 3, 10, 189, 231, 14, 9, 11, 0, 3, 10, 190, 210, 14, 10, 11, -1, 3, 10, 191, 41, 29, 7, 11, -1, 4, 7, 192, 141, 0, 10, 13, -1, 1, 9, 193, 130, 0, 10, 13, -1, 1, 9, 194, 119, 0, 10, 13, -1, 1, 9, 195, 20, 0, 10, 14, -1, 0, 9, 196, 67, 15, 10, 12, -1, 2, 9, 197, 108, 0, 10, 13, -1, 1, 9, 198, 0, 42, 12, 10, -1, 4, 11, 199, 228, 0, 8, 13, 0, 4, 8, 200, 245, 0, 7, 13, 0, 1, 7, 201, 237, 0, 7, 13, 0, 1, 7, 202, 0, 16, 7, 13, 0, 1, 7, 203, 130, 14, 7, 12, 0, 2, 7, 204, 36, 15, 6, 13, -2, 1, 4, 205, 22, 15, 6, 13, -1, 1, 4, 206, 29, 15, 6, 13, -1, 1, 4, 207, 154, 14, 7, 12, -2, 2, 4, 208, 78, 40, 9, 10, -1, 4, 9, 209, 59, 0, 8, 14, 0, 0, 10, 210, 172, 0, 9, 13, 0, 1, 10, 211, 152, 0, 9, 13, 0, 1, 10, 212, 182, 0, 9, 13, 0, 1, 10, 213, 31, 0, 9, 14, 0, 0, 10, 214, 78, 15, 9, 12, 0, 2, 10, 215, 121, 62, 7, 7, 0, 6, 7, 216, 8, 0, 11, 14, -1, 2, 10, 217, 192, 0, 8, 13, 0, 1, 9, 218, 210, 0, 8, 13, 0, 1, 9, 219, 201, 0, 8, 13, 0, 1, 9, 220, 88, 15, 8, 12, 0, 2, 9, 221, 162, 0, 9, 13, -1, 1, 7, 222, 81, 51, 7, 10, 0, 4, 8, 223, 49, 29, 7, 11, 0, 3, 8, 224, 57, 28, 7, 11, 0, 3, 7, 225, 65, 28, 7, 11, 0, 3, 7, 226, 73, 28, 7, 11, 0, 3, 7, 227, 138, 14, 7, 12, 0, 2, 7, 228, 25, 52, 7, 10, 0, 4, 7, 229, 146, 14, 7, 12, 0, 2, 7, 230, 192, 49, 11, 8, 0, 6, 12, 231, 207, 26, 6, 11, 0, 6, 6, 232, 97, 28, 7, 11, 0, 3, 8, 233, 105, 28, 7, 11, 0, 3, 8, 234, 113, 28, 7, 11, 0, 3, 8, 235, 73, 51, 7, 10, 0, 4, 8, 236, 214, 26, 5, 11, -2, 3, 3, 237, 250, 14, 5, 11, -1, 3, 3, 238, 193, 26, 6, 11, -2, 3, 3, 239, 142, 50, 6, 10, -2, 4, 3, 240, 185, 26, 7, 11, 0, 3, 8, 241, 106, 15, 7, 12, 0, 2, 8, 242, 129, 27, 7, 11, 0, 3, 8, 243, 137, 27, 7, 11, 0, 3, 8, 244, 145, 27, 7, 11, 0, 3, 8, 245, 114, 14, 7, 12, 0, 2, 8, 246, 49, 52, 7, 10, 0, 4, 8, 247, 237, 48, 8, 8, -1, 5, 7, 248, 201, 38, 8, 10, 0, 5, 8, 249, 161, 27, 7, 11, 0, 3, 8, 250, 169, 26, 7, 11, 0, 3, 8, 251, 177, 26, 7, 11, 0, 3, 8, 252, 89, 51, 7, 10, 0, 4, 8, 253, 41, 0, 8, 14, -1, 3, 7, 254, 68, 0, 7, 14, 0, 3, 8, 255, 219, 0, 8, 13, -1, 4, 7};
+static const int _bi_font_doc_font_height = 18;
+static const int _bi_font_doc_font_ascent = 14;
+static const int _bi_font_doc_font_charcount = 193;
+static const int _bi_font_doc_font_characters[] = { 0, 253, 3, 2, 2, -1, 13, 0, 13, 253, 9, 2, 2, -1, 13, 0, 32, 253, 0, 2, 2, -1, 13, 3, 33, 220, 26, 3, 11, 1, 3, 5, 34, 187, 59, 5, 5, 0, 3, 6, 35, 88, 40, 9, 10, -1, 4, 7, 36, 50, 0, 8, 14, -1, 2, 7, 37, 175, 14, 11, 11, -1, 3, 11, 38, 187, 14, 11, 11, -1, 3, 10, 39, 198, 58, 3, 5, 0, 3, 3, 40, 98, 0, 4, 14, 0, 3, 5, 41, 103, 0, 4, 14, 0, 3, 5, 42, 146, 61, 7, 6, 0, 3, 7, 43, 246, 48, 8, 8, -1, 5, 7, 44, 193, 58, 4, 5, -1, 11, 4, 45, 13, 73, 5, 2, 0, 9, 5, 46, 241, 57, 3, 3, 0, 11, 4, 47, 84, 0, 7, 14, -1, 2, 6, 48, 246, 37, 8, 10, -1, 4, 7, 49, 33, 52, 7, 10, 0, 4, 7, 50, 237, 37, 8, 10, -1, 4, 7, 51, 219, 38, 8, 10, -1, 4, 7, 52, 128, 39, 9, 10, -1, 4, 7, 53, 41, 52, 7, 10, -1, 4, 7, 54, 9, 53, 7, 10, 0, 4, 7, 55, 228, 38, 8, 10, -1, 4, 7, 56, 57, 52, 7, 10, 0, 4, 7, 57, 65, 51, 7, 10, 0, 4, 7, 58, 98, 62, 4, 8, 0, 6, 4, 59, 162, 50, 5, 10, -1, 6, 4, 60, 174, 49, 8, 9, -1, 4, 7, 61, 179, 59, 7, 5, 0, 7, 7, 62, 228, 49, 8, 8, -1, 5, 7, 63, 89, 28, 7, 11, 0, 3, 7, 64, 54, 15, 12, 12, 0, 4, 13, 65, 36, 41, 10, 10, -1, 4, 9, 66, 97, 51, 7, 10, 0, 4, 8, 67, 174, 38, 8, 10, 0, 4, 8, 68, 156, 39, 8, 10, 0, 4, 9, 69, 105, 51, 7, 10, 0, 4, 7, 70, 121, 51, 6, 10, 0, 4, 7, 71, 0, 53, 8, 10, 0, 4, 9, 72, 192, 38, 8, 10, 0, 4, 9, 73, 251, 26, 3, 10, 0, 4, 4, 74, 156, 50, 5, 10, -1, 4, 5, 75, 147, 39, 8, 10, 0, 4, 8, 76, 135, 50, 6, 10, 0, 4, 6, 77, 13, 41, 11, 10, 0, 4, 12, 78, 210, 38, 8, 10, 0, 4, 10, 79, 68, 40, 9, 10, 0, 4, 10, 80, 113, 51, 7, 10, 0, 4, 8, 81, 199, 14, 10, 11, 0, 4, 10, 82, 183, 38, 8, 10, 0, 4, 8, 83, 128, 50, 6, 10, 0, 4, 7, 84, 108, 40, 9, 10, -1, 4, 7, 85, 165, 39, 8, 10, 0, 4, 9, 86, 25, 41, 10, 10, -1, 4, 9, 87, 236, 26, 14, 10, -1, 4, 13, 88, 98, 40, 9, 10, -1, 4, 8, 89, 118, 40, 9, 10, -1, 4, 7, 90, 138, 39, 8, 10, -1, 4, 7, 91, 49, 15, 4, 13, 0, 3, 5, 92, 76, 0, 7, 14, -1, 2, 6, 93, 43, 15, 5, 13, -1, 3, 5, 94, 137, 61, 8, 6, -1, 4, 7, 95, 245, 57, 9, 2, -1, 15, 7, 96, 230, 58, 5, 3, -1, 3, 4, 97, 57, 63, 7, 8, 0, 6, 7, 98, 81, 28, 7, 11, 0, 3, 8, 99, 79, 62, 6, 8, 0, 6, 6, 100, 33, 29, 7, 11, 0, 3, 8, 101, 9, 64, 7, 8, 0, 6, 8, 102, 200, 26, 6, 11, -1, 3, 5, 103, 153, 27, 7, 11, 0, 6, 7, 104, 121, 27, 7, 11, 0, 3, 8, 105, 224, 26, 3, 11, 0, 3, 4, 106, 92, 0, 5, 14, -2, 3, 4, 107, 25, 29, 7, 11, 0, 3, 7, 108, 228, 26, 3, 11, 0, 3, 4, 109, 204, 49, 11, 8, 0, 6, 12, 110, 17, 63, 7, 8, 0, 6, 8, 111, 33, 63, 7, 8, 0, 6, 8, 112, 17, 29, 7, 11, 0, 6, 8, 113, 9, 29, 7, 11, 0, 6, 8, 114, 86, 62, 5, 8, 0, 6, 5, 115, 92, 62, 5, 8, 0, 6, 6, 116, 168, 50, 5, 10, -1, 4, 5, 117, 49, 63, 7, 8, 0, 6, 8, 118, 0, 64, 8, 8, -1, 6, 7, 119, 216, 49, 11, 8, -1, 6, 10, 120, 41, 63, 7, 8, -1, 6, 7, 121, 0, 30, 8, 11, -1, 6, 7, 122, 72, 62, 6, 8, 0, 6, 6, 123, 8, 15, 6, 13, -1, 3, 5, 124, 0, 0, 3, 15, 1, 2, 7, 125, 15, 15, 6, 13, -1, 3, 5, 126, 202, 58, 8, 4, -1, 4, 7, 160, 253, 6, 2, 2, -1, 13, 3, 161, 232, 26, 3, 11, 0, 4, 5, 162, 149, 50, 6, 10, 0, 4, 7, 163, 17, 52, 7, 10, 0, 4, 7, 164, 183, 49, 8, 9, -1, 5, 7, 165, 47, 41, 10, 10, -2, 4, 7, 166, 4, 0, 3, 15, 2, 2, 7, 167, 122, 14, 7, 12, 0, 3, 7, 168, 0, 73, 6, 2, -1, 4, 6, 169, 162, 14, 12, 11, 0, 3, 13, 170, 65, 62, 6, 8, -1, 4, 6, 171, 112, 62, 8, 7, -1, 6, 8, 172, 211, 58, 7, 4, -1, 8, 7, 173, 19, 72, 5, 2, 0, 9, 5, 174, 103, 62, 8, 7, -1, 3, 8, 175, 7, 73, 5, 2, 0, 3, 6, 176, 171, 61, 7, 5, -1, 3, 5, 177, 58, 40, 9, 10, -1, 4, 7, 178, 154, 61, 5, 6, 0, 2, 5, 179, 160, 61, 5, 6, -1, 2, 5, 180, 224, 58, 5, 3, -1, 3, 4, 181, 241, 14, 8, 11, 0, 6, 8, 182, 97, 15, 8, 12, 0, 4, 9, 183, 236, 58, 4, 3, 0, 8, 4, 184, 219, 58, 4, 4, 0, 13, 5, 185, 166, 61, 4, 6, 0, 2, 4, 186, 25, 63, 7, 8, -1, 4, 6, 187, 129, 61, 7, 7, 0, 6, 8, 188, 221, 14, 9, 11, 0, 3, 10, 189, 231, 14, 9, 11, 0, 3, 10, 190, 210, 14, 10, 11, -1, 3, 10, 191, 41, 29, 7, 11, -1, 4, 7, 192, 141, 0, 10, 13, -1, 1, 9, 193, 130, 0, 10, 13, -1, 1, 9, 194, 119, 0, 10, 13, -1, 1, 9, 195, 20, 0, 10, 14, -1, 0, 9, 196, 67, 15, 10, 12, -1, 2, 9, 197, 108, 0, 10, 13, -1, 1, 9, 198, 0, 42, 12, 10, -1, 4, 11, 199, 228, 0, 8, 13, 0, 4, 8, 200, 245, 0, 7, 13, 0, 1, 7, 201, 237, 0, 7, 13, 0, 1, 7, 202, 0, 16, 7, 13, 0, 1, 7, 203, 130, 14, 7, 12, 0, 2, 7, 204, 36, 15, 6, 13, -2, 1, 4, 205, 22, 15, 6, 13, -1, 1, 4, 206, 29, 15, 6, 13, -1, 1, 4, 207, 154, 14, 7, 12, -2, 2, 4, 208, 78, 40, 9, 10, -1, 4, 9, 209, 59, 0, 8, 14, 0, 0, 10, 210, 172, 0, 9, 13, 0, 1, 10, 211, 152, 0, 9, 13, 0, 1, 10, 212, 182, 0, 9, 13, 0, 1, 10, 213, 31, 0, 9, 14, 0, 0, 10, 214, 78, 15, 9, 12, 0, 2, 10, 215, 121, 62, 7, 7, 0, 6, 7, 216, 8, 0, 11, 14, -1, 2, 10, 217, 192, 0, 8, 13, 0, 1, 9, 218, 210, 0, 8, 13, 0, 1, 9, 219, 201, 0, 8, 13, 0, 1, 9, 220, 88, 15, 8, 12, 0, 2, 9, 221, 162, 0, 9, 13, -1, 1, 7, 222, 81, 51, 7, 10, 0, 4, 8, 223, 49, 29, 7, 11, 0, 3, 8, 224, 57, 28, 7, 11, 0, 3, 7, 225, 65, 28, 7, 11, 0, 3, 7, 226, 73, 28, 7, 11, 0, 3, 7, 227, 138, 14, 7, 12, 0, 2, 7, 228, 25, 52, 7, 10, 0, 4, 7, 229, 146, 14, 7, 12, 0, 2, 7, 230, 192, 49, 11, 8, 0, 6, 12, 231, 207, 26, 6, 11, 0, 6, 6, 232, 97, 28, 7, 11, 0, 3, 8, 233, 105, 28, 7, 11, 0, 3, 8, 234, 113, 28, 7, 11, 0, 3, 8, 235, 73, 51, 7, 10, 0, 4, 8, 236, 214, 26, 5, 11, -2, 3, 3, 237, 250, 14, 5, 11, -1, 3, 3, 238, 193, 26, 6, 11, -2, 3, 3, 239, 142, 50, 6, 10, -2, 4, 3, 240, 185, 26, 7, 11, 0, 3, 8, 241, 106, 15, 7, 12, 0, 2, 8, 242, 129, 27, 7, 11, 0, 3, 8, 243, 137, 27, 7, 11, 0, 3, 8, 244, 145, 27, 7, 11, 0, 3, 8, 245, 114, 14, 7, 12, 0, 2, 8, 246, 49, 52, 7, 10, 0, 4, 8, 247, 237, 48, 8, 8, -1, 5, 7, 248, 201, 38, 8, 10, 0, 5, 8, 249, 161, 27, 7, 11, 0, 3, 8, 250, 169, 26, 7, 11, 0, 3, 8, 251, 177, 26, 7, 11, 0, 3, 8, 252, 89, 51, 7, 10, 0, 4, 8, 253, 41, 0, 8, 14, -1, 3, 7, 254, 68, 0, 7, 14, 0, 3, 8, 255, 219, 0, 8, 13, -1, 4, 7 };
diff --git a/editor/doc_title_font.h b/editor/doc_title_font.h
index afa0f61eda..bb8a394807 100644
--- a/editor/doc_title_font.h
+++ b/editor/doc_title_font.h
@@ -26,7 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-static const int _bi_font_doc_title_font_height=22;
-static const int _bi_font_doc_title_font_ascent=17;
-static const int _bi_font_doc_title_font_charcount=193;
-static const int _bi_font_doc_title_font_characters[]={0, 108, 97, 2, 2, -1, 16, 0, 13, 111, 97, 2, 2, -1, 16, 0, 32, 252, 55, 2, 2, -1, 16, 4, 33, 84, 48, 3, 13, 1, 4, 6, 34, 9, 99, 6, 6, 0, 4, 8, 35, 52, 76, 9, 12, -1, 5, 9, 36, 31, 18, 9, 16, 0, 3, 9, 37, 28, 35, 13, 13, -1, 4, 13, 38, 56, 35, 12, 13, 0, 4, 13, 39, 16, 99, 3, 6, 0, 4, 4, 40, 48, 0, 5, 17, 0, 3, 6, 41, 54, 0, 5, 17, 0, 3, 6, 42, 207, 84, 9, 8, 0, 3, 9, 43, 121, 86, 9, 9, 0, 7, 9, 44, 251, 71, 4, 6, -1, 13, 5, 45, 102, 97, 5, 3, 0, 10, 6, 46, 66, 99, 4, 4, 0, 13, 5, 47, 24, 0, 9, 17, -2, 3, 8, 48, 11, 76, 10, 12, -1, 5, 9, 49, 102, 74, 9, 12, 0, 5, 9, 50, 48, 63, 10, 12, -1, 5, 9, 51, 59, 63, 10, 12, -1, 5, 9, 52, 70, 63, 10, 12, -1, 5, 9, 53, 81, 62, 10, 12, -1, 5, 9, 54, 235, 59, 10, 12, -1, 5, 9, 55, 103, 61, 10, 12, -1, 5, 9, 56, 114, 60, 10, 12, -1, 5, 9, 57, 125, 60, 10, 12, -1, 5, 9, 58, 252, 45, 3, 9, 0, 8, 5, 59, 246, 71, 4, 11, -1, 8, 5, 60, 148, 73, 8, 12, 0, 5, 9, 61, 0, 100, 8, 7, 0, 8, 9, 62, 139, 73, 8, 12, 0, 5, 9, 63, 40, 49, 8, 13, 0, 4, 8, 64, 184, 17, 15, 14, 0, 5, 16, 65, 178, 47, 12, 12, -1, 5, 11, 66, 136, 60, 10, 12, 0, 5, 10, 67, 240, 45, 11, 12, -1, 5, 10, 68, 0, 63, 11, 12, 0, 5, 11, 69, 130, 73, 8, 12, 0, 5, 9, 70, 112, 74, 8, 12, 0, 5, 8, 71, 191, 46, 12, 12, -1, 5, 11, 72, 24, 63, 11, 12, 0, 5, 11, 73, 193, 72, 4, 12, 0, 5, 5, 74, 173, 73, 6, 12, -1, 5, 6, 75, 147, 60, 10, 12, 0, 5, 10, 76, 121, 73, 8, 12, 0, 5, 8, 77, 122, 47, 15, 12, 0, 5, 16, 78, 12, 63, 11, 12, 0, 5, 12, 79, 138, 47, 13, 12, -1, 5, 12, 80, 62, 76, 9, 12, 0, 5, 10, 81, 200, 17, 14, 14, -1, 5, 12, 82, 158, 60, 10, 12, 0, 5, 10, 83, 32, 76, 9, 12, -1, 5, 9, 84, 169, 60, 10, 12, -1, 5, 9, 85, 204, 46, 11, 12, 0, 5, 12, 86, 165, 47, 12, 12, -1, 5, 11, 87, 88, 48, 17, 12, -1, 5, 16, 88, 216, 46, 11, 12, -1, 5, 10, 89, 228, 46, 11, 12, -1, 5, 9, 90, 180, 60, 10, 12, -1, 5, 9, 91, 249, 0, 5, 16, 0, 4, 6, 92, 13, 0, 10, 17, -2, 3, 8, 93, 85, 17, 5, 16, 0, 4, 6, 94, 196, 85, 10, 8, -1, 5, 9, 95, 71, 99, 10, 3, -1, 17, 9, 96, 46, 99, 6, 4, -1, 4, 5, 97, 111, 87, 9, 9, -1, 8, 9, 98, 207, 32, 9, 13, 0, 4, 10, 99, 161, 86, 8, 9, -1, 8, 8, 100, 69, 34, 10, 13, -1, 4, 10, 101, 89, 88, 10, 9, -1, 8, 9, 102, 58, 49, 7, 13, -1, 4, 6, 103, 191, 59, 10, 12, -1, 8, 9, 104, 177, 33, 9, 13, 0, 4, 10, 105, 187, 73, 5, 12, -1, 5, 4, 106, 177, 17, 6, 15, -2, 5, 5, 107, 217, 32, 9, 13, 0, 4, 9, 108, 250, 17, 4, 13, 0, 4, 4, 109, 24, 89, 14, 9, 0, 8, 15, 110, 151, 86, 9, 9, 0, 8, 10, 111, 100, 87, 10, 9, -1, 8, 10, 112, 42, 76, 9, 12, 0, 8, 10, 113, 213, 59, 10, 12, -1, 8, 10, 114, 188, 86, 7, 9, 0, 8, 6, 115, 170, 86, 8, 9, -1, 8, 7, 116, 230, 72, 7, 11, -1, 6, 6, 117, 141, 86, 9, 9, 0, 8, 10, 118, 78, 89, 10, 9, -1, 8, 9, 119, 8, 89, 15, 9, -1, 8, 13, 120, 131, 86, 9, 9, -1, 8, 8, 121, 224, 59, 10, 12, -1, 8, 9, 122, 179, 86, 8, 9, -1, 8, 7, 123, 34, 0, 6, 17, -1, 3, 6, 124, 64, 0, 3, 17, 2, 3, 9, 125, 41, 0, 6, 17, 0, 3, 6, 126, 30, 99, 9, 5, 0, 5, 9, 160, 114, 97, 2, 2, -1, 16, 4, 161, 80, 48, 3, 13, 1, 6, 6, 162, 165, 73, 7, 12, 0, 5, 9, 163, 92, 74, 9, 12, 0, 5, 9, 164, 209, 72, 10, 11, -1, 6, 9, 165, 36, 63, 11, 12, -2, 5, 9, 166, 60, 0, 3, 17, 2, 3, 9, 167, 151, 17, 8, 15, 0, 4, 9, 168, 82, 99, 6, 3, 0, 5, 7, 169, 236, 17, 13, 13, 0, 4, 15, 170, 238, 72, 7, 11, 0, 5, 7, 171, 54, 89, 11, 9, -1, 7, 10, 172, 20, 99, 9, 5, -1, 10, 9, 173, 96, 98, 5, 3, 0, 10, 6, 174, 226, 84, 8, 8, 0, 4, 9, 175, 89, 98, 6, 3, 0, 4, 7, 176, 40, 99, 5, 5, 0, 4, 6, 177, 22, 76, 9, 12, 0, 5, 9, 178, 235, 84, 6, 8, 0, 3, 6, 179, 242, 84, 6, 8, 0, 3, 6, 180, 53, 99, 6, 4, -1, 4, 5, 181, 0, 76, 10, 12, 0, 8, 10, 182, 215, 17, 10, 14, 0, 5, 11, 183, 251, 78, 3, 4, 0, 9, 5, 184, 60, 99, 5, 4, 0, 16, 5, 185, 249, 83, 5, 8, -1, 3, 5, 186, 0, 89, 7, 10, 0, 5, 8, 187, 66, 89, 11, 9, -1, 7, 10, 188, 42, 35, 13, 13, -1, 4, 12, 189, 0, 35, 13, 13, -1, 4, 12, 190, 14, 35, 13, 13, -1, 4, 13, 191, 49, 49, 8, 13, -1, 6, 8, 192, 150, 0, 12, 16, -1, 1, 11, 193, 176, 0, 12, 16, -1, 1, 11, 194, 163, 0, 12, 16, -1, 1, 11, 195, 124, 0, 12, 16, -1, 1, 11, 196, 105, 17, 12, 15, -1, 2, 11, 197, 0, 0, 12, 17, -1, 0, 11, 198, 106, 47, 15, 12, -1, 5, 14, 199, 141, 17, 9, 15, 0, 5, 10, 200, 60, 18, 8, 16, 0, 1, 9, 201, 41, 18, 9, 16, 0, 1, 9, 202, 21, 18, 9, 16, 0, 1, 9, 203, 160, 17, 8, 15, 0, 2, 9, 204, 69, 17, 7, 16, -2, 1, 5, 205, 77, 17, 7, 16, -1, 1, 5, 206, 51, 18, 8, 16, -2, 1, 5, 207, 169, 17, 7, 15, -2, 2, 5, 208, 152, 47, 12, 12, -1, 5, 12, 209, 237, 0, 11, 16, 0, 1, 12, 210, 82, 0, 13, 16, -1, 1, 12, 211, 68, 0, 13, 16, -1, 1, 12, 212, 110, 0, 13, 16, -1, 1, 12, 213, 96, 0, 13, 16, -1, 1, 12, 214, 91, 17, 13, 15, -1, 2, 12, 215, 217, 84, 8, 8, 0, 8, 9, 216, 137, 0, 12, 16, 0, 3, 12, 217, 225, 0, 11, 16, 0, 1, 12, 218, 189, 0, 11, 16, 0, 1, 12, 219, 213, 0, 11, 16, 0, 1, 12, 220, 118, 17, 11, 15, 0, 2, 12, 221, 201, 0, 11, 16, -1, 1, 9, 222, 72, 76, 9, 12, 0, 5, 10, 223, 167, 33, 9, 13, 0, 4, 10, 224, 157, 33, 9, 13, -1, 4, 9, 225, 30, 49, 9, 13, -1, 4, 9, 226, 227, 32, 9, 13, -1, 4, 9, 227, 237, 31, 9, 13, -1, 4, 9, 228, 82, 75, 9, 12, -1, 5, 9, 229, 226, 17, 9, 14, -1, 3, 9, 230, 39, 89, 14, 9, 0, 8, 14, 231, 157, 73, 7, 12, 0, 8, 8, 232, 146, 33, 10, 13, -1, 4, 9, 233, 80, 34, 10, 13, -1, 4, 9, 234, 91, 33, 10, 13, -1, 4, 9, 235, 92, 61, 10, 12, -1, 5, 9, 236, 66, 49, 6, 13, -2, 4, 4, 237, 73, 48, 6, 13, -1, 4, 4, 238, 247, 31, 8, 13, -2, 4, 4, 239, 180, 73, 6, 12, -1, 5, 4, 240, 187, 32, 9, 13, 0, 4, 10, 241, 197, 32, 9, 13, 0, 4, 10, 242, 102, 33, 10, 13, -1, 4, 10, 243, 113, 33, 10, 13, -1, 4, 10, 244, 124, 33, 10, 13, -1, 4, 10, 245, 135, 33, 10, 13, -1, 4, 10, 246, 202, 59, 10, 12, -1, 5, 10, 247, 220, 72, 9, 11, -1, 6, 9, 248, 198, 72, 10, 11, 0, 7, 10, 249, 0, 49, 9, 13, 0, 4, 10, 250, 10, 49, 9, 13, 0, 4, 10, 251, 20, 49, 9, 13, 0, 4, 10, 252, 246, 58, 9, 12, 0, 5, 10, 253, 0, 18, 10, 16, -1, 4, 9, 254, 11, 18, 9, 16, 0, 4, 10, 255, 130, 17, 10, 15, -1, 5, 9};
+static const int _bi_font_doc_title_font_height = 22;
+static const int _bi_font_doc_title_font_ascent = 17;
+static const int _bi_font_doc_title_font_charcount = 193;
+static const int _bi_font_doc_title_font_characters[] = { 0, 108, 97, 2, 2, -1, 16, 0, 13, 111, 97, 2, 2, -1, 16, 0, 32, 252, 55, 2, 2, -1, 16, 4, 33, 84, 48, 3, 13, 1, 4, 6, 34, 9, 99, 6, 6, 0, 4, 8, 35, 52, 76, 9, 12, -1, 5, 9, 36, 31, 18, 9, 16, 0, 3, 9, 37, 28, 35, 13, 13, -1, 4, 13, 38, 56, 35, 12, 13, 0, 4, 13, 39, 16, 99, 3, 6, 0, 4, 4, 40, 48, 0, 5, 17, 0, 3, 6, 41, 54, 0, 5, 17, 0, 3, 6, 42, 207, 84, 9, 8, 0, 3, 9, 43, 121, 86, 9, 9, 0, 7, 9, 44, 251, 71, 4, 6, -1, 13, 5, 45, 102, 97, 5, 3, 0, 10, 6, 46, 66, 99, 4, 4, 0, 13, 5, 47, 24, 0, 9, 17, -2, 3, 8, 48, 11, 76, 10, 12, -1, 5, 9, 49, 102, 74, 9, 12, 0, 5, 9, 50, 48, 63, 10, 12, -1, 5, 9, 51, 59, 63, 10, 12, -1, 5, 9, 52, 70, 63, 10, 12, -1, 5, 9, 53, 81, 62, 10, 12, -1, 5, 9, 54, 235, 59, 10, 12, -1, 5, 9, 55, 103, 61, 10, 12, -1, 5, 9, 56, 114, 60, 10, 12, -1, 5, 9, 57, 125, 60, 10, 12, -1, 5, 9, 58, 252, 45, 3, 9, 0, 8, 5, 59, 246, 71, 4, 11, -1, 8, 5, 60, 148, 73, 8, 12, 0, 5, 9, 61, 0, 100, 8, 7, 0, 8, 9, 62, 139, 73, 8, 12, 0, 5, 9, 63, 40, 49, 8, 13, 0, 4, 8, 64, 184, 17, 15, 14, 0, 5, 16, 65, 178, 47, 12, 12, -1, 5, 11, 66, 136, 60, 10, 12, 0, 5, 10, 67, 240, 45, 11, 12, -1, 5, 10, 68, 0, 63, 11, 12, 0, 5, 11, 69, 130, 73, 8, 12, 0, 5, 9, 70, 112, 74, 8, 12, 0, 5, 8, 71, 191, 46, 12, 12, -1, 5, 11, 72, 24, 63, 11, 12, 0, 5, 11, 73, 193, 72, 4, 12, 0, 5, 5, 74, 173, 73, 6, 12, -1, 5, 6, 75, 147, 60, 10, 12, 0, 5, 10, 76, 121, 73, 8, 12, 0, 5, 8, 77, 122, 47, 15, 12, 0, 5, 16, 78, 12, 63, 11, 12, 0, 5, 12, 79, 138, 47, 13, 12, -1, 5, 12, 80, 62, 76, 9, 12, 0, 5, 10, 81, 200, 17, 14, 14, -1, 5, 12, 82, 158, 60, 10, 12, 0, 5, 10, 83, 32, 76, 9, 12, -1, 5, 9, 84, 169, 60, 10, 12, -1, 5, 9, 85, 204, 46, 11, 12, 0, 5, 12, 86, 165, 47, 12, 12, -1, 5, 11, 87, 88, 48, 17, 12, -1, 5, 16, 88, 216, 46, 11, 12, -1, 5, 10, 89, 228, 46, 11, 12, -1, 5, 9, 90, 180, 60, 10, 12, -1, 5, 9, 91, 249, 0, 5, 16, 0, 4, 6, 92, 13, 0, 10, 17, -2, 3, 8, 93, 85, 17, 5, 16, 0, 4, 6, 94, 196, 85, 10, 8, -1, 5, 9, 95, 71, 99, 10, 3, -1, 17, 9, 96, 46, 99, 6, 4, -1, 4, 5, 97, 111, 87, 9, 9, -1, 8, 9, 98, 207, 32, 9, 13, 0, 4, 10, 99, 161, 86, 8, 9, -1, 8, 8, 100, 69, 34, 10, 13, -1, 4, 10, 101, 89, 88, 10, 9, -1, 8, 9, 102, 58, 49, 7, 13, -1, 4, 6, 103, 191, 59, 10, 12, -1, 8, 9, 104, 177, 33, 9, 13, 0, 4, 10, 105, 187, 73, 5, 12, -1, 5, 4, 106, 177, 17, 6, 15, -2, 5, 5, 107, 217, 32, 9, 13, 0, 4, 9, 108, 250, 17, 4, 13, 0, 4, 4, 109, 24, 89, 14, 9, 0, 8, 15, 110, 151, 86, 9, 9, 0, 8, 10, 111, 100, 87, 10, 9, -1, 8, 10, 112, 42, 76, 9, 12, 0, 8, 10, 113, 213, 59, 10, 12, -1, 8, 10, 114, 188, 86, 7, 9, 0, 8, 6, 115, 170, 86, 8, 9, -1, 8, 7, 116, 230, 72, 7, 11, -1, 6, 6, 117, 141, 86, 9, 9, 0, 8, 10, 118, 78, 89, 10, 9, -1, 8, 9, 119, 8, 89, 15, 9, -1, 8, 13, 120, 131, 86, 9, 9, -1, 8, 8, 121, 224, 59, 10, 12, -1, 8, 9, 122, 179, 86, 8, 9, -1, 8, 7, 123, 34, 0, 6, 17, -1, 3, 6, 124, 64, 0, 3, 17, 2, 3, 9, 125, 41, 0, 6, 17, 0, 3, 6, 126, 30, 99, 9, 5, 0, 5, 9, 160, 114, 97, 2, 2, -1, 16, 4, 161, 80, 48, 3, 13, 1, 6, 6, 162, 165, 73, 7, 12, 0, 5, 9, 163, 92, 74, 9, 12, 0, 5, 9, 164, 209, 72, 10, 11, -1, 6, 9, 165, 36, 63, 11, 12, -2, 5, 9, 166, 60, 0, 3, 17, 2, 3, 9, 167, 151, 17, 8, 15, 0, 4, 9, 168, 82, 99, 6, 3, 0, 5, 7, 169, 236, 17, 13, 13, 0, 4, 15, 170, 238, 72, 7, 11, 0, 5, 7, 171, 54, 89, 11, 9, -1, 7, 10, 172, 20, 99, 9, 5, -1, 10, 9, 173, 96, 98, 5, 3, 0, 10, 6, 174, 226, 84, 8, 8, 0, 4, 9, 175, 89, 98, 6, 3, 0, 4, 7, 176, 40, 99, 5, 5, 0, 4, 6, 177, 22, 76, 9, 12, 0, 5, 9, 178, 235, 84, 6, 8, 0, 3, 6, 179, 242, 84, 6, 8, 0, 3, 6, 180, 53, 99, 6, 4, -1, 4, 5, 181, 0, 76, 10, 12, 0, 8, 10, 182, 215, 17, 10, 14, 0, 5, 11, 183, 251, 78, 3, 4, 0, 9, 5, 184, 60, 99, 5, 4, 0, 16, 5, 185, 249, 83, 5, 8, -1, 3, 5, 186, 0, 89, 7, 10, 0, 5, 8, 187, 66, 89, 11, 9, -1, 7, 10, 188, 42, 35, 13, 13, -1, 4, 12, 189, 0, 35, 13, 13, -1, 4, 12, 190, 14, 35, 13, 13, -1, 4, 13, 191, 49, 49, 8, 13, -1, 6, 8, 192, 150, 0, 12, 16, -1, 1, 11, 193, 176, 0, 12, 16, -1, 1, 11, 194, 163, 0, 12, 16, -1, 1, 11, 195, 124, 0, 12, 16, -1, 1, 11, 196, 105, 17, 12, 15, -1, 2, 11, 197, 0, 0, 12, 17, -1, 0, 11, 198, 106, 47, 15, 12, -1, 5, 14, 199, 141, 17, 9, 15, 0, 5, 10, 200, 60, 18, 8, 16, 0, 1, 9, 201, 41, 18, 9, 16, 0, 1, 9, 202, 21, 18, 9, 16, 0, 1, 9, 203, 160, 17, 8, 15, 0, 2, 9, 204, 69, 17, 7, 16, -2, 1, 5, 205, 77, 17, 7, 16, -1, 1, 5, 206, 51, 18, 8, 16, -2, 1, 5, 207, 169, 17, 7, 15, -2, 2, 5, 208, 152, 47, 12, 12, -1, 5, 12, 209, 237, 0, 11, 16, 0, 1, 12, 210, 82, 0, 13, 16, -1, 1, 12, 211, 68, 0, 13, 16, -1, 1, 12, 212, 110, 0, 13, 16, -1, 1, 12, 213, 96, 0, 13, 16, -1, 1, 12, 214, 91, 17, 13, 15, -1, 2, 12, 215, 217, 84, 8, 8, 0, 8, 9, 216, 137, 0, 12, 16, 0, 3, 12, 217, 225, 0, 11, 16, 0, 1, 12, 218, 189, 0, 11, 16, 0, 1, 12, 219, 213, 0, 11, 16, 0, 1, 12, 220, 118, 17, 11, 15, 0, 2, 12, 221, 201, 0, 11, 16, -1, 1, 9, 222, 72, 76, 9, 12, 0, 5, 10, 223, 167, 33, 9, 13, 0, 4, 10, 224, 157, 33, 9, 13, -1, 4, 9, 225, 30, 49, 9, 13, -1, 4, 9, 226, 227, 32, 9, 13, -1, 4, 9, 227, 237, 31, 9, 13, -1, 4, 9, 228, 82, 75, 9, 12, -1, 5, 9, 229, 226, 17, 9, 14, -1, 3, 9, 230, 39, 89, 14, 9, 0, 8, 14, 231, 157, 73, 7, 12, 0, 8, 8, 232, 146, 33, 10, 13, -1, 4, 9, 233, 80, 34, 10, 13, -1, 4, 9, 234, 91, 33, 10, 13, -1, 4, 9, 235, 92, 61, 10, 12, -1, 5, 9, 236, 66, 49, 6, 13, -2, 4, 4, 237, 73, 48, 6, 13, -1, 4, 4, 238, 247, 31, 8, 13, -2, 4, 4, 239, 180, 73, 6, 12, -1, 5, 4, 240, 187, 32, 9, 13, 0, 4, 10, 241, 197, 32, 9, 13, 0, 4, 10, 242, 102, 33, 10, 13, -1, 4, 10, 243, 113, 33, 10, 13, -1, 4, 10, 244, 124, 33, 10, 13, -1, 4, 10, 245, 135, 33, 10, 13, -1, 4, 10, 246, 202, 59, 10, 12, -1, 5, 10, 247, 220, 72, 9, 11, -1, 6, 9, 248, 198, 72, 10, 11, 0, 7, 10, 249, 0, 49, 9, 13, 0, 4, 10, 250, 10, 49, 9, 13, 0, 4, 10, 251, 20, 49, 9, 13, 0, 4, 10, 252, 246, 58, 9, 12, 0, 5, 10, 253, 0, 18, 10, 16, -1, 4, 9, 254, 11, 18, 9, 16, 0, 4, 10, 255, 130, 17, 10, 15, -1, 5, 9 };
diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp
index 8af01012a4..dfe63aacc2 100644
--- a/editor/editor_asset_installer.cpp
+++ b/editor/editor_asset_installer.cpp
@@ -28,36 +28,32 @@
/*************************************************************************/
#include "editor_asset_installer.h"
+#include "editor_node.h"
#include "io/zip_io.h"
#include "os/dir_access.h"
#include "os/file_access.h"
-#include "editor_node.h"
-
-void EditorAssetInstaller::_update_subitems(TreeItem* p_item,bool p_check,bool p_first) {
+void EditorAssetInstaller::_update_subitems(TreeItem *p_item, bool p_check, bool p_first) {
if (p_check) {
- if (p_item->get_custom_color(0)==Color()) {
- p_item->set_checked(0,true);
+ if (p_item->get_custom_color(0) == Color()) {
+ p_item->set_checked(0, true);
}
} else {
- p_item->set_checked(0,false);
-
+ p_item->set_checked(0, false);
}
if (p_item->get_children()) {
- _update_subitems(p_item->get_children(),p_check);
+ _update_subitems(p_item->get_children(), p_check);
}
if (!p_first && p_item->get_next()) {
- _update_subitems(p_item->get_next(),p_check);
+ _update_subitems(p_item->get_next(), p_check);
}
-
}
void EditorAssetInstaller::_item_edited() {
-
if (updating)
return;
@@ -65,32 +61,28 @@ void EditorAssetInstaller::_item_edited() {
if (!item)
return;
+ String path = item->get_metadata(0);
- String path=item->get_metadata(0);
-
- updating=true;
- if (path==String()) { //a dir
- _update_subitems(item,item->is_checked(0),true);
+ updating = true;
+ if (path == String()) { //a dir
+ _update_subitems(item, item->is_checked(0), true);
}
if (item->is_checked(0)) {
- while(item) {
- item->set_checked(0,true);
- item=item->get_parent();
+ while (item) {
+ item->set_checked(0, true);
+ item = item->get_parent();
}
-
}
- updating=false;
-
+ updating = false;
}
-void EditorAssetInstaller::open(const String& p_path,int p_depth) {
-
+void EditorAssetInstaller::open(const String &p_path, int p_depth) {
- package_path=p_path;
+ package_path = p_path;
Set<String> files_sorted;
- FileAccess *src_f=NULL;
+ FileAccess *src_f = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
unzFile pkg = unzOpen2(p_path.utf8().get_data(), &io);
@@ -102,138 +94,126 @@ void EditorAssetInstaller::open(const String& p_path,int p_depth) {
int ret = unzGoToFirstFile(pkg);
-
- while(ret==UNZ_OK) {
+ while (ret == UNZ_OK) {
//get filename
unz_file_info info;
char fname[16384];
- ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0);
+ ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
- String name=fname;
+ String name = fname;
files_sorted.insert(name);
ret = unzGoToNextFile(pkg);
}
-
- Map<String,Ref<Texture> > extension_guess;
+ Map<String, Ref<Texture> > extension_guess;
{
- extension_guess["png"]=get_icon("Texture","EditorIcons");
- extension_guess["jpg"]=get_icon("Texture","EditorIcons");
- extension_guess["tex"]=get_icon("Texture","EditorIcons");
- extension_guess["atex"]=get_icon("Texture","EditorIcons");
- extension_guess["dds"]=get_icon("Texture","EditorIcons");
- extension_guess["scn"]=get_icon("PackedScene","EditorIcons");
- extension_guess["tscn"]=get_icon("PackedScene","EditorIcons");
- extension_guess["xml"]=get_icon("PackedScene","EditorIcons");
- extension_guess["xscn"]=get_icon("PackedScene","EditorIcons");
- extension_guess["mtl"]=get_icon("Material","EditorIcons");
- extension_guess["shd"]=get_icon("Shader","EditorIcons");
- extension_guess["gd"]=get_icon("GDScript","EditorIcons");
+ extension_guess["png"] = get_icon("Texture", "EditorIcons");
+ extension_guess["jpg"] = get_icon("Texture", "EditorIcons");
+ extension_guess["tex"] = get_icon("Texture", "EditorIcons");
+ extension_guess["atex"] = get_icon("Texture", "EditorIcons");
+ extension_guess["dds"] = get_icon("Texture", "EditorIcons");
+ extension_guess["scn"] = get_icon("PackedScene", "EditorIcons");
+ extension_guess["tscn"] = get_icon("PackedScene", "EditorIcons");
+ extension_guess["xml"] = get_icon("PackedScene", "EditorIcons");
+ extension_guess["xscn"] = get_icon("PackedScene", "EditorIcons");
+ extension_guess["mtl"] = get_icon("Material", "EditorIcons");
+ extension_guess["shd"] = get_icon("Shader", "EditorIcons");
+ extension_guess["gd"] = get_icon("GDScript", "EditorIcons");
}
- Ref<Texture> generic_extension = get_icon("Object","EditorIcons");
-
+ Ref<Texture> generic_extension = get_icon("Object", "EditorIcons");
unzClose(pkg);
- updating=true;
+ updating = true;
tree->clear();
- TreeItem *root=tree->create_item();
- root->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- root->set_checked(0,true);
- root->set_icon(0,get_icon("folder","FileDialog"));
- root->set_text(0,"res://");
- root->set_editable(0,true);
- Map<String,TreeItem*> dir_map;
+ TreeItem *root = tree->create_item();
+ root->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ root->set_checked(0, true);
+ root->set_icon(0, get_icon("folder", "FileDialog"));
+ root->set_text(0, "res://");
+ root->set_editable(0, true);
+ Map<String, TreeItem *> dir_map;
- for(Set<String>::Element *E=files_sorted.front();E;E=E->next()) {
+ for (Set<String>::Element *E = files_sorted.front(); E; E = E->next()) {
String path = E->get();
- int depth=p_depth;
- bool skip=false;
- while(depth>0) {
+ int depth = p_depth;
+ bool skip = false;
+ while (depth > 0) {
int pp = path.find("/");
- if (pp==-1) {
- skip=true;
+ if (pp == -1) {
+ skip = true;
break;
}
- path=path.substr(pp+1,path.length());
+ path = path.substr(pp + 1, path.length());
depth--;
}
- if (skip || path==String())
+ if (skip || path == String())
continue;
- bool isdir=false;
+ bool isdir = false;
if (path.ends_with("/")) {
//a directory
- path=path.substr(0,path.length()-1);
- isdir=true;
+ path = path.substr(0, path.length() - 1);
+ isdir = true;
}
int pp = path.find_last("/");
-
TreeItem *parent;
- if (pp==-1) {
- parent=root;
+ if (pp == -1) {
+ parent = root;
} else {
- String ppath=path.substr(0,pp);
- print_line("PPATH IS: "+ppath);
+ String ppath = path.substr(0, pp);
+ print_line("PPATH IS: " + ppath);
ERR_CONTINUE(!dir_map.has(ppath));
- parent=dir_map[ppath];
-
+ parent = dir_map[ppath];
}
TreeItem *ti = tree->create_item(parent);
- ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- ti->set_checked(0,true);
- ti->set_editable(0,true);
+ ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ ti->set_checked(0, true);
+ ti->set_editable(0, true);
if (isdir) {
- dir_map[path]=ti;
- ti->set_text(0,path.get_file()+"/");
- ti->set_icon(0,get_icon("folder","FileDialog"));
+ dir_map[path] = ti;
+ ti->set_text(0, path.get_file() + "/");
+ ti->set_icon(0, get_icon("folder", "FileDialog"));
} else {
String file = path.get_file();
String extension = file.get_extension().to_lower();
if (extension_guess.has(extension)) {
- ti->set_icon(0,extension_guess[extension]);
+ ti->set_icon(0, extension_guess[extension]);
} else {
- ti->set_icon(0,generic_extension);
+ ti->set_icon(0, generic_extension);
}
- ti->set_text(0,file);
+ ti->set_text(0, file);
-
- String res_path = "res://"+path;
+ String res_path = "res://" + path;
if (FileAccess::exists(res_path)) {
- ti->set_custom_color(0,Color(1,0.3,0.2));
- ti->set_tooltip(0,res_path+" (Already Exists)");
- ti->set_checked(0,false);
+ ti->set_custom_color(0, Color(1, 0.3, 0.2));
+ ti->set_tooltip(0, res_path + " (Already Exists)");
+ ti->set_checked(0, false);
} else {
- ti->set_tooltip(0,res_path);
-
+ ti->set_tooltip(0, res_path);
}
- ti->set_metadata(0,res_path);
-
+ ti->set_metadata(0, res_path);
}
- status_map[E->get()]=ti;
-
-
-
+ status_map[E->get()] = ti;
}
popup_centered_ratio();
- updating=false;
-
+ updating = false;
}
void EditorAssetInstaller::ok_pressed() {
- FileAccess *src_f=NULL;
+ FileAccess *src_f = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
unzFile pkg = unzOpen2(package_path.utf8().get_data(), &io);
@@ -247,32 +227,32 @@ void EditorAssetInstaller::ok_pressed() {
Vector<String> failed_files;
- ProgressDialog::get_singleton()->add_task("uncompress","Uncompressing Assets",status_map.size());
+ ProgressDialog::get_singleton()->add_task("uncompress", "Uncompressing Assets", status_map.size());
- int idx=0;
- while(ret==UNZ_OK) {
+ int idx = 0;
+ while (ret == UNZ_OK) {
//get filename
unz_file_info info;
char fname[16384];
- ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0);
+ ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
- String name=fname;
+ String name = fname;
if (status_map.has(name) && status_map[name]->is_checked(0)) {
String path = status_map[name]->get_metadata(0);
- if (path==String()) { // a dir
+ if (path == String()) { // a dir
String dirpath;
TreeItem *t = status_map[name];
- while(t) {
- dirpath=t->get_text(0)+dirpath;
- t=t->get_parent();
+ while (t) {
+ dirpath = t->get_text(0) + dirpath;
+ t = t->get_parent();
}
if (dirpath.ends_with("/")) {
- dirpath=dirpath.substr(0,dirpath.length()-1);
+ dirpath = dirpath.substr(0, dirpath.length() - 1);
}
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
@@ -286,20 +266,19 @@ void EditorAssetInstaller::ok_pressed() {
//read
unzOpenCurrentFile(pkg);
- unzReadCurrentFile(pkg,data.ptr(),data.size());
+ unzReadCurrentFile(pkg, data.ptr(), data.size());
unzCloseCurrentFile(pkg);
- FileAccess *f=FileAccess::open(path,FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(path, FileAccess::WRITE);
if (f) {
- f->store_buffer(data.ptr(),data.size());
+ f->store_buffer(data.ptr(), data.size());
memdelete(f);
} else {
failed_files.push_back(path);
}
- ProgressDialog::get_singleton()->task_step("uncompress",path,idx);
+ ProgressDialog::get_singleton()->task_step("uncompress", path, idx);
}
-
}
idx++;
@@ -310,50 +289,43 @@ void EditorAssetInstaller::ok_pressed() {
unzClose(pkg);
if (failed_files.size()) {
- String msg="The following files failed extraction from package:\n\n";
- for(int i=0;i<failed_files.size();i++) {
+ String msg = "The following files failed extraction from package:\n\n";
+ for (int i = 0; i < failed_files.size(); i++) {
- if (i>15) {
- msg+="\nAnd "+itos(failed_files.size()-i)+" more files.";
+ if (i > 15) {
+ msg += "\nAnd " + itos(failed_files.size() - i) + " more files.";
break;
}
- msg+=failed_files[i];
+ msg += failed_files[i];
}
if (EditorNode::get_singleton() != NULL)
EditorNode::get_singleton()->show_warning(msg);
} else {
if (EditorNode::get_singleton() != NULL)
- EditorNode::get_singleton()->show_warning("Package Installed Successfully!","Success!");
+ EditorNode::get_singleton()->show_warning("Package Installed Successfully!", "Success!");
}
-
-
-
-
}
void EditorAssetInstaller::_bind_methods() {
- ClassDB::bind_method("_item_edited",&EditorAssetInstaller::_item_edited);
-
+ ClassDB::bind_method("_item_edited", &EditorAssetInstaller::_item_edited);
}
EditorAssetInstaller::EditorAssetInstaller() {
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
+ tree = memnew(Tree);
+ vb->add_margin_child("Package Contents:", tree, true);
+ tree->connect("item_edited", this, "_item_edited");
- tree = memnew( Tree );
- vb->add_margin_child("Package Contents:",tree,true);
- tree->connect("item_edited",this,"_item_edited");
-
- error = memnew( AcceptDialog) ;
+ error = memnew(AcceptDialog);
add_child(error);
get_ok()->set_text("Install");
set_title("Package Installer");
- updating=false;
+ updating = false;
set_hide_on_ok(true);
}
-
diff --git a/editor/editor_asset_installer.h b/editor/editor_asset_installer.h
index 2d0486a6f6..046387520e 100644
--- a/editor/editor_asset_installer.h
+++ b/editor/editor_asset_installer.h
@@ -29,27 +29,26 @@
#ifndef EDITORASSETINSTALLER_H
#define EDITORASSETINSTALLER_H
-
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
class EditorAssetInstaller : public ConfirmationDialog {
- GDCLASS( EditorAssetInstaller, ConfirmationDialog );
+ GDCLASS(EditorAssetInstaller, ConfirmationDialog);
Tree *tree;
String package_path;
AcceptDialog *error;
- Map<String,TreeItem*> status_map;
+ Map<String, TreeItem *> status_map;
bool updating;
- void _update_subitems(TreeItem* p_item,bool p_check,bool p_first=false);
+ void _update_subitems(TreeItem *p_item, bool p_check, bool p_first = false);
void _item_edited();
virtual void ok_pressed();
-protected:
+protected:
static void _bind_methods();
-public:
- void open(const String& p_path,int p_depth=0);
+public:
+ void open(const String &p_path, int p_depth = 0);
EditorAssetInstaller();
};
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index 8643644950..36cb95a373 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -29,114 +29,109 @@
#include "editor_audio_buses.h"
#include "editor_node.h"
-#include "servers/audio_server.h"
-#include "os/keyboard.h"
-#include "io/resource_saver.h"
#include "filesystem_dock.h"
+#include "io/resource_saver.h"
+#include "os/keyboard.h"
+#include "servers/audio_server.h"
void EditorAudioBus::_notification(int p_what) {
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
- vu_l->set_under_texture(get_icon("BusVuEmpty","EditorIcons"));
- vu_l->set_progress_texture(get_icon("BusVuFull","EditorIcons"));
- vu_r->set_under_texture(get_icon("BusVuEmpty","EditorIcons"));
- vu_r->set_progress_texture(get_icon("BusVuFull","EditorIcons"));
- scale->set_texture( get_icon("BusVuDb","EditorIcons"));
+ vu_l->set_under_texture(get_icon("BusVuEmpty", "EditorIcons"));
+ vu_l->set_progress_texture(get_icon("BusVuFull", "EditorIcons"));
+ vu_r->set_under_texture(get_icon("BusVuEmpty", "EditorIcons"));
+ vu_r->set_progress_texture(get_icon("BusVuFull", "EditorIcons"));
+ scale->set_texture(get_icon("BusVuDb", "EditorIcons"));
- disabled_vu = get_icon("BusVuFrozen","EditorIcons");
+ disabled_vu = get_icon("BusVuFrozen", "EditorIcons");
- prev_active=true;
+ prev_active = true;
update_bus();
set_process(true);
}
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
if (has_focus()) {
- draw_style_box(get_stylebox("focus","Button"),Rect2(Vector2(),get_size()));
+ draw_style_box(get_stylebox("focus", "Button"), Rect2(Vector2(), get_size()));
}
}
- if (p_what==NOTIFICATION_PROCESS) {
+ if (p_what == NOTIFICATION_PROCESS) {
- float real_peak[2]={-100,-100};
- bool activity_found=false;
+ float real_peak[2] = { -100, -100 };
+ bool activity_found = false;
int cc;
- switch(AudioServer::get_singleton()->get_speaker_mode()) {
+ switch (AudioServer::get_singleton()->get_speaker_mode()) {
case AudioServer::SPEAKER_MODE_STEREO: cc = 1; break;
case AudioServer::SPEAKER_SURROUND_51: cc = 4; break;
case AudioServer::SPEAKER_SURROUND_71: cc = 5; break;
}
- for(int i=0;i<cc;i++) {
- if (AudioServer::get_singleton()->is_bus_channel_active(get_index(),i)) {
- activity_found=true;
- real_peak[0]=MAX(real_peak[0],AudioServer::get_singleton()->get_bus_peak_volume_left_db(get_index(),i));
- real_peak[1]=MAX(real_peak[1],AudioServer::get_singleton()->get_bus_peak_volume_right_db(get_index(),i));
+ for (int i = 0; i < cc; i++) {
+ if (AudioServer::get_singleton()->is_bus_channel_active(get_index(), i)) {
+ activity_found = true;
+ real_peak[0] = MAX(real_peak[0], AudioServer::get_singleton()->get_bus_peak_volume_left_db(get_index(), i));
+ real_peak[1] = MAX(real_peak[1], AudioServer::get_singleton()->get_bus_peak_volume_right_db(get_index(), i));
}
}
-
- if (real_peak[0]>peak_l) {
+ if (real_peak[0] > peak_l) {
peak_l = real_peak[0];
} else {
- peak_l-=get_process_delta_time()*60.0;
+ peak_l -= get_process_delta_time() * 60.0;
}
- if (real_peak[1]>peak_r) {
+ if (real_peak[1] > peak_r) {
peak_r = real_peak[1];
} else {
- peak_r-=get_process_delta_time()*60.0;
-
+ peak_r -= get_process_delta_time() * 60.0;
}
vu_l->set_value(peak_l);
vu_r->set_value(peak_r);
- if (activity_found!=prev_active) {
+ if (activity_found != prev_active) {
if (activity_found) {
vu_l->set_over_texture(Ref<Texture>());
vu_r->set_over_texture(Ref<Texture>());
} else {
vu_l->set_over_texture(disabled_vu);
vu_r->set_over_texture(disabled_vu);
-
}
- prev_active=activity_found;
+ prev_active = activity_found;
}
-
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- peak_l=-100;
- peak_r=-100;
- prev_active=true;
+ peak_l = -100;
+ peak_r = -100;
+ prev_active = true;
set_process(is_visible_in_tree());
}
-
}
void EditorAudioBus::update_send() {
send->clear();
- if (get_index()==0) {
+ if (get_index() == 0) {
send->set_disabled(true);
send->set_text("Speakers");
} else {
send->set_disabled(false);
StringName current_send = AudioServer::get_singleton()->get_bus_send(get_index());
- int current_send_index=0; //by default to master
+ int current_send_index = 0; //by default to master
- for(int i=0;i<get_index();i++) {
+ for (int i = 0; i < get_index(); i++) {
StringName send_name = AudioServer::get_singleton()->get_bus_name(i);
send->add_item(send_name);
- if (send_name==current_send) {
- current_send_index=i;
+ if (send_name == current_send) {
+ current_send_index = i;
}
}
@@ -149,63 +144,60 @@ void EditorAudioBus::update_bus() {
if (updating_bus)
return;
- updating_bus=true;
+ updating_bus = true;
int index = get_index();
slider->set_value(AudioServer::get_singleton()->get_bus_volume_db(index));
track_name->set_text(AudioServer::get_singleton()->get_bus_name(index));
- if (get_index()==0)
+ if (get_index() == 0)
track_name->set_editable(false);
- solo->set_pressed( AudioServer::get_singleton()->is_bus_solo(index));
- mute->set_pressed( AudioServer::get_singleton()->is_bus_mute(index));
- bypass->set_pressed( AudioServer::get_singleton()->is_bus_bypassing_effects(index));
+ solo->set_pressed(AudioServer::get_singleton()->is_bus_solo(index));
+ mute->set_pressed(AudioServer::get_singleton()->is_bus_mute(index));
+ bypass->set_pressed(AudioServer::get_singleton()->is_bus_bypassing_effects(index));
// effects..
effects->clear();
TreeItem *root = effects->create_item();
- for(int i=0;i<AudioServer::get_singleton()->get_bus_effect_count(index);i++) {
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_effect_count(index); i++) {
- Ref<AudioEffect> afx = AudioServer::get_singleton()->get_bus_effect(index,i);
+ Ref<AudioEffect> afx = AudioServer::get_singleton()->get_bus_effect(index, i);
TreeItem *fx = effects->create_item(root);
- fx->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- fx->set_editable(0,true);
- fx->set_checked(0,AudioServer::get_singleton()->is_bus_effect_enabled(index,i));
- fx->set_text(0,afx->get_name());
- fx->set_metadata(0,i);
-
+ fx->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ fx->set_editable(0, true);
+ fx->set_checked(0, AudioServer::get_singleton()->is_bus_effect_enabled(index, i));
+ fx->set_text(0, afx->get_name());
+ fx->set_metadata(0, i);
}
TreeItem *add = effects->create_item(root);
- add->set_cell_mode(0,TreeItem::CELL_MODE_CUSTOM);
- add->set_editable(0,true);
- add->set_selectable(0,false);
- add->set_text(0,"Add Effect");
+ add->set_cell_mode(0, TreeItem::CELL_MODE_CUSTOM);
+ add->set_editable(0, true);
+ add->set_selectable(0, false);
+ add->set_text(0, "Add Effect");
update_send();
- updating_bus=false;
-
+ updating_bus = false;
}
+void EditorAudioBus::_name_changed(const String &p_new_name) {
-void EditorAudioBus::_name_changed(const String& p_new_name) {
-
- if (p_new_name==AudioServer::get_singleton()->get_bus_name(get_index()))
+ if (p_new_name == AudioServer::get_singleton()->get_bus_name(get_index()))
return;
- String attempt=p_new_name;
- int attempts=1;
+ String attempt = p_new_name;
+ int attempts = 1;
- while(true) {
+ while (true) {
- bool name_free=true;
- for(int i=0;i<AudioServer::get_singleton()->get_bus_count();i++) {
+ bool name_free = true;
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
- if (AudioServer::get_singleton()->get_bus_name(i)==attempt) {
- name_free=false;
+ if (AudioServer::get_singleton()->get_bus_name(i) == attempt) {
+ name_free = false;
break;
}
}
@@ -215,115 +207,107 @@ void EditorAudioBus::_name_changed(const String& p_new_name) {
}
attempts++;
- attempt=p_new_name+" "+itos(attempts);
+ attempt = p_new_name + " " + itos(attempts);
}
- updating_bus=true;
+ updating_bus = true;
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
StringName current = AudioServer::get_singleton()->get_bus_name(get_index());
ur->create_action("Rename Audio Bus");
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_name",get_index(),attempt);
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_name",get_index(),current);
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_name", get_index(), attempt);
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_name", get_index(), current);
- for(int i=0;i<AudioServer::get_singleton()->get_bus_count();i++) {
- if (AudioServer::get_singleton()->get_bus_send(i)==current) {
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_send",i,attempt);
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_send",i,current);
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
+ if (AudioServer::get_singleton()->get_bus_send(i) == current) {
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_send", i, attempt);
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_send", i, current);
}
}
- ur->add_do_method(buses,"_update_bus",get_index());
- ur->add_undo_method(buses,"_update_bus",get_index());
-
+ ur->add_do_method(buses, "_update_bus", get_index());
+ ur->add_undo_method(buses, "_update_bus", get_index());
- ur->add_do_method(buses,"_update_sends");
- ur->add_undo_method(buses,"_update_sends");
+ ur->add_do_method(buses, "_update_sends");
+ ur->add_undo_method(buses, "_update_sends");
ur->commit_action();
- updating_bus=false;
-
+ updating_bus = false;
}
-void EditorAudioBus::_volume_db_changed(float p_db){
+void EditorAudioBus::_volume_db_changed(float p_db) {
if (updating_bus)
return;
- updating_bus=true;
-
+ updating_bus = true;
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- ur->create_action("Change Audio Bus Volume",UndoRedo::MERGE_ENDS);
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_volume_db",get_index(),p_db);
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_volume_db",get_index(),AudioServer::get_singleton()->get_bus_volume_db(get_index()));
- ur->add_do_method(buses,"_update_bus",get_index());
- ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->create_action("Change Audio Bus Volume", UndoRedo::MERGE_ENDS);
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_volume_db", get_index(), p_db);
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_volume_db", get_index(), AudioServer::get_singleton()->get_bus_volume_db(get_index()));
+ ur->add_do_method(buses, "_update_bus", get_index());
+ ur->add_undo_method(buses, "_update_bus", get_index());
ur->commit_action();
- updating_bus=false;
-
+ updating_bus = false;
}
-void EditorAudioBus::_solo_toggled(){
+void EditorAudioBus::_solo_toggled() {
- updating_bus=true;
+ updating_bus = true;
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Toggle Audio Bus Solo");
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_solo",get_index(),solo->is_pressed());
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_solo",get_index(),AudioServer::get_singleton()->is_bus_solo(get_index()));
- ur->add_do_method(buses,"_update_bus",get_index());
- ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_solo", get_index(), solo->is_pressed());
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_solo", get_index(), AudioServer::get_singleton()->is_bus_solo(get_index()));
+ ur->add_do_method(buses, "_update_bus", get_index());
+ ur->add_undo_method(buses, "_update_bus", get_index());
ur->commit_action();
- updating_bus=false;
-
+ updating_bus = false;
}
-void EditorAudioBus::_mute_toggled(){
+void EditorAudioBus::_mute_toggled() {
- updating_bus=true;
+ updating_bus = true;
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Toggle Audio Bus Mute");
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_mute",get_index(),mute->is_pressed());
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_mute",get_index(),AudioServer::get_singleton()->is_bus_mute(get_index()));
- ur->add_do_method(buses,"_update_bus",get_index());
- ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_mute", get_index(), mute->is_pressed());
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_mute", get_index(), AudioServer::get_singleton()->is_bus_mute(get_index()));
+ ur->add_do_method(buses, "_update_bus", get_index());
+ ur->add_undo_method(buses, "_update_bus", get_index());
ur->commit_action();
- updating_bus=false;
-
+ updating_bus = false;
}
-void EditorAudioBus::_bypass_toggled(){
+void EditorAudioBus::_bypass_toggled() {
- updating_bus=true;
+ updating_bus = true;
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Toggle Audio Bus Bypass Effects");
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_bypass_effects",get_index(),bypass->is_pressed());
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_bypass_effects",get_index(),AudioServer::get_singleton()->is_bus_bypassing_effects(get_index()));
- ur->add_do_method(buses,"_update_bus",get_index());
- ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_bypass_effects", get_index(), bypass->is_pressed());
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_bypass_effects", get_index(), AudioServer::get_singleton()->is_bus_bypassing_effects(get_index()));
+ ur->add_do_method(buses, "_update_bus", get_index());
+ ur->add_undo_method(buses, "_update_bus", get_index());
ur->commit_action();
- updating_bus=false;
-
-
+ updating_bus = false;
}
void EditorAudioBus::_send_selected(int p_which) {
- updating_bus=true;
+ updating_bus = true;
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Select Audio Bus Send");
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_send",get_index(),send->get_item_text(p_which));
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_send",get_index(),AudioServer::get_singleton()->get_bus_send(get_index()));
- ur->add_do_method(buses,"_update_bus",get_index());
- ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_send", get_index(), send->get_item_text(p_which));
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_send", get_index(), AudioServer::get_singleton()->get_bus_send(get_index()));
+ ur->add_do_method(buses, "_update_bus", get_index());
+ ur->add_undo_method(buses, "_update_bus", get_index());
ur->commit_action();
- updating_bus=false;
+ updating_bus = false;
}
void EditorAudioBus::_effect_selected() {
@@ -331,19 +315,18 @@ void EditorAudioBus::_effect_selected() {
TreeItem *effect = effects->get_selected();
if (!effect)
return;
- updating_bus=true;
+ updating_bus = true;
- if (effect->get_metadata(0)!=Variant()) {
+ if (effect->get_metadata(0) != Variant()) {
int index = effect->get_metadata(0);
- Ref<AudioEffect> effect = AudioServer::get_singleton()->get_bus_effect(get_index(),index);
+ Ref<AudioEffect> effect = AudioServer::get_singleton()->get_bus_effect(get_index(), index);
if (effect.is_valid()) {
EditorNode::get_singleton()->push_item(effect.ptr());
}
}
- updating_bus=false;
-
+ updating_bus = false;
}
void EditorAudioBus::_effect_edited() {
@@ -355,28 +338,26 @@ void EditorAudioBus::_effect_edited() {
if (!effect)
return;
- if (effect->get_metadata(0)==Variant()) {
+ if (effect->get_metadata(0) == Variant()) {
Rect2 area = effects->get_item_rect(effect);
- effect_options->set_pos(effects->get_global_pos()+area.pos+Vector2(0,area.size.y));
+ effect_options->set_pos(effects->get_global_pos() + area.pos + Vector2(0, area.size.y));
effect_options->popup();
//add effect
- } else {
+ } else {
int index = effect->get_metadata(0);
- updating_bus=true;
+ updating_bus = true;
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Select Audio Bus Send");
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_effect_enabled",get_index(),index,effect->is_checked(0));
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_effect_enabled",get_index(),index,AudioServer::get_singleton()->is_bus_effect_enabled(get_index(),index));
- ur->add_do_method(buses,"_update_bus",get_index());
- ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_effect_enabled", get_index(), index, effect->is_checked(0));
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_effect_enabled", get_index(), index, AudioServer::get_singleton()->is_bus_effect_enabled(get_index(), index));
+ ur->add_do_method(buses, "_update_bus", get_index());
+ ur->add_undo_method(buses, "_update_bus", get_index());
ur->commit_action();
- updating_bus=false;
-
+ updating_bus = false;
}
-
}
void EditorAudioBus::_effect_add(int p_which) {
@@ -396,78 +377,75 @@ void EditorAudioBus::_effect_add(int p_which) {
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Add Audio Bus Effect");
- ur->add_do_method(AudioServer::get_singleton(),"add_bus_effect",get_index(),afxr,-1);
- ur->add_undo_method(AudioServer::get_singleton(),"remove_bus_effect",get_index(),AudioServer::get_singleton()->get_bus_effect_count(get_index()));
- ur->add_do_method(buses,"_update_bus",get_index());
- ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->add_do_method(AudioServer::get_singleton(), "add_bus_effect", get_index(), afxr, -1);
+ ur->add_undo_method(AudioServer::get_singleton(), "remove_bus_effect", get_index(), AudioServer::get_singleton()->get_bus_effect_count(get_index()));
+ ur->add_do_method(buses, "_update_bus", get_index());
+ ur->add_undo_method(buses, "_update_bus", get_index());
ur->commit_action();
}
-void EditorAudioBus::_gui_input(const InputEvent& p_event) {
+void EditorAudioBus::_gui_input(const InputEvent &p_event) {
- if (p_event.type==InputEvent::KEY && p_event.key.pressed && p_event.key.scancode==KEY_DELETE && !p_event.key.echo) {
+ if (p_event.type == InputEvent::KEY && p_event.key.pressed && p_event.key.scancode == KEY_DELETE && !p_event.key.echo) {
accept_event();
emit_signal("delete_request");
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==2 && p_event.mouse_button.pressed) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == 2 && p_event.mouse_button.pressed) {
- Vector2 pos = Vector2(p_event.mouse_button.x,p_event.mouse_button.y);
- delete_popup->set_pos(get_global_pos()+pos);
+ Vector2 pos = Vector2(p_event.mouse_button.x, p_event.mouse_button.y);
+ delete_popup->set_pos(get_global_pos() + pos);
delete_popup->popup();
}
}
void EditorAudioBus::_delete_pressed(int p_option) {
- if (p_option==1) {
+ if (p_option == 1) {
emit_signal("delete_request");
- } else if (p_option==0) {
+ } else if (p_option == 0) {
//duplicate
- emit_signal("duplicate_request",get_index());
+ emit_signal("duplicate_request", get_index());
}
-
}
+Variant EditorAudioBus::get_drag_data(const Point2 &p_point) {
-Variant EditorAudioBus::get_drag_data(const Point2& p_point) {
-
- if (get_index()==0) {
+ if (get_index() == 0) {
return Variant();
}
Control *c = memnew(Control);
- Panel *p = memnew( Panel );
+ Panel *p = memnew(Panel);
c->add_child(p);
- p->add_style_override("panel",get_stylebox("focus","Button"));
+ p->add_style_override("panel", get_stylebox("focus", "Button"));
p->set_size(get_size());
p->set_pos(-p_point);
set_drag_preview(c);
Dictionary d;
- d["type"]="move_audio_bus";
- d["index"]=get_index();
+ d["type"] = "move_audio_bus";
+ d["index"] = get_index();
emit_signal("drop_end_request");
return d;
}
-bool EditorAudioBus::can_drop_data(const Point2& p_point,const Variant& p_data) const {
+bool EditorAudioBus::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
- if (get_index()==0)
+ if (get_index() == 0)
return false;
- Dictionary d=p_data;
- if (d.has("type") && String(d["type"])=="move_audio_bus") {
+ Dictionary d = p_data;
+ if (d.has("type") && String(d["type"]) == "move_audio_bus") {
return true;
}
return false;
}
-void EditorAudioBus::drop_data(const Point2& p_point,const Variant& p_data) {
-
- Dictionary d=p_data;
- emit_signal("dropped",d["index"],get_index());
+void EditorAudioBus::drop_data(const Point2 &p_point, const Variant &p_data) {
+ Dictionary d = p_data;
+ emit_signal("dropped", d["index"], get_index());
}
-Variant EditorAudioBus::get_drag_data_fw(const Point2& p_point,Control* p_from) {
+Variant EditorAudioBus::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
print_line("drag fw");
TreeItem *item = effects->get_item_at_pos(p_point);
@@ -478,13 +456,13 @@ Variant EditorAudioBus::get_drag_data_fw(const Point2& p_point,Control* p_from)
Variant md = item->get_metadata(0);
- if (md.get_type()==Variant::INT) {
+ if (md.get_type() == Variant::INT) {
Dictionary fxd;
- fxd["type"]="audio_bus_effect";
- fxd["bus"]=get_index();
- fxd["effect"]=md;
+ fxd["type"] = "audio_bus_effect";
+ fxd["bus"] = get_index();
+ fxd["effect"] = md;
- Label *l = memnew( Label );
+ Label *l = memnew(Label);
l->set_text(item->get_text(0));
effects->set_drag_preview(l);
@@ -492,13 +470,12 @@ Variant EditorAudioBus::get_drag_data_fw(const Point2& p_point,Control* p_from)
}
return Variant();
-
}
-bool EditorAudioBus::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{
+bool EditorAudioBus::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
Dictionary d = p_data;
- if (!d.has("type") || String(d["type"])!="audio_bus_effect")
+ if (!d.has("type") || String(d["type"]) != "audio_bus_effect")
return false;
TreeItem *item = effects->get_item_at_pos(p_point);
@@ -510,98 +487,92 @@ bool EditorAudioBus::can_drop_data_fw(const Point2& p_point,const Variant& p_dat
return true;
}
-void EditorAudioBus::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){
+void EditorAudioBus::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
Dictionary d = p_data;
TreeItem *item = effects->get_item_at_pos(p_point);
if (!item)
return;
- int pos=effects->get_drop_section_at_pos(p_point);
+ int pos = effects->get_drop_section_at_pos(p_point);
Variant md = item->get_metadata(0);
int paste_at;
int bus = d["bus"];
int effect = d["effect"];
- if (md.get_type()==Variant::INT) {
- paste_at=md;
- if (pos>0)
+ if (md.get_type() == Variant::INT) {
+ paste_at = md;
+ if (pos > 0)
paste_at++;
- if (bus==get_index() && paste_at >effect) {
+ if (bus == get_index() && paste_at > effect) {
paste_at--;
}
} else {
- paste_at=-1;
+ paste_at = -1;
}
-
- bool enabled = AudioServer::get_singleton()->is_bus_effect_enabled(bus,effect);
+ bool enabled = AudioServer::get_singleton()->is_bus_effect_enabled(bus, effect);
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Move Bus Effect");
- ur->add_do_method(AudioServer::get_singleton(),"remove_bus_effect",bus,effect);
- ur->add_do_method(AudioServer::get_singleton(),"add_bus_effect",get_index(),AudioServer::get_singleton()->get_bus_effect(bus,effect),paste_at);
+ ur->add_do_method(AudioServer::get_singleton(), "remove_bus_effect", bus, effect);
+ ur->add_do_method(AudioServer::get_singleton(), "add_bus_effect", get_index(), AudioServer::get_singleton()->get_bus_effect(bus, effect), paste_at);
- if (paste_at==-1) {
+ if (paste_at == -1) {
paste_at = AudioServer::get_singleton()->get_bus_effect_count(get_index());
- if (bus==get_index()) {
+ if (bus == get_index()) {
paste_at--;
}
}
if (!enabled) {
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_effect_enabled",get_index(),paste_at,false);
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_effect_enabled", get_index(), paste_at, false);
}
- ur->add_undo_method(AudioServer::get_singleton(),"remove_bus_effect",get_index(),paste_at);
- ur->add_undo_method(AudioServer::get_singleton(),"add_bus_effect",bus,AudioServer::get_singleton()->get_bus_effect(bus,effect),effect);
+ ur->add_undo_method(AudioServer::get_singleton(), "remove_bus_effect", get_index(), paste_at);
+ ur->add_undo_method(AudioServer::get_singleton(), "add_bus_effect", bus, AudioServer::get_singleton()->get_bus_effect(bus, effect), effect);
if (!enabled) {
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_effect_enabled",bus,effect,false);
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_effect_enabled", bus, effect, false);
}
- ur->add_do_method(buses,"_update_bus",get_index());
- ur->add_undo_method(buses,"_update_bus",get_index());
- if (get_index()!=bus) {
- ur->add_do_method(buses,"_update_bus",bus);
- ur->add_undo_method(buses,"_update_bus",bus);
+ ur->add_do_method(buses, "_update_bus", get_index());
+ ur->add_undo_method(buses, "_update_bus", get_index());
+ if (get_index() != bus) {
+ ur->add_do_method(buses, "_update_bus", bus);
+ ur->add_undo_method(buses, "_update_bus", bus);
}
ur->commit_action();
-
-
-
}
void EditorAudioBus::_delete_effect_pressed(int p_option) {
- TreeItem * item = effects->get_selected();
+ TreeItem *item = effects->get_selected();
if (!item)
return;
- if (item->get_metadata(0).get_type()!=Variant::INT)
+ if (item->get_metadata(0).get_type() != Variant::INT)
return;
int index = item->get_metadata(0);
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Delete Bus Effect");
- ur->add_do_method(AudioServer::get_singleton(),"remove_bus_effect",get_index(),index);
- ur->add_undo_method(AudioServer::get_singleton(),"add_bus_effect",get_index(),AudioServer::get_singleton()->get_bus_effect(get_index(),index),index);
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_effect_enabled",get_index(),index,AudioServer::get_singleton()->is_bus_effect_enabled(get_index(),index));
- ur->add_do_method(buses,"_update_bus",get_index());
- ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->add_do_method(AudioServer::get_singleton(), "remove_bus_effect", get_index(), index);
+ ur->add_undo_method(AudioServer::get_singleton(), "add_bus_effect", get_index(), AudioServer::get_singleton()->get_bus_effect(get_index(), index), index);
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_effect_enabled", get_index(), index, AudioServer::get_singleton()->is_bus_effect_enabled(get_index(), index));
+ ur->add_do_method(buses, "_update_bus", get_index());
+ ur->add_undo_method(buses, "_update_bus", get_index());
ur->commit_action();
-
-
}
-void EditorAudioBus::_effect_rmb(const Vector2& p_pos) {
+void EditorAudioBus::_effect_rmb(const Vector2 &p_pos) {
- TreeItem * item = effects->get_selected();
+ TreeItem *item = effects->get_selected();
if (!item)
return;
- if (item->get_metadata(0).get_type()!=Variant::INT)
+ if (item->get_metadata(0).get_type() != Variant::INT)
return;
delete_effect_popup->set_pos(get_global_mouse_pos());
@@ -610,172 +581,165 @@ void EditorAudioBus::_effect_rmb(const Vector2& p_pos) {
void EditorAudioBus::_bind_methods() {
- ClassDB::bind_method("update_bus",&EditorAudioBus::update_bus);
- ClassDB::bind_method("update_send",&EditorAudioBus::update_send);
- ClassDB::bind_method("_name_changed",&EditorAudioBus::_name_changed);
- ClassDB::bind_method("_volume_db_changed",&EditorAudioBus::_volume_db_changed);
- ClassDB::bind_method("_solo_toggled",&EditorAudioBus::_solo_toggled);
- ClassDB::bind_method("_mute_toggled",&EditorAudioBus::_mute_toggled);
- ClassDB::bind_method("_bypass_toggled",&EditorAudioBus::_bypass_toggled);
- ClassDB::bind_method("_name_focus_exit",&EditorAudioBus::_name_focus_exit);
- ClassDB::bind_method("_send_selected",&EditorAudioBus::_send_selected);
- ClassDB::bind_method("_effect_edited",&EditorAudioBus::_effect_edited);
- ClassDB::bind_method("_effect_selected",&EditorAudioBus::_effect_selected);
- ClassDB::bind_method("_effect_add",&EditorAudioBus::_effect_add);
- ClassDB::bind_method("_gui_input",&EditorAudioBus::_gui_input);
- ClassDB::bind_method("_delete_pressed",&EditorAudioBus::_delete_pressed);
- ClassDB::bind_method("get_drag_data_fw",&EditorAudioBus::get_drag_data_fw);
- ClassDB::bind_method("can_drop_data_fw",&EditorAudioBus::can_drop_data_fw);
- ClassDB::bind_method("drop_data_fw",&EditorAudioBus::drop_data_fw);
- ClassDB::bind_method("_delete_effect_pressed",&EditorAudioBus::_delete_effect_pressed);
- ClassDB::bind_method("_effect_rmb",&EditorAudioBus::_effect_rmb);
-
-
+ ClassDB::bind_method("update_bus", &EditorAudioBus::update_bus);
+ ClassDB::bind_method("update_send", &EditorAudioBus::update_send);
+ ClassDB::bind_method("_name_changed", &EditorAudioBus::_name_changed);
+ ClassDB::bind_method("_volume_db_changed", &EditorAudioBus::_volume_db_changed);
+ ClassDB::bind_method("_solo_toggled", &EditorAudioBus::_solo_toggled);
+ ClassDB::bind_method("_mute_toggled", &EditorAudioBus::_mute_toggled);
+ ClassDB::bind_method("_bypass_toggled", &EditorAudioBus::_bypass_toggled);
+ ClassDB::bind_method("_name_focus_exit", &EditorAudioBus::_name_focus_exit);
+ ClassDB::bind_method("_send_selected", &EditorAudioBus::_send_selected);
+ ClassDB::bind_method("_effect_edited", &EditorAudioBus::_effect_edited);
+ ClassDB::bind_method("_effect_selected", &EditorAudioBus::_effect_selected);
+ ClassDB::bind_method("_effect_add", &EditorAudioBus::_effect_add);
+ ClassDB::bind_method("_gui_input", &EditorAudioBus::_gui_input);
+ ClassDB::bind_method("_delete_pressed", &EditorAudioBus::_delete_pressed);
+ ClassDB::bind_method("get_drag_data_fw", &EditorAudioBus::get_drag_data_fw);
+ ClassDB::bind_method("can_drop_data_fw", &EditorAudioBus::can_drop_data_fw);
+ ClassDB::bind_method("drop_data_fw", &EditorAudioBus::drop_data_fw);
+ ClassDB::bind_method("_delete_effect_pressed", &EditorAudioBus::_delete_effect_pressed);
+ ClassDB::bind_method("_effect_rmb", &EditorAudioBus::_effect_rmb);
ADD_SIGNAL(MethodInfo("duplicate_request"));
ADD_SIGNAL(MethodInfo("delete_request"));
ADD_SIGNAL(MethodInfo("drop_end_request"));
ADD_SIGNAL(MethodInfo("dropped"));
-
}
EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses) {
- buses=p_buses;
- updating_bus=false;
+ buses = p_buses;
+ updating_bus = false;
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
set_v_size_flags(SIZE_EXPAND_FILL);
- track_name = memnew( LineEdit );
+ track_name = memnew(LineEdit);
vb->add_child(track_name);
- track_name->connect("text_entered",this,"_name_changed");
- track_name->connect("focus_exited",this,"_name_focus_exit");
+ track_name->connect("text_entered", this, "_name_changed");
+ track_name->connect("focus_exited", this, "_name_focus_exit");
- HBoxContainer *hbc = memnew( HBoxContainer);
+ HBoxContainer *hbc = memnew(HBoxContainer);
vb->add_child(hbc);
hbc->add_spacer();
- solo = memnew( ToolButton );
+ solo = memnew(ToolButton);
solo->set_text("S");
solo->set_toggle_mode(true);
- solo->set_modulate(Color(0.8,1.2,0.8));
+ solo->set_modulate(Color(0.8, 1.2, 0.8));
solo->set_focus_mode(FOCUS_NONE);
- solo->connect("pressed",this,"_solo_toggled");
+ solo->connect("pressed", this, "_solo_toggled");
hbc->add_child(solo);
- mute = memnew( ToolButton );
+ mute = memnew(ToolButton);
mute->set_text("M");
mute->set_toggle_mode(true);
- mute->set_modulate(Color(1.2,0.8,0.8));
+ mute->set_modulate(Color(1.2, 0.8, 0.8));
mute->set_focus_mode(FOCUS_NONE);
- mute->connect("pressed",this,"_mute_toggled");
+ mute->connect("pressed", this, "_mute_toggled");
hbc->add_child(mute);
- bypass = memnew( ToolButton );
+ bypass = memnew(ToolButton);
bypass->set_text("B");
bypass->set_toggle_mode(true);
- bypass->set_modulate(Color(1.1,1.1,0.8));
+ bypass->set_modulate(Color(1.1, 1.1, 0.8));
bypass->set_focus_mode(FOCUS_NONE);
- bypass->connect("pressed",this,"_bypass_toggled");
+ bypass->connect("pressed", this, "_bypass_toggled");
hbc->add_child(bypass);
hbc->add_spacer();
- HBoxContainer *hb = memnew( HBoxContainer );
+ HBoxContainer *hb = memnew(HBoxContainer);
vb->add_child(hb);
- slider = memnew( VSlider );
+ slider = memnew(VSlider);
slider->set_min(-80);
slider->set_max(24);
slider->set_step(0.1);
- slider->connect("value_changed",this,"_volume_db_changed");
+ slider->connect("value_changed", this, "_volume_db_changed");
hb->add_child(slider);
- vu_l = memnew( TextureProgress );
+ vu_l = memnew(TextureProgress);
vu_l->set_fill_mode(TextureProgress::FILL_BOTTOM_TO_TOP);
hb->add_child(vu_l);
vu_l->set_min(-80);
vu_l->set_max(24);
vu_l->set_step(0.1);
- vu_r = memnew( TextureProgress );
+ vu_r = memnew(TextureProgress);
vu_r->set_fill_mode(TextureProgress::FILL_BOTTOM_TO_TOP);
hb->add_child(vu_r);
vu_r->set_min(-80);
vu_r->set_max(24);
vu_r->set_step(0.1);
- scale = memnew( TextureRect );
+ scale = memnew(TextureRect);
hb->add_child(scale);
//add_child(hb);
- effects = memnew( Tree );
+ effects = memnew(Tree);
effects->set_hide_root(true);
- effects->set_custom_minimum_size(Size2(0,90)*EDSCALE);
+ effects->set_custom_minimum_size(Size2(0, 90) * EDSCALE);
effects->set_hide_folding(true);
vb->add_child(effects);
- effects->connect("item_edited",this,"_effect_edited");
- effects->connect("cell_selected",this,"_effect_selected");
+ effects->connect("item_edited", this, "_effect_edited");
+ effects->connect("cell_selected", this, "_effect_selected");
effects->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
effects->set_drag_forwarding(this);
- effects->connect("item_rmb_selected",this,"_effect_rmb");
+ effects->connect("item_rmb_selected", this, "_effect_rmb");
effects->set_allow_rmb_select(true);
- send = memnew( OptionButton );
+ send = memnew(OptionButton);
send->set_clip_text(true);
- send->connect("item_selected",this,"_send_selected");
+ send->connect("item_selected", this, "_send_selected");
vb->add_child(send);
set_focus_mode(FOCUS_CLICK);
- effect_options = memnew( PopupMenu );
- effect_options->connect("index_pressed",this,"_effect_add");
+ effect_options = memnew(PopupMenu);
+ effect_options->connect("index_pressed", this, "_effect_add");
add_child(effect_options);
List<StringName> effects;
- ClassDB::get_inheriters_from_class("AudioEffect",&effects);
+ ClassDB::get_inheriters_from_class("AudioEffect", &effects);
effects.sort_custom<StringName::AlphCompare>();
- for (List<StringName>::Element *E=effects.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = effects.front(); E; E = E->next()) {
if (!ClassDB::can_instance(E->get()))
continue;
Ref<Texture> icon;
- if (has_icon(E->get(),"EditorIcons")) {
- icon = get_icon(E->get(),"EditorIcons");
+ if (has_icon(E->get(), "EditorIcons")) {
+ icon = get_icon(E->get(), "EditorIcons");
}
- String name = E->get().operator String().replace("AudioEffect","");
+ String name = E->get().operator String().replace("AudioEffect", "");
effect_options->add_item(name);
- effect_options->set_item_metadata(effect_options->get_item_count()-1,E->get());
- effect_options->set_item_icon(effect_options->get_item_count()-1,icon);
+ effect_options->set_item_metadata(effect_options->get_item_count() - 1, E->get());
+ effect_options->set_item_icon(effect_options->get_item_count() - 1, icon);
}
- delete_popup = memnew( PopupMenu );
+ delete_popup = memnew(PopupMenu);
delete_popup->add_item("Duplicate");
delete_popup->add_item("Delete");
add_child(delete_popup);
- delete_popup->connect("index_pressed",this,"_delete_pressed");
+ delete_popup->connect("index_pressed", this, "_delete_pressed");
- delete_effect_popup = memnew( PopupMenu );
+ delete_effect_popup = memnew(PopupMenu);
delete_effect_popup->add_item("Delete Effect");
add_child(delete_effect_popup);
- delete_effect_popup->connect("index_pressed",this,"_delete_effect_pressed");
-
+ delete_effect_popup->connect("index_pressed", this, "_delete_effect_pressed");
}
+bool EditorAudioBusDrop::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
-
-bool EditorAudioBusDrop::can_drop_data(const Point2& p_point,const Variant& p_data) const {
-
- Dictionary d=p_data;
- if (d.has("type") && String(d["type"])=="move_audio_bus") {
+ Dictionary d = p_data;
+ if (d.has("type") && String(d["type"]) == "move_audio_bus") {
return true;
}
return false;
}
-void EditorAudioBusDrop::drop_data(const Point2& p_point,const Variant& p_data){
-
- Dictionary d=p_data;
- emit_signal("dropped",d["index"],-1);
+void EditorAudioBusDrop::drop_data(const Point2 &p_point, const Variant &p_data) {
+ Dictionary d = p_data;
+ emit_signal("dropped", d["index"], -1);
}
void EditorAudioBusDrop::_bind_methods() {
@@ -784,65 +748,59 @@ void EditorAudioBusDrop::_bind_methods() {
}
EditorAudioBusDrop::EditorAudioBusDrop() {
-
-
}
-
void EditorAudioBuses::_update_buses() {
- while(bus_hb->get_child_count()>0) {
+ while (bus_hb->get_child_count() > 0) {
memdelete(bus_hb->get_child(0));
}
- drop_end=NULL;
+ drop_end = NULL;
- for(int i=0;i<AudioServer::get_singleton()->get_bus_count();i++) {
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
- EditorAudioBus *audio_bus = memnew( EditorAudioBus(this) );
- if (i==0) {
- audio_bus->set_self_modulate(Color(1,0.9,0.9));
+ EditorAudioBus *audio_bus = memnew(EditorAudioBus(this));
+ if (i == 0) {
+ audio_bus->set_self_modulate(Color(1, 0.9, 0.9));
}
bus_hb->add_child(audio_bus);
- audio_bus->connect("delete_request",this,"_delete_bus",varray(audio_bus),CONNECT_DEFERRED);
- audio_bus->connect("duplicate_request",this,"_duplicate_bus",varray(),CONNECT_DEFERRED);
- audio_bus->connect("drop_end_request",this,"_request_drop_end");
- audio_bus->connect("dropped",this,"_drop_at_index",varray(),CONNECT_DEFERRED);
-
-
-
+ audio_bus->connect("delete_request", this, "_delete_bus", varray(audio_bus), CONNECT_DEFERRED);
+ audio_bus->connect("duplicate_request", this, "_duplicate_bus", varray(), CONNECT_DEFERRED);
+ audio_bus->connect("drop_end_request", this, "_request_drop_end");
+ audio_bus->connect("dropped", this, "_drop_at_index", varray(), CONNECT_DEFERRED);
}
}
EditorAudioBuses *EditorAudioBuses::register_editor() {
- EditorAudioBuses * audio_buses = memnew( EditorAudioBuses );
- EditorNode::get_singleton()->add_bottom_panel_item("Audio",audio_buses);
+ EditorAudioBuses *audio_buses = memnew(EditorAudioBuses);
+ EditorNode::get_singleton()->add_bottom_panel_item("Audio", audio_buses);
return audio_buses;
}
void EditorAudioBuses::_notification(int p_what) {
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
_update_buses();
}
- if (p_what==NOTIFICATION_DRAG_END) {
+ if (p_what == NOTIFICATION_DRAG_END) {
if (drop_end) {
drop_end->queue_delete();
- drop_end=NULL;
+ drop_end = NULL;
}
}
- if (p_what==NOTIFICATION_PROCESS) {
+ if (p_what == NOTIFICATION_PROCESS) {
//check if anything was edited
bool edited = AudioServer::get_singleton()->is_edited();
- for(int i=0;i<AudioServer::get_singleton()->get_bus_count();i++) {
- for(int j=0;j<AudioServer::get_singleton()->get_bus_effect_count(i);j++) {
- Ref<AudioEffect> effect = AudioServer::get_singleton()->get_bus_effect(i,j);
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
+ for (int j = 0; j < AudioServer::get_singleton()->get_bus_effect_count(i); j++) {
+ Ref<AudioEffect> effect = AudioServer::get_singleton()->get_bus_effect(i, j);
if (effect->is_edited()) {
- edited=true;
+ edited = true;
effect->set_edited(false);
}
}
@@ -855,27 +813,24 @@ void EditorAudioBuses::_notification(int p_what) {
save_timer->start();
}
}
-
}
-
void EditorAudioBuses::_add_bus() {
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
//need to simulate new name, so we can undi :(
ur->create_action("Add Audio Bus");
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_count",AudioServer::get_singleton()->get_bus_count()+1);
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_count",AudioServer::get_singleton()->get_bus_count());
- ur->add_do_method(this,"_update_buses");
- ur->add_undo_method(this,"_update_buses");
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_count", AudioServer::get_singleton()->get_bus_count() + 1);
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_count", AudioServer::get_singleton()->get_bus_count());
+ ur->add_do_method(this, "_update_buses");
+ ur->add_undo_method(this, "_update_buses");
ur->commit_action();
-
}
void EditorAudioBuses::_update_bus(int p_index) {
- if (p_index>=bus_hb->get_child_count())
+ if (p_index >= bus_hb->get_child_count())
return;
bus_hb->get_child(p_index)->call("update_bus");
@@ -883,109 +838,103 @@ void EditorAudioBuses::_update_bus(int p_index) {
void EditorAudioBuses::_update_sends() {
- for(int i=0;i<bus_hb->get_child_count();i++) {
+ for (int i = 0; i < bus_hb->get_child_count(); i++) {
bus_hb->get_child(i)->call("update_send");
}
}
-void EditorAudioBuses::_delete_bus(Object* p_which) {
+void EditorAudioBuses::_delete_bus(Object *p_which) {
EditorAudioBus *bus = p_which->cast_to<EditorAudioBus>();
int index = bus->get_index();
- if (index==0) {
+ if (index == 0) {
EditorNode::get_singleton()->show_warning("Master bus can't be deleted!");
return;
}
-
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Delete Audio Bus");
- ur->add_do_method(AudioServer::get_singleton(),"remove_bus",index);
- ur->add_undo_method(AudioServer::get_singleton(),"add_bus",index);
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_name",index,AudioServer::get_singleton()->get_bus_name(index));
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_volume_db",index,AudioServer::get_singleton()->get_bus_volume_db(index));
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_send",index,AudioServer::get_singleton()->get_bus_send(index));
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_solo",index,AudioServer::get_singleton()->is_bus_solo(index));
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_mute",index,AudioServer::get_singleton()->is_bus_mute(index));
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_bypass_effects",index,AudioServer::get_singleton()->is_bus_bypassing_effects(index));
- for(int i=0;i<AudioServer::get_singleton()->get_bus_effect_count(index);i++) {
-
- ur->add_undo_method(AudioServer::get_singleton(),"add_bus_effect",index,AudioServer::get_singleton()->get_bus_effect(index,i));
- ur->add_undo_method(AudioServer::get_singleton(),"set_bus_effect_enabled",index,i,AudioServer::get_singleton()->is_bus_effect_enabled(index,i));
+ ur->add_do_method(AudioServer::get_singleton(), "remove_bus", index);
+ ur->add_undo_method(AudioServer::get_singleton(), "add_bus", index);
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_name", index, AudioServer::get_singleton()->get_bus_name(index));
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_volume_db", index, AudioServer::get_singleton()->get_bus_volume_db(index));
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_send", index, AudioServer::get_singleton()->get_bus_send(index));
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_solo", index, AudioServer::get_singleton()->is_bus_solo(index));
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_mute", index, AudioServer::get_singleton()->is_bus_mute(index));
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_bypass_effects", index, AudioServer::get_singleton()->is_bus_bypassing_effects(index));
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_effect_count(index); i++) {
+
+ ur->add_undo_method(AudioServer::get_singleton(), "add_bus_effect", index, AudioServer::get_singleton()->get_bus_effect(index, i));
+ ur->add_undo_method(AudioServer::get_singleton(), "set_bus_effect_enabled", index, i, AudioServer::get_singleton()->is_bus_effect_enabled(index, i));
}
- ur->add_do_method(this,"_update_buses");
- ur->add_undo_method(this,"_update_buses");
+ ur->add_do_method(this, "_update_buses");
+ ur->add_undo_method(this, "_update_buses");
ur->commit_action();
-
}
-
void EditorAudioBuses::_duplicate_bus(int p_which) {
- int add_at_pos = p_which+1;
+ int add_at_pos = p_which + 1;
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Duplicate Audio Bus");
- ur->add_do_method(AudioServer::get_singleton(),"add_bus",add_at_pos);
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_name",add_at_pos,AudioServer::get_singleton()->get_bus_name(p_which)+" Copy");
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_volume_db",add_at_pos,AudioServer::get_singleton()->get_bus_volume_db(p_which));
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_send",add_at_pos,AudioServer::get_singleton()->get_bus_send(p_which));
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_solo",add_at_pos,AudioServer::get_singleton()->is_bus_solo(p_which));
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_mute",add_at_pos,AudioServer::get_singleton()->is_bus_mute(p_which));
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_bypass_effects",add_at_pos,AudioServer::get_singleton()->is_bus_bypassing_effects(p_which));
- for(int i=0;i<AudioServer::get_singleton()->get_bus_effect_count(p_which);i++) {
-
- ur->add_do_method(AudioServer::get_singleton(),"add_bus_effect",add_at_pos,AudioServer::get_singleton()->get_bus_effect(p_which,i));
- ur->add_do_method(AudioServer::get_singleton(),"set_bus_effect_enabled",add_at_pos,i,AudioServer::get_singleton()->is_bus_effect_enabled(p_which,i));
+ ur->add_do_method(AudioServer::get_singleton(), "add_bus", add_at_pos);
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_name", add_at_pos, AudioServer::get_singleton()->get_bus_name(p_which) + " Copy");
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_volume_db", add_at_pos, AudioServer::get_singleton()->get_bus_volume_db(p_which));
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_send", add_at_pos, AudioServer::get_singleton()->get_bus_send(p_which));
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_solo", add_at_pos, AudioServer::get_singleton()->is_bus_solo(p_which));
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_mute", add_at_pos, AudioServer::get_singleton()->is_bus_mute(p_which));
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_bypass_effects", add_at_pos, AudioServer::get_singleton()->is_bus_bypassing_effects(p_which));
+ for (int i = 0; i < AudioServer::get_singleton()->get_bus_effect_count(p_which); i++) {
+
+ ur->add_do_method(AudioServer::get_singleton(), "add_bus_effect", add_at_pos, AudioServer::get_singleton()->get_bus_effect(p_which, i));
+ ur->add_do_method(AudioServer::get_singleton(), "set_bus_effect_enabled", add_at_pos, i, AudioServer::get_singleton()->is_bus_effect_enabled(p_which, i));
}
- ur->add_undo_method(AudioServer::get_singleton(),"remove_bus",add_at_pos);
- ur->add_do_method(this,"_update_buses");
- ur->add_undo_method(this,"_update_buses");
+ ur->add_undo_method(AudioServer::get_singleton(), "remove_bus", add_at_pos);
+ ur->add_do_method(this, "_update_buses");
+ ur->add_undo_method(this, "_update_buses");
ur->commit_action();
-
}
void EditorAudioBuses::_request_drop_end() {
if (!drop_end && bus_hb->get_child_count()) {
- drop_end = memnew( EditorAudioBusDrop );
+ drop_end = memnew(EditorAudioBusDrop);
bus_hb->add_child(drop_end);
drop_end->set_custom_minimum_size(bus_hb->get_child(0)->cast_to<Control>()->get_size());
- drop_end->connect("dropped",this,"_drop_at_index",varray(),CONNECT_DEFERRED);
+ drop_end->connect("dropped", this, "_drop_at_index", varray(), CONNECT_DEFERRED);
}
}
-void EditorAudioBuses::_drop_at_index(int p_bus,int p_index) {
-
+void EditorAudioBuses::_drop_at_index(int p_bus, int p_index) {
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
//need to simulate new name, so we can undi :(
ur->create_action("Move Audio Bus");
- ur->add_do_method(AudioServer::get_singleton(),"move_bus",p_bus,p_index);
+ ur->add_do_method(AudioServer::get_singleton(), "move_bus", p_bus, p_index);
int final_pos;
- if (p_index==p_bus) {
- final_pos=p_bus;
- } else if (p_index==-1) {
- final_pos = AudioServer::get_singleton()->get_bus_count()-1;
- } else if (p_index<p_bus) {
+ if (p_index == p_bus) {
+ final_pos = p_bus;
+ } else if (p_index == -1) {
+ final_pos = AudioServer::get_singleton()->get_bus_count() - 1;
+ } else if (p_index < p_bus) {
final_pos = p_index;
} else {
- final_pos = p_index -1;
+ final_pos = p_index - 1;
}
- ur->add_undo_method(AudioServer::get_singleton(),"move_bus",final_pos,p_bus);
+ ur->add_undo_method(AudioServer::get_singleton(), "move_bus", final_pos, p_bus);
- ur->add_do_method(this,"_update_buses");
- ur->add_undo_method(this,"_update_buses");
+ ur->add_do_method(this, "_update_buses");
+ ur->add_undo_method(this, "_update_buses");
ur->commit_action();
}
void EditorAudioBuses::_server_save() {
Ref<AudioBusLayout> state = AudioServer::get_singleton()->generate_bus_layout();
- ResourceSaver::save(edited_path,state);
-
+ ResourceSaver::save(edited_path, state);
}
void EditorAudioBuses::_select_layout() {
@@ -999,17 +948,16 @@ void EditorAudioBuses::_save_as_layout() {
file_dialog->set_title(TTR("Save Audio Bus Layout As.."));
file_dialog->set_current_path(edited_path);
file_dialog->popup_centered_ratio();
- new_layout=false;
+ new_layout = false;
}
-
void EditorAudioBuses::_new_layout() {
file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
file_dialog->set_title(TTR("Location for New Layout.."));
file_dialog->set_current_path(edited_path);
file_dialog->popup_centered_ratio();
- new_layout=true;
+ new_layout = true;
}
void EditorAudioBuses::_load_layout() {
@@ -1018,20 +966,18 @@ void EditorAudioBuses::_load_layout() {
file_dialog->set_title(TTR("Open Audio Bus Layout"));
file_dialog->set_current_path(edited_path);
file_dialog->popup_centered_ratio();
- new_layout=false;
+ new_layout = false;
}
-
void EditorAudioBuses::_load_default_layout() {
-
Ref<AudioBusLayout> state = ResourceLoader::load("res://default_bus_layout.tres");
if (state.is_null()) {
EditorNode::get_singleton()->show_warning("There is no 'res://default_bus_layout.tres' file.");
return;
}
- edited_path="res://default_bus_layout.tres";
+ edited_path = "res://default_bus_layout.tres";
file->set_text(edited_path.get_file());
AudioServer::get_singleton()->set_bus_layout(state);
_update_buses();
@@ -1039,23 +985,23 @@ void EditorAudioBuses::_load_default_layout() {
call_deferred("_select_layout");
}
-void EditorAudioBuses::_file_dialog_callback(const String& p_string) {
+void EditorAudioBuses::_file_dialog_callback(const String &p_string) {
- if (file_dialog->get_mode()==EditorFileDialog::MODE_OPEN_FILE) {
+ if (file_dialog->get_mode() == EditorFileDialog::MODE_OPEN_FILE) {
Ref<AudioBusLayout> state = ResourceLoader::load(p_string);
if (state.is_null()) {
EditorNode::get_singleton()->show_warning("Invalid file, not an audio bus layout.");
return;
}
- edited_path=p_string;
+ edited_path = p_string;
file->set_text(p_string.get_file());
AudioServer::get_singleton()->set_bus_layout(state);
_update_buses();
EditorNode::get_singleton()->get_undo_redo()->clear_history();
call_deferred("_select_layout");
- } else if (file_dialog->get_mode()==EditorFileDialog::MODE_SAVE_FILE) {
+ } else if (file_dialog->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
if (new_layout) {
Ref<AudioBusLayout> empty_state;
@@ -1063,116 +1009,111 @@ void EditorAudioBuses::_file_dialog_callback(const String& p_string) {
AudioServer::get_singleton()->set_bus_layout(empty_state);
}
- Error err = ResourceSaver::save(p_string,AudioServer::get_singleton()->generate_bus_layout());
+ Error err = ResourceSaver::save(p_string, AudioServer::get_singleton()->generate_bus_layout());
- if (err!=OK) {
- EditorNode::get_singleton()->show_warning("Error saving file: "+p_string);
+ if (err != OK) {
+ EditorNode::get_singleton()->show_warning("Error saving file: " + p_string);
return;
}
- edited_path=p_string;
+ edited_path = p_string;
file->set_text(p_string.get_file());
_update_buses();
EditorNode::get_singleton()->get_undo_redo()->clear_history();
call_deferred("_select_layout");
}
-
}
void EditorAudioBuses::_bind_methods() {
- ClassDB::bind_method("_add_bus",&EditorAudioBuses::_add_bus);
- ClassDB::bind_method("_update_buses",&EditorAudioBuses::_update_buses);
- ClassDB::bind_method("_update_bus",&EditorAudioBuses::_update_bus);
- ClassDB::bind_method("_update_sends",&EditorAudioBuses::_update_sends);
- ClassDB::bind_method("_delete_bus",&EditorAudioBuses::_delete_bus);
- ClassDB::bind_method("_request_drop_end",&EditorAudioBuses::_request_drop_end);
- ClassDB::bind_method("_drop_at_index",&EditorAudioBuses::_drop_at_index);
- ClassDB::bind_method("_server_save",&EditorAudioBuses::_server_save);
- ClassDB::bind_method("_select_layout",&EditorAudioBuses::_select_layout);
- ClassDB::bind_method("_save_as_layout",&EditorAudioBuses::_save_as_layout);
- ClassDB::bind_method("_load_layout",&EditorAudioBuses::_load_layout);
- ClassDB::bind_method("_load_default_layout",&EditorAudioBuses::_load_default_layout);
- ClassDB::bind_method("_new_layout",&EditorAudioBuses::_new_layout);
- ClassDB::bind_method("_duplicate_bus",&EditorAudioBuses::_duplicate_bus);
-
- ClassDB::bind_method("_file_dialog_callback",&EditorAudioBuses::_file_dialog_callback);
+ ClassDB::bind_method("_add_bus", &EditorAudioBuses::_add_bus);
+ ClassDB::bind_method("_update_buses", &EditorAudioBuses::_update_buses);
+ ClassDB::bind_method("_update_bus", &EditorAudioBuses::_update_bus);
+ ClassDB::bind_method("_update_sends", &EditorAudioBuses::_update_sends);
+ ClassDB::bind_method("_delete_bus", &EditorAudioBuses::_delete_bus);
+ ClassDB::bind_method("_request_drop_end", &EditorAudioBuses::_request_drop_end);
+ ClassDB::bind_method("_drop_at_index", &EditorAudioBuses::_drop_at_index);
+ ClassDB::bind_method("_server_save", &EditorAudioBuses::_server_save);
+ ClassDB::bind_method("_select_layout", &EditorAudioBuses::_select_layout);
+ ClassDB::bind_method("_save_as_layout", &EditorAudioBuses::_save_as_layout);
+ ClassDB::bind_method("_load_layout", &EditorAudioBuses::_load_layout);
+ ClassDB::bind_method("_load_default_layout", &EditorAudioBuses::_load_default_layout);
+ ClassDB::bind_method("_new_layout", &EditorAudioBuses::_new_layout);
+ ClassDB::bind_method("_duplicate_bus", &EditorAudioBuses::_duplicate_bus);
+
+ ClassDB::bind_method("_file_dialog_callback", &EditorAudioBuses::_file_dialog_callback);
}
-EditorAudioBuses::EditorAudioBuses()
-{
+EditorAudioBuses::EditorAudioBuses() {
drop_end = NULL;
- top_hb = memnew( HBoxContainer );
+ top_hb = memnew(HBoxContainer);
add_child(top_hb);
- add = memnew( Button );
- top_hb->add_child(add);;
+ add = memnew(Button);
+ top_hb->add_child(add);
+ ;
add->set_text(TTR("Add Bus"));
- add->connect("pressed",this,"_add_bus");
-
-
+ add->connect("pressed", this, "_add_bus");
top_hb->add_spacer();
- file = memnew( ToolButton );
+ file = memnew(ToolButton);
file->set_text("default_bus_layout.tres");
top_hb->add_child(file);
- file->connect("pressed",this,"_select_layout");
+ file->connect("pressed", this, "_select_layout");
- load = memnew( Button );
+ load = memnew(Button);
load->set_text(TTR("Load"));
top_hb->add_child(load);
- load->connect("pressed",this,"_load_layout");
+ load->connect("pressed", this, "_load_layout");
- save_as = memnew( Button );
+ save_as = memnew(Button);
save_as->set_text(TTR("Save As"));
top_hb->add_child(save_as);
- save_as->connect("pressed",this,"_save_as_layout");
+ save_as->connect("pressed", this, "_save_as_layout");
- _default = memnew( Button );
+ _default = memnew(Button);
_default->set_text(TTR("Default"));
top_hb->add_child(_default);
- _default->connect("pressed",this,"_load_default_layout");
+ _default->connect("pressed", this, "_load_default_layout");
- _new = memnew( Button );
+ _new = memnew(Button);
_new->set_text(TTR("Create"));
top_hb->add_child(_new);
- _new->connect("pressed",this,"_new_layout");
+ _new->connect("pressed", this, "_new_layout");
- bus_scroll = memnew( ScrollContainer );
+ bus_scroll = memnew(ScrollContainer);
bus_scroll->set_v_size_flags(SIZE_EXPAND_FILL);
bus_scroll->set_enable_h_scroll(true);
bus_scroll->set_enable_v_scroll(false);
add_child(bus_scroll);
- bus_hb = memnew( HBoxContainer );
+ bus_hb = memnew(HBoxContainer);
bus_scroll->add_child(bus_hb);
- save_timer=memnew(Timer);
+ save_timer = memnew(Timer);
save_timer->set_wait_time(0.8);
save_timer->set_one_shot(true);
add_child(save_timer);
- save_timer->connect("timeout",this,"_server_save");
+ save_timer->connect("timeout", this, "_server_save");
set_v_size_flags(SIZE_EXPAND_FILL);
-
edited_path = "res://default_bus_layout.tres";
- file_dialog = memnew( EditorFileDialog );
+ file_dialog = memnew(EditorFileDialog);
List<String> ext;
- ResourceLoader::get_recognized_extensions_for_type("AudioServerState",&ext);
- for (List<String>::Element *E=ext.front();E;E=E->next()) {
- file_dialog->add_filter("*."+E->get()+"; Audio Bus State");
+ ResourceLoader::get_recognized_extensions_for_type("AudioServerState", &ext);
+ for (List<String>::Element *E = ext.front(); E; E = E->next()) {
+ file_dialog->add_filter("*." + E->get() + "; Audio Bus State");
}
add_child(file_dialog);
- file_dialog->connect("file_selected",this,"_file_dialog_callback");
+ file_dialog->connect("file_selected", this, "_file_dialog_callback");
set_process(true);
-
}
-void EditorAudioBuses::open_layout(const String& p_path) {
+void EditorAudioBuses::open_layout(const String &p_path) {
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
@@ -1182,7 +1123,7 @@ void EditorAudioBuses::open_layout(const String& p_path) {
return;
}
- edited_path=p_path;
+ edited_path = p_path;
file->set_text(p_path.get_file());
AudioServer::get_singleton()->set_bus_layout(state);
_update_buses();
@@ -1203,19 +1144,16 @@ void AudioBusesEditorPlugin::edit(Object *p_node) {
bool AudioBusesEditorPlugin::handles(Object *p_node) const {
- return (p_node->cast_to<AudioBusLayout>()!=NULL);
+ return (p_node->cast_to<AudioBusLayout>() != NULL);
}
-void AudioBusesEditorPlugin::make_visible(bool p_visible){
-
-
+void AudioBusesEditorPlugin::make_visible(bool p_visible) {
}
AudioBusesEditorPlugin::AudioBusesEditorPlugin(EditorAudioBuses *p_node) {
- audio_bus_editor=p_node;
+ audio_bus_editor = p_node;
}
AudioBusesEditorPlugin::~AudioBusesEditorPlugin() {
-
}
diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h
index 8f9e327368..06a9c01bf0 100644
--- a/editor/editor_audio_buses.h
+++ b/editor/editor_audio_buses.h
@@ -29,27 +29,26 @@
#ifndef EDITORAUDIOBUSES_H
#define EDITORAUDIOBUSES_H
-
+#include "editor/editor_file_dialog.h"
+#include "editor_plugin.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
-#include "scene/gui/tool_button.h"
-#include "scene/gui/scroll_container.h"
+#include "scene/gui/line_edit.h"
+#include "scene/gui/option_button.h"
+#include "scene/gui/panel.h"
#include "scene/gui/panel_container.h"
+#include "scene/gui/scroll_container.h"
#include "scene/gui/slider.h"
#include "scene/gui/texture_progress.h"
#include "scene/gui/texture_rect.h"
-#include "scene/gui/line_edit.h"
+#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
-#include "scene/gui/option_button.h"
-#include "scene/gui/panel.h"
-#include "editor/editor_file_dialog.h"
-#include "editor_plugin.h"
class EditorAudioBuses;
class EditorAudioBus : public PanelContainer {
- GDCLASS( EditorAudioBus, PanelContainer )
+ GDCLASS(EditorAudioBus, PanelContainer)
bool prev_active;
float peak_l;
@@ -75,10 +74,10 @@ class EditorAudioBus : public PanelContainer {
bool updating_bus;
- void _gui_input(const InputEvent& p_event);
+ void _gui_input(const InputEvent &p_event);
void _delete_pressed(int p_option);
- void _name_changed(const String& p_new_name);
+ void _name_changed(const String &p_new_name);
void _name_focus_exit() { _name_changed(track_name->get_text()); }
void _volume_db_changed(float p_db);
void _solo_toggled();
@@ -89,52 +88,48 @@ class EditorAudioBus : public PanelContainer {
void _effect_add(int p_which);
void _effect_selected();
void _delete_effect_pressed(int p_option);
- void _effect_rmb(const Vector2& p_pos);
-
-
- 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 _effect_rmb(const Vector2 &p_pos);
+ 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);
- Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
- bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
- void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
-friend class EditorAudioBuses;
+ friend class EditorAudioBuses;
EditorAudioBuses *buses;
protected:
-
static void _bind_methods();
void _notification(int p_what);
-public:
+public:
void update_bus();
void update_send();
- EditorAudioBus(EditorAudioBuses *p_buses=NULL);
+ EditorAudioBus(EditorAudioBuses *p_buses = NULL);
};
-
class EditorAudioBusDrop : public Panel {
- GDCLASS(EditorAudioBusDrop,Panel);
+ GDCLASS(EditorAudioBusDrop, Panel);
- 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);
-protected:
+ 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);
+protected:
static void _bind_methods();
-public:
+public:
EditorAudioBusDrop();
};
-class EditorAudioBuses : public VBoxContainer {
+class EditorAudioBuses : public VBoxContainer {
- GDCLASS(EditorAudioBuses,VBoxContainer)
+ GDCLASS(EditorAudioBuses, VBoxContainer)
HBoxContainer *top_hb;
@@ -158,12 +153,11 @@ class EditorAudioBuses : public VBoxContainer {
void _update_bus(int p_index);
void _update_sends();
- void _delete_bus(Object* p_which);
+ void _delete_bus(Object *p_which);
void _duplicate_bus(int p_which);
-
void _request_drop_end();
- void _drop_at_index(int p_bus,int p_index);
+ void _drop_at_index(int p_bus, int p_index);
void _server_save();
@@ -176,30 +170,27 @@ class EditorAudioBuses : public VBoxContainer {
EditorFileDialog *file_dialog;
bool new_layout;
- void _file_dialog_callback(const String& p_string);
+ void _file_dialog_callback(const String &p_string);
protected:
-
static void _bind_methods();
void _notification(int p_what);
-public:
- void open_layout(const String& p_path);
+public:
+ void open_layout(const String &p_path);
- static EditorAudioBuses* register_editor();
+ static EditorAudioBuses *register_editor();
EditorAudioBuses();
};
-
-
class AudioBusesEditorPlugin : public EditorPlugin {
- GDCLASS( AudioBusesEditorPlugin, EditorPlugin );
+ GDCLASS(AudioBusesEditorPlugin, EditorPlugin);
EditorAudioBuses *audio_bus_editor;
-public:
+public:
virtual String get_name() const { return "SampleLibrary"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -208,7 +199,6 @@ public:
AudioBusesEditorPlugin(EditorAudioBuses *p_node);
~AudioBusesEditorPlugin();
-
};
#endif // EDITORAUDIOBUSES_H
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 3e3362f515..67e8c63e51 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -28,9 +28,9 @@
/*************************************************************************/
#include "editor_autoload_settings.h"
+#include "editor_node.h"
#include "global_config.h"
#include "global_constants.h"
-#include "editor_node.h"
#define PREVIEW_LIST_MAX_SIZE 10
@@ -51,11 +51,11 @@ void EditorAutoloadSettings::_notification(int p_what) {
}
}
-bool EditorAutoloadSettings::_autoload_name_is_valid(const String& p_name, String* r_error) {
+bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, String *r_error) {
if (!p_name.is_valid_identifier()) {
if (r_error)
- *r_error = TTR("Invalid name.") + "\n" + TTR("Valid characters:")+" a-z, A-Z, 0-9 or _";
+ *r_error = TTR("Invalid name.") + "\n" + TTR("Valid characters:") + " a-z, A-Z, 0-9 or _";
return false;
}
@@ -68,7 +68,7 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String& p_name, Strin
}
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- if (Variant::get_type_name( Variant::Type(i) ) == p_name) {
+ if (Variant::get_type_name(Variant::Type(i)) == p_name) {
if (r_error)
*r_error = TTR("Invalid name. Must not collide with an existing buit-in type name.");
@@ -105,13 +105,13 @@ void EditorAutoloadSettings::_autoload_add() {
}
if (!path.begins_with("res://")) {
- EditorNode::get_singleton()->show_warning(TTR("Invalid Path.") + "\n"+ TTR("Not in resource path."));
+ EditorNode::get_singleton()->show_warning(TTR("Invalid Path.") + "\n" + TTR("Not in resource path."));
return;
}
name = "autoload/" + name;
- UndoRedo* undo_redo = EditorNode::get_singleton()->get_undo_redo();
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
undo_redo->create_action(TTR("Add AutoLoad"));
undo_redo->add_do_property(GlobalConfig::get_singleton(), name, "*" + path);
@@ -220,8 +220,8 @@ void EditorAutoloadSettings::_autoload_edited() {
undo_redo->add_do_property(GlobalConfig::get_singleton(), base, path);
undo_redo->add_undo_property(GlobalConfig::get_singleton(), base, GlobalConfig::get_singleton()->get(base));
- undo_redo->add_do_method(GlobalConfig::get_singleton(),"set_order", base, order);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(),"set_order", base, order);
+ undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", base, order);
+ undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", base, order);
undo_redo->add_do_method(this, "update_autoload");
undo_redo->add_undo_method(this, "update_autoload");
@@ -245,7 +245,7 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu
switch (p_button) {
- case BUTTON_MOVE_UP:
+ case BUTTON_MOVE_UP:
case BUTTON_MOVE_DOWN: {
TreeItem *swap = NULL;
@@ -303,7 +303,7 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu
}
}
-void EditorAutoloadSettings::_autoload_file_callback(const String& p_path) {
+void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) {
autoload_add_name->set_text(p_path.get_file().get_basename());
}
@@ -361,16 +361,16 @@ void EditorAutoloadSettings::update_autoload() {
item->set_text(2, TTR("Enable"));
item->set_checked(2, global);
- item->add_button(3, get_icon("MoveUp","EditorIcons"), BUTTON_MOVE_UP);
- item->add_button(3, get_icon("MoveDown","EditorIcons"), BUTTON_MOVE_DOWN);
- item->add_button(3, get_icon("Del","EditorIcons"), BUTTON_DELETE);
+ item->add_button(3, get_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP);
+ item->add_button(3, get_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN);
+ item->add_button(3, get_icon("Del", "EditorIcons"), BUTTON_DELETE);
item->set_selectable(3, false);
}
updating_autoload = false;
}
-Variant EditorAutoloadSettings::get_drag_data_fw(const Point2& p_point, Control *p_control) {
+Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control *p_control) {
if (autoload_cache.size() <= 1)
return false;
@@ -387,13 +387,13 @@ Variant EditorAutoloadSettings::get_drag_data_fw(const Point2& p_point, Control
if (autoloads.size() == 0 || autoloads.size() == autoload_cache.size())
return Variant();
- VBoxContainer *preview = memnew( VBoxContainer );
+ VBoxContainer *preview = memnew(VBoxContainer);
int max_size = MIN(PREVIEW_LIST_MAX_SIZE, autoloads.size());
for (int i = 0; i < max_size; i++) {
- Label *label = memnew( Label(autoloads[i]) );
- label->set_self_modulate(Color(1,1,1,Math::lerp(1, 0, float(i)/PREVIEW_LIST_MAX_SIZE)));
+ Label *label = memnew(Label(autoloads[i]));
+ label->set_self_modulate(Color(1, 1, 1, Math::lerp(1, 0, float(i) / PREVIEW_LIST_MAX_SIZE)));
preview->add_child(label);
}
@@ -408,7 +408,7 @@ Variant EditorAutoloadSettings::get_drag_data_fw(const Point2& p_point, Control
return drop_data;
}
-bool EditorAutoloadSettings::can_drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_control) const {
+bool EditorAutoloadSettings::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) const {
if (updating_autoload)
return false;
@@ -434,7 +434,7 @@ bool EditorAutoloadSettings::can_drop_data_fw(const Point2& p_point, const Varia
return false;
}
-void EditorAutoloadSettings::drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_control) {
+void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) {
TreeItem *ti = tree->get_item_at_pos(p_point);
@@ -544,13 +544,13 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
updating_autoload = false;
selected_autoload = "";
- HBoxContainer *hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
add_child(hbc);
- VBoxContainer *vbc_path = memnew( VBoxContainer );
+ VBoxContainer *vbc_path = memnew(VBoxContainer);
vbc_path->set_h_size_flags(SIZE_EXPAND_FILL);
- autoload_add_path = memnew( EditorLineEditFileChooser );
+ autoload_add_path = memnew(EditorLineEditFileChooser);
autoload_add_path->set_h_size_flags(SIZE_EXPAND_FILL);
autoload_add_path->get_file_dialog()->set_mode(EditorFileDialog::MODE_OPEN_FILE);
@@ -559,16 +559,16 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
vbc_path->add_margin_child(TTR("Path:"), autoload_add_path);
hbc->add_child(vbc_path);
- VBoxContainer *vbc_name = memnew( VBoxContainer );
+ VBoxContainer *vbc_name = memnew(VBoxContainer);
vbc_name->set_h_size_flags(SIZE_EXPAND_FILL);
- HBoxContainer *hbc_name = memnew( HBoxContainer );
+ HBoxContainer *hbc_name = memnew(HBoxContainer);
- autoload_add_name = memnew( LineEdit );
+ autoload_add_name = memnew(LineEdit);
autoload_add_name->set_h_size_flags(SIZE_EXPAND_FILL);
hbc_name->add_child(autoload_add_name);
- Button *add_autoload = memnew( Button );
+ Button *add_autoload = memnew(Button);
add_autoload->set_text(TTR("Add"));
hbc_name->add_child(add_autoload);
add_autoload->connect("pressed", this, "_autoload_add");
@@ -576,7 +576,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
vbc_name->add_margin_child(TTR("Node Name:"), hbc_name);
hbc->add_child(vbc_name);
- tree = memnew( Tree );
+ tree = memnew(Tree);
tree->set_hide_root(true);
tree->set_select_mode(Tree::SELECT_MULTI);
tree->set_single_select_cell_editing_only_when_already_selected(true);
@@ -586,20 +586,20 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
tree->set_columns(4);
tree->set_column_titles_visible(true);
- tree->set_column_title(0,TTR("Name"));
- tree->set_column_expand(0,true);
- tree->set_column_min_width(0,100);
+ tree->set_column_title(0, TTR("Name"));
+ tree->set_column_expand(0, true);
+ tree->set_column_min_width(0, 100);
- tree->set_column_title(1,TTR("Path"));
- tree->set_column_expand(1,true);
- tree->set_column_min_width(1,100);
+ tree->set_column_title(1, TTR("Path"));
+ tree->set_column_expand(1, true);
+ tree->set_column_min_width(1, 100);
- tree->set_column_title(2,TTR("Singleton"));
- tree->set_column_expand(2,false);
- tree->set_column_min_width(2,80);
+ tree->set_column_title(2, TTR("Singleton"));
+ tree->set_column_expand(2, false);
+ tree->set_column_min_width(2, 80);
- tree->set_column_expand(3,false);
- tree->set_column_min_width(3,80);
+ tree->set_column_expand(3, false);
+ tree->set_column_min_width(3, 80);
tree->connect("cell_selected", this, "_autoload_selected");
tree->connect("item_edited", this, "_autoload_edited");
@@ -607,4 +607,3 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
add_margin_child(TTR("List:"), tree, true);
}
-
diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h
index 2afe239000..8eb6140180 100644
--- a/editor/editor_autoload_settings.h
+++ b/editor/editor_autoload_settings.h
@@ -36,7 +36,7 @@
class EditorAutoloadSettings : public VBoxContainer {
- GDCLASS( EditorAutoloadSettings, VBoxContainer );
+ GDCLASS(EditorAutoloadSettings, VBoxContainer);
enum {
BUTTON_MOVE_UP,
@@ -50,7 +50,7 @@ class EditorAutoloadSettings : public VBoxContainer {
String name;
int order;
- bool operator==(const AutoLoadInfo& p_info) {
+ bool operator==(const AutoLoadInfo &p_info) {
return order == p_info.order;
}
};
@@ -65,30 +65,26 @@ class EditorAutoloadSettings : public VBoxContainer {
EditorLineEditFileChooser *autoload_add_path;
LineEdit *autoload_add_name;
- bool _autoload_name_is_valid(const String& p_string, String *r_error = NULL);
+ bool _autoload_name_is_valid(const String &p_string, String *r_error = NULL);
void _autoload_add();
void _autoload_selected();
void _autoload_edited();
void _autoload_button_pressed(Object *p_item, int p_column, int p_button);
- void _autoload_file_callback(const String& p_path);
+ void _autoload_file_callback(const String &p_path);
- Variant get_drag_data_fw(const Point2& p_point, Control *p_from);
- bool can_drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_from) const;
- void drop_data_fw(const Point2& p_point, const Variant& p_data, Control *p_from);
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
protected:
-
void _notification(int p_what);
static void _bind_methods();
public:
-
void update_autoload();
EditorAutoloadSettings();
-
};
#endif
-
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index d2fa40e08c..d92a348df9 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -28,30 +28,30 @@
/*************************************************************************/
#include "editor_data.h"
-#include "global_config.h"
+#include "editor_node.h"
#include "editor_settings.h"
-#include "os/dir_access.h"
+#include "global_config.h"
#include "io/resource_loader.h"
-#include "scene/resources/packed_scene.h"
+#include "os/dir_access.h"
#include "os/file_access.h"
-#include "editor_node.h"
+#include "scene/resources/packed_scene.h"
void EditorHistory::_cleanup_history() {
- for(int i=0;i<history.size();i++) {
+ for (int i = 0; i < history.size(); i++) {
- bool fail=false;
+ bool fail = false;
- for(int j=0;j<history[i].path.size();j++) {
+ for (int j = 0; j < history[i].path.size(); j++) {
if (!history[i].path[j].ref.is_null())
continue;
if (ObjectDB::get_instance(history[i].path[j].object))
continue; //has isntance, try next
- if (j<=history[i].level) {
+ if (j <= history[i].level) {
//before or equal level, complete fail
- fail=true;
+ fail = true;
} else {
//after level, clip
history[i].path.resize(j);
@@ -66,46 +66,46 @@ void EditorHistory::_cleanup_history() {
}
}
- if (current>=history.size())
- current=history.size()-1;
+ if (current >= history.size())
+ current = history.size() - 1;
}
-void EditorHistory::_add_object(ObjectID p_object,const String& p_property,int p_level_change) {
+void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int p_level_change) {
Object *obj = ObjectDB::get_instance(p_object);
ERR_FAIL_COND(!obj);
Reference *r = obj->cast_to<Reference>();
Obj o;
if (r)
- o.ref=REF(r);
- o.object=p_object;
- o.property=p_property;
+ o.ref = REF(r);
+ o.object = p_object;
+ o.property = p_property;
History h;
- bool has_prev = current>=0 && current<history.size();
+ bool has_prev = current >= 0 && current < history.size();
if (has_prev) {
- history.resize(current+1); //clip history to next
+ history.resize(current + 1); //clip history to next
}
- if (p_property!="" && has_prev) {
+ if (p_property != "" && has_prev) {
//add a sub property
History &pr = history[current];
- h=pr;
- h.path.resize(h.level+1);
+ h = pr;
+ h.path.resize(h.level + 1);
h.path.push_back(o);
h.level++;
- } else if (p_level_change!=-1 && has_prev) {
+ } else if (p_level_change != -1 && has_prev) {
//add a sub property
History &pr = history[current];
- h=pr;
- ERR_FAIL_INDEX(p_level_change,h.path.size());
- h.level=p_level_change;
+ h = pr;
+ ERR_FAIL_INDEX(p_level_change, h.path.size());
+ h.level = p_level_change;
} else {
//add a new node
h.path.push_back(o);
- h.level=0;
+ h.level = 0;
}
history.push_back(h);
@@ -114,17 +114,17 @@ void EditorHistory::_add_object(ObjectID p_object,const String& p_property,int p
void EditorHistory::add_object(ObjectID p_object) {
- _add_object(p_object,"",-1);
+ _add_object(p_object, "", -1);
}
-void EditorHistory::add_object(ObjectID p_object,const String& p_subprop) {
+void EditorHistory::add_object(ObjectID p_object, const String &p_subprop) {
- _add_object(p_object,p_subprop,-1);
+ _add_object(p_object, p_subprop, -1);
}
-void EditorHistory::add_object(ObjectID p_object,int p_relevel){
+void EditorHistory::add_object(ObjectID p_object, int p_relevel) {
- _add_object(p_object,"",p_relevel);
+ _add_object(p_object, "", p_relevel);
}
int EditorHistory::get_history_len() {
@@ -135,26 +135,24 @@ int EditorHistory::get_history_pos() {
}
ObjectID EditorHistory::get_history_obj(int p_obj) const {
- ERR_FAIL_INDEX_V(p_obj,history.size(),0);
- ERR_FAIL_INDEX_V(history[p_obj].level,history[p_obj].path.size(),0);
+ ERR_FAIL_INDEX_V(p_obj, history.size(), 0);
+ ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), 0);
return history[p_obj].path[history[p_obj].level].object;
}
bool EditorHistory::is_at_begining() const {
- return current<=0;
+ return current <= 0;
}
bool EditorHistory::is_at_end() const {
- return ((current+1)>=history.size());
+ return ((current + 1) >= history.size());
}
-
bool EditorHistory::next() {
-
_cleanup_history();
- if ((current+1)<history.size())
+ if ((current + 1) < history.size())
current++;
else
return false;
@@ -164,10 +162,9 @@ bool EditorHistory::next() {
bool EditorHistory::previous() {
-
_cleanup_history();
- if (current>0)
+ if (current > 0)
current--;
else
return false;
@@ -177,11 +174,10 @@ bool EditorHistory::previous() {
ObjectID EditorHistory::get_current() {
-
- if (current<0 || current >=history.size())
+ if (current < 0 || current >= history.size())
return 0;
- History &h=history[current];
+ History &h = history[current];
Object *obj = ObjectDB::get_instance(h.path[h.level].object);
if (!obj)
return 0;
@@ -191,22 +187,21 @@ ObjectID EditorHistory::get_current() {
int EditorHistory::get_path_size() const {
- if (current<0 || current >=history.size())
+ if (current < 0 || current >= history.size())
return 0;
- const History &h=history[current];
+ const History &h = history[current];
return h.path.size();
-
}
ObjectID EditorHistory::get_path_object(int p_index) const {
- if (current<0 || current >=history.size())
+ if (current < 0 || current >= history.size())
return 0;
- const History &h=history[current];
+ const History &h = history[current];
- ERR_FAIL_INDEX_V(p_index,h.path.size(),0);
+ ERR_FAIL_INDEX_V(p_index, h.path.size(), 0);
Object *obj = ObjectDB::get_instance(h.path[p_index].object);
if (!obj)
@@ -217,31 +212,30 @@ ObjectID EditorHistory::get_path_object(int p_index) const {
String EditorHistory::get_path_property(int p_index) const {
- if (current<0 || current >=history.size())
+ if (current < 0 || current >= history.size())
return "";
- const History &h=history[current];
+ const History &h = history[current];
- ERR_FAIL_INDEX_V(p_index,h.path.size(),"");
+ ERR_FAIL_INDEX_V(p_index, h.path.size(), "");
return h.path[p_index].property;
-
}
void EditorHistory::clear() {
history.clear();
- current=-1;
+ current = -1;
}
EditorHistory::EditorHistory() {
- current=-1;
+ current = -1;
}
-EditorPlugin* EditorData::get_editor(Object *p_object) {
+EditorPlugin *EditorData::get_editor(Object *p_object) {
- for (int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
if (editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object))
return editor_plugins[i];
@@ -250,9 +244,9 @@ EditorPlugin* EditorData::get_editor(Object *p_object) {
return NULL;
}
-EditorPlugin* EditorData::get_subeditor(Object *p_object) {
+EditorPlugin *EditorData::get_subeditor(Object *p_object) {
- for (int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object))
return editor_plugins[i];
@@ -261,8 +255,8 @@ EditorPlugin* EditorData::get_subeditor(Object *p_object) {
return NULL;
}
-Vector<EditorPlugin*> EditorData::get_subeditors(Object* p_object) {
- Vector<EditorPlugin*> sub_plugins;
+Vector<EditorPlugin *> EditorData::get_subeditors(Object *p_object) {
+ Vector<EditorPlugin *> sub_plugins;
for (int i = 0; i < editor_plugins.size(); i++) {
if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) {
sub_plugins.push_back(editor_plugins[i]);
@@ -271,11 +265,11 @@ Vector<EditorPlugin*> EditorData::get_subeditors(Object* p_object) {
return sub_plugins;
}
-EditorPlugin* EditorData::get_editor(String p_name) {
+EditorPlugin *EditorData::get_editor(String p_name) {
- for(int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
- if (editor_plugins[i]->get_name()==p_name)
+ if (editor_plugins[i]->get_name() == p_name)
return editor_plugins[i];
}
@@ -289,79 +283,73 @@ void EditorData::copy_object_params(Object *p_object) {
List<PropertyInfo> pinfo;
p_object->get_property_list(&pinfo);
- for( List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- if (!(E->get().usage&PROPERTY_USAGE_EDITOR))
+ if (!(E->get().usage & PROPERTY_USAGE_EDITOR))
continue;
PropertyData pd;
- pd.name=E->get().name;
- pd.value=p_object->get(pd.name);
+ pd.name = E->get().name;
+ pd.value = p_object->get(pd.name);
clipboard.push_back(pd);
}
}
void EditorData::get_editor_breakpoints(List<String> *p_breakpoints) {
-
- for(int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
editor_plugins[i]->get_breakpoints(p_breakpoints);
}
-
-
}
Dictionary EditorData::get_editor_states() const {
Dictionary metadata;
- for(int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
- Dictionary state=editor_plugins[i]->get_state();
+ Dictionary state = editor_plugins[i]->get_state();
if (state.empty())
continue;
- metadata[editor_plugins[i]->get_name()]=state;
+ metadata[editor_plugins[i]->get_name()] = state;
}
return metadata;
-
}
-Dictionary EditorData::get_scene_editor_states(int p_idx) const
-{
- ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),Dictionary());
+Dictionary EditorData::get_scene_editor_states(int p_idx) const {
+ ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), Dictionary());
EditedScene es = edited_scene[p_idx];
return es.editor_states;
}
-void EditorData::set_editor_states(const Dictionary& p_states) {
+void EditorData::set_editor_states(const Dictionary &p_states) {
List<Variant> keys;
p_states.get_key_list(&keys);
- List<Variant>::Element *E=keys.front();
- for(;E;E=E->next()) {
+ List<Variant>::Element *E = keys.front();
+ for (; E; E = E->next()) {
String name = E->get();
- int idx=-1;
- for(int i=0;i<editor_plugins.size();i++) {
+ int idx = -1;
+ for (int i = 0; i < editor_plugins.size(); i++) {
- if (editor_plugins[i]->get_name()==name) {
- idx=i;
+ if (editor_plugins[i]->get_name() == name) {
+ idx = i;
break;
}
}
- if (idx==-1)
+ if (idx == -1)
continue;
editor_plugins[idx]->set_state(p_states[name]);
}
-
}
void EditorData::notify_edited_scene_changed() {
- for(int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
editor_plugins[i]->edited_scene_changed();
}
@@ -369,16 +357,15 @@ void EditorData::notify_edited_scene_changed() {
void EditorData::clear_editor_states() {
- for(int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
editor_plugins[i]->clear();
}
-
}
void EditorData::save_editor_external_data() {
- for(int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
editor_plugins[i]->save_external_data();
}
@@ -386,42 +373,36 @@ void EditorData::save_editor_external_data() {
void EditorData::apply_changes_in_editors() {
- for(int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
editor_plugins[i]->apply_changes();
}
-
}
void EditorData::save_editor_global_states() {
- for(int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
editor_plugins[i]->save_global_state();
}
}
-void EditorData::restore_editor_global_states(){
+void EditorData::restore_editor_global_states() {
- for(int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
editor_plugins[i]->restore_global_state();
}
-
}
-
void EditorData::paste_object_params(Object *p_object) {
+ for (List<PropertyData>::Element *E = clipboard.front(); E; E = E->next()) {
- for( List<PropertyData>::Element *E=clipboard.front();E;E=E->next()) {
-
- p_object->set( E->get().name, E->get().value);
+ p_object->set(E->get().name, E->get().value);
}
-
}
-
UndoRedo &EditorData::get_undo_redo() {
return undo_redo;
@@ -429,14 +410,13 @@ UndoRedo &EditorData::get_undo_redo() {
void EditorData::remove_editor_plugin(EditorPlugin *p_plugin) {
- p_plugin->undo_redo=NULL;
+ p_plugin->undo_redo = NULL;
editor_plugins.erase(p_plugin);
-
}
void EditorData::add_editor_plugin(EditorPlugin *p_plugin) {
- p_plugin->undo_redo=&undo_redo;
+ p_plugin->undo_redo = &undo_redo;
editor_plugins.push_back(p_plugin);
}
@@ -445,32 +425,30 @@ int EditorData::get_editor_plugin_count() const {
}
EditorPlugin *EditorData::get_editor_plugin(int p_idx) {
- ERR_FAIL_INDEX_V(p_idx,editor_plugins.size(),NULL);
+ ERR_FAIL_INDEX_V(p_idx, editor_plugins.size(), NULL);
return editor_plugins[p_idx];
}
-
-void EditorData::add_custom_type(const String& p_type, const String& p_inherits,const Ref<Script>& p_script,const Ref<Texture>& p_icon ) {
+void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture> &p_icon) {
ERR_FAIL_COND(p_script.is_null());
CustomType ct;
- ct.name=p_type;
- ct.icon=p_icon;
- ct.script=p_script;
+ ct.name = p_type;
+ ct.icon = p_icon;
+ ct.script = p_script;
if (!custom_types.has(p_inherits)) {
- custom_types[p_inherits]=Vector<CustomType>();
+ custom_types[p_inherits] = Vector<CustomType>();
}
custom_types[p_inherits].push_back(ct);
}
-void EditorData::remove_custom_type(const String& p_type){
-
+void EditorData::remove_custom_type(const String &p_type) {
- for (Map<String,Vector<CustomType> >::Element *E=custom_types.front();E;E=E->next()) {
+ for (Map<String, Vector<CustomType> >::Element *E = custom_types.front(); E; E = E->next()) {
- for(int i=0;i<E->get().size();i++) {
- if (E->get()[i].name==p_type) {
+ for (int i = 0; i < E->get().size(); i++) {
+ if (E->get()[i].name == p_type) {
E->get().remove(i);
if (E->get().empty()) {
custom_types.erase(E->key());
@@ -479,51 +457,49 @@ void EditorData::remove_custom_type(const String& p_type){
}
}
}
-
}
int EditorData::add_edited_scene(int p_at_pos) {
- if (p_at_pos<0)
- p_at_pos=edited_scene.size();
+ if (p_at_pos < 0)
+ p_at_pos = edited_scene.size();
EditedScene es;
- es.root=NULL;
- es.history_current=-1;
- es.version=0;
- es.live_edit_root=NodePath(String("/root"));
+ es.root = NULL;
+ es.history_current = -1;
+ es.version = 0;
+ es.live_edit_root = NodePath(String("/root"));
- if (p_at_pos==edited_scene.size())
+ if (p_at_pos == edited_scene.size())
edited_scene.push_back(es);
else
- edited_scene.insert(p_at_pos,es);
+ edited_scene.insert(p_at_pos, es);
- if (current_edited_scene<0)
- current_edited_scene=0;
+ if (current_edited_scene < 0)
+ current_edited_scene = 0;
return p_at_pos;
}
-void EditorData::move_edited_scene_index(int p_idx,int p_to_idx){
+void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) {
- ERR_FAIL_INDEX(p_idx,edited_scene.size());
- ERR_FAIL_INDEX(p_to_idx,edited_scene.size());
- SWAP(edited_scene[p_idx],edited_scene[p_to_idx]);
+ ERR_FAIL_INDEX(p_idx, edited_scene.size());
+ ERR_FAIL_INDEX(p_to_idx, edited_scene.size());
+ SWAP(edited_scene[p_idx], edited_scene[p_to_idx]);
}
-void EditorData::remove_scene(int p_idx){
- ERR_FAIL_INDEX(p_idx,edited_scene.size());
+void EditorData::remove_scene(int p_idx) {
+ ERR_FAIL_INDEX(p_idx, edited_scene.size());
if (edited_scene[p_idx].root)
memdelete(edited_scene[p_idx].root);
- if (current_edited_scene>p_idx)
+ if (current_edited_scene > p_idx)
current_edited_scene--;
- else if (current_edited_scene==p_idx && current_edited_scene>0) {
+ else if (current_edited_scene == p_idx && current_edited_scene > 0) {
current_edited_scene--;
}
edited_scene.remove(p_idx);
-
}
-bool EditorData::_find_updated_instances(Node* p_root,Node *p_node,Set<String> &checked_paths) {
+bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths) {
/*
if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner()))
@@ -532,10 +508,10 @@ bool EditorData::_find_updated_instances(Node* p_root,Node *p_node,Set<String> &
Ref<SceneState> ss;
- if (p_node==p_root) {
- ss=p_node->get_scene_inherited_state();
- } else if (p_node->get_filename()!=String()){
- ss=p_node->get_scene_instance_state();
+ if (p_node == p_root) {
+ ss = p_node->get_scene_inherited_state();
+ } else if (p_node->get_filename() != String()) {
+ ss = p_node->get_scene_instance_state();
}
if (ss.is_valid()) {
@@ -544,18 +520,17 @@ bool EditorData::_find_updated_instances(Node* p_root,Node *p_node,Set<String> &
if (!checked_paths.has(path)) {
uint64_t modified_time = FileAccess::get_modified_time(path);
- if (modified_time!=ss->get_last_modified_time()) {
+ if (modified_time != ss->get_last_modified_time()) {
return true; //external scene changed
}
checked_paths.insert(path);
}
-
}
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- bool found = _find_updated_instances(p_root,p_node->get_child(i),checked_paths);
+ bool found = _find_updated_instances(p_root, p_node->get_child(i), checked_paths);
if (found)
return true;
}
@@ -563,79 +538,75 @@ bool EditorData::_find_updated_instances(Node* p_root,Node *p_node,Set<String> &
return false;
}
-
bool EditorData::check_and_update_scene(int p_idx) {
- ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),false);
+ ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), false);
if (!edited_scene[p_idx].root)
return false;
Set<String> checked_scenes;
+ bool must_reload = _find_updated_instances(edited_scene[p_idx].root, edited_scene[p_idx].root, checked_scenes);
- bool must_reload = _find_updated_instances(edited_scene[p_idx].root,edited_scene[p_idx].root,checked_scenes);
-
- print_line("MUST RELOAD? "+itos(must_reload));
+ print_line("MUST RELOAD? " + itos(must_reload));
if (must_reload) {
Ref<PackedScene> pscene;
pscene.instance();
- EditorProgress ep("update_scene",TTR("Updating Scene"),2);
- ep.step(TTR("Storing local changes.."),0);
+ EditorProgress ep("update_scene", TTR("Updating Scene"), 2);
+ ep.step(TTR("Storing local changes.."), 0);
//pack first, so it stores diffs to previous version of saved scene
Error err = pscene->pack(edited_scene[p_idx].root);
- ERR_FAIL_COND_V(err!=OK,false);
- ep.step(TTR("Updating scene.."),1);
+ ERR_FAIL_COND_V(err != OK, false);
+ ep.step(TTR("Updating scene.."), 1);
Node *new_scene = pscene->instance(PackedScene::GEN_EDIT_STATE_MAIN);
- ERR_FAIL_COND_V(!new_scene,false);
+ ERR_FAIL_COND_V(!new_scene, false);
//transfer selection
- List<Node*> new_selection;
- for (List<Node*>::Element *E=edited_scene[p_idx].selection.front();E;E=E->next()) {
+ List<Node *> new_selection;
+ for (List<Node *>::Element *E = edited_scene[p_idx].selection.front(); E; E = E->next()) {
NodePath p = edited_scene[p_idx].root->get_path_to(E->get());
Node *new_node = new_scene->get_node(p);
if (new_node)
new_selection.push_back(new_node);
}
- new_scene->set_filename( edited_scene[p_idx].root->get_filename() );
+ new_scene->set_filename(edited_scene[p_idx].root->get_filename());
memdelete(edited_scene[p_idx].root);
- edited_scene[p_idx].root=new_scene;
- edited_scene[p_idx].selection=new_selection;
+ edited_scene[p_idx].root = new_scene;
+ edited_scene[p_idx].selection = new_selection;
return true;
-
}
return false;
-
}
int EditorData::get_edited_scene() const {
return current_edited_scene;
}
-void EditorData::set_edited_scene(int p_idx){
+void EditorData::set_edited_scene(int p_idx) {
- ERR_FAIL_INDEX(p_idx,edited_scene.size());
- current_edited_scene=p_idx;
+ ERR_FAIL_INDEX(p_idx, edited_scene.size());
+ current_edited_scene = p_idx;
//swap
}
-Node* EditorData::get_edited_scene_root(int p_idx){
+Node *EditorData::get_edited_scene_root(int p_idx) {
if (p_idx < 0) {
- ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),NULL);
+ ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), NULL);
return edited_scene[current_edited_scene].root;
} else {
- ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),NULL);
+ ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), NULL);
return edited_scene[p_idx].root;
}
}
-void EditorData::set_edited_scene_root(Node* p_root) {
+void EditorData::set_edited_scene_root(Node *p_root) {
- ERR_FAIL_INDEX(current_edited_scene,edited_scene.size());
- edited_scene[current_edited_scene].root=p_root;
+ ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
+ edited_scene[current_edited_scene].root = p_root;
}
int EditorData::get_edited_scene_count() const {
@@ -644,123 +615,111 @@ int EditorData::get_edited_scene_count() const {
}
void EditorData::set_edited_scene_version(uint64_t version, int scene_idx) {
- ERR_FAIL_INDEX(current_edited_scene,edited_scene.size());
+ ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
if (scene_idx < 0) {
- edited_scene[current_edited_scene].version=version;
+ edited_scene[current_edited_scene].version = version;
} else {
- ERR_FAIL_INDEX(scene_idx,edited_scene.size());
- edited_scene[scene_idx].version=version;
+ ERR_FAIL_INDEX(scene_idx, edited_scene.size());
+ edited_scene[scene_idx].version = version;
}
-
}
-uint64_t EditorData::get_edited_scene_version() const{
+uint64_t EditorData::get_edited_scene_version() const {
- ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),0);
+ ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), 0);
return edited_scene[current_edited_scene].version;
-
}
-uint64_t EditorData::get_scene_version(int p_idx) const{
- ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),false);
+uint64_t EditorData::get_scene_version(int p_idx) const {
+ ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), false);
return edited_scene[p_idx].version;
}
String EditorData::get_scene_type(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),String());
+ ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String());
if (!edited_scene[p_idx].root)
return "";
return edited_scene[p_idx].root->get_class();
-
}
void EditorData::move_edited_scene_to_index(int p_idx) {
- ERR_FAIL_INDEX(current_edited_scene,edited_scene.size());
- ERR_FAIL_INDEX(p_idx,edited_scene.size());
+ ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
+ ERR_FAIL_INDEX(p_idx, edited_scene.size());
- EditedScene es=edited_scene[current_edited_scene];
+ EditedScene es = edited_scene[current_edited_scene];
edited_scene.remove(current_edited_scene);
- edited_scene.insert(p_idx,es);
- current_edited_scene=p_idx;
+ edited_scene.insert(p_idx, es);
+ current_edited_scene = p_idx;
}
Ref<Script> EditorData::get_scene_root_script(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),Ref<Script>());
+ ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), Ref<Script>());
if (!edited_scene[p_idx].root)
return Ref<Script>();
- Ref<Script> s=edited_scene[p_idx].root->get_script();
+ Ref<Script> s = edited_scene[p_idx].root->get_script();
if (!s.is_valid() && edited_scene[p_idx].root->get_child_count()) {
Node *n = edited_scene[p_idx].root->get_child(0);
- while(!s.is_valid() && n && n->get_filename()==String()) {
- s=n->get_script();
- n=n->get_parent();
+ while (!s.is_valid() && n && n->get_filename() == String()) {
+ s = n->get_script();
+ n = n->get_parent();
}
}
return s;
}
String EditorData::get_scene_title(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),String());
+ ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String());
if (!edited_scene[p_idx].root)
return "[empty]";
- if (edited_scene[p_idx].root->get_filename()=="")
+ if (edited_scene[p_idx].root->get_filename() == "")
return "[unsaved]";
return edited_scene[p_idx].root->get_filename().get_file();
}
-
String EditorData::get_scene_path(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,edited_scene.size(),String());
+ ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String());
if (!edited_scene[p_idx].root)
return "";
return edited_scene[p_idx].root->get_filename();
-
}
-void EditorData::set_edited_scene_live_edit_root(const NodePath& p_root) {
- ERR_FAIL_INDEX(current_edited_scene,edited_scene.size());
-
- edited_scene[current_edited_scene].live_edit_root=p_root;
+void EditorData::set_edited_scene_live_edit_root(const NodePath &p_root) {
+ ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
+ edited_scene[current_edited_scene].live_edit_root = p_root;
}
NodePath EditorData::get_edited_scene_live_edit_root() {
- ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),String());
+ ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), String());
return edited_scene[current_edited_scene].live_edit_root;
-
-
-
}
+void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary &p_custom) {
-void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary& p_custom) {
-
- ERR_FAIL_INDEX(current_edited_scene,edited_scene.size());
+ ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
- EditedScene &es=edited_scene[current_edited_scene];
+ EditedScene &es = edited_scene[current_edited_scene];
es.selection = p_selection->get_selected_node_list();
- es.history_current=p_history->current;
- es.history_stored=p_history->history;
- es.editor_states=get_editor_states();
- es.custom_state=p_custom;
-
+ es.history_current = p_history->current;
+ es.history_stored = p_history->history;
+ es.editor_states = get_editor_states();
+ es.custom_state = p_custom;
}
Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history) {
- ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),Dictionary());
-
- EditedScene &es=edited_scene[current_edited_scene];
+ ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), Dictionary());
- p_history->current=es.history_current;
- p_history->history=es.history_stored;
+ EditedScene &es = edited_scene[current_edited_scene];
+ p_history->current = es.history_current;
+ p_history->history = es.history_stored;
p_selection->clear();
- for(List<Node*>::Element *E=es.selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = es.selection.front(); E; E = E->next()) {
p_selection->add_node(E->get());
}
set_editor_states(es.editor_states);
@@ -768,34 +727,31 @@ Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection,
return es.custom_state;
}
-
void EditorData::clear_edited_scenes() {
- for(int i=0;i<edited_scene.size();i++) {
+ for (int i = 0; i < edited_scene.size(); i++) {
if (edited_scene[i].root) {
- memdelete( edited_scene[i].root );
+ memdelete(edited_scene[i].root);
}
}
edited_scene.clear();
}
-
-
void EditorData::set_plugin_window_layout(Ref<ConfigFile> p_layout) {
- for(int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
editor_plugins[i]->set_window_layout(p_layout);
}
}
void EditorData::get_plugin_window_layout(Ref<ConfigFile> p_layout) {
- for(int i=0;i<editor_plugins.size();i++) {
+ for (int i = 0; i < editor_plugins.size(); i++) {
editor_plugins[i]->get_window_layout(p_layout);
}
}
EditorData::EditorData() {
- current_edited_scene=-1;
+ current_edited_scene = -1;
//load_imported_scenes_from_globals();
}
@@ -810,8 +766,8 @@ void EditorSelection::_node_removed(Node *p_node) {
if (meta)
memdelete(meta);
selection.erase(p_node);
- changed=true;
- nl_changed=true;
+ changed = true;
+ nl_changed = true;
}
void EditorSelection::add_node(Node *p_node) {
@@ -821,20 +777,19 @@ void EditorSelection::add_node(Node *p_node) {
if (selection.has(p_node))
return;
- changed=true;
- nl_changed=true;
- Object *meta=NULL;
- for(List<Object*>::Element *E=editor_plugins.front();E;E=E->next()) {
+ changed = true;
+ nl_changed = true;
+ Object *meta = NULL;
+ for (List<Object *>::Element *E = editor_plugins.front(); E; E = E->next()) {
- meta = E->get()->call("_get_editor_data",p_node);
+ meta = E->get()->call("_get_editor_data", p_node);
if (meta) {
break;
}
-
}
- selection[p_node]=meta;
+ selection[p_node] = meta;
- p_node->connect("tree_exited",this,"_node_removed",varray(p_node),CONNECT_ONESHOT);
+ p_node->connect("tree_exited", this, "_node_removed", varray(p_node), CONNECT_ONESHOT);
//emit_signal("selection_changed");
}
@@ -846,16 +801,16 @@ void EditorSelection::remove_node(Node *p_node) {
if (!selection.has(p_node))
return;
- changed=true;
- nl_changed=true;
+ changed = true;
+ nl_changed = true;
Object *meta = selection[p_node];
if (meta)
memdelete(meta);
selection.erase(p_node);
- p_node->disconnect("tree_exited",this,"_node_removed");
+ p_node->disconnect("tree_exited", this, "_node_removed");
//emit_signal("selection_changed");
}
-bool EditorSelection::is_selected(Node * p_node) const {
+bool EditorSelection::is_selected(Node *p_node) const {
return selection.has(p_node);
}
@@ -864,7 +819,7 @@ Array EditorSelection::_get_transformable_selected_nodes() {
Array ret;
- for (List<Node*>::Element *E=selected_node_list.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selected_node_list.front(); E; E = E->next()) {
ret.push_back(E->get());
}
@@ -876,7 +831,7 @@ Array EditorSelection::_get_selected_nodes() {
Array ret;
- for (Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
ret.push_back(E->key());
}
@@ -886,14 +841,13 @@ Array EditorSelection::_get_selected_nodes() {
void EditorSelection::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_node_removed"),&EditorSelection::_node_removed);
- ClassDB::bind_method(D_METHOD("clear"),&EditorSelection::clear);
- ClassDB::bind_method(D_METHOD("add_node","node:Node"),&EditorSelection::add_node);
- ClassDB::bind_method(D_METHOD("remove_node","node:Node"),&EditorSelection::remove_node);
- ClassDB::bind_method(D_METHOD("get_selected_nodes"),&EditorSelection::_get_selected_nodes);
- ClassDB::bind_method(D_METHOD("get_transformable_selected_nodes"),&EditorSelection::_get_transformable_selected_nodes);
- ADD_SIGNAL( MethodInfo("selection_changed") );
-
+ ClassDB::bind_method(D_METHOD("_node_removed"), &EditorSelection::_node_removed);
+ ClassDB::bind_method(D_METHOD("clear"), &EditorSelection::clear);
+ ClassDB::bind_method(D_METHOD("add_node", "node:Node"), &EditorSelection::add_node);
+ ClassDB::bind_method(D_METHOD("remove_node", "node:Node"), &EditorSelection::remove_node);
+ ClassDB::bind_method(D_METHOD("get_selected_nodes"), &EditorSelection::_get_selected_nodes);
+ ClassDB::bind_method(D_METHOD("get_transformable_selected_nodes"), &EditorSelection::_get_transformable_selected_nodes);
+ ADD_SIGNAL(MethodInfo("selection_changed"));
}
void EditorSelection::add_editor_plugin(Object *p_object) {
@@ -908,18 +862,17 @@ void EditorSelection::_update_nl() {
selected_node_list.clear();
- for (Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
-
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
Node *parent = E->key();
- parent=parent->get_parent();
- bool skip=false;
+ parent = parent->get_parent();
+ bool skip = false;
while (parent) {
if (selection.has(parent)) {
- skip=true;
+ skip = true;
break;
}
- parent=parent->get_parent();
+ parent = parent->get_parent();
}
if (skip)
@@ -927,7 +880,7 @@ void EditorSelection::_update_nl() {
selected_node_list.push_back(E->key());
}
- nl_changed=true;
+ nl_changed = true;
}
void EditorSelection::update() {
@@ -937,12 +890,10 @@ void EditorSelection::update() {
if (!changed)
return;
emit_signal("selection_changed");
- changed=false;
-
-
+ changed = false;
}
-List<Node*>& EditorSelection::get_selected_node_list() {
+List<Node *> &EditorSelection::get_selected_node_list() {
if (changed)
update();
@@ -951,26 +902,20 @@ List<Node*>& EditorSelection::get_selected_node_list() {
return selected_node_list;
}
-
-
-
void EditorSelection::clear() {
- while( !selection.empty() ) {
+ while (!selection.empty()) {
remove_node(selection.front()->key());
}
-
- changed=true;
- nl_changed=true;
-
+ changed = true;
+ nl_changed = true;
}
EditorSelection::EditorSelection() {
- changed=false;
- nl_changed=false;
-
+ changed = false;
+ nl_changed = false;
}
EditorSelection::~EditorSelection() {
diff --git a/editor/editor_data.h b/editor/editor_data.h
index 4622791653..598cde2318 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -30,16 +30,16 @@
#define EDITOR_DATA_H
#include "editor/editor_plugin.h"
-#include "scene/resources/texture.h"
#include "list.h"
-#include "undo_redo.h"
#include "pair.h"
+#include "scene/resources/texture.h"
+#include "undo_redo.h"
class EditorHistory {
enum {
- HISTORY_MAX=64
+ HISTORY_MAX = 64
};
struct Obj {
@@ -54,7 +54,7 @@ class EditorHistory {
Vector<Obj> path;
int level;
};
-friend class EditorData;
+ friend class EditorData;
Vector<History> history;
int current;
@@ -67,19 +67,17 @@ friend class EditorData;
Variant value;
};
-
void _cleanup_history();
- void _add_object(ObjectID p_object,const String& p_property,int p_level_change);
+ void _add_object(ObjectID p_object, const String &p_property, int p_level_change);
public:
-
bool is_at_begining() const;
bool is_at_end() const;
void add_object(ObjectID p_object);
- void add_object(ObjectID p_object,const String& p_subprop);
- void add_object(ObjectID p_object,int p_relevel);
+ void add_object(ObjectID p_object, const String &p_subprop);
+ void add_object(ObjectID p_object, int p_relevel);
int get_history_len();
int get_history_pos();
@@ -109,54 +107,50 @@ public:
Ref<Script> script;
Ref<Texture> icon;
};
-private:
- Vector<EditorPlugin*> editor_plugins;
+private:
+ Vector<EditorPlugin *> editor_plugins;
struct PropertyData {
String name;
Variant value;
};
- Map<String,Vector<CustomType> > custom_types;
+ Map<String, Vector<CustomType> > custom_types;
List<PropertyData> clipboard;
UndoRedo undo_redo;
-
void _cleanup_history();
struct EditedScene {
- Node* root;
+ Node *root;
Dictionary editor_states;
- List<Node*> selection;
+ List<Node *> selection;
Vector<EditorHistory::History> history_stored;
int history_current;
Dictionary custom_state;
uint64_t version;
NodePath live_edit_root;
-
-
};
Vector<EditedScene> edited_scene;
int current_edited_scene;
- bool _find_updated_instances(Node* p_root,Node *p_node,Set<String> &checked_paths);
+ bool _find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths);
public:
-
- EditorPlugin* get_editor(Object *p_object);
- EditorPlugin* get_subeditor(Object *p_object);
- Vector<EditorPlugin*> get_subeditors(Object *p_object);
- EditorPlugin* get_editor(String p_name);
+ EditorPlugin *get_editor(Object *p_object);
+ EditorPlugin *get_subeditor(Object *p_object);
+ Vector<EditorPlugin *> get_subeditors(Object *p_object);
+ EditorPlugin *get_editor(String p_name);
void copy_object_params(Object *p_object);
void paste_object_params(Object *p_object);
Dictionary get_editor_states() const;
Dictionary get_scene_editor_states(int p_idx) const;
- void set_editor_states(const Dictionary& p_states);
+ void set_editor_states(const Dictionary &p_states);
void get_editor_breakpoints(List<String> *p_breakpoints);
void clear_editor_states();
void save_editor_external_data();
@@ -173,18 +167,17 @@ public:
void save_editor_global_states();
void restore_editor_global_states();
- void add_custom_type(const String& p_type, const String& p_inherits,const Ref<Script>& p_script,const Ref<Texture>& p_icon );
- void remove_custom_type(const String& p_type);
- const Map<String,Vector<CustomType> >& get_custom_types() const { return custom_types; }
-
+ void add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture> &p_icon);
+ void remove_custom_type(const String &p_type);
+ const Map<String, Vector<CustomType> > &get_custom_types() const { return custom_types; }
int add_edited_scene(int p_at_pos);
- void move_edited_scene_index(int p_idx,int p_to_idx);
+ void move_edited_scene_index(int p_idx, int p_to_idx);
void remove_scene(int p_idx);
void set_edited_scene(int p_idx);
- void set_edited_scene_root(Node* p_root);
+ void set_edited_scene_root(Node *p_root);
int get_edited_scene() const;
- Node* get_edited_scene_root(int p_idx = -1);
+ Node *get_edited_scene_root(int p_idx = -1);
int get_edited_scene_count() const;
String get_scene_title(int p_idx) const;
String get_scene_path(int p_idx) const;
@@ -194,55 +187,50 @@ public:
uint64_t get_edited_scene_version() const;
uint64_t get_scene_version(int p_idx) const;
void clear_edited_scenes();
- void set_edited_scene_live_edit_root(const NodePath& p_root);
+ void set_edited_scene_live_edit_root(const NodePath &p_root);
NodePath get_edited_scene_live_edit_root();
bool check_and_update_scene(int p_idx);
void move_edited_scene_to_index(int p_idx);
-
void set_plugin_window_layout(Ref<ConfigFile> p_layout);
void get_plugin_window_layout(Ref<ConfigFile> p_layout);
- void save_edited_scene_state(EditorSelection *p_selection,EditorHistory *p_history,const Dictionary& p_custom);
+ void save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary &p_custom);
Dictionary restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history);
void notify_edited_scene_changed();
-
EditorData();
};
-
-
class EditorSelection : public Object {
- GDCLASS(EditorSelection,Object);
-public:
+ GDCLASS(EditorSelection, Object);
- Map<Node*,Object*> selection;
+public:
+ Map<Node *, Object *> selection;
bool changed;
bool nl_changed;
void _node_removed(Node *p_node);
- List<Object*> editor_plugins;
- List<Node*> selected_node_list;
+ List<Object *> editor_plugins;
+ List<Node *> selected_node_list;
void _update_nl();
Array _get_selected_nodes();
Array _get_transformable_selected_nodes();
protected:
-
static void _bind_methods();
-public:
+public:
void add_node(Node *p_node);
void remove_node(Node *p_node);
bool is_selected(Node *) const;
- template<class T>
- T* get_node_editor_data(Node *p_node) {
+ template <class T>
+ T *get_node_editor_data(Node *p_node) {
if (!selection.has(p_node))
return NULL;
Object *obj = selection[p_node];
@@ -256,14 +244,11 @@ public:
void update();
void clear();
-
- List<Node*>& get_selected_node_list();
- Map<Node*,Object*>& get_selection() { return selection; }
-
+ List<Node *> &get_selected_node_list();
+ Map<Node *, Object *> &get_selection() { return selection; }
EditorSelection();
~EditorSelection();
};
-
#endif // EDITOR_DATA_H
diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp
index 235d1f06ba..5cd277e218 100644
--- a/editor/editor_dir_dialog.cpp
+++ b/editor/editor_dir_dialog.cpp
@@ -28,28 +28,27 @@
/*************************************************************************/
#include "editor_dir_dialog.h"
-#include "os/os.h"
-#include "os/keyboard.h"
-#include "editor/editor_settings.h"
#include "editor/editor_file_system.h"
+#include "editor/editor_settings.h"
+#include "os/keyboard.h"
+#include "os/os.h"
+void EditorDirDialog::_update_dir(TreeItem *p_item) {
-void EditorDirDialog::_update_dir(TreeItem* p_item) {
-
- updating=true;
+ updating = true;
p_item->clear_children();
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
String cdir = p_item->get_metadata(0);
da->change_dir(cdir);
da->list_dir_begin();
- String p=da->get_next();
+ String p = da->get_next();
List<String> dirs;
bool ishidden;
bool show_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files");
- while(p!="") {
+ while (p != "") {
ishidden = da->current_is_hidden();
@@ -58,153 +57,144 @@ void EditorDirDialog::_update_dir(TreeItem* p_item) {
dirs.push_back(p);
}
}
- p=da->get_next();
+ p = da->get_next();
}
dirs.sort();
- for(List<String>::Element *E=dirs.front();E;E=E->next()) {
+ for (List<String>::Element *E = dirs.front(); E; E = E->next()) {
TreeItem *ti = tree->create_item(p_item);
- ti->set_text(0,E->get());
- ti->set_icon(0,get_icon("Folder","EditorIcons"));
+ ti->set_text(0, E->get());
+ ti->set_icon(0, get_icon("Folder", "EditorIcons"));
ti->set_collapsed(true);
-
}
memdelete(da);
- updating=false;
-
+ updating = false;
}
-
void EditorDirDialog::reload() {
if (!is_visible_in_tree()) {
- must_reload=true;
+ must_reload = true;
return;
}
tree->clear();
TreeItem *root = tree->create_item();
- root->set_metadata(0,"res://");
- root->set_icon(0,get_icon("Folder","EditorIcons"));
- root->set_text(0,"/");
+ root->set_metadata(0, "res://");
+ root->set_icon(0, get_icon("Folder", "EditorIcons"));
+ root->set_text(0, "/");
_update_dir(root);
_item_collapsed(root);
- must_reload=false;
-
+ must_reload = false;
}
-
void EditorDirDialog::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
reload();
- if (!tree->is_connected("item_collapsed",this,"_item_collapsed")) {
- tree->connect("item_collapsed",this,"_item_collapsed",varray(),CONNECT_DEFERRED);
+ if (!tree->is_connected("item_collapsed", this, "_item_collapsed")) {
+ tree->connect("item_collapsed", this, "_item_collapsed", varray(), CONNECT_DEFERRED);
}
- if (!EditorFileSystem::get_singleton()->is_connected("filesystem_changed",this,"reload")) {
- EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"reload");
+ if (!EditorFileSystem::get_singleton()->is_connected("filesystem_changed", this, "reload")) {
+ EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "reload");
}
-
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (must_reload && is_visible_in_tree()) {
reload();
}
}
}
-void EditorDirDialog::_item_collapsed(Object* _p_item){
+void EditorDirDialog::_item_collapsed(Object *_p_item) {
- TreeItem *p_item=_p_item->cast_to<TreeItem>();
+ TreeItem *p_item = _p_item->cast_to<TreeItem>();
if (updating || p_item->is_collapsed())
return;
TreeItem *ci = p_item->get_children();
- while(ci) {
+ while (ci) {
- String p =ci->get_metadata(0);
- if (p=="") {
+ String p = ci->get_metadata(0);
+ if (p == "") {
String pp = p_item->get_metadata(0);
- ci->set_metadata(0,pp.plus_file(ci->get_text(0)));
+ ci->set_metadata(0, pp.plus_file(ci->get_text(0)));
_update_dir(ci);
}
- ci=ci->get_next();
+ ci = ci->get_next();
}
-
}
-void EditorDirDialog::set_current_path(const String& p_path) {
+void EditorDirDialog::set_current_path(const String &p_path) {
reload();
String p = p_path;
if (p.begins_with("res://"))
- p = p.replace_first("res://","");
+ p = p.replace_first("res://", "");
- Vector<String> dirs = p.split("/",false);
+ Vector<String> dirs = p.split("/", false);
- TreeItem *r=tree->get_root();
- for(int i=0;i<dirs.size();i++) {
+ TreeItem *r = tree->get_root();
+ for (int i = 0; i < dirs.size(); i++) {
String d = dirs[i];
TreeItem *p = r->get_children();
- while(p) {
+ while (p) {
- if (p->get_text(0)==d)
+ if (p->get_text(0) == d)
break;
- p=p->get_next();
+ p = p->get_next();
}
ERR_FAIL_COND(!p);
String pp = p->get_metadata(0);
- if (pp=="") {
- p->set_metadata(0,String(r->get_metadata(0)).plus_file(d));
+ if (pp == "") {
+ p->set_metadata(0, String(r->get_metadata(0)).plus_file(d));
_update_dir(p);
}
- updating=true;
+ updating = true;
p->set_collapsed(false);
- updating=false;
+ updating = false;
_item_collapsed(p);
- r=p;
+ r = p;
}
r->select(0);
-
}
void EditorDirDialog::ok_pressed() {
- TreeItem *ti=tree->get_selected();
+ TreeItem *ti = tree->get_selected();
if (!ti)
return;
String dir = ti->get_metadata(0);
- emit_signal("dir_selected",dir);
+ emit_signal("dir_selected", dir);
hide();
}
-
void EditorDirDialog::_make_dir() {
- TreeItem *ti=tree->get_selected();
+ TreeItem *ti = tree->get_selected();
if (!ti) {
mkdirerr->set_text("Please select a base directory first");
mkdirerr->popup_centered_minsize();
return;
}
- makedialog->popup_centered_minsize(Size2(250,80));
+ makedialog->popup_centered_minsize(Size2(250, 80));
makedirname->grab_focus();
}
void EditorDirDialog::_make_dir_confirm() {
- TreeItem *ti=tree->get_selected();
+ TreeItem *ti = tree->get_selected();
if (!ti)
return;
@@ -214,63 +204,57 @@ void EditorDirDialog::_make_dir_confirm() {
ERR_FAIL_COND(!d);
Error err = d->make_dir(makedirname->get_text());
- if (err!=OK) {
- mkdirerr->popup_centered_minsize(Size2(250,80));
+ if (err != OK) {
+ mkdirerr->popup_centered_minsize(Size2(250, 80));
} else {
set_current_path(dir.plus_file(makedirname->get_text()));
}
makedirname->set_text(""); // reset label
}
-
void EditorDirDialog::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_item_collapsed"),&EditorDirDialog::_item_collapsed);
- ClassDB::bind_method(D_METHOD("_make_dir"),&EditorDirDialog::_make_dir);
- ClassDB::bind_method(D_METHOD("_make_dir_confirm"),&EditorDirDialog::_make_dir_confirm);
- ClassDB::bind_method(D_METHOD("reload"),&EditorDirDialog::reload);
+ ClassDB::bind_method(D_METHOD("_item_collapsed"), &EditorDirDialog::_item_collapsed);
+ ClassDB::bind_method(D_METHOD("_make_dir"), &EditorDirDialog::_make_dir);
+ ClassDB::bind_method(D_METHOD("_make_dir_confirm"), &EditorDirDialog::_make_dir_confirm);
+ ClassDB::bind_method(D_METHOD("reload"), &EditorDirDialog::reload);
- ADD_SIGNAL(MethodInfo("dir_selected",PropertyInfo(Variant::STRING,"dir")));
+ ADD_SIGNAL(MethodInfo("dir_selected", PropertyInfo(Variant::STRING, "dir")));
}
-
-
EditorDirDialog::EditorDirDialog() {
- updating=false;
+ updating = false;
set_title(TTR("Choose a Directory"));
set_hide_on_ok(false);
- tree = memnew( Tree );
+ tree = memnew(Tree);
add_child(tree);
- tree->connect("item_activated",this,"_ok");
+ tree->connect("item_activated", this, "_ok");
- makedir = add_button(TTR("Create Folder"),OS::get_singleton()->get_swap_ok_cancel()?true:false,"makedir");
- makedir->connect("pressed",this,"_make_dir");
+ makedir = add_button(TTR("Create Folder"), OS::get_singleton()->get_swap_ok_cancel() ? true : false, "makedir");
+ makedir->connect("pressed", this, "_make_dir");
- makedialog = memnew( ConfirmationDialog );
+ makedialog = memnew(ConfirmationDialog);
makedialog->set_title(TTR("Create Folder"));
add_child(makedialog);
- VBoxContainer *makevb= memnew( VBoxContainer );
+ VBoxContainer *makevb = memnew(VBoxContainer);
makedialog->add_child(makevb);
//makedialog->set_child_rect(makevb);
- makedirname = memnew( LineEdit );
- makevb->add_margin_child(TTR("Name:"),makedirname);
+ makedirname = memnew(LineEdit);
+ makevb->add_margin_child(TTR("Name:"), makedirname);
makedialog->register_text_enter(makedirname);
- makedialog->connect("confirmed",this,"_make_dir_confirm");
+ makedialog->connect("confirmed", this, "_make_dir_confirm");
- mkdirerr = memnew( AcceptDialog );
+ mkdirerr = memnew(AcceptDialog);
mkdirerr->set_text(TTR("Could not create folder."));
add_child(mkdirerr);
get_ok()->set_text(TTR("Choose"));
- must_reload=false;
-
-
-
+ must_reload = false;
}
diff --git a/editor/editor_dir_dialog.h b/editor/editor_dir_dialog.h
index 0577ff0442..2f2385e971 100644
--- a/editor/editor_dir_dialog.h
+++ b/editor/editor_dir_dialog.h
@@ -34,8 +34,7 @@
#include "scene/gui/tree.h"
class EditorDirDialog : public ConfirmationDialog {
- GDCLASS(EditorDirDialog,ConfirmationDialog);
-
+ GDCLASS(EditorDirDialog, ConfirmationDialog);
ConfirmationDialog *makedialog;
LineEdit *makedirname;
@@ -46,8 +45,8 @@ class EditorDirDialog : public ConfirmationDialog {
Tree *tree;
bool updating;
- void _item_collapsed(Object* p_item);
- void _update_dir(TreeItem* p_item);
+ void _item_collapsed(Object *p_item);
+ void _update_dir(TreeItem *p_item);
void _make_dir();
void _make_dir_confirm();
@@ -56,14 +55,12 @@ class EditorDirDialog : public ConfirmationDialog {
bool must_reload;
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_current_path(const String& p_path);
+public:
+ void set_current_path(const String &p_path);
void reload();
EditorDirDialog();
};
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index f5840d00fb..7ac299974c 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -27,20 +27,20 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_export.h"
-#include "version.h"
-#include "script_language.h"
-#include "global_config.h"
-#include "os/file_access.h"
-#include "os/dir_access.h"
#include "editor/editor_file_system.h"
-#include "io/resource_loader.h"
+#include "editor/plugins/script_editor_plugin.h"
#include "editor_node.h"
#include "editor_settings.h"
+#include "global_config.h"
#include "io/config_file.h"
-#include "io/resource_saver.h"
#include "io/md5.h"
-#include "editor/plugins/script_editor_plugin.h"
+#include "io/resource_loader.h"
+#include "io/resource_saver.h"
#include "io/zip_io.h"
+#include "os/dir_access.h"
+#include "os/file_access.h"
+#include "script_language.h"
+#include "version.h"
static int _get_pad(int p_alignment, int p_n) {
@@ -55,10 +55,10 @@ static int _get_pad(int p_alignment, int p_n) {
#define PCK_PADDING 16
-bool EditorExportPreset::_set(const StringName& p_name, const Variant& p_value) {
+bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) {
- if (values.has(p_name)) {
- values[p_name]=p_value;
+ if (values.has(p_name)) {
+ values[p_name] = p_value;
EditorExport::singleton->save_presets();
return true;
}
@@ -66,18 +66,18 @@ bool EditorExportPreset::_set(const StringName& p_name, const Variant& p_value)
return false;
}
-bool EditorExportPreset::_get(const StringName& p_name,Variant &r_ret) const{
+bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const {
if (values.has(p_name)) {
- r_ret=values[p_name];
+ r_ret = values[p_name];
return true;
}
return false;
}
-void EditorExportPreset::_get_property_list( List<PropertyInfo> *p_list) const{
+void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const {
- for (const List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) {
+ for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
p_list->push_back(E->get());
}
@@ -91,26 +91,24 @@ Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
Vector<String> EditorExportPreset::get_files_to_export() const {
Vector<String> files;
- for(Set<String>::Element *E=selected_files.front();E;E=E->next()) {
+ for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) {
files.push_back(E->get());
}
return files;
}
-void EditorExportPreset::set_name(const String& p_name) {
- name=p_name;
+void EditorExportPreset::set_name(const String &p_name) {
+ name = p_name;
EditorExport::singleton->save_presets();
-
}
String EditorExportPreset::get_name() const {
return name;
-
}
void EditorExportPreset::set_runnable(bool p_enable) {
- runnable=p_enable;
+ runnable = p_enable;
EditorExport::singleton->save_presets();
}
@@ -121,20 +119,18 @@ bool EditorExportPreset::is_runnable() const {
void EditorExportPreset::set_export_filter(ExportFilter p_filter) {
- export_filter=p_filter;
+ export_filter = p_filter;
EditorExport::singleton->save_presets();
-
}
EditorExportPreset::ExportFilter EditorExportPreset::get_export_filter() const {
return export_filter;
}
-void EditorExportPreset::set_include_filter(const String& p_include) {
+void EditorExportPreset::set_include_filter(const String &p_include) {
- include_filter=p_include;
+ include_filter = p_include;
EditorExport::singleton->save_presets();
-
}
String EditorExportPreset::get_include_filter() const {
@@ -142,9 +138,9 @@ String EditorExportPreset::get_include_filter() const {
return include_filter;
}
-void EditorExportPreset::set_exclude_filter(const String& p_exclude) {
+void EditorExportPreset::set_exclude_filter(const String &p_exclude) {
- exclude_filter=p_exclude;
+ exclude_filter = p_exclude;
EditorExport::singleton->save_presets();
}
@@ -153,28 +149,28 @@ String EditorExportPreset::get_exclude_filter() const {
return exclude_filter;
}
-void EditorExportPreset::add_export_file(const String& p_path) {
+void EditorExportPreset::add_export_file(const String &p_path) {
selected_files.insert(p_path);
EditorExport::singleton->save_presets();
}
-void EditorExportPreset::remove_export_file(const String& p_path) {
+void EditorExportPreset::remove_export_file(const String &p_path) {
selected_files.erase(p_path);
EditorExport::singleton->save_presets();
}
-bool EditorExportPreset::has_export_file(const String& p_path) {
+bool EditorExportPreset::has_export_file(const String &p_path) {
return selected_files.has(p_path);
}
-void EditorExportPreset::add_patch(const String& p_path,int p_at_pos) {
+void EditorExportPreset::add_patch(const String &p_path, int p_at_pos) {
- if (p_at_pos<0)
+ if (p_at_pos < 0)
patches.push_back(p_path);
else
- patches.insert(p_at_pos,p_path);
+ patches.insert(p_at_pos, p_path);
EditorExport::singleton->save_presets();
}
@@ -183,14 +179,14 @@ void EditorExportPreset::remove_patch(int p_idx) {
EditorExport::singleton->save_presets();
}
-void EditorExportPreset::set_patch(int p_index,const String& p_path) {
- ERR_FAIL_INDEX(p_index,patches.size());
- patches[p_index]=p_path;
+void EditorExportPreset::set_patch(int p_index, const String &p_path) {
+ ERR_FAIL_INDEX(p_index, patches.size());
+ patches[p_index] = p_path;
EditorExport::singleton->save_presets();
}
String EditorExportPreset::get_patch(int p_index) {
- ERR_FAIL_INDEX_V(p_index,patches.size(),String());
+ ERR_FAIL_INDEX_V(p_index, patches.size(), String());
return patches[p_index];
}
@@ -200,136 +196,131 @@ Vector<String> EditorExportPreset::get_patches() const {
EditorExportPreset::EditorExportPreset() {
- export_filter=EXPORT_ALL_RESOURCES;
- runnable=false;
+ export_filter = EXPORT_ALL_RESOURCES;
+ runnable = false;
}
-
///////////////////////////////////
void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) {
String host = EditorSettings::get_singleton()->get("network/debug_host");
- if (p_flags&DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST)
- host="localhost";
+ if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST)
+ host = "localhost";
- if (p_flags&DEBUG_FLAG_DUMB_CLIENT) {
+ if (p_flags & DEBUG_FLAG_DUMB_CLIENT) {
int port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password");
r_flags.push_back("-rfs");
- r_flags.push_back(host+":"+itos(port));
- if (passwd!="") {
+ r_flags.push_back(host + ":" + itos(port));
+ if (passwd != "") {
r_flags.push_back("-rfs_pass");
r_flags.push_back(passwd);
}
}
- if (p_flags&DEBUG_FLAG_REMOTE_DEBUG) {
+ if (p_flags & DEBUG_FLAG_REMOTE_DEBUG) {
r_flags.push_back("-rdebug");
- r_flags.push_back(host+":"+String::num(GLOBAL_DEF("network/debug/remote_port", 6007)));
+ r_flags.push_back(host + ":" + String::num(GLOBAL_DEF("network/debug/remote_port", 6007)));
List<String> breakpoints;
ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
-
if (breakpoints.size()) {
r_flags.push_back("-bp");
String bpoints;
- for(const List<String>::Element *E=breakpoints.front();E;E=E->next()) {
+ for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
- bpoints+=E->get().replace(" ","%20");
+ bpoints += E->get().replace(" ", "%20");
if (E->next())
- bpoints+=",";
+ bpoints += ",";
}
r_flags.push_back(bpoints);
}
-
}
- if (p_flags&DEBUG_FLAG_VIEW_COLLISONS) {
+ if (p_flags & DEBUG_FLAG_VIEW_COLLISONS) {
r_flags.push_back("-debugcol");
}
- if (p_flags&DEBUG_FLAG_VIEW_NAVIGATION) {
+ if (p_flags & DEBUG_FLAG_VIEW_NAVIGATION) {
r_flags.push_back("-debugnav");
}
}
-Error EditorExportPlatform::_save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) {
+Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) {
- PackData *pd = (PackData*)p_userdata;
+ PackData *pd = (PackData *)p_userdata;
SavedData sd;
- sd.path_utf8=p_path.utf8();
+ sd.path_utf8 = p_path.utf8();
sd.ofs = pd->f->get_pos();
sd.size = p_data.size();
- pd->f->store_buffer(p_data.ptr(),p_data.size());
- int pad = _get_pad(PCK_PADDING,sd.size);
- for(int i=0;i<pad;i++) {
+ pd->f->store_buffer(p_data.ptr(), p_data.size());
+ int pad = _get_pad(PCK_PADDING, sd.size);
+ for (int i = 0; i < pad; i++) {
pd->f->store_8(0);
}
{
MD5_CTX ctx;
MD5Init(&ctx);
- MD5Update(&ctx,(unsigned char*)p_data.ptr(),p_data.size());
+ MD5Update(&ctx, (unsigned char *)p_data.ptr(), p_data.size());
MD5Final(&ctx);
sd.md5.resize(16);
- for(int i=0;i<16;i++) {
- sd.md5[i]=ctx.digest[i];
+ for (int i = 0; i < 16; i++) {
+ sd.md5[i] = ctx.digest[i];
}
}
pd->file_ofs.push_back(sd);
- pd->ep->step(TTR("Storing File:")+" "+p_path,2+p_file*100/p_total,false);
+ pd->ep->step(TTR("Storing File:") + " " + p_path, 2 + p_file * 100 / p_total, false);
return OK;
}
-Error EditorExportPlatform::_save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) {
-
+Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) {
- String path=p_path.replace_first("res://","");
+ String path = p_path.replace_first("res://", "");
- ZipData *zd = (ZipData*)p_userdata;
+ ZipData *zd = (ZipData *)p_userdata;
- zipFile zip=(zipFile)zd->zip;
+ zipFile zip = (zipFile)zd->zip;
zipOpenNewFileInZip(zip,
- path.utf8().get_data(),
- NULL,
- NULL,
- 0,
- NULL,
- 0,
- NULL,
- Z_DEFLATED,
- Z_DEFAULT_COMPRESSION);
-
- zipWriteInFileInZip(zip,p_data.ptr(),p_data.size());
+ path.utf8().get_data(),
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ Z_DEFLATED,
+ Z_DEFAULT_COMPRESSION);
+
+ zipWriteInFileInZip(zip, p_data.ptr(), p_data.size());
zipCloseFileInZip(zip);
- zd->ep->step(TTR("Storing File:")+" "+p_path,2+p_file*100/p_total,false);
+ zd->ep->step(TTR("Storing File:") + " " + p_path, 2 + p_file * 100 / p_total, false);
return OK;
}
String EditorExportPlatform::find_export_template(String template_file_name, String *err) const {
- String user_file = EditorSettings::get_singleton()->get_settings_path()
- +"/templates/"+itos(VERSION_MAJOR)+"."+itos(VERSION_MINOR)+"."+_MKSTR(VERSION_STATUS)+"/"+template_file_name;
- String system_file=OS::get_singleton()->get_installed_templates_path();
- bool has_system_path=(system_file!="");
- system_file+=template_file_name;
+ String user_file = EditorSettings::get_singleton()->get_settings_path() + "/templates/" + itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "." + _MKSTR(VERSION_STATUS) + "/" + template_file_name;
+ String system_file = OS::get_singleton()->get_installed_templates_path();
+ bool has_system_path = (system_file != "");
+ system_file += template_file_name;
// Prefer user file
if (FileAccess::exists(user_file)) {
@@ -345,11 +336,11 @@ String EditorExportPlatform::find_export_template(String template_file_name, Str
// Not found
if (err) {
- *err+="No export template found at \""+user_file+"\"";
+ *err += "No export template found at \"" + user_file + "\"";
if (has_system_path)
- *err+="\n or \""+system_file+"\".";
+ *err += "\n or \"" + system_file + "\".";
else
- *err+=".";
+ *err += ".";
}
return "";
}
@@ -358,34 +349,32 @@ Ref<EditorExportPreset> EditorExportPlatform::create_preset() {
Ref<EditorExportPreset> preset;
preset.instance();
- preset->platform=Ref<EditorExportPlatform>(this);
+ preset->platform = Ref<EditorExportPlatform>(this);
List<ExportOption> options;
get_export_options(&options);
- for (List<ExportOption>::Element *E=options.front();E;E=E->next()) {
+ for (List<ExportOption>::Element *E = options.front(); E; E = E->next()) {
preset->properties.push_back(E->get().option);
- preset->values[E->get().option.name]=E->get().default_value;
+ preset->values[E->get().option.name] = E->get().default_value;
}
return preset;
-
}
-void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir,Set<String>& p_paths) {
+void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir, Set<String> &p_paths) {
- for(int i=0;i<p_dir->get_subdir_count();i++) {
- _export_find_resources(p_dir->get_subdir(i),p_paths);
+ for (int i = 0; i < p_dir->get_subdir_count(); i++) {
+ _export_find_resources(p_dir->get_subdir(i), p_paths);
}
- for(int i=0;i<p_dir->get_file_count();i++) {
+ for (int i = 0; i < p_dir->get_file_count(); i++) {
p_paths.insert(p_dir->get_file_path(i));
}
}
-
-void EditorExportPlatform::_export_find_dependencies(const String& p_path,Set<String>& p_paths) {
+void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set<String> &p_paths) {
if (p_paths.has(p_path))
return;
@@ -394,94 +383,93 @@ void EditorExportPlatform::_export_find_dependencies(const String& p_path,Set<St
EditorFileSystemDirectory *dir;
int file_idx;
- dir = EditorFileSystem::get_singleton()->find_file(p_path,&file_idx);
+ dir = EditorFileSystem::get_singleton()->find_file(p_path, &file_idx);
if (!dir)
return;
Vector<String> deps = dir->get_file_deps(file_idx);
- for(int i=0;i<deps.size();i++) {
+ for (int i = 0; i < deps.size(); i++) {
- _export_find_dependencies(deps[i],p_paths);
+ _export_find_dependencies(deps[i], p_paths);
}
}
-
-Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset>& p_preset,EditorExportSaveFunction p_func, void* p_udata) {
+Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata) {
Ref<EditorExportPlatform> platform = p_preset->get_platform();
List<String> feature_list;
- platform->get_preset_features(p_preset,&feature_list);
+ platform->get_preset_features(p_preset, &feature_list);
//figure out features
Set<String> features;
- for (List<String>::Element *E=feature_list.front();E;E=E->next()) {
+ for (List<String>::Element *E = feature_list.front(); E; E = E->next()) {
features.insert(E->get());
}
//figure out paths of files that will be exported
Set<String> paths;
- if (p_preset->get_export_filter()==EditorExportPreset::EXPORT_ALL_RESOURCES) {
+ if (p_preset->get_export_filter() == EditorExportPreset::EXPORT_ALL_RESOURCES) {
//find stuff
- _export_find_resources(EditorFileSystem::get_singleton()->get_filesystem(),paths);
+ _export_find_resources(EditorFileSystem::get_singleton()->get_filesystem(), paths);
} else {
- bool scenes_only = p_preset->get_export_filter()==EditorExportPreset::EXPORT_SELECTED_SCENES;
+ bool scenes_only = p_preset->get_export_filter() == EditorExportPreset::EXPORT_SELECTED_SCENES;
Vector<String> files = p_preset->get_files_to_export();
- for(int i=0;i<files.size();i++) {
- if (scenes_only && ResourceLoader::get_resource_type(files[i])!="PackedScene")
+ for (int i = 0; i < files.size(); i++) {
+ if (scenes_only && ResourceLoader::get_resource_type(files[i]) != "PackedScene")
continue;
- _export_find_dependencies(files[i],paths);
+ _export_find_dependencies(files[i], paths);
}
}
//store everything in the export medium
int idx = 0;
- int total=paths.size();
+ int total = paths.size();
- for(Set<String>::Element *E=paths.front();E;E=E->next()) {
+ for (Set<String>::Element *E = paths.front(); E; E = E->next()) {
String path = E->get();
- if (FileAccess::exists(path+".import")) {
+ if (FileAccess::exists(path + ".import")) {
//file is imported, replace by what it imports
Ref<ConfigFile> config;
config.instance();
- Error err = config->load(path+".import");
- if (err!=OK) {
- ERR_PRINTS("Could not parse: '"+path+"', not exported.");
+ Error err = config->load(path + ".import");
+ if (err != OK) {
+ ERR_PRINTS("Could not parse: '" + path + "', not exported.");
continue;
}
List<String> remaps;
- config->get_section_keys("remap",&remaps);
+ config->get_section_keys("remap", &remaps);
- for(List<String>::Element *F=remaps.front();F;F=F->next()) {
+ for (List<String>::Element *F = remaps.front(); F; F = F->next()) {
- String remap=F->get();
- if (remap=="path") {
- String remapped_path=config->get_value("remap",remap);
+ String remap = F->get();
+ if (remap == "path") {
+ String remapped_path = config->get_value("remap", remap);
Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path);
- p_func(p_udata,remapped_path,array,idx,total);
+ p_func(p_udata, remapped_path, array, idx, total);
} else if (remap.begins_with("path.")) {
- String feature = remap.get_slice(".",1);
+ String feature = remap.get_slice(".", 1);
if (features.has(feature)) {
- String remapped_path=config->get_value("remap",remap);
+ String remapped_path = config->get_value("remap", remap);
Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path);
- p_func(p_udata,remapped_path,array,idx,total);
+ p_func(p_udata, remapped_path, array, idx, total);
}
}
}
//also save the .import file
- Vector<uint8_t> array = FileAccess::get_file_as_array(path+".import");
- p_func(p_udata,path+".import",array,idx,total);
+ Vector<uint8_t> array = FileAccess::get_file_as_array(path + ".import");
+ p_func(p_udata, path + ".import", array, idx, total);
} else {
//just store it as it comes
Vector<uint8_t> array = FileAccess::get_file_as_array(path);
- p_func(p_udata,path,array,idx,total);
+ p_func(p_udata, path, array, idx, total);
}
idx++;
@@ -489,29 +477,29 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset>&
//save config!
- String config_file="godot.cfb";
- String engine_cfb =EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmp"+config_file;
+ String config_file = "godot.cfb";
+ String engine_cfb = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmp" + config_file;
GlobalConfig::get_singleton()->save_custom(engine_cfb);
Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb);
- p_func(p_udata,"res://"+config_file,data,idx,total);
+ p_func(p_udata, "res://" + config_file, data, idx, total);
return OK;
}
-Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset>& p_preset,const String& p_path) {
+Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
- EditorProgress ep("savepack",TTR("Packing"),102);
+ EditorProgress ep("savepack", TTR("Packing"), 102);
- String tmppath = EditorSettings::get_singleton()->get_settings_path()+"/tmp/packtmp";
- FileAccess *ftmp = FileAccess::open(tmppath,FileAccess::WRITE);
- ERR_FAIL_COND_V(!ftmp,ERR_CANT_CREATE)
+ String tmppath = EditorSettings::get_singleton()->get_settings_path() + "/tmp/packtmp";
+ FileAccess *ftmp = FileAccess::open(tmppath, FileAccess::WRITE);
+ ERR_FAIL_COND_V(!ftmp, ERR_CANT_CREATE)
PackData pd;
- pd.ep=&ep;
- pd.f=ftmp;
+ pd.ep = &ep;
+ pd.f = ftmp;
- Error err = export_project_files(p_preset,_save_pack_file,&pd);
+ Error err = export_project_files(p_preset, _save_pack_file, &pd);
memdelete(ftmp); //close tmp file
@@ -520,15 +508,14 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset>& p_preset,co
pd.file_ofs.sort(); //do sort, so we can do binary search later
-
- FileAccess *f = FileAccess::open(p_path,FileAccess::WRITE);
- ERR_FAIL_COND_V(!f,ERR_CANT_CREATE)
+ FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE);
+ ERR_FAIL_COND_V(!f, ERR_CANT_CREATE)
f->store_32(0x43504447); //GDPK
f->store_32(1); //pack version
f->store_32(VERSION_MAJOR);
f->store_32(VERSION_MINOR);
f->store_32(0); //hmph
- for(int i=0;i<16;i++) {
+ for (int i = 0; i < 16; i++) {
//reserved
f->store_32(0);
}
@@ -539,55 +526,54 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset>& p_preset,co
//precalculate header size
- for(int i=0;i<pd.file_ofs.size();i++) {
+ for (int i = 0; i < pd.file_ofs.size(); i++) {
header_size += 4; // size of path string (32 bits is enough)
uint32_t string_len = pd.file_ofs[i].path_utf8.length();
- header_size += string_len + _get_pad(4,string_len); ///size of path string
+ header_size += string_len + _get_pad(4, string_len); ///size of path string
header_size += 8; // offset to file _with_ header size included
header_size += 8; // size of file
- header_size +=16; // md5
-
+ header_size += 16; // md5
}
- size_t header_padding = _get_pad(PCK_PADDING,header_size);
+ size_t header_padding = _get_pad(PCK_PADDING, header_size);
-
- for(int i=0;i<pd.file_ofs.size();i++) {
+ for (int i = 0; i < pd.file_ofs.size(); i++) {
uint32_t string_len = pd.file_ofs[i].path_utf8.length();
- uint32_t pad = _get_pad(4,string_len);;
- f->store_32(string_len+pad);
- f->store_buffer((const uint8_t*)pd.file_ofs[i].path_utf8.get_data(),string_len);
- for(uint32_t j=0;j<pad;j++) {
+ uint32_t pad = _get_pad(4, string_len);
+ ;
+ f->store_32(string_len + pad);
+ f->store_buffer((const uint8_t *)pd.file_ofs[i].path_utf8.get_data(), string_len);
+ for (uint32_t j = 0; j < pad; j++) {
f->store_8(0);
}
f->store_64(pd.file_ofs[i].ofs + header_padding + header_size);
f->store_64(pd.file_ofs[i].size); // pay attention here, this is where file is
- f->store_buffer(pd.file_ofs[i].md5.ptr(),16); //also save md5 for file
+ f->store_buffer(pd.file_ofs[i].md5.ptr(), 16); //also save md5 for file
}
- for(uint32_t j=0;j<header_padding;j++) {
+ for (uint32_t j = 0; j < header_padding; j++) {
f->store_8(0);
}
//save the rest of the data
- ftmp = FileAccess::open(tmppath,FileAccess::READ);
+ ftmp = FileAccess::open(tmppath, FileAccess::READ);
if (!ftmp) {
memdelete(f);
- ERR_FAIL_COND_V(!ftmp,ERR_CANT_CREATE)
+ ERR_FAIL_COND_V(!ftmp, ERR_CANT_CREATE)
}
- const int bufsize=16384;
+ const int bufsize = 16384;
uint8_t buf[bufsize];
- while(true) {
+ while (true) {
- int got = ftmp->get_buffer(buf,bufsize);
- if (got<=0)
+ int got = ftmp->get_buffer(buf, bufsize);
+ if (got <= 0)
break;
- f->store_buffer(buf,got);
+ f->store_buffer(buf, got);
}
memdelete(ftmp);
@@ -598,91 +584,81 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset>& p_preset,co
return OK;
}
-Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset>& p_preset,const String& p_path) {
+Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
- EditorProgress ep("savezip",TTR("Packing"),102);
+ EditorProgress ep("savezip", TTR("Packing"), 102);
//FileAccess *tmp = FileAccess::open(tmppath,FileAccess::WRITE);
FileAccess *src_f;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
- zipFile zip=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io);
+ zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io);
ZipData zd;
- zd.ep=&ep;
- zd.zip=zip;
-
+ zd.ep = &ep;
+ zd.zip = zip;
- Error err = export_project_files(p_preset,_save_zip_file,&zd);
+ Error err = export_project_files(p_preset, _save_zip_file, &zd);
- zipClose(zip,NULL);
+ zipClose(zip, NULL);
return OK;
}
EditorExportPlatform::EditorExportPlatform() {
-
-
}
-
////
-EditorExport *EditorExport::singleton=NULL;
-
+EditorExport *EditorExport::singleton = NULL;
void EditorExport::_save() {
-
Ref<ConfigFile> config;
config.instance();
- for(int i=0;i<export_presets.size();i++) {
+ for (int i = 0; i < export_presets.size(); i++) {
Ref<EditorExportPreset> preset = export_presets[i];
- String section="preset."+itos(i);
+ String section = "preset." + itos(i);
- config->set_value(section,"name",preset->get_name());
- config->set_value(section,"platform",preset->get_platform()->get_name());
- config->set_value(section,"runnable",preset->is_runnable());
- bool save_files=false;
- switch(preset->get_export_filter()) {
+ config->set_value(section, "name", preset->get_name());
+ config->set_value(section, "platform", preset->get_platform()->get_name());
+ config->set_value(section, "runnable", preset->is_runnable());
+ bool save_files = false;
+ switch (preset->get_export_filter()) {
case EditorExportPreset::EXPORT_ALL_RESOURCES: {
- config->set_value(section,"export_filter","all_resources");
+ config->set_value(section, "export_filter", "all_resources");
} break;
case EditorExportPreset::EXPORT_SELECTED_SCENES: {
- config->set_value(section,"export_filter","scenes");
- save_files=true;
+ config->set_value(section, "export_filter", "scenes");
+ save_files = true;
} break;
case EditorExportPreset::EXPORT_SELECTED_RESOURCES: {
- config->set_value(section,"export_filter","resources");
- save_files=true;
+ config->set_value(section, "export_filter", "resources");
+ save_files = true;
} break;
-
-
}
if (save_files) {
Vector<String> export_files = preset->get_files_to_export();
- config->set_value(section,"export_files",export_files);
+ config->set_value(section, "export_files", export_files);
}
- config->set_value(section,"include_filter",preset->get_include_filter());
- config->set_value(section,"exclude_filter",preset->get_exclude_filter());
- config->set_value(section,"patch_list",preset->get_patches());
+ config->set_value(section, "include_filter", preset->get_include_filter());
+ config->set_value(section, "exclude_filter", preset->get_exclude_filter());
+ config->set_value(section, "patch_list", preset->get_patches());
- String option_section="preset."+itos(i)+".options";
+ String option_section = "preset." + itos(i) + ".options";
- for (const List<PropertyInfo>::Element *E=preset->get_properties().front();E;E=E->next()) {
- config->set_value(option_section,E->get().name,preset->get(E->get().name));
+ for (const List<PropertyInfo>::Element *E = preset->get_properties().front(); E; E = E->next()) {
+ config->set_value(option_section, E->get().name, preset->get(E->get().name));
}
}
config->save("res://export_presets.cfg");
print_line("saved ok");
-
}
-
void EditorExport::save_presets() {
print_line("save presets");
@@ -693,10 +669,10 @@ void EditorExport::save_presets() {
void EditorExport::_bind_methods() {
- ClassDB::bind_method("_save",&EditorExport::_save);
+ ClassDB::bind_method("_save", &EditorExport::_save);
}
-void EditorExport::add_export_platform(const Ref<EditorExportPlatform>& p_platform) {
+void EditorExport::add_export_platform(const Ref<EditorExportPlatform> &p_platform) {
export_platforms.push_back(p_platform);
}
@@ -708,20 +684,17 @@ int EditorExport::get_export_platform_count() {
Ref<EditorExportPlatform> EditorExport::get_export_platform(int p_idx) {
- ERR_FAIL_INDEX_V(p_idx,export_platforms.size(),Ref<EditorExportPlatform>());
+ ERR_FAIL_INDEX_V(p_idx, export_platforms.size(), Ref<EditorExportPlatform>());
return export_platforms[p_idx];
}
+void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos) {
-void EditorExport::add_export_preset(const Ref<EditorExportPreset>& p_preset,int p_at_pos) {
-
- if (p_at_pos<0)
+ if (p_at_pos < 0)
export_presets.push_back(p_preset);
else
- export_presets.insert(p_at_pos,p_preset);
-
-
+ export_presets.insert(p_at_pos, p_preset);
}
int EditorExport::get_export_preset_count() const {
@@ -731,7 +704,7 @@ int EditorExport::get_export_preset_count() const {
Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) {
- ERR_FAIL_INDEX_V( p_idx, export_presets.size(),Ref<EditorExportPreset>() );
+ ERR_FAIL_INDEX_V(p_idx, export_presets.size(), Ref<EditorExportPreset>());
return export_presets[p_idx];
}
@@ -742,7 +715,7 @@ void EditorExport::remove_export_preset(int p_idx) {
void EditorExport::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
load_config();
}
}
@@ -752,24 +725,24 @@ void EditorExport::load_config() {
Ref<ConfigFile> config;
config.instance();
Error err = config->load("res://export_presets.cfg");
- if (err!=OK)
+ if (err != OK)
return;
- block_save=true;
+ block_save = true;
- int index=0;
- while(true) {
+ int index = 0;
+ while (true) {
- String section = "preset."+itos(index);
+ String section = "preset." + itos(index);
if (!config->has_section(section))
break;
- String platform=config->get_value(section,"platform");
+ String platform = config->get_value(section, "platform");
Ref<EditorExportPreset> preset;
- for(int i=0;i<export_platforms.size();i++) {
- if (export_platforms[i]->get_name()==platform) {
+ for (int i = 0; i < export_platforms.size(); i++) {
+ if (export_platforms[i]->get_name() == platform) {
preset = export_platforms[i]->create_preset();
break;
}
@@ -780,86 +753,79 @@ void EditorExport::load_config() {
ERR_CONTINUE(!preset.is_valid());
}
- preset->set_name( config->get_value(section,"name") );
- preset->set_runnable( config->get_value(section,"runnable") );
+ preset->set_name(config->get_value(section, "name"));
+ preset->set_runnable(config->get_value(section, "runnable"));
- String export_filter = config->get_value(section,"export_filter");
+ String export_filter = config->get_value(section, "export_filter");
- bool get_files=false;
+ bool get_files = false;
- if (export_filter=="all_resources") {
+ if (export_filter == "all_resources") {
preset->set_export_filter(EditorExportPreset::EXPORT_ALL_RESOURCES);
- } else if (export_filter=="scenes") {
+ } else if (export_filter == "scenes") {
preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_SCENES);
- get_files=true;
- } else if (export_filter=="resources") {
+ get_files = true;
+ } else if (export_filter == "resources") {
preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_RESOURCES);
- get_files=true;
+ get_files = true;
}
if (get_files) {
- Vector<String> files = config->get_value(section,"export_files");
+ Vector<String> files = config->get_value(section, "export_files");
- for(int i=0;i<files.size();i++) {
+ for (int i = 0; i < files.size(); i++) {
preset->add_export_file(files[i]);
}
}
- preset->set_include_filter( config->get_value(section,"include_filter") );
- preset->set_exclude_filter( config->get_value(section,"exclude_filter") );
+ preset->set_include_filter(config->get_value(section, "include_filter"));
+ preset->set_exclude_filter(config->get_value(section, "exclude_filter"));
+ Vector<String> patch_list = config->get_value(section, "patch_list");
- Vector<String> patch_list = config->get_value(section,"patch_list");
-
- for(int i=0;i<patch_list.size();i++) {
+ for (int i = 0; i < patch_list.size(); i++) {
preset->add_patch(patch_list[i]);
}
- String option_section="preset."+itos(index)+".options";
+ String option_section = "preset." + itos(index) + ".options";
List<String> options;
- config->get_section_keys(option_section,&options);
+ config->get_section_keys(option_section, &options);
- for (List<String>::Element *E=options.front();E;E=E->next()) {
+ for (List<String>::Element *E = options.front(); E; E = E->next()) {
- Variant value = config->get_value(option_section,E->get());
+ Variant value = config->get_value(option_section, E->get());
- preset->set(E->get(),value);
+ preset->set(E->get(), value);
}
add_export_preset(preset);
index++;
}
- block_save=false;
-
+ block_save = false;
}
-
-
EditorExport::EditorExport() {
- save_timer = memnew( Timer );
+ save_timer = memnew(Timer);
add_child(save_timer);
save_timer->set_wait_time(0.8);
save_timer->set_one_shot(true);
- save_timer->connect("timeout",this,"_save");
- block_save=false;
+ save_timer->connect("timeout", this, "_save");
+ block_save = false;
- singleton=this;
+ singleton = this;
}
EditorExport::~EditorExport() {
-
-
}
-
//////////
-void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset>& p_preset,List<String>* r_features) {
+void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
if (p_preset->get("texture_format/s3tc")) {
r_features->push_back("s3tc");
@@ -874,35 +840,35 @@ void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset>&
void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) {
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"texture_format/s3tc"),true));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"texture_format/etc"),false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"texture_format/etc2"),false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"binary_format/64_bits"),true));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING,"custom_template/release",PROPERTY_HINT_GLOBAL_FILE),""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING,"custom_template/debug",PROPERTY_HINT_GLOBAL_FILE),""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/64_bits"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE), ""));
}
String EditorExportPlatformPC::get_name() const {
return name;
}
-Ref<Texture> EditorExportPlatformPC::get_logo() const {
+Ref<Texture> EditorExportPlatformPC::get_logo() const {
return logo;
}
-bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset>& p_preset,String &r_error, bool &r_missing_templates) const {
+bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
- r_missing_templates=false;
+ r_missing_templates = false;
- if (find_export_template(release_file_32)==String()) {
- r_missing_templates=true;
- } else if (find_export_template(debug_file_32)==String()) {
- r_missing_templates=true;
- } else if (find_export_template(release_file_64)==String()) {
- r_missing_templates=true;
- } else if (find_export_template(debug_file_64)==String()) {
- r_missing_templates=true;
+ if (find_export_template(release_file_32) == String()) {
+ r_missing_templates = true;
+ } else if (find_export_template(debug_file_32) == String()) {
+ r_missing_templates = true;
+ } else if (find_export_template(release_file_64) == String()) {
+ r_missing_templates = true;
+ } else if (find_export_template(debug_file_64) == String()) {
+ r_missing_templates = true;
}
return !r_missing_templates;
}
@@ -911,64 +877,62 @@ String EditorExportPlatformPC::get_binary_extension() const {
return extension;
}
-Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset>& p_preset, bool p_debug, const String& p_path, int p_flags) {
+Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
return OK;
}
-void EditorExportPlatformPC::set_extension(const String& p_extension) {
- extension=p_extension;
+void EditorExportPlatformPC::set_extension(const String &p_extension) {
+ extension = p_extension;
}
-void EditorExportPlatformPC::set_name(const String& p_name) {
- name=p_name;
+void EditorExportPlatformPC::set_name(const String &p_name) {
+ name = p_name;
}
-void EditorExportPlatformPC::set_logo(const Ref<Texture>& p_logo) {
- logo=p_logo;
+void EditorExportPlatformPC::set_logo(const Ref<Texture> &p_logo) {
+ logo = p_logo;
}
-void EditorExportPlatformPC::set_release_64(const String& p_file) {
+void EditorExportPlatformPC::set_release_64(const String &p_file) {
- release_file_64=p_file;
+ release_file_64 = p_file;
}
-void EditorExportPlatformPC::set_release_32(const String& p_file){
+void EditorExportPlatformPC::set_release_32(const String &p_file) {
- release_file_32=p_file;
+ release_file_32 = p_file;
}
-void EditorExportPlatformPC::set_debug_64(const String& p_file){
+void EditorExportPlatformPC::set_debug_64(const String &p_file) {
- debug_file_64=p_file;
+ debug_file_64 = p_file;
}
-void EditorExportPlatformPC::set_debug_32(const String& p_file){
-
- debug_file_32=p_file;
+void EditorExportPlatformPC::set_debug_32(const String &p_file) {
+ debug_file_32 = p_file;
}
EditorExportPlatformPC::EditorExportPlatformPC() {
-
}
////////
#if 0
-#include "version.h"
-#include "script_language.h"
-#include "global_config.h"
-#include "os/file_access.h"
-#include "os/dir_access.h"
#include "editor/editor_file_system.h"
-#include "io/resource_loader.h"
+#include "editor/plugins/script_editor_plugin.h"
#include "editor_node.h"
#include "editor_settings.h"
+#include "global_config.h"
#include "io/config_file.h"
-#include "io/resource_saver.h"
#include "io/md5.h"
-#include "io_plugins/editor_texture_import_plugin.h"
-#include "editor/plugins/script_editor_plugin.h"
+#include "io/resource_loader.h"
+#include "io/resource_saver.h"
#include "io/zip_io.h"
+#include "io_plugins/editor_texture_import_plugin.h"
+#include "os/dir_access.h"
+#include "os/file_access.h"
+#include "script_language.h"
+#include "version.h"
String EditorImportPlugin::validate_source_path(const String& p_path) {
diff --git a/editor/editor_export.h b/editor/editor_export.h
index 8a9dc965e5..fe3c3df7d4 100644
--- a/editor/editor_export.h
+++ b/editor/editor_export.h
@@ -29,12 +29,10 @@
#ifndef EDITOR_EXPORT_H
#define EDITOR_EXPORT_H
-
-
#include "resource.h"
#include "scene/main/node.h"
-#include "scene/resources/texture.h"
#include "scene/main/timer.h"
+#include "scene/resources/texture.h"
class EditorProgress;
class FileAccess;
@@ -43,7 +41,7 @@ class EditorFileSystemDirectory;
class EditorExportPreset : public Reference {
- GDCLASS( EditorExportPreset,Reference )
+ GDCLASS(EditorExportPreset, Reference)
public:
enum ExportFilter {
EXPORT_ALL_RESOURCES,
@@ -52,7 +50,6 @@ public:
};
private:
-
Ref<EditorExportPlatform> platform;
ExportFilter export_filter;
String include_filter;
@@ -64,31 +61,30 @@ private:
Vector<String> patches;
-
-friend class EditorExport;
-friend class EditorExportPlatform;
+ friend class EditorExport;
+ friend class EditorExportPlatform;
List<PropertyInfo> properties;
- Map<StringName,Variant> values;
+ Map<StringName, Variant> values;
String name;
+
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;
public:
-
Ref<EditorExportPlatform> get_platform() const;
- bool has(const StringName& p_property) const { return values.has(p_property); }
+ bool has(const StringName &p_property) const { return values.has(p_property); }
Vector<String> get_files_to_export() const;
- void add_export_file(const String& p_path);
- void remove_export_file(const String& p_path);
- bool has_export_file(const String& p_path);
+ void add_export_file(const String &p_path);
+ void remove_export_file(const String &p_path);
+ bool has_export_file(const String &p_path);
- void set_name(const String& p_name);
+ void set_name(const String &p_name);
String get_name() const;
void set_runnable(bool p_enable);
@@ -97,34 +93,31 @@ public:
void set_export_filter(ExportFilter p_filter);
ExportFilter get_export_filter() const;
- void set_include_filter(const String& p_include);
+ void set_include_filter(const String &p_include);
String get_include_filter() const;
- void set_exclude_filter(const String& p_exclude);
+ void set_exclude_filter(const String &p_exclude);
String get_exclude_filter() const;
- void add_patch(const String& p_path,int p_at_pos=-1);
- void set_patch(int p_index,const String& p_path);
+ void add_patch(const String &p_path, int p_at_pos = -1);
+ void set_patch(int p_index, const String &p_path);
String get_patch(int p_index);
void remove_patch(int p_idx);
Vector<String> get_patches() const;
- const List<PropertyInfo>& get_properties() const { return properties; }
+ const List<PropertyInfo> &get_properties() const { return properties; }
EditorExportPreset();
};
-
class EditorExportPlatform : public Reference {
- GDCLASS( EditorExportPlatform,Reference )
+ GDCLASS(EditorExportPlatform, Reference)
public:
-
- typedef Error (*EditorExportSaveFunction)(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
+ typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
private:
-
struct SavedData {
uint64_t ofs;
@@ -132,7 +125,7 @@ private:
Vector<uint8_t> md5;
CharString path_utf8;
- bool operator<(const SavedData& p_data) const {
+ bool operator<(const SavedData &p_data) const {
return path_utf8 < p_data.path_utf8;
}
};
@@ -146,47 +139,43 @@ private:
struct ZipData {
- void* zip;
+ void *zip;
EditorProgress *ep;
-
};
- void _export_find_resources(EditorFileSystemDirectory *p_dir,Set<String>& p_paths);
- void _export_find_dependencies(const String& p_path,Set<String>& p_paths);
+ void _export_find_resources(EditorFileSystemDirectory *p_dir, Set<String> &p_paths);
+ void _export_find_dependencies(const String &p_path, Set<String> &p_paths);
void gen_debug_flags(Vector<String> &r_flags, int p_flags);
- static Error _save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
- static Error _save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
-
+ static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
+ static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
protected:
-
- virtual void get_preset_features(const Ref<EditorExportPreset>& p_preset,List<String> *r_features)=0;
- String find_export_template(String template_file_name, String *err=NULL) const;
+ virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0;
+ String find_export_template(String template_file_name, String *err = NULL) const;
public:
-
-
struct ExportOption {
PropertyInfo option;
Variant default_value;
- ExportOption(const PropertyInfo& p_info,const Variant& p_default) { option=p_info; default_value=p_default; }
+ ExportOption(const PropertyInfo &p_info, const Variant &p_default) {
+ option = p_info;
+ default_value = p_default;
+ }
ExportOption() {}
};
virtual Ref<EditorExportPreset> create_preset();
- virtual void get_export_options(List<ExportOption> *r_options)=0;
- virtual String get_name() const =0;
- virtual Ref<Texture> get_logo() const =0;
-
-
- Error export_project_files(const Ref<EditorExportPreset>& p_preset,EditorExportSaveFunction p_func, void* p_udata);
+ virtual void get_export_options(List<ExportOption> *r_options) = 0;
+ virtual String get_name() const = 0;
+ virtual Ref<Texture> get_logo() const = 0;
- Error save_pack(const Ref<EditorExportPreset>& p_preset,const String& p_path);
- Error save_zip(const Ref<EditorExportPreset>& p_preset,const String& p_path);
+ Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata);
+ Error save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path);
+ Error save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path);
virtual bool poll_devices() { return false; }
virtual int get_device_count() const { return 0; }
@@ -194,26 +183,25 @@ public:
virtual String get_device_info(int p_device) const { return ""; }
enum DebugFlags {
- DEBUG_FLAG_DUMB_CLIENT=1,
- DEBUG_FLAG_REMOTE_DEBUG=2,
- DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST=4,
- DEBUG_FLAG_VIEW_COLLISONS=8,
- DEBUG_FLAG_VIEW_NAVIGATION=16,
+ DEBUG_FLAG_DUMB_CLIENT = 1,
+ DEBUG_FLAG_REMOTE_DEBUG = 2,
+ DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST = 4,
+ DEBUG_FLAG_VIEW_COLLISONS = 8,
+ DEBUG_FLAG_VIEW_NAVIGATION = 16,
};
- virtual Error run(int p_device,int p_debug_flags) { return OK; }
+ virtual Error run(int p_device, int p_debug_flags) { return OK; }
- virtual bool can_export(const Ref<EditorExportPreset>& p_preset,String &r_error,bool &r_missing_templates) const=0;
+ virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0;
- virtual String get_binary_extension() const=0;
- virtual Error export_project(const Ref<EditorExportPreset>& p_preset,bool p_debug,const String& p_path,int p_flags=0)=0;
+ virtual String get_binary_extension() const = 0;
+ virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) = 0;
EditorExportPlatform();
};
-
class EditorExport : public Node {
- GDCLASS(EditorExport,Node);
+ GDCLASS(EditorExport, Node);
Vector<Ref<EditorExportPlatform> > export_platforms;
Vector<Ref<EditorExportPreset> > export_presets;
@@ -224,23 +212,22 @@ class EditorExport : public Node {
static EditorExport *singleton;
void _save();
-protected:
-friend class EditorExportPreset;
+protected:
+ friend class EditorExportPreset;
void save_presets();
void _notification(int p_what);
static void _bind_methods();
-public:
- static EditorExport * get_singleton() { return singleton; }
+public:
+ static EditorExport *get_singleton() { return singleton; }
- void add_export_platform(const Ref<EditorExportPlatform>& p_platform);
+ void add_export_platform(const Ref<EditorExportPlatform> &p_platform);
int get_export_platform_count();
Ref<EditorExportPlatform> get_export_platform(int p_idx);
-
- void add_export_preset(const Ref<EditorExportPreset>& p_preset,int p_at_pos=-1);
+ void add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos = -1);
int get_export_preset_count() const;
Ref<EditorExportPreset> get_export_preset(int p_idx);
void remove_export_preset(int p_idx);
@@ -251,12 +238,9 @@ public:
~EditorExport();
};
-
-
-
class EditorExportPlatformPC : public EditorExportPlatform {
- GDCLASS( EditorExportPlatformPC,EditorExportPlatform )
+ GDCLASS(EditorExportPlatformPC, EditorExportPlatform)
Ref<ImageTexture> logo;
String name;
@@ -268,30 +252,28 @@ class EditorExportPlatformPC : public EditorExportPlatform {
String debug_file_64;
public:
-
- virtual void get_preset_features(const Ref<EditorExportPreset>& p_preset,List<String>* r_features);
+ virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
virtual void get_export_options(List<ExportOption> *r_options);
virtual String get_name() const;
virtual Ref<Texture> get_logo() const;
- virtual bool can_export(const Ref<EditorExportPreset>& p_preset,String &r_error,bool &r_missing_templates) const;
+ virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
virtual String get_binary_extension() const;
- virtual Error export_project(const Ref<EditorExportPreset>& p_preset,bool p_debug,const String& p_path,int p_flags=0);
+ virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
- void set_extension(const String& p_extension);
- void set_name(const String& p_name);
+ void set_extension(const String &p_extension);
+ void set_name(const String &p_name);
- void set_logo(const Ref<Texture>& p_loco);
+ void set_logo(const Ref<Texture> &p_loco);
- void set_release_64(const String& p_file);
- void set_release_32(const String& p_file);
- void set_debug_64(const String& p_file);
- void set_debug_32(const String& p_file);
+ void set_release_64(const String &p_file);
+ void set_release_32(const String &p_file);
+ void set_debug_64(const String &p_file);
+ void set_debug_32(const String &p_file);
EditorExportPlatformPC();
};
-
#endif // EDITOR_IMPORT_EXPORT_H
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index bfaf1906d8..bde0fd90cf 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -28,107 +28,105 @@
/*************************************************************************/
#include "editor_file_dialog.h"
-#include "scene/gui/label.h"
-#include "scene/gui/center_container.h"
-#include "print_string.h"
-#include "os/keyboard.h"
#include "editor_resource_preview.h"
+#include "editor_scale.h"
#include "editor_settings.h"
-#include "scene/gui/margin_container.h"
#include "os/file_access.h"
-#include "editor_scale.h"
-
-EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func=NULL;
-EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func=NULL;
+#include "os/keyboard.h"
+#include "print_string.h"
+#include "scene/gui/center_container.h"
+#include "scene/gui/label.h"
+#include "scene/gui/margin_container.h"
-EditorFileDialog::RegisterFunc EditorFileDialog::register_func=NULL;
-EditorFileDialog::RegisterFunc EditorFileDialog::unregister_func=NULL;
+EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func = NULL;
+EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func = NULL;
+EditorFileDialog::RegisterFunc EditorFileDialog::register_func = NULL;
+EditorFileDialog::RegisterFunc EditorFileDialog::unregister_func = NULL;
VBoxContainer *EditorFileDialog::get_vbox() {
return vbox;
-
}
void EditorFileDialog::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- mode_thumbnails->set_icon(get_icon("FileThumbnail","EditorIcons"));
- mode_list->set_icon(get_icon("FileList","EditorIcons"));
- dir_prev->set_icon(get_icon("ArrowLeft","EditorIcons"));
- dir_next->set_icon(get_icon("ArrowRight","EditorIcons"));
- dir_up->set_icon(get_icon("ArrowUp","EditorIcons"));
- refresh->set_icon(get_icon("Reload","EditorIcons"));
- favorite->set_icon(get_icon("Favorites","EditorIcons"));
+ mode_thumbnails->set_icon(get_icon("FileThumbnail", "EditorIcons"));
+ mode_list->set_icon(get_icon("FileList", "EditorIcons"));
+ dir_prev->set_icon(get_icon("ArrowLeft", "EditorIcons"));
+ dir_next->set_icon(get_icon("ArrowRight", "EditorIcons"));
+ dir_up->set_icon(get_icon("ArrowUp", "EditorIcons"));
+ refresh->set_icon(get_icon("Reload", "EditorIcons"));
+ favorite->set_icon(get_icon("Favorites", "EditorIcons"));
- fav_up->set_icon(get_icon("MoveUp","EditorIcons"));
- fav_down->set_icon(get_icon("MoveDown","EditorIcons"));
- fav_rm->set_icon(get_icon("RemoveSmall","EditorIcons"));
+ fav_up->set_icon(get_icon("MoveUp", "EditorIcons"));
+ fav_down->set_icon(get_icon("MoveDown", "EditorIcons"));
+ fav_rm->set_icon(get_icon("RemoveSmall", "EditorIcons"));
- } else if (p_what==NOTIFICATION_PROCESS) {
+ } else if (p_what == NOTIFICATION_PROCESS) {
if (preview_waiting) {
- preview_wheel_timeout-=get_process_delta_time();
- if (preview_wheel_timeout<=0) {
+ preview_wheel_timeout -= get_process_delta_time();
+ if (preview_wheel_timeout <= 0) {
preview_wheel_index++;
- if (preview_wheel_index>=8)
- preview_wheel_index=0;
- Ref<Texture> frame = get_icon("WaitPreview"+itos(preview_wheel_index+1),"EditorIcons");
+ if (preview_wheel_index >= 8)
+ preview_wheel_index = 0;
+ Ref<Texture> frame = get_icon("WaitPreview" + itos(preview_wheel_index + 1), "EditorIcons");
preview->set_texture(frame);
- preview_wheel_timeout=0.1;
+ preview_wheel_timeout = 0.1;
}
}
- } else if (p_what==NOTIFICATION_DRAW) {
+ } else if (p_what == NOTIFICATION_DRAW) {
//RID ci = get_canvas_item();
//get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
- } else if (p_what==NOTIFICATION_POPUP_HIDE) {
+ } else if (p_what == NOTIFICATION_POPUP_HIDE) {
set_process_unhandled_input(false);
- } else if (p_what==EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
+ } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- bool show_hidden=EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files");
- if (show_hidden_files!=show_hidden)
+ bool show_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files");
+ if (show_hidden_files != show_hidden)
set_show_hidden_files(show_hidden);
set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int());
}
}
-void EditorFileDialog::_unhandled_input(const InputEvent& p_event) {
+void EditorFileDialog::_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()) {
if (p_event.key.pressed) {
- bool handled=false;
+ bool handled = false;
if (ED_IS_SHORTCUT("file_dialog/go_back", p_event)) {
_go_back();
- handled=true;
+ handled = true;
}
if (ED_IS_SHORTCUT("file_dialog/go_forward", p_event)) {
_go_forward();
- handled=true;
+ handled = true;
}
if (ED_IS_SHORTCUT("file_dialog/go_up", p_event)) {
_go_up();
- handled=true;
+ handled = true;
}
if (ED_IS_SHORTCUT("file_dialog/refresh", p_event)) {
invalidate();
- handled=true;
+ handled = true;
}
if (ED_IS_SHORTCUT("file_dialog/toggle_hidden_files", p_event)) {
- bool show=!show_hidden_files;
+ bool show = !show_hidden_files;
set_show_hidden_files(show);
- EditorSettings::get_singleton()->set("filesystem/file_dialog/show_hidden_files",show);
- handled=true;
+ EditorSettings::get_singleton()->set("filesystem/file_dialog/show_hidden_files", show);
+ handled = true;
}
if (ED_IS_SHORTCUT("file_dialog/toggle_favorite", p_event)) {
_favorite_toggled(favorite->is_pressed());
- handled=true;
+ handled = true;
}
if (ED_IS_SHORTCUT("file_dialog/toggle_mode", p_event)) {
if (mode_thumbnails->is_pressed()) {
@@ -136,23 +134,23 @@ void EditorFileDialog::_unhandled_input(const InputEvent& p_event) {
} else {
set_display_mode(DISPLAY_THUMBNAILS);
}
- handled=true;
+ handled = true;
}
if (ED_IS_SHORTCUT("file_dialog/create_folder", p_event)) {
_make_dir();
- handled=true;
+ handled = true;
}
if (ED_IS_SHORTCUT("file_dialog/focus_path", p_event)) {
dir->grab_focus();
- handled=true;
+ handled = true;
}
if (ED_IS_SHORTCUT("file_dialog/move_favorite_up", p_event)) {
_favorite_move_up();
- handled=true;
+ handled = true;
}
if (ED_IS_SHORTCUT("file_dialog/move_favorite_down", p_event)) {
_favorite_move_down();
- handled=true;
+ handled = true;
}
if (handled) {
@@ -164,19 +162,17 @@ void EditorFileDialog::_unhandled_input(const InputEvent& p_event) {
void EditorFileDialog::set_enable_multiple_selection(bool p_enable) {
- item_list->set_select_mode(p_enable?ItemList::SELECT_MULTI:ItemList::SELECT_SINGLE);
-
+ item_list->set_select_mode(p_enable ? ItemList::SELECT_MULTI : ItemList::SELECT_SINGLE);
};
Vector<String> EditorFileDialog::get_selected_files() const {
Vector<String> list;
- for(int i=0;i<item_list->get_item_count();i++) {
+ for (int i = 0; i < item_list->get_item_count(); i++) {
if (item_list->is_selected(i))
list.push_back(item_list->get_item_text(i));
}
return list;
-
};
void EditorFileDialog::update_dir() {
@@ -186,25 +182,22 @@ void EditorFileDialog::update_dir() {
void EditorFileDialog::_dir_entered(String p_dir) {
-
dir_access->change_dir(p_dir);
file->set_text("");
invalidate();
update_dir();
_push_history();
-
-
}
-void EditorFileDialog::_file_entered(const String& p_file) {
+void EditorFileDialog::_file_entered(const String &p_file) {
_action_pressed();
}
void EditorFileDialog::_save_confirm_pressed() {
- String f=dir_access->get_current_dir().plus_file(file->get_text());
+ String f = dir_access->get_current_dir().plus_file(file->get_text());
_save_to_recent();
- emit_signal("file_selected",f);
+ emit_signal("file_selected", f);
hide();
}
@@ -213,75 +206,72 @@ void EditorFileDialog::_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
item_list->grab_focus();
- if (is_visible_in_tree() && get_current_file()!="")
+ if (is_visible_in_tree() && get_current_file() != "")
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
if (is_visible_in_tree()) {
- Ref<Texture> folder = get_icon("folder","FileDialog");
+ Ref<Texture> folder = get_icon("folder", "FileDialog");
recent->clear();
-
- bool res = access==ACCESS_RESOURCES;
+ bool res = access == ACCESS_RESOURCES;
Vector<String> recentd = EditorSettings::get_singleton()->get_recent_dirs();
- for(int i=0;i<recentd.size();i++) {
+ for (int i = 0; i < recentd.size(); i++) {
bool cres = recentd[i].begins_with("res://");
- if (cres!=res)
+ if (cres != res)
continue;
String name = recentd[i];
- if (res && name=="res://") {
- name="/";
+ if (res && name == "res://") {
+ name = "/";
} else {
- name=name.get_file()+"/";
+ name = name.get_file() + "/";
}
//print_line("file: "+name);
- recent->add_item(name,folder);
- recent->set_item_metadata( recent->get_item_count()-1,recentd[i]);
+ recent->add_item(name, folder);
+ recent->set_item_metadata(recent->get_item_count() - 1, recentd[i]);
}
local_history.clear();
- local_history_pos=-1;
+ local_history_pos = -1;
_push_history();
_update_favorites();
}
set_process_unhandled_input(true);
-
}
-void EditorFileDialog::_thumbnail_result(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata) {
+void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata) {
- if (display_mode==DISPLAY_LIST || p_preview.is_null())
+ if (display_mode == DISPLAY_LIST || p_preview.is_null())
return;
- for(int i=0;i<item_list->get_item_count();i++) {
+ for (int i = 0; i < item_list->get_item_count(); i++) {
Dictionary d = item_list->get_item_metadata(i);
String pname = d["path"];
- if (pname==p_path) {
- item_list->set_item_icon(i,p_preview);
- item_list->set_item_tag_icon(i,Ref<Texture>());
+ if (pname == p_path) {
+ item_list->set_item_icon(i, p_preview);
+ item_list->set_item_tag_icon(i, Ref<Texture>());
}
}
}
-void EditorFileDialog::_thumbnail_done(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata) {
+void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata) {
set_process(false);
- preview_waiting=false;
-
- if (p_preview.is_valid() && get_current_path()==p_path) {
+ preview_waiting = false;
+ if (p_preview.is_valid() && get_current_path() == p_path) {
preview->set_texture(p_preview);
- if (display_mode==DISPLAY_THUMBNAILS) {
+ if (display_mode == DISPLAY_THUMBNAILS) {
preview_vb->hide();
} else {
preview_vb->show();
@@ -290,63 +280,59 @@ void EditorFileDialog::_thumbnail_done(const String& p_path,const Ref<Texture>&
} else {
preview_vb->hide();
preview->set_texture(Ref<Texture>());
-
}
-
}
-void EditorFileDialog::_request_single_thumbnail(const String& p_path) {
+void EditorFileDialog::_request_single_thumbnail(const String &p_path) {
if (!FileAccess::exists(p_path))
return;
- EditorResourcePreview::get_singleton()->queue_resource_preview(p_path,this,"_thumbnail_done",p_path);
+ EditorResourcePreview::get_singleton()->queue_resource_preview(p_path, this, "_thumbnail_done", p_path);
//print_line("want file "+p_path);
set_process(true);
- preview_waiting=true;
- preview_wheel_timeout=0;
-
+ preview_waiting = true;
+ preview_wheel_timeout = 0;
}
void EditorFileDialog::_action_pressed() {
- if (mode==MODE_OPEN_FILES) {
-
+ if (mode == MODE_OPEN_FILES) {
- String fbase=dir_access->get_current_dir();
+ String fbase = dir_access->get_current_dir();
PoolVector<String> files;
- for(int i=0;i<item_list->get_item_count();i++) {
+ for (int i = 0; i < item_list->get_item_count(); i++) {
if (item_list->is_selected(i))
- files.push_back( fbase.plus_file(item_list->get_item_text(i) ));
+ files.push_back(fbase.plus_file(item_list->get_item_text(i)));
}
if (files.size()) {
_save_to_recent();
- 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)) {
+ if ((mode == MODE_OPEN_ANY || mode == MODE_OPEN_FILE) && dir_access->file_exists(f)) {
_save_to_recent();
- emit_signal("file_selected",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();
- path=path.replace("\\","/");
+ path = path.replace("\\", "/");
- for(int i=0;i<item_list->get_item_count();i++) {
+ for (int i = 0; i < item_list->get_item_count(); i++) {
if (item_list->is_selected(i)) {
- Dictionary d=item_list->get_item_metadata(i);
+ Dictionary d = item_list->get_item_metadata(i);
if (d["dir"]) {
- path=path.plus_file(d["name"]);
+ path = path.plus_file(d["name"]);
break;
}
@@ -354,26 +340,26 @@ void EditorFileDialog::_action_pressed() {
}
_save_to_recent();
- emit_signal("dir_selected",path);
+ 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;
}
}
@@ -381,49 +367,47 @@ void EditorFileDialog::_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);
_request_single_thumbnail(get_current_dir().plus_file(f.get_file()));
file->set_text(f.get_file());
- valid=true;
+ valid = true;
}
} else {
- valid=true;
+ valid = true;
}
}
-
if (!valid) {
- exterr->popup_centered_minsize(Size2(250,80)*EDSCALE);
+ exterr->popup_centered_minsize(Size2(250, 80) * EDSCALE);
return;
-
}
if (dir_access->file_exists(f) && !disable_overwrite_warning) {
confirm_save->set_text(TTR("File Exists, Overwrite?"));
- confirm_save->popup_centered(Size2(200,80));
+ confirm_save->popup_centered(Size2(200, 80));
} else {
_save_to_recent();
- emit_signal("file_selected",f);
+ emit_signal("file_selected", f);
hide();
}
}
@@ -439,10 +423,10 @@ void EditorFileDialog::_cancel_pressed() {
void EditorFileDialog::_item_selected(int p_item) {
int current = p_item;
- if (current<0 || current>=item_list->get_item_count())
+ if (current < 0 || current >= item_list->get_item_count())
return;
- Dictionary d=item_list->get_item_metadata(current);
+ Dictionary d = item_list->get_item_metadata(current);
if (!d["dir"]) {
@@ -453,24 +437,22 @@ void EditorFileDialog::_item_selected(int p_item) {
void EditorFileDialog::_push_history() {
- local_history.resize(local_history_pos+1);
+ local_history.resize(local_history_pos + 1);
String new_path = dir_access->get_current_dir();
- if (local_history.size()==0 || new_path!=local_history[local_history_pos]) {
+ if (local_history.size() == 0 || new_path != local_history[local_history_pos]) {
local_history.push_back(new_path);
local_history_pos++;
- dir_prev->set_disabled(local_history_pos==0);
+ dir_prev->set_disabled(local_history_pos == 0);
dir_next->set_disabled(true);
}
-
}
void EditorFileDialog::_item_dc_selected(int p_item) {
-
int current = p_item;
- if (current<0 || current>=item_list->get_item_count())
+ if (current < 0 || current >= item_list->get_item_count())
return;
- Dictionary d=item_list->get_item_metadata(current);
+ Dictionary d = item_list->get_item_metadata(current);
if (d["dir"]) {
@@ -480,54 +462,50 @@ void EditorFileDialog::_item_dc_selected(int p_item) {
_push_history();
-
} else {
_action_pressed();
}
}
-
-
void EditorFileDialog::update_file_list() {
-
int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
- thumbnail_size*=EDSCALE;
+ thumbnail_size *= EDSCALE;
Ref<Texture> folder_thumbnail;
Ref<Texture> file_thumbnail;
item_list->clear();
- if (display_mode==DISPLAY_THUMBNAILS) {
+ if (display_mode == DISPLAY_THUMBNAILS) {
item_list->set_max_columns(0);
item_list->set_icon_mode(ItemList::ICON_MODE_TOP);
- item_list->set_fixed_column_width(thumbnail_size*3/2);
+ item_list->set_fixed_column_width(thumbnail_size * 3 / 2);
item_list->set_max_text_lines(2);
- item_list->set_fixed_icon_size(Size2(thumbnail_size,thumbnail_size));
+ item_list->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
- if (!has_icon("ResizedFolder","EditorIcons")) {
- Ref<ImageTexture> folder = get_icon("FolderBig","EditorIcons");
+ if (!has_icon("ResizedFolder", "EditorIcons")) {
+ Ref<ImageTexture> folder = get_icon("FolderBig", "EditorIcons");
Image img = folder->get_data();
- img.resize(thumbnail_size,thumbnail_size);
- Ref<ImageTexture> resized_folder = Ref<ImageTexture>( memnew( ImageTexture));
- resized_folder->create_from_image(img,0);
- Theme::get_default()->set_icon("ResizedFolder","EditorIcons",resized_folder);
+ img.resize(thumbnail_size, thumbnail_size);
+ Ref<ImageTexture> resized_folder = Ref<ImageTexture>(memnew(ImageTexture));
+ resized_folder->create_from_image(img, 0);
+ Theme::get_default()->set_icon("ResizedFolder", "EditorIcons", resized_folder);
}
- folder_thumbnail = get_icon("ResizedFolder","EditorIcons");
+ folder_thumbnail = get_icon("ResizedFolder", "EditorIcons");
- if (!has_icon("ResizedFile","EditorIcons")) {
- Ref<ImageTexture> file = get_icon("FileBig","EditorIcons");
+ if (!has_icon("ResizedFile", "EditorIcons")) {
+ Ref<ImageTexture> file = get_icon("FileBig", "EditorIcons");
Image img = file->get_data();
- img.resize(thumbnail_size,thumbnail_size);
- Ref<ImageTexture> resized_file = Ref<ImageTexture>( memnew( ImageTexture));
- resized_file->create_from_image(img,0);
- Theme::get_default()->set_icon("ResizedFile","EditorIcons",resized_file);
+ img.resize(thumbnail_size, thumbnail_size);
+ Ref<ImageTexture> resized_file = Ref<ImageTexture>(memnew(ImageTexture));
+ resized_file->create_from_image(img, 0);
+ Theme::get_default()->set_icon("ResizedFile", "EditorIcons", resized_file);
}
- file_thumbnail = get_icon("ResizedFile","EditorIcons");
+ file_thumbnail = get_icon("ResizedFile", "EditorIcons");
preview_vb->hide();
@@ -540,16 +518,14 @@ void EditorFileDialog::update_file_list() {
item_list->set_fixed_icon_size(Size2());
if (preview->get_texture().is_valid())
preview_vb->show();
-
}
String cdir = dir_access->get_current_dir();
- bool skip_pp = access==ACCESS_RESOURCES && cdir=="res://";
+ bool skip_pp = access == ACCESS_RESOURCES && cdir == "res://";
dir_access->list_dir_begin();
-
- Ref<Texture> folder = get_icon("folder","FileDialog");
+ Ref<Texture> folder = get_icon("folder", "FileDialog");
List<String> files;
List<String> dirs;
@@ -558,19 +534,19 @@ void EditorFileDialog::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();
if (show_hidden || !ishidden) {
if (!isdir)
files.push_back(item);
- else if (item!=".." || !skip_pp)
+ else if (item != ".." || !skip_pp)
dirs.push_back(item);
}
}
- if (dirs.find("..")==NULL) {
+ if (dirs.find("..") == NULL) {
//may happen if lacking permissions
dirs.push_back("..");
}
@@ -578,25 +554,25 @@ void EditorFileDialog::update_file_list() {
dirs.sort_custom<NoCaseComparator>();
files.sort_custom<NoCaseComparator>();
- while(!dirs.empty()) {
- const String& dir_name=dirs.front()->get();
+ while (!dirs.empty()) {
+ const String &dir_name = dirs.front()->get();
- item_list->add_item(dir_name+"/");
+ item_list->add_item(dir_name + "/");
- if (display_mode==DISPLAY_THUMBNAILS) {
+ if (display_mode == DISPLAY_THUMBNAILS) {
- item_list->set_item_icon(item_list->get_item_count()-1,folder_thumbnail);
+ item_list->set_item_icon(item_list->get_item_count() - 1, folder_thumbnail);
} else {
- item_list->set_item_icon(item_list->get_item_count()-1,folder);
+ item_list->set_item_icon(item_list->get_item_count() - 1, folder);
}
Dictionary d;
- d["name"]=dir_name;
- d["path"]=String();
- d["dir"]=true;
+ d["name"] = dir_name;
+ d["path"] = String();
+ d["dir"] = true;
- item_list->set_item_metadata( item_list->get_item_count() -1, d);
+ item_list->set_item_metadata(item_list->get_item_count() - 1, d);
dirs.pop_front();
}
@@ -605,47 +581,45 @@ void EditorFileDialog::update_file_list() {
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();
- 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=true;
+ match = true;
break;
}
}
@@ -657,62 +631,60 @@ void EditorFileDialog::update_file_list() {
if (get_icon_func) {
-
Ref<Texture> icon = get_icon_func(base_dir.plus_file(files.front()->get()));
//ti->set_icon(0,icon);
- if (display_mode==DISPLAY_THUMBNAILS) {
+ if (display_mode == DISPLAY_THUMBNAILS) {
- item_list->set_item_icon(item_list->get_item_count()-1,file_thumbnail);
- item_list->set_item_tag_icon(item_list->get_item_count()-1,icon);
+ item_list->set_item_icon(item_list->get_item_count() - 1, file_thumbnail);
+ item_list->set_item_tag_icon(item_list->get_item_count() - 1, icon);
} else {
- item_list->set_item_icon(item_list->get_item_count()-1,icon);
+ item_list->set_item_icon(item_list->get_item_count() - 1, icon);
}
}
- if (mode==MODE_OPEN_DIR) {
+ if (mode == MODE_OPEN_DIR) {
//disabled mode?
//ti->set_custom_color(0,get_color("files_disabled"));
//ti->set_selectable(0,false);
}
Dictionary d;
- d["name"]=files.front()->get();
- d["dir"]=false;
+ d["name"] = files.front()->get();
+ d["dir"] = false;
String fullpath = base_dir.plus_file(files.front()->get());
- if (display_mode==DISPLAY_THUMBNAILS) {
- EditorResourcePreview::get_singleton()->queue_resource_preview(fullpath,this,"_thumbnail_result",fullpath);
+ if (display_mode == DISPLAY_THUMBNAILS) {
+ EditorResourcePreview::get_singleton()->queue_resource_preview(fullpath, this, "_thumbnail_result", fullpath);
}
- d["path"]=base_dir.plus_file(files.front()->get());
+ d["path"] = base_dir.plus_file(files.front()->get());
//ti->set_metadata(0,d);
- item_list->set_item_metadata(item_list->get_item_count()-1,d);
+ item_list->set_item_metadata(item_list->get_item_count() - 1, d);
- if (file->get_text()==files.front()->get())
- item_list->set_current(item_list->get_item_count()-1);
+ if (file->get_text() == files.front()->get())
+ item_list->set_current(item_list->get_item_count() - 1);
}
files.pop_front();
}
- if (favorites->get_current()>=0) {
+ if (favorites->get_current() >= 0) {
favorites->unselect(favorites->get_current());
}
favorite->set_pressed(false);
fav_up->set_disabled(true);
fav_down->set_disabled(true);
- for(int i=0;i<favorites->get_item_count();i++) {
- if (favorites->get_item_metadata(i)==base_dir) {
+ for (int i = 0; i < favorites->get_item_count(); i++) {
+ if (favorites->get_item_metadata(i) == base_dir) {
favorites->select(i);
favorite->set_pressed(true);
- if (i>0) {
+ if (i > 0) {
fav_up->set_disabled(false);
}
- if (i<favorites->get_item_count()-1) {
+ if (i < favorites->get_item_count() - 1) {
fav_down->set_disabled(false);
}
break;
}
-
}
// ??
/*
@@ -721,7 +693,6 @@ void EditorFileDialog::update_file_list() {
*/
files.clear();
-
}
void EditorFileDialog::_filter_selected(int) {
@@ -733,35 +704,34 @@ void EditorFileDialog::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(TTR("All Recognized")+" ( "+all_filters+" )");
+ filter->add_item(TTR("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(desc+" ( "+flt+" )");
+ filter->add_item(desc + " ( " + flt + " )");
else
- filter->add_item("( "+flt+" )");
+ filter->add_item("( " + flt + " )");
}
filter->add_item(TTR("All Files (*)"));
-
}
void EditorFileDialog::clear_filters() {
@@ -770,12 +740,11 @@ void EditorFileDialog::clear_filters() {
update_filters();
invalidate();
}
-void EditorFileDialog::add_filter(const String& p_filter) {
+void EditorFileDialog::add_filter(const String &p_filter) {
filters.push_back(p_filter);
update_filters();
invalidate();
-
}
String EditorFileDialog::get_current_dir() const {
@@ -790,62 +759,77 @@ String EditorFileDialog::get_current_path() const {
return dir->get_text().plus_file(file->get_text());
}
-void EditorFileDialog::set_current_dir(const String& p_dir) {
+void EditorFileDialog::set_current_dir(const String &p_dir) {
dir_access->change_dir(p_dir);
update_dir();
invalidate();
//_push_history();
-
-
}
-void EditorFileDialog::set_current_file(const String& p_file) {
+void EditorFileDialog::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();
}
if (is_visible_in_tree())
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
-
-
}
-void EditorFileDialog::set_current_path(const String& p_path) {
+void EditorFileDialog::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 EditorFileDialog::set_mode(Mode p_mode) {
- mode=p_mode;
- switch(mode) {
+ mode = p_mode;
+ switch (mode) {
- case MODE_OPEN_FILE: get_ok()->set_text(TTR("Open")); set_title("Open a File"); makedir->hide(); break;
- case MODE_OPEN_FILES: get_ok()->set_text(TTR("Open")); set_title("Open File(s)"); makedir->hide(); break;
- case MODE_OPEN_DIR: get_ok()->set_text(TTR("Open")); set_title("Open a Directory"); makedir->show(); break;
- case MODE_OPEN_ANY: get_ok()->set_text(TTR("Open")); set_title("Open a File or Directory"); makedir->show(); break;
- case MODE_SAVE_FILE: get_ok()->set_text(TTR("Save")); set_title("Save a File"); makedir->show(); break;
+ case MODE_OPEN_FILE:
+ get_ok()->set_text(TTR("Open"));
+ set_title("Open a File");
+ makedir->hide();
+ break;
+ case MODE_OPEN_FILES:
+ get_ok()->set_text(TTR("Open"));
+ set_title("Open File(s)");
+ makedir->hide();
+ break;
+ case MODE_OPEN_DIR:
+ get_ok()->set_text(TTR("Open"));
+ set_title("Open a Directory");
+ makedir->show();
+ break;
+ case MODE_OPEN_ANY:
+ get_ok()->set_text(TTR("Open"));
+ set_title("Open a File or Directory");
+ makedir->show();
+ break;
+ case MODE_SAVE_FILE:
+ get_ok()->set_text(TTR("Save"));
+ set_title("Save a File");
+ makedir->show();
+ break;
}
- if (mode==MODE_OPEN_FILES) {
+ if (mode == MODE_OPEN_FILES) {
item_list->set_select_mode(ItemList::SELECT_MULTI);
} else {
item_list->set_select_mode(ItemList::SELECT_SINGLE);
@@ -859,11 +843,11 @@ EditorFileDialog::Mode EditorFileDialog::get_mode() const {
void EditorFileDialog::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);
@@ -877,7 +861,7 @@ void EditorFileDialog::set_access(Access p_access) {
dir_access = DirAccess::create(DirAccess::ACCESS_USERDATA);
} break;
}
- access=p_access;
+ access = p_access;
_update_drives();
invalidate();
update_filters();
@@ -888,22 +872,21 @@ void EditorFileDialog::invalidate() {
if (is_visible_in_tree()) {
update_file_list();
- invalidated=false;
+ invalidated = false;
} else {
- invalidated=true;
+ invalidated = true;
}
-
}
-EditorFileDialog::Access EditorFileDialog::get_access() const{
+EditorFileDialog::Access EditorFileDialog::get_access() const {
return access;
}
void EditorFileDialog::_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();
@@ -911,17 +894,15 @@ void EditorFileDialog::_make_dir_confirm() {
_push_history();
} else {
- mkdirerr->popup_centered_minsize(Size2(250,50)*EDSCALE);
+ mkdirerr->popup_centered_minsize(Size2(250, 50) * EDSCALE);
}
makedirname->set_text(""); // reset label
}
-
void EditorFileDialog::_make_dir() {
- makedialog->popup_centered_minsize(Size2(250,80)*EDSCALE);
+ makedialog->popup_centered_minsize(Size2(250, 80) * EDSCALE);
makedirname->grab_focus();
-
}
void EditorFileDialog::_select_drive(int p_idx) {
@@ -932,35 +913,30 @@ void EditorFileDialog::_select_drive(int p_idx) {
invalidate();
update_dir();
_push_history();
-
-
}
void EditorFileDialog::_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());
-
}
}
-
void EditorFileDialog::_favorite_selected(int p_idx) {
Vector<String> favorited = EditorSettings::get_singleton()->get_favorite_dirs();
- ERR_FAIL_INDEX(p_idx,favorited.size());
+ ERR_FAIL_INDEX(p_idx, favorited.size());
dir_access->change_dir(favorited[p_idx]);
file->set_text("");
@@ -969,105 +945,98 @@ void EditorFileDialog::_favorite_selected(int p_idx) {
_push_history();
}
-void EditorFileDialog::_favorite_move_up(){
+void EditorFileDialog::_favorite_move_up() {
int current = favorites->get_current();
- if (current>0 && current<favorites->get_item_count()) {
+ if (current > 0 && current < favorites->get_item_count()) {
Vector<String> favorited = EditorSettings::get_singleton()->get_favorite_dirs();
- int a_idx=favorited.find(String(favorites->get_item_metadata(current-1)));
- int b_idx=favorited.find(String(favorites->get_item_metadata(current)));
+ int a_idx = favorited.find(String(favorites->get_item_metadata(current - 1)));
+ int b_idx = favorited.find(String(favorites->get_item_metadata(current)));
- if (a_idx==-1 || b_idx==-1)
+ if (a_idx == -1 || b_idx == -1)
return;
- SWAP(favorited[a_idx],favorited[b_idx]);
+ SWAP(favorited[a_idx], favorited[b_idx]);
EditorSettings::get_singleton()->set_favorite_dirs(favorited);
_update_favorites();
update_file_list();
-
}
}
-void EditorFileDialog::_favorite_move_down(){
+void EditorFileDialog::_favorite_move_down() {
int current = favorites->get_current();
- if (current>=0 && current<favorites->get_item_count()-1) {
+ if (current >= 0 && current < favorites->get_item_count() - 1) {
Vector<String> favorited = EditorSettings::get_singleton()->get_favorite_dirs();
- int a_idx=favorited.find(String(favorites->get_item_metadata(current+1)));
- int b_idx=favorited.find(String(favorites->get_item_metadata(current)));
+ int a_idx = favorited.find(String(favorites->get_item_metadata(current + 1)));
+ int b_idx = favorited.find(String(favorites->get_item_metadata(current)));
- if (a_idx==-1 || b_idx==-1)
+ if (a_idx == -1 || b_idx == -1)
return;
- SWAP(favorited[a_idx],favorited[b_idx]);
+ SWAP(favorited[a_idx], favorited[b_idx]);
EditorSettings::get_singleton()->set_favorite_dirs(favorited);
_update_favorites();
update_file_list();
-
}
}
-
void EditorFileDialog::_update_favorites() {
- bool res = access==ACCESS_RESOURCES;
+ bool res = access == ACCESS_RESOURCES;
String current = get_current_dir();
- Ref<Texture> star = get_icon("Favorites","EditorIcons");
+ Ref<Texture> star = get_icon("Favorites", "EditorIcons");
favorites->clear();
favorite->set_pressed(false);
-
Vector<String> favorited = EditorSettings::get_singleton()->get_favorite_dirs();
- for(int i=0;i<favorited.size();i++) {
+ for (int i = 0; i < favorited.size(); i++) {
bool cres = favorited[i].begins_with("res://");
- if (cres!=res)
+ if (cres != res)
continue;
String name = favorited[i];
- bool setthis = name==current;
+ bool setthis = name == current;
- if (res && name=="res://") {
- name="/";
+ if (res && name == "res://") {
+ name = "/";
} else {
- name=name.get_file()+"/";
+ name = name.get_file() + "/";
}
-
//print_line("file: "+name);
- favorites->add_item(name,star);
- favorites->set_item_metadata( favorites->get_item_count()-1,favorited[i]);
+ favorites->add_item(name, star);
+ favorites->set_item_metadata(favorites->get_item_count() - 1, favorited[i]);
if (setthis) {
favorite->set_pressed(true);
- favorites->set_current(favorites->get_item_count()-1);
+ favorites->set_current(favorites->get_item_count() - 1);
}
}
-
-
}
void EditorFileDialog::_favorite_toggled(bool p_toggle) {
- bool res = access==ACCESS_RESOURCES;
+ bool res = access == ACCESS_RESOURCES;
String cd = get_current_dir();
Vector<String> favorited = EditorSettings::get_singleton()->get_favorite_dirs();
bool found = false;
- for(int i=0;i<favorited.size();i++) {
+ for (int i = 0; i < favorited.size(); i++) {
bool cres = favorited[i].begins_with("res://");
- if (cres!=res)
+ if (cres != res)
continue;
- if (favorited[i]==cd) {
- found=true;
+ if (favorited[i] == cd) {
+ found = true;
break;
}
}
@@ -1083,13 +1052,12 @@ void EditorFileDialog::_favorite_toggled(bool p_toggle) {
EditorSettings::get_singleton()->set_favorite_dirs(favorited);
_update_favorites();
-
}
void EditorFileDialog::_recent_selected(int p_idx) {
Vector<String> recentd = EditorSettings::get_singleton()->get_recent_dirs();
- ERR_FAIL_INDEX(p_idx,recentd.size());
+ ERR_FAIL_INDEX(p_idx, recentd.size());
dir_access->change_dir(recent->get_item_metadata(p_idx));
update_file_list();
@@ -1103,12 +1071,11 @@ void EditorFileDialog::_go_up() {
update_file_list();
update_dir();
_push_history();
-
}
-void EditorFileDialog::_go_back(){
+void EditorFileDialog::_go_back() {
- if (local_history_pos<=0) {
+ if (local_history_pos <= 0) {
return;
}
@@ -1117,12 +1084,12 @@ void EditorFileDialog::_go_back(){
update_file_list();
update_dir();
- dir_prev->set_disabled(local_history_pos==0);
- dir_next->set_disabled(local_history_pos==local_history.size()-1);
+ dir_prev->set_disabled(local_history_pos == 0);
+ dir_next->set_disabled(local_history_pos == local_history.size() - 1);
}
-void EditorFileDialog::_go_forward(){
+void EditorFileDialog::_go_forward() {
- if (local_history_pos==local_history.size()-1) {
+ if (local_history_pos == local_history.size() - 1) {
return;
}
@@ -1131,108 +1098,103 @@ void EditorFileDialog::_go_forward(){
update_file_list();
update_dir();
- dir_prev->set_disabled(local_history_pos==0);
- dir_next->set_disabled(local_history_pos==local_history.size()-1);
-
+ dir_prev->set_disabled(local_history_pos == 0);
+ dir_next->set_disabled(local_history_pos == local_history.size() - 1);
}
-bool EditorFileDialog::default_show_hidden_files=false;
+bool EditorFileDialog::default_show_hidden_files = false;
-EditorFileDialog::DisplayMode EditorFileDialog::default_display_mode=DISPLAY_THUMBNAILS;
+EditorFileDialog::DisplayMode EditorFileDialog::default_display_mode = DISPLAY_THUMBNAILS;
void EditorFileDialog::set_display_mode(DisplayMode p_mode) {
- if (display_mode==p_mode)
+ if (display_mode == p_mode)
return;
- if (p_mode==DISPLAY_THUMBNAILS) {
+ if (p_mode == DISPLAY_THUMBNAILS) {
mode_list->set_pressed(false);
mode_thumbnails->set_pressed(true);
} else {
mode_thumbnails->set_pressed(false);
mode_list->set_pressed(true);
}
- display_mode=p_mode;
+ display_mode = p_mode;
invalidate();
}
-EditorFileDialog::DisplayMode EditorFileDialog::get_display_mode() const{
+EditorFileDialog::DisplayMode EditorFileDialog::get_display_mode() const {
return display_mode;
}
-
-
void EditorFileDialog::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_unhandled_input"),&EditorFileDialog::_unhandled_input);
-
- ClassDB::bind_method(D_METHOD("_item_selected"),&EditorFileDialog::_item_selected);
- ClassDB::bind_method(D_METHOD("_item_db_selected"),&EditorFileDialog::_item_dc_selected);
- ClassDB::bind_method(D_METHOD("_dir_entered"),&EditorFileDialog::_dir_entered);
- ClassDB::bind_method(D_METHOD("_file_entered"),&EditorFileDialog::_file_entered);
- ClassDB::bind_method(D_METHOD("_action_pressed"),&EditorFileDialog::_action_pressed);
- ClassDB::bind_method(D_METHOD("_cancel_pressed"),&EditorFileDialog::_cancel_pressed);
- ClassDB::bind_method(D_METHOD("_filter_selected"),&EditorFileDialog::_filter_selected);
- ClassDB::bind_method(D_METHOD("_save_confirm_pressed"),&EditorFileDialog::_save_confirm_pressed);
-
- ClassDB::bind_method(D_METHOD("clear_filters"),&EditorFileDialog::clear_filters);
- ClassDB::bind_method(D_METHOD("add_filter","filter"),&EditorFileDialog::add_filter);
- ClassDB::bind_method(D_METHOD("get_current_dir"),&EditorFileDialog::get_current_dir);
- ClassDB::bind_method(D_METHOD("get_current_file"),&EditorFileDialog::get_current_file);
- ClassDB::bind_method(D_METHOD("get_current_path"),&EditorFileDialog::get_current_path);
- ClassDB::bind_method(D_METHOD("set_current_dir","dir"),&EditorFileDialog::set_current_dir);
- ClassDB::bind_method(D_METHOD("set_current_file","file"),&EditorFileDialog::set_current_file);
- ClassDB::bind_method(D_METHOD("set_current_path","path"),&EditorFileDialog::set_current_path);
- ClassDB::bind_method(D_METHOD("set_mode","mode"),&EditorFileDialog::set_mode);
- ClassDB::bind_method(D_METHOD("get_mode"),&EditorFileDialog::get_mode);
- ClassDB::bind_method(D_METHOD("get_vbox:VBoxContainer"),&EditorFileDialog::get_vbox);
- ClassDB::bind_method(D_METHOD("set_access","access"),&EditorFileDialog::set_access);
- ClassDB::bind_method(D_METHOD("get_access"),&EditorFileDialog::get_access);
- ClassDB::bind_method(D_METHOD("set_show_hidden_files","show"),&EditorFileDialog::set_show_hidden_files);
- ClassDB::bind_method(D_METHOD("is_showing_hidden_files"),&EditorFileDialog::is_showing_hidden_files);
- ClassDB::bind_method(D_METHOD("_select_drive"),&EditorFileDialog::_select_drive);
- ClassDB::bind_method(D_METHOD("_make_dir"),&EditorFileDialog::_make_dir);
- ClassDB::bind_method(D_METHOD("_make_dir_confirm"),&EditorFileDialog::_make_dir_confirm);
- ClassDB::bind_method(D_METHOD("_update_file_list"),&EditorFileDialog::update_file_list);
- ClassDB::bind_method(D_METHOD("_update_dir"),&EditorFileDialog::update_dir);
- ClassDB::bind_method(D_METHOD("_thumbnail_done"),&EditorFileDialog::_thumbnail_done);
- ClassDB::bind_method(D_METHOD("set_display_mode","mode"),&EditorFileDialog::set_display_mode);
- ClassDB::bind_method(D_METHOD("get_display_mode"),&EditorFileDialog::get_display_mode);
- ClassDB::bind_method(D_METHOD("_thumbnail_result"),&EditorFileDialog::_thumbnail_result);
- ClassDB::bind_method(D_METHOD("set_disable_overwrite_warning","disable"),&EditorFileDialog::set_disable_overwrite_warning);
- ClassDB::bind_method(D_METHOD("is_overwrite_warning_disabled"),&EditorFileDialog::is_overwrite_warning_disabled);
-
- ClassDB::bind_method(D_METHOD("_recent_selected"),&EditorFileDialog::_recent_selected);
- ClassDB::bind_method(D_METHOD("_go_back"),&EditorFileDialog::_go_back);
- ClassDB::bind_method(D_METHOD("_go_forward"),&EditorFileDialog::_go_forward);
- ClassDB::bind_method(D_METHOD("_go_up"),&EditorFileDialog::_go_up);
-
- ClassDB::bind_method(D_METHOD("_favorite_toggled"),&EditorFileDialog::_favorite_toggled);
- ClassDB::bind_method(D_METHOD("_favorite_selected"),&EditorFileDialog::_favorite_selected);
- ClassDB::bind_method(D_METHOD("_favorite_move_up"),&EditorFileDialog::_favorite_move_up);
- ClassDB::bind_method(D_METHOD("_favorite_move_down"),&EditorFileDialog::_favorite_move_down);
-
- ClassDB::bind_method(D_METHOD("invalidate"),&EditorFileDialog::invalidate);
-
- ADD_SIGNAL(MethodInfo("file_selected",PropertyInfo( Variant::STRING,"path")));
- ADD_SIGNAL(MethodInfo("files_selected",PropertyInfo( Variant::POOL_STRING_ARRAY,"paths")));
- ADD_SIGNAL(MethodInfo("dir_selected",PropertyInfo( Variant::STRING,"dir")));
-
- BIND_CONSTANT( MODE_OPEN_FILE );
- BIND_CONSTANT( MODE_OPEN_FILES );
- BIND_CONSTANT( MODE_OPEN_DIR );
- BIND_CONSTANT( MODE_OPEN_ANY );
- BIND_CONSTANT( MODE_SAVE_FILE );
-
- BIND_CONSTANT( ACCESS_RESOURCES );
- BIND_CONSTANT( ACCESS_USERDATA );
- BIND_CONSTANT( ACCESS_FILESYSTEM );
-
+ ClassDB::bind_method(D_METHOD("_unhandled_input"), &EditorFileDialog::_unhandled_input);
+
+ ClassDB::bind_method(D_METHOD("_item_selected"), &EditorFileDialog::_item_selected);
+ ClassDB::bind_method(D_METHOD("_item_db_selected"), &EditorFileDialog::_item_dc_selected);
+ ClassDB::bind_method(D_METHOD("_dir_entered"), &EditorFileDialog::_dir_entered);
+ ClassDB::bind_method(D_METHOD("_file_entered"), &EditorFileDialog::_file_entered);
+ ClassDB::bind_method(D_METHOD("_action_pressed"), &EditorFileDialog::_action_pressed);
+ ClassDB::bind_method(D_METHOD("_cancel_pressed"), &EditorFileDialog::_cancel_pressed);
+ ClassDB::bind_method(D_METHOD("_filter_selected"), &EditorFileDialog::_filter_selected);
+ ClassDB::bind_method(D_METHOD("_save_confirm_pressed"), &EditorFileDialog::_save_confirm_pressed);
+
+ ClassDB::bind_method(D_METHOD("clear_filters"), &EditorFileDialog::clear_filters);
+ ClassDB::bind_method(D_METHOD("add_filter", "filter"), &EditorFileDialog::add_filter);
+ ClassDB::bind_method(D_METHOD("get_current_dir"), &EditorFileDialog::get_current_dir);
+ ClassDB::bind_method(D_METHOD("get_current_file"), &EditorFileDialog::get_current_file);
+ ClassDB::bind_method(D_METHOD("get_current_path"), &EditorFileDialog::get_current_path);
+ ClassDB::bind_method(D_METHOD("set_current_dir", "dir"), &EditorFileDialog::set_current_dir);
+ ClassDB::bind_method(D_METHOD("set_current_file", "file"), &EditorFileDialog::set_current_file);
+ ClassDB::bind_method(D_METHOD("set_current_path", "path"), &EditorFileDialog::set_current_path);
+ ClassDB::bind_method(D_METHOD("set_mode", "mode"), &EditorFileDialog::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"), &EditorFileDialog::get_mode);
+ ClassDB::bind_method(D_METHOD("get_vbox:VBoxContainer"), &EditorFileDialog::get_vbox);
+ ClassDB::bind_method(D_METHOD("set_access", "access"), &EditorFileDialog::set_access);
+ ClassDB::bind_method(D_METHOD("get_access"), &EditorFileDialog::get_access);
+ ClassDB::bind_method(D_METHOD("set_show_hidden_files", "show"), &EditorFileDialog::set_show_hidden_files);
+ ClassDB::bind_method(D_METHOD("is_showing_hidden_files"), &EditorFileDialog::is_showing_hidden_files);
+ ClassDB::bind_method(D_METHOD("_select_drive"), &EditorFileDialog::_select_drive);
+ ClassDB::bind_method(D_METHOD("_make_dir"), &EditorFileDialog::_make_dir);
+ ClassDB::bind_method(D_METHOD("_make_dir_confirm"), &EditorFileDialog::_make_dir_confirm);
+ ClassDB::bind_method(D_METHOD("_update_file_list"), &EditorFileDialog::update_file_list);
+ ClassDB::bind_method(D_METHOD("_update_dir"), &EditorFileDialog::update_dir);
+ ClassDB::bind_method(D_METHOD("_thumbnail_done"), &EditorFileDialog::_thumbnail_done);
+ ClassDB::bind_method(D_METHOD("set_display_mode", "mode"), &EditorFileDialog::set_display_mode);
+ ClassDB::bind_method(D_METHOD("get_display_mode"), &EditorFileDialog::get_display_mode);
+ ClassDB::bind_method(D_METHOD("_thumbnail_result"), &EditorFileDialog::_thumbnail_result);
+ ClassDB::bind_method(D_METHOD("set_disable_overwrite_warning", "disable"), &EditorFileDialog::set_disable_overwrite_warning);
+ ClassDB::bind_method(D_METHOD("is_overwrite_warning_disabled"), &EditorFileDialog::is_overwrite_warning_disabled);
+
+ ClassDB::bind_method(D_METHOD("_recent_selected"), &EditorFileDialog::_recent_selected);
+ ClassDB::bind_method(D_METHOD("_go_back"), &EditorFileDialog::_go_back);
+ ClassDB::bind_method(D_METHOD("_go_forward"), &EditorFileDialog::_go_forward);
+ ClassDB::bind_method(D_METHOD("_go_up"), &EditorFileDialog::_go_up);
+
+ ClassDB::bind_method(D_METHOD("_favorite_toggled"), &EditorFileDialog::_favorite_toggled);
+ ClassDB::bind_method(D_METHOD("_favorite_selected"), &EditorFileDialog::_favorite_selected);
+ ClassDB::bind_method(D_METHOD("_favorite_move_up"), &EditorFileDialog::_favorite_move_up);
+ ClassDB::bind_method(D_METHOD("_favorite_move_down"), &EditorFileDialog::_favorite_move_down);
+
+ ClassDB::bind_method(D_METHOD("invalidate"), &EditorFileDialog::invalidate);
+
+ ADD_SIGNAL(MethodInfo("file_selected", PropertyInfo(Variant::STRING, "path")));
+ ADD_SIGNAL(MethodInfo("files_selected", PropertyInfo(Variant::POOL_STRING_ARRAY, "paths")));
+ ADD_SIGNAL(MethodInfo("dir_selected", PropertyInfo(Variant::STRING, "dir")));
+
+ BIND_CONSTANT(MODE_OPEN_FILE);
+ BIND_CONSTANT(MODE_OPEN_FILES);
+ BIND_CONSTANT(MODE_OPEN_DIR);
+ BIND_CONSTANT(MODE_OPEN_ANY);
+ BIND_CONSTANT(MODE_SAVE_FILE);
+
+ BIND_CONSTANT(ACCESS_RESOURCES);
+ BIND_CONSTANT(ACCESS_USERDATA);
+ BIND_CONSTANT(ACCESS_FILESYSTEM);
}
-
void EditorFileDialog::set_show_hidden_files(bool p_show) {
- show_hidden_files=p_show;
+ show_hidden_files = p_show;
invalidate();
}
@@ -1241,11 +1203,11 @@ bool EditorFileDialog::is_showing_hidden_files() const {
}
void EditorFileDialog::set_default_show_hidden_files(bool p_show) {
- default_show_hidden_files=p_show;
+ default_show_hidden_files = p_show;
}
void EditorFileDialog::set_default_display_mode(DisplayMode p_mode) {
- default_display_mode=p_mode;
+ default_display_mode = p_mode;
}
void EditorFileDialog::_save_to_recent() {
@@ -1253,13 +1215,13 @@ void EditorFileDialog::_save_to_recent() {
String dir = get_current_dir();
Vector<String> recent = EditorSettings::get_singleton()->get_recent_dirs();
- const int max=20;
- int count=0;
- bool res=dir.begins_with("res://");
+ const int max = 20;
+ int count = 0;
+ bool res = dir.begins_with("res://");
- for(int i=0;i<recent.size();i++) {
- bool cres=recent[i].begins_with("res://");
- if (recent[i]==dir || (res==cres && count>max)) {
+ for (int i = 0; i < recent.size(); i++) {
+ bool cres = recent[i].begins_with("res://");
+ if (recent[i] == dir || (res == cres && count > max)) {
recent.remove(i);
i--;
} else {
@@ -1267,222 +1229,210 @@ void EditorFileDialog::_save_to_recent() {
}
}
- recent.insert(0,dir);
+ recent.insert(0, dir);
EditorSettings::get_singleton()->set_recent_dirs(recent);
-
-
}
void EditorFileDialog::set_disable_overwrite_warning(bool p_disable) {
- disable_overwrite_warning=p_disable;
+ disable_overwrite_warning = p_disable;
}
-bool EditorFileDialog::is_overwrite_warning_disabled() const{
+bool EditorFileDialog::is_overwrite_warning_disabled() const {
return disable_overwrite_warning;
}
-
EditorFileDialog::EditorFileDialog() {
- show_hidden_files=default_show_hidden_files;
- display_mode=default_display_mode;
- local_history_pos=0;
- disable_overwrite_warning=false;
- VBoxContainer *vbc = memnew( VBoxContainer );
+ show_hidden_files = default_show_hidden_files;
+ display_mode = default_display_mode;
+ local_history_pos = 0;
+ disable_overwrite_warning = false;
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
- mode=MODE_SAVE_FILE;
+ mode = MODE_SAVE_FILE;
set_title(TTR("Save a File"));
- ED_SHORTCUT("file_dialog/go_back", TTR("Go Back"), KEY_MASK_ALT|KEY_LEFT);
- ED_SHORTCUT("file_dialog/go_forward", TTR("Go Forward"), KEY_MASK_ALT|KEY_RIGHT);
- ED_SHORTCUT("file_dialog/go_up", TTR("Go Up"), KEY_MASK_ALT|KEY_UP);
+ ED_SHORTCUT("file_dialog/go_back", TTR("Go Back"), KEY_MASK_ALT | KEY_LEFT);
+ ED_SHORTCUT("file_dialog/go_forward", TTR("Go Forward"), KEY_MASK_ALT | KEY_RIGHT);
+ ED_SHORTCUT("file_dialog/go_up", TTR("Go Up"), KEY_MASK_ALT | KEY_UP);
ED_SHORTCUT("file_dialog/refresh", TTR("Refresh"), KEY_F5);
- ED_SHORTCUT("file_dialog/toggle_hidden_files", TTR("Toggle Hidden Files"), KEY_MASK_CMD|KEY_H);
- ED_SHORTCUT("file_dialog/toggle_favorite", TTR("Toggle Favorite"), KEY_MASK_ALT|KEY_F);
- ED_SHORTCUT("file_dialog/toggle_mode", TTR("Toggle Mode"), KEY_MASK_ALT|KEY_V);
- ED_SHORTCUT("file_dialog/create_folder", TTR("Create Folder"), KEY_MASK_CMD|KEY_N);
- ED_SHORTCUT("file_dialog/focus_path", TTR("Focus Path"), KEY_MASK_CMD|KEY_D);
- ED_SHORTCUT("file_dialog/move_favorite_up", TTR("Move Favorite Up"), KEY_MASK_CMD|KEY_UP);
- ED_SHORTCUT("file_dialog/move_favorite_down", TTR("Move Favorite Down"), KEY_MASK_CMD|KEY_DOWN);
+ ED_SHORTCUT("file_dialog/toggle_hidden_files", TTR("Toggle Hidden Files"), KEY_MASK_CMD | KEY_H);
+ ED_SHORTCUT("file_dialog/toggle_favorite", TTR("Toggle Favorite"), KEY_MASK_ALT | KEY_F);
+ ED_SHORTCUT("file_dialog/toggle_mode", TTR("Toggle Mode"), KEY_MASK_ALT | KEY_V);
+ ED_SHORTCUT("file_dialog/create_folder", TTR("Create Folder"), KEY_MASK_CMD | KEY_N);
+ ED_SHORTCUT("file_dialog/focus_path", TTR("Focus Path"), KEY_MASK_CMD | KEY_D);
+ ED_SHORTCUT("file_dialog/move_favorite_up", TTR("Move Favorite Up"), KEY_MASK_CMD | KEY_UP);
+ ED_SHORTCUT("file_dialog/move_favorite_down", TTR("Move Favorite Down"), KEY_MASK_CMD | KEY_DOWN);
- HBoxContainer *pathhb = memnew( HBoxContainer );
+ HBoxContainer *pathhb = memnew(HBoxContainer);
- dir_prev = memnew( ToolButton );
- dir_next = memnew( ToolButton );
- dir_up = memnew( ToolButton );
+ dir_prev = memnew(ToolButton);
+ dir_next = memnew(ToolButton);
+ dir_up = memnew(ToolButton);
pathhb->add_child(dir_prev);
pathhb->add_child(dir_next);
pathhb->add_child(dir_up);
- dir_prev->connect("pressed",this,"_go_back");
- dir_next->connect("pressed",this,"_go_forward");
- dir_up->connect("pressed",this,"_go_up");
+ dir_prev->connect("pressed", this, "_go_back");
+ dir_next->connect("pressed", this, "_go_forward");
+ dir_up->connect("pressed", this, "_go_up");
dir = memnew(LineEdit);
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);
- favorite = memnew( ToolButton );
+ favorite = memnew(ToolButton);
favorite->set_toggle_mode(true);
- favorite->connect("toggled",this,"_favorite_toggled");
+ favorite->connect("toggled", this, "_favorite_toggled");
pathhb->add_child(favorite);
- mode_thumbnails = memnew( ToolButton );
- mode_thumbnails->connect("pressed",this,"set_display_mode",varray(DISPLAY_THUMBNAILS));
+ mode_thumbnails = memnew(ToolButton);
+ mode_thumbnails->connect("pressed", this, "set_display_mode", varray(DISPLAY_THUMBNAILS));
mode_thumbnails->set_toggle_mode(true);
- mode_thumbnails->set_pressed(display_mode==DISPLAY_THUMBNAILS);
+ mode_thumbnails->set_pressed(display_mode == DISPLAY_THUMBNAILS);
pathhb->add_child(mode_thumbnails);
- mode_list = memnew( ToolButton );
- mode_list->connect("pressed",this,"set_display_mode",varray(DISPLAY_LIST));
+ mode_list = memnew(ToolButton);
+ mode_list->connect("pressed", this, "set_display_mode", varray(DISPLAY_LIST));
mode_list->set_toggle_mode(true);
- mode_list->set_pressed(display_mode==DISPLAY_LIST);
+ mode_list->set_pressed(display_mode == DISPLAY_LIST);
pathhb->add_child(mode_list);
- 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(TTR("Create Folder"));
- makedir->connect("pressed",this,"_make_dir");
+ makedir->connect("pressed", this, "_make_dir");
pathhb->add_child(makedir);
- list_hb = memnew( HBoxContainer );
+ list_hb = memnew(HBoxContainer);
- vbc->add_margin_child(TTR("Path:"),pathhb);
+ vbc->add_margin_child(TTR("Path:"), pathhb);
vbc->add_child(list_hb);
list_hb->set_v_size_flags(SIZE_EXPAND_FILL);
- VBoxContainer *fav_vb = memnew( VBoxContainer );
+ VBoxContainer *fav_vb = memnew(VBoxContainer);
list_hb->add_child(fav_vb);
- HBoxContainer *fav_hb = memnew( HBoxContainer );
+ HBoxContainer *fav_hb = memnew(HBoxContainer);
fav_vb->add_child(fav_hb);
fav_hb->add_child(memnew(Label(TTR("Favorites:"))));
fav_hb->add_spacer();
- fav_up = memnew( ToolButton );
+ fav_up = memnew(ToolButton);
fav_hb->add_child(fav_up);
- fav_up->connect("pressed",this,"_favorite_move_up");
- fav_down = memnew( ToolButton );
+ fav_up->connect("pressed", this, "_favorite_move_up");
+ fav_down = memnew(ToolButton);
fav_hb->add_child(fav_down);
- fav_down->connect("pressed",this,"_favorite_move_down");
- fav_rm = memnew( ToolButton );
+ fav_down->connect("pressed", this, "_favorite_move_down");
+ fav_rm = memnew(ToolButton);
fav_hb->add_child(fav_rm);
fav_rm->hide(); // redundant
- MarginContainer *fav_mv = memnew( MarginContainer );
+ MarginContainer *fav_mv = memnew(MarginContainer);
fav_vb->add_child(fav_mv);
fav_mv->set_v_size_flags(SIZE_EXPAND_FILL);
- favorites = memnew( ItemList );
+ favorites = memnew(ItemList);
fav_mv->add_child(favorites);
- favorites->connect("item_selected",this,"_favorite_selected");
+ favorites->connect("item_selected", this, "_favorite_selected");
- recent = memnew( ItemList );
- fav_vb->add_margin_child(TTR("Recent:"),recent,true);
- recent->connect("item_selected",this,"_recent_selected");
+ recent = memnew(ItemList);
+ fav_vb->add_margin_child(TTR("Recent:"), recent, true);
+ recent->connect("item_selected", this, "_recent_selected");
- VBoxContainer *item_vb = memnew( VBoxContainer );
+ VBoxContainer *item_vb = memnew(VBoxContainer);
list_hb->add_child(item_vb);
item_vb->set_h_size_flags(SIZE_EXPAND_FILL);
- item_list = memnew( ItemList );
+ item_list = memnew(ItemList);
item_list->set_v_size_flags(SIZE_EXPAND_FILL);
- item_vb->add_margin_child(TTR("Directories & Files:"),item_list,true);
+ item_vb->add_margin_child(TTR("Directories & Files:"), item_list, true);
- HBoxContainer* filter_hb = memnew( HBoxContainer );
+ HBoxContainer *filter_hb = memnew(HBoxContainer);
item_vb->add_child(filter_hb);
- VBoxContainer *filter_vb = memnew( VBoxContainer );
+ VBoxContainer *filter_vb = memnew(VBoxContainer);
filter_hb->add_child(filter_vb);
filter_vb->set_h_size_flags(SIZE_EXPAND_FILL);
- preview_vb = memnew( VBoxContainer );
+ preview_vb = memnew(VBoxContainer);
filter_hb->add_child(preview_vb);
- CenterContainer *prev_cc = memnew( CenterContainer );
- preview_vb->add_margin_child(TTR("Preview:"),prev_cc);
- preview = memnew( TextureRect );
+ CenterContainer *prev_cc = memnew(CenterContainer);
+ preview_vb->add_margin_child(TTR("Preview:"), prev_cc);
+ preview = memnew(TextureRect);
prev_cc->add_child(preview);
preview_vb->hide();
-
file = memnew(LineEdit);
//add_child(file);
- filter_vb->add_margin_child(TTR("File:"),file);
-
+ filter_vb->add_margin_child(TTR("File:"), file);
- filter = memnew( OptionButton );
+ filter = memnew(OptionButton);
//add_child(filter);
- filter_vb->add_margin_child(TTR("Filter:"),filter);
- filter->set_clip_text(true);//too many extensions overflow it
+ filter_vb->add_margin_child(TTR("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");
- item_list->connect("item_selected", this,"_item_selected",varray(),CONNECT_DEFERRED);
- item_list->connect("item_activated", this,"_item_db_selected",varray());
- dir->connect("text_entered", this,"_dir_entered");
- file->connect("text_entered", this,"_file_entered");
- filter->connect("item_selected", this,"_filter_selected");
-
+ item_list->connect("item_selected", this, "_item_selected", varray(), CONNECT_DEFERRED);
+ item_list->connect("item_activated", this, "_item_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(TTR("Create Folder"));
- VBoxContainer *makevb= memnew( VBoxContainer );
+ VBoxContainer *makevb = memnew(VBoxContainer);
makedialog->add_child(makevb);
- makedirname = memnew( LineEdit );
- makevb->add_margin_child(TTR("Name:"),makedirname);
+ makedirname = memnew(LineEdit);
+ makevb->add_margin_child(TTR("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(TTR("Could not create folder."));
add_child(mkdirerr);
- exterr = memnew( AcceptDialog );
+ exterr = memnew(AcceptDialog);
exterr->set_text(TTR("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);
- preview_wheel_timeout=0;
- preview_wheel_index=0;
- preview_waiting=false;
-
+ preview_wheel_timeout = 0;
+ preview_wheel_index = 0;
+ preview_waiting = false;
}
-
EditorFileDialog::~EditorFileDialog() {
if (unregister_func)
@@ -1490,21 +1440,19 @@ EditorFileDialog::~EditorFileDialog() {
memdelete(dir_access);
}
-
void EditorLineEditFileChooser::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_browse"),&EditorLineEditFileChooser::_browse);
- ClassDB::bind_method(D_METHOD("_chosen"),&EditorLineEditFileChooser::_chosen);
- ClassDB::bind_method(D_METHOD("get_button:Button"),&EditorLineEditFileChooser::get_button);
- ClassDB::bind_method(D_METHOD("get_line_edit:LineEdit"),&EditorLineEditFileChooser::get_line_edit);
- ClassDB::bind_method(D_METHOD("get_file_dialog:EditorFileDialog"),&EditorLineEditFileChooser::get_file_dialog);
-
+ ClassDB::bind_method(D_METHOD("_browse"), &EditorLineEditFileChooser::_browse);
+ ClassDB::bind_method(D_METHOD("_chosen"), &EditorLineEditFileChooser::_chosen);
+ ClassDB::bind_method(D_METHOD("get_button:Button"), &EditorLineEditFileChooser::get_button);
+ ClassDB::bind_method(D_METHOD("get_line_edit:LineEdit"), &EditorLineEditFileChooser::get_line_edit);
+ ClassDB::bind_method(D_METHOD("get_file_dialog:EditorFileDialog"), &EditorLineEditFileChooser::get_file_dialog);
}
-void EditorLineEditFileChooser::_chosen(const String& p_text){
+void EditorLineEditFileChooser::_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 EditorLineEditFileChooser::_browse() {
@@ -1514,18 +1462,16 @@ void EditorLineEditFileChooser::_browse() {
EditorLineEditFileChooser::EditorLineEditFileChooser() {
- 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( EditorFileDialog);
+ button->connect("pressed", this, "_browse");
+ dialog = memnew(EditorFileDialog);
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/editor/editor_file_dialog.h b/editor/editor_file_dialog.h
index 193cbc513c..6c1bf08a40 100644
--- a/editor/editor_file_dialog.h
+++ b/editor/editor_file_dialog.h
@@ -29,12 +29,12 @@
#ifndef EDITORFILEDIALOG_H
#define EDITORFILEDIALOG_H
+#include "os/dir_access.h"
+#include "scene/gui/box_container.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/item_list.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/option_button.h"
-#include "os/dir_access.h"
-#include "scene/gui/box_container.h"
#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
/**
@@ -42,23 +42,20 @@
*/
class EditorFileDialog : public ConfirmationDialog {
- GDCLASS( EditorFileDialog, ConfirmationDialog );
+ GDCLASS(EditorFileDialog, ConfirmationDialog);
public:
-
enum DisplayMode {
DISPLAY_THUMBNAILS,
DISPLAY_LIST
};
-
enum Access {
ACCESS_RESOURCES,
ACCESS_USERDATA,
ACCESS_FILESYSTEM
};
-
enum Mode {
MODE_OPEN_FILE,
MODE_OPEN_FILES,
@@ -67,8 +64,8 @@ public:
MODE_SAVE_FILE
};
- typedef Ref<Texture> (*GetIconFunc)(const String&);
- typedef void (*RegisterFunc)(EditorFileDialog*);
+ typedef Ref<Texture> (*GetIconFunc)(const String &);
+ typedef void (*RegisterFunc)(EditorFileDialog *);
static GetIconFunc get_icon_func;
static GetIconFunc get_large_icon_func;
@@ -76,7 +73,6 @@ public:
static RegisterFunc unregister_func;
private:
-
ConfirmationDialog *makedialog;
LineEdit *makedirname;
@@ -105,7 +101,6 @@ private:
ToolButton *mode_thumbnails;
ToolButton *mode_list;
-
ToolButton *refresh;
ToolButton *favorite;
@@ -143,8 +138,6 @@ private:
void _favorite_move_up();
void _favorite_move_down();
-
-
void _recent_selected(int p_idx);
void _item_selected(int p_item);
@@ -152,7 +145,7 @@ private:
void _select_drive(int p_idx);
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();
@@ -171,21 +164,19 @@ private:
void _save_to_recent();
//callback funtion is callback(String p_path,Ref<Texture> preview,Variant udata) preview null if could not load
- void _thumbnail_result(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata);
- void _thumbnail_done(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata);
- void _request_single_thumbnail(const String& p_path);
+ void _thumbnail_result(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata);
+ void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata);
+ void _request_single_thumbnail(const String &p_path);
- void _unhandled_input(const InputEvent& p_event);
+ void _unhandled_input(const InputEvent &p_event);
protected:
-
void _notification(int p_what);
static void _bind_methods();
//bind helpers
public:
-
void clear_filters();
- void add_filter(const String& p_filter);
+ void add_filter(const String &p_filter);
void set_enable_multiple_selection(bool p_enable);
Vector<String> get_selected_files() const;
@@ -193,9 +184,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_display_mode(DisplayMode p_mode);
DisplayMode get_display_mode() const;
@@ -222,22 +213,22 @@ public:
EditorFileDialog();
~EditorFileDialog();
-
};
class EditorLineEditFileChooser : public HBoxContainer {
- GDCLASS( EditorLineEditFileChooser, HBoxContainer );
+ GDCLASS(EditorLineEditFileChooser, HBoxContainer);
Button *button;
LineEdit *line_edit;
EditorFileDialog *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; }
EditorFileDialog *get_file_dialog() { return dialog; }
@@ -245,8 +236,8 @@ public:
EditorLineEditFileChooser();
};
-VARIANT_ENUM_CAST( EditorFileDialog::Mode );
-VARIANT_ENUM_CAST( EditorFileDialog::Access );
-VARIANT_ENUM_CAST( EditorFileDialog::DisplayMode );
+VARIANT_ENUM_CAST(EditorFileDialog::Mode);
+VARIANT_ENUM_CAST(EditorFileDialog::Access);
+VARIANT_ENUM_CAST(EditorFileDialog::DisplayMode);
#endif // EDITORFILEDIALOG_H
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index cd151cd90b..b188a5760b 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -28,65 +28,61 @@
/*************************************************************************/
#include "editor_file_system.h"
+#include "editor_node.h"
+#include "editor_resource_preview.h"
+#include "editor_settings.h"
#include "global_config.h"
+#include "io/resource_import.h"
#include "io/resource_loader.h"
-#include "os/os.h"
-#include "os/file_access.h"
-#include "editor_node.h"
#include "io/resource_saver.h"
-#include "io/resource_import.h"
-#include "editor_settings.h"
-#include "editor_resource_preview.h"
+#include "os/file_access.h"
+#include "os/os.h"
#include "variant_parser.h"
-EditorFileSystem *EditorFileSystem::singleton=NULL;
+EditorFileSystem *EditorFileSystem::singleton = NULL;
void EditorFileSystemDirectory::sort_files() {
files.sort_custom<FileInfoSort>();
}
-int EditorFileSystemDirectory::find_file_index(const String& p_file) const {
+int EditorFileSystemDirectory::find_file_index(const String &p_file) const {
- for(int i=0;i<files.size();i++) {
- if (files[i]->file==p_file)
+ for (int i = 0; i < files.size(); i++) {
+ if (files[i]->file == p_file)
return i;
}
return -1;
-
}
-int EditorFileSystemDirectory::find_dir_index(const String& p_dir) const{
+int EditorFileSystemDirectory::find_dir_index(const String &p_dir) const {
-
- for(int i=0;i<subdirs.size();i++) {
- if (subdirs[i]->name==p_dir)
+ for (int i = 0; i < subdirs.size(); i++) {
+ if (subdirs[i]->name == p_dir)
return i;
}
return -1;
}
-
int EditorFileSystemDirectory::get_subdir_count() const {
return subdirs.size();
}
-EditorFileSystemDirectory *EditorFileSystemDirectory::get_subdir(int p_idx){
+EditorFileSystemDirectory *EditorFileSystemDirectory::get_subdir(int p_idx) {
- ERR_FAIL_INDEX_V(p_idx,subdirs.size(),NULL);
+ ERR_FAIL_INDEX_V(p_idx, subdirs.size(), NULL);
return subdirs[p_idx];
-
}
-int EditorFileSystemDirectory::get_file_count() const{
+int EditorFileSystemDirectory::get_file_count() const {
return files.size();
}
-String EditorFileSystemDirectory::get_file(int p_idx) const{
+String EditorFileSystemDirectory::get_file(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,files.size(),"");
+ ERR_FAIL_INDEX_V(p_idx, files.size(), "");
return files[p_idx]->file;
}
@@ -94,41 +90,36 @@ String EditorFileSystemDirectory::get_file(int p_idx) const{
String EditorFileSystemDirectory::get_path() const {
String p;
- const EditorFileSystemDirectory *d=this;
- while(d->parent) {
- p=d->name+"/"+p;
- d=d->parent;
+ const EditorFileSystemDirectory *d = this;
+ while (d->parent) {
+ p = d->name + "/" + p;
+ d = d->parent;
}
- return "res://"+p;
-
+ return "res://" + p;
}
-
String EditorFileSystemDirectory::get_file_path(int p_idx) const {
String file = get_file(p_idx);
- const EditorFileSystemDirectory *d=this;
- while(d->parent) {
- file=d->name+"/"+file;
- d=d->parent;
+ const EditorFileSystemDirectory *d = this;
+ while (d->parent) {
+ file = d->name + "/" + file;
+ d = d->parent;
}
- return "res://"+file;
+ return "res://" + file;
}
-
Vector<String> EditorFileSystemDirectory::get_file_deps(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,files.size(),Vector<String>());
+ ERR_FAIL_INDEX_V(p_idx, files.size(), Vector<String>());
return files[p_idx]->deps;
-
}
-
StringName EditorFileSystemDirectory::get_file_type(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,files.size(),"");
+ ERR_FAIL_INDEX_V(p_idx, files.size(), "");
return files[p_idx]->type;
}
@@ -144,45 +135,38 @@ EditorFileSystemDirectory *EditorFileSystemDirectory::get_parent() {
void EditorFileSystemDirectory::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_subdir_count"),&EditorFileSystemDirectory::get_subdir_count);
- ClassDB::bind_method(D_METHOD("get_subdir","idx"),&EditorFileSystemDirectory::get_subdir);
- ClassDB::bind_method(D_METHOD("get_file_count"),&EditorFileSystemDirectory::get_file_count);
- ClassDB::bind_method(D_METHOD("get_file","idx"),&EditorFileSystemDirectory::get_file);
- ClassDB::bind_method(D_METHOD("get_file_path","idx"),&EditorFileSystemDirectory::get_file_path);
- ClassDB::bind_method(D_METHOD("get_file_type","idx"),&EditorFileSystemDirectory::get_file_type);
- ClassDB::bind_method(D_METHOD("get_name"),&EditorFileSystemDirectory::get_name);
- ClassDB::bind_method(D_METHOD("get_path"),&EditorFileSystemDirectory::get_path);
- ClassDB::bind_method(D_METHOD("get_parent:EditorFileSystemDirectory"),&EditorFileSystemDirectory::get_parent);
- ClassDB::bind_method(D_METHOD("find_file_index","name"),&EditorFileSystemDirectory::find_file_index);
- ClassDB::bind_method(D_METHOD("find_dir_index","name"),&EditorFileSystemDirectory::find_dir_index);
-
-
+ ClassDB::bind_method(D_METHOD("get_subdir_count"), &EditorFileSystemDirectory::get_subdir_count);
+ ClassDB::bind_method(D_METHOD("get_subdir", "idx"), &EditorFileSystemDirectory::get_subdir);
+ ClassDB::bind_method(D_METHOD("get_file_count"), &EditorFileSystemDirectory::get_file_count);
+ ClassDB::bind_method(D_METHOD("get_file", "idx"), &EditorFileSystemDirectory::get_file);
+ ClassDB::bind_method(D_METHOD("get_file_path", "idx"), &EditorFileSystemDirectory::get_file_path);
+ ClassDB::bind_method(D_METHOD("get_file_type", "idx"), &EditorFileSystemDirectory::get_file_type);
+ ClassDB::bind_method(D_METHOD("get_name"), &EditorFileSystemDirectory::get_name);
+ ClassDB::bind_method(D_METHOD("get_path"), &EditorFileSystemDirectory::get_path);
+ ClassDB::bind_method(D_METHOD("get_parent:EditorFileSystemDirectory"), &EditorFileSystemDirectory::get_parent);
+ ClassDB::bind_method(D_METHOD("find_file_index", "name"), &EditorFileSystemDirectory::find_file_index);
+ ClassDB::bind_method(D_METHOD("find_dir_index", "name"), &EditorFileSystemDirectory::find_dir_index);
}
-
EditorFileSystemDirectory::EditorFileSystemDirectory() {
- modified_time=0;
- parent=NULL;
+ modified_time = 0;
+ parent = NULL;
}
EditorFileSystemDirectory::~EditorFileSystemDirectory() {
- for(int i=0;i<files.size();i++) {
+ for (int i = 0; i < files.size(); i++) {
memdelete(files[i]);
}
- for(int i=0;i<subdirs.size();i++) {
+ for (int i = 0; i < subdirs.size(); i++) {
memdelete(subdirs[i]);
}
}
-
-
-
-
void EditorFileSystem::_scan_filesystem() {
ERR_FAIL_COND(!scanning || new_filesystem);
@@ -193,335 +177,316 @@ void EditorFileSystem::_scan_filesystem() {
sources_changed.clear();
file_cache.clear();
- String project=GlobalConfig::get_singleton()->get_resource_path();
+ String project = GlobalConfig::get_singleton()->get_resource_path();
String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache2");
- FileAccess *f =FileAccess::open(fscache,FileAccess::READ);
+ FileAccess *f = FileAccess::open(fscache, FileAccess::READ);
if (f) {
//read the disk cache
- while(!f->eof_reached()) {
+ while (!f->eof_reached()) {
String l = f->get_line().strip_edges();
- if (l==String())
+ if (l == String())
continue;
if (l.begins_with("::")) {
Vector<String> split = l.split("::");
- ERR_CONTINUE( split.size() != 3);
+ ERR_CONTINUE(split.size() != 3);
String name = split[1];
- cpath=name;
+ cpath = name;
} else {
Vector<String> split = l.split("::");
- ERR_CONTINUE( split.size() != 5);
+ ERR_CONTINUE(split.size() != 5);
String name = split[0];
String file;
- file=name;
- name=cpath.plus_file(name);
+ file = name;
+ name = cpath.plus_file(name);
FileCache fc;
- fc.type=split[1];
- fc.modification_time=split[2].to_int64();
+ fc.type = split[1];
+ fc.modification_time = split[2].to_int64();
fc.import_modification_time = split[3].to_int64();
String deps = split[4].strip_edges();
if (deps.length()) {
Vector<String> dp = deps.split("<>");
- for(int i=0;i<dp.size();i++) {
- String path=dp[i];
+ for (int i = 0; i < dp.size(); i++) {
+ String path = dp[i];
fc.deps.push_back(path);
}
}
- file_cache[name]=fc;
-
+ file_cache[name] = fc;
}
-
}
f->close();
memdelete(f);
}
-
-
- EditorProgressBG scan_progress("efs","ScanFS",1000);
+ EditorProgressBG scan_progress("efs", "ScanFS", 1000);
ScanProgress sp;
- sp.low=0;
- sp.hi=1;
- sp.progress=&scan_progress;
-
+ sp.low = 0;
+ sp.hi = 1;
+ sp.progress = &scan_progress;
- new_filesystem = memnew( EditorFileSystemDirectory );
- new_filesystem->parent=NULL;
+ new_filesystem = memnew(EditorFileSystemDirectory);
+ new_filesystem->parent = NULL;
DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
d->change_dir("res://");
- _scan_new_dir(new_filesystem,d,sp);
+ _scan_new_dir(new_filesystem, d, sp);
file_cache.clear(); //clear caches, no longer needed
memdelete(d);
-
//save back the findings
//String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("file_cache");
- f=FileAccess::open(fscache,FileAccess::WRITE);
- _save_filesystem_cache(new_filesystem,f);
+ f = FileAccess::open(fscache, FileAccess::WRITE);
+ _save_filesystem_cache(new_filesystem, f);
f->close();
memdelete(f);
- scanning=false;
-
+ scanning = false;
}
void EditorFileSystem::_save_filesystem_cache() {
String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache2");
- FileAccess *f=FileAccess::open(fscache,FileAccess::WRITE);
- _save_filesystem_cache(filesystem,f);
+ FileAccess *f = FileAccess::open(fscache, FileAccess::WRITE);
+ _save_filesystem_cache(filesystem, f);
f->close();
memdelete(f);
}
void EditorFileSystem::_thread_func(void *_userdata) {
- EditorFileSystem *sd = (EditorFileSystem*)_userdata;
+ EditorFileSystem *sd = (EditorFileSystem *)_userdata;
sd->_scan_filesystem();
-
}
bool EditorFileSystem::_update_scan_actions() {
sources_changed.clear();
- bool fs_changed=false;
+ bool fs_changed = false;
Vector<String> reimports;
- for (List<ItemAction>::Element *E=scan_actions.front();E;E=E->next()) {
+ for (List<ItemAction>::Element *E = scan_actions.front(); E; E = E->next()) {
- ItemAction&ia = E->get();
+ ItemAction &ia = E->get();
- switch(ia.action) {
+ switch (ia.action) {
case ItemAction::ACTION_NONE: {
} break;
case ItemAction::ACTION_DIR_ADD: {
//print_line("*ACTION ADD DIR: "+ia.new_dir->get_name());
- int idx=0;
- for(int i=0;i<ia.dir->subdirs.size();i++) {
+ int idx = 0;
+ for (int i = 0; i < ia.dir->subdirs.size(); i++) {
- if (ia.new_dir->name<ia.dir->subdirs[i]->name)
+ if (ia.new_dir->name < ia.dir->subdirs[i]->name)
break;
idx++;
}
- if (idx==ia.dir->subdirs.size()) {
+ if (idx == ia.dir->subdirs.size()) {
ia.dir->subdirs.push_back(ia.new_dir);
} else {
- ia.dir->subdirs.insert(idx,ia.new_dir);
+ ia.dir->subdirs.insert(idx, ia.new_dir);
}
- fs_changed=true;
+ fs_changed = true;
} break;
case ItemAction::ACTION_DIR_REMOVE: {
ERR_CONTINUE(!ia.dir->parent);
//print_line("*ACTION REMOVE DIR: "+ia.dir->get_name());
ia.dir->parent->subdirs.erase(ia.dir);
- memdelete( ia.dir );
- fs_changed=true;
+ memdelete(ia.dir);
+ fs_changed = true;
} break;
case ItemAction::ACTION_FILE_ADD: {
- int idx=0;
- for(int i=0;i<ia.dir->files.size();i++) {
+ int idx = 0;
+ for (int i = 0; i < ia.dir->files.size(); i++) {
- if (ia.new_file->file<ia.dir->files[i]->file)
+ if (ia.new_file->file < ia.dir->files[i]->file)
break;
idx++;
}
- if (idx==ia.dir->files.size()) {
+ if (idx == ia.dir->files.size()) {
ia.dir->files.push_back(ia.new_file);
} else {
- ia.dir->files.insert(idx,ia.new_file);
+ ia.dir->files.insert(idx, ia.new_file);
}
- fs_changed=true;
+ fs_changed = true;
//print_line("*ACTION ADD FILE: "+ia.new_file->file);
} break;
case ItemAction::ACTION_FILE_REMOVE: {
int idx = ia.dir->find_file_index(ia.file);
- ERR_CONTINUE(idx==-1);
- memdelete( ia.dir->files[idx] );
+ ERR_CONTINUE(idx == -1);
+ memdelete(ia.dir->files[idx]);
ia.dir->files.remove(idx);
- fs_changed=true;
+ fs_changed = true;
//print_line("*ACTION REMOVE FILE: "+ia.file);
} break;
case ItemAction::ACTION_FILE_REIMPORT: {
-
int idx = ia.dir->find_file_index(ia.file);
- ERR_CONTINUE(idx==-1);
+ ERR_CONTINUE(idx == -1);
String full_path = ia.dir->get_file_path(idx);
reimports.push_back(full_path);
- fs_changed=true;
+ fs_changed = true;
} break;
-
}
}
-
if (reimports.size()) {
reimport_files(reimports);
-
}
scan_actions.clear();
return fs_changed;
-
}
void EditorFileSystem::scan() {
- if (false /*&& bool(Globals::get_singleton()->get("debug/disable_scan"))*/)
- return;
+ if (false /*&& bool(Globals::get_singleton()->get("debug/disable_scan"))*/)
+ return;
- if (scanning || scanning_changes|| thread)
+ if (scanning || scanning_changes || thread)
return;
_update_extensions();
- abort_scan=false;
+ abort_scan = false;
if (!use_threads) {
- scanning=true;
- scan_total=0;
+ scanning = true;
+ scan_total = 0;
_scan_filesystem();
if (filesystem)
memdelete(filesystem);
//file_type_cache.clear();
- filesystem=new_filesystem;
- new_filesystem=NULL;
+ filesystem = new_filesystem;
+ new_filesystem = NULL;
_update_scan_actions();
- scanning=false;
+ scanning = false;
emit_signal("filesystem_changed");
- emit_signal("sources_changed",sources_changed.size()>0);
+ emit_signal("sources_changed", sources_changed.size() > 0);
} else {
ERR_FAIL_COND(thread);
set_process(true);
Thread::Settings s;
- scanning=true;
- scan_total=0;
- s.priority=Thread::PRIORITY_LOW;
- thread = Thread::create(_thread_func,this,s);
+ scanning = true;
+ scan_total = 0;
+ s.priority = Thread::PRIORITY_LOW;
+ thread = Thread::create(_thread_func, this, s);
//tree->hide();
//progress->show();
-
}
-
-
-
}
-void EditorFileSystem::ScanProgress::update(int p_current,int p_total) const {
+void EditorFileSystem::ScanProgress::update(int p_current, int p_total) const {
- float ratio = low + ((hi-low)/p_total)*p_current;
- progress->step(ratio*1000);
- EditorFileSystem::singleton->scan_total=ratio;
+ float ratio = low + ((hi - low) / p_total) * p_current;
+ progress->step(ratio * 1000);
+ EditorFileSystem::singleton->scan_total = ratio;
}
-EditorFileSystem::ScanProgress EditorFileSystem::ScanProgress::get_sub(int p_current,int p_total) const{
+EditorFileSystem::ScanProgress EditorFileSystem::ScanProgress::get_sub(int p_current, int p_total) const {
- ScanProgress sp=*this;
- float slice = (sp.hi-sp.low)/p_total;
- sp.low+=slice*p_current;
- sp.hi=slice;
+ ScanProgress sp = *this;
+ float slice = (sp.hi - sp.low) / p_total;
+ sp.low += slice * p_current;
+ sp.hi = slice;
return sp;
-
}
-bool EditorFileSystem::_check_missing_imported_files(const String& p_path) {
+bool EditorFileSystem::_check_missing_imported_files(const String &p_path) {
if (!reimport_on_missing_imported_files)
return true;
Error err;
- FileAccess *f= FileAccess::open(p_path+".import",FileAccess::READ,&err);
+ FileAccess *f = FileAccess::open(p_path + ".import", FileAccess::READ, &err);
if (!f) {
- print_line("could not open import for "+p_path);
+ print_line("could not open import for " + p_path);
return false;
}
VariantParser::StreamFile stream;
- stream.f=f;
+ stream.f = f;
String assign;
Variant value;
VariantParser::Tag next_tag;
- int lines=0;
+ int lines = 0;
String error_text;
List<String> to_check;
- while(true) {
+ while (true) {
- assign=Variant();
+ assign = Variant();
next_tag.fields.clear();
- next_tag.name=String();
+ next_tag.name = String();
- err = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,NULL,true);
- if (err==ERR_FILE_EOF) {
+ err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true);
+ if (err == ERR_FILE_EOF) {
memdelete(f);
return OK;
- }
- else if (err!=OK) {
- ERR_PRINTS("ResourceFormatImporter::load - "+p_path+".import:"+itos(lines)+" error: "+error_text);
+ } else if (err != OK) {
+ ERR_PRINTS("ResourceFormatImporter::load - " + p_path + ".import:" + itos(lines) + " error: " + error_text);
memdelete(f);
return false;
}
- if (assign!=String()) {
+ if (assign != String()) {
if (assign.begins_with("path")) {
to_check.push_back(value);
- } else if (assign=="files") {
+ } else if (assign == "files") {
Array fa = value;
- for(int i=0;i<fa.size();i++) {
+ for (int i = 0; i < fa.size(); i++) {
to_check.push_back(fa[i]);
}
}
- } else if (next_tag.name!="remap" && next_tag.name!="deps") {
+ } else if (next_tag.name != "remap" && next_tag.name != "deps") {
break;
}
}
memdelete(f);
- for (List<String>::Element *E=to_check.front();E;E=E->next()) {
+ for (List<String>::Element *E = to_check.front(); E; E = E->next()) {
if (!FileAccess::exists(E->get())) {
- print_line("missing "+E->get()+", reimport" );
+ print_line("missing " + E->get() + ", reimport");
return false;
}
}
return true;
}
-void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess *da,const ScanProgress& p_progress) {
+void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess *da, const ScanProgress &p_progress) {
List<String> dirs;
List<String> files;
@@ -530,13 +495,12 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess
p_dir->modified_time = FileAccess::get_modified_time(cd);
-
da->list_dir_begin();
while (true) {
bool isdir;
String f = da->get_next(&isdir);
- if (f=="")
+ if (f == "")
break;
if (isdir) {
@@ -553,7 +517,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess
files.push_back(f);
}
-
}
da->list_dir_end();
@@ -561,61 +524,57 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess
dirs.sort();
files.sort();
- int total = dirs.size()+files.size();
- int idx=0;
-
+ int total = dirs.size() + files.size();
+ int idx = 0;
- for (List<String>::Element *E=dirs.front();E;E=E->next(),idx++) {
+ for (List<String>::Element *E = dirs.front(); E; E = E->next(), idx++) {
- if (da->change_dir(E->get())==OK) {
+ if (da->change_dir(E->get()) == OK) {
String d = da->get_current_dir();
- if (d==cd || !d.begins_with(cd)) {
+ if (d == cd || !d.begins_with(cd)) {
da->change_dir(cd); //avoid recursion
} else {
+ EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory);
- EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory );
+ efd->parent = p_dir;
+ efd->name = E->get();
- efd->parent=p_dir;
- efd->name=E->get();
+ _scan_new_dir(efd, da, p_progress.get_sub(idx, total));
- _scan_new_dir(efd,da,p_progress.get_sub(idx,total));
+ int idx = 0;
+ for (int i = 0; i < p_dir->subdirs.size(); i++) {
- int idx=0;
- for(int i=0;i<p_dir->subdirs.size();i++) {
-
- if (efd->name<p_dir->subdirs[i]->name)
+ if (efd->name < p_dir->subdirs[i]->name)
break;
idx++;
}
- if (idx==p_dir->subdirs.size()) {
+ if (idx == p_dir->subdirs.size()) {
p_dir->subdirs.push_back(efd);
} else {
- p_dir->subdirs.insert(idx,efd);
+ p_dir->subdirs.insert(idx, efd);
}
da->change_dir("..");
}
} else {
- ERR_PRINTS("Cannot go into subdir: "+E->get());
+ ERR_PRINTS("Cannot go into subdir: " + E->get());
}
- p_progress.update(idx,total);
-
+ p_progress.update(idx, total);
}
- for (List<String>::Element*E=files.front();E;E=E->next(),idx++) {
-
+ for (List<String>::Element *E = files.front(); E; E = E->next(), idx++) {
String ext = E->get().get_extension().to_lower();
if (!valid_extensions.has(ext)) {
continue; //invalid
}
- EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo );
- fi->file=E->get();
+ EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo);
+ fi->file = E->get();
String path = cd.plus_file(fi->file);
@@ -624,92 +583,87 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess
if (import_extensions.has(ext)) {
- //is imported
- uint64_t import_mt=0;
- if (FileAccess::exists(path+".import")) {
- import_mt=FileAccess::get_modified_time(path+".import");
+ //is imported
+ uint64_t import_mt = 0;
+ if (FileAccess::exists(path + ".import")) {
+ import_mt = FileAccess::get_modified_time(path + ".import");
}
+ if (fc && fc->modification_time == mt && fc->import_modification_time == import_mt && _check_missing_imported_files(path)) {
- if (fc && fc->modification_time==mt && fc->import_modification_time==import_mt && _check_missing_imported_files(path)) {
-
- fi->type=fc->type;
- fi->modified_time=fc->modification_time;
- fi->import_modified_time=fc->import_modification_time;
+ fi->type = fc->type;
+ fi->modified_time = fc->modification_time;
+ fi->import_modified_time = fc->import_modification_time;
} else {
if (!fc) {
print_line("REIMPORT BECAUSE: not previously found");
- } else if (fc->modification_time!=mt) {
- print_line("REIMPORT BECAUSE: modified resource time "+itos(fc->modification_time)+" vs "+itos(mt));
+ } else if (fc->modification_time != mt) {
+ print_line("REIMPORT BECAUSE: modified resource time " + itos(fc->modification_time) + " vs " + itos(mt));
- } else if (fc->import_modification_time!=import_mt) {
- print_line("REIMPORT BECAUSE: modified .import time"+itos(fc->import_modification_time)+" vs "+itos(import_mt));
+ } else if (fc->import_modification_time != import_mt) {
+ print_line("REIMPORT BECAUSE: modified .import time" + itos(fc->import_modification_time) + " vs " + itos(import_mt));
} else {
print_line("REIMPORT BECAUSE: missing imported files");
}
-
- fi->type=ResourceFormatImporter::get_singleton()->get_resource_type(path);
- fi->modified_time=0;
- fi->import_modified_time=0;
+ fi->type = ResourceFormatImporter::get_singleton()->get_resource_type(path);
+ fi->modified_time = 0;
+ fi->import_modified_time = 0;
ItemAction ia;
- ia.action=ItemAction::ACTION_FILE_REIMPORT;
- ia.dir=p_dir;
- ia.file=E->get();
+ ia.action = ItemAction::ACTION_FILE_REIMPORT;
+ ia.dir = p_dir;
+ ia.file = E->get();
scan_actions.push_back(ia);
}
} else {
//not imported, so just update type if changed
if (fc && fc->modification_time == mt) {
- fi->type=fc->type;
- fi->modified_time=fc->modification_time;
- fi->import_modified_time=0;
+ fi->type = fc->type;
+ fi->modified_time = fc->modification_time;
+ fi->import_modified_time = 0;
} else {
- fi->type=ResourceLoader::get_resource_type(path);
- fi->modified_time=mt;
- fi->import_modified_time=0;
+ fi->type = ResourceLoader::get_resource_type(path);
+ fi->modified_time = mt;
+ fi->import_modified_time = 0;
}
}
p_dir->files.push_back(fi);
- p_progress.update(idx,total);
+ p_progress.update(idx, total);
}
-
}
-
-
-void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const ScanProgress& p_progress) {
+void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const ScanProgress &p_progress) {
uint64_t current_mtime = FileAccess::get_modified_time(p_dir->get_path());
- bool updated_dir=false;
+ bool updated_dir = false;
String cd = p_dir->get_path();
//print_line("dir: "+p_dir->get_path()+" MODTIME: "+itos(p_dir->modified_time)+" CTIME: "+itos(current_mtime));
- if (current_mtime!=p_dir->modified_time) {
+ if (current_mtime != p_dir->modified_time) {
- updated_dir=true;
- p_dir->modified_time=current_mtime;
+ updated_dir = true;
+ p_dir->modified_time = current_mtime;
//ooooops, dir changed, see what's going on
//first mark everything as veryfied
- for(int i=0;i<p_dir->files.size();i++) {
+ for (int i = 0; i < p_dir->files.size(); i++) {
- p_dir->files[i]->verified=false;
+ p_dir->files[i]->verified = false;
}
- for(int i=0;i<p_dir->subdirs.size();i++) {
+ for (int i = 0; i < p_dir->subdirs.size(); i++) {
- p_dir->get_subdir(i)->verified=false;
+ p_dir->get_subdir(i)->verified = false;
}
//then scan files and directories and check what's different
@@ -722,7 +676,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
bool isdir;
String f = da->get_next(&isdir);
- if (f=="")
+ if (f == "")
break;
if (isdir) {
@@ -731,32 +685,30 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
continue;
int idx = p_dir->find_dir_index(f);
- if (idx==-1) {
+ if (idx == -1) {
if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this
continue;
- EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory );
+ EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory);
- efd->parent=p_dir;
- efd->name=f;
+ efd->parent = p_dir;
+ efd->name = f;
DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
d->change_dir(cd.plus_file(f));
- _scan_new_dir(efd,d,p_progress.get_sub(1,1));
+ _scan_new_dir(efd, d, p_progress.get_sub(1, 1));
memdelete(d);
-
ItemAction ia;
- ia.action=ItemAction::ACTION_DIR_ADD;
- ia.dir=p_dir;
- ia.file=f;
- ia.new_dir=efd;
+ ia.action = ItemAction::ACTION_DIR_ADD;
+ ia.dir = p_dir;
+ ia.file = f;
+ ia.new_dir = efd;
scan_actions.push_back(ia);
} else {
- p_dir->subdirs[idx]->verified=true;
+ p_dir->subdirs[idx]->verified = true;
}
-
} else {
String ext = f.get_extension().to_lower();
if (!valid_extensions.has(ext))
@@ -764,66 +716,59 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
int idx = p_dir->find_file_index(f);
- if (idx==-1) {
+ if (idx == -1) {
//never seen this file, add actition to add it
- EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo );
- fi->file=f;
+ EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo);
+ fi->file = f;
String path = cd.plus_file(fi->file);
- fi->modified_time=FileAccess::get_modified_time(path);
- fi->import_modified_time=0;
- fi->type=ResourceLoader::get_resource_type(path);
+ fi->modified_time = FileAccess::get_modified_time(path);
+ fi->import_modified_time = 0;
+ fi->type = ResourceLoader::get_resource_type(path);
{
ItemAction ia;
- ia.action=ItemAction::ACTION_FILE_ADD;
- ia.dir=p_dir;
- ia.file=f;
- ia.new_file=fi;
+ ia.action = ItemAction::ACTION_FILE_ADD;
+ ia.dir = p_dir;
+ ia.file = f;
+ ia.new_file = fi;
scan_actions.push_back(ia);
-
-
}
if (import_extensions.has(ext)) {
//if it can be imported, and it was added, it needs to be reimported
print_line("REIMPORT: file was not found before, reimport");
- print_line("at dir: "+p_dir->get_path()+" file: "+f);
- for(int i=0;i<p_dir->files.size();i++) {
- print_line(itos(i)+": "+p_dir->files[i]->file);
+ print_line("at dir: " + p_dir->get_path() + " file: " + f);
+ for (int i = 0; i < p_dir->files.size(); i++) {
+ print_line(itos(i) + ": " + p_dir->files[i]->file);
}
ItemAction ia;
- ia.action=ItemAction::ACTION_FILE_REIMPORT;
- ia.dir=p_dir;
- ia.file=f;
+ ia.action = ItemAction::ACTION_FILE_REIMPORT;
+ ia.dir = p_dir;
+ ia.file = f;
scan_actions.push_back(ia);
}
} else {
- p_dir->files[idx]->verified=true;
+ p_dir->files[idx]->verified = true;
}
-
-
}
-
}
da->list_dir_end();
memdelete(da);
-
}
- for(int i=0;i<p_dir->files.size();i++) {
+ for (int i = 0; i < p_dir->files.size(); i++) {
if (updated_dir && !p_dir->files[i]->verified) {
//this file was removed, add action to remove it
ItemAction ia;
- ia.action=ItemAction::ACTION_FILE_REMOVE;
- ia.dir=p_dir;
- ia.file=p_dir->files[i]->file;
+ ia.action = ItemAction::ACTION_FILE_REMOVE;
+ ia.dir = p_dir;
+ ia.file = p_dir->files[i]->file;
scan_actions.push_back(ia);
continue;
-
}
if (import_extensions.has(p_dir->files[i]->file.get_extension().to_lower())) {
@@ -833,150 +778,142 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
uint64_t mt = FileAccess::get_modified_time(path);
- bool reimport=false;
+ bool reimport = false;
- if (mt!=p_dir->files[i]->modified_time) {
+ if (mt != p_dir->files[i]->modified_time) {
print_line("REIMPORT: modified time changed, reimport");
- reimport=true; //it was modified, must be reimported.
- } else if (!FileAccess::exists(path+".import")) {
+ reimport = true; //it was modified, must be reimported.
+ } else if (!FileAccess::exists(path + ".import")) {
print_line("REIMPORT: no .import exists, reimport");
- reimport=true; //no .import file, obviously reimport
+ reimport = true; //no .import file, obviously reimport
} else {
- uint64_t import_mt=FileAccess::get_modified_time(path+".import");
- print_line(itos(import_mt)+" vs "+itos(p_dir->files[i]->import_modified_time));
- if (import_mt!=p_dir->files[i]->import_modified_time) {
+ uint64_t import_mt = FileAccess::get_modified_time(path + ".import");
+ print_line(itos(import_mt) + " vs " + itos(p_dir->files[i]->import_modified_time));
+ if (import_mt != p_dir->files[i]->import_modified_time) {
print_line("REIMPORT: import modified changed, reimport");
- reimport=true;
+ reimport = true;
} else if (!_check_missing_imported_files(path)) {
print_line("REIMPORT: imported files removed");
- reimport=true;
+ reimport = true;
}
}
if (reimport) {
ItemAction ia;
- ia.action=ItemAction::ACTION_FILE_REIMPORT;
- ia.dir=p_dir;
- ia.file=p_dir->files[i]->file;
+ ia.action = ItemAction::ACTION_FILE_REIMPORT;
+ ia.dir = p_dir;
+ ia.file = p_dir->files[i]->file;
scan_actions.push_back(ia);
}
-
}
EditorResourcePreview::get_singleton()->check_for_invalidation(p_dir->get_file_path(i));
}
- for(int i=0;i<p_dir->subdirs.size();i++) {
+ for (int i = 0; i < p_dir->subdirs.size(); i++) {
if (updated_dir && !p_dir->subdirs[i]->verified) {
//this directory was removed, add action to remove it
ItemAction ia;
- ia.action=ItemAction::ACTION_DIR_REMOVE;
- ia.dir=p_dir->subdirs[i];
+ ia.action = ItemAction::ACTION_DIR_REMOVE;
+ ia.dir = p_dir->subdirs[i];
scan_actions.push_back(ia);
continue;
-
}
- _scan_fs_changes(p_dir->get_subdir(i),p_progress);
+ _scan_fs_changes(p_dir->get_subdir(i), p_progress);
}
-
}
void EditorFileSystem::_thread_func_sources(void *_userdata) {
- EditorFileSystem *efs = (EditorFileSystem*)_userdata;
+ EditorFileSystem *efs = (EditorFileSystem *)_userdata;
if (efs->filesystem) {
- EditorProgressBG pr("sources",TTR("ScanSources"),1000);
+ EditorProgressBG pr("sources", TTR("ScanSources"), 1000);
ScanProgress sp;
- sp.progress=&pr;
- sp.hi=1;
- sp.low=0;
- efs->_scan_fs_changes(efs->filesystem,sp);
+ sp.progress = &pr;
+ sp.hi = 1;
+ sp.low = 0;
+ efs->_scan_fs_changes(efs->filesystem, sp);
}
- efs->scanning_changes_done=true;
+ efs->scanning_changes_done = true;
}
void EditorFileSystem::get_changed_sources(List<String> *r_changed) {
- *r_changed=sources_changed;
+ *r_changed = sources_changed;
}
void EditorFileSystem::scan_changes() {
- if (scanning || scanning_changes|| thread)
+ if (scanning || scanning_changes || thread)
return;
_update_extensions();
sources_changed.clear();
- scanning_changes=true;
- scanning_changes_done=false;
+ scanning_changes = true;
+ scanning_changes_done = false;
- abort_scan=false;
+ abort_scan = false;
if (!use_threads) {
if (filesystem) {
- EditorProgressBG pr("sources",TTR("ScanSources"),1000);
+ EditorProgressBG pr("sources", TTR("ScanSources"), 1000);
ScanProgress sp;
- sp.progress=&pr;
- sp.hi=1;
- sp.low=0;
- scan_total=0;
- _scan_fs_changes(filesystem,sp);
+ sp.progress = &pr;
+ sp.hi = 1;
+ sp.low = 0;
+ scan_total = 0;
+ _scan_fs_changes(filesystem, sp);
if (_update_scan_actions())
emit_signal("filesystem_changed");
}
- scanning_changes=false;
- scanning_changes_done=true;
- emit_signal("sources_changed",sources_changed.size()>0);
+ scanning_changes = false;
+ scanning_changes_done = true;
+ emit_signal("sources_changed", sources_changed.size() > 0);
} else {
ERR_FAIL_COND(thread_sources);
set_process(true);
- scan_total=0;
+ scan_total = 0;
Thread::Settings s;
- s.priority=Thread::PRIORITY_LOW;
- thread_sources = Thread::create(_thread_func_sources,this,s);
+ s.priority = Thread::PRIORITY_LOW;
+ thread_sources = Thread::create(_thread_func_sources, this, s);
//tree->hide();
//print_line("SCAN BEGIN!");
//progress->show();
}
-
-
-
}
void EditorFileSystem::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
-
- scan();
+ scan();
} break;
case NOTIFICATION_EXIT_TREE: {
if (use_threads && thread) {
//abort thread if in progress
- abort_scan=true;
- while(scanning) {
+ abort_scan = true;
+ while (scanning) {
OS::get_singleton()->delay_usec(1000);
}
Thread::wait_to_finish(thread);
memdelete(thread);
- thread=NULL;
+ thread = NULL;
WARN_PRINTS("Scan thread aborted...");
set_process(false);
-
}
if (filesystem)
memdelete(filesystem);
if (new_filesystem)
memdelete(new_filesystem);
- filesystem=NULL;
- new_filesystem=NULL;
+ filesystem = NULL;
+ new_filesystem = NULL;
} break;
case NOTIFICATION_PROCESS: {
@@ -987,17 +924,17 @@ void EditorFileSystem::_notification(int p_what) {
if (scanning_changes_done) {
- scanning_changes=false;
+ scanning_changes = false;
set_process(false);
Thread::wait_to_finish(thread_sources);
memdelete(thread_sources);
- thread_sources=NULL;
+ thread_sources = NULL;
if (_update_scan_actions())
emit_signal("filesystem_changed");
//print_line("sources changed: "+itos(sources_changed.size()));
- emit_signal("sources_changed",sources_changed.size()>0);
+ emit_signal("sources_changed", sources_changed.size() > 0);
}
} else if (!scanning) {
@@ -1005,25 +942,22 @@ void EditorFileSystem::_notification(int p_what) {
if (filesystem)
memdelete(filesystem);
- filesystem=new_filesystem;
- new_filesystem=NULL;
+ filesystem = new_filesystem;
+ new_filesystem = NULL;
Thread::wait_to_finish(thread);
memdelete(thread);
- thread=NULL;
+ thread = NULL;
_update_scan_actions();
emit_signal("filesystem_changed");
- emit_signal("sources_changed",sources_changed.size()>0);
+ emit_signal("sources_changed", sources_changed.size() > 0);
//print_line("initial sources changed: "+itos(sources_changed.size()));
-
-
} else {
//progress->set_text("Scanning...\n"+itos(total*100)+"%");
}
}
} break;
}
-
}
bool EditorFileSystem::is_scanning() const {
@@ -1040,311 +974,283 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem() {
return filesystem;
}
-void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory*p_dir,FileAccess *p_file) {
-
+void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir, FileAccess *p_file) {
if (!p_dir)
return; //none
- p_file->store_line("::"+p_dir->get_path()+"::"+String::num(p_dir->modified_time));
+ p_file->store_line("::" + p_dir->get_path() + "::" + String::num(p_dir->modified_time));
- for(int i=0;i<p_dir->files.size();i++) {
+ for (int i = 0; i < p_dir->files.size(); i++) {
- String s=p_dir->files[i]->file+"::"+p_dir->files[i]->type+"::"+itos(p_dir->files[i]->modified_time)+"::"+itos(p_dir->files[i]->import_modified_time);
- s+="::";
- for(int j=0;j<p_dir->files[i]->deps.size();j++) {
+ String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time);
+ s += "::";
+ for (int j = 0; j < p_dir->files[i]->deps.size(); j++) {
- if (j>0)
- s+="<>";
- s+=p_dir->files[i]->deps[j];
+ if (j > 0)
+ s += "<>";
+ s += p_dir->files[i]->deps[j];
}
p_file->store_line(s);
}
- for(int i=0;i<p_dir->subdirs.size();i++) {
+ for (int i = 0; i < p_dir->subdirs.size(); i++) {
- _save_filesystem_cache(p_dir->subdirs[i],p_file);
+ _save_filesystem_cache(p_dir->subdirs[i], p_file);
}
-
}
-
-
-
-
-
-bool EditorFileSystem::_find_file(const String& p_file,EditorFileSystemDirectory ** r_d, int &r_file_pos) const {
+bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirectory **r_d, int &r_file_pos) const {
//todo make faster
if (!filesystem || scanning)
return false;
-
String f = GlobalConfig::get_singleton()->localize_path(p_file);
if (!f.begins_with("res://"))
return false;
- f=f.substr(6,f.length());
- f=f.replace("\\","/");
+ f = f.substr(6, f.length());
+ f = f.replace("\\", "/");
Vector<String> path = f.split("/");
- if (path.size()==0)
+ if (path.size() == 0)
return false;
- String file=path[path.size()-1];
- path.resize(path.size()-1);
+ String file = path[path.size() - 1];
+ path.resize(path.size() - 1);
- EditorFileSystemDirectory *fs=filesystem;
+ EditorFileSystemDirectory *fs = filesystem;
- for(int i=0;i<path.size();i++) {
+ for (int i = 0; i < path.size(); i++) {
if (path[i].begins_with("."))
return false;
- int idx=-1;
- for(int j=0;j<fs->get_subdir_count();j++) {
+ int idx = -1;
+ for (int j = 0; j < fs->get_subdir_count(); j++) {
- if (fs->get_subdir(j)->get_name()==path[i]) {
- idx=j;
+ if (fs->get_subdir(j)->get_name() == path[i]) {
+ idx = j;
break;
}
}
- if (idx==-1) {
+ if (idx == -1) {
//does not exist, create i guess?
- EditorFileSystemDirectory *efsd = memnew( EditorFileSystemDirectory );
- efsd->name=path[i];
- int idx2=0;
- for(int j=0;j<fs->get_subdir_count();j++) {
+ EditorFileSystemDirectory *efsd = memnew(EditorFileSystemDirectory);
+ efsd->name = path[i];
+ int idx2 = 0;
+ for (int j = 0; j < fs->get_subdir_count(); j++) {
- if (efsd->name<fs->get_subdir(j)->get_name())
+ if (efsd->name < fs->get_subdir(j)->get_name())
break;
idx2++;
}
- if (idx2==fs->get_subdir_count())
+ if (idx2 == fs->get_subdir_count())
fs->subdirs.push_back(efsd);
else
- fs->subdirs.insert(idx2,efsd);
- fs=efsd;
+ fs->subdirs.insert(idx2, efsd);
+ fs = efsd;
} else {
- fs=fs->get_subdir(idx);
+ fs = fs->get_subdir(idx);
}
}
+ int cpos = -1;
+ for (int i = 0; i < fs->files.size(); i++) {
- int cpos=-1;
- for(int i=0;i<fs->files.size();i++) {
-
- if (fs->files[i]->file==file) {
- cpos=i;
+ if (fs->files[i]->file == file) {
+ cpos = i;
break;
}
}
- r_file_pos=cpos;
- *r_d=fs;
+ r_file_pos = cpos;
+ *r_d = fs;
- if (cpos!=-1) {
+ if (cpos != -1) {
return true;
- } else {
+ } else {
return false;
}
-
-
}
-String EditorFileSystem::get_file_type(const String& p_file) const {
-
- EditorFileSystemDirectory *fs=NULL;
- int cpos=-1;
+String EditorFileSystem::get_file_type(const String &p_file) const {
- if (!_find_file(p_file,&fs,cpos)) {
+ EditorFileSystemDirectory *fs = NULL;
+ int cpos = -1;
- return "";
- }
+ if (!_find_file(p_file, &fs, cpos)) {
+ return "";
+ }
- return fs->files[cpos]->type;
-
+ return fs->files[cpos]->type;
}
-EditorFileSystemDirectory* EditorFileSystem::find_file(const String& p_file,int* r_index) const {
+EditorFileSystemDirectory *EditorFileSystem::find_file(const String &p_file, int *r_index) const {
if (!filesystem || scanning)
- return NULL;
+ return NULL;
- EditorFileSystemDirectory *fs=NULL;
- int cpos=-1;
- if (!_find_file(p_file,&fs,cpos)) {
+ EditorFileSystemDirectory *fs = NULL;
+ int cpos = -1;
+ if (!_find_file(p_file, &fs, cpos)) {
- return NULL;
+ return NULL;
}
-
if (r_index)
- *r_index=cpos;
+ *r_index = cpos;
return fs;
}
+EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p_path) {
-EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String& p_path) {
-
- if (!filesystem || scanning)
- return NULL;
-
-
- String f = GlobalConfig::get_singleton()->localize_path(p_path);
-
- if (!f.begins_with("res://"))
- return NULL;
+ if (!filesystem || scanning)
+ return NULL;
+ String f = GlobalConfig::get_singleton()->localize_path(p_path);
- f=f.substr(6,f.length());
- f=f.replace("\\","/");
- if (f==String())
- return filesystem;
+ if (!f.begins_with("res://"))
+ return NULL;
- if (f.ends_with("/"))
- f=f.substr(0,f.length()-1);
+ f = f.substr(6, f.length());
+ f = f.replace("\\", "/");
+ if (f == String())
+ return filesystem;
- Vector<String> path = f.split("/");
+ if (f.ends_with("/"))
+ f = f.substr(0, f.length() - 1);
- if (path.size()==0)
- return NULL;
+ Vector<String> path = f.split("/");
- EditorFileSystemDirectory *fs=filesystem;
+ if (path.size() == 0)
+ return NULL;
- for(int i=0;i<path.size();i++) {
+ EditorFileSystemDirectory *fs = filesystem;
+ for (int i = 0; i < path.size(); i++) {
- int idx=-1;
- for(int j=0;j<fs->get_subdir_count();j++) {
+ int idx = -1;
+ for (int j = 0; j < fs->get_subdir_count(); j++) {
- if (fs->get_subdir(j)->get_name()==path[i]) {
- idx=j;
- break;
- }
- }
+ if (fs->get_subdir(j)->get_name() == path[i]) {
+ idx = j;
+ break;
+ }
+ }
- if (idx==-1) {
- return NULL;
- } else {
+ if (idx == -1) {
+ return NULL;
+ } else {
- fs=fs->get_subdir(idx);
+ fs = fs->get_subdir(idx);
+ }
}
- }
- return fs;
+ return fs;
}
-void EditorFileSystem::_resource_saved(const String& p_path){
-
+void EditorFileSystem::_resource_saved(const String &p_path) {
//print_line("resource saved: "+p_path);
EditorFileSystem::get_singleton()->update_file(p_path);
-
}
+void EditorFileSystem::update_file(const String &p_file) {
+ EditorFileSystemDirectory *fs = NULL;
+ int cpos = -1;
+ if (!_find_file(p_file, &fs, cpos)) {
-void EditorFileSystem::update_file(const String& p_file) {
-
- EditorFileSystemDirectory *fs=NULL;
- int cpos=-1;
-
- if (!_find_file(p_file,&fs,cpos)) {
+ if (!fs)
+ return;
+ }
- if (!fs)
+ if (!FileAccess::exists(p_file)) {
+ //was removed
+ memdelete(fs->files[cpos]);
+ fs->files.remove(cpos);
+ call_deferred("emit_signal", "filesystem_changed"); //update later
return;
- }
-
- if (!FileAccess::exists(p_file)) {
- //was removed
- memdelete( fs->files[cpos] );
- fs->files.remove(cpos);
- call_deferred("emit_signal","filesystem_changed"); //update later
- return;
-
- }
-
- String type = ResourceLoader::get_resource_type(p_file);
-
- if (cpos==-1) {
+ }
- int idx=0;
+ String type = ResourceLoader::get_resource_type(p_file);
- for(int i=0;i<fs->files.size();i++) {
- if (p_file<fs->files[i]->file)
- break;
- idx++;
- }
+ if (cpos == -1) {
- EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo );
- fi->file=p_file.get_file();
- fi->import_modified_time=0;
+ int idx = 0;
- if (idx==fs->files.size()) {
- fs->files.push_back(fi);
- } else {
+ for (int i = 0; i < fs->files.size(); i++) {
+ if (p_file < fs->files[i]->file)
+ break;
+ idx++;
+ }
- fs->files.insert(idx,fi);
- }
- cpos=idx;
+ EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo);
+ fi->file = p_file.get_file();
+ fi->import_modified_time = 0;
+ if (idx == fs->files.size()) {
+ fs->files.push_back(fi);
+ } else {
- }
+ fs->files.insert(idx, fi);
+ }
+ cpos = idx;
+ }
//print_line("UPDATING: "+p_file);
- fs->files[cpos]->type=type;
- fs->files[cpos]->modified_time=FileAccess::get_modified_time(p_file);
+ fs->files[cpos]->type = type;
+ fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file);
//if (FileAccess::exists(p_file+".import")) {
// fs->files[cpos]->import_modified_time=FileAccess::get_modified_time(p_file+".import");
//}
- EditorResourcePreview::get_singleton()->call_deferred("check_for_invalidation",p_file);
- call_deferred("emit_signal","filesystem_changed"); //update later
-
+ EditorResourcePreview::get_singleton()->call_deferred("check_for_invalidation", p_file);
+ call_deferred("emit_signal", "filesystem_changed"); //update later
}
+void EditorFileSystem::_reimport_file(const String &p_file) {
-void EditorFileSystem::_reimport_file(const String& p_file) {
-
- print_line("REIMPORTING: "+p_file);
+ print_line("REIMPORTING: " + p_file);
- EditorFileSystemDirectory *fs=NULL;
- int cpos=-1;
- bool found = _find_file(p_file,&fs,cpos);
+ EditorFileSystemDirectory *fs = NULL;
+ int cpos = -1;
+ bool found = _find_file(p_file, &fs, cpos);
ERR_FAIL_COND(!found);
//try to obtain existing params
- Map<StringName,Variant> params;
+ Map<StringName, Variant> params;
String importer_name;
- if (FileAccess::exists(p_file+".import")) {
+ if (FileAccess::exists(p_file + ".import")) {
Ref<ConfigFile> cf;
cf.instance();
- Error err = cf->load(p_file+".import");
- if (err==OK) {
+ Error err = cf->load(p_file + ".import");
+ if (err == OK) {
List<String> sk;
- cf->get_section_keys("params",&sk);
- for(List<String>::Element *E=sk.front();E;E=E->next()) {
- params[E->get()]=cf->get_value("params",E->get());
+ cf->get_section_keys("params", &sk);
+ for (List<String>::Element *E = sk.front(); E; E = E->next()) {
+ params[E->get()] = cf->get_value("params", E->get());
}
- importer_name = cf->get_value("remap","importer");
+ importer_name = cf->get_value("remap", "importer");
}
}
Ref<ResourceImporter> importer;
//find the importer
- if (importer_name!="") {
+ if (importer_name != "") {
importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name);
}
@@ -1354,7 +1260,6 @@ void EditorFileSystem::_reimport_file(const String& p_file) {
if (importer.is_null()) {
ERR_PRINT("BUG: File queued for import, but can't be imported!");
ERR_FAIL();
-
}
}
@@ -1362,9 +1267,9 @@ void EditorFileSystem::_reimport_file(const String& p_file) {
List<ResourceImporter::ImportOption> opts;
importer->get_import_options(&opts);
- for (List<ResourceImporter::ImportOption>::Element *E=opts.front();E;E=E->next()) {
+ for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) {
if (!params.has(E->get().option.name)) { //this one is not present
- params[E->get().option.name]=E->get().default_value;
+ params[E->get().option.name] = E->get().default_value;
}
}
@@ -1374,72 +1279,65 @@ void EditorFileSystem::_reimport_file(const String& p_file) {
List<String> import_variants;
List<String> gen_files;
- Error err = importer->import(p_file,base_path,params,&import_variants,&gen_files);
+ Error err = importer->import(p_file, base_path, params, &import_variants, &gen_files);
- if (err!=OK) {
- ERR_PRINTS("Error importing: "+p_file);
+ if (err != OK) {
+ ERR_PRINTS("Error importing: " + p_file);
}
//as import is complete, save the .import file
- FileAccess *f = FileAccess::open(p_file+".import",FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(p_file + ".import", FileAccess::WRITE);
ERR_FAIL_COND(!f);
//write manually, as order matters ([remap] has to go first for performance).
f->store_line("[remap]");
f->store_line("");
- f->store_line("importer=\""+importer->get_importer_name()+"\"");
- if (importer->get_resource_type()!="") {
- f->store_line("type=\""+importer->get_resource_type()+"\"");
+ f->store_line("importer=\"" + importer->get_importer_name() + "\"");
+ if (importer->get_resource_type() != "") {
+ f->store_line("type=\"" + importer->get_resource_type() + "\"");
}
-
- if (importer->get_save_extension()=="") {
+ if (importer->get_save_extension() == "") {
//no path
} else if (import_variants.size()) {
//import with variants
- for(List<String>::Element *E=import_variants.front();E;E=E->next()) {
-
-
- String path = base_path.c_escape()+"."+E->get()+"."+importer->get_save_extension();
+ for (List<String>::Element *E = import_variants.front(); E; E = E->next()) {
- f->store_line("path."+E->get()+"=\""+path+"\"");
+ String path = base_path.c_escape() + "." + E->get() + "." + importer->get_save_extension();
+ f->store_line("path." + E->get() + "=\"" + path + "\"");
}
} else {
- f->store_line("path=\""+base_path+"."+importer->get_save_extension()+"\"");
+ f->store_line("path=\"" + base_path + "." + importer->get_save_extension() + "\"");
}
f->store_line("");
if (gen_files.size()) {
f->store_line("[gen]");
Array genf;
- for (List<String>::Element *E=gen_files.front();E;E=E->next()) {
+ for (List<String>::Element *E = gen_files.front(); E; E = E->next()) {
genf.push_back(E->get());
}
String value;
- VariantWriter::write_to_string(genf,value);
- f->store_line("files="+value);
+ VariantWriter::write_to_string(genf, value);
+ f->store_line("files=" + value);
f->store_line("");
}
-
f->store_line("[params]");
f->store_line("");
//store options in provided order, to avoid file changing
-
- for (List<ResourceImporter::ImportOption>::Element *E=opts.front();E;E=E->next()) {
+ for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) {
String base = E->get().option.name;
String value;
- VariantWriter::write_to_string(params[base],value);
- f->store_line(base+"="+value);
-
-
+ VariantWriter::write_to_string(params[base], value);
+ f->store_line(base + "=" + value);
}
f->close();
@@ -1447,7 +1345,7 @@ void EditorFileSystem::_reimport_file(const String& p_file) {
//update modified times, to avoid reimport
fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file);
- fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file+".import");
+ fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file + ".import");
//if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it
//to reload properly
@@ -1455,7 +1353,7 @@ void EditorFileSystem::_reimport_file(const String& p_file) {
Resource *r = ResourceCache::get(p_file);
- if (r->get_import_path()!=String()) {
+ if (r->get_import_path() != String()) {
String dst_path = ResourceFormatImporter::get_singleton()->get_internal_resource_path(p_file);
r->set_import_path(dst_path);
@@ -1464,18 +1362,18 @@ void EditorFileSystem::_reimport_file(const String& p_file) {
}
}
-void EditorFileSystem::reimport_files(const Vector<String>& p_files) {
+void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
- importing=true;
- EditorProgress pr("reimport",TTR("(Re)Importing Assets"),p_files.size());
- for(int i=0;i<p_files.size();i++) {
- pr.step(p_files[i].get_file(),i);
+ importing = true;
+ EditorProgress pr("reimport", TTR("(Re)Importing Assets"), p_files.size());
+ for (int i = 0; i < p_files.size(); i++) {
+ pr.step(p_files[i].get_file(), i);
_reimport_file(p_files[i]);
}
_save_filesystem_cache();
- importing=false;
+ importing = false;
if (!is_scanning()) {
emit_signal("filesystem_changed");
}
@@ -1483,19 +1381,17 @@ void EditorFileSystem::reimport_files(const Vector<String>& p_files) {
void EditorFileSystem::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("get_filesystem:EditorFileSystemDirectory"),&EditorFileSystem::get_filesystem);
- ClassDB::bind_method(D_METHOD("is_scanning"),&EditorFileSystem::is_scanning);
- ClassDB::bind_method(D_METHOD("get_scanning_progress"),&EditorFileSystem::get_scanning_progress);
- ClassDB::bind_method(D_METHOD("scan"),&EditorFileSystem::scan);
- ClassDB::bind_method(D_METHOD("scan_sources"),&EditorFileSystem::scan_changes);
- ClassDB::bind_method(D_METHOD("update_file","path"),&EditorFileSystem::update_file);
- ClassDB::bind_method(D_METHOD("get_filesystem_path:EditorFileSystemDirectory","path"),&EditorFileSystem::get_filesystem_path);
- ClassDB::bind_method(D_METHOD("get_file_type","path"),&EditorFileSystem::get_file_type);
-
- ADD_SIGNAL( MethodInfo("filesystem_changed") );
- ADD_SIGNAL( MethodInfo("sources_changed",PropertyInfo(Variant::BOOL,"exist")) );
-
+ ClassDB::bind_method(D_METHOD("get_filesystem:EditorFileSystemDirectory"), &EditorFileSystem::get_filesystem);
+ ClassDB::bind_method(D_METHOD("is_scanning"), &EditorFileSystem::is_scanning);
+ ClassDB::bind_method(D_METHOD("get_scanning_progress"), &EditorFileSystem::get_scanning_progress);
+ ClassDB::bind_method(D_METHOD("scan"), &EditorFileSystem::scan);
+ ClassDB::bind_method(D_METHOD("scan_sources"), &EditorFileSystem::scan_changes);
+ ClassDB::bind_method(D_METHOD("update_file", "path"), &EditorFileSystem::update_file);
+ ClassDB::bind_method(D_METHOD("get_filesystem_path:EditorFileSystemDirectory", "path"), &EditorFileSystem::get_filesystem_path);
+ ClassDB::bind_method(D_METHOD("get_file_type", "path"), &EditorFileSystem::get_file_type);
+
+ ADD_SIGNAL(MethodInfo("filesystem_changed"));
+ ADD_SIGNAL(MethodInfo("sources_changed", PropertyInfo(Variant::BOOL, "exist")));
}
void EditorFileSystem::_update_extensions() {
@@ -1504,15 +1400,15 @@ void EditorFileSystem::_update_extensions() {
import_extensions.clear();
List<String> extensionsl;
- ResourceLoader::get_recognized_extensions_for_type("",&extensionsl);
- for(List<String>::Element *E = extensionsl.front();E;E=E->next()) {
+ ResourceLoader::get_recognized_extensions_for_type("", &extensionsl);
+ for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) {
valid_extensions.insert(E->get());
}
extensionsl.clear();
ResourceFormatImporter::get_singleton()->get_recognized_extensions(&extensionsl);
- for(List<String>::Element *E = extensionsl.front();E;E=E->next()) {
+ for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) {
import_extensions.insert(E->get());
}
@@ -1520,31 +1416,29 @@ void EditorFileSystem::_update_extensions() {
EditorFileSystem::EditorFileSystem() {
- reimport_on_missing_imported_files = GLOBAL_DEF("editor/reimport_missing_imported_files",true);
+ reimport_on_missing_imported_files = GLOBAL_DEF("editor/reimport_missing_imported_files", true);
- singleton=this;
- filesystem=memnew( EditorFileSystemDirectory ); //like, empty
+ singleton = this;
+ filesystem = memnew(EditorFileSystemDirectory); //like, empty
thread = NULL;
- scanning=false;
- importing=false;
- use_threads=true;
- thread_sources=NULL;
- new_filesystem=NULL;
+ scanning = false;
+ importing = false;
+ use_threads = true;
+ thread_sources = NULL;
+ new_filesystem = NULL;
- scanning_changes=false;
+ scanning_changes = false;
ResourceSaver::set_save_callback(_resource_saved);
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- if (da->change_dir("res://.import")!=OK) {
+ if (da->change_dir("res://.import") != OK) {
da->make_dir("res://.import");
}
memdelete(da);
- scan_total=0;
+ scan_total = 0;
}
EditorFileSystem::~EditorFileSystem() {
-
-
}
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index 10d9b919fc..da78ba9cfb 100644
--- a/editor/editor_file_system.h
+++ b/editor/editor_file_system.h
@@ -29,25 +29,24 @@
#ifndef EDITOR_FILE_SYSTEM_H
#define EDITOR_FILE_SYSTEM_H
-#include "scene/main/node.h"
-#include "os/thread.h"
#include "os/dir_access.h"
-#include "set.h"
+#include "os/thread.h"
#include "os/thread_safe.h"
+#include "scene/main/node.h"
+#include "set.h"
class FileAccess;
struct EditorProgressBG;
class EditorFileSystemDirectory : public Object {
- GDCLASS( EditorFileSystemDirectory,Object );
+ GDCLASS(EditorFileSystemDirectory, Object);
String name;
uint64_t modified_time;
bool verified; //used for checking changes
EditorFileSystemDirectory *parent;
- Vector<EditorFileSystemDirectory*> subdirs;
-
+ Vector<EditorFileSystemDirectory *> subdirs;
struct FileInfo {
String file;
@@ -56,25 +55,23 @@ class EditorFileSystemDirectory : public Object {
uint64_t import_modified_time;
Vector<String> deps;
bool verified; //used for checking changes
-
};
struct FileInfoSort {
- bool operator()(const FileInfo *p_a,const FileInfo *p_b) const {
- return p_a->file<p_b->file;
+ bool operator()(const FileInfo *p_a, const FileInfo *p_b) const {
+ return p_a->file < p_b->file;
}
};
void sort_files();
- Vector<FileInfo*> files;
+ Vector<FileInfo *> files;
static void _bind_methods();
+ friend class EditorFileSystem;
-friend class EditorFileSystem;
public:
-
String get_name();
String get_path() const;
@@ -88,9 +85,8 @@ public:
EditorFileSystemDirectory *get_parent();
- int find_file_index(const String& p_file) const;
- int find_dir_index(const String& p_dir) const;
-
+ int find_file_index(const String &p_file) const;
+ int find_dir_index(const String &p_dir) const;
EditorFileSystemDirectory();
~EditorFileSystemDirectory();
@@ -98,12 +94,10 @@ public:
class EditorFileSystem : public Node {
- GDCLASS( EditorFileSystem, Node );
+ GDCLASS(EditorFileSystem, Node);
_THREAD_SAFE_CLASS_
-
-
struct ItemAction {
enum Action {
@@ -121,8 +115,12 @@ class EditorFileSystem : public Node {
EditorFileSystemDirectory *new_dir;
EditorFileSystemDirectory::FileInfo *new_file;
- ItemAction() { action=ACTION_NONE; dir=NULL; new_dir=NULL; new_file=NULL; }
-
+ ItemAction() {
+ action = ACTION_NONE;
+ dir = NULL;
+ new_dir = NULL;
+ new_file = NULL;
+ }
};
bool use_threads;
@@ -136,7 +134,6 @@ class EditorFileSystem : public Node {
bool importing;
float scan_total;
-
void _scan_filesystem();
EditorFileSystemDirectory *filesystem;
@@ -152,32 +149,30 @@ class EditorFileSystem : public Node {
Vector<String> deps;
};
- HashMap<String,FileCache> file_cache;
+ HashMap<String, FileCache> file_cache;
struct ScanProgress {
float low;
float hi;
mutable EditorProgressBG *progress;
- void update(int p_current,int p_total) const;
- ScanProgress get_sub(int p_current,int p_total) const;
+ void update(int p_current, int p_total) const;
+ ScanProgress get_sub(int p_current, int p_total) const;
};
-
void _save_filesystem_cache();
- void _save_filesystem_cache(EditorFileSystemDirectory *p_dir,FileAccess *p_file);
+ void _save_filesystem_cache(EditorFileSystemDirectory *p_dir, FileAccess *p_file);
- bool _find_file(const String& p_file,EditorFileSystemDirectory ** r_d, int &r_file_pos) const;
+ bool _find_file(const String &p_file, EditorFileSystemDirectory **r_d, int &r_file_pos) const;
void _scan_fs_changes(EditorFileSystemDirectory *p_dir, const ScanProgress &p_progress);
-
int md_count;
Set<String> valid_extensions;
Set<String> import_extensions;
- void _scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess *da,const ScanProgress& p_progress);
+ void _scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess *da, const ScanProgress &p_progress);
Thread *thread_sources;
bool scanning_changes;
@@ -190,24 +185,22 @@ class EditorFileSystem : public Node {
bool _update_scan_actions();
- static void _resource_saved(const String& p_path);
+ static void _resource_saved(const String &p_path);
void _update_extensions();
void _reimport_file(const String &p_file);
- bool _check_missing_imported_files(const String& p_path);
+ bool _check_missing_imported_files(const String &p_path);
bool reimport_on_missing_imported_files;
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
-
- static EditorFileSystem* get_singleton() { return singleton; }
+public:
+ static EditorFileSystem *get_singleton() { return singleton; }
EditorFileSystemDirectory *get_filesystem();
bool is_scanning() const;
@@ -216,13 +209,13 @@ public:
void scan();
void scan_changes();
void get_changed_sources(List<String> *r_changed);
- void update_file(const String& p_file);
+ void update_file(const String &p_file);
- EditorFileSystemDirectory *get_filesystem_path(const String& p_path);
- String get_file_type(const String& p_file) const;
- EditorFileSystemDirectory* find_file(const String& p_file,int* r_index) const;
+ EditorFileSystemDirectory *get_filesystem_path(const String &p_path);
+ String get_file_type(const String &p_file) const;
+ EditorFileSystemDirectory *find_file(const String &p_file, int *r_index) const;
- void reimport_files(const Vector<String>& p_files);
+ void reimport_files(const Vector<String> &p_files);
EditorFileSystem();
~EditorFileSystem();
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index 3652a59978..8bfacb4a26 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -28,103 +28,97 @@
/*************************************************************************/
#include "editor_fonts.h"
+#include "builtin_fonts.h"
+#include "doc_code_font.h"
#include "doc_font.h"
#include "doc_title_font.h"
-#include "doc_code_font.h"
-#include "builtin_fonts.h"
-#include "editor_settings.h"
-#include "scene/resources/dynamic_font.h"
#include "editor_scale.h"
+#include "editor_settings.h"
#include "scene/resources/default_theme/default_theme.h"
+#include "scene/resources/dynamic_font.h"
-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;
}
-#define MAKE_FALLBACKS(m_name)\
- m_name->add_fallback(DroidSansFallback);\
- m_name->add_fallback(DroidSansJapanese);\
- m_name->add_fallback(DroidSansArabic);\
- m_name->add_fallback(DroidSansHebrew);\
+#define MAKE_FALLBACKS(m_name) \
+ m_name->add_fallback(DroidSansFallback); \
+ m_name->add_fallback(DroidSansJapanese); \
+ m_name->add_fallback(DroidSansArabic); \
+ m_name->add_fallback(DroidSansHebrew); \
m_name->add_fallback(DroidSansThai);
-#define MAKE_DROID_SANS(m_name,m_size) \
- Ref<DynamicFont> m_name;\
- m_name.instance();\
- m_name->set_size(m_size);\
- m_name->set_font_data(DroidSans);\
+#define MAKE_DROID_SANS(m_name, m_size) \
+ Ref<DynamicFont> m_name; \
+ m_name.instance(); \
+ m_name->set_size(m_size); \
+ m_name->set_font_data(DroidSans); \
MAKE_FALLBACKS(m_name);
-
void editor_register_fonts(Ref<Theme> p_theme) {
/* Droid Sans */
Ref<DynamicFontData> DroidSans;
DroidSans.instance();
- DroidSans->set_font_ptr(_font_DroidSans,_font_DroidSans_size);
+ DroidSans->set_font_ptr(_font_DroidSans, _font_DroidSans_size);
DroidSans->set_force_autohinter(true); //just looks better..i think?
Ref<DynamicFontData> DroidSansFallback;
DroidSansFallback.instance();
- DroidSansFallback->set_font_ptr(_font_DroidSansFallback,_font_DroidSansFallback_size);
+ DroidSansFallback->set_font_ptr(_font_DroidSansFallback, _font_DroidSansFallback_size);
DroidSansFallback->set_force_autohinter(true); //just looks better..i think?
Ref<DynamicFontData> DroidSansJapanese;
DroidSansJapanese.instance();
- DroidSansJapanese->set_font_ptr(_font_DroidSansJapanese,_font_DroidSansJapanese_size);
+ DroidSansJapanese->set_font_ptr(_font_DroidSansJapanese, _font_DroidSansJapanese_size);
DroidSansJapanese->set_force_autohinter(true); //just looks better..i think?
Ref<DynamicFontData> DroidSansArabic;
DroidSansArabic.instance();
- DroidSansArabic->set_font_ptr(_font_DroidSansArabic,_font_DroidSansArabic_size);
+ DroidSansArabic->set_font_ptr(_font_DroidSansArabic, _font_DroidSansArabic_size);
DroidSansArabic->set_force_autohinter(true); //just looks better..i think?
Ref<DynamicFontData> DroidSansHebrew;
DroidSansHebrew.instance();
- DroidSansHebrew->set_font_ptr(_font_DroidSansHebrew,_font_DroidSansHebrew_size);
+ DroidSansHebrew->set_font_ptr(_font_DroidSansHebrew, _font_DroidSansHebrew_size);
DroidSansHebrew->set_force_autohinter(true); //just looks better..i think?
Ref<DynamicFontData> DroidSansThai;
DroidSansThai.instance();
- DroidSansThai->set_font_ptr(_font_DroidSansThai,_font_DroidSansThai_size);
+ DroidSansThai->set_font_ptr(_font_DroidSansThai, _font_DroidSansThai_size);
DroidSansThai->set_force_autohinter(true); //just looks better..i think?
/* Source Code Pro */
-
Ref<DynamicFontData> dfmono;
dfmono.instance();
- dfmono->set_font_ptr(_font_source_code_pro,_font_source_code_pro_size);
+ dfmono->set_font_ptr(_font_source_code_pro, _font_source_code_pro_size);
//dfd->set_force_autohinter(true); //just looks better..i think?
- MAKE_DROID_SANS(df,int(EditorSettings::get_singleton()->get("interface/font_size"))*EDSCALE);
-
+ MAKE_DROID_SANS(df, int(EditorSettings::get_singleton()->get("interface/font_size")) * EDSCALE);
p_theme->set_default_theme_font(df);
@@ -132,37 +126,31 @@ void editor_register_fonts(Ref<Theme> p_theme) {
//Ref<BitmapFont> doc_title_font = make_font(_bi_font_doc_title_font_height,_bi_font_doc_title_font_ascent,0,_bi_font_doc_title_font_charcount,_bi_font_doc_title_font_characters,p_theme->get_icon("DocTitleFont","EditorIcons"));
//Ref<BitmapFont> doc_code_font = make_font(_bi_font_doc_code_font_height,_bi_font_doc_code_font_ascent,0,_bi_font_doc_code_font_charcount,_bi_font_doc_code_font_characters,p_theme->get_icon("DocCodeFont","EditorIcons"));
- MAKE_DROID_SANS(df_title,int(EDITOR_DEF("text_editor/help/help_title_font_size",18))*EDSCALE);
-
- MAKE_DROID_SANS(df_doc,int(EDITOR_DEF("text_editor/help/help_font_size",16))*EDSCALE);
+ MAKE_DROID_SANS(df_title, int(EDITOR_DEF("text_editor/help/help_title_font_size", 18)) * EDSCALE);
+ MAKE_DROID_SANS(df_doc, int(EDITOR_DEF("text_editor/help/help_font_size", 16)) * EDSCALE);
- p_theme->set_font("doc","EditorFonts",df_doc);
- p_theme->set_font("doc_title","EditorFonts",df_title);
-
+ p_theme->set_font("doc", "EditorFonts", df_doc);
+ p_theme->set_font("doc_title", "EditorFonts", df_title);
Ref<DynamicFont> df_code;
df_code.instance();
- df_code->set_size(int(EditorSettings::get_singleton()->get("interface/source_font_size"))*EDSCALE);
+ df_code->set_size(int(EditorSettings::get_singleton()->get("interface/source_font_size")) * EDSCALE);
df_code->set_font_data(dfmono);
MAKE_FALLBACKS(df_code);
- p_theme->set_font("source","EditorFonts",df_code);
+ p_theme->set_font("source", "EditorFonts", df_code);
Ref<DynamicFont> df_doc_code;
df_doc_code.instance();
- df_doc_code->set_size(int(EDITOR_DEF("text_editor/help/help_source_font_size",14))*EDSCALE);
+ df_doc_code->set_size(int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE);
df_doc_code->set_font_data(dfmono);
MAKE_FALLBACKS(df_doc_code);
-
- p_theme->set_font("doc_source","EditorFonts",df_doc_code);
-
+ p_theme->set_font("doc_source", "EditorFonts", df_doc_code);
//replace default theme
Ref<Texture> di;
Ref<StyleBox> ds;
- fill_default_theme(p_theme,df,df_doc,di,ds,EDSCALE);
-
-
+ fill_default_theme(p_theme, df, df_doc, di, ds, EDSCALE);
}
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 7ef7658132..161326ebab 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -28,25 +28,25 @@
/*************************************************************************/
#include "editor_help.h"
+#include "doc_data_compressed.h"
+#include "editor/plugins/script_editor_plugin.h"
#include "editor_node.h"
#include "editor_settings.h"
#include "os/keyboard.h"
-#include "doc_data_compressed.h"
-#include "editor/plugins/script_editor_plugin.h"
void EditorHelpSearch::popup() {
popup_centered_ratio(0.6);
- if (search_box->get_text()!="") {
+ if (search_box->get_text() != "") {
search_box->select_all();
_update_search();
}
search_box->grab_focus();
}
-void EditorHelpSearch::popup(const String& p_term) {
+void EditorHelpSearch::popup(const String &p_term) {
popup_centered_ratio(0.6);
- if (p_term!="") {
+ if (p_term != "") {
search_box->set_text(p_term);
search_box->select_all();
_update_search();
@@ -55,24 +55,21 @@ void EditorHelpSearch::popup(const String& p_term) {
search_box->grab_focus();
}
-
-void EditorHelpSearch::_text_changed(const String& p_newtext) {
+void EditorHelpSearch::_text_changed(const String &p_newtext) {
_update_search();
}
-void EditorHelpSearch::_sbox_input(const InputEvent& p_ie) {
+void EditorHelpSearch::_sbox_input(const InputEvent &p_ie) {
- if (p_ie.type==InputEvent::KEY && (
- p_ie.key.scancode == KEY_UP ||
- p_ie.key.scancode == KEY_DOWN ||
- p_ie.key.scancode == KEY_PAGEUP ||
- p_ie.key.scancode == KEY_PAGEDOWN ) ) {
+ if (p_ie.type == InputEvent::KEY && (p_ie.key.scancode == KEY_UP ||
+ p_ie.key.scancode == KEY_DOWN ||
+ p_ie.key.scancode == KEY_PAGEUP ||
+ p_ie.key.scancode == KEY_PAGEDOWN)) {
- search_options->call("_gui_input",p_ie);
+ search_options->call("_gui_input", p_ie);
search_box->accept_event();
}
-
}
void EditorHelpSearch::_update_search() {
@@ -88,178 +85,161 @@ void EditorHelpSearch::_update_search() {
List<StringName> type_list;
ClassDB::get_class_list(&type_list);
- DocData *doc=EditorHelp::get_doc_data();
+ DocData *doc = EditorHelp::get_doc_data();
String term = search_box->get_text();
- if (term.length()<2)
+ if (term.length() < 2)
return;
TreeItem *root = search_options->create_item();
-
-
- Ref<Texture> def_icon = get_icon("Node","EditorIcons");
+ Ref<Texture> def_icon = get_icon("Node", "EditorIcons");
//classes first
- for (Map<String,DocData::ClassDoc>::Element *E=doc->class_list.front();E;E=E->next()) {
+ for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
- if (E->key().findn(term)!=-1) {
+ if (E->key().findn(term) != -1) {
TreeItem *item = search_options->create_item(root);
- item->set_metadata(0,"class_name:"+E->key());
- item->set_text(0,E->key()+" (Class)");
- if (has_icon(E->key(),"EditorIcons"))
- item->set_icon(0,get_icon(E->key(),"EditorIcons"));
+ item->set_metadata(0, "class_name:" + E->key());
+ item->set_text(0, E->key() + " (Class)");
+ if (has_icon(E->key(), "EditorIcons"))
+ item->set_icon(0, get_icon(E->key(), "EditorIcons"));
else
- item->set_icon(0,def_icon);
-
-
+ item->set_icon(0, def_icon);
}
-
}
//class methods, etc second
- for (Map<String,DocData::ClassDoc>::Element *E=doc->class_list.front();E;E=E->next()) {
+ for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
-
- DocData::ClassDoc & c = E->get();
+ DocData::ClassDoc &c = E->get();
Ref<Texture> cicon;
- if (has_icon(E->key(),"EditorIcons"))
- cicon=get_icon(E->key(),"EditorIcons");
+ if (has_icon(E->key(), "EditorIcons"))
+ cicon = get_icon(E->key(), "EditorIcons");
else
- cicon=def_icon;
-
+ cicon = def_icon;
- for(int i=0;i<c.methods.size();i++) {
- if( (term.begins_with(".") && c.methods[i].name.begins_with(term.right(1)))
- || (term.ends_with("(") && c.methods[i].name.ends_with(term.left(term.length()-1).strip_edges()))
- || (term.begins_with(".") && term.ends_with("(") && c.methods[i].name==term.substr(1,term.length()-2).strip_edges())
- || c.methods[i].name.findn(term)!=-1) {
+ for (int i = 0; i < c.methods.size(); i++) {
+ if ((term.begins_with(".") && c.methods[i].name.begins_with(term.right(1))) || (term.ends_with("(") && c.methods[i].name.ends_with(term.left(term.length() - 1).strip_edges())) || (term.begins_with(".") && term.ends_with("(") && c.methods[i].name == term.substr(1, term.length() - 2).strip_edges()) || c.methods[i].name.findn(term) != -1) {
TreeItem *item = search_options->create_item(root);
- item->set_metadata(0,"class_method:"+E->key()+":"+c.methods[i].name);
- item->set_text(0,E->key()+"."+c.methods[i].name+" (Method)");
- item->set_icon(0,cicon);
+ item->set_metadata(0, "class_method:" + E->key() + ":" + c.methods[i].name);
+ item->set_text(0, E->key() + "." + c.methods[i].name + " (Method)");
+ item->set_icon(0, cicon);
}
}
- for(int i=0;i<c.signals.size();i++) {
+ for (int i = 0; i < c.signals.size(); i++) {
- if (c.signals[i].name.findn(term)!=-1) {
+ if (c.signals[i].name.findn(term) != -1) {
TreeItem *item = search_options->create_item(root);
- item->set_metadata(0,"class_signal:"+E->key()+":"+c.signals[i].name);
- item->set_text(0,E->key()+"."+c.signals[i].name+" (Signal)");
- item->set_icon(0,cicon);
+ item->set_metadata(0, "class_signal:" + E->key() + ":" + c.signals[i].name);
+ item->set_text(0, E->key() + "." + c.signals[i].name + " (Signal)");
+ item->set_icon(0, cicon);
}
}
- for(int i=0;i<c.constants.size();i++) {
+ for (int i = 0; i < c.constants.size(); i++) {
- if (c.constants[i].name.findn(term)!=-1) {
+ if (c.constants[i].name.findn(term) != -1) {
TreeItem *item = search_options->create_item(root);
- item->set_metadata(0,"class_constant:"+E->key()+":"+c.constants[i].name);
- item->set_text(0,E->key()+"."+c.constants[i].name+" (Constant)");
- item->set_icon(0,cicon);
+ item->set_metadata(0, "class_constant:" + E->key() + ":" + c.constants[i].name);
+ item->set_text(0, E->key() + "." + c.constants[i].name + " (Constant)");
+ item->set_icon(0, cicon);
}
}
- for(int i=0;i<c.properties.size();i++) {
+ for (int i = 0; i < c.properties.size(); i++) {
- if (c.properties[i].name.findn(term)!=-1) {
+ if (c.properties[i].name.findn(term) != -1) {
TreeItem *item = search_options->create_item(root);
- item->set_metadata(0,"class_property:"+E->key()+":"+c.properties[i].name);
- item->set_text(0,E->key()+"."+c.properties[i].name+" (Property)");
- item->set_icon(0,cicon);
+ item->set_metadata(0, "class_property:" + E->key() + ":" + c.properties[i].name);
+ item->set_text(0, E->key() + "." + c.properties[i].name + " (Property)");
+ item->set_icon(0, cicon);
}
}
- for(int i=0;i<c.theme_properties.size();i++) {
+ for (int i = 0; i < c.theme_properties.size(); i++) {
- if (c.theme_properties[i].name.findn(term)!=-1) {
+ if (c.theme_properties[i].name.findn(term) != -1) {
TreeItem *item = search_options->create_item(root);
- item->set_metadata(0,"class_theme_item:"+E->key()+":"+c.theme_properties[i].name);
- item->set_text(0,E->key()+"."+c.theme_properties[i].name+" (Theme Item)");
- item->set_icon(0,cicon);
+ item->set_metadata(0, "class_theme_item:" + E->key() + ":" + c.theme_properties[i].name);
+ item->set_text(0, E->key() + "." + c.theme_properties[i].name + " (Theme Item)");
+ item->set_icon(0, cicon);
}
}
-
-
}
//same but descriptions
- for (Map<String,DocData::ClassDoc>::Element *E=doc->class_list.front();E;E=E->next()) {
+ for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
-
- DocData::ClassDoc & c = E->get();
+ DocData::ClassDoc &c = E->get();
Ref<Texture> cicon;
- if (has_icon(E->key(),"EditorIcons"))
- cicon=get_icon(E->key(),"EditorIcons");
+ if (has_icon(E->key(), "EditorIcons"))
+ cicon = get_icon(E->key(), "EditorIcons");
else
- cicon=def_icon;
-
- if (c.description.findn(term)!=-1) {
+ cicon = def_icon;
+ if (c.description.findn(term) != -1) {
TreeItem *item = search_options->create_item(root);
- item->set_metadata(0,"class_desc:"+E->key());
- item->set_text(0,E->key()+" (Class Description)");
- item->set_icon(0,cicon);
-
+ item->set_metadata(0, "class_desc:" + E->key());
+ item->set_text(0, E->key() + " (Class Description)");
+ item->set_icon(0, cicon);
}
- for(int i=0;i<c.methods.size();i++) {
+ for (int i = 0; i < c.methods.size(); i++) {
- if (c.methods[i].description.findn(term)!=-1) {
+ if (c.methods[i].description.findn(term) != -1) {
TreeItem *item = search_options->create_item(root);
- item->set_metadata(0,"class_method_desc:"+E->key()+":"+c.methods[i].name);
- item->set_text(0,E->key()+"."+c.methods[i].name+" (Method Description)");
- item->set_icon(0,cicon);
+ item->set_metadata(0, "class_method_desc:" + E->key() + ":" + c.methods[i].name);
+ item->set_text(0, E->key() + "." + c.methods[i].name + " (Method Description)");
+ item->set_icon(0, cicon);
}
}
- for(int i=0;i<c.signals.size();i++) {
+ for (int i = 0; i < c.signals.size(); i++) {
- if (c.signals[i].description.findn(term)!=-1) {
+ if (c.signals[i].description.findn(term) != -1) {
TreeItem *item = search_options->create_item(root);
- item->set_metadata(0,"class_signal:"+E->key()+":"+c.signals[i].name);
- item->set_text(0,E->key()+"."+c.signals[i].name+" (Signal Description)");
- item->set_icon(0,cicon);
+ item->set_metadata(0, "class_signal:" + E->key() + ":" + c.signals[i].name);
+ item->set_text(0, E->key() + "." + c.signals[i].name + " (Signal Description)");
+ item->set_icon(0, cicon);
}
}
- for(int i=0;i<c.constants.size();i++) {
+ for (int i = 0; i < c.constants.size(); i++) {
- if (c.constants[i].description.findn(term)!=-1) {
+ if (c.constants[i].description.findn(term) != -1) {
TreeItem *item = search_options->create_item(root);
- item->set_metadata(0,"class_constant:"+E->key()+":"+c.constants[i].name);
- item->set_text(0,E->key()+"."+c.constants[i].name+" (Constant Description)");
- item->set_icon(0,cicon);
+ item->set_metadata(0, "class_constant:" + E->key() + ":" + c.constants[i].name);
+ item->set_text(0, E->key() + "." + c.constants[i].name + " (Constant Description)");
+ item->set_icon(0, cicon);
}
}
- for(int i=0;i<c.properties.size();i++) {
+ for (int i = 0; i < c.properties.size(); i++) {
- if (c.properties[i].description.findn(term)!=-1) {
+ if (c.properties[i].description.findn(term) != -1) {
TreeItem *item = search_options->create_item(root);
- item->set_metadata(0,"class_property_desc:"+E->key()+":"+c.properties[i].name);
- item->set_text(0,E->key()+"."+c.properties[i].name+" (Property Description)");
- item->set_icon(0,cicon);
+ item->set_metadata(0, "class_property_desc:" + E->key() + ":" + c.properties[i].name);
+ item->set_text(0, E->key() + "." + c.properties[i].name + " (Property Description)");
+ item->set_icon(0, cicon);
}
}
-
}
- get_ok()->set_disabled(root->get_children()==NULL);
-
+ get_ok()->set_disabled(root->get_children() == NULL);
}
void EditorHelpSearch::_confirmed() {
@@ -268,22 +248,22 @@ void EditorHelpSearch::_confirmed() {
if (!ti)
return;
- String mdata=ti->get_metadata(0);
- emit_signal("go_to_help",mdata);
- editor->call("_editor_select",EditorNode::EDITOR_SCRIPT); // in case EditorHelpSearch beeen invoked on top of other editor window
+ String mdata = ti->get_metadata(0);
+ emit_signal("go_to_help", mdata);
+ editor->call("_editor_select", EditorNode::EDITOR_SCRIPT); // in case EditorHelpSearch beeen invoked on top of other editor window
// go to that
hide();
}
void EditorHelpSearch::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- connect("confirmed",this,"_confirmed");
+ connect("confirmed", this, "_confirmed");
_update_search();
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (is_visible_in_tree()) {
@@ -291,49 +271,44 @@ void EditorHelpSearch::_notification(int p_what) {
search_box->select_all();
}
}
-
}
-
void EditorHelpSearch::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_text_changed"),&EditorHelpSearch::_text_changed);
- ClassDB::bind_method(D_METHOD("_confirmed"),&EditorHelpSearch::_confirmed);
- ClassDB::bind_method(D_METHOD("_sbox_input"),&EditorHelpSearch::_sbox_input);
- ClassDB::bind_method(D_METHOD("_update_search"),&EditorHelpSearch::_update_search);
+ ClassDB::bind_method(D_METHOD("_text_changed"), &EditorHelpSearch::_text_changed);
+ ClassDB::bind_method(D_METHOD("_confirmed"), &EditorHelpSearch::_confirmed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"), &EditorHelpSearch::_sbox_input);
+ ClassDB::bind_method(D_METHOD("_update_search"), &EditorHelpSearch::_update_search);
ADD_SIGNAL(MethodInfo("go_to_help"));
-
}
-
EditorHelpSearch::EditorHelpSearch() {
- editor=EditorNode::get_singleton();
- VBoxContainer *vbc = memnew( VBoxContainer );
+ editor = EditorNode::get_singleton();
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
- HBoxContainer *sb_hb = memnew( HBoxContainer);
- search_box = memnew( LineEdit );
+ HBoxContainer *sb_hb = memnew(HBoxContainer);
+ search_box = memnew(LineEdit);
sb_hb->add_child(search_box);
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
- Button *sb = memnew( Button(TTR("Search")));
- sb->connect("pressed",this,"_update_search");
+ Button *sb = memnew(Button(TTR("Search")));
+ sb->connect("pressed", this, "_update_search");
sb_hb->add_child(sb);
- vbc->add_margin_child(TTR("Search:"),sb_hb);
- search_box->connect("text_changed",this,"_text_changed");
- search_box->connect("gui_input",this,"_sbox_input");
- search_options = memnew( Tree );
- vbc->add_margin_child(TTR("Matches:"),search_options,true);
+ vbc->add_margin_child(TTR("Search:"), sb_hb);
+ search_box->connect("text_changed", this, "_text_changed");
+ search_box->connect("gui_input", this, "_sbox_input");
+ search_options = memnew(Tree);
+ vbc->add_margin_child(TTR("Matches:"), search_options, true);
get_ok()->set_text(TTR("Open"));
get_ok()->set_disabled(true);
register_text_enter(search_box);
set_hide_on_ok(false);
- search_options->connect("item_activated",this,"_confirmed");
+ search_options->connect("item_activated", this, "_confirmed");
set_title(TTR("Search Help"));
//search_options->set_hide_root(true);
-
}
/////////////////////////////////
@@ -341,9 +316,7 @@ EditorHelpSearch::EditorHelpSearch() {
////////////////////////////////////
/// /////////////////////////////////
-
-
-void EditorHelpIndex::add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root) {
+void EditorHelpIndex::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root) {
if (p_types.has(p_type))
return;
@@ -352,53 +325,48 @@ void EditorHelpIndex::add_type(const String& p_type,HashMap<String,TreeItem*>& p
return;
*/
- String inherits=EditorHelp::get_doc_data()->class_list[p_type].inherits;
-
- TreeItem *parent=p_root;
+ String inherits = EditorHelp::get_doc_data()->class_list[p_type].inherits;
+ TreeItem *parent = p_root;
if (inherits.length()) {
if (!p_types.has(inherits)) {
- add_type(inherits,p_types,p_root);
+ add_type(inherits, p_types, p_root);
}
- if (p_types.has(inherits) )
- parent=p_types[inherits];
+ if (p_types.has(inherits))
+ parent = p_types[inherits];
}
TreeItem *item = class_list->create_item(parent);
- item->set_metadata(0,p_type);
- item->set_tooltip(0,EditorHelp::get_doc_data()->class_list[p_type].brief_description);
- item->set_text(0,p_type);
-
+ item->set_metadata(0, p_type);
+ item->set_tooltip(0, EditorHelp::get_doc_data()->class_list[p_type].brief_description);
+ item->set_text(0, p_type);
- if (has_icon(p_type,"EditorIcons")) {
+ if (has_icon(p_type, "EditorIcons")) {
- item->set_icon(0, get_icon(p_type,"EditorIcons"));
+ item->set_icon(0, get_icon(p_type, "EditorIcons"));
}
- p_types[p_type]=item;
+ p_types[p_type] = item;
}
-
void EditorHelpIndex::_tree_item_selected() {
-
- TreeItem *s=class_list->get_selected();
+ TreeItem *s = class_list->get_selected();
if (!s)
return;
- emit_signal("open_class",s->get_text(0));
+ emit_signal("open_class", s->get_text(0));
hide();
//_goto_desc(s->get_text(0));
-
}
-void EditorHelpIndex::select_class(const String& p_class) {
+void EditorHelpIndex::select_class(const String &p_class) {
if (!tree_item_map.has(p_class))
return;
@@ -416,19 +384,19 @@ void EditorHelpIndex::popup() {
void EditorHelpIndex::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
_update_class_list();
- connect("confirmed",this,"_tree_item_selected");
+ connect("confirmed", this, "_tree_item_selected");
- } else if (p_what==NOTIFICATION_POST_POPUP) {
+ } else if (p_what == NOTIFICATION_POST_POPUP) {
search_box->call_deferred("grab_focus");
}
}
-void EditorHelpIndex::_text_changed(const String& p_text) {
+void EditorHelpIndex::_text_changed(const String &p_text) {
_update_class_list();
}
@@ -443,23 +411,23 @@ void EditorHelpIndex::_update_class_list() {
String filter = search_box->get_text().strip_edges();
String to_select = "";
- for(Map<String,DocData::ClassDoc>::Element *E=EditorHelp::get_doc_data()->class_list.front();E;E=E->next()) {
+ for (Map<String, DocData::ClassDoc>::Element *E = EditorHelp::get_doc_data()->class_list.front(); E; E = E->next()) {
if (filter == "") {
- add_type(E->key(),tree_item_map,root);
+ add_type(E->key(), tree_item_map, root);
} else {
bool found = false;
String type = E->key();
- while(type != "") {
+ while (type != "") {
if (filter.is_subsequence_ofi(type)) {
if (to_select.empty()) {
to_select = type;
}
- found=true;
+ found = true;
break;
}
@@ -467,7 +435,7 @@ void EditorHelpIndex::_update_class_list() {
}
if (found) {
- add_type(E->key(),tree_item_map,root);
+ add_type(E->key(), tree_item_map, root);
}
}
}
@@ -479,37 +447,33 @@ void EditorHelpIndex::_update_class_list() {
}
}
+void EditorHelpIndex::_sbox_input(const InputEvent &p_ie) {
-void EditorHelpIndex::_sbox_input(const InputEvent& p_ie) {
+ if (p_ie.type == InputEvent::KEY && (p_ie.key.scancode == KEY_UP ||
+ p_ie.key.scancode == KEY_DOWN ||
+ p_ie.key.scancode == KEY_PAGEUP ||
+ p_ie.key.scancode == KEY_PAGEDOWN)) {
- if (p_ie.type==InputEvent::KEY && (
- p_ie.key.scancode == KEY_UP ||
- p_ie.key.scancode == KEY_DOWN ||
- p_ie.key.scancode == KEY_PAGEUP ||
- p_ie.key.scancode == KEY_PAGEDOWN ) ) {
-
- class_list->call("_gui_input",p_ie);
+ class_list->call("_gui_input", p_ie);
search_box->accept_event();
}
}
void EditorHelpIndex::_bind_methods() {
- ClassDB::bind_method("_tree_item_selected",&EditorHelpIndex::_tree_item_selected);
- ClassDB::bind_method("_text_changed",&EditorHelpIndex::_text_changed);
- ClassDB::bind_method("_sbox_input",&EditorHelpIndex::_sbox_input);
- ClassDB::bind_method("select_class",&EditorHelpIndex::select_class);
- ADD_SIGNAL( MethodInfo("open_class"));
+ ClassDB::bind_method("_tree_item_selected", &EditorHelpIndex::_tree_item_selected);
+ ClassDB::bind_method("_text_changed", &EditorHelpIndex::_text_changed);
+ ClassDB::bind_method("_sbox_input", &EditorHelpIndex::_sbox_input);
+ ClassDB::bind_method("select_class", &EditorHelpIndex::select_class);
+ ADD_SIGNAL(MethodInfo("open_class"));
}
-
-
EditorHelpIndex::EditorHelpIndex() {
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
- search_box = memnew( LineEdit );
+ search_box = memnew(LineEdit);
vbc->add_margin_child(TTR("Search:"), search_box);
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -518,52 +482,47 @@ EditorHelpIndex::EditorHelpIndex() {
search_box->connect("text_changed", this, "_text_changed");
search_box->connect("gui_input", this, "_sbox_input");
- class_list = memnew( Tree );
- vbc->add_margin_child(TTR("Class List:")+" ", class_list, true);
+ class_list = memnew(Tree);
+ vbc->add_margin_child(TTR("Class List:") + " ", class_list, true);
class_list->set_v_size_flags(SIZE_EXPAND_FILL);
- class_list->connect("item_activated",this,"_tree_item_selected");
+ class_list->connect("item_activated", this, "_tree_item_selected");
get_ok()->set_text(TTR("Open"));
set_title(TTR("Search Classes"));
}
-
-
/////////////////////////////////
////////////////////////////////////
/// /////////////////////////////////
-DocData *EditorHelp::doc=NULL;
+DocData *EditorHelp::doc = NULL;
-void EditorHelp::_unhandled_key_input(const InputEvent& p_ev) {
+void EditorHelp::_unhandled_key_input(const InputEvent &p_ev) {
if (!is_visible_in_tree())
return;
- if ( p_ev.key.mod.control && p_ev.key.scancode==KEY_F) {
+ if (p_ev.key.mod.control && p_ev.key.scancode == KEY_F) {
search->grab_focus();
search->select_all();
}
}
-void EditorHelp::_search(const String&) {
+void EditorHelp::_search(const String &) {
- if (search->get_text()=="")
+ if (search->get_text() == "")
return;
-
- String stext=search->get_text();
- bool keep = prev_search==stext;
+ String stext = search->get_text();
+ bool keep = prev_search == stext;
bool ret = class_desc->search(stext, keep);
if (!ret) {
class_desc->search(stext, false);
}
- prev_search=stext;
-
-
+ prev_search = stext;
}
#if 0
@@ -607,66 +566,59 @@ void EditorHelp::_button_pressed(int p_idx) {
}
}
-
#endif
-void EditorHelp::_class_list_select(const String& p_select) {
+void EditorHelp::_class_list_select(const String &p_select) {
_goto_desc(p_select);
}
-void EditorHelp::_class_desc_select(const String& p_select) {
-
-
+void EditorHelp::_class_desc_select(const String &p_select) {
//print_line("LINK: "+p_select);
if (p_select.begins_with("#")) {
//_goto_desc(p_select.substr(1,p_select.length()));
- emit_signal("go_to_help","class_name:"+p_select.substr(1,p_select.length()));
+ emit_signal("go_to_help", "class_name:" + p_select.substr(1, p_select.length()));
return;
} else if (p_select.begins_with("@")) {
- String m = p_select.substr(1,p_select.length());
+ String m = p_select.substr(1, p_select.length());
- if (m.find(".")!=-1) {
+ if (m.find(".") != -1) {
//must go somewhere else
- emit_signal("go_to_help","class_method:"+m.get_slice(".",0)+":"+m.get_slice(".",0));
+ emit_signal("go_to_help", "class_method:" + m.get_slice(".", 0) + ":" + m.get_slice(".", 0));
} else {
if (!method_line.has(m))
return;
class_desc->scroll_to_line(method_line[m]);
}
-
}
-
-
}
-void EditorHelp::_class_desc_input(const InputEvent& p_input) {
- if (p_input.type==InputEvent::MOUSE_BUTTON && p_input.mouse_button.pressed && p_input.mouse_button.button_index==1) {
+void EditorHelp::_class_desc_input(const InputEvent &p_input) {
+ if (p_input.type == InputEvent::MOUSE_BUTTON && p_input.mouse_button.pressed && p_input.mouse_button.button_index == 1) {
class_desc->set_selection_enabled(false);
class_desc->set_selection_enabled(true);
}
set_focused();
}
-void EditorHelp::_add_type(const String& p_type) {
+void EditorHelp::_add_type(const String &p_type) {
String t = p_type;
- if (t=="")
- t="void";
- bool can_ref = (t!="int" && t!="real" && t!="bool" && t!="void");
+ if (t == "")
+ t = "void";
+ bool can_ref = (t != "int" && t != "real" && t != "bool" && t != "void");
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/base_type_color"));
if (can_ref)
- class_desc->push_meta("#"+t); //class
+ class_desc->push_meta("#" + t); //class
class_desc->add_text(t);
if (can_ref)
class_desc->pop();
class_desc->pop();
-
}
void EditorHelp::_scroll_changed(double p_scroll) {
@@ -675,51 +627,48 @@ void EditorHelp::_scroll_changed(double p_scroll) {
return;
if (!class_desc->get_v_scroll()->is_visible())
- p_scroll=0;
+ p_scroll = 0;
//history[p].scroll=p_scroll;
}
-Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
+Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
//ERR_FAIL_COND(!doc->class_list.has(p_class));
if (!doc->class_list.has(p_class))
return ERR_DOES_NOT_EXIST;
-
//if (tree_item_map.has(p_class)) {
- select_locked = true;
+ select_locked = true;
//}
class_desc->show();
//tabs->set_current_tab(PAGE_CLASS_DESC);
- description_line=0;
+ description_line = 0;
- if (p_class==edited_class)
+ if (p_class == edited_class)
return OK; //already there
- scroll_locked=true;
+ scroll_locked = true;
class_desc->clear();
method_line.clear();
- edited_class=p_class;
+ edited_class = p_class;
//edited_class->show();
-
- DocData::ClassDoc cd=doc->class_list[p_class]; //make a copy, so we can sort without worrying
+ DocData::ClassDoc cd = doc->class_list[p_class]; //make a copy, so we can sort without worrying
Color h_color;
- Ref<Font> doc_font = get_font("doc","EditorFonts");
- Ref<Font> doc_title_font = get_font("doc_title","EditorFonts");
- Ref<Font> doc_code_font = get_font("doc_source","EditorFonts");
-
+ Ref<Font> doc_font = get_font("doc", "EditorFonts");
+ Ref<Font> doc_title_font = get_font("doc_title", "EditorFonts");
+ Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts");
- h_color=Color(1,1,1,1);
+ h_color = Color(1, 1, 1, 1);
class_desc->push_font(doc_title_font);
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
- class_desc->add_text(TTR("Class:")+" ");
+ class_desc->add_text(TTR("Class:") + " ");
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/base_type_color"));
_add_text(p_class);
class_desc->pop();
@@ -727,11 +676,11 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->pop();
class_desc->add_newline();
- if (cd.inherits!="") {
+ if (cd.inherits != "") {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
class_desc->push_font(doc_title_font);
- class_desc->add_text(TTR("Inherits:")+" ");
+ class_desc->add_text(TTR("Inherits:") + " ");
class_desc->pop();
class_desc->pop();
@@ -758,14 +707,14 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
bool found = false;
bool prev = false;
- for (Map<String,DocData::ClassDoc>::Element *E=doc->class_list.front();E;E=E->next()) {
+ for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
if (E->get().inherits == cd.name) {
if (!found) {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
class_desc->push_font(doc_title_font);
- class_desc->add_text(TTR("Inherited by:")+" ");
+ class_desc->add_text(TTR("Inherited by:") + " ");
class_desc->pop();
class_desc->pop();
@@ -792,7 +741,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->add_newline();
- if (cd.brief_description!="") {
+ if (cd.brief_description != "") {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
class_desc->push_font(doc_title_font);
@@ -803,7 +752,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
//class_desc->add_newline();
class_desc->add_newline();
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
- class_desc->push_font( doc_font );
+ class_desc->push_font(doc_font);
class_desc->push_indent(1);
_add_text(cd.brief_description);
class_desc->pop();
@@ -814,11 +763,10 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
}
Set<String> skip_methods;
- bool property_descr=false;
+ bool property_descr = false;
if (cd.properties.size()) {
-
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
class_desc->push_font(doc_title_font);
class_desc->add_text(TTR("Members:"));
@@ -828,10 +776,10 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->push_indent(1);
class_desc->push_table(2);
- class_desc->set_table_column_expand(1,1);
+ class_desc->set_table_column_expand(1, 1);
- for(int i=0;i<cd.properties.size();i++) {
- property_line[cd.properties[i].name]=class_desc->get_line_count()-2; //gets overriden if description
+ for (int i = 0; i < cd.properties.size(); i++) {
+ property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; //gets overriden if description
class_desc->push_cell();
class_desc->push_align(RichTextLabel::ALIGN_RIGHT);
@@ -842,25 +790,23 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->pop();
class_desc->pop();
- bool describe=false;
+ bool describe = false;
- if (cd.properties[i].setter!="") {
+ if (cd.properties[i].setter != "") {
skip_methods.insert(cd.properties[i].setter);
- describe=true;
-
+ describe = true;
}
- if (cd.properties[i].getter!="") {
+ if (cd.properties[i].getter != "") {
skip_methods.insert(cd.properties[i].getter);
- describe=true;
+ describe = true;
}
- if (cd.properties[i].description!="") {
- describe=true;
-
+ if (cd.properties[i].description != "") {
+ describe = true;
}
class_desc->push_cell();
if (describe) {
- class_desc->push_meta("@"+cd.properties[i].name);
+ class_desc->push_meta("@" + cd.properties[i].name);
}
class_desc->push_font(doc_code_font);
@@ -871,42 +817,36 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->pop();
}
-
- if (cd.properties[i].brief_description!="") {
+ if (cd.properties[i].brief_description != "") {
class_desc->push_font(doc_font);
class_desc->add_text(" ");
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color"));
_add_text(cd.properties[i].description);
class_desc->pop();
class_desc->pop();
-
}
if (describe) {
- property_descr=true;
+ property_descr = true;
}
-
class_desc->pop();
class_desc->pop();
class_desc->pop();
-
}
-
class_desc->pop(); //table
class_desc->pop();
class_desc->add_newline();
class_desc->add_newline();
}
-
- bool method_descr=false;
+ bool method_descr = false;
bool sort_methods = EditorSettings::get_singleton()->get("text_editor/help/sort_functions_alphabetically");
Vector<DocData::MethodDoc> methods;
- for(int i=0;i<cd.methods.size();i++) {
+ for (int i = 0; i < cd.methods.size(); i++) {
if (skip_methods.has(cd.methods[i].name))
continue;
methods.push_back(cd.methods[i]);
@@ -928,14 +868,13 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->push_indent(1);
class_desc->push_table(2);
- class_desc->set_table_column_expand(1,1);
+ class_desc->set_table_column_expand(1, 1);
- for(int i=0;i<methods.size();i++) {
+ for (int i = 0; i < methods.size(); i++) {
class_desc->push_cell();
-
- method_line[methods[i].name]=class_desc->get_line_count()-2; //gets overriden if description
+ method_line[methods[i].name] = class_desc->get_line_count() - 2; //gets overriden if description
class_desc->push_align(RichTextLabel::ALIGN_RIGHT);
class_desc->push_font(doc_code_font);
_add_type(methods[i].return_type);
@@ -946,26 +885,26 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->push_cell();
class_desc->push_font(doc_code_font);
- if (methods[i].description!="") {
- method_descr=true;
- class_desc->push_meta("@"+methods[i].name);
+ if (methods[i].description != "") {
+ method_descr = true;
+ class_desc->push_meta("@" + methods[i].name);
}
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
_add_text(methods[i].name);
class_desc->pop();
- if (methods[i].description!="")
+ if (methods[i].description != "")
class_desc->pop();
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
- class_desc->add_text(methods[i].arguments.size()?"( ":"(");
+ class_desc->add_text(methods[i].arguments.size() ? "( " : "(");
class_desc->pop();
- for(int j=0;j<methods[i].arguments.size();j++) {
+ for (int j = 0; j < methods[i].arguments.size(); j++) {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
- if (j>0)
+ if (j > 0)
class_desc->add_text(", ");
_add_type(methods[i].arguments[j].type);
class_desc->add_text(" ");
_add_text(methods[i].arguments[j].name);
- if (methods[i].arguments[j].default_value!="") {
+ if (methods[i].arguments[j].default_value != "") {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
class_desc->add_text("=");
@@ -976,7 +915,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->pop();
}
- if (methods[i].qualifiers.find("vararg")!=-1) {
+ if (methods[i].qualifiers.find("vararg") != -1) {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
class_desc->add_text(",");
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
@@ -986,32 +925,27 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
}
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
- class_desc->add_text(methods[i].arguments.size()?" )":")");
+ class_desc->add_text(methods[i].arguments.size() ? " )" : ")");
class_desc->pop();
- if (methods[i].qualifiers!="") {
+ if (methods[i].qualifiers != "") {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
class_desc->add_text(" ");
_add_text(methods[i].qualifiers);
class_desc->pop();
-
}
- class_desc->pop();//monofont
+ class_desc->pop(); //monofont
//class_desc->add_newline();
class_desc->pop(); //cell
-
}
class_desc->pop(); //table
class_desc->pop();
class_desc->add_newline();
class_desc->add_newline();
-
}
-
if (cd.theme_properties.size()) {
-
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
class_desc->push_font(doc_title_font);
class_desc->add_text(TTR("GUI Theme Items:"));
@@ -1023,9 +957,9 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
//class_desc->add_newline();
- for(int i=0;i<cd.theme_properties.size();i++) {
+ for (int i = 0; i < cd.theme_properties.size(); i++) {
- theme_property_line[cd.theme_properties[i].name]=class_desc->get_line_count()-2; //gets overriden if description
+ theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; //gets overriden if description
class_desc->push_font(doc_code_font);
_add_type(cd.theme_properties[i].type);
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
@@ -1034,14 +968,13 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->pop();
class_desc->pop();
- if (cd.theme_properties[i].description!="") {
+ if (cd.theme_properties[i].description != "") {
class_desc->push_font(doc_font);
class_desc->add_text(" ");
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color"));
_add_text(cd.theme_properties[i].description);
class_desc->pop();
class_desc->pop();
-
}
class_desc->add_newline();
@@ -1067,26 +1000,26 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->push_indent(1);
- for(int i=0;i<cd.signals.size();i++) {
+ for (int i = 0; i < cd.signals.size(); i++) {
- signal_line[cd.signals[i].name]=class_desc->get_line_count()-2; //gets overriden if description
- class_desc->push_font(doc_code_font); // monofont
+ signal_line[cd.signals[i].name] = class_desc->get_line_count() - 2; //gets overriden if description
+ class_desc->push_font(doc_code_font); // monofont
//_add_type("void");
//class_desc->add_text(" ");
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
_add_text(cd.signals[i].name);
class_desc->pop();
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
- class_desc->add_text(cd.signals[i].arguments.size()?"( ":"(");
+ class_desc->add_text(cd.signals[i].arguments.size() ? "( " : "(");
class_desc->pop();
- for(int j=0;j<cd.signals[i].arguments.size();j++) {
+ for (int j = 0; j < cd.signals[i].arguments.size(); j++) {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
- if (j>0)
+ if (j > 0)
class_desc->add_text(", ");
_add_type(cd.signals[i].arguments[j].type);
class_desc->add_text(" ");
_add_text(cd.signals[i].arguments[j].name);
- if (cd.signals[i].arguments[j].default_value!="") {
+ if (cd.signals[i].arguments[j].default_value != "") {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
class_desc->add_text("=");
@@ -1098,29 +1031,25 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
}
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
- class_desc->add_text(cd.signals[i].arguments.size()?" )":")");
+ class_desc->add_text(cd.signals[i].arguments.size() ? " )" : ")");
class_desc->pop();
class_desc->pop(); // end monofont
- if (cd.signals[i].description!="") {
+ if (cd.signals[i].description != "") {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color"));
class_desc->add_text(" ");
_add_text(cd.signals[i].description);
class_desc->pop();
-
}
class_desc->add_newline();
-
}
class_desc->pop();
class_desc->add_newline();
-
}
if (cd.constants.size()) {
-
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
class_desc->push_font(doc_title_font);
class_desc->add_text(TTR("Constants:"));
@@ -1131,9 +1060,9 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->add_newline();
//class_desc->add_newline();
- for(int i=0;i<cd.constants.size();i++) {
+ for (int i = 0; i < cd.constants.size(); i++) {
- constant_line[cd.constants[i].name]=class_desc->get_line_count()-2;
+ constant_line[cd.constants[i].name] = class_desc->get_line_count() - 2;
class_desc->push_font(doc_code_font);
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/base_type_color"));
_add_text(cd.constants[i].name);
@@ -1145,7 +1074,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
_add_text(cd.constants[i].value);
class_desc->pop();
class_desc->pop();
- if (cd.constants[i].description!="") {
+ if (cd.constants[i].description != "") {
class_desc->push_font(doc_font);
class_desc->add_text(" ");
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color"));
@@ -1159,13 +1088,11 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->pop();
class_desc->add_newline();
-
-
}
- if (cd.description!="") {
+ if (cd.description != "") {
- description_line=class_desc->get_line_count()-2;
+ description_line = class_desc->get_line_count() - 2;
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
class_desc->push_font(doc_title_font);
class_desc->add_text(TTR("Description:"));
@@ -1175,7 +1102,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->add_newline();
class_desc->add_newline();
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
- class_desc->push_font( doc_font );
+ class_desc->push_font(doc_font);
class_desc->push_indent(1);
_add_text(cd.description);
class_desc->pop();
@@ -1196,10 +1123,9 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->add_newline();
class_desc->add_newline();
+ for (int i = 0; i < cd.properties.size(); i++) {
- for(int i=0;i<cd.properties.size();i++) {
-
- method_line[cd.properties[i].name]=class_desc->get_line_count()-2;
+ method_line[cd.properties[i].name] = class_desc->get_line_count() - 2;
class_desc->push_font(doc_code_font);
_add_type(cd.properties[i].type);
@@ -1213,9 +1139,9 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->pop(); //font
- if (cd.properties[i].setter!="") {
+ if (cd.properties[i].setter != "") {
- class_desc->push_font( doc_font );
+ class_desc->push_font(doc_font);
class_desc->push_indent(2);
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
@@ -1223,18 +1149,17 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->pop();
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
- class_desc->add_text(cd.properties[i].setter+"(value)");
+ class_desc->add_text(cd.properties[i].setter + "(value)");
class_desc->pop(); //color
class_desc->pop(); //indent
class_desc->pop(); //font
-
}
- if (cd.properties[i].getter!="") {
+ if (cd.properties[i].getter != "") {
- class_desc->push_font( doc_font );
+ class_desc->push_font(doc_font);
class_desc->push_indent(2);
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
@@ -1242,19 +1167,18 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->pop();
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
- class_desc->add_text(cd.properties[i].getter+"()");
+ class_desc->add_text(cd.properties[i].getter + "()");
class_desc->pop(); //color
class_desc->pop(); //indent
class_desc->pop(); //font
-
}
class_desc->add_newline();
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
- class_desc->push_font( doc_font );
+ class_desc->push_font(doc_font);
class_desc->push_indent(1);
_add_text(cd.properties[i].description);
class_desc->pop();
@@ -1263,9 +1187,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->add_newline();
class_desc->add_newline();
class_desc->add_newline();
-
}
-
}
if (method_descr) {
@@ -1279,10 +1201,9 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->add_newline();
class_desc->add_newline();
+ for (int i = 0; i < methods.size(); i++) {
- for(int i=0;i<methods.size();i++) {
-
- method_line[methods[i].name]=class_desc->get_line_count()-2;
+ method_line[methods[i].name] = class_desc->get_line_count() - 2;
class_desc->push_font(doc_code_font);
_add_type(methods[i].return_type);
@@ -1292,16 +1213,16 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
_add_text(methods[i].name);
class_desc->pop();
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
- class_desc->add_text(methods[i].arguments.size()?"( ":"(");
+ class_desc->add_text(methods[i].arguments.size() ? "( " : "(");
class_desc->pop();
- for(int j=0;j<methods[i].arguments.size();j++) {
+ for (int j = 0; j < methods[i].arguments.size(); j++) {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
- if (j>0)
+ if (j > 0)
class_desc->add_text(", ");
_add_type(methods[i].arguments[j].type);
class_desc->add_text(" ");
_add_text(methods[i].arguments[j].name);
- if (methods[i].arguments[j].default_value!="") {
+ if (methods[i].arguments[j].default_value != "") {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
class_desc->add_text("=");
@@ -1313,22 +1234,21 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
}
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color"));
- class_desc->add_text(methods[i].arguments.size()?" )":")");
+ class_desc->add_text(methods[i].arguments.size() ? " )" : ")");
class_desc->pop();
- if (methods[i].qualifiers!="") {
+ if (methods[i].qualifiers != "") {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
class_desc->add_text(" ");
_add_text(methods[i].qualifiers);
class_desc->pop();
-
}
class_desc->pop();
class_desc->add_newline();
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"));
- class_desc->push_font( doc_font );
+ class_desc->push_font(doc_font);
class_desc->push_indent(1);
_add_text(methods[i].description);
class_desc->pop();
@@ -1337,72 +1257,60 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->add_newline();
class_desc->add_newline();
class_desc->add_newline();
-
}
-
-
-
-
-
}
-
-
- scroll_locked=false;
+ scroll_locked = false;
return OK;
}
-void EditorHelp::_request_help(const String& p_string) {
+void EditorHelp::_request_help(const String &p_string) {
Error err = _goto_desc(p_string);
- if (err==OK) {
- editor->call("_editor_select",EditorNode::EDITOR_SCRIPT);
+ if (err == OK) {
+ editor->call("_editor_select", EditorNode::EDITOR_SCRIPT);
}
//100 palabras
}
+void EditorHelp::_help_callback(const String &p_topic) {
-void EditorHelp::_help_callback(const String& p_topic) {
-
- String what = p_topic.get_slice(":",0);
- String clss = p_topic.get_slice(":",1);
+ String what = p_topic.get_slice(":", 0);
+ String clss = p_topic.get_slice(":", 1);
String name;
- if (p_topic.get_slice_count(":")==3)
- name=p_topic.get_slice(":",2);
+ if (p_topic.get_slice_count(":") == 3)
+ name = p_topic.get_slice(":", 2);
_request_help(clss); //first go to class
- int line=0;
+ int line = 0;
- if (what=="class_desc") {
- line=description_line;
- } else if (what=="class_signal") {
+ if (what == "class_desc") {
+ line = description_line;
+ } else if (what == "class_signal") {
if (signal_line.has(name))
- line=signal_line[name];
- } else if (what=="class_method" || what=="class_method_desc") {
+ line = signal_line[name];
+ } else if (what == "class_method" || what == "class_method_desc") {
if (method_line.has(name))
- line=method_line[name];
- } else if (what=="class_property") {
+ line = method_line[name];
+ } else if (what == "class_property") {
if (property_line.has(name))
- line=property_line[name];
- } else if (what=="class_theme_item") {
+ line = property_line[name];
+ } else if (what == "class_theme_item") {
if (theme_property_line.has(name))
- line=theme_property_line[name];
- } else if (what=="class_constant") {
+ line = theme_property_line[name];
+ } else if (what == "class_constant") {
if (constant_line.has(name))
- line=constant_line[name];
+ line = constant_line[name];
}
class_desc->call_deferred("scroll_to_line", line);
-
}
-
-
-static void _add_text_to_rt(const String& p_bbcode,RichTextLabel *p_rt) {
+static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
DocData *doc = EditorHelp::get_doc_data();
String base_path;
@@ -1412,34 +1320,34 @@ static void _add_text_to_rt(const String& p_bbcode,RichTextLabel *p_rt) {
p_rt->push_indent(1);*/
int pos = 0;
- Ref<Font> doc_font = p_rt->get_font("doc","EditorFonts");
- Ref<Font> doc_code_font = p_rt->get_font("doc_source","EditorFonts");
+ Ref<Font> doc_font = p_rt->get_font("doc", "EditorFonts");
+ Ref<Font> doc_code_font = p_rt->get_font("doc_source", "EditorFonts");
- String bbcode=p_bbcode.replace("\t"," ").replace("\r"," ").strip_edges();
+ String bbcode = p_bbcode.replace("\t", " ").replace("\r", " ").strip_edges();
//change newlines for double newlines
- for(int i=0;i<bbcode.length();i++) {
+ for (int i = 0; i < bbcode.length(); i++) {
//find valid newlines (double)
- if (bbcode[i]=='\n') {
- bool dnl=false;
- int j=i+1;
- for(;j<p_bbcode.length();j++) {
- if (bbcode[j]==' ')
+ if (bbcode[i] == '\n') {
+ bool dnl = false;
+ int j = i + 1;
+ for (; j < p_bbcode.length(); j++) {
+ if (bbcode[j] == ' ')
continue;
- if (bbcode[j]=='\n') {
- dnl=true;
+ if (bbcode[j] == '\n') {
+ dnl = true;
break;
}
break;
}
if (dnl) {
- bbcode[i]=0xFFFF;
+ bbcode[i] = 0xFFFF;
//keep
- i=j;
+ i = j;
} else {
- bbcode=bbcode.insert(i,"\n");
+ bbcode = bbcode.insert(i, "\n");
i++;
//bbcode[i]=' ';
//i=j-1;
@@ -1448,12 +1356,12 @@ static void _add_text_to_rt(const String& p_bbcode,RichTextLabel *p_rt) {
}
//remove double spaces or spaces after newlines
- for(int i=0;i<bbcode.length();i++) {
+ for (int i = 0; i < bbcode.length(); i++) {
- if (bbcode[i]==' ' || bbcode[i]=='\n' || bbcode[i]==0xFFFF) {
+ if (bbcode[i] == ' ' || bbcode[i] == '\n' || bbcode[i] == 0xFFFF) {
- for(int j=i+1;j<p_bbcode.length();j++) {
- if (bbcode[j]==' ') {
+ for (int j = i + 1; j < p_bbcode.length(); j++) {
+ if (bbcode[j] == ' ') {
bbcode.remove(j);
j--;
continue;
@@ -1466,47 +1374,39 @@ static void _add_text_to_rt(const String& p_bbcode,RichTextLabel *p_rt) {
//change newlines to double newlines
- CharType dnls[2]={0xFFFF,0};
- bbcode=bbcode.replace(dnls,"\n");
-
+ CharType dnls[2] = { 0xFFFF, 0 };
+ bbcode = bbcode.replace(dnls, "\n");
List<String> tag_stack;
- while(pos < bbcode.length()) {
+ while (pos < bbcode.length()) {
+ int brk_pos = bbcode.find("[", pos);
- int brk_pos = bbcode.find("[",pos);
-
- if (brk_pos<0)
- brk_pos=bbcode.length();
+ if (brk_pos < 0)
+ brk_pos = bbcode.length();
if (brk_pos > pos) {
- p_rt->add_text(bbcode.substr(pos,brk_pos-pos));
-
+ p_rt->add_text(bbcode.substr(pos, brk_pos - pos));
}
- if (brk_pos==bbcode.length())
+ if (brk_pos == bbcode.length())
break; //nothing else o add
- int brk_end = bbcode.find("]",brk_pos+1);
+ int brk_end = bbcode.find("]", brk_pos + 1);
- if (brk_end==-1) {
+ if (brk_end == -1) {
//no close, add the rest
- p_rt->add_text(bbcode.substr(brk_pos,bbcode.length()-brk_pos));
+ p_rt->add_text(bbcode.substr(brk_pos, bbcode.length() - brk_pos));
break;
}
-
- String tag = bbcode.substr(brk_pos+1,brk_end-brk_pos-1);
-
+ String tag = bbcode.substr(brk_pos + 1, brk_end - brk_pos - 1);
if (tag.begins_with("/")) {
- 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.size()) {
-
-
-
}
if (!tag_ok) {
@@ -1516,224 +1416,203 @@ static void _add_text_to_rt(const String& p_bbcode,RichTextLabel *p_rt) {
}
tag_stack.pop_front();
- pos=brk_end+1;
- if (tag!="/img")
+ pos = brk_end + 1;
+ if (tag != "/img")
p_rt->pop();
} else if (tag.begins_with("method ")) {
- String m = tag.substr(7,tag.length());
+ String m = tag.substr(7, tag.length());
p_rt->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
- p_rt->push_meta("@"+m);
- p_rt->add_text(m+"()");
+ p_rt->push_meta("@" + m);
+ p_rt->add_text(m + "()");
p_rt->pop();
p_rt->pop();
- pos=brk_end+1;
+ pos = brk_end + 1;
} else if (doc->class_list.has(tag)) {
-
p_rt->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color"));
- p_rt->push_meta("#"+tag);
+ p_rt->push_meta("#" + tag);
p_rt->add_text(tag);
p_rt->pop();
p_rt->pop();
- pos=brk_end+1;
+ pos = brk_end + 1;
- } else if (tag=="b") {
+ } else if (tag == "b") {
//use bold font
p_rt->push_font(doc_code_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
Color text_color = EditorSettings::get_singleton()->get("text_editor/highlighting/text_color");
//no italics so emphasize with color
- text_color.r*=1.1;
- text_color.g*=1.1;
- text_color.b*=1.1;
+ text_color.r *= 1.1;
+ text_color.g *= 1.1;
+ text_color.b *= 1.1;
p_rt->push_color(text_color);
//p_rt->push_font(get_font("italic","Fonts"));
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="code" || tag=="codeblock") {
+ } else if (tag == "code" || tag == "codeblock") {
//use monospace font
p_rt->push_font(doc_code_font);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="center") {
+ } else if (tag == "center") {
//use monospace font
p_rt->push_align(RichTextLabel::ALIGN_CENTER);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="br") {
+ } else if (tag == "br") {
//use monospace font
p_rt->add_newline();
- pos=brk_end+1;
- } else if (tag=="u") {
+ pos = brk_end + 1;
+ } else if (tag == "u") {
//use underline
p_rt->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)
p_rt->push_underline();
- 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=bbcode.find("[",brk_end);
- if (end==-1)
- end=bbcode.length();
- String url = bbcode.substr(brk_end+1,end-brk_end-1);
+ int end = bbcode.find("[", brk_end);
+ if (end == -1)
+ end = bbcode.length();
+ String url = bbcode.substr(brk_end + 1, end - brk_end - 1);
p_rt->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());
p_rt->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=bbcode.find("[",brk_end);
- if (end==-1)
- end=bbcode.length();
- String image = bbcode.substr(brk_end+1,end-brk_end-1);
+ int end = bbcode.find("[", brk_end);
+ if (end == -1)
+ end = bbcode.length();
+ String image = bbcode.substr(brk_end + 1, end - brk_end - 1);
- Ref<Texture> texture = ResourceLoader::load(base_path+"/"+image,"Texture");
+ Ref<Texture> texture = ResourceLoader::load(base_path + "/" + image, "Texture");
if (texture.is_valid())
p_rt->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=Color(0,0,0,1); //base_color;
-
-
+ color = Color(0, 0, 0, 1); //base_color;
p_rt->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(base_path+"/"+fnt,"Font");
+ Ref<Font> font = ResourceLoader::load(base_path + "/" + fnt, "Font");
if (font.is_valid())
p_rt->push_font(font);
else {
p_rt->push_font(doc_font);
}
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front("font");
-
} else {
p_rt->add_text("["); //ignore
- pos=brk_pos+1;
-
+ pos = brk_pos + 1;
}
}
/*p_rt->pop();
p_rt->pop();
p_rt->pop();*/
-
}
+void EditorHelp::_add_text(const String &p_bbcode) {
-void EditorHelp::_add_text(const String& p_bbcode) {
-
-
- _add_text_to_rt(p_bbcode,class_desc);
-
+ _add_text_to_rt(p_bbcode, class_desc);
}
-
-
-
void EditorHelp::_update_doc() {
-
-
-
}
-
void EditorHelp::generate_doc() {
- doc = memnew( DocData );
+ doc = memnew(DocData);
doc->generate(true);
DocData compdoc;
- compdoc.load_compressed(_doc_data_compressed,_doc_data_compressed_size,_doc_data_uncompressed_size);
+ compdoc.load_compressed(_doc_data_compressed, _doc_data_compressed_size, _doc_data_uncompressed_size);
doc->merge_from(compdoc); //ensure all is up to date
-
-
}
void EditorHelp::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
-
//forward->set_icon(get_icon("Forward","EditorIcons"));
//back->set_icon(get_icon("Back","EditorIcons"));
_update_doc();
@@ -1742,20 +1621,19 @@ void EditorHelp::_notification(int p_what) {
}
}
-void EditorHelp::go_to_help(const String& p_help) {
+void EditorHelp::go_to_help(const String &p_help) {
_help_callback(p_help);
}
-void EditorHelp::go_to_class(const String& p_class,int p_scroll) {
+void EditorHelp::go_to_class(const String &p_class, int p_scroll) {
- _goto_desc(p_class,p_scroll);
+ _goto_desc(p_class, p_scroll);
}
void EditorHelp::popup_search() {
-
- search_dialog->popup_centered(Size2(250,80));
+ search_dialog->popup_centered(Size2(250, 80));
search->grab_focus();
}
@@ -1779,74 +1657,70 @@ int EditorHelp::get_scroll() const {
}
void EditorHelp::set_scroll(int p_scroll) {
-
class_desc->get_v_scroll()->set_value(p_scroll);
-
}
void EditorHelp::_bind_methods() {
- ClassDB::bind_method("_class_list_select",&EditorHelp::_class_list_select);
- ClassDB::bind_method("_class_desc_select",&EditorHelp::_class_desc_select);
- ClassDB::bind_method("_class_desc_input",&EditorHelp::_class_desc_input);
+ ClassDB::bind_method("_class_list_select", &EditorHelp::_class_list_select);
+ ClassDB::bind_method("_class_desc_select", &EditorHelp::_class_desc_select);
+ ClassDB::bind_method("_class_desc_input", &EditorHelp::_class_desc_input);
//ClassDB::bind_method("_button_pressed",&EditorHelp::_button_pressed);
- ClassDB::bind_method("_scroll_changed",&EditorHelp::_scroll_changed);
- ClassDB::bind_method("_request_help",&EditorHelp::_request_help);
- ClassDB::bind_method("_unhandled_key_input",&EditorHelp::_unhandled_key_input);
- ClassDB::bind_method("_search",&EditorHelp::_search);
- ClassDB::bind_method("_search_cbk",&EditorHelp::_search_cbk);
- ClassDB::bind_method("_help_callback",&EditorHelp::_help_callback);
+ ClassDB::bind_method("_scroll_changed", &EditorHelp::_scroll_changed);
+ ClassDB::bind_method("_request_help", &EditorHelp::_request_help);
+ ClassDB::bind_method("_unhandled_key_input", &EditorHelp::_unhandled_key_input);
+ ClassDB::bind_method("_search", &EditorHelp::_search);
+ ClassDB::bind_method("_search_cbk", &EditorHelp::_search_cbk);
+ ClassDB::bind_method("_help_callback", &EditorHelp::_help_callback);
ADD_SIGNAL(MethodInfo("go_to_help"));
-
}
EditorHelp::EditorHelp() {
- editor=EditorNode::get_singleton();
+ editor = EditorNode::get_singleton();
VBoxContainer *vbc = this;
- EDITOR_DEF("text_editor/help/sort_functions_alphabetically",true);
+ EDITOR_DEF("text_editor/help/sort_functions_alphabetically", true);
//class_list->connect("meta_clicked",this,"_class_list_select");
//class_list->set_selection_enabled(true);
{
- Panel *pc = memnew( Panel );
- Ref<StyleBoxFlat> style( memnew( StyleBoxFlat ) );
- style->set_bg_color( EditorSettings::get_singleton()->get("text_editor/highlighting/background_color") );
+ Panel *pc = memnew(Panel);
+ Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));
+ style->set_bg_color(EditorSettings::get_singleton()->get("text_editor/highlighting/background_color"));
pc->set_v_size_flags(SIZE_EXPAND_FILL);
pc->add_style_override("panel", style); //get_stylebox("normal","TextEdit"));
vbc->add_child(pc);
- class_desc = memnew( RichTextLabel );
+ class_desc = memnew(RichTextLabel);
pc->add_child(class_desc);
class_desc->set_area_as_parent_rect(8);
- class_desc->connect("meta_clicked",this,"_class_desc_select");
- class_desc->connect("gui_input",this,"_class_desc_input");
+ class_desc->connect("meta_clicked", this, "_class_desc_select");
+ class_desc->connect("gui_input", this, "_class_desc_input");
}
- class_desc->get_v_scroll()->connect("value_changed",this,"_scroll_changed");
+ class_desc->get_v_scroll()->connect("value_changed", this, "_scroll_changed");
class_desc->set_selection_enabled(true);
- scroll_locked=false;
- select_locked=false;
+ scroll_locked = false;
+ select_locked = false;
set_process_unhandled_key_input(true);
class_desc->hide();
- search_dialog = memnew( ConfirmationDialog );
+ search_dialog = memnew(ConfirmationDialog);
add_child(search_dialog);
- VBoxContainer *search_vb = memnew( VBoxContainer );
+ VBoxContainer *search_vb = memnew(VBoxContainer);
search_dialog->add_child(search_vb);
- search = memnew( LineEdit );
+ search = memnew(LineEdit);
search_dialog->register_text_enter(search);
- search_vb->add_margin_child(TTR("Search Text"),search);
+ search_vb->add_margin_child(TTR("Search Text"), search);
search_dialog->get_ok()->set_text(TTR("Find"));
- search_dialog->connect("confirmed",this,"_search_cbk");
+ search_dialog->connect("confirmed", this, "_search_cbk");
search_dialog->set_hide_on_ok(false);
- search_dialog->set_self_modulate(Color(1,1,1,0.8));
-
+ search_dialog->set_self_modulate(Color(1, 1, 1, 0.8));
/*class_search = memnew( EditorHelpSearch(editor) );
editor->get_gui_base()->add_child(class_search);
@@ -1856,13 +1730,10 @@ EditorHelp::EditorHelp() {
}
EditorHelp::~EditorHelp() {
-
}
/////////////
-
-
void EditorHelpBit::_go_to_help(String p_what) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
@@ -1875,16 +1746,16 @@ void EditorHelpBit::_meta_clicked(String p_select) {
//print_line("LINK: "+p_select);
if (p_select.begins_with("#")) {
//_goto_desc(p_select.substr(1,p_select.length()));
- _go_to_help("class_name:"+p_select.substr(1,p_select.length()));
+ _go_to_help("class_name:" + p_select.substr(1, p_select.length()));
return;
} else if (p_select.begins_with("@")) {
- String m = p_select.substr(1,p_select.length());
+ String m = p_select.substr(1, p_select.length());
- if (m.find(".")!=-1) {
+ if (m.find(".") != -1) {
//must go somewhere else
- _go_to_help("class_method:"+m.get_slice(".",0)+":"+m.get_slice(".",0));
+ _go_to_help("class_method:" + m.get_slice(".", 0) + ":" + m.get_slice(".", 0));
} else {
/*
if (!method_line.has(m))
@@ -1892,38 +1763,33 @@ void EditorHelpBit::_meta_clicked(String p_select) {
class_desc->scroll_to_line(method_line[m]);
*/
}
-
}
-
-
}
void EditorHelpBit::_bind_methods() {
- ClassDB::bind_method("_meta_clicked",&EditorHelpBit::_meta_clicked);
+ ClassDB::bind_method("_meta_clicked", &EditorHelpBit::_meta_clicked);
ADD_SIGNAL(MethodInfo("request_hide"));
}
-void EditorHelpBit::_notification(int p_what){
+void EditorHelpBit::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
- add_style_override("panel",get_stylebox("normal","TextEdit"));
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ add_style_override("panel", get_stylebox("normal", "TextEdit"));
}
}
-
-void EditorHelpBit::set_text(const String& p_text) {
+void EditorHelpBit::set_text(const String &p_text) {
rich_text->clear();
- _add_text_to_rt(p_text,rich_text);
+ _add_text_to_rt(p_text, rich_text);
}
EditorHelpBit::EditorHelpBit() {
- rich_text = memnew( RichTextLabel );
+ rich_text = memnew(RichTextLabel);
add_child(rich_text);
- rich_text->set_area_as_parent_rect(8*EDSCALE);
- rich_text->connect("meta_clicked",this,"_meta_clicked");
- set_custom_minimum_size(Size2(0,70*EDSCALE));
-
+ rich_text->set_area_as_parent_rect(8 * EDSCALE);
+ rich_text->connect("meta_clicked", this, "_meta_clicked");
+ set_custom_minimum_size(Size2(0, 70 * EDSCALE));
}
diff --git a/editor/editor_help.h b/editor/editor_help.h
index 909226f403..06b64edf78 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -30,24 +30,23 @@
#define EDITOR_HELP_H
#include "editor/editor_plugin.h"
-#include "scene/gui/tab_container.h"
-#include "scene/gui/text_edit.h"
-#include "scene/gui/split_container.h"
#include "scene/gui/menu_button.h"
-#include "scene/gui/rich_text_label.h"
#include "scene/gui/panel_container.h"
+#include "scene/gui/rich_text_label.h"
+#include "scene/gui/split_container.h"
+#include "scene/gui/tab_container.h"
+#include "scene/gui/text_edit.h"
#include "scene/gui/tree.h"
-#include "scene/main/timer.h"
#include "editor/code_editor.h"
#include "editor/doc/doc_data.h"
-
+#include "scene/main/timer.h"
class EditorNode;
class EditorHelpSearch : public ConfirmationDialog {
- GDCLASS(EditorHelpSearch,ConfirmationDialog )
+ GDCLASS(EditorHelpSearch, ConfirmationDialog)
EditorNode *editor;
LineEdit *search_box;
@@ -56,56 +55,51 @@ class EditorHelpSearch : public ConfirmationDialog {
void _update_search();
- void _sbox_input(const InputEvent& p_ie);
+ void _sbox_input(const InputEvent &p_ie);
void _confirmed();
- void _text_changed(const String& p_newtext);
-
+ void _text_changed(const String &p_newtext);
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void popup();
- void popup(const String& p_term);
+ void popup(const String &p_term);
EditorHelpSearch();
};
class EditorHelpIndex : public ConfirmationDialog {
- GDCLASS( EditorHelpIndex, ConfirmationDialog );
+ GDCLASS(EditorHelpIndex, ConfirmationDialog);
LineEdit *search_box;
Tree *class_list;
- HashMap<String,TreeItem*> tree_item_map;
+ HashMap<String, TreeItem *> tree_item_map;
void _tree_item_selected();
- void _text_changed(const String& p_text);
- void _sbox_input(const InputEvent& p_ie);
+ void _text_changed(const String &p_text);
+ void _sbox_input(const InputEvent &p_ie);
void _update_class_list();
- void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root);
-protected:
+ void add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root);
+protected:
void _notification(int p_what);
static void _bind_methods();
public:
-
- void select_class(const String& p_class);
+ void select_class(const String &p_class);
void popup();
EditorHelpIndex();
};
-
class EditorHelp : public VBoxContainer {
- GDCLASS( EditorHelp, VBoxContainer );
-
+ GDCLASS(EditorHelp, VBoxContainer);
enum Page {
@@ -118,7 +112,6 @@ class EditorHelp : public VBoxContainer {
};
-
bool select_locked;
String prev_search;
@@ -126,63 +119,55 @@ class EditorHelp : public VBoxContainer {
String edited_class;
EditorNode *editor;
- Map<String,int> method_line;
- Map<String,int> signal_line;
- Map<String,int> property_line;
- Map<String,int> theme_property_line;
- Map<String,int> constant_line;
+ Map<String, int> method_line;
+ Map<String, int> signal_line;
+ Map<String, int> property_line;
+ Map<String, int> theme_property_line;
+ Map<String, int> constant_line;
int description_line;
-
RichTextLabel *class_desc;
HSplitContainer *h_split;
static DocData *doc;
-
ConfirmationDialog *search_dialog;
LineEdit *search;
-
String base_path;
+ void _help_callback(const String &p_topic);
- void _help_callback(const String& p_topic);
-
- void _add_text(const String& p_text);
+ void _add_text(const String &p_text);
bool scroll_locked;
//void _button_pressed(int p_idx);
- void _add_type(const String& p_type);
+ void _add_type(const String &p_type);
void _scroll_changed(double p_scroll);
- void _class_list_select(const String& p_select);
- void _class_desc_select(const String& p_select);
- void _class_desc_input(const InputEvent& p_input);
+ void _class_list_select(const String &p_select);
+ void _class_desc_select(const String &p_select);
+ void _class_desc_input(const InputEvent &p_input);
- Error _goto_desc(const String& p_class, int p_vscr=-1);
+ Error _goto_desc(const String &p_class, int p_vscr = -1);
//void _update_history_buttons();
void _update_doc();
- void _request_help(const String& p_string);
- void _search(const String& p_str);
+ void _request_help(const String &p_string);
+ void _search(const String &p_str);
void _search_cbk();
- void _unhandled_key_input(const InputEvent& p_ev);
-
-
+ void _unhandled_key_input(const InputEvent &p_ev);
protected:
-
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
static void generate_doc();
static DocData *get_doc_data() { return doc; }
- void go_to_help(const String& p_help);
- void go_to_class(const String& p_class,int p_scroll=0);
+ void go_to_help(const String &p_help);
+ void go_to_class(const String &p_class, int p_scroll = 0);
void popup_search();
void search_again();
@@ -198,24 +183,20 @@ public:
~EditorHelp();
};
-
-
class EditorHelpBit : public Panel {
- GDCLASS( EditorHelpBit, Panel);
+ GDCLASS(EditorHelpBit, Panel);
RichTextLabel *rich_text;
void _go_to_help(String p_what);
void _meta_clicked(String p_what);
-
protected:
-
static void _bind_methods();
void _notification(int p_what);
-public:
- void set_text(const String& p_text);
+public:
+ void set_text(const String &p_text);
EditorHelpBit();
};
diff --git a/editor/editor_initialize_ssl.cpp b/editor/editor_initialize_ssl.cpp
index c08dcc6656..7801b312b3 100644
--- a/editor/editor_initialize_ssl.cpp
+++ b/editor/editor_initialize_ssl.cpp
@@ -29,23 +29,18 @@
#include "editor_initialize_ssl.h"
#include "certs_compressed.h"
-#include "io/stream_peer_ssl.h"
#include "io/compression.h"
+#include "io/stream_peer_ssl.h"
void editor_initialize_certificates() {
-
PoolByteArray data;
- data.resize(_certs_uncompressed_size+1);
+ data.resize(_certs_uncompressed_size + 1);
{
PoolByteArray::Write w = data.write();
- Compression::decompress(w.ptr(),_certs_uncompressed_size,_certs_compressed,_certs_compressed_size,Compression::MODE_DEFLATE);
- w[_certs_uncompressed_size]=0; //make sure it ends at zero
+ Compression::decompress(w.ptr(), _certs_uncompressed_size, _certs_compressed, _certs_compressed_size, Compression::MODE_DEFLATE);
+ w[_certs_uncompressed_size] = 0; //make sure it ends at zero
}
StreamPeerSSL::load_certs_from_memory(data);
-
-
}
-
-
diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp
index 850d9273f8..60837d900e 100644
--- a/editor/editor_log.cpp
+++ b/editor/editor_log.cpp
@@ -28,21 +28,21 @@
/*************************************************************************/
#include "editor_log.h"
-#include "version.h"
-#include "scene/gui/center_container.h"
#include "editor_node.h"
+#include "scene/gui/center_container.h"
+#include "version.h"
-void EditorLog::_error_handler(void *p_self, const char*p_func, const char*p_file,int p_line, const char*p_error,const char*p_errorexp,ErrorHandlerType p_type ) {
+void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type) {
- EditorLog *self=(EditorLog *)p_self;
- if (self->current!=Thread::get_caller_ID())
+ EditorLog *self = (EditorLog *)p_self;
+ if (self->current != Thread::get_caller_ID())
return;
String err_str;
if (p_errorexp && p_errorexp[0]) {
- err_str=p_errorexp;
+ err_str = p_errorexp;
} else {
- err_str=String(p_file)+":"+itos(p_line)+" - "+String(p_error);
+ err_str = String(p_file) + ":" + itos(p_line) + " - " + String(p_error);
}
/*
@@ -50,44 +50,41 @@ void EditorLog::_error_handler(void *p_self, const char*p_func, const char*p_fil
self->emit_signal("show_request");
*/
- err_str=" "+err_str;
+ err_str = " " + err_str;
self->log->add_newline();
Ref<Texture> icon;
- switch(p_type) {
+ switch (p_type) {
case ERR_HANDLER_ERROR: {
- icon = self->get_icon("Error","EditorIcons");
+ icon = self->get_icon("Error", "EditorIcons");
return; // these are confusing
} break;
case ERR_HANDLER_WARNING: {
- icon = self->get_icon("Error","EditorIcons");
+ icon = self->get_icon("Error", "EditorIcons");
} break;
case ERR_HANDLER_SCRIPT: {
- icon = self->get_icon("ScriptError","EditorIcons");
+ icon = self->get_icon("ScriptError", "EditorIcons");
} break;
case ERR_HANDLER_SHADER: {
- icon = self->get_icon("Shader","EditorIcons");
+ icon = self->get_icon("Shader", "EditorIcons");
} break;
-
}
- self->add_message(err_str,true);
-
+ self->add_message(err_str, true);
}
void EditorLog::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- log->add_color_override("default_color",get_color("font_color","Tree"));
+ log->add_color_override("default_color", get_color("font_color", "Tree"));
//button->set_icon(get_icon("Console","EditorIcons"));
-
}
/*if (p_what==NOTIFICATION_DRAW) {
@@ -102,42 +99,32 @@ void EditorLog::_notification(int p_what) {
}*/
}
-
-
-
void EditorLog::_clear_request() {
log->clear();
-
}
void EditorLog::clear() {
_clear_request();
}
-
-void EditorLog::add_message(const String& p_msg,bool p_error) {
-
+void EditorLog::add_message(const String &p_msg, bool p_error) {
if (p_error) {
- Ref<Texture> icon = get_icon("Error","EditorIcons");
- log->add_image( icon );
+ Ref<Texture> icon = get_icon("Error", "EditorIcons");
+ log->add_image(icon);
//button->set_icon(icon);
- log->push_color(get_color("fg_error","Editor"));
+ log->push_color(get_color("fg_error", "Editor"));
} else {
//button->set_icon(Ref<Texture>());
-
}
-
log->add_newline();
log->add_text(p_msg);
//button->set_text(p_msg);
if (p_error)
log->pop();
-
-
}
/*
@@ -155,32 +142,28 @@ void EditorLog::_dragged(const Point2& p_ofs) {
}
*/
+void EditorLog::_undo_redo_cbk(void *p_self, const String &p_name) {
-
-
-void EditorLog::_undo_redo_cbk(void *p_self,const String& p_name) {
-
- EditorLog *self=(EditorLog *)p_self;
+ EditorLog *self = (EditorLog *)p_self;
self->add_message(p_name);
-
}
void EditorLog::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_clear_request"),&EditorLog::_clear_request );
- ClassDB::bind_method("_override_logger_styles",&EditorLog::_override_logger_styles );
+ ClassDB::bind_method(D_METHOD("_clear_request"), &EditorLog::_clear_request);
+ ClassDB::bind_method("_override_logger_styles", &EditorLog::_override_logger_styles);
//ClassDB::bind_method(D_METHOD("_dragged"),&EditorLog::_dragged );
- ADD_SIGNAL( MethodInfo("clear_request"));
+ ADD_SIGNAL(MethodInfo("clear_request"));
}
EditorLog::EditorLog() {
VBoxContainer *vb = this;
- add_constant_override("separation",get_constant("separation","VBoxContainer"));
+ add_constant_override("separation", get_constant("separation", "VBoxContainer"));
- HBoxContainer *hb = memnew( HBoxContainer );
+ HBoxContainer *hb = memnew(HBoxContainer);
vb->add_child(hb);
- title = memnew( Label );
+ title = memnew(Label);
title->set_text(TTR(" Output:"));
title->set_h_size_flags(SIZE_EXPAND_FILL);
hb->add_child(title);
@@ -190,53 +173,47 @@ EditorLog::EditorLog() {
//pd->connect("dragged",this,"_dragged");
//pd->set_default_cursor_shape(Control::CURSOR_MOVE);
- clearbutton = memnew( Button );
+ clearbutton = memnew(Button);
hb->add_child(clearbutton);
clearbutton->set_text(TTR("Clear"));
- clearbutton->connect("pressed", this,"_clear_request");
+ clearbutton->connect("pressed", this, "_clear_request");
- ec = memnew( Control);
+ ec = memnew(Control);
vb->add_child(ec);
- ec->set_custom_minimum_size(Size2(0,180));
+ ec->set_custom_minimum_size(Size2(0, 180));
ec->set_v_size_flags(SIZE_EXPAND_FILL);
- pc = memnew( PanelContainer );
+ pc = memnew(PanelContainer);
ec->add_child(pc);
pc->set_area_as_parent_rect();
pc->connect("tree_entered", this, "_override_logger_styles");
- log = memnew( RichTextLabel );
+ log = memnew(RichTextLabel);
log->set_scroll_follow(true);
log->set_selection_enabled(true);
log->set_focus_mode(FOCUS_CLICK);
pc->add_child(log);
- add_message(VERSION_FULL_NAME" (c) 2008-2017 Juan Linietsky, Ariel Manzur.");
+ add_message(VERSION_FULL_NAME " (c) 2008-2017 Juan Linietsky, Ariel Manzur.");
//log->add_text("Initialization Complete.\n"); //because it looks cool.
- eh.errfunc=_error_handler;
- eh.userdata=this;
+ eh.errfunc = _error_handler;
+ eh.userdata = this;
add_error_handler(&eh);
- current=Thread::get_caller_ID();
-
- EditorNode::get_undo_redo()->set_commit_notify_callback(_undo_redo_cbk,this);
-
+ current = Thread::get_caller_ID();
+ EditorNode::get_undo_redo()->set_commit_notify_callback(_undo_redo_cbk, this);
}
void EditorLog::deinit() {
remove_error_handler(&eh);
-
}
void EditorLog::_override_logger_styles() {
- pc->add_style_override("panel",get_stylebox("normal","TextEdit"));
-
+ pc->add_style_override("panel", get_stylebox("normal", "TextEdit"));
}
EditorLog::~EditorLog() {
-
-
}
diff --git a/editor/editor_log.h b/editor/editor_log.h
index 965d8d6420..3debbfecd4 100644
--- a/editor/editor_log.h
+++ b/editor/editor_log.h
@@ -34,15 +34,15 @@
#include "scene/gui/rich_text_label.h"
#include "scene/gui/texture_button.h"
//#include "scene/gui/empty_control.h"
+#include "os/thread.h"
+#include "pane_drag.h"
#include "scene/gui/box_container.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
-#include "pane_drag.h"
-#include "os/thread.h"
class EditorLog : public VBoxContainer {
- GDCLASS( EditorLog, VBoxContainer );
+ GDCLASS(EditorLog, VBoxContainer);
Button *clearbutton;
Label *title;
@@ -52,7 +52,7 @@ class EditorLog : public VBoxContainer {
Control *ec;
PanelContainer *pc;
- static void _error_handler(void *p_self, const char*p_func, const char*p_file,int p_line, const char*p_error,const char*p_errorexp,ErrorHandlerType p_type);
+ static void _error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type);
ErrorHandlerList eh;
@@ -60,18 +60,17 @@ class EditorLog : public VBoxContainer {
//void _dragged(const Point2& p_ofs);
void _clear_request();
- static void _undo_redo_cbk(void *p_self,const String& p_name);
-protected:
+ static void _undo_redo_cbk(void *p_self, const String &p_name);
+protected:
static void _bind_methods();
void _notification(int p_what);
void _override_logger_styles();
-public:
- void add_message(const String& p_msg, bool p_error=false);
+public:
+ void add_message(const String &p_msg, bool p_error = false);
void deinit();
-
void clear();
EditorLog();
~EditorLog();
diff --git a/editor/editor_name_dialog.cpp b/editor/editor_name_dialog.cpp
index da9f25f1e3..b8fa534ddb 100644
--- a/editor/editor_name_dialog.cpp
+++ b/editor/editor_name_dialog.cpp
@@ -31,7 +31,7 @@
#include "class_db.h"
#include "os/keyboard.h"
-void EditorNameDialog::_line_gui_input(const InputEvent& p_event) {
+void EditorNameDialog::_line_gui_input(const InputEvent &p_event) {
if (p_event.type == InputEvent::KEY) {
@@ -65,25 +65,24 @@ void EditorNameDialog::_post_popup() {
void EditorNameDialog::ok_pressed() {
- if (name->get_text()!="") {
+ if (name->get_text() != "") {
emit_signal("name_confirmed", name->get_text());
}
}
void EditorNameDialog::_bind_methods() {
- ClassDB::bind_method("_line_gui_input",&EditorNameDialog::_line_gui_input);
+ ClassDB::bind_method("_line_gui_input", &EditorNameDialog::_line_gui_input);
- ADD_SIGNAL(MethodInfo("name_confirmed",PropertyInfo( Variant::STRING,"name")));
+ ADD_SIGNAL(MethodInfo("name_confirmed", PropertyInfo(Variant::STRING, "name")));
}
-EditorNameDialog::EditorNameDialog()
-{
- name = memnew( LineEdit );
+EditorNameDialog::EditorNameDialog() {
+ name = memnew(LineEdit);
add_child(name);
- move_child(name, get_label()->get_index()+1);
- name->set_margin(MARGIN_TOP,5);
- name->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
- name->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
+ move_child(name, get_label()->get_index() + 1);
+ name->set_margin(MARGIN_TOP, 5);
+ name->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5);
+ name->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 5);
name->connect("gui_input", this, "_line_gui_input");
}
diff --git a/editor/editor_name_dialog.h b/editor/editor_name_dialog.h
index d6bc7eca94..5b65abef84 100644
--- a/editor/editor_name_dialog.h
+++ b/editor/editor_name_dialog.h
@@ -35,21 +35,19 @@
class EditorNameDialog : public ConfirmationDialog {
- GDCLASS( EditorNameDialog, ConfirmationDialog );
+ GDCLASS(EditorNameDialog, ConfirmationDialog);
LineEdit *name;
- void _line_gui_input(const InputEvent& p_event);
+ void _line_gui_input(const InputEvent &p_event);
protected:
-
static void _bind_methods();
virtual void ok_pressed();
virtual void _post_popup();
public:
-
- LineEdit* get_line_edit() { return name; }
+ LineEdit *get_line_edit() { return name; }
EditorNameDialog();
};
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 7a85941b0d..00df0f337d 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -28,162 +28,154 @@
/*************************************************************************/
#include "editor_node.h"
-#include "version.h"
-#include "print_string.h"
-#include "editor_themes.h"
-#include "editor_help.h"
-#include "core/io/resource_saver.h"
+#include "animation_editor.h"
+#include "bind/core_bind.h"
+#include "class_db.h"
#include "core/io/resource_loader.h"
-#include "servers/physics_2d_server.h"
-#include "scene/resources/packed_scene.h"
+#include "core/io/resource_saver.h"
+#include "editor_file_system.h"
+#include "editor_help.h"
#include "editor_settings.h"
+#include "editor_themes.h"
#include "global_config.h"
-#include <stdio.h>
-#include "class_db.h"
+#include "io/config_file.h"
+#include "io/stream_peer_ssl.h"
+#include "io/zip_io.h"
+#include "main/input_default.h"
+#include "message_queue.h"
+#include "os/file_access.h"
+#include "os/input.h"
#include "os/keyboard.h"
#include "os/os.h"
-#include "os/file_access.h"
-#include "message_queue.h"
#include "path_remap.h"
-#include "translation.h"
+#include "print_string.h"
#include "pvrtc_compress.h"
-#include "editor_file_system.h"
#include "register_exporters.h"
-#include "bind/core_bind.h"
-#include "io/zip_io.h"
-#include "io/config_file.h"
-#include "animation_editor.h"
-#include "io/stream_peer_ssl.h"
-#include "main/input_default.h"
-#include "os/input.h"
+#include "scene/resources/packed_scene.h"
+#include "servers/physics_2d_server.h"
+#include "translation.h"
+#include "version.h"
+#include <stdio.h>
// plugins
-#include "plugins/sprite_frames_editor_plugin.h"
-#include "plugins/texture_region_editor_plugin.h"
-#include "plugins/canvas_item_editor_plugin.h"
#include "asset_library_editor_plugin.h"
-#include "plugins/spatial_editor_plugin.h"
-#include "plugins/sample_editor_plugin.h"
-#include "plugins/texture_editor_plugin.h"
-#include "plugins/material_editor_plugin.h"
-#include "plugins/sample_library_editor_plugin.h"
-#include "plugins/sample_player_editor_plugin.h"
+#include "import/resource_importer_csv_translation.h"
+#include "import/resource_importer_obj.h"
+#include "import/resource_importer_scene.h"
+#include "import/resource_importer_texture.h"
+#include "import/resource_importer_wav.h"
+#include "plugins/animation_player_editor_plugin.h"
+#include "plugins/animation_tree_editor_plugin.h"
+#include "plugins/baked_light_editor_plugin.h"
#include "plugins/camera_editor_plugin.h"
-#include "plugins/style_box_editor_plugin.h"
-#include "plugins/resource_preloader_editor_plugin.h"
+#include "plugins/canvas_item_editor_plugin.h"
+#include "plugins/collision_polygon_2d_editor_plugin.h"
+#include "plugins/collision_polygon_editor_plugin.h"
+#include "plugins/collision_shape_2d_editor_plugin.h"
+#include "plugins/color_ramp_editor_plugin.h"
+#include "plugins/cube_grid_theme_editor_plugin.h"
+#include "plugins/gi_probe_editor_plugin.h"
#include "plugins/item_list_editor_plugin.h"
-#include "plugins/stream_editor_plugin.h"
-#include "plugins/multimesh_editor_plugin.h"
-#include "plugins/mesh_instance_editor_plugin.h"
+#include "plugins/light_occluder_2d_editor_plugin.h"
+#include "plugins/line_2d_editor_plugin.h"
+#include "plugins/material_editor_plugin.h"
#include "plugins/mesh_editor_plugin.h"
-#include "plugins/theme_editor_plugin.h"
-#include "plugins/tile_map_editor_plugin.h"
-#include "plugins/cube_grid_theme_editor_plugin.h"
-#include "plugins/shader_editor_plugin.h"
-#include "plugins/shader_graph_editor_plugin.h"
+#include "plugins/mesh_instance_editor_plugin.h"
+#include "plugins/multimesh_editor_plugin.h"
+#include "plugins/navigation_polygon_editor_plugin.h"
+#include "plugins/particles_2d_editor_plugin.h"
+#include "plugins/particles_editor_plugin.h"
+#include "plugins/path_2d_editor_plugin.h"
#include "plugins/path_editor_plugin.h"
+#include "plugins/polygon_2d_editor_plugin.h"
+#include "plugins/resource_preloader_editor_plugin.h"
#include "plugins/rich_text_editor_plugin.h"
-#include "plugins/collision_polygon_editor_plugin.h"
-#include "plugins/collision_polygon_2d_editor_plugin.h"
+#include "plugins/sample_editor_plugin.h"
+#include "plugins/sample_library_editor_plugin.h"
+#include "plugins/sample_player_editor_plugin.h"
#include "plugins/script_editor_plugin.h"
#include "plugins/script_text_editor.h"
-#include "plugins/path_2d_editor_plugin.h"
-#include "plugins/line_2d_editor_plugin.h"
-#include "plugins/particles_editor_plugin.h"
-#include "plugins/particles_2d_editor_plugin.h"
-#include "plugins/animation_tree_editor_plugin.h"
+#include "plugins/shader_editor_plugin.h"
+#include "plugins/shader_graph_editor_plugin.h"
+#include "plugins/spatial_editor_plugin.h"
+#include "plugins/sprite_frames_editor_plugin.h"
+#include "plugins/stream_editor_plugin.h"
+#include "plugins/style_box_editor_plugin.h"
+#include "plugins/texture_editor_plugin.h"
+#include "plugins/texture_region_editor_plugin.h"
+#include "plugins/theme_editor_plugin.h"
+#include "plugins/tile_map_editor_plugin.h"
#include "plugins/tile_set_editor_plugin.h"
-#include "plugins/animation_player_editor_plugin.h"
-#include "plugins/baked_light_editor_plugin.h"
-#include "plugins/polygon_2d_editor_plugin.h"
-#include "plugins/navigation_polygon_editor_plugin.h"
-#include "plugins/light_occluder_2d_editor_plugin.h"
-#include "plugins/color_ramp_editor_plugin.h"
-#include "plugins/collision_shape_2d_editor_plugin.h"
-#include "plugins/gi_probe_editor_plugin.h"
-#include "import/resource_importer_texture.h"
-#include "import/resource_importer_csv_translation.h"
-#include "import/resource_importer_wav.h"
-#include "import/resource_importer_obj.h"
-#include "import/resource_importer_scene.h"
// end
#include "editor_settings.h"
-#include "io_plugins/editor_texture_import_plugin.h"
-#include "io_plugins/editor_scene_import_plugin.h"
-#include "io_plugins/editor_font_import_plugin.h"
-#include "io_plugins/editor_sample_import_plugin.h"
-#include "io_plugins/editor_translation_import_plugin.h"
+#include "import/editor_import_collada.h"
#include "io_plugins/editor_bitmask_import_plugin.h"
-#include "io_plugins/editor_mesh_import_plugin.h"
#include "io_plugins/editor_export_scene.h"
-#include "import/editor_import_collada.h"
+#include "io_plugins/editor_font_import_plugin.h"
+#include "io_plugins/editor_mesh_import_plugin.h"
+#include "io_plugins/editor_sample_import_plugin.h"
+#include "io_plugins/editor_scene_import_plugin.h"
#include "io_plugins/editor_scene_importer_fbxconv.h"
+#include "io_plugins/editor_texture_import_plugin.h"
+#include "io_plugins/editor_translation_import_plugin.h"
-#include "plugins/editor_preview_plugins.h"
-#include "editor_initialize_ssl.h"
#include "editor_audio_buses.h"
+#include "editor_initialize_ssl.h"
+#include "plugins/editor_preview_plugins.h"
#include "script_editor_debugger.h"
-EditorNode *EditorNode::singleton=NULL;
+EditorNode *EditorNode::singleton = NULL;
void EditorNode::_update_scene_tabs() {
bool show_rb = EditorSettings::get_singleton()->get("interface/show_script_in_scene_tabs");
scene_tabs->clear_tabs();
- Ref<Texture> script_icon = gui_base->get_icon("Script","EditorIcons");
- for(int i=0;i<editor_data.get_edited_scene_count();i++) {
+ Ref<Texture> script_icon = gui_base->get_icon("Script", "EditorIcons");
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
- String type=editor_data.get_scene_type(i);
+ String type = editor_data.get_scene_type(i);
Ref<Texture> icon;
- if (type!=String()) {
+ if (type != String()) {
- if (!gui_base->has_icon(type,"EditorIcons")) {
- type="Node";
+ if (!gui_base->has_icon(type, "EditorIcons")) {
+ type = "Node";
}
- icon=gui_base->get_icon(type,"EditorIcons");
-
+ icon = gui_base->get_icon(type, "EditorIcons");
}
-
-
int current = editor_data.get_edited_scene();
- bool unsaved = (i==current)?saved_version!=editor_data.get_undo_redo().get_version():editor_data.get_scene_version(i)!=0;
- scene_tabs->add_tab(editor_data.get_scene_title(i)+(unsaved?"(*)":""),icon);
+ bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0;
+ scene_tabs->add_tab(editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), icon);
if (show_rb && editor_data.get_scene_root_script(i).is_valid()) {
- scene_tabs->set_tab_right_button(i,script_icon);
+ scene_tabs->set_tab_right_button(i, script_icon);
}
-
}
scene_tabs->set_current_tab(editor_data.get_edited_scene());
scene_tabs->ensure_tab_visible(editor_data.get_edited_scene());
-
}
void EditorNode::_update_title() {
String appname = GlobalConfig::get_singleton()->get("application/name");
- String title = appname.empty()?String(VERSION_FULL_NAME):String(_MKSTR(VERSION_NAME) + String(" - ") + appname);
- String edited = editor_data.get_edited_scene_root()?editor_data.get_edited_scene_root()->get_filename():String();
+ String title = appname.empty() ? String(VERSION_FULL_NAME) : String(_MKSTR(VERSION_NAME) + String(" - ") + appname);
+ String edited = editor_data.get_edited_scene_root() ? editor_data.get_edited_scene_root()->get_filename() : String();
if (!edited.empty())
- title+=" - " + String(edited.get_file());
+ title += " - " + String(edited.get_file());
if (unsaved_cache)
- title+=" (*)";
+ title += " (*)";
OS::get_singleton()->set_window_title(title);
-
}
-void EditorNode::_unhandled_input(const InputEvent& p_event) {
+void EditorNode::_unhandled_input(const InputEvent &p_event) {
if (Node::get_viewport()->get_modal_stack_top())
return; //ignore because of modal window
-
- if (p_event.type==InputEvent::KEY && p_event.key.pressed && !p_event.key.echo && !gui_base->get_viewport()->gui_has_modal_stack()) {
-
+ if (p_event.type == InputEvent::KEY && p_event.key.pressed && !p_event.key.echo && !gui_base->get_viewport()->gui_has_modal_stack()) {
if (ED_IS_SHORTCUT("editor/next_tab", p_event)) {
int next_tab = editor_data.get_edited_scene() + 1;
@@ -199,7 +191,7 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) {
filesystem_dock->focus_on_filter();
}
- switch(p_event.key.scancode) {
+ switch (p_event.key.scancode) {
/*case KEY_F1:
if (!p_event.key.mod.shift && !p_event.key.mod.command)
@@ -208,38 +200,34 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) {
case KEY_F1:
if (!p_event.key.mod.shift && !p_event.key.mod.command)
_editor_select(EDITOR_2D);
- break;
+ break;
case KEY_F2:
if (!p_event.key.mod.shift && !p_event.key.mod.command)
_editor_select(EDITOR_3D);
- break;
+ break;
case KEY_F3:
if (!p_event.key.mod.shift && !p_event.key.mod.command)
_editor_select(EDITOR_SCRIPT);
- break;
- /* case KEY_F5: _menu_option_confirm((p_event.key.mod.control&&p_event.key.mod.shift)?RUN_PLAY_CUSTOM_SCENE:RUN_PLAY,true); break;
+ break;
+ /* case KEY_F5: _menu_option_confirm((p_event.key.mod.control&&p_event.key.mod.shift)?RUN_PLAY_CUSTOM_SCENE:RUN_PLAY,true); break;
case KEY_F6: _menu_option_confirm(RUN_PLAY_SCENE,true); break;
//case KEY_F7: _menu_option_confirm(RUN_PAUSE,true); break;
case KEY_F8: _menu_option_confirm(RUN_STOP,true); break;*/
-
}
-
}
}
-
-
void EditorNode::_notification(int p_what) {
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
editor_data.save_editor_external_data();
FileAccess::set_file_close_fail_notify_callback(NULL);
log->deinit(); // do not get messages anymore
}
- if (p_what==NOTIFICATION_PROCESS) {
+ if (p_what == NOTIFICATION_PROCESS) {
- //force the whole tree viewport
+//force the whole tree viewport
#if 0
{
Rect2 grect = scene_root_base->get_global_rect();
@@ -252,17 +240,17 @@ void EditorNode::_notification(int p_what) {
#endif
if (opening_prev && !confirmation->is_visible())
- opening_prev=false;
+ opening_prev = false;
- if (unsaved_cache != (saved_version!=editor_data.get_undo_redo().get_version())) {
+ if (unsaved_cache != (saved_version != editor_data.get_undo_redo().get_version())) {
- unsaved_cache = (saved_version!=editor_data.get_undo_redo().get_version());
+ unsaved_cache = (saved_version != editor_data.get_undo_redo().get_version());
_update_title();
}
- if (last_checked_version!=editor_data.get_undo_redo().get_version()) {
+ if (last_checked_version != editor_data.get_undo_redo().get_version()) {
_update_scene_tabs();
- last_checked_version=editor_data.get_undo_redo().get_version();
+ last_checked_version = editor_data.get_undo_redo().get_version();
}
//get_root_node()->set_rect(viewport->get_global_rect());
@@ -271,48 +259,46 @@ void EditorNode::_notification(int p_what) {
uint64_t frame = Engine::get_singleton()->get_frames_drawn();
uint32_t tick = OS::get_singleton()->get_ticks_msec();
- if (frame!=circle_step_frame && (tick-circle_step_msec)>(1000/8)) {
+ if (frame != circle_step_frame && (tick - circle_step_msec) > (1000 / 8)) {
circle_step++;
- if (circle_step>=8)
- circle_step=0;
+ if (circle_step >= 8)
+ circle_step = 0;
- circle_step_msec=tick;
- circle_step_frame=frame+1;
+ circle_step_msec = tick;
+ circle_step_frame = frame + 1;
// update the circle itself only when its enabled
- if (!update_menu->get_popup()->is_item_checked(3)){
- update_menu->set_icon(gui_base->get_icon("Progress"+itos(circle_step+1),"EditorIcons"));
+ if (!update_menu->get_popup()->is_item_checked(3)) {
+ update_menu->set_icon(gui_base->get_icon("Progress" + itos(circle_step + 1), "EditorIcons"));
}
}
editor_selection->update();
{
- uint32_t p32 = 0;//AudioServer::get_singleton()->read_output_peak()>>8;
+ uint32_t p32 = 0; //AudioServer::get_singleton()->read_output_peak()>>8;
- float peak = p32==0? -80 : Math::linear2db(p32 / 65535.0);
+ float peak = p32 == 0 ? -80 : Math::linear2db(p32 / 65535.0);
- if (peak<-80)
- peak=-80;
+ if (peak < -80)
+ peak = -80;
float vu = audio_vu->get_value();
if (peak > vu) {
audio_vu->set_value(peak);
} else {
- float new_vu = vu - get_process_delta_time()*70.0;
- if (new_vu<-80)
- new_vu=-80;
- if (new_vu !=-80 && vu !=-80)
+ float new_vu = vu - get_process_delta_time() * 70.0;
+ if (new_vu < -80)
+ new_vu = -80;
+ if (new_vu != -80 && vu != -80)
audio_vu->set_value(new_vu);
}
-
}
ResourceImporterTexture::get_singleton()->update_imports();
-
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
get_tree()->get_root()->set_disable_3d(true);
//MessageQueue::get_singleton()->push_call(this,"_get_scene_metadata");
@@ -320,28 +306,26 @@ void EditorNode::_notification(int p_what) {
get_tree()->get_root()->set_as_audio_listener(false);
get_tree()->get_root()->set_as_audio_listener_2d(false);
get_tree()->set_auto_accept_quit(false);
- get_tree()->connect("files_dropped",this,"_dropped_files");
- //VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport(),false);
+ get_tree()->connect("files_dropped", this, "_dropped_files");
+ //VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport(),false);
//import_monitor->scan_changes();
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
-
+ if (p_what == NOTIFICATION_EXIT_TREE) {
editor_data.clear_edited_scenes();
-
}
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
- VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(),true);
- VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(),true);
- VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(),true);
+ VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true);
+ VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true);
+ VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(), true);
_editor_select(EDITOR_3D);
_update_debug_options();
-/*
+ /*
if (defer_optimize!="") {
Error ok = save_optimized_copy(defer_optimize,defer_optimize_preset);
defer_optimize_preset="";
@@ -372,27 +356,26 @@ void EditorNode::_notification(int p_what) {
};
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- scene_tabs->set_tab_close_display_policy( (bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY) );
+ scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
}
-
}
void EditorNode::_fs_changed() {
- for(Set<FileDialog*>::Element *E=file_dialogs.front();E;E=E->next()) {
+ for (Set<FileDialog *>::Element *E = file_dialogs.front(); E; E = E->next()) {
E->get()->invalidate();
}
- for(Set<EditorFileDialog*>::Element *E=editor_file_dialogs.front();E;E=E->next()) {
+ for (Set<EditorFileDialog *>::Element *E = editor_file_dialogs.front(); E; E = E->next()) {
E->get()->invalidate();
}
- if (export_defer.platform!="") {
+ if (export_defer.platform != "") {
//project_export_settings->export_platform(export_defer.platform,export_defer.path,export_defer.debug,export_defer.password,true);
- export_defer.platform="";
+ export_defer.platform = "";
}
{
@@ -403,7 +386,7 @@ void EditorNode::_fs_changed() {
List<Ref<Resource> > cached;
ResourceCache::get_cached_resources(&cached);
//this should probably be done in a thread..
- for(List<Ref<Resource> >::Element *E=cached.front();E;E=E->next()) {
+ for (List<Ref<Resource> >::Element *E = cached.front(); E; E = E->next()) {
if (!E->get()->editor_can_reload_from_file())
continue;
@@ -412,12 +395,12 @@ void EditorNode::_fs_changed() {
if (!FileAccess::exists(E->get()->get_path()))
continue;
- if (E->get()->get_import_path()!=String()) {
+ if (E->get()->get_import_path() != String()) {
//imported resource
uint64_t mt = FileAccess::get_modified_time(E->get()->get_import_path());
- print_line("testing modified: "+E->get()->get_import_path()+" "+itos(mt)+" vs "+itos(E->get()->get_import_last_modified_time()));
+ print_line("testing modified: " + E->get()->get_import_path() + " " + itos(mt) + " vs " + itos(E->get()->get_import_last_modified_time()));
- if (mt!=E->get()->get_import_last_modified_time()) {
+ if (mt != E->get()->get_import_last_modified_time()) {
print_line("success");
changed.push_back(E->get());
}
@@ -425,7 +408,7 @@ void EditorNode::_fs_changed() {
} else {
uint64_t mt = FileAccess::get_modified_time(E->get()->get_path());
- if (mt!=E->get()->get_last_modified_time()) {
+ if (mt != E->get()->get_last_modified_time()) {
changed.push_back(E->get());
}
}
@@ -433,47 +416,39 @@ void EditorNode::_fs_changed() {
if (changed.size()) {
//EditorProgress ep("reload_res","Reload Modified Resources",changed.size());
- int idx=0;
- for(List<Ref<Resource> >::Element *E=changed.front();E;E=E->next()) {
+ int idx = 0;
+ for (List<Ref<Resource> >::Element *E = changed.front(); E; E = E->next()) {
//ep.step(E->get()->get_path(),idx++);
E->get()->reload_from_file();
}
}
-
-
}
}
-
void EditorNode::_sources_changed(bool p_exist) {
if (waiting_for_first_scan) {
- if (defer_load_scene!="") {
+ if (defer_load_scene != "") {
print_line("loading scene DEFERED");
load_scene(defer_load_scene);
- defer_load_scene="";
+ defer_load_scene = "";
}
- waiting_for_first_scan=false;
+ waiting_for_first_scan = false;
}
-
-
}
void EditorNode::_vp_resized() {
-
-
}
-void EditorNode::_rebuild_import_menu()
-{
- PopupMenu* p = import_menu->get_popup();
+void EditorNode::_rebuild_import_menu() {
+ PopupMenu *p = import_menu->get_popup();
p->clear();
- //p->add_item(TTR("Node From Scene"), FILE_IMPORT_SUBSCENE);
- //p->add_separator();
+//p->add_item(TTR("Node From Scene"), FILE_IMPORT_SUBSCENE);
+//p->add_separator();
#if 0
for (int i = 0; i < editor_import_export->get_import_plugin_count(); i++) {
p->add_item(editor_import_export->get_import_plugin(i)->get_visible_name(), IMPORT_PLUGIN_BASE + i);
@@ -487,21 +462,19 @@ void EditorNode::_node_renamed() {
property_editor->update_tree();
}
-
-Error EditorNode::load_resource(const String& p_scene) {
+Error EditorNode::load_resource(const String &p_scene) {
RES res = ResourceLoader::load(p_scene);
- ERR_FAIL_COND_V(!res.is_valid(),ERR_CANT_OPEN);
+ ERR_FAIL_COND_V(!res.is_valid(), ERR_CANT_OPEN);
edit_resource(res);
return OK;
}
+void EditorNode::edit_resource(const Ref<Resource> &p_resource) {
-void EditorNode::edit_resource(const Ref<Resource>& p_resource) {
-
- _resource_selected(p_resource,"");
+ _resource_selected(p_resource, "");
}
void EditorNode::edit_node(Node *p_node) {
@@ -509,213 +482,202 @@ void EditorNode::edit_node(Node *p_node) {
push_item(p_node);
}
-void EditorNode::open_resource(const String& p_type) {
-
+void EditorNode::open_resource(const String &p_type) {
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type(p_type,&extensions);
+ ResourceLoader::get_recognized_extensions_for_type(p_type, &extensions);
file->clear_filters();
- for(int i=0;i<extensions.size();i++) {
+ for (int i = 0; i < extensions.size(); i++) {
- file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+ file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
//file->set_current_path(current_path);
file->popup_centered_ratio();
- current_option=RESOURCE_LOAD;
+ current_option = RESOURCE_LOAD;
}
-
-void EditorNode::save_resource_in_path(const Ref<Resource>& p_resource,const String& p_path) {
+void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path) {
editor_data.apply_changes_in_editors();
- int flg=0;
+ int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
- flg|=ResourceSaver::FLAG_COMPRESS;
+ flg |= ResourceSaver::FLAG_COMPRESS;
/*
if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
*/
String path = GlobalConfig::get_singleton()->localize_path(p_path);
- Error err = ResourceSaver::save(path,p_resource,flg|ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
+ Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
- if (err!=OK) {
+ if (err != OK) {
accept->set_text(TTR("Error saving resource!"));
accept->popup_centered_minsize();
- return;
+ return;
}
//EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
- ((Resource*)p_resource.ptr())->set_path(path);
- emit_signal("resource_saved",p_resource);
-
+ ((Resource *)p_resource.ptr())->set_path(path);
+ emit_signal("resource_saved", p_resource);
}
-void EditorNode::save_resource(const Ref<Resource>& p_resource) {
+void EditorNode::save_resource(const Ref<Resource> &p_resource) {
if (p_resource->get_path().is_resource_file()) {
- save_resource_in_path(p_resource,p_resource->get_path());
+ save_resource_in_path(p_resource, p_resource->get_path());
} else {
save_resource_as(p_resource);
}
}
-void EditorNode::save_resource_as(const Ref<Resource>& p_resource,const String& p_at_path) {
+void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path) {
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
- current_option=RESOURCE_SAVE_AS;
+ current_option = RESOURCE_SAVE_AS;
List<String> extensions;
- Ref<PackedScene> sd = memnew( PackedScene );
- ResourceSaver::get_recognized_extensions(p_resource,&extensions);
+ Ref<PackedScene> sd = memnew(PackedScene);
+ ResourceSaver::get_recognized_extensions(p_resource, &extensions);
file->clear_filters();
List<String> preferred;
- for(int i=0;i<extensions.size();i++) {
+ for (int i = 0; i < extensions.size(); i++) {
- if (p_resource->is_class("Script") && (extensions[i]=="tres" || extensions[i]=="res" || extensions[i]=="xml")) {
+ if (p_resource->is_class("Script") && (extensions[i] == "tres" || extensions[i] == "res" || extensions[i] == "xml")) {
//this serves no purpose and confused people
continue;
}
- file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+ file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
preferred.push_back(extensions[i]);
}
//file->set_current_path(current_path);
- if (p_at_path!=String()) {
+ if (p_at_path != String()) {
file->set_current_dir(p_at_path);
if (p_resource->get_path().is_resource_file()) {
file->set_current_file(p_resource->get_path().get_file());
} else {
- if (extensions.size()) {
- file->set_current_file("new_"+p_resource->get_class().to_lower()+"."+preferred.front()->get().to_lower());
+ if (extensions.size()) {
+ file->set_current_file("new_" + p_resource->get_class().to_lower() + "." + preferred.front()->get().to_lower());
} else {
file->set_current_file(String());
}
}
- } else if (p_resource->get_path()!="") {
+ } else if (p_resource->get_path() != "") {
file->set_current_path(p_resource->get_path());
if (extensions.size()) {
- String ext=p_resource->get_path().get_extension().to_lower();
- if (extensions.find(ext)==NULL) {
- file->set_current_path(p_resource->get_path().replacen("."+ext,"."+extensions.front()->get()));
+ String ext = p_resource->get_path().get_extension().to_lower();
+ if (extensions.find(ext) == NULL) {
+ file->set_current_path(p_resource->get_path().replacen("." + ext, "." + extensions.front()->get()));
}
}
} else if (preferred.size()) {
String existing;
if (extensions.size()) {
- existing="new_"+p_resource->get_class().to_lower()+"."+preferred.front()->get().to_lower();
+ existing = "new_" + p_resource->get_class().to_lower() + "." + preferred.front()->get().to_lower();
}
file->set_current_path(existing);
-
}
file->popup_centered_ratio();
file->set_title(TTR("Save Resource As.."));
}
-
void EditorNode::_menu_option(int p_option) {
- _menu_option_confirm(p_option,false);
+ _menu_option_confirm(p_option, false);
}
void EditorNode::_menu_confirm_current() {
- _menu_option_confirm(current_option,true);
+ _menu_option_confirm(current_option, true);
}
-
-void EditorNode::_dialog_display_file_error(String p_file,Error p_error) {
-
+void EditorNode::_dialog_display_file_error(String p_file, Error p_error) {
if (p_error) {
- current_option=-1;
+ current_option = -1;
//accept->"()->hide();
accept->get_ok()->set_text(TTR("I see.."));
- switch(p_error) {
+ switch (p_error) {
case ERR_FILE_CANT_WRITE: {
- accept->set_text(TTR("Can't open file for writing:")+" "+p_file.get_extension());
+ accept->set_text(TTR("Can't open file for writing:") + " " + p_file.get_extension());
} break;
case ERR_FILE_UNRECOGNIZED: {
- accept->set_text(TTR("Requested file format unknown:")+" "+p_file.get_extension());
+ accept->set_text(TTR("Requested file format unknown:") + " " + p_file.get_extension());
} break;
default: {
accept->set_text(TTR("Error while saving."));
- }break;
+ } break;
}
accept->popup_centered_minsize();
}
-
}
-void EditorNode::_get_scene_metadata(const String& p_file) {
+void EditorNode::_get_scene_metadata(const String &p_file) {
Node *scene = editor_data.get_edited_scene_root();
if (!scene)
return;
- String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file()+"-editstate-"+p_file.md5_text()+".cfg");
+ String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg");
Ref<ConfigFile> cf;
cf.instance();
Error err = cf->load(path);
- if (err!=OK || !cf->has_section("editor_states"))
+ if (err != OK || !cf->has_section("editor_states"))
return; //must not exist
List<String> esl;
- cf->get_section_keys("editor_states",&esl);
+ cf->get_section_keys("editor_states", &esl);
Dictionary md;
- for (List<String>::Element *E=esl.front();E;E=E->next()) {
+ for (List<String>::Element *E = esl.front(); E; E = E->next()) {
- Variant st=cf->get_value("editor_states",E->get());
+ Variant st = cf->get_value("editor_states", E->get());
if (st.get_type()) {
- md[E->get()]=st;
+ md[E->get()] = st;
}
}
-
-
editor_data.set_editor_states(md);
-
}
-void EditorNode::_set_scene_metadata(const String& p_file, int p_idx) {
+void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) {
Node *scene = editor_data.get_edited_scene_root(p_idx);
if (!scene)
return;
- scene->set_meta("__editor_run_settings__",Variant()); //clear it (no point in keeping it)
- scene->set_meta("__editor_plugin_states__",Variant());
+ scene->set_meta("__editor_run_settings__", Variant()); //clear it (no point in keeping it)
+ scene->set_meta("__editor_plugin_states__", Variant());
- String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file()+"-editstate-"+p_file.md5_text()+".cfg");
+ String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg");
Ref<ConfigFile> cf;
cf.instance();
Dictionary md;
- if (p_idx<0 || editor_data.get_edited_scene()==p_idx) {
+ if (p_idx < 0 || editor_data.get_edited_scene() == p_idx) {
md = editor_data.get_editor_states();
} else {
md = editor_data.get_scene_editor_states(p_idx);
@@ -724,83 +686,76 @@ void EditorNode::_set_scene_metadata(const String& p_file, int p_idx) {
List<Variant> keys;
md.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()) {
- cf->set_value("editor_states",E->get(),md[E->get()]);
+ cf->set_value("editor_states", E->get(), md[E->get()]);
}
Error err = cf->save(path);
- ERR_FAIL_COND(err!=OK);
-
+ ERR_FAIL_COND(err != OK);
}
-
-bool EditorNode::_find_and_save_resource(RES res,Map<RES,bool>& processed,int32_t flags) {
+bool EditorNode::_find_and_save_resource(RES res, Map<RES, bool> &processed, int32_t flags) {
if (res.is_null())
return false;
- if (processed.has(res)) {
-
- return processed[res];
- }
+ if (processed.has(res)) {
+ return processed[res];
+ }
bool changed = res->is_edited();
res->set_edited(false);
- bool subchanged = _find_and_save_edited_subresources(res.ptr(),processed,flags);
+ bool subchanged = _find_and_save_edited_subresources(res.ptr(), processed, flags);
//print_line("checking if edited: "+res->get_type()+" :: "+res->get_name()+" :: "+res->get_path()+" :: "+itos(changed)+" :: SR "+itos(subchanged));
if (res->get_path().is_resource_file()) {
if (changed || subchanged) {
//save
- print_line("Also saving modified external resource: "+res->get_path());
- ResourceSaver::save(res->get_path(),res,flags);
-
+ print_line("Also saving modified external resource: " + res->get_path());
+ ResourceSaver::save(res->get_path(), res, flags);
}
- processed[res]=false; //because it's a file
+ processed[res] = false; //because it's a file
return false;
} else {
-
- processed[res]=changed;
+ processed[res] = changed;
return changed;
}
}
-bool EditorNode::_find_and_save_edited_subresources(Object *obj,Map<RES,bool>& processed,int32_t flags) {
+bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> &processed, int32_t flags) {
- bool ret_changed=false;
+ bool ret_changed = false;
List<PropertyInfo> pi;
obj->get_property_list(&pi);
- for (List<PropertyInfo>::Element *E=pi.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) {
- if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
-
-
- switch(E->get().type) {
+ switch (E->get().type) {
case Variant::OBJECT: {
RES res = obj->get(E->get().name);
- if (_find_and_save_resource(res,processed,flags))
- ret_changed=true;
+ if (_find_and_save_resource(res, processed, flags))
+ ret_changed = true;
} break;
case Variant::ARRAY: {
- Array varray= obj->get(E->get().name);
- int len=varray.size();
- for(int i=0;i<len;i++) {
+ Array varray = obj->get(E->get().name);
+ int len = varray.size();
+ for (int i = 0; i < len; i++) {
- Variant v=varray.get(i);
- RES res=v;
- if (_find_and_save_resource(res,processed,flags))
- ret_changed=true;
+ Variant v = varray.get(i);
+ RES res = v;
+ if (_find_and_save_resource(res, processed, flags))
+ ret_changed = true;
//_find_resources(v);
}
@@ -808,44 +763,40 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj,Map<RES,bool>& p
} break;
case Variant::DICTIONARY: {
-
- Dictionary d=obj->get(E->get().name);
+ Dictionary d = obj->get(E->get().name);
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()];
- RES res=v;
- if (_find_and_save_resource(res,processed,flags))
- ret_changed=true;
+ RES res = v;
+ if (_find_and_save_resource(res, processed, flags))
+ ret_changed = true;
}
} break;
default: {}
}
-
}
return ret_changed;
-
}
-void EditorNode::_save_edited_subresources(Node* scene,Map<RES,bool>& processed,int32_t flags) {
+void EditorNode::_save_edited_subresources(Node *scene, Map<RES, bool> &processed, int32_t flags) {
- _find_and_save_edited_subresources(scene,processed,flags);
+ _find_and_save_edited_subresources(scene, processed, flags);
- for(int i=0;i<scene->get_child_count();i++) {
+ for (int i = 0; i < scene->get_child_count(); i++) {
Node *n = scene->get_child(i);
- if (n->get_owner()!=editor_data.get_edited_scene_root())
+ if (n->get_owner() != editor_data.get_edited_scene_root())
continue;
- _save_edited_subresources(n,processed,flags);
+ _save_edited_subresources(n, processed, flags);
}
-
}
-void EditorNode::_find_node_types(Node* p_node, int&count_2d, int&count_3d) {
+void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) {
- if (p_node->is_class("Viewport") || (p_node!=editor_data.get_edited_scene_root() && p_node->get_owner()!=editor_data.get_edited_scene_root()))
+ if (p_node->is_class("Viewport") || (p_node != editor_data.get_edited_scene_root() && p_node->get_owner() != editor_data.get_edited_scene_root()))
return;
if (p_node->is_class("CanvasItem"))
@@ -853,46 +804,42 @@ void EditorNode::_find_node_types(Node* p_node, int&count_2d, int&count_3d) {
else if (p_node->is_class("Spatial"))
count_3d++;
- for(int i=0;i<p_node->get_child_count();i++)
- _find_node_types(p_node->get_child(i),count_2d,count_3d);
-
+ for (int i = 0; i < p_node->get_child_count(); i++)
+ _find_node_types(p_node->get_child(i), count_2d, count_3d);
}
-
void EditorNode::_save_scene_with_preview(String p_file) {
- int c2d=0;
- int c3d=0;
+ int c2d = 0;
+ int c3d = 0;
- EditorProgress save("save",TTR("Saving Scene"),4);
- save.step(TTR("Analyzing"),0);
- _find_node_types(editor_data.get_edited_scene_root(),c2d,c3d);
+ EditorProgress save("save", TTR("Saving Scene"), 4);
+ save.step(TTR("Analyzing"), 0);
+ _find_node_types(editor_data.get_edited_scene_root(), c2d, c3d);
RID viewport;
bool is2d;
- if (c3d<c2d) {
- viewport=scene_root->get_viewport_rid();
- is2d=true;
+ if (c3d < c2d) {
+ viewport = scene_root->get_viewport_rid();
+ is2d = true;
} else {
- viewport=SpatialEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_viewport_rid();
- is2d=false;
-
+ viewport = SpatialEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_viewport_rid();
+ is2d = false;
}
- save.step(TTR("Creating Thumbnail"),1);
+ save.step(TTR("Creating Thumbnail"), 1);
//current view?
- int screen =-1;
- for(int i=0;i<editor_table.size();i++) {
- if (editor_plugin_screen==editor_table[i]) {
- screen=i;
+ int screen = -1;
+ for (int i = 0; i < editor_table.size(); i++) {
+ if (editor_plugin_screen == editor_table[i]) {
+ screen = i;
break;
}
}
- _editor_select(is2d?EDITOR_2D:EDITOR_3D);
-
+ _editor_select(is2d ? EDITOR_2D : EDITOR_3D);
- save.step(TTR("Creating Thumbnail"),2);
- save.step(TTR("Creating Thumbnail"),3);
+ save.step(TTR("Creating Thumbnail"), 2);
+ save.step(TTR("Creating Thumbnail"), 3);
#if 0
Image img = VS::get_singleton()->viewport_texture(scree_capture(viewport);
int preview_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
@@ -926,22 +873,20 @@ void EditorNode::_save_scene_with_preview(String p_file) {
editor_data.get_edited_scene_import_metadata()->set_option("thumbnail",imgdata);
#endif
//tamanio tel thumbnail
- if (screen!=-1) {
+ if (screen != -1) {
_editor_select(screen);
}
- save.step(TTR("Saving Scene"),4);
+ save.step(TTR("Saving Scene"), 4);
_save_scene(p_file);
-
}
-
void EditorNode::_save_scene(String p_file, int idx) {
Node *scene = editor_data.get_edited_scene_root(idx);
if (!scene) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text("This operation can't be done without a tree root.");
@@ -951,8 +896,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
editor_data.apply_changes_in_editors();
- _set_scene_metadata(p_file,idx);
-
+ _set_scene_metadata(p_file, idx);
Ref<PackedScene> sdata;
@@ -961,7 +905,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
// we must update it, but also let the previous scene state go, as
// old version still work for referencing changes in instanced or inherited scenes
- sdata = Ref<PackedScene>( ResourceCache::get(p_file)->cast_to<PackedScene>() );
+ sdata = Ref<PackedScene>(ResourceCache::get(p_file)->cast_to<PackedScene>());
if (sdata.is_valid())
sdata->recreate_state();
else
@@ -971,10 +915,9 @@ void EditorNode::_save_scene(String p_file, int idx) {
}
Error err = sdata->pack(scene);
+ if (err != OK) {
- if (err!=OK) {
-
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Couldn't save scene. Likely dependencies (instances) couldn't be satisfied."));
@@ -982,41 +925,35 @@ void EditorNode::_save_scene(String p_file, int idx) {
return;
}
- int flg=0;
+ int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
- flg|=ResourceSaver::FLAG_COMPRESS;
+ flg |= ResourceSaver::FLAG_COMPRESS;
/*
if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
*/
- flg|=ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
-
+ flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
- err = ResourceSaver::save(p_file,sdata,flg);
- Map<RES,bool> processed;
- _save_edited_subresources(scene,processed,flg);
+ err = ResourceSaver::save(p_file, sdata, flg);
+ Map<RES, bool> processed;
+ _save_edited_subresources(scene, processed, flg);
editor_data.save_editor_external_data();
- if (err==OK) {
- scene->set_filename( GlobalConfig::get_singleton()->localize_path(p_file) );
+ if (err == OK) {
+ scene->set_filename(GlobalConfig::get_singleton()->localize_path(p_file));
//EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type());
if (idx < 0 || idx == editor_data.get_edited_scene())
set_current_version(editor_data.get_undo_redo().get_version());
else
- editor_data.set_edited_scene_version(0,idx);
+ editor_data.set_edited_scene_version(0, idx);
_update_title();
_update_scene_tabs();
} else {
- _dialog_display_file_error(p_file,err);
+ _dialog_display_file_error(p_file, err);
}
-
-
};
-
-
-
-void EditorNode::_import_action(const String& p_action) {
+void EditorNode::_import_action(const String &p_action) {
#if 0
import_confirmation->hide();
@@ -1113,65 +1050,58 @@ void EditorNode::_import(const String &p_file) {
saved_version=editor_data.get_undo_redo().get_version();
_update_title();
-
#endif
}
void EditorNode::_dialog_action(String p_file) {
-
- switch(current_option) {
+ switch (current_option) {
case RESOURCE_LOAD: {
RES res = ResourceLoader::load(p_file);
if (res.is_null()) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text("ok :(");
accept->set_text(TTR("Failed to load resource."));
return;
};
-
- push_item(res.operator->() );
+ push_item(res.operator->());
} break;
case FILE_NEW_INHERITED_SCENE: {
-
- load_scene(p_file,false,true);
+ load_scene(p_file, false, true);
} break;
case FILE_OPEN_SCENE: {
-
load_scene(p_file);
} break;
case SETTINGS_PICK_MAIN_SCENE: {
- GlobalConfig::get_singleton()->set("application/main_scene",p_file);
+ GlobalConfig::get_singleton()->set("application/main_scene", p_file);
GlobalConfig::get_singleton()->save();
//would be nice to show the project manager opened with the hilighted field..
} break;
case FILE_SAVE_OPTIMIZED: {
-
-
} break;
case FILE_RUN_SCRIPT: {
- Ref<Script> scr = ResourceLoader::load(p_file,"Script",true);
+ Ref<Script> scr = ResourceLoader::load(p_file, "Script", true);
if (scr.is_null()) {
- add_io_error("Script Failed to Load:\n"+p_file);
+ add_io_error("Script Failed to Load:\n" + p_file);
return;
}
if (!scr->is_tool()) {
- add_io_error("Script is not tool, will not be able to run:\n"+p_file);
+ add_io_error("Script is not tool, will not be able to run:\n" + p_file);
return;
}
- Ref<EditorScript> es = memnew( EditorScript );
+ Ref<EditorScript> es = memnew(EditorScript);
es->set_script(scr.get_ref_ptr());
es->set_editor(this);
es->_run();
@@ -1181,17 +1111,16 @@ void EditorNode::_dialog_action(String p_file) {
case FILE_SAVE_SCENE:
case FILE_SAVE_AS_SCENE: {
- if (file->get_mode()==EditorFileDialog::MODE_SAVE_FILE) {
+ if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
//_save_scene(p_file);
_save_scene_with_preview(p_file);
-
}
} break;
case FILE_SAVE_AND_RUN: {
- if (file->get_mode()==EditorFileDialog::MODE_SAVE_FILE) {
+ if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
//_save_scene(p_file);
_save_scene_with_preview(p_file);
@@ -1204,26 +1133,25 @@ void EditorNode::_dialog_action(String p_file) {
Ref<MeshLibrary> ml;
if (file_export_lib_merge->is_pressed() && FileAccess::exists(p_file)) {
- ml=ResourceLoader::load(p_file,"MeshLibrary");
+ ml = ResourceLoader::load(p_file, "MeshLibrary");
if (ml.is_null()) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Can't load MeshLibrary for merging!"));
accept->popup_centered_minsize();
return;
}
-
}
if (ml.is_null()) {
- ml = Ref<MeshLibrary>( memnew( MeshLibrary ));
+ ml = Ref<MeshLibrary>(memnew(MeshLibrary));
}
//MeshLibraryEditor::update_library_file(editor_data.get_edited_scene_root(),ml,true);
- Error err = ResourceSaver::save(p_file,ml);
+ Error err = ResourceSaver::save(p_file, ml);
if (err) {
accept->get_ok()->set_text(TTR("I see.."));
@@ -1232,17 +1160,16 @@ void EditorNode::_dialog_action(String p_file) {
return;
}
-
} break;
case FILE_EXPORT_TILESET: {
Ref<TileSet> ml;
if (FileAccess::exists(p_file)) {
- ml=ResourceLoader::load(p_file,"TileSet");
+ ml = ResourceLoader::load(p_file, "TileSet");
if (ml.is_null()) {
if (file_export_lib_merge->is_pressed()) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Can't load TileSet for merging!"));
@@ -1254,12 +1181,12 @@ void EditorNode::_dialog_action(String p_file) {
}
} else {
- ml = Ref<TileSet>( memnew( TileSet ));
+ ml = Ref<TileSet>(memnew(TileSet));
}
- TileSetEditor::update_library_file(editor_data.get_edited_scene_root(),ml,true);
+ TileSetEditor::update_library_file(editor_data.get_edited_scene_root(), ml, true);
- Error err = ResourceSaver::save(p_file,ml);
+ Error err = ResourceSaver::save(p_file, ml);
if (err) {
accept->get_ok()->set_text(TTR("I see.."));
@@ -1271,52 +1198,49 @@ void EditorNode::_dialog_action(String p_file) {
case SETTINGS_LOAD_EXPORT_TEMPLATES: {
- FileAccess *fa=NULL;
+ FileAccess *fa = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&fa);
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
if (!pkg) {
- current_option=-1;
+ current_option = -1;
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Can't open export templates zip."));
accept->popup_centered_minsize();
return;
-
}
int ret = unzGoToFirstFile(pkg);
- int fc=0; //count them
+ int fc = 0; //count them
- while(ret==UNZ_OK) {
+ while (ret == UNZ_OK) {
fc++;
ret = unzGoToNextFile(pkg);
-
}
ret = unzGoToFirstFile(pkg);
- EditorProgress p("ltask",TTR("Loading Export Templates"),fc);
+ EditorProgress p("ltask", TTR("Loading Export Templates"), fc);
- fc=0;
+ fc = 0;
- while(ret==UNZ_OK) {
+ while (ret == UNZ_OK) {
//get filename
unz_file_info info;
char fname[16384];
- ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0);
-
+ ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
- String file=fname;
+ String file = fname;
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
//read
ret = unzOpenCurrentFile(pkg);
- ret = unzReadCurrentFile(pkg,data.ptr(),data.size());
+ ret = unzReadCurrentFile(pkg, data.ptr(), data.size());
unzCloseCurrentFile(pkg);
print_line(fname);
@@ -1326,14 +1250,14 @@ void EditorNode::_dialog_action(String p_file) {
}
*/
- file=file.get_file();
+ file = file.get_file();
- p.step(TTR("Importing:")+" "+file,fc);
+ p.step(TTR("Importing:") + " " + file, fc);
- FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_settings_path()+"/templates/"+file,FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_settings_path() + "/templates/" + file, FileAccess::WRITE);
ERR_CONTINUE(!f);
- f->store_buffer(data.ptr(),data.size());
+ f->store_buffer(data.ptr(), data.size());
memdelete(f);
@@ -1348,15 +1272,14 @@ void EditorNode::_dialog_action(String p_file) {
case RESOURCE_SAVE:
case RESOURCE_SAVE_AS: {
-
uint32_t current = editor_history.get_current();
- Object *current_obj = current>0 ? ObjectDB::get_instance(current) : NULL;
+ Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj->cast_to<Resource>())
RES current_res = RES(current_obj->cast_to<Resource>());
- save_resource_in_path(current_res,p_file);
+ save_resource_in_path(current_res, p_file);
} break;
case SETTINGS_LAYOUT_SAVE: {
@@ -1368,9 +1291,9 @@ void EditorNode::_dialog_action(String p_file) {
config.instance();
Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
- if (err==ERR_CANT_OPEN) {
+ if (err == ERR_CANT_OPEN) {
config.instance(); // new config
- } else if (err!=OK) {
+ } else if (err != OK) {
show_warning(TTR("Error trying to save layout!"));
return;
}
@@ -1382,7 +1305,7 @@ void EditorNode::_dialog_action(String p_file) {
layout_dialog->hide();
_update_layouts_menu();
- if (p_file=="Default") {
+ if (p_file == "Default") {
show_warning(TTR("Default editor layout overridden."));
}
@@ -1396,7 +1319,7 @@ void EditorNode::_dialog_action(String p_file) {
config.instance();
Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
- if (err!=OK || !config->has_section(p_file)) {
+ if (err != OK || !config->has_section(p_file)) {
show_warning(TTR("Layout name not found!"));
return;
}
@@ -1404,7 +1327,7 @@ void EditorNode::_dialog_action(String p_file) {
// erase
List<String> keys;
config->get_section_keys(p_file, &keys);
- for (List<String>::Element *E=keys.front();E;E=E->next()) {
+ for (List<String>::Element *E = keys.front(); E; E = E->next()) {
config->set_value(p_file, E->get(), Variant());
}
@@ -1413,14 +1336,14 @@ void EditorNode::_dialog_action(String p_file) {
layout_dialog->hide();
_update_layouts_menu();
- if (p_file=="Default") {
+ if (p_file == "Default") {
show_warning(TTR("Restored default layout to base settings."));
}
} break;
default: { //save scene?
- if (file->get_mode()==EditorFileDialog::MODE_SAVE_FILE) {
+ if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) {
//_save_scene(p_file);
_save_scene_with_preview(p_file);
@@ -1430,10 +1353,7 @@ void EditorNode::_dialog_action(String p_file) {
}
}
-
-
-void EditorNode::push_item(Object *p_object,const String& p_property) {
-
+void EditorNode::push_item(Object *p_object, const String &p_property) {
if (!p_object) {
property_editor->edit(NULL);
@@ -1443,23 +1363,22 @@ void EditorNode::push_item(Object *p_object,const String& p_property) {
}
uint32_t id = p_object->get_instance_ID();
- if (id!=editor_history.get_current()) {
+ if (id != editor_history.get_current()) {
- if (p_property=="")
+ if (p_property == "")
editor_history.add_object(id);
else
- editor_history.add_object(id,p_property);
+ editor_history.add_object(id, p_property);
}
_edit_current();
-
}
void EditorNode::_select_history(int p_idx) {
//push it to the top, it is not correct, but it's more useful
- ObjectID id=editor_history.get_history_obj(p_idx);
- Object* obj=ObjectDB::get_instance(id);
+ ObjectID id = editor_history.get_history_obj(p_idx);
+ Object *obj = ObjectDB::get_instance(id);
if (!obj)
return;
push_item(obj);
@@ -1467,19 +1386,18 @@ void EditorNode::_select_history(int p_idx) {
void EditorNode::_prepare_history() {
- int history_to = MAX(0,editor_history.get_history_len()-25);
+ int history_to = MAX(0, editor_history.get_history_len() - 25);
editor_history_menu->get_popup()->clear();
- Ref<Texture> base_icon = gui_base->get_icon("Object","EditorIcons");
+ Ref<Texture> base_icon = gui_base->get_icon("Object", "EditorIcons");
Set<ObjectID> already;
- for(int i=editor_history.get_history_len()-1;i>=history_to;i--) {
+ for (int i = editor_history.get_history_len() - 1; i >= history_to; i--) {
-
- ObjectID id=editor_history.get_history_obj(i);
- Object* obj=ObjectDB::get_instance(id);
+ ObjectID id = editor_history.get_history_obj(i);
+ Object *obj = ObjectDB::get_instance(id);
if (!obj || already.has(id)) {
- if (history_to>0) {
+ if (history_to > 0) {
history_to--;
}
continue;
@@ -1487,32 +1405,32 @@ void EditorNode::_prepare_history() {
already.insert(id);
- Ref<Texture> icon = gui_base->get_icon("Object","EditorIcons");
- if (gui_base->has_icon(obj->get_class(),"EditorIcons"))
- icon=gui_base->get_icon(obj->get_class(),"EditorIcons");
+ Ref<Texture> icon = gui_base->get_icon("Object", "EditorIcons");
+ if (gui_base->has_icon(obj->get_class(), "EditorIcons"))
+ icon = gui_base->get_icon(obj->get_class(), "EditorIcons");
else
- icon=base_icon;
+ icon = base_icon;
String text;
if (obj->cast_to<Resource>()) {
- Resource *r=obj->cast_to<Resource>();
+ Resource *r = obj->cast_to<Resource>();
if (r->get_path().is_resource_file())
- text=r->get_path().get_file();
- else if (r->get_name()!=String()) {
- text=r->get_name();
+ text = r->get_path().get_file();
+ else if (r->get_name() != String()) {
+ text = r->get_name();
} else {
- text=r->get_class();
+ text = r->get_class();
}
} else if (obj->cast_to<Node>()) {
- text=obj->cast_to<Node>()->get_name();
+ text = obj->cast_to<Node>()->get_name();
} else {
- text=obj->get_class();
+ text = obj->get_class();
}
- if (i==editor_history.get_history_pos()) {
- text="["+text+"]";
+ if (i == editor_history.get_history_pos()) {
+ text = "[" + text + "]";
}
- editor_history_menu->get_popup()->add_icon_item(icon,text,i);
+ editor_history_menu->get_popup()->add_icon_item(icon, text, i);
}
}
@@ -1520,19 +1438,16 @@ void EditorNode::_property_editor_forward() {
if (editor_history.next())
_edit_current();
-
}
void EditorNode::_property_editor_back() {
if (editor_history.previous())
_edit_current();
-
}
-
void EditorNode::_imported(Node *p_node) {
-/*
+ /*
Node *scene = editor_data.get_edited_scene_root();
add_edited_scene(p_node);
@@ -1542,11 +1457,8 @@ void EditorNode::_imported(Node *p_node) {
memdelete(scene);
}
*/
-
-
}
-
void EditorNode::_hide_top_editors() {
_display_top_editors(false);
@@ -1558,32 +1470,29 @@ void EditorNode::_display_top_editors(bool p_display) {
editor_plugins_over->make_visible(p_display);
}
-void EditorNode::_set_top_editors(Vector<EditorPlugin*> p_editor_plugins_over) {
+void EditorNode::_set_top_editors(Vector<EditorPlugin *> p_editor_plugins_over) {
editor_plugins_over->set_plugins_list(p_editor_plugins_over);
}
-void EditorNode::_set_editing_top_editors(Object* p_current_object) {
+void EditorNode::_set_editing_top_editors(Object *p_current_object) {
editor_plugins_over->edit(p_current_object);
}
-
-
void EditorNode::_edit_current() {
uint32_t current = editor_history.get_current();
- Object *current_obj = current>0 ? ObjectDB::get_instance(current) : NULL;
+ Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
- property_back->set_disabled( editor_history.is_at_begining() );
- property_forward->set_disabled( editor_history.is_at_end() );
+ property_back->set_disabled(editor_history.is_at_begining());
+ property_forward->set_disabled(editor_history.is_at_end());
- this->current=current_obj;
+ this->current = current_obj;
editor_path->update_path();
-
if (!current_obj) {
scene_tree_dock->set_selected(NULL);
- property_editor->edit( NULL );
+ property_editor->edit(NULL);
node_dock->set_node(NULL);
object_menu->set_disabled(true);
@@ -1600,29 +1509,24 @@ void EditorNode::_edit_current() {
if (is_resource) {
-
Resource *current_res = current_obj->cast_to<Resource>();
ERR_FAIL_COND(!current_res);
scene_tree_dock->set_selected(NULL);
- property_editor->edit( current_res );
+ property_editor->edit(current_res);
node_dock->set_node(NULL);
object_menu->set_disabled(false);
//resources_dock->add_resource(Ref<Resource>(current_res));
-
//top_pallete->set_current_tab(1);
} else if (is_node) {
- Node * current_node = current_obj->cast_to<Node>();
+ Node *current_node = current_obj->cast_to<Node>();
ERR_FAIL_COND(!current_node);
ERR_FAIL_COND(!current_node->is_inside_tree());
-
-
-
- property_editor->edit( current_node );
- node_dock->set_node( current_node );
+ property_editor->edit(current_node);
+ node_dock->set_node(current_node);
scene_tree_dock->set_selected(current_node);
object_menu->get_popup()->clear();
@@ -1630,40 +1534,37 @@ void EditorNode::_edit_current() {
} else {
- property_editor->edit( current_obj );
+ property_editor->edit(current_obj);
node_dock->set_node(NULL);
//scene_tree_dock->set_selected(current_node);
//object_menu->get_popup()->clear();
-
}
/* Take care of PLUGIN EDITOR */
-
EditorPlugin *main_plugin = editor_data.get_editor(current_obj);
if (main_plugin) {
// special case if use of external editor is true
- if (main_plugin->get_name() == "Script" && bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))){
+ if (main_plugin->get_name() == "Script" && bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
main_plugin->edit(current_obj);
}
- else if (main_plugin!=editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) {
+ else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) {
// update screen main_plugin
if (!changing_scene) {
if (editor_plugin_screen)
editor_plugin_screen->make_visible(false);
- editor_plugin_screen=main_plugin;
+ editor_plugin_screen = main_plugin;
editor_plugin_screen->edit(current_obj);
editor_plugin_screen->make_visible(true);
+ for (int i = 0; i < editor_table.size(); i++) {
- for(int i=0;i<editor_table.size();i++) {
-
- main_editor_buttons[i]->set_pressed(editor_table[i]==main_plugin);
+ main_editor_buttons[i]->set_pressed(editor_table[i] == main_plugin);
}
}
@@ -1671,10 +1572,9 @@ void EditorNode::_edit_current() {
editor_plugin_screen->edit(current_obj);
}
-
}
- Vector<EditorPlugin*> sub_plugins = editor_data.get_subeditors(current_obj);
+ Vector<EditorPlugin *> sub_plugins = editor_data.get_subeditors(current_obj);
if (!sub_plugins.empty()) {
_display_top_editors(false);
@@ -1686,9 +1586,8 @@ void EditorNode::_edit_current() {
} else if (!editor_plugins_over->get_plugins_list().empty()) {
_hide_top_editors();
-
}
-/*
+ /*
if (!plugin || plugin->has_main_screen()) {
// remove the OVER plugin if exists
if (editor_plugin_over)
@@ -1700,52 +1599,50 @@ void EditorNode::_edit_current() {
object_menu->set_disabled(false);
- PopupMenu *p=object_menu->get_popup();
+ PopupMenu *p = object_menu->get_popup();
p->clear();
- p->add_shortcut(ED_SHORTCUT("property_editor/copy_params",TTR("Copy Params")),OBJECT_COPY_PARAMS);
- p->add_shortcut(ED_SHORTCUT("property_editor/paste_params",TTR("Paste Params")),OBJECT_PASTE_PARAMS);
+ p->add_shortcut(ED_SHORTCUT("property_editor/copy_params", TTR("Copy Params")), OBJECT_COPY_PARAMS);
+ p->add_shortcut(ED_SHORTCUT("property_editor/paste_params", TTR("Paste Params")), OBJECT_PASTE_PARAMS);
p->add_separator();
- p->add_shortcut(ED_SHORTCUT("property_editor/paste_resource",TTR("Paste Resource")),RESOURCE_PASTE);
+ p->add_shortcut(ED_SHORTCUT("property_editor/paste_resource", TTR("Paste Resource")), RESOURCE_PASTE);
if (is_resource) {
- p->add_shortcut(ED_SHORTCUT("property_editor/copy_resource",TTR("Copy Resource")),RESOURCE_COPY);
- p->add_shortcut(ED_SHORTCUT("property_editor/unref_resource",TTR("Make Built-In")),RESOURCE_UNREF);
+ p->add_shortcut(ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY);
+ p->add_shortcut(ED_SHORTCUT("property_editor/unref_resource", TTR("Make Built-In")), RESOURCE_UNREF);
}
if (is_resource || is_node) {
p->add_separator();
- p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique",TTR("Make Sub-Resources Unique")),OBJECT_UNIQUE_RESOURCES);
+ p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique", TTR("Make Sub-Resources Unique")), OBJECT_UNIQUE_RESOURCES);
p->add_separator();
- p->add_icon_shortcut(gui_base->get_icon("Help","EditorIcons"),ED_SHORTCUT("property_editor/open_help",TTR("Open in Help")),OBJECT_REQUEST_HELP);
+ p->add_icon_shortcut(gui_base->get_icon("Help", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP);
}
List<MethodInfo> methods;
current_obj->get_method_list(&methods);
-
if (!methods.empty()) {
- bool found=false;
- List<MethodInfo>::Element *I=methods.front();
- int i=0;
- while(I) {
+ bool found = false;
+ List<MethodInfo>::Element *I = methods.front();
+ int i = 0;
+ while (I) {
- if (I->get().flags&METHOD_FLAG_EDITOR) {
+ if (I->get().flags & METHOD_FLAG_EDITOR) {
if (!found) {
p->add_separator();
- found=true;
+ found = true;
}
- p->add_item(I->get().name.capitalize(),OBJECT_METHOD_BASE+i);
+ p->add_item(I->get().name.capitalize(), OBJECT_METHOD_BASE + i);
}
i++;
- I=I->next();
+ I = I->next();
}
}
//p->add_separator();
//p->add_item("All Methods",OBJECT_CALL_METHOD);
-
update_keying();
}
@@ -1757,27 +1654,23 @@ void EditorNode::_resource_created() {
Resource *r = c->cast_to<Resource>();
ERR_FAIL_COND(!r);
- REF res( r );
+ REF res(r);
push_item(c);
-
}
-void EditorNode::_resource_selected(const RES& p_res,const String& p_property) {
-
+void EditorNode::_resource_selected(const RES &p_res, const String &p_property) {
if (p_res.is_null())
return;
- RES r=p_res;
- push_item(r.operator->(),p_property);
-
+ RES r = p_res;
+ push_item(r.operator->(), p_property);
}
+void EditorNode::_run(bool p_current, const String &p_custom) {
-void EditorNode::_run(bool p_current,const String& p_custom) {
-
- if (editor_run.get_status()==EditorRun::STATUS_PLAY) {
+ if (editor_run.get_status() == EditorRun::STATUS_PLAY) {
play_button->set_pressed(!_playing_edited);
play_scene_button->set_pressed(_playing_edited);
@@ -1785,24 +1678,23 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
}
play_button->set_pressed(false);
- play_button->set_icon(gui_base->get_icon("MainPlay","EditorIcons"));
+ play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons"));
//pause_button->set_pressed(false);
play_scene_button->set_pressed(false);
- play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons"));
+ play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
play_custom_scene_button->set_pressed(false);
- play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom","EditorIcons"));
+ play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
String main_scene;
String run_filename;
String args;
-
- if (p_current || (editor_data.get_edited_scene_root() && p_custom==editor_data.get_edited_scene_root()->get_filename())) {
+ if (p_current || (editor_data.get_edited_scene_root() && p_custom == editor_data.get_edited_scene_root()->get_filename())) {
Node *scene = editor_data.get_edited_scene_root();
if (!scene) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("There is no defined scene to run."));
@@ -1810,27 +1702,26 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
return;
}
- if (scene->get_filename()=="") {
- current_option=-1;
+ if (scene->get_filename() == "") {
+ current_option = -1;
//accept->get_cancel()->hide();
/**/
_menu_option_confirm(FILE_SAVE_BEFORE_RUN, false);
return;
-
}
- run_filename=scene->get_filename();
- } else if (p_custom!="") {
+ run_filename = scene->get_filename();
+ } else if (p_custom != "") {
run_filename = p_custom;
}
- if (run_filename=="") {
+ if (run_filename == "") {
//evidently, run the scene
- main_scene=GLOBAL_DEF("application/main_scene","");
- if (main_scene=="") {
+ main_scene = GLOBAL_DEF("application/main_scene", "");
+ if (main_scene == "") {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in later in \"Project Settings\" under the 'application' category."));
pick_main_scene->popup_centered_minsize();
@@ -1839,28 +1730,24 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
if (!FileAccess::exists(main_scene)) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
pick_main_scene->popup_centered_minsize();
return;
-
}
- if (ResourceLoader::get_resource_type(main_scene)!="PackedScene") {
+ if (ResourceLoader::get_resource_type(main_scene) != "PackedScene") {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
pick_main_scene->popup_centered_minsize();
return;
-
}
-
}
-
- if (bool(EDITOR_DEF("run/auto_save/save_before_running",true))) {
+ if (bool(EDITOR_DEF("run/auto_save/save_before_running", true))) {
if (unsaved_cache) {
@@ -1868,9 +1755,9 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
if (scene) { //only autosave if there is a scene obviously
- if (scene->get_filename()=="") {
+ if (scene->get_filename() == "") {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Current scene was never saved, please save it prior to running."));
@@ -1899,34 +1786,32 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
args = GlobalConfig::get_singleton()->get("editor/main_run_args");
- Error error = editor_run.run(run_filename,args,breakpoints);
+ Error error = editor_run.run(run_filename, args, breakpoints);
- if (error!=OK) {
+ if (error != OK) {
- current_option=-1;
+ current_option = -1;
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Could not start subprocess!"));
accept->popup_centered_minsize();
return;
-
}
emit_signal("play_pressed");
if (p_current) {
play_scene_button->set_pressed(true);
- play_scene_button->set_icon(gui_base->get_icon("Reload","EditorIcons"));
- } else if (p_custom!="") {
- run_custom_filename=p_custom;
+ play_scene_button->set_icon(gui_base->get_icon("Reload", "EditorIcons"));
+ } else if (p_custom != "") {
+ run_custom_filename = p_custom;
play_custom_scene_button->set_pressed(true);
- play_custom_scene_button->set_icon(gui_base->get_icon("Reload","EditorIcons"));
+ play_custom_scene_button->set_icon(gui_base->get_icon("Reload", "EditorIcons"));
} else {
play_button->set_pressed(true);
- play_button->set_icon(gui_base->get_icon("Reload","EditorIcons"));
+ play_button->set_icon(gui_base->get_icon("Reload", "EditorIcons"));
}
- _playing_edited=p_current;
-
+ _playing_edited = p_current;
}
void EditorNode::_cleanup_scene() {
@@ -1970,14 +1855,13 @@ void EditorNode::_cleanup_scene() {
#endif
}
-void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
+void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
//print_line("option "+itos(p_option)+" confirm "+itos(p_confirmed));
if (!p_confirmed) //this may be a hack..
- current_option=(MenuOptions)p_option;
+ current_option = (MenuOptions)p_option;
-
- switch( p_option ) {
+ switch (p_option) {
case FILE_NEW_SCENE: {
// TODO: Drop such obsolete commented code
@@ -1990,37 +1874,33 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
break;
}*/
-
int idx = editor_data.add_edited_scene(-1);
_scene_tab_changed(idx);
editor_data.clear_editor_states();
//_cleanup_scene();
-
} break;
case FILE_NEW_INHERITED_SCENE:
case FILE_OPEN_SCENE: {
-
//print_tree();
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
//not for now?
List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions);
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
file->clear_filters();
- for(int i=0;i<extensions.size();i++) {
+ for (int i = 0; i < extensions.size(); i++) {
- file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+ file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
-
//file->set_current_path(current_path);
Node *scene = editor_data.get_edited_scene_root();
if (scene) {
file->set_current_path(scene->get_filename());
};
- file->set_title(p_option==FILE_OPEN_SCENE?TTR("Open Scene"):TTR("Open Base Scene"));
+ file->set_title(p_option == FILE_OPEN_SCENE ? TTR("Open Scene") : TTR("Open Base Scene"));
file->popup_centered_ratio();
} break;
@@ -2032,7 +1912,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case FILE_QUICK_OPEN_SCRIPT: {
-
quick_open->popup("Script", true);
quick_open->set_title(TTR("Quick Open Script.."));
@@ -2045,7 +1924,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (previous_scenes.empty())
break;
- opening_prev=true;
+ opening_prev = true;
open_request(previous_scenes.back()->get());
} break;
@@ -2061,8 +1940,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
_remove_edited_scene();
-
-
} break;
case SCENE_TAB_CLOSE: {
_remove_scene(tab_closing);
@@ -2071,9 +1948,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case FILE_SAVE_SCENE: {
-
Node *scene = editor_data.get_edited_scene_root();
- if (scene && scene->get_filename()!="") {
+ if (scene && scene->get_filename() != "") {
// save in background if in the script editor
if (_get_current_main_editor() == EDITOR_SCRIPT) {
@@ -2091,7 +1967,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (!scene) {
- current_option=-1;
+ current_option = -1;
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text("This operation can't be done without a tree root.");
@@ -2101,23 +1977,22 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
-
List<String> extensions;
- Ref<PackedScene> sd = memnew( PackedScene );
- ResourceSaver::get_recognized_extensions(sd,&extensions);
+ Ref<PackedScene> sd = memnew(PackedScene);
+ ResourceSaver::get_recognized_extensions(sd, &extensions);
file->clear_filters();
- for(int i=0;i<extensions.size();i++) {
+ for (int i = 0; i < extensions.size(); i++) {
- file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+ file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
//file->set_current_path(current_path);
- if (scene->get_filename()!="") {
+ if (scene->get_filename() != "") {
file->set_current_path(scene->get_filename());
if (extensions.size()) {
- String ext=scene->get_filename().get_extension().to_lower();
- if (extensions.find(ext)==NULL) {
- file->set_current_path(scene->get_filename().replacen("."+ext,"."+extensions.front()->get()));
+ String ext = scene->get_filename().get_extension().to_lower();
+ if (extensions.find(ext) == NULL) {
+ file->set_current_path(scene->get_filename().replacen("." + ext, "." + extensions.front()->get()));
}
}
} else {
@@ -2125,10 +2000,9 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
String existing;
if (extensions.size()) {
String root_name(get_edited_scene()->get_name());
- existing=root_name+"."+extensions.front()->get().to_lower();
+ existing = root_name + "." + extensions.front()->get().to_lower();
}
file->set_current_path(existing);
-
}
file->popup_centered_ratio();
file->set_title(TTR("Save Scene As.."));
@@ -2138,14 +2012,14 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case FILE_SAVE_ALL_SCENES: {
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
Node *scene = editor_data.get_edited_scene_root(i);
- if (scene && scene->get_filename()!="") {
+ if (scene && scene->get_filename() != "") {
// save in background if in the script editor
if (i != editor_data.get_edited_scene() || _get_current_main_editor() == EDITOR_SCRIPT) {
_save_scene(scene->get_filename(), i);
} else {
_save_scene_with_preview(scene->get_filename());
}
- }// else: ignore new scenes
+ } // else: ignore new scenes
}
} break;
case FILE_SAVE_BEFORE_RUN: {
@@ -2207,7 +2081,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (!editor_data.get_edited_scene_root()) {
- current_option=-1;
+ current_option = -1;
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text("This operation can't be done without a scene.");
@@ -2216,11 +2090,11 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
}
List<String> extensions;
- Ref<MeshLibrary> ml( memnew( MeshLibrary) );
- ResourceSaver::get_recognized_extensions(ml,&extensions);
+ Ref<MeshLibrary> ml(memnew(MeshLibrary));
+ ResourceSaver::get_recognized_extensions(ml, &extensions);
file_export_lib->clear_filters();
- for(List<String>::Element *E=extensions.front();E;E=E->next()) {
- file_export_lib->add_filter("*."+E->get());
+ for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
+ file_export_lib->add_filter("*." + E->get());
}
file_export_lib->popup_centered_ratio();
@@ -2230,11 +2104,11 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case FILE_EXPORT_TILESET: {
List<String> extensions;
- Ref<TileSet> ml( memnew( TileSet) );
- ResourceSaver::get_recognized_extensions(ml,&extensions);
+ Ref<TileSet> ml(memnew(TileSet));
+ ResourceSaver::get_recognized_extensions(ml, &extensions);
file_export_lib->clear_filters();
- for(List<String>::Element *E=extensions.front();E;E=E->next()) {
- file_export_lib->add_filter("*."+E->get());
+ for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
+ file_export_lib->add_filter("*." + E->get());
}
file_export_lib->popup_centered_ratio();
@@ -2252,7 +2126,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (!editor_data.get_edited_scene_root()) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text("This operation can't be done without a selected node.");
@@ -2266,19 +2140,17 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case FILE_QUIT: {
-
if (!p_confirmed) {
confirmation->get_ok()->set_text(TTR("Quit"));
//confirmation->get_cancel()->show();
confirmation->set_text(TTR("Exit the editor?"));
- confirmation->popup_centered(Size2(180,70)*EDSCALE);
+ confirmation->popup_centered(Size2(180, 70) * EDSCALE);
break;
}
-
- _menu_option_confirm(RUN_STOP,true);
- exiting=true;
+ _menu_option_confirm(RUN_STOP, true);
+ exiting = true;
get_tree()->quit();
} break;
@@ -2291,42 +2163,39 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
confirmation->set_text(TTR("Current scene not saved. Open anyway?"));
confirmation->popup_centered_minsize();
break;
-
}
- bool oprev=opening_prev;
+ bool oprev = opening_prev;
Error err = load_scene(external_file);
if (err == OK && oprev) {
previous_scenes.pop_back();
- opening_prev=false;
+ opening_prev = false;
}
} break;
case EDIT_UNDO: {
-
-
- if (Input::get_singleton()->get_mouse_button_mask()&0x7) {
+ if (Input::get_singleton()->get_mouse_button_mask() & 0x7) {
print_line("no because state");
break; // can't undo while mouse buttons are pressed
}
- String action = editor_data.get_undo_redo().get_current_action_name();
- if (action!="")
- log->add_message("UNDO: "+action);
+ String action = editor_data.get_undo_redo().get_current_action_name();
+ if (action != "")
+ log->add_message("UNDO: " + action);
editor_data.get_undo_redo().undo();
} break;
case EDIT_REDO: {
- if (Input::get_singleton()->get_mouse_button_mask()&0x7)
+ if (Input::get_singleton()->get_mouse_button_mask() & 0x7)
break; // can't redo while mouse buttons are pressed
editor_data.get_undo_redo().redo();
- String action = editor_data.get_undo_redo().get_current_action_name();
- if (action!="")
- log->add_message("REDO: "+action);
+ String action = editor_data.get_undo_redo().get_current_action_name();
+ if (action != "")
+ log->add_message("REDO: " + action);
} break;
case TOOLS_ORPHAN_RESOURCES: {
@@ -2343,7 +2212,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
String filename = scene->get_filename();
- if (filename==String()) {
+ if (filename == String()) {
show_warning(TTR("Can't reload a scene that was never saved."));
break;
}
@@ -2355,7 +2224,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
break;
}
-
int cur_idx = editor_data.get_edited_scene();
_remove_edited_scene();
Error err = load_scene(filename);
@@ -2429,9 +2297,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case RESOURCE_SAVE: {
-
uint32_t current = editor_history.get_current();
- Object *current_obj = current>0 ? ObjectDB::get_instance(current) : NULL;
+ Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj->cast_to<Resource>())
@@ -2443,7 +2310,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case RESOURCE_SAVE_AS: {
uint32_t current = editor_history.get_current();
- Object *current_obj = current>0 ? ObjectDB::get_instance(current) : NULL;
+ Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj->cast_to<Resource>())
@@ -2455,7 +2322,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case RESOURCE_UNREF: {
uint32_t current = editor_history.get_current();
- Object *current_obj = current>0 ? ObjectDB::get_instance(current) : NULL;
+ Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj->cast_to<Resource>())
@@ -2466,7 +2333,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case RESOURCE_COPY: {
uint32_t current = editor_history.get_current();
- Object *current_obj = current>0 ? ObjectDB::get_instance(current) : NULL;
+ Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL;
ERR_FAIL_COND(!current_obj->cast_to<Resource>())
@@ -2479,7 +2346,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
RES r = EditorSettings::get_singleton()->get_resource_clipboard();
if (r.is_valid()) {
- push_item(EditorSettings::get_singleton()->get_resource_clipboard().ptr(),String());
+ push_item(EditorSettings::get_singleton()->get_resource_clipboard().ptr(), String());
}
} break;
@@ -2487,10 +2354,9 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (current) {
_editor_select(EDITOR_SCRIPT);
- emit_signal("request_help",current->get_class());
+ emit_signal("request_help", current->get_class());
}
-
} break;
case OBJECT_COPY_PARAMS: {
@@ -2511,10 +2377,10 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (current) {
List<PropertyInfo> props;
current->get_property_list(&props);
- Map<RES,RES> duplicates;
- for (List<PropertyInfo>::Element *E=props.front();E;E=E->next()) {
+ Map<RES, RES> duplicates;
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
- if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
Variant v = current->get(E->get().name);
@@ -2526,16 +2392,14 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (res.is_valid()) {
if (!duplicates.has(res)) {
- duplicates[res]=res->duplicate();
+ duplicates[res] = res->duplicate();
}
- res=duplicates[res];
+ res = duplicates[res];
- current->set(E->get().name,res);
+ current->set(E->get().name, res);
}
-
}
}
-
}
}
@@ -2546,42 +2410,42 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case RUN_PLAY: {
- _menu_option_confirm(RUN_STOP,true);
+ _menu_option_confirm(RUN_STOP, true);
_call_build();
_run(false);
} break;
case RUN_PLAY_CUSTOM_SCENE: {
- if (run_custom_filename.empty() || editor_run.get_status()==EditorRun::STATUS_STOP) {
- _menu_option_confirm(RUN_STOP,true);
- quick_run->popup("PackedScene",true);
+ if (run_custom_filename.empty() || editor_run.get_status() == EditorRun::STATUS_STOP) {
+ _menu_option_confirm(RUN_STOP, true);
+ quick_run->popup("PackedScene", true);
quick_run->set_title(TTR("Quick Run Scene.."));
play_custom_scene_button->set_pressed(false);
} else {
- String last_custom_scene=run_custom_filename;
- _menu_option_confirm(RUN_STOP,true);
- _run(false,last_custom_scene);
+ String last_custom_scene = run_custom_filename;
+ _menu_option_confirm(RUN_STOP, true);
+ _run(false, last_custom_scene);
}
} break;
case RUN_STOP: {
- if (editor_run.get_status()==EditorRun::STATUS_STOP)
+ if (editor_run.get_status() == EditorRun::STATUS_STOP)
break;
editor_run.stop();
run_custom_filename.clear();
play_button->set_pressed(false);
- play_button->set_icon(gui_base->get_icon("MainPlay","EditorIcons"));
+ play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons"));
play_scene_button->set_pressed(false);
- play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons"));
+ play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
play_custom_scene_button->set_pressed(false);
- play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom","EditorIcons"));
+ play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
//pause_button->set_pressed(false);
if (bool(EDITOR_DEF("run/output/always_close_output_on_stop", true))) {
- for(int i=0;i<bottom_panel_items.size();i++) {
- if (bottom_panel_items[i].control==log) {
- _bottom_panel_switch(false,i);
+ for (int i = 0; i < bottom_panel_items.size(); i++) {
+ if (bottom_panel_items[i].control == log) {
+ _bottom_panel_switch(false, i);
break;
}
}
@@ -2590,19 +2454,19 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case RUN_PLAY_SCENE: {
- _menu_option_confirm(RUN_STOP,true);
+ _menu_option_confirm(RUN_STOP, true);
_call_build();
_run(true);
} break;
case RUN_PLAY_NATIVE: {
- bool autosave = EDITOR_DEF("run/auto_save/save_before_running",true);
+ bool autosave = EDITOR_DEF("run/auto_save/save_before_running", true);
if (autosave) {
_menu_option_confirm(FILE_SAVE_ALL_SCENES, false);
}
- if (run_native->is_deploy_debug_remote_enabled()){
- _menu_option_confirm(RUN_STOP,true);
+ if (run_native->is_deploy_debug_remote_enabled()) {
+ _menu_option_confirm(RUN_STOP, true);
_call_build();
emit_signal("play_pressed");
editor_run.run_native_notify();
@@ -2625,8 +2489,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
break;
}
- _menu_option_confirm(RUN_STOP,true);
- exiting=true;
+ _menu_option_confirm(RUN_STOP, true);
+ exiting = true;
get_tree()->quit();
String exec = OS::get_singleton()->get_executable_path();
@@ -2635,14 +2499,14 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
args.push_back(exec.get_base_dir());
args.push_back("-pm");
- OS::ProcessID pid=0;
- Error err = OS::get_singleton()->execute(exec,args,false,&pid);
+ OS::ProcessID pid = 0;
+ Error err = OS::get_singleton()->execute(exec, args, false, &pid);
ERR_FAIL_COND(err);
} break;
case RUN_FILE_SERVER: {
//file_server
- bool ischecked = debug_button->get_popup()->is_item_checked( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER));
+ bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_FILE_SERVER));
if (ischecked) {
file_server->stop();
@@ -2656,14 +2520,14 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//debug_button->get_popup()->set_item_text( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER),"Disable File Server");
}
- debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER),!ischecked);
+ debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_FILE_SERVER), !ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_file_server", !ischecked);
} break;
case RUN_LIVE_DEBUG: {
- bool ischecked = debug_button->get_popup()->is_item_checked( debug_button->get_popup()->get_item_index(RUN_LIVE_DEBUG));
+ bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_LIVE_DEBUG));
- debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_LIVE_DEBUG),!ischecked);
+ debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_LIVE_DEBUG), !ischecked);
ScriptEditor::get_singleton()->get_debugger()->set_live_debugging(!ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_live_debug", !ischecked);
@@ -2678,16 +2542,16 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;*/
case RUN_DEPLOY_REMOTE_DEBUG: {
- bool ischecked = debug_button->get_popup()->is_item_checked( debug_button->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG));
- debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG),!ischecked);
+ bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG));
+ debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG), !ischecked);
run_native->set_deploy_debug_remote(!ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_deploy_remote_debug", !ischecked);
} break;
case RUN_DEBUG_COLLISONS: {
- bool ischecked = debug_button->get_popup()->is_item_checked( debug_button->get_popup()->get_item_index(RUN_DEBUG_COLLISONS));
- debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_DEBUG_COLLISONS),!ischecked);
+ bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_DEBUG_COLLISONS));
+ debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_DEBUG_COLLISONS), !ischecked);
run_native->set_debug_collisions(!ischecked);
editor_run.set_debug_collisions(!ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_collisons", !ischecked);
@@ -2695,8 +2559,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case RUN_DEBUG_NAVIGATION: {
- bool ischecked = debug_button->get_popup()->is_item_checked( debug_button->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION));
- debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION),!ischecked);
+ bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION));
+ debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION), !ischecked);
run_native->set_debug_navigation(!ischecked);
editor_run.set_debug_navigation(!ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_navigation", !ischecked);
@@ -2704,9 +2568,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case RUN_RELOAD_SCRIPTS: {
-
- bool ischecked = debug_button->get_popup()->is_item_checked( debug_button->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS));
- debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS),!ischecked);
+ bool ischecked = debug_button->get_popup()->is_item_checked(debug_button->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS));
+ debug_button->get_popup()->set_item_checked(debug_button->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS), !ischecked);
ScriptEditor::get_singleton()->set_live_auto_reload_running_scripts(!ischecked);
EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_reload_scripts", !ischecked);
@@ -2714,20 +2577,20 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case SETTINGS_UPDATE_ALWAYS: {
- update_menu->get_popup()->set_item_checked(0,true);
- update_menu->get_popup()->set_item_checked(1,false);
+ update_menu->get_popup()->set_item_checked(0, true);
+ update_menu->get_popup()->set_item_checked(1, false);
OS::get_singleton()->set_low_processor_usage_mode(false);
} break;
case SETTINGS_UPDATE_CHANGES: {
- update_menu->get_popup()->set_item_checked(0,false);
- update_menu->get_popup()->set_item_checked(1,true);
+ update_menu->get_popup()->set_item_checked(0, false);
+ update_menu->get_popup()->set_item_checked(1, true);
OS::get_singleton()->set_low_processor_usage_mode(true);
} break;
- case SETTINGS_UPDATE_SPINNER_HIDE: {
- update_menu->set_icon(gui_base->get_icon("Collapse","EditorIcons"));
- update_menu->get_popup()->toggle_item_checked(3);
- } break;
+ case SETTINGS_UPDATE_SPINNER_HIDE: {
+ update_menu->set_icon(gui_base->get_icon("Collapse", "EditorIcons"));
+ update_menu->get_popup()->toggle_item_checked(3);
+ } break;
case SETTINGS_PREFERENCES: {
settings_config_dialog->popup_edit_settings();
@@ -2738,31 +2601,27 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case SETTINGS_LOAD_EXPORT_TEMPLATES: {
-
file_templates->popup_centered_ratio();
} break;
case SETTINGS_TOGGLE_FULLSCREN: {
- OS::get_singleton()->set_window_fullscreen( !OS::get_singleton()->is_window_fullscreen() );
-
+ OS::get_singleton()->set_window_fullscreen(!OS::get_singleton()->is_window_fullscreen());
} break;
case SETTINGS_PICK_MAIN_SCENE: {
-
//print_tree();
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
//not for now?
List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions);
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
file->clear_filters();
- for(int i=0;i<extensions.size();i++) {
+ for (int i = 0; i < extensions.size(); i++) {
- file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+ file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
-
//file->set_current_path(current_path);
Node *scene = editor_data.get_edited_scene_root();
if (scene) {
@@ -2774,7 +2633,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case SETTINGS_ABOUT: {
- about->popup_centered_minsize(Size2(500,130)*EDSCALE);
+ about->popup_centered_minsize(Size2(500, 130) * EDSCALE);
} break;
case SOURCES_REIMPORT: {
@@ -2782,12 +2641,10 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case DEPENDENCY_LOAD_CHANGED_IMAGES: {
-
-
} break;
case DEPENDENCY_UPDATE_IMPORTED: {
-/*
+ /*
bool editing_changed = _find_editing_changed_scene(get_edited_scene());
import_reload_fn="";
@@ -2829,28 +2686,25 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
*/
-
} break;
default: {
- if (p_option>=OBJECT_METHOD_BASE) {
+ if (p_option >= OBJECT_METHOD_BASE) {
ERR_FAIL_COND(!current);
- int idx=p_option-OBJECT_METHOD_BASE;
+ int idx = p_option - OBJECT_METHOD_BASE;
List<MethodInfo> methods;
current->get_method_list(&methods);
- ERR_FAIL_INDEX( idx, methods.size() );
- String name=methods[idx].name;
+ ERR_FAIL_INDEX(idx, methods.size());
+ String name = methods[idx].name;
if (current)
current->call(name);
- } else if (p_option>=IMPORT_PLUGIN_BASE) {
-
-
+ } else if (p_option >= IMPORT_PLUGIN_BASE) {
}
}
}
@@ -2858,72 +2712,64 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
void EditorNode::_update_debug_options() {
- bool check_deploy_remote = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_deploy_remote_debug", false);
- bool check_file_server = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_file_server", false);
- bool check_debug_collisons = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_collisons", false);
+ bool check_deploy_remote = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_deploy_remote_debug", false);
+ bool check_file_server = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_file_server", false);
+ bool check_debug_collisons = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_collisons", false);
bool check_debug_navigation = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_navigation", false);
- bool check_live_debug = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_live_debug", false);
- bool check_reload_scripts = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_reload_scripts", false);
+ bool check_live_debug = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_live_debug", false);
+ bool check_reload_scripts = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_reload_scripts", false);
- if (check_deploy_remote) _menu_option_confirm(RUN_DEPLOY_REMOTE_DEBUG, true);
- if (check_file_server) _menu_option_confirm(RUN_FILE_SERVER, true);
- if (check_debug_collisons) _menu_option_confirm(RUN_DEBUG_COLLISONS, true);
+ if (check_deploy_remote) _menu_option_confirm(RUN_DEPLOY_REMOTE_DEBUG, true);
+ if (check_file_server) _menu_option_confirm(RUN_FILE_SERVER, true);
+ if (check_debug_collisons) _menu_option_confirm(RUN_DEBUG_COLLISONS, true);
if (check_debug_navigation) _menu_option_confirm(RUN_DEBUG_NAVIGATION, true);
- if (check_live_debug) _menu_option_confirm(RUN_LIVE_DEBUG, true);
- if (check_reload_scripts) _menu_option_confirm(RUN_RELOAD_SCRIPTS, true);
-
+ if (check_live_debug) _menu_option_confirm(RUN_LIVE_DEBUG, true);
+ if (check_reload_scripts) _menu_option_confirm(RUN_RELOAD_SCRIPTS, true);
}
-Control* EditorNode::get_viewport() {
+Control *EditorNode::get_viewport() {
return viewport;
}
-
-
void EditorNode::_editor_select(int p_which) {
- static bool selecting=false;
+ static bool selecting = false;
if (selecting || changing_scene)
return;
- selecting=true;
+ selecting = true;
+ ERR_FAIL_INDEX(p_which, editor_table.size());
- ERR_FAIL_INDEX(p_which,editor_table.size());
-
- for(int i=0;i<main_editor_buttons.size();i++) {
- main_editor_buttons[i]->set_pressed(i==p_which);
+ for (int i = 0; i < main_editor_buttons.size(); i++) {
+ main_editor_buttons[i]->set_pressed(i == p_which);
}
- selecting=false;
-
+ selecting = false;
EditorPlugin *new_editor = editor_table[p_which];
ERR_FAIL_COND(!new_editor);
- if (editor_plugin_screen==new_editor)
+ if (editor_plugin_screen == new_editor)
return;
if (editor_plugin_screen) {
editor_plugin_screen->make_visible(false);
}
- editor_plugin_screen=new_editor;
+ editor_plugin_screen = new_editor;
editor_plugin_screen->make_visible(true);
editor_plugin_screen->selected_notify();
-
-
}
void EditorNode::add_editor_plugin(EditorPlugin *p_editor) {
-
if (p_editor->has_main_screen()) {
- ToolButton *tb = memnew( ToolButton );
+ ToolButton *tb = memnew(ToolButton);
tb->set_toggle_mode(true);
- tb->connect("pressed",singleton,"_editor_select",varray(singleton->main_editor_buttons.size()));
+ tb->connect("pressed", singleton, "_editor_select", varray(singleton->main_editor_buttons.size()));
tb->set_text(p_editor->get_name());
singleton->main_editor_buttons.push_back(tb);
singleton->main_editor_button_vb->add_child(tb);
@@ -2931,24 +2777,23 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor) {
singleton->distraction_free->raise();
}
- singleton->editor_data.add_editor_plugin( p_editor );
+ singleton->editor_data.add_editor_plugin(p_editor);
singleton->add_child(p_editor);
}
-
void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) {
if (p_editor->has_main_screen()) {
- for(int i=0;i<singleton->main_editor_buttons.size();i++) {
+ for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
- if (p_editor->get_name()==singleton->main_editor_buttons[i]->get_text()) {
+ if (p_editor->get_name() == singleton->main_editor_buttons[i]->get_text()) {
if (singleton->main_editor_buttons[i]->is_pressed()) {
singleton->_editor_select(EDITOR_SCRIPT);
}
- memdelete( singleton->main_editor_buttons[i] );
+ memdelete(singleton->main_editor_buttons[i]);
singleton->main_editor_buttons.remove(i);
break;
@@ -2962,12 +2807,9 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) {
p_editor->clear();
singleton->editor_plugins_over->get_plugins_list().erase(p_editor);
singleton->remove_child(p_editor);
- singleton->editor_data.remove_editor_plugin( p_editor );
-
+ singleton->editor_data.remove_editor_plugin(p_editor);
}
-
-
void EditorNode::_update_addon_config() {
if (_initializing_addons)
@@ -2975,21 +2817,20 @@ void EditorNode::_update_addon_config() {
Vector<String> enabled_addons;
- for(Map<String,EditorPlugin*>::Element *E=plugin_addons.front();E;E=E->next()) {
+ for (Map<String, EditorPlugin *>::Element *E = plugin_addons.front(); E; E = E->next()) {
enabled_addons.push_back(E->key());
}
- if (enabled_addons.size()==0) {
- GlobalConfig::get_singleton()->set("editor_plugins/enabled",Variant());
+ if (enabled_addons.size() == 0) {
+ GlobalConfig::get_singleton()->set("editor_plugins/enabled", Variant());
} else {
- GlobalConfig::get_singleton()->set("editor_plugins/enabled",enabled_addons);
+ GlobalConfig::get_singleton()->set("editor_plugins/enabled", enabled_addons);
}
project_settings->queue_save();
-
}
-void EditorNode::set_addon_plugin_enabled(const String& p_addon,bool p_enabled) {
+void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled) {
ERR_FAIL_COND(p_enabled && plugin_addons.has(p_addon));
ERR_FAIL_COND(!p_enabled && !plugin_addons.has(p_addon));
@@ -3004,75 +2845,68 @@ void EditorNode::set_addon_plugin_enabled(const String& p_addon,bool p_enabled)
return;
}
-
Ref<ConfigFile> cf;
cf.instance();
- String addon_path = "res://addons/"+p_addon+"/plugin.cfg";
+ String addon_path = "res://addons/" + p_addon + "/plugin.cfg";
Error err = cf->load(addon_path);
- if (err!=OK) {
- show_warning("Unable to enable addon plugin at: '"+addon_path+"' parsing of config failed.");
+ if (err != OK) {
+ show_warning("Unable to enable addon plugin at: '" + addon_path + "' parsing of config failed.");
return;
}
- if (!cf->has_section_key("plugin","script")) {
- show_warning("Unable to find script field for addon plugin at: 'res://addons/"+p_addon+"''.");
+ if (!cf->has_section_key("plugin", "script")) {
+ show_warning("Unable to find script field for addon plugin at: 'res://addons/" + p_addon + "''.");
return;
}
- String path = cf->get_value("plugin","script");
- path="res://addons/"+p_addon+"/"+path;
+ String path = cf->get_value("plugin", "script");
+ path = "res://addons/" + p_addon + "/" + path;
Ref<Script> script = ResourceLoader::load(path);
-
if (script.is_null()) {
- show_warning("Unable to load addon script from path: '"+path+"'.");
+ show_warning("Unable to load addon script from path: '" + path + "'.");
return;
}
//could check inheritance..
- if (String(script->get_instance_base_type())!="EditorPlugin") {
- show_warning("Unable to load addon script from path: '"+path+"' Base type is not EditorPlugin.");
+ if (String(script->get_instance_base_type()) != "EditorPlugin") {
+ show_warning("Unable to load addon script from path: '" + path + "' Base type is not EditorPlugin.");
return;
}
if (!script->is_tool()) {
- show_warning("Unable to load addon script from path: '"+path+"' Script is does not support tool mode.");
+ show_warning("Unable to load addon script from path: '" + path + "' Script is does not support tool mode.");
return;
}
- EditorPlugin *ep = memnew( EditorPlugin );
+ EditorPlugin *ep = memnew(EditorPlugin);
ep->set_script(script.get_ref_ptr());
- plugin_addons[p_addon]=ep;
+ plugin_addons[p_addon] = ep;
add_editor_plugin(ep);
_update_addon_config();
-
-
}
-bool EditorNode::is_addon_plugin_enabled(const String& p_addon) const {
+bool EditorNode::is_addon_plugin_enabled(const String &p_addon) const {
return plugin_addons.has(p_addon);
}
-
void EditorNode::_remove_edited_scene() {
int new_index = editor_data.get_edited_scene();
- int old_index=new_index;
+ int old_index = new_index;
- if (new_index>0) {
- new_index=new_index-1;
- } else if (editor_data.get_edited_scene_count()>1) {
- new_index=1;
+ if (new_index > 0) {
+ new_index = new_index - 1;
+ } else if (editor_data.get_edited_scene_count() > 1) {
+ new_index = 1;
} else {
editor_data.add_edited_scene(-1);
- new_index=1;
+ new_index = 1;
}
-
-
- if (editor_data.get_scene_path(old_index)!=String()) {
+ if (editor_data.get_scene_path(old_index) != String()) {
ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(editor_data.get_scene_path(old_index));
}
_scene_tab_changed(new_index);
@@ -3096,8 +2930,7 @@ void EditorNode::_remove_scene(int index) {
if (editor_data.get_edited_scene() == index) {
//Scene to remove is current scene
_remove_edited_scene();
- }
- else {
+ } else {
// Scene to remove is not active scene
editor_data.remove_scene(index);
}
@@ -3106,9 +2939,8 @@ void EditorNode::_remove_scene(int index) {
void EditorNode::set_edited_scene(Node *p_scene) {
if (get_editor_data().get_edited_scene_root()) {
- if (get_editor_data().get_edited_scene_root()->get_parent()==scene_root)
+ if (get_editor_data().get_edited_scene_root()->get_parent() == scene_root)
scene_root->remove_child(get_editor_data().get_edited_scene_root());
-
}
get_editor_data().set_edited_scene_root(p_scene);
@@ -3119,19 +2951,15 @@ void EditorNode::set_edited_scene(Node *p_scene) {
get_tree()->set_edited_scene_root(p_scene);
if (p_scene) {
- if (p_scene->get_parent()!=scene_root)
+ if (p_scene->get_parent() != scene_root)
scene_root->add_child(p_scene);
-
}
}
-
-
-
int EditorNode::_get_current_main_editor() {
- for(int i=0;i<editor_table.size();i++) {
- if (editor_table[i]==editor_plugin_screen)
+ for (int i = 0; i < editor_table.size(); i++) {
+ if (editor_table[i] == editor_plugin_screen)
return i;
}
@@ -3141,22 +2969,22 @@ int EditorNode::_get_current_main_editor() {
Dictionary EditorNode::_get_main_scene_state() {
Dictionary state;
- state["main_tab"]=_get_current_main_editor();
- state["scene_tree_offset"]=scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->get_value();
- state["property_edit_offset"]=get_property_editor()->get_scene_tree()->get_vscroll_bar()->get_value();
- state["saved_version"]=saved_version;
- state["node_filter"]=scene_tree_dock->get_filter();
+ state["main_tab"] = _get_current_main_editor();
+ state["scene_tree_offset"] = scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->get_value();
+ state["property_edit_offset"] = get_property_editor()->get_scene_tree()->get_vscroll_bar()->get_value();
+ state["saved_version"] = saved_version;
+ state["node_filter"] = scene_tree_dock->get_filter();
//print_line(" getting main tab: "+itos(state["main_tab"]));
return state;
}
-void EditorNode::_set_main_scene_state(Dictionary p_state,Node* p_for_scene) {
+void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
- if (get_edited_scene()!=p_for_scene && p_for_scene!=NULL)
+ if (get_edited_scene() != p_for_scene && p_for_scene != NULL)
return; //not for this scene
//print_line("set current 7 ");
- changing_scene=false;
+ changing_scene = false;
#if 0
if (p_state.has("main_tab")) {
@@ -3183,31 +3011,28 @@ void EditorNode::_set_main_scene_state(Dictionary p_state,Node* p_for_scene) {
if (get_edited_scene()) {
- int current=-1;
- for(int i=0;i<editor_table.size();i++) {
- if (editor_plugin_screen==editor_table[i]) {
- current=i;
+ int current = -1;
+ for (int i = 0; i < editor_table.size(); i++) {
+ if (editor_plugin_screen == editor_table[i]) {
+ current = i;
break;
}
}
- if (current<2) {
+ if (current < 2) {
//use heuristic instead
- int n2d=0,n3d=0;
- _find_node_types(get_edited_scene(),n2d,n3d);
- if (n2d>n3d) {
+ int n2d = 0, n3d = 0;
+ _find_node_types(get_edited_scene(), n2d, n3d);
+ if (n2d > n3d) {
_editor_select(EDITOR_2D);
- } else if (n3d>n2d) {
+ } else if (n3d > n2d) {
_editor_select(EDITOR_3D);
-
}
}
-
}
#endif
-
if (p_state.has("scene_tree_offset"))
scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->set_value(p_state["scene_tree_offset"]);
if (p_state.has("property_edit_offset"))
@@ -3221,16 +3046,15 @@ void EditorNode::_set_main_scene_state(Dictionary p_state,Node* p_for_scene) {
//changing_scene=true; //avoid script change from opening editor
ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root();
- ScriptEditor::get_singleton()->set_scene_root_script( editor_data.get_scene_root_script(editor_data.get_edited_scene()) );
+ ScriptEditor::get_singleton()->set_scene_root_script(editor_data.get_scene_root_script(editor_data.get_edited_scene()));
editor_data.notify_edited_scene_changed();
//changing_scene=false;
-
}
void EditorNode::set_current_version(uint64_t p_version) {
- saved_version=p_version;
+ saved_version = p_version;
editor_data.set_edited_scene_version(p_version);
}
@@ -3249,13 +3073,12 @@ void EditorNode::set_current_scene(int p_idx) {
call_deferred("_clear_undo_history");
}
- changing_scene=true;
- editor_data.save_edited_scene_state(editor_selection,&editor_history,_get_main_scene_state());
+ changing_scene = true;
+ editor_data.save_edited_scene_state(editor_selection, &editor_history, _get_main_scene_state());
if (get_editor_data().get_edited_scene_root()) {
- if (get_editor_data().get_edited_scene_root()->get_parent()==scene_root)
+ if (get_editor_data().get_edited_scene_root()->get_parent() == scene_root)
scene_root->remove_child(get_editor_data().get_edited_scene_root());
-
}
//print_line("set current 2 ");
@@ -3263,7 +3086,7 @@ void EditorNode::set_current_scene(int p_idx) {
editor_selection->clear();
editor_data.set_edited_scene(p_idx);
- Node* new_scene = editor_data.get_edited_scene_root();
+ Node *new_scene = editor_data.get_edited_scene_root();
if (new_scene && new_scene->cast_to<Popup>())
new_scene->cast_to<Popup>()->show(); //show popups
@@ -3275,14 +3098,12 @@ void EditorNode::set_current_scene(int p_idx) {
get_tree()->set_edited_scene_root(new_scene);
if (new_scene) {
- if (new_scene->get_parent()!=scene_root)
+ if (new_scene->get_parent() != scene_root)
scene_root->add_child(new_scene);
-
}
//print_line("set current 4 ");
-
- Dictionary state = editor_data.restore_edited_scene_state(editor_selection,&editor_history);
+ Dictionary state = editor_data.restore_edited_scene_state(editor_selection, &editor_history);
_edit_current();
/*if (!unsaved) {
@@ -3297,60 +3118,50 @@ void EditorNode::set_current_scene(int p_idx) {
}*/
//_set_main_scene_state(state);
- call_deferred("_set_main_scene_state",state,get_edited_scene()); //do after everything else is done setting up
+ call_deferred("_set_main_scene_state", state, get_edited_scene()); //do after everything else is done setting up
//print_line("set current 6 ");
-
-
}
-bool EditorNode::is_scene_open(const String& p_path) {
+bool EditorNode::is_scene_open(const String &p_path) {
- for(int i=0;i<editor_data.get_edited_scene_count();i++) {
- if (editor_data.get_scene_path(i)==p_path)
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
+ if (editor_data.get_scene_path(i) == p_path)
return true;
}
return false;
}
-void EditorNode::fix_dependencies(const String& p_for_file) {
+void EditorNode::fix_dependencies(const String &p_for_file) {
dependency_fixer->edit(p_for_file);
}
-
-
-
-Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps, bool p_set_inherited, bool p_clear_errors, bool p_force_open_imported) {
+Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, bool p_set_inherited, bool p_clear_errors, bool p_force_open_imported) {
if (!is_inside_tree()) {
defer_load_scene = p_scene;
return OK;
}
+ if (!p_set_inherited) {
- if(!p_set_inherited) {
-
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
- for(int i=0;i<editor_data.get_edited_scene_count();i++) {
-
- if (editor_data.get_scene_path(i)==p_scene) {
+ if (editor_data.get_scene_path(i) == p_scene) {
_scene_tab_changed(i);
return OK;
}
}
- if (!p_force_open_imported && FileAccess::exists(p_scene+".import")) {
- open_imported->set_text(vformat(TTR("Scene '%s' was automatically imported, so it can't be modified.\nTo make changes to it, a new inherited scene can be created."),p_scene.get_file()));
+ if (!p_force_open_imported && FileAccess::exists(p_scene + ".import")) {
+ open_imported->set_text(vformat(TTR("Scene '%s' was automatically imported, so it can't be modified.\nTo make changes to it, a new inherited scene can be created."), p_scene.get_file()));
open_imported->popup_centered_minsize();
new_inherited_button->grab_focus();
- open_import_request=p_scene;
+ open_import_request = p_scene;
return OK;
}
-
}
-
-
if (p_clear_errors)
load_errors->clear();
@@ -3358,12 +3169,12 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps, b
if (!lpath.begins_with("res://")) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
accept->set_text(TTR("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path."));
accept->popup_centered_minsize();
- opening_prev=false;
+ opening_prev = false;
return ERR_FILE_NOT_FOUND;
}
@@ -3372,29 +3183,27 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps, b
//print_line("load scene callback");
//set_current_scene(idx);
- if (!editor_data.get_edited_scene_root() && editor_data.get_edited_scene_count()==2) {
+ if (!editor_data.get_edited_scene_root() && editor_data.get_edited_scene_count() == 2) {
_remove_edited_scene();
} else {
_scene_tab_changed(idx);
}
-
-
//_cleanup_scene(); // i'm sorry but this MUST happen to avoid modified resources to not be reloaded.
dependency_errors.clear();
- Ref<PackedScene> sdata = ResourceLoader::load(lpath,"",true);
+ Ref<PackedScene> sdata = ResourceLoader::load(lpath, "", true);
if (!sdata.is_valid()) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
accept->set_text(TTR("Error loading scene."));
accept->popup_centered_minsize();
- opening_prev=false;
+ opening_prev = false;
- if (prev!=-1) {
+ if (prev != -1) {
set_current_scene(prev);
editor_data.remove_scene(idx);
}
@@ -3403,16 +3212,16 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps, b
if (!p_ignore_broken_deps && dependency_errors.has(lpath)) {
- current_option=-1;
+ current_option = -1;
Vector<String> errors;
- for(Set<String>::Element *E=dependency_errors[lpath].front();E;E=E->next()) {
+ for (Set<String>::Element *E = dependency_errors[lpath].front(); E; E = E->next()) {
errors.push_back(E->get());
}
- dependency_error->show(lpath,errors);
- opening_prev=false;
+ dependency_error->show(lpath, errors);
+ opening_prev = false;
- if (prev!=-1) {
+ if (prev != -1) {
set_current_scene(prev);
editor_data.remove_scene(idx);
}
@@ -3421,40 +3230,40 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps, b
dependency_errors.erase(lpath); //at least not self path
- for (Map<String,Set<String> >::Element *E=dependency_errors.front();E;E=E->next()) {
+ for (Map<String, Set<String> >::Element *E = dependency_errors.front(); E; E = E->next()) {
- String txt=vformat(TTR("Scene '%s' has broken dependencies:"),E->key())+"\n";
- for(Set<String>::Element *F=E->get().front();F;F=F->next()) {
- txt+="\t"+F->get()+"\n";
+ String txt = vformat(TTR("Scene '%s' has broken dependencies:"), E->key()) + "\n";
+ for (Set<String>::Element *F = E->get().front(); F; F = F->next()) {
+ txt += "\t" + F->get() + "\n";
}
add_io_error(txt);
}
if (ResourceCache::has(lpath)) {
//used from somewhere else? no problem! update state and replace sdata
- Ref<PackedScene> ps = Ref<PackedScene>( ResourceCache::get(lpath)->cast_to<PackedScene>() );
+ Ref<PackedScene> ps = Ref<PackedScene>(ResourceCache::get(lpath)->cast_to<PackedScene>());
if (ps.is_valid()) {
- ps->replace_state( sdata->get_state() );
- ps->set_last_modified_time( sdata->get_last_modified_time() );
- sdata=ps;
+ ps->replace_state(sdata->get_state());
+ ps->set_last_modified_time(sdata->get_last_modified_time());
+ sdata = ps;
}
} else {
- sdata->set_path(lpath,true); //take over path
+ sdata->set_path(lpath, true); //take over path
}
- Node*new_scene=sdata->instance(PackedScene::GEN_EDIT_STATE_MAIN);
+ Node *new_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_MAIN);
if (!new_scene) {
sdata.unref();
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
accept->set_text(TTR("Error loading scene."));
accept->popup_centered_minsize();
- opening_prev=false;
- if (prev!=-1) {
+ opening_prev = false;
+ if (prev != -1) {
set_current_scene(prev);
editor_data.remove_scene(idx);
}
@@ -3501,13 +3310,13 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps, b
*/
//editor_data.get_undo_redo().clear_history();
- saved_version=editor_data.get_undo_redo().get_version();
+ saved_version = editor_data.get_undo_redo().get_version();
_update_title();
_update_scene_tabs();
_add_to_recent_scenes(lpath);
- prev_scene->set_disabled(previous_scenes.size()==0);
- opening_prev=false;
+ prev_scene->set_disabled(previous_scenes.size() == 0);
+ opening_prev = false;
ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root();
@@ -3518,9 +3327,7 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps, b
return OK;
}
-
-
-void EditorNode::open_request(const String& p_path) {
+void EditorNode::open_request(const String &p_path) {
load_scene(p_path); // as it will be opened in separate tab
//external_file=p_path;
@@ -3530,10 +3337,9 @@ void EditorNode::open_request(const String& p_path) {
void EditorNode::request_instance_scene(const String &p_path) {
scene_tree_dock->instance(p_path);
-
}
-void EditorNode::request_instance_scenes(const Vector<String>& p_files) {
+void EditorNode::request_instance_scenes(const Vector<String> &p_files) {
scene_tree_dock->instance_scenes(p_files);
}
@@ -3551,41 +3357,40 @@ SceneTreeDock *EditorNode::get_scene_tree_dock() {
return scene_tree_dock;
}
-void EditorNode::_instance_request(const Vector<String>& p_files) {
+void EditorNode::_instance_request(const Vector<String> &p_files) {
request_instance_scenes(p_files);
}
-void EditorNode::_property_keyed(const String& p_keyed,const Variant& p_value,bool p_advance) {
+void EditorNode::_property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance) {
- AnimationPlayerEditor::singleton->get_key_editor()->insert_value_key(p_keyed,p_value,p_advance);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_value_key(p_keyed, p_value, p_advance);
}
-void EditorNode::_transform_keyed(Object *sp,const String& p_sub,const Transform& p_key) {
+void EditorNode::_transform_keyed(Object *sp, const String &p_sub, const Transform &p_key) {
- Spatial *s=sp->cast_to<Spatial>();
+ Spatial *s = sp->cast_to<Spatial>();
if (!s)
return;
- AnimationPlayerEditor::singleton->get_key_editor()->insert_transform_key(s,p_sub,p_key);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_transform_key(s, p_sub, p_key);
}
void EditorNode::update_keying() {
//print_line("KR: "+itos(p_enabled));
- bool valid=false;
+ bool valid = false;
if (AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) {
- if (editor_history.get_path_size()>=1) {
+ if (editor_history.get_path_size() >= 1) {
Object *obj = ObjectDB::get_instance(editor_history.get_path_object(0));
if (obj && obj->cast_to<Node>()) {
- valid=true;
+ valid = true;
}
}
-
}
property_editor->set_keying(valid);
@@ -3593,7 +3398,6 @@ void EditorNode::update_keying() {
AnimationPlayerEditor::singleton->get_key_editor()->update_keying();
}
-
void EditorNode::_close_messages() {
//left_split->set_dragger_visible(false);
@@ -3607,7 +3411,6 @@ void EditorNode::_show_messages() {
//left_split->set_dragger_visible(true);
center_split->set_split_offset(old_split_ofs);
//scene_root_parent->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,log->get_margin(MARGIN_TOP));
-
}
#if 0
@@ -3648,33 +3451,31 @@ void EditorNode::animation_editor_make_visible(bool p_visible) {
}
#endif
-void EditorNode::_add_to_recent_scenes(const String& p_scene) {
+void EditorNode::_add_to_recent_scenes(const String &p_scene) {
- String base="_"+GlobalConfig::get_singleton()->get_resource_path().replace("\\","::").replace("/","::");
- Vector<String> rc = EDITOR_DEF(base+"/_recent_scenes",Array());
+ String base = "_" + GlobalConfig::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
+ Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array());
String name = p_scene;
- name=name.replace("res://","");
- if (rc.find(name)!=-1)
+ name = name.replace("res://", "");
+ if (rc.find(name) != -1)
rc.erase(name);
- rc.insert(0,name);
- if (rc.size()>10)
+ rc.insert(0, name);
+ if (rc.size() > 10)
rc.resize(10);
- EditorSettings::get_singleton()->set(base+"/_recent_scenes",rc);
+ EditorSettings::get_singleton()->set(base + "/_recent_scenes", rc);
EditorSettings::get_singleton()->save();
_update_recent_scenes();
-
}
void EditorNode::_open_recent_scene(int p_idx) {
- String base="_"+GlobalConfig::get_singleton()->get_resource_path().replace("\\","::").replace("/","::");
- Vector<String> rc = EDITOR_DEF(base+"/_recent_scenes",Array());
-
- ERR_FAIL_INDEX(p_idx,rc.size());
+ String base = "_" + GlobalConfig::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
+ Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array());
- String path = "res://"+rc[p_idx];
+ ERR_FAIL_INDEX(p_idx, rc.size());
+ String path = "res://" + rc[p_idx];
/*if (unsaved_cache) {
_recent_scene=rc[p_idx];
@@ -3685,14 +3486,11 @@ void EditorNode::_open_recent_scene(int p_idx) {
}*/
load_scene(path);
-
-
}
void EditorNode::_save_optimized() {
-
- //save_optimized_copy(optimized_save->get_optimized_scene(),optimized_save->get_preset());
+//save_optimized_copy(optimized_save->get_optimized_scene(),optimized_save->get_preset());
#if 0
String path = optimized_save->get_optimized_scene();
@@ -3730,25 +3528,23 @@ void EditorNode::_save_optimized() {
void EditorNode::_update_recent_scenes() {
- String base="_"+GlobalConfig::get_singleton()->get_resource_path().replace("\\","::").replace("/","::");
- Vector<String> rc = EDITOR_DEF(base+"/_recent_scenes",Array());
+ String base = "_" + GlobalConfig::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
+ Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array());
recent_scenes->clear();
- for(int i=0;i<rc.size();i++) {
+ for (int i = 0; i < rc.size(); i++) {
- recent_scenes->add_item(rc[i],i);
+ recent_scenes->add_item(rc[i], i);
}
-
}
void EditorNode::_quick_opened() {
-
Vector<String> files = quick_open->get_selected_files();
for (int i = 0; i < files.size(); i++) {
String res_path = files[i];
- if (quick_open->get_base_type()=="PackedScene") {
+ if (quick_open->get_base_type() == "PackedScene") {
open_request(res_path);
} else {
load_resource(res_path);
@@ -3759,21 +3555,18 @@ void EditorNode::_quick_opened() {
void EditorNode::_quick_run() {
_call_build();
- _run(false,quick_run->get_selected());
+ _run(false, quick_run->get_selected());
}
-
void EditorNode::notify_child_process_exited() {
- _menu_option_confirm(RUN_STOP,false);
+ _menu_option_confirm(RUN_STOP, false);
stop_button->set_pressed(false);
editor_run.stop();
-
}
-
bool EditorNode::_find_editing_changed_scene(Node *p_from) {
-/*
+ /*
if (!p_from)
return false;
@@ -3796,35 +3589,29 @@ bool EditorNode::_find_editing_changed_scene(Node *p_from) {
return false;
}
-
-
-
-void EditorNode::add_io_error(const String& p_error) {
+void EditorNode::add_io_error(const String &p_error) {
//CharString err_ut = p_error.utf8();
//ERR_PRINT(!err_ut.get_data());
- _load_error_notify(singleton,p_error);
+ _load_error_notify(singleton, p_error);
}
-void EditorNode::_load_error_notify(void* p_ud,const String& p_text) {
-
+void EditorNode::_load_error_notify(void *p_ud, const String &p_text) {
- EditorNode*en=(EditorNode*)p_ud;
- en->load_errors->add_image(en->gui_base->get_icon("Error","EditorIcons"));
- en->load_errors->add_text(p_text+"\n");
+ EditorNode *en = (EditorNode *)p_ud;
+ en->load_errors->add_image(en->gui_base->get_icon("Error", "EditorIcons"));
+ en->load_errors->add_text(p_text + "\n");
en->load_error_dialog->popup_centered_ratio(0.5);
-
}
+bool EditorNode::_find_scene_in_use(Node *p_node, const String &p_path) const {
-bool EditorNode::_find_scene_in_use(Node* p_node,const String& p_path) const {
-
- if (p_node->get_filename()==p_path) {
+ if (p_node->get_filename() == p_path) {
return true;
}
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- if (_find_scene_in_use(p_node->get_child(i),p_path)) {
+ if (_find_scene_in_use(p_node->get_child(i), p_path)) {
return true;
}
}
@@ -3832,22 +3619,20 @@ bool EditorNode::_find_scene_in_use(Node* p_node,const String& p_path) const {
return false;
}
-
-bool EditorNode::is_scene_in_use(const String& p_path) {
+bool EditorNode::is_scene_in_use(const String &p_path) {
Node *es = get_edited_scene();
if (es)
- return _find_scene_in_use(es,p_path);
+ return _find_scene_in_use(es, p_path);
return false;
-
}
void EditorNode::register_editor_types() {
ClassDB::register_class<EditorPlugin>();
-// ClassDB::register_class<EditorImportPlugin>();
-// ClassDB::register_class<EditorExportPlugin>();
-// ClassDB::register_class<EditorScenePostImport>();
+ // ClassDB::register_class<EditorImportPlugin>();
+ // ClassDB::register_class<EditorExportPlugin>();
+ // ClassDB::register_class<EditorScenePostImport>();
ClassDB::register_class<EditorScript>();
ClassDB::register_class<EditorSelection>();
ClassDB::register_class<EditorFileDialog>();
@@ -3859,8 +3644,6 @@ void EditorNode::register_editor_types() {
ClassDB::register_class<EditorFileSystem>();
ClassDB::register_class<EditorFileSystemDirectory>();
-
-
//ClassDB::register_type<EditorImporter>();
//ClassDB::register_type<EditorPostImport>();
}
@@ -3870,62 +3653,49 @@ void EditorNode::unregister_editor_types() {
_init_callbacks.clear();
}
-
void EditorNode::stop_child_process() {
- _menu_option_confirm(RUN_STOP,false);
+ _menu_option_confirm(RUN_STOP, false);
}
+void EditorNode::progress_add_task(const String &p_task, const String &p_label, int p_steps) {
-
-
-
-void EditorNode::progress_add_task(const String& p_task,const String& p_label, int p_steps) {
-
- singleton->progress_dialog->add_task(p_task,p_label,p_steps);
+ singleton->progress_dialog->add_task(p_task, p_label, p_steps);
}
-void EditorNode::progress_task_step(const String& p_task, const String& p_state, int p_step,bool p_force_redraw) {
-
- singleton->progress_dialog->task_step(p_task,p_state,p_step,p_force_redraw);
+void EditorNode::progress_task_step(const String &p_task, const String &p_state, int p_step, bool p_force_redraw) {
+ singleton->progress_dialog->task_step(p_task, p_state, p_step, p_force_redraw);
}
-void EditorNode::progress_end_task(const String& p_task) {
+void EditorNode::progress_end_task(const String &p_task) {
singleton->progress_dialog->end_task(p_task);
-
}
+void EditorNode::progress_add_task_bg(const String &p_task, const String &p_label, int p_steps) {
-void EditorNode::progress_add_task_bg(const String& p_task,const String& p_label, int p_steps) {
-
- singleton->progress_hb->add_task(p_task,p_label,p_steps);
+ singleton->progress_hb->add_task(p_task, p_label, p_steps);
}
-void EditorNode::progress_task_step_bg(const String& p_task, int p_step) {
-
- singleton->progress_hb->task_step(p_task,p_step);
+void EditorNode::progress_task_step_bg(const String &p_task, int p_step) {
+ singleton->progress_hb->task_step(p_task, p_step);
}
-void EditorNode::progress_end_task_bg(const String& p_task) {
+void EditorNode::progress_end_task_bg(const String &p_task) {
singleton->progress_hb->end_task(p_task);
-
}
-
-
-Ref<Texture> EditorNode::_file_dialog_get_icon(const String& p_path) {
-
+Ref<Texture> EditorNode::_file_dialog_get_icon(const String &p_path) {
EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem_path(p_path.get_base_dir());
if (efsd) {
String file = p_path.get_file();
- for(int i=0;i<efsd->get_file_count();i++) {
- if (efsd->get_file(i)==file) {
+ for (int i = 0; i < efsd->get_file_count(); i++) {
+ if (efsd->get_file(i) == file) {
String type = efsd->get_file_type(i);
@@ -3934,7 +3704,6 @@ Ref<Texture> EditorNode::_file_dialog_get_icon(const String& p_path) {
} else {
return singleton->icon_type_cache["Object"];
}
-
}
}
}
@@ -3947,7 +3716,7 @@ void EditorNode::_file_dialog_register(FileDialog *p_dialog) {
singleton->file_dialogs.insert(p_dialog);
}
-void EditorNode::_file_dialog_unregister(FileDialog *p_dialog){
+void EditorNode::_file_dialog_unregister(FileDialog *p_dialog) {
singleton->file_dialogs.erase(p_dialog);
}
@@ -3957,83 +3726,80 @@ void EditorNode::_editor_file_dialog_register(EditorFileDialog *p_dialog) {
singleton->editor_file_dialogs.insert(p_dialog);
}
-void EditorNode::_editor_file_dialog_unregister(EditorFileDialog *p_dialog){
+void EditorNode::_editor_file_dialog_unregister(EditorFileDialog *p_dialog) {
singleton->editor_file_dialogs.erase(p_dialog);
}
Vector<EditorNodeInitCallback> EditorNode::_init_callbacks;
-Error EditorNode::export_platform(const String& p_platform, const String& p_path, bool p_debug,const String& p_password,bool p_quit_after) {
+Error EditorNode::export_platform(const String &p_platform, const String &p_path, bool p_debug, const String &p_password, bool p_quit_after) {
- export_defer.platform=p_platform;
- export_defer.path=p_path;
- export_defer.debug=p_debug;
- export_defer.password=p_password;
+ export_defer.platform = p_platform;
+ export_defer.path = p_path;
+ export_defer.debug = p_debug;
+ export_defer.password = p_password;
return OK;
}
-void EditorNode::show_warning(const String& p_text, const String &p_title) {
+void EditorNode::show_warning(const String &p_text, const String &p_title) {
warning->set_text(p_text);
warning->set_title(p_title);
warning->popup_centered_minsize();
}
-void EditorNode::_dock_select_input(const InputEvent& p_input) {
+void EditorNode::_dock_select_input(const InputEvent &p_input) {
- if (p_input.type==InputEvent::MOUSE_BUTTON || p_input.type==InputEvent::MOUSE_MOTION) {
+ if (p_input.type == InputEvent::MOUSE_BUTTON || p_input.type == InputEvent::MOUSE_MOTION) {
- Vector2 point(p_input.mouse_motion.x,p_input.mouse_motion.y);
+ Vector2 point(p_input.mouse_motion.x, p_input.mouse_motion.y);
int nrect = -1;
- for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
if (dock_select_rect[i].has_point(point)) {
- nrect=i;
+ nrect = i;
break;
}
}
-
- if (nrect!=dock_select_rect_over) {
+ if (nrect != dock_select_rect_over) {
dock_select->update();
- dock_select_rect_over=nrect;
-
+ dock_select_rect_over = nrect;
}
-
- if (nrect==-1)
+ if (nrect == -1)
return;
- if (p_input.type==InputEvent::MOUSE_BUTTON && p_input.mouse_button.button_index==1 && p_input.mouse_button.pressed && dock_popup_selected!=nrect) {
+ if (p_input.type == InputEvent::MOUSE_BUTTON && p_input.mouse_button.button_index == 1 && p_input.mouse_button.pressed && dock_popup_selected != nrect) {
Control *dock = dock_slot[dock_popup_selected]->get_current_tab_control();
if (dock) {
dock_slot[dock_popup_selected]->remove_child(dock);
}
- if (dock_slot[dock_popup_selected]->get_tab_count()==0) {
+ if (dock_slot[dock_popup_selected]->get_tab_count() == 0) {
dock_slot[dock_popup_selected]->hide();
- } else {
+ } else {
dock_slot[dock_popup_selected]->set_current_tab(0);
}
dock_slot[nrect]->add_child(dock);
- dock_popup_selected=nrect;
- dock_slot[nrect]->set_current_tab(dock_slot[nrect]->get_tab_count()-1);
+ dock_popup_selected = nrect;
+ dock_slot[nrect]->set_current_tab(dock_slot[nrect]->get_tab_count() - 1);
dock_slot[nrect]->show();
dock_select->update();
- VSplitContainer*splits[DOCK_SLOT_MAX/2]={
+ VSplitContainer *splits[DOCK_SLOT_MAX / 2] = {
left_l_vsplit,
left_r_vsplit,
right_l_vsplit,
right_r_vsplit,
};
- for(int i=0;i<4;i++) {
- bool in_use = dock_slot[i*2+0]->get_tab_count() || dock_slot[i*2+1]->get_tab_count();
+ for (int i = 0; i < 4; i++) {
+ bool in_use = dock_slot[i * 2 + 0]->get_tab_count() || dock_slot[i * 2 + 1]->get_tab_count();
if (in_use)
splits[i]->show();
else
@@ -4047,132 +3813,127 @@ void EditorNode::_dock_select_input(const InputEvent& p_input) {
void EditorNode::_dock_popup_exit() {
- dock_select_rect_over=-1;
+ dock_select_rect_over = -1;
dock_select->update();
}
void EditorNode::_dock_pre_popup(int p_which) {
-
- dock_popup_selected=p_which;
+ dock_popup_selected = p_which;
}
void EditorNode::_dock_move_left() {
- if (dock_popup_selected<0 || dock_popup_selected>=DOCK_SLOT_MAX)
+ if (dock_popup_selected < 0 || dock_popup_selected >= DOCK_SLOT_MAX)
return;
- Control *current = dock_slot[dock_popup_selected]->get_tab_control( dock_slot[dock_popup_selected]->get_current_tab() );
- Control *prev = dock_slot[dock_popup_selected]->get_tab_control( dock_slot[dock_popup_selected]->get_current_tab()-1 );
+ Control *current = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab());
+ Control *prev = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab() - 1);
if (!current || !prev)
return;
- dock_slot[dock_popup_selected]->move_child(current,prev->get_index());
- dock_slot[dock_popup_selected]->set_current_tab( dock_slot[dock_popup_selected]->get_current_tab()-1 );
+ dock_slot[dock_popup_selected]->move_child(current, prev->get_index());
+ dock_slot[dock_popup_selected]->set_current_tab(dock_slot[dock_popup_selected]->get_current_tab() - 1);
dock_select->update();
_save_docks();
-
-
}
void EditorNode::_dock_move_right() {
- Control *current = dock_slot[dock_popup_selected]->get_tab_control( dock_slot[dock_popup_selected]->get_current_tab() );
- Control *next = dock_slot[dock_popup_selected]->get_tab_control( dock_slot[dock_popup_selected]->get_current_tab()+1 );
+ Control *current = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab());
+ Control *next = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab() + 1);
if (!current || !next)
return;
- dock_slot[dock_popup_selected]->move_child(next,current->get_index());
- dock_slot[dock_popup_selected]->set_current_tab( dock_slot[dock_popup_selected]->get_current_tab()+1 );
+ dock_slot[dock_popup_selected]->move_child(next, current->get_index());
+ dock_slot[dock_popup_selected]->set_current_tab(dock_slot[dock_popup_selected]->get_current_tab() + 1);
dock_select->update();
_save_docks();
}
-void EditorNode::_dock_select_draw(){
+void EditorNode::_dock_select_draw() {
Size2 s = dock_select->get_size();
- s.y/=2.0;
- s.x/=6.0;
+ s.y /= 2.0;
+ s.x /= 6.0;
- Color used=Color(0.6,0.6,0.6,0.8);
- Color used_selected=Color(0.8,0.8,0.8,0.8);
- Color tab_selected=Color(1,1,1,1);
- Color unused=used;
- unused.a=0.4;
- Color unusable=unused;
- unusable.a=0.1;
+ Color used = Color(0.6, 0.6, 0.6, 0.8);
+ Color used_selected = Color(0.8, 0.8, 0.8, 0.8);
+ Color tab_selected = Color(1, 1, 1, 1);
+ Color unused = used;
+ unused.a = 0.4;
+ Color unusable = unused;
+ unusable.a = 0.1;
- Rect2 unr(s.x*2,0,s.x*2,s.y*2);
- unr.pos+=Vector2(2,5);
- unr.size-=Vector2(4,7);
+ Rect2 unr(s.x * 2, 0, s.x * 2, s.y * 2);
+ unr.pos += Vector2(2, 5);
+ unr.size -= Vector2(4, 7);
- dock_select->draw_rect(unr,unusable);
+ dock_select->draw_rect(unr, unusable);
dock_tab_move_left->set_disabled(true);
dock_tab_move_right->set_disabled(true);
- if (dock_popup_selected!=-1 && dock_slot[dock_popup_selected]->get_tab_count()) {
+ if (dock_popup_selected != -1 && dock_slot[dock_popup_selected]->get_tab_count()) {
- dock_tab_move_left->set_disabled(dock_slot[dock_popup_selected]->get_current_tab()==0);
- dock_tab_move_right->set_disabled(dock_slot[dock_popup_selected]->get_current_tab()>=dock_slot[dock_popup_selected]->get_tab_count()-1);
+ dock_tab_move_left->set_disabled(dock_slot[dock_popup_selected]->get_current_tab() == 0);
+ dock_tab_move_right->set_disabled(dock_slot[dock_popup_selected]->get_current_tab() >= dock_slot[dock_popup_selected]->get_tab_count() - 1);
}
- for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
Vector2 ofs;
- switch(i) {
+ switch (i) {
case DOCK_SLOT_LEFT_UL: {
} break;
case DOCK_SLOT_LEFT_BL: {
- ofs.y+=s.y;
+ ofs.y += s.y;
} break;
case DOCK_SLOT_LEFT_UR: {
- ofs.x+=s.x;
+ ofs.x += s.x;
} break;
case DOCK_SLOT_LEFT_BR: {
- ofs+=s;
+ ofs += s;
} break;
case DOCK_SLOT_RIGHT_UL: {
- ofs.x+=s.x*4;
+ ofs.x += s.x * 4;
} break;
case DOCK_SLOT_RIGHT_BL: {
- ofs.x+=s.x*4;
- ofs.y+=s.y;
+ ofs.x += s.x * 4;
+ ofs.y += s.y;
} break;
case DOCK_SLOT_RIGHT_UR: {
- ofs.x+=s.x*4;
- ofs.x+=s.x;
+ ofs.x += s.x * 4;
+ ofs.x += s.x;
} break;
case DOCK_SLOT_RIGHT_BR: {
- ofs.x+=s.x*4;
- ofs+=s;
+ ofs.x += s.x * 4;
+ ofs += s;
} break;
}
- Rect2 r(ofs,s);
- dock_select_rect[i]=r;
- r.pos+=Vector2(2,5);
- r.size-=Vector2(4,7);
+ Rect2 r(ofs, s);
+ dock_select_rect[i] = r;
+ r.pos += Vector2(2, 5);
+ r.size -= Vector2(4, 7);
-
- if (i==dock_select_rect_over) {
- dock_select->draw_rect(r,used_selected);
- } else if (dock_slot[i]->get_child_count()==0) {
- dock_select->draw_rect(r,unused);
+ if (i == dock_select_rect_over) {
+ dock_select->draw_rect(r, used_selected);
+ } else if (dock_slot[i]->get_child_count() == 0) {
+ dock_select->draw_rect(r, unused);
} else {
- dock_select->draw_rect(r,used);
+ dock_select->draw_rect(r, used);
}
- for(int j=0;j<MIN(3,dock_slot[i]->get_child_count());j++) {
- int xofs = (r.size.width/3)*j;
+ for (int j = 0; j < MIN(3, dock_slot[i]->get_child_count()); j++) {
+ int xofs = (r.size.width / 3) * j;
Color c = used;
- if (i==dock_popup_selected && (dock_slot[i]->get_current_tab()>3 || dock_slot[i]->get_current_tab()==j))
- c=tab_selected;
- dock_select->draw_rect(Rect2(2+ofs.x+xofs,ofs.y,r.size.width/3-1,3),c);
+ if (i == dock_popup_selected && (dock_slot[i]->get_current_tab() > 3 || dock_slot[i]->get_current_tab() == j))
+ c = tab_selected;
+ dock_select->draw_rect(Rect2(2 + ofs.x + xofs, ofs.y, r.size.width / 3 - 1, 3), c);
}
-
}
}
@@ -4185,54 +3946,51 @@ void EditorNode::_save_docks() {
editor_data.get_plugin_window_layout(config);
config->save(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg"));
-
}
-void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String& p_section) {
+void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section) {
- for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
String names;
- for(int j=0;j<dock_slot[i]->get_tab_count();j++) {
+ for (int j = 0; j < dock_slot[i]->get_tab_count(); j++) {
String name = dock_slot[i]->get_tab_control(j)->get_name();
- if (names!="")
- names+=",";
- names+=name;
+ if (names != "")
+ names += ",";
+ names += name;
}
- if (names!="") {
- p_layout->set_value(p_section,"dock_"+itos(i+1),names);
+ if (names != "") {
+ p_layout->set_value(p_section, "dock_" + itos(i + 1), names);
}
}
- p_layout->set_value(p_section,"dock_filesystem_split",filesystem_dock->get_split_offset());
+ p_layout->set_value(p_section, "dock_filesystem_split", filesystem_dock->get_split_offset());
- VSplitContainer*splits[DOCK_SLOT_MAX/2]={
+ VSplitContainer *splits[DOCK_SLOT_MAX / 2] = {
left_l_vsplit,
left_r_vsplit,
right_l_vsplit,
right_r_vsplit,
};
- for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
+ for (int i = 0; i < DOCK_SLOT_MAX / 2; i++) {
if (splits[i]->is_visible_in_tree()) {
- p_layout->set_value(p_section,"dock_split_"+itos(i+1),splits[i]->get_split_offset());
+ p_layout->set_value(p_section, "dock_split_" + itos(i + 1), splits[i]->get_split_offset());
}
}
-
- HSplitContainer *h_splits[4]={
+ HSplitContainer *h_splits[4] = {
left_l_hsplit,
left_r_hsplit,
main_hsplit,
right_hsplit,
};
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- p_layout->set_value(p_section,"dock_hsplit_"+itos(i+1),h_splits[i]->get_split_offset());
+ p_layout->set_value(p_section, "dock_hsplit_" + itos(i + 1), h_splits[i]->get_split_offset());
}
-
}
void EditorNode::save_layout() {
@@ -4250,9 +4008,9 @@ void EditorNode::_load_docks() {
Ref<ConfigFile> config;
config.instance();
Error err = config->load(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg"));
- if (err!=OK) {
+ if (err != OK) {
//no config
- if (overridden_default_layout>=0) {
+ if (overridden_default_layout >= 0) {
_layout_menu_option(overridden_default_layout);
}
return;
@@ -4260,21 +4018,18 @@ void EditorNode::_load_docks() {
_load_docks_from_config(config, "docks");
editor_data.set_plugin_window_layout(config);
-
}
-
void EditorNode::_update_dock_slots_visibility() {
- VSplitContainer*splits[DOCK_SLOT_MAX/2]={
+ VSplitContainer *splits[DOCK_SLOT_MAX / 2] = {
left_l_vsplit,
left_r_vsplit,
right_l_vsplit,
right_r_vsplit,
};
-
- HSplitContainer*h_splits[4]={
+ HSplitContainer *h_splits[4] = {
left_l_hsplit,
left_r_hsplit,
main_hsplit,
@@ -4283,36 +4038,34 @@ void EditorNode::_update_dock_slots_visibility() {
if (!docks_visible) {
- for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
dock_slot[i]->hide();
}
- for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
+ for (int i = 0; i < DOCK_SLOT_MAX / 2; i++) {
splits[i]->hide();
}
right_hsplit->hide();
bottom_panel->hide();
} else {
- for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
if (dock_slot[i]->get_tab_count())
dock_slot[i]->show();
else
dock_slot[i]->hide();
-
}
-
- for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
- bool in_use = dock_slot[i*2+0]->get_tab_count() || dock_slot[i*2+1]->get_tab_count();
+ for (int i = 0; i < DOCK_SLOT_MAX / 2; i++) {
+ bool in_use = dock_slot[i * 2 + 0]->get_tab_count() || dock_slot[i * 2 + 1]->get_tab_count();
if (in_use)
splits[i]->show();
else
splits[i]->hide();
}
- for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
if (dock_slot[i]->is_visible() && dock_slot[i]->get_tab_count()) {
dock_slot[i]->set_current_tab(0);
@@ -4338,44 +4091,42 @@ void EditorNode::_update_top_menu_visibility() {
}*/
}
-void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section) {
+void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section) {
- for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
- if (!p_layout->has_section_key(p_section,"dock_"+itos(i+1)))
+ if (!p_layout->has_section_key(p_section, "dock_" + itos(i + 1)))
continue;
- Vector<String> names = String(p_layout->get_value(p_section,"dock_"+itos(i+1))).split(",");
+ Vector<String> names = String(p_layout->get_value(p_section, "dock_" + itos(i + 1))).split(",");
- for(int j=0;j<names.size();j++) {
+ for (int j = 0; j < names.size(); j++) {
- String name=names[j];
+ String name = names[j];
//find it, in a horribly inefficient way
- int atidx=-1;
- Control *node=NULL;
- for(int k=0;k<DOCK_SLOT_MAX;k++) {
+ int atidx = -1;
+ Control *node = NULL;
+ for (int k = 0; k < DOCK_SLOT_MAX; k++) {
if (!dock_slot[k]->has_node(name))
continue;
- node=dock_slot[k]->get_node(name)->cast_to<Control>();
+ node = dock_slot[k]->get_node(name)->cast_to<Control>();
if (!node)
continue;
- atidx=k;
+ atidx = k;
break;
}
- if (atidx==-1) //well, it's not anywhere
+ if (atidx == -1) //well, it's not anywhere
continue;
- if (atidx==i) {
+ if (atidx == i) {
node->raise();
continue;
}
-
dock_slot[atidx]->remove_child(node);
- if (dock_slot[atidx]->get_tab_count()==0) {
+ if (dock_slot[atidx]->get_tab_count() == 0) {
dock_slot[atidx]->hide();
-
}
dock_slot[i]->add_child(node);
dock_slot[i]->show();
@@ -4383,50 +4134,50 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String&
}
int fs_split_ofs = 0;
- if (p_layout->has_section_key(p_section,"dock_filesystem_split")) {
- fs_split_ofs = p_layout->get_value(p_section,"dock_filesystem_split");
+ if (p_layout->has_section_key(p_section, "dock_filesystem_split")) {
+ fs_split_ofs = p_layout->get_value(p_section, "dock_filesystem_split");
}
filesystem_dock->set_split_offset(fs_split_ofs);
- VSplitContainer*splits[DOCK_SLOT_MAX/2]={
+ VSplitContainer *splits[DOCK_SLOT_MAX / 2] = {
left_l_vsplit,
left_r_vsplit,
right_l_vsplit,
right_r_vsplit,
};
- for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
+ for (int i = 0; i < DOCK_SLOT_MAX / 2; i++) {
- if (!p_layout->has_section_key(p_section,"dock_split_"+itos(i+1)))
+ if (!p_layout->has_section_key(p_section, "dock_split_" + itos(i + 1)))
continue;
- int ofs = p_layout->get_value(p_section,"dock_split_"+itos(i+1));
+ int ofs = p_layout->get_value(p_section, "dock_split_" + itos(i + 1));
splits[i]->set_split_offset(ofs);
}
- HSplitContainer*h_splits[4]={
+ HSplitContainer *h_splits[4] = {
left_l_hsplit,
left_r_hsplit,
main_hsplit,
right_hsplit,
};
- for(int i=0;i<4;i++) {
- if (!p_layout->has_section_key(p_section,"dock_hsplit_"+itos(i+1)))
+ for (int i = 0; i < 4; i++) {
+ if (!p_layout->has_section_key(p_section, "dock_hsplit_" + itos(i + 1)))
continue;
- int ofs = p_layout->get_value(p_section,"dock_hsplit_"+itos(i+1));
+ int ofs = p_layout->get_value(p_section, "dock_hsplit_" + itos(i + 1));
h_splits[i]->set_split_offset(ofs);
}
- for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
- bool in_use = dock_slot[i*2+0]->get_tab_count() || dock_slot[i*2+1]->get_tab_count();
+ for (int i = 0; i < DOCK_SLOT_MAX / 2; i++) {
+ bool in_use = dock_slot[i * 2 + 0]->get_tab_count() || dock_slot[i * 2 + 1]->get_tab_count();
if (in_use)
splits[i]->show();
else
splits[i]->hide();
}
- for(int i=0;i<DOCK_SLOT_MAX;i++) {
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
if (dock_slot[i]->is_visible() && dock_slot[i]->get_tab_count()) {
dock_slot[i]->set_current_tab(0);
@@ -4434,40 +4185,38 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String&
}
}
-
void EditorNode::_update_layouts_menu() {
editor_layouts->clear();
- overridden_default_layout=-1;
+ overridden_default_layout = -1;
editor_layouts->set_size(Vector2());
- editor_layouts->add_shortcut(ED_SHORTCUT("layout/save",TTR("Save Layout")), SETTINGS_LAYOUT_SAVE);
- editor_layouts->add_shortcut(ED_SHORTCUT("layout/delete",TTR("Delete Layout")), SETTINGS_LAYOUT_DELETE);
+ editor_layouts->add_shortcut(ED_SHORTCUT("layout/save", TTR("Save Layout")), SETTINGS_LAYOUT_SAVE);
+ editor_layouts->add_shortcut(ED_SHORTCUT("layout/delete", TTR("Delete Layout")), SETTINGS_LAYOUT_DELETE);
editor_layouts->add_separator();
- editor_layouts->add_shortcut(ED_SHORTCUT("layout/default",TTR("Default")), SETTINGS_LAYOUT_DEFAULT);
+ editor_layouts->add_shortcut(ED_SHORTCUT("layout/default", TTR("Default")), SETTINGS_LAYOUT_DEFAULT);
Ref<ConfigFile> config;
config.instance();
Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
- if (err!=OK) {
+ if (err != OK) {
return; //no config
}
List<String> layouts;
config.ptr()->get_sections(&layouts);
- for (List<String>::Element *E=layouts.front();E;E=E->next()) {
+ for (List<String>::Element *E = layouts.front(); E; E = E->next()) {
- String layout=E->get();
+ String layout = E->get();
- if (layout==TTR("Default")) {
+ if (layout == TTR("Default")) {
editor_layouts->remove_item(editor_layouts->get_item_index(SETTINGS_LAYOUT_DEFAULT));
- overridden_default_layout=editor_layouts->get_item_count();
+ overridden_default_layout = editor_layouts->get_item_count();
}
editor_layouts->add_item(layout);
}
-
}
void EditorNode::_layout_menu_option(int p_id) {
@@ -4476,14 +4225,14 @@ void EditorNode::_layout_menu_option(int p_id) {
case SETTINGS_LAYOUT_SAVE: {
- current_option=p_id;
+ current_option = p_id;
layout_dialog->set_title(TTR("Save Layout"));
layout_dialog->get_ok()->set_text(TTR("Save"));
layout_dialog->popup_centered();
} break;
case SETTINGS_LAYOUT_DELETE: {
- current_option=p_id;
+ current_option = p_id;
layout_dialog->set_title(TTR("Delete Layout"));
layout_dialog->get_ok()->set_text(TTR("Delete"));
layout_dialog->popup_centered();
@@ -4498,7 +4247,7 @@ void EditorNode::_layout_menu_option(int p_id) {
Ref<ConfigFile> config;
config.instance();
Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg"));
- if (err!=OK) {
+ if (err != OK) {
return; //no config
}
@@ -4506,13 +4255,11 @@ void EditorNode::_layout_menu_option(int p_id) {
_save_docks();
}
}
-
}
-
void EditorNode::_scene_tab_script_edited(int p_tab) {
- Ref<Script> script = editor_data.get_scene_root_script(p_tab);
+ Ref<Script> script = editor_data.get_scene_root_script(p_tab);
if (script.is_valid())
edit_resource(script);
}
@@ -4521,53 +4268,46 @@ void EditorNode::_scene_tab_closed(int p_tab) {
current_option = SCENE_TAB_CLOSE;
tab_closing = p_tab;
- bool unsaved = (p_tab==editor_data.get_edited_scene()) ?
- saved_version!=editor_data.get_undo_redo().get_version() :
- editor_data.get_scene_version(p_tab)!=0;
+ bool unsaved = (p_tab == editor_data.get_edited_scene()) ?
+ saved_version != editor_data.get_undo_redo().get_version() :
+ editor_data.get_scene_version(p_tab) != 0;
if (unsaved) {
confirmation->get_ok()->set_text(TTR("Yes"));
//confirmation->get_cancel()->show();
confirmation->set_text(TTR("Close scene? (Unsaved changes will be lost)"));
confirmation->popup_centered_minsize();
- }
- else {
+ } else {
_remove_scene(p_tab);
_update_scene_tabs();
}
-
}
-
void EditorNode::_scene_tab_changed(int p_tab) {
-
//print_line("set current 1 ");
- bool unsaved = (saved_version!=editor_data.get_undo_redo().get_version());
+ bool unsaved = (saved_version != editor_data.get_undo_redo().get_version());
//print_line("version: "+itos(editor_data.get_undo_redo().get_version())+", saved "+itos(saved_version));
- if (p_tab==editor_data.get_edited_scene())
+ if (p_tab == editor_data.get_edited_scene())
return; //pointless
uint64_t next_scene_version = editor_data.get_scene_version(p_tab);
-
-
//print_line("scene tab changed???");
editor_data.get_undo_redo().create_action(TTR("Switch Scene Tab"));
- editor_data.get_undo_redo().add_do_method(this,"set_current_version",unsaved?saved_version:0);
- editor_data.get_undo_redo().add_do_method(this,"set_current_scene",p_tab);
+ editor_data.get_undo_redo().add_do_method(this, "set_current_version", unsaved ? saved_version : 0);
+ editor_data.get_undo_redo().add_do_method(this, "set_current_scene", p_tab);
//editor_data.get_undo_redo().add_do_method(scene_tabs,"set_current_tab",p_tab);
//editor_data.get_undo_redo().add_do_method(scene_tabs,"ensure_tab_visible",p_tab);
- editor_data.get_undo_redo().add_do_method(this,"set_current_version",next_scene_version==0?editor_data.get_undo_redo().get_version()+1:next_scene_version);
+ editor_data.get_undo_redo().add_do_method(this, "set_current_version", next_scene_version == 0 ? editor_data.get_undo_redo().get_version() + 1 : next_scene_version);
- editor_data.get_undo_redo().add_undo_method(this,"set_current_version",next_scene_version);
- editor_data.get_undo_redo().add_undo_method(this,"set_current_scene",editor_data.get_edited_scene());
+ editor_data.get_undo_redo().add_undo_method(this, "set_current_version", next_scene_version);
+ editor_data.get_undo_redo().add_undo_method(this, "set_current_scene", editor_data.get_edited_scene());
//editor_data.get_undo_redo().add_undo_method(scene_tabs,"set_current_tab",editor_data.get_edited_scene());
//editor_data.get_undo_redo().add_undo_method(scene_tabs,"ensure_tab_visible",p_tab,editor_data.get_edited_scene());
- editor_data.get_undo_redo().add_undo_method(this,"set_current_version",saved_version);
+ editor_data.get_undo_redo().add_undo_method(this, "set_current_version", saved_version);
editor_data.get_undo_redo().commit_action();
-
}
void EditorNode::_toggle_search_bar(bool p_pressed) {
@@ -4587,17 +4327,17 @@ void EditorNode::_toggle_search_bar(bool p_pressed) {
void EditorNode::_clear_search_box() {
- if (search_box->get_text()=="")
+ if (search_box->get_text() == "")
return;
search_box->clear();
property_editor->update_tree();
}
-ToolButton *EditorNode::add_bottom_panel_item(String p_text,Control *p_item) {
+ToolButton *EditorNode::add_bottom_panel_item(String p_text, Control *p_item) {
- ToolButton *tb = memnew( ToolButton );
- tb->connect("toggled",this,"_bottom_panel_switch",varray(bottom_panel_items.size()));
+ ToolButton *tb = memnew(ToolButton);
+ tb->connect("toggled", this, "_bottom_panel_switch", varray(bottom_panel_items.size()));
tb->set_text(p_text);
tb->set_toggle_mode(true);
tb->set_focus_mode(Control::FOCUS_NONE);
@@ -4607,18 +4347,17 @@ ToolButton *EditorNode::add_bottom_panel_item(String p_text,Control *p_item) {
p_item->set_v_size_flags(Control::SIZE_EXPAND_FILL);
p_item->hide();
BottomPanelItem bpi;
- bpi.button=tb;
- bpi.control=p_item;
- bpi.name=p_text;
+ bpi.button = tb;
+ bpi.control = p_item;
+ bpi.name = p_text;
bottom_panel_items.push_back(bpi);
return tb;
-
}
bool EditorNode::are_bottom_panels_hidden() const {
- for(int i=0;i<bottom_panel_items.size();i++) {
+ for (int i = 0; i < bottom_panel_items.size(); i++) {
if (bottom_panel_items[i].button->is_pressed())
return false;
}
@@ -4628,16 +4367,15 @@ bool EditorNode::are_bottom_panels_hidden() const {
void EditorNode::hide_bottom_panel() {
- _bottom_panel_switch(false,0);
-
+ _bottom_panel_switch(false, 0);
}
void EditorNode::make_bottom_panel_item_visible(Control *p_item) {
- for(int i=0;i<bottom_panel_items.size();i++) {
+ for (int i = 0; i < bottom_panel_items.size(); i++) {
- if (bottom_panel_items[i].control==p_item) {
- _bottom_panel_switch(true,i);
+ if (bottom_panel_items[i].control == p_item) {
+ _bottom_panel_switch(true, i);
break;
}
}
@@ -4645,60 +4383,57 @@ void EditorNode::make_bottom_panel_item_visible(Control *p_item) {
void EditorNode::raise_bottom_panel_item(Control *p_item) {
- for(int i=0;i<bottom_panel_items.size();i++) {
+ for (int i = 0; i < bottom_panel_items.size(); i++) {
- if (bottom_panel_items[i].control==p_item) {
+ if (bottom_panel_items[i].control == p_item) {
bottom_panel_items[i].button->raise();
- SWAP( bottom_panel_items[i], bottom_panel_items[bottom_panel_items.size()-1]);
+ SWAP(bottom_panel_items[i], bottom_panel_items[bottom_panel_items.size() - 1]);
break;
}
}
- for(int i=0;i<bottom_panel_items.size();i++) {
- bottom_panel_items[i].button->disconnect("toggled",this,"_bottom_panel_switch");
- bottom_panel_items[i].button->connect("toggled",this,"_bottom_panel_switch",varray(i));
+ for (int i = 0; i < bottom_panel_items.size(); i++) {
+ bottom_panel_items[i].button->disconnect("toggled", this, "_bottom_panel_switch");
+ bottom_panel_items[i].button->connect("toggled", this, "_bottom_panel_switch", varray(i));
}
-
}
void EditorNode::remove_bottom_panel_item(Control *p_item) {
- for(int i=0;i<bottom_panel_items.size();i++) {
+ for (int i = 0; i < bottom_panel_items.size(); i++) {
- if (bottom_panel_items[i].control==p_item) {
+ if (bottom_panel_items[i].control == p_item) {
if (p_item->is_visible_in_tree()) {
- _bottom_panel_switch(false,0);
+ _bottom_panel_switch(false, 0);
}
bottom_panel_vb->remove_child(bottom_panel_items[i].control);
bottom_panel_hb->remove_child(bottom_panel_items[i].button);
- memdelete( bottom_panel_items[i].button );
+ memdelete(bottom_panel_items[i].button);
bottom_panel_items.remove(i);
break;
}
}
- for(int i=0;i<bottom_panel_items.size();i++) {
- bottom_panel_items[i].button->disconnect("toggled",this,"_bottom_panel_switch");
- bottom_panel_items[i].button->connect("toggled",this,"_bottom_panel_switch",varray(i));
+ for (int i = 0; i < bottom_panel_items.size(); i++) {
+ bottom_panel_items[i].button->disconnect("toggled", this, "_bottom_panel_switch");
+ bottom_panel_items[i].button->connect("toggled", this, "_bottom_panel_switch", varray(i));
}
}
-void EditorNode::_bottom_panel_switch(bool p_enable,int p_idx) {
-
- ERR_FAIL_INDEX(p_idx,bottom_panel_items.size());
-
+void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) {
+ ERR_FAIL_INDEX(p_idx, bottom_panel_items.size());
if (p_enable) {
- for(int i=0;i<bottom_panel_items.size();i++) {
+ for (int i = 0; i < bottom_panel_items.size(); i++) {
- bottom_panel_items[i].button->set_pressed(i==p_idx);
- bottom_panel_items[i].control->set_visible(i==p_idx);
+ bottom_panel_items[i].button->set_pressed(i == p_idx);
+ bottom_panel_items[i].control->set_visible(i == p_idx);
}
center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE);
center_split->set_collapsed(false);
} else {
- for(int i=0;i<bottom_panel_items.size();i++) {
+ for (int i = 0; i < bottom_panel_items.size(); i++) {
bottom_panel_items[i].button->set_pressed(false);
bottom_panel_items[i].control->set_visible(false);
@@ -4719,7 +4454,7 @@ bool EditorNode::get_docks_visible() const {
void EditorNode::_toggle_distraction_free_mode() {
- set_distraction_free_mode( distraction_free->is_pressed() );
+ set_distraction_free_mode(distraction_free->is_pressed());
}
void EditorNode::set_distraction_free_mode(bool p_enter) {
@@ -4740,19 +4475,18 @@ bool EditorNode::get_distraction_free_mode() const {
return distraction_free->is_pressed();
}
-void EditorNode::add_control_to_dock(DockSlot p_slot,Control* p_control) {
- ERR_FAIL_INDEX(p_slot,DOCK_SLOT_MAX);
+void EditorNode::add_control_to_dock(DockSlot p_slot, Control *p_control) {
+ ERR_FAIL_INDEX(p_slot, DOCK_SLOT_MAX);
dock_slot[p_slot]->add_child(p_control);
_update_dock_slots_visibility();
-
}
-void EditorNode::remove_control_from_dock(Control* p_control) {
+void EditorNode::remove_control_from_dock(Control *p_control) {
- Control *dock=NULL;
- for(int i=0;i<DOCK_SLOT_MAX;i++) {
- if (p_control->get_parent()==dock_slot[i]) {
- dock=dock_slot[i];
+ Control *dock = NULL;
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
+ if (p_control->get_parent() == dock_slot[i]) {
+ dock = dock_slot[i];
break;
}
}
@@ -4764,139 +4498,128 @@ void EditorNode::remove_control_from_dock(Control* p_control) {
_update_dock_slots_visibility();
}
-Variant EditorNode::drag_resource(const Ref<Resource>& p_res,Control* p_from) {
-
+Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) {
- Control *drag_control = memnew( Control );
- TextureRect *drag_preview = memnew( TextureRect );
- Label* label=memnew( Label );
+ Control *drag_control = memnew(Control);
+ TextureRect *drag_preview = memnew(TextureRect);
+ Label *label = memnew(Label);
Ref<Texture> preview;
{
//todo make proper previews
- Ref<ImageTexture> pic = gui_base->get_icon("FileBig","EditorIcons");
+ Ref<ImageTexture> pic = gui_base->get_icon("FileBig", "EditorIcons");
Image img = pic->get_data();
- img.resize(48,48); //meh
- Ref<ImageTexture> resized_pic = Ref<ImageTexture>( memnew( ImageTexture) );
+ img.resize(48, 48); //meh
+ Ref<ImageTexture> resized_pic = Ref<ImageTexture>(memnew(ImageTexture));
resized_pic->create_from_image(img);
- preview=resized_pic;
+ preview = resized_pic;
}
drag_preview->set_texture(preview);
drag_control->add_child(drag_preview);
if (p_res->get_path().is_resource_file()) {
label->set_text(p_res->get_path().get_file());
- } else if (p_res->get_name()!="") {
+ } else if (p_res->get_name() != "") {
label->set_text(p_res->get_name());
} else {
label->set_text(p_res->get_class());
-
}
drag_control->add_child(label);
p_from->set_drag_preview(drag_control); //wait until it enters scene
- label->set_pos( Point2((preview->get_width()-label->get_minimum_size().width)/2,preview->get_height()) );
+ label->set_pos(Point2((preview->get_width() - label->get_minimum_size().width) / 2, preview->get_height()));
Dictionary drag_data;
- drag_data["type"]="resource";
- drag_data["resource"]=p_res;
- drag_data["from"]=p_from;
-
+ drag_data["type"] = "resource";
+ drag_data["resource"] = p_res;
+ drag_data["from"] = p_from;
return drag_data;
-
}
-Variant EditorNode::drag_files(const Vector<String>& p_files, Control *p_from){
+Variant EditorNode::drag_files(const Vector<String> &p_files, Control *p_from) {
- VBoxContainer *files = memnew( VBoxContainer );
+ VBoxContainer *files = memnew(VBoxContainer);
- int max_files=6;
+ int max_files = 6;
- for(int i=0;i<MIN(max_files,p_files.size());i++) {
+ for (int i = 0; i < MIN(max_files, p_files.size()); i++) {
- Label* label=memnew( Label );
+ Label *label = memnew(Label);
label->set_text(p_files[i].get_file());
files->add_child(label);
}
- if (p_files.size()>max_files) {
+ if (p_files.size() > max_files) {
- Label* label=memnew( Label );
- label->set_text(vformat(TTR("%d more file(s)"), p_files.size()-max_files));
+ Label *label = memnew(Label);
+ label->set_text(vformat(TTR("%d more file(s)"), p_files.size() - max_files));
files->add_child(label);
-
}
Dictionary drag_data;
- drag_data["type"]="files";
- drag_data["files"]=p_files;
- drag_data["from"]=p_from;
+ drag_data["type"] = "files";
+ drag_data["files"] = p_files;
+ drag_data["from"] = p_from;
p_from->set_drag_preview(files); //wait until it enters scene
return drag_data;
-
}
-Variant EditorNode::drag_files_and_dirs(const Vector<String>& p_files, Control *p_from){
+Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_files, Control *p_from) {
- VBoxContainer *files = memnew( VBoxContainer );
+ VBoxContainer *files = memnew(VBoxContainer);
- int max_files=6;
+ int max_files = 6;
- for(int i=0;i<MIN(max_files,p_files.size());i++) {
+ for (int i = 0; i < MIN(max_files, p_files.size()); i++) {
- Label* label=memnew( Label );
+ Label *label = memnew(Label);
label->set_text(p_files[i].get_file());
files->add_child(label);
}
- if (p_files.size()>max_files) {
+ if (p_files.size() > max_files) {
- Label* label=memnew( Label );
- label->set_text(vformat(TTR("%d more file(s) or folder(s)"), p_files.size()-max_files));
+ Label *label = memnew(Label);
+ label->set_text(vformat(TTR("%d more file(s) or folder(s)"), p_files.size() - max_files));
files->add_child(label);
-
}
Dictionary drag_data;
- drag_data["type"]="files_and_dirs";
- drag_data["files"]=p_files;
- drag_data["from"]=p_from;
+ drag_data["type"] = "files_and_dirs";
+ drag_data["files"] = p_files;
+ drag_data["from"] = p_from;
p_from->set_drag_preview(files); //wait until it enters scene
return drag_data;
-
}
-
-void EditorNode::_dropped_files(const Vector<String>& p_files,int p_screen) {
+void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
String cur_path = filesystem_dock->get_current_path();
-// for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) {
-// EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path);
-// }
+ // for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) {
+ // EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path);
+ // }
}
-void EditorNode::_file_access_close_error_notify(const String& p_str) {
+void EditorNode::_file_access_close_error_notify(const String &p_str) {
- add_io_error("Unable to write to file '"+p_str+"', file in use, locked or lacking permissions.");
+ add_io_error("Unable to write to file '" + p_str + "', file in use, locked or lacking permissions.");
}
-
-void EditorNode::reload_scene(const String& p_path) {
-
+void EditorNode::reload_scene(const String &p_path) {
//first of all, reload textures as they might have changed on disk
List<Ref<Resource> > cached;
ResourceCache::get_cached_resources(&cached);
List<Ref<Resource> > to_clear; //clear internal resources from previous scene from being used
- for(List<Ref<Resource> >::Element *E=cached.front();E;E=E->next()) {
+ for (List<Ref<Resource> >::Element *E = cached.front(); E; E = E->next()) {
- if (E->get()->get_path().begins_with(p_path+"::")) //subresources of existing scene
+ if (E->get()->get_path().begins_with(p_path + "::")) //subresources of existing scene
to_clear.push_back(E->get());
if (!E->get()->cast_to<Texture>())
@@ -4906,30 +4629,29 @@ void EditorNode::reload_scene(const String& p_path) {
if (!FileAccess::exists(E->get()->get_path()))
continue;
uint64_t mt = FileAccess::get_modified_time(E->get()->get_path());
- if (mt!=E->get()->get_last_modified_time()) {
+ if (mt != E->get()->get_last_modified_time()) {
E->get()->reload_from_file();
}
}
//so reload reloads everything, clear subresources of previous scene
- while(to_clear.front()) {
+ while (to_clear.front()) {
to_clear.front()->get()->set_path("");
to_clear.pop_front();
}
- int scene_idx=-1;
- for(int i=0;i<editor_data.get_edited_scene_count();i++) {
+ int scene_idx = -1;
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
- if (editor_data.get_scene_path(i)==p_path) {
- scene_idx=i;
+ if (editor_data.get_scene_path(i) == p_path) {
+ scene_idx = i;
break;
}
}
int current_tab = editor_data.get_edited_scene();
-
- if (scene_idx==-1) {
+ if (scene_idx == -1) {
if (get_edited_scene()) {
//scene is not open, so at it might be instanced, just refresh, set tab to itself and it will reload
set_current_scene(current_tab);
@@ -4938,11 +4660,9 @@ void EditorNode::reload_scene(const String& p_path) {
return;
}
-
- if (current_tab==scene_idx) {
+ if (current_tab == scene_idx) {
editor_data.apply_changes_in_editors();
_set_scene_metadata(p_path);
-
}
//remove scene
_remove_scene(scene_idx);
@@ -4956,122 +4676,116 @@ void EditorNode::reload_scene(const String& p_path) {
_scene_tab_changed(current_tab);
}
-int EditorNode::plugin_init_callback_count=0;
+int EditorNode::plugin_init_callback_count = 0;
void EditorNode::add_plugin_init_callback(EditorPluginInitializeCallback p_callback) {
- ERR_FAIL_COND(plugin_init_callback_count==MAX_INIT_CALLBACKS);
+ ERR_FAIL_COND(plugin_init_callback_count == MAX_INIT_CALLBACKS);
- plugin_init_callbacks[plugin_init_callback_count++]=p_callback;
+ plugin_init_callbacks[plugin_init_callback_count++] = p_callback;
}
EditorPluginInitializeCallback EditorNode::plugin_init_callbacks[EditorNode::MAX_INIT_CALLBACKS];
-
-int EditorNode::build_callback_count=0;
+int EditorNode::build_callback_count = 0;
void EditorNode::add_build_callback(EditorBuildCallback p_callback) {
- ERR_FAIL_COND(build_callback_count==MAX_INIT_CALLBACKS);
+ ERR_FAIL_COND(build_callback_count == MAX_INIT_CALLBACKS);
- build_callbacks[build_callback_count++]=p_callback;
+ build_callbacks[build_callback_count++] = p_callback;
}
EditorPluginInitializeCallback EditorNode::build_callbacks[EditorNode::MAX_BUILD_CALLBACKS];
void EditorNode::_call_build() {
- for(int i=0;i<build_callback_count;i++) {
+ for (int i = 0; i < build_callback_count; i++) {
build_callbacks[i]();
}
}
-
-void EditorNode::_inherit_imported(const String& p_action) {
+void EditorNode::_inherit_imported(const String &p_action) {
open_imported->hide();
- load_scene(open_import_request,true,true);
-
+ load_scene(open_import_request, true, true);
}
void EditorNode::_open_imported() {
- load_scene(open_import_request,true,false,true,true);
+ load_scene(open_import_request, true, false, true, true);
}
void EditorNode::_bind_methods() {
-
- ClassDB::bind_method("_menu_option",&EditorNode::_menu_option);
- ClassDB::bind_method("_menu_confirm_current",&EditorNode::_menu_confirm_current);
- ClassDB::bind_method("_dialog_action",&EditorNode::_dialog_action);
- ClassDB::bind_method("_resource_selected",&EditorNode::_resource_selected,DEFVAL(""));
- ClassDB::bind_method("_property_editor_forward",&EditorNode::_property_editor_forward);
- ClassDB::bind_method("_property_editor_back",&EditorNode::_property_editor_back);
- ClassDB::bind_method("_editor_select",&EditorNode::_editor_select);
- ClassDB::bind_method("_node_renamed",&EditorNode::_node_renamed);
- ClassDB::bind_method("edit_node",&EditorNode::edit_node);
- ClassDB::bind_method("_imported",&EditorNode::_imported);
- ClassDB::bind_method("_unhandled_input",&EditorNode::_unhandled_input);
-
- ClassDB::bind_method("_get_scene_metadata",&EditorNode::_get_scene_metadata);
- ClassDB::bind_method("set_edited_scene",&EditorNode::set_edited_scene);
- ClassDB::bind_method("open_request",&EditorNode::open_request);
- ClassDB::bind_method("_instance_request",&EditorNode::_instance_request);
- ClassDB::bind_method("update_keying",&EditorNode::update_keying);
- ClassDB::bind_method("_property_keyed",&EditorNode::_property_keyed);
- ClassDB::bind_method("_transform_keyed",&EditorNode::_transform_keyed);
- ClassDB::bind_method("_close_messages",&EditorNode::_close_messages);
- ClassDB::bind_method("_show_messages",&EditorNode::_show_messages);
- ClassDB::bind_method("_vp_resized",&EditorNode::_vp_resized);
- ClassDB::bind_method("_quick_opened",&EditorNode::_quick_opened);
- ClassDB::bind_method("_quick_run",&EditorNode::_quick_run);
-
- ClassDB::bind_method("_resource_created",&EditorNode::_resource_created);
-
- ClassDB::bind_method("_import_action",&EditorNode::_import_action);
+ ClassDB::bind_method("_menu_option", &EditorNode::_menu_option);
+ ClassDB::bind_method("_menu_confirm_current", &EditorNode::_menu_confirm_current);
+ ClassDB::bind_method("_dialog_action", &EditorNode::_dialog_action);
+ ClassDB::bind_method("_resource_selected", &EditorNode::_resource_selected, DEFVAL(""));
+ ClassDB::bind_method("_property_editor_forward", &EditorNode::_property_editor_forward);
+ ClassDB::bind_method("_property_editor_back", &EditorNode::_property_editor_back);
+ ClassDB::bind_method("_editor_select", &EditorNode::_editor_select);
+ ClassDB::bind_method("_node_renamed", &EditorNode::_node_renamed);
+ ClassDB::bind_method("edit_node", &EditorNode::edit_node);
+ ClassDB::bind_method("_imported", &EditorNode::_imported);
+ ClassDB::bind_method("_unhandled_input", &EditorNode::_unhandled_input);
+
+ ClassDB::bind_method("_get_scene_metadata", &EditorNode::_get_scene_metadata);
+ ClassDB::bind_method("set_edited_scene", &EditorNode::set_edited_scene);
+ ClassDB::bind_method("open_request", &EditorNode::open_request);
+ ClassDB::bind_method("_instance_request", &EditorNode::_instance_request);
+ ClassDB::bind_method("update_keying", &EditorNode::update_keying);
+ ClassDB::bind_method("_property_keyed", &EditorNode::_property_keyed);
+ ClassDB::bind_method("_transform_keyed", &EditorNode::_transform_keyed);
+ ClassDB::bind_method("_close_messages", &EditorNode::_close_messages);
+ ClassDB::bind_method("_show_messages", &EditorNode::_show_messages);
+ ClassDB::bind_method("_vp_resized", &EditorNode::_vp_resized);
+ ClassDB::bind_method("_quick_opened", &EditorNode::_quick_opened);
+ ClassDB::bind_method("_quick_run", &EditorNode::_quick_run);
+
+ ClassDB::bind_method("_resource_created", &EditorNode::_resource_created);
+
+ ClassDB::bind_method("_import_action", &EditorNode::_import_action);
//ClassDB::bind_method("_import",&EditorNode::_import);
//ClassDB::bind_method("_import_conflicts_solved",&EditorNode::_import_conflicts_solved);
- ClassDB::bind_method("_open_recent_scene",&EditorNode::_open_recent_scene);
+ ClassDB::bind_method("_open_recent_scene", &EditorNode::_open_recent_scene);
//ClassDB::bind_method("_open_recent_scene_confirm",&EditorNode::_open_recent_scene_confirm);
- ClassDB::bind_method("_save_optimized",&EditorNode::_save_optimized);
-
- ClassDB::bind_method("stop_child_process",&EditorNode::stop_child_process);
-
- ClassDB::bind_method("_sources_changed",&EditorNode::_sources_changed);
- ClassDB::bind_method("_fs_changed",&EditorNode::_fs_changed);
- ClassDB::bind_method("_dock_select_draw",&EditorNode::_dock_select_draw);
- ClassDB::bind_method("_dock_select_input",&EditorNode::_dock_select_input);
- ClassDB::bind_method("_dock_pre_popup",&EditorNode::_dock_pre_popup);
- ClassDB::bind_method("_dock_split_dragged",&EditorNode::_dock_split_dragged);
- ClassDB::bind_method("_save_docks",&EditorNode::_save_docks);
- ClassDB::bind_method("_dock_popup_exit",&EditorNode::_dock_popup_exit);
- ClassDB::bind_method("_dock_move_left",&EditorNode::_dock_move_left);
- ClassDB::bind_method("_dock_move_right",&EditorNode::_dock_move_right);
-
- ClassDB::bind_method("_layout_menu_option",&EditorNode::_layout_menu_option);
-
- ClassDB::bind_method("set_current_scene",&EditorNode::set_current_scene);
- ClassDB::bind_method("set_current_version",&EditorNode::set_current_version);
- ClassDB::bind_method("_scene_tab_changed",&EditorNode::_scene_tab_changed);
- ClassDB::bind_method("_scene_tab_closed",&EditorNode::_scene_tab_closed);
- ClassDB::bind_method("_scene_tab_script_edited",&EditorNode::_scene_tab_script_edited);
- ClassDB::bind_method("_set_main_scene_state",&EditorNode::_set_main_scene_state);
- ClassDB::bind_method("_update_scene_tabs",&EditorNode::_update_scene_tabs);
-
- ClassDB::bind_method("_prepare_history",&EditorNode::_prepare_history);
- ClassDB::bind_method("_select_history",&EditorNode::_select_history);
-
- ClassDB::bind_method("_toggle_search_bar",&EditorNode::_toggle_search_bar);
- ClassDB::bind_method("_clear_search_box",&EditorNode::_clear_search_box);
- ClassDB::bind_method("_clear_undo_history",&EditorNode::_clear_undo_history);
- ClassDB::bind_method("_dropped_files",&EditorNode::_dropped_files);
- ClassDB::bind_method("_toggle_distraction_free_mode",&EditorNode::_toggle_distraction_free_mode);
-
-
-
-// ClassDB::bind_method(D_METHOD("add_editor_import_plugin", "plugin"), &EditorNode::add_editor_import_plugin);
+ ClassDB::bind_method("_save_optimized", &EditorNode::_save_optimized);
+
+ ClassDB::bind_method("stop_child_process", &EditorNode::stop_child_process);
+
+ ClassDB::bind_method("_sources_changed", &EditorNode::_sources_changed);
+ ClassDB::bind_method("_fs_changed", &EditorNode::_fs_changed);
+ ClassDB::bind_method("_dock_select_draw", &EditorNode::_dock_select_draw);
+ ClassDB::bind_method("_dock_select_input", &EditorNode::_dock_select_input);
+ ClassDB::bind_method("_dock_pre_popup", &EditorNode::_dock_pre_popup);
+ ClassDB::bind_method("_dock_split_dragged", &EditorNode::_dock_split_dragged);
+ ClassDB::bind_method("_save_docks", &EditorNode::_save_docks);
+ ClassDB::bind_method("_dock_popup_exit", &EditorNode::_dock_popup_exit);
+ ClassDB::bind_method("_dock_move_left", &EditorNode::_dock_move_left);
+ ClassDB::bind_method("_dock_move_right", &EditorNode::_dock_move_right);
+
+ ClassDB::bind_method("_layout_menu_option", &EditorNode::_layout_menu_option);
+
+ ClassDB::bind_method("set_current_scene", &EditorNode::set_current_scene);
+ ClassDB::bind_method("set_current_version", &EditorNode::set_current_version);
+ ClassDB::bind_method("_scene_tab_changed", &EditorNode::_scene_tab_changed);
+ ClassDB::bind_method("_scene_tab_closed", &EditorNode::_scene_tab_closed);
+ ClassDB::bind_method("_scene_tab_script_edited", &EditorNode::_scene_tab_script_edited);
+ ClassDB::bind_method("_set_main_scene_state", &EditorNode::_set_main_scene_state);
+ ClassDB::bind_method("_update_scene_tabs", &EditorNode::_update_scene_tabs);
+
+ ClassDB::bind_method("_prepare_history", &EditorNode::_prepare_history);
+ ClassDB::bind_method("_select_history", &EditorNode::_select_history);
+
+ ClassDB::bind_method("_toggle_search_bar", &EditorNode::_toggle_search_bar);
+ ClassDB::bind_method("_clear_search_box", &EditorNode::_clear_search_box);
+ ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history);
+ ClassDB::bind_method("_dropped_files", &EditorNode::_dropped_files);
+ ClassDB::bind_method("_toggle_distraction_free_mode", &EditorNode::_toggle_distraction_free_mode);
+
+ // ClassDB::bind_method(D_METHOD("add_editor_import_plugin", "plugin"), &EditorNode::add_editor_import_plugin);
//ClassDB::bind_method(D_METHOD("remove_editor_import_plugin", "plugin"), &EditorNode::remove_editor_import_plugin);
ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base);
ClassDB::bind_method(D_METHOD("_bottom_panel_switch"), &EditorNode::_bottom_panel_switch);
@@ -5079,25 +4793,22 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_open_imported"), &EditorNode::_open_imported);
ClassDB::bind_method(D_METHOD("_inherit_imported"), &EditorNode::_inherit_imported);
- ADD_SIGNAL( MethodInfo("play_pressed") );
- ADD_SIGNAL( MethodInfo("pause_pressed") );
- ADD_SIGNAL( MethodInfo("stop_pressed") );
- ADD_SIGNAL( MethodInfo("request_help") );
- ADD_SIGNAL( MethodInfo("script_add_function_request",PropertyInfo(Variant::OBJECT,"obj"),PropertyInfo(Variant::STRING,"function"),PropertyInfo(Variant::POOL_STRING_ARRAY,"args")) );
- ADD_SIGNAL( MethodInfo("resource_saved",PropertyInfo(Variant::OBJECT,"obj")) );
-
-
-
+ ADD_SIGNAL(MethodInfo("play_pressed"));
+ ADD_SIGNAL(MethodInfo("pause_pressed"));
+ ADD_SIGNAL(MethodInfo("stop_pressed"));
+ ADD_SIGNAL(MethodInfo("request_help"));
+ ADD_SIGNAL(MethodInfo("script_add_function_request", PropertyInfo(Variant::OBJECT, "obj"), PropertyInfo(Variant::STRING, "function"), PropertyInfo(Variant::POOL_STRING_ARRAY, "args")));
+ ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "obj")));
}
-static Node* _resource_get_edited_scene() {
+static Node *_resource_get_edited_scene() {
return EditorNode::get_singleton()->get_edited_scene();
}
EditorNode::EditorNode() {
- Resource::_get_local_scene_func=_resource_get_edited_scene;
+ Resource::_get_local_scene_func = _resource_get_edited_scene;
VisualServer::get_singleton()->textures_keep_original(true);
@@ -5116,15 +4827,13 @@ EditorNode::EditorNode() {
id->set_custom_mouse_cursor(RES());
}
-
- singleton=this;
- exiting=false;
- last_checked_version=0;
- changing_scene=false;
- _initializing_addons=false;
+ singleton = this;
+ exiting = false;
+ last_checked_version = 0;
+ changing_scene = false;
+ _initializing_addons = false;
docks_visible = true;
-
FileAccess::set_backup_save(true);
TranslationServer::get_singleton()->set_enabled(false);
@@ -5135,35 +4844,33 @@ EditorNode::EditorNode() {
bool use_single_dock_column = false;
{
int dpi_mode = EditorSettings::get_singleton()->get("interface/hidpi_mode");
- if (dpi_mode==0) {
- editor_set_scale( OS::get_singleton()->get_screen_dpi(0) > 150 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x>2000 ? 2.0 : 1.0 );
+ if (dpi_mode == 0) {
+ editor_set_scale(OS::get_singleton()->get_screen_dpi(0) > 150 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x > 2000 ? 2.0 : 1.0);
- use_single_dock_column = OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x<1200;
+ use_single_dock_column = OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x < 1200;
- } else if (dpi_mode==1) {
+ } else if (dpi_mode == 1) {
editor_set_scale(0.75);
- } else if (dpi_mode==2) {
+ } else if (dpi_mode == 2) {
editor_set_scale(1.0);
- } else if (dpi_mode==3) {
+ } else if (dpi_mode == 3) {
editor_set_scale(1.5);
- } else if (dpi_mode==4) {
+ } else if (dpi_mode == 4) {
editor_set_scale(2.0);
}
}
-
ResourceLoader::set_abort_on_missing_resources(false);
FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"));
EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"));
EditorFileDialog::set_default_display_mode((EditorFileDialog::DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int());
- ResourceLoader::set_error_notify_func(this,_load_error_notify);
- ResourceLoader::set_dependency_error_notify_func(this,_dependency_error_report);
+ ResourceLoader::set_error_notify_func(this, _load_error_notify);
+ ResourceLoader::set_dependency_error_notify_func(this, _dependency_error_report);
ResourceLoader::set_timestamp_on_load(true);
ResourceSaver::set_timestamp_on_save(true);
-
- { //register importers at the begining, so dialogs are created with the right extensions
+ { //register importers at the begining, so dialogs are created with the right extensions
Ref<ResourceImporterTexture> import_texture;
import_texture.instance();
ResourceFormatImporter::get_singleton()->add_importer(import_texture);
@@ -5176,7 +4883,6 @@ EditorNode::EditorNode() {
import_wav.instance();
ResourceFormatImporter::get_singleton()->add_importer(import_wav);
-
Ref<ResourceImporterOBJ> import_obj;
import_obj.instance();
ResourceFormatImporter::get_singleton()->add_importer(import_obj);
@@ -5190,60 +4896,58 @@ EditorNode::EditorNode() {
import_collada.instance();
import_scene->add_importer(import_collada);
}
-
}
_pvrtc_register_compressors();
- editor_selection = memnew( EditorSelection );
+ editor_selection = memnew(EditorSelection);
- EditorFileSystem *efs = memnew( EditorFileSystem );
+ EditorFileSystem *efs = memnew(EditorFileSystem);
add_child(efs);
//used for previews
- FileDialog::get_icon_func=_file_dialog_get_icon;
- FileDialog::register_func=_file_dialog_register;
- FileDialog::unregister_func=_file_dialog_unregister;
+ FileDialog::get_icon_func = _file_dialog_get_icon;
+ FileDialog::register_func = _file_dialog_register;
+ FileDialog::unregister_func = _file_dialog_unregister;
- EditorFileDialog::get_icon_func=_file_dialog_get_icon;
- EditorFileDialog::register_func=_editor_file_dialog_register;
- EditorFileDialog::unregister_func=_editor_file_dialog_unregister;
+ EditorFileDialog::get_icon_func = _file_dialog_get_icon;
+ EditorFileDialog::register_func = _editor_file_dialog_register;
+ EditorFileDialog::unregister_func = _editor_file_dialog_unregister;
- editor_export = memnew( EditorExport );
+ editor_export = memnew(EditorExport);
add_child(editor_export);
-
register_exporters();
- GLOBAL_DEF("editor/main_run_args","");
+ GLOBAL_DEF("editor/main_run_args", "");
- ClassDB::set_class_enabled("CollisionShape",true);
- ClassDB::set_class_enabled("CollisionShape2D",true);
- ClassDB::set_class_enabled("CollisionPolygon2D",true);
+ ClassDB::set_class_enabled("CollisionShape", true);
+ ClassDB::set_class_enabled("CollisionShape2D", true);
+ ClassDB::set_class_enabled("CollisionPolygon2D", true);
- Control *theme_base = memnew( Control );
+ Control *theme_base = memnew(Control);
add_child(theme_base);
theme_base->set_area_as_parent_rect();
- gui_base = memnew( Panel );
+ gui_base = memnew(Panel);
theme_base->add_child(gui_base);
gui_base->set_area_as_parent_rect();
Ref<Theme> theme = create_editor_theme();
- theme_base->set_theme( theme );
+ theme_base->set_theme(theme);
gui_base->set_theme(create_custom_theme());
- resource_preview = memnew( EditorResourcePreview );
+ resource_preview = memnew(EditorResourcePreview);
add_child(resource_preview);
- progress_dialog = memnew( ProgressDialog );
+ progress_dialog = memnew(ProgressDialog);
gui_base->add_child(progress_dialog);
// take up all screen
- gui_base->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
- gui_base->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END );
- gui_base->set_end( Point2(0,0) );
+ gui_base->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END);
+ gui_base->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_END);
+ gui_base->set_end(Point2(0, 0));
- main_vbox = memnew( VBoxContainer );
+ main_vbox = memnew(VBoxContainer);
gui_base->add_child(main_vbox);
main_vbox->set_area_as_parent_rect(8);
@@ -5265,175 +4969,164 @@ EditorNode::EditorNode() {
top_dark_panel->add_child(top_dark_vb);
#endif
-
-
- menu_hb = memnew( HBoxContainer );
+ menu_hb = memnew(HBoxContainer);
main_vbox->add_child(menu_hb);
//top_dark_vb->add_child(scene_tabs);
//left
- left_l_hsplit = memnew( HSplitContainer );
+ left_l_hsplit = memnew(HSplitContainer);
main_vbox->add_child(left_l_hsplit);
left_l_hsplit->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- left_l_vsplit = memnew( VSplitContainer );
+ left_l_vsplit = memnew(VSplitContainer);
left_l_hsplit->add_child(left_l_vsplit);
- dock_slot[DOCK_SLOT_LEFT_UL]=memnew( TabContainer );
+ dock_slot[DOCK_SLOT_LEFT_UL] = memnew(TabContainer);
left_l_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_UL]);
- dock_slot[DOCK_SLOT_LEFT_BL]=memnew( TabContainer );
+ dock_slot[DOCK_SLOT_LEFT_BL] = memnew(TabContainer);
left_l_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_BL]);
left_l_vsplit->hide();
dock_slot[DOCK_SLOT_LEFT_UL]->hide();
dock_slot[DOCK_SLOT_LEFT_BL]->hide();
- left_r_hsplit = memnew( HSplitContainer );
+ left_r_hsplit = memnew(HSplitContainer);
left_l_hsplit->add_child(left_r_hsplit);
- left_r_vsplit = memnew( VSplitContainer );
+ left_r_vsplit = memnew(VSplitContainer);
left_r_hsplit->add_child(left_r_vsplit);
- dock_slot[DOCK_SLOT_LEFT_UR]=memnew( TabContainer );
+ dock_slot[DOCK_SLOT_LEFT_UR] = memnew(TabContainer);
left_r_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_UR]);
- dock_slot[DOCK_SLOT_LEFT_BR]=memnew( TabContainer );
+ dock_slot[DOCK_SLOT_LEFT_BR] = memnew(TabContainer);
left_r_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_BR]);
//left_r_vsplit->hide();
//dock_slot[DOCK_SLOT_LEFT_UR]->hide();
//dock_slot[DOCK_SLOT_LEFT_BR]->hide();
-
- main_hsplit = memnew( HSplitContainer );
+ main_hsplit = memnew(HSplitContainer);
left_r_hsplit->add_child(main_hsplit);
//main_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- VBoxContainer * center_vb = memnew( VBoxContainer);
+ VBoxContainer *center_vb = memnew(VBoxContainer);
main_hsplit->add_child(center_vb);
center_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- center_split = memnew( VSplitContainer );
+ center_split = memnew(VSplitContainer);
//main_hsplit->add_child(center_split);
center_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
center_split->set_collapsed(false);
center_vb->add_child(center_split);
- right_hsplit = memnew( HSplitContainer );
+ right_hsplit = memnew(HSplitContainer);
main_hsplit->add_child(right_hsplit);
- right_l_vsplit = memnew( VSplitContainer );
+ right_l_vsplit = memnew(VSplitContainer);
right_hsplit->add_child(right_l_vsplit);
- dock_slot[DOCK_SLOT_RIGHT_UL]=memnew( TabContainer );
+ dock_slot[DOCK_SLOT_RIGHT_UL] = memnew(TabContainer);
right_l_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_UL]);
- dock_slot[DOCK_SLOT_RIGHT_BL]=memnew( TabContainer );
+ dock_slot[DOCK_SLOT_RIGHT_BL] = memnew(TabContainer);
right_l_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_BL]);
//right_l_vsplit->hide();
//dock_slot[DOCK_SLOT_RIGHT_UL]->hide();
//dock_slot[DOCK_SLOT_RIGHT_BL]->hide();
- right_r_vsplit = memnew( VSplitContainer );
+ right_r_vsplit = memnew(VSplitContainer);
right_hsplit->add_child(right_r_vsplit);
- dock_slot[DOCK_SLOT_RIGHT_UR]=memnew( TabContainer );
+ dock_slot[DOCK_SLOT_RIGHT_UR] = memnew(TabContainer);
right_r_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_UR]);
- dock_slot[DOCK_SLOT_RIGHT_BR]=memnew( TabContainer );
+ dock_slot[DOCK_SLOT_RIGHT_BR] = memnew(TabContainer);
right_r_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_BR]);
right_r_vsplit->hide();
dock_slot[DOCK_SLOT_RIGHT_UR]->hide();
dock_slot[DOCK_SLOT_RIGHT_BR]->hide();
- left_l_vsplit->connect("dragged",this,"_dock_split_dragged");
- left_r_vsplit->connect("dragged",this,"_dock_split_dragged");
- right_l_vsplit->connect("dragged",this,"_dock_split_dragged");
- right_r_vsplit->connect("dragged",this,"_dock_split_dragged");
-
- left_l_hsplit->connect("dragged",this,"_dock_split_dragged");
- left_r_hsplit->connect("dragged",this,"_dock_split_dragged");
- main_hsplit->connect("dragged",this,"_dock_split_dragged");
- right_hsplit->connect("dragged",this,"_dock_split_dragged");
-
+ left_l_vsplit->connect("dragged", this, "_dock_split_dragged");
+ left_r_vsplit->connect("dragged", this, "_dock_split_dragged");
+ right_l_vsplit->connect("dragged", this, "_dock_split_dragged");
+ right_r_vsplit->connect("dragged", this, "_dock_split_dragged");
+ left_l_hsplit->connect("dragged", this, "_dock_split_dragged");
+ left_r_hsplit->connect("dragged", this, "_dock_split_dragged");
+ main_hsplit->connect("dragged", this, "_dock_split_dragged");
+ right_hsplit->connect("dragged", this, "_dock_split_dragged");
- dock_select_popoup = memnew( PopupPanel );
+ dock_select_popoup = memnew(PopupPanel);
gui_base->add_child(dock_select_popoup);
- VBoxContainer *dock_vb = memnew( VBoxContainer );
+ VBoxContainer *dock_vb = memnew(VBoxContainer);
dock_select_popoup->add_child(dock_vb);
- HBoxContainer *dock_hb = memnew( HBoxContainer);
- dock_tab_move_left = memnew( ToolButton );
- dock_tab_move_left->set_icon(theme->get_icon("Back","EditorIcons"));
+ HBoxContainer *dock_hb = memnew(HBoxContainer);
+ dock_tab_move_left = memnew(ToolButton);
+ dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons"));
dock_tab_move_left->set_focus_mode(Control::FOCUS_NONE);
- dock_tab_move_left->connect("pressed",this,"_dock_move_left");
+ dock_tab_move_left->connect("pressed", this, "_dock_move_left");
//dock_tab_move_left->set_h_size_flags(Control::SIZE_EXPAND_FILL);
dock_hb->add_child(dock_tab_move_left);
dock_hb->add_spacer();
- dock_tab_move_right = memnew( ToolButton );
- dock_tab_move_right->set_icon(theme->get_icon("Forward","EditorIcons"));
+ dock_tab_move_right = memnew(ToolButton);
+ dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons"));
dock_tab_move_right->set_focus_mode(Control::FOCUS_NONE);
- dock_tab_move_right->connect("pressed",this,"_dock_move_right");
+ dock_tab_move_right->connect("pressed", this, "_dock_move_right");
//dock_tab_move_right->set_h_size_flags(Control::SIZE_EXPAND_FILL);
dock_hb->add_child(dock_tab_move_right);
dock_vb->add_child(dock_hb);
- dock_select = memnew( Control );
- dock_select->set_custom_minimum_size(Size2(128,64)*EDSCALE);
- dock_select->connect("gui_input",this,"_dock_select_input");
- dock_select->connect("draw",this,"_dock_select_draw");
- dock_select->connect("mouse_exited",this,"_dock_popup_exit");
+ dock_select = memnew(Control);
+ dock_select->set_custom_minimum_size(Size2(128, 64) * EDSCALE);
+ dock_select->connect("gui_input", this, "_dock_select_input");
+ dock_select->connect("draw", this, "_dock_select_draw");
+ dock_select->connect("mouse_exited", this, "_dock_popup_exit");
dock_select->set_v_size_flags(Control::SIZE_EXPAND_FILL);
dock_vb->add_child(dock_select);
-
-
dock_select_popoup->set_as_minsize();
- dock_select_rect_over=-1;
- dock_popup_selected=-1;
+ dock_select_rect_over = -1;
+ dock_popup_selected = -1;
//dock_select_popoup->set_(Size2(20,20));
- for(int i=0;i<DOCK_SLOT_MAX;i++) {
- dock_slot[i]->set_custom_minimum_size(Size2(230,220)*EDSCALE);
+ for (int i = 0; i < DOCK_SLOT_MAX; i++) {
+ dock_slot[i]->set_custom_minimum_size(Size2(230, 220) * EDSCALE);
dock_slot[i]->set_v_size_flags(Control::SIZE_EXPAND_FILL);
dock_slot[i]->set_popup(dock_select_popoup);
- dock_slot[i]->connect("pre_popup_pressed",this,"_dock_pre_popup",varray(i));
+ dock_slot[i]->connect("pre_popup_pressed", this, "_dock_pre_popup", varray(i));
//dock_slot[i]->set_tab_align(TabContainer::ALIGN_LEFT);
}
- dock_drag_timer = memnew( Timer );
+ dock_drag_timer = memnew(Timer);
add_child(dock_drag_timer);
dock_drag_timer->set_wait_time(0.5);
dock_drag_timer->set_one_shot(true);
- dock_drag_timer->connect("timeout",this,"_save_docks");
+ dock_drag_timer->connect("timeout", this, "_save_docks");
- top_split = memnew( VSplitContainer );
+ top_split = memnew(VSplitContainer);
center_split->add_child(top_split);
top_split->set_v_size_flags(Control::SIZE_EXPAND_FILL);
top_split->set_collapsed(true);
- VBoxContainer *srt = memnew( VBoxContainer );
+ VBoxContainer *srt = memnew(VBoxContainer);
srt->set_v_size_flags(Control::SIZE_EXPAND_FILL);
top_split->add_child(srt);
- srt->add_constant_override("separation",0);
+ srt->add_constant_override("separation", 0);
-
-/* main_editor_tabs = memnew( Tabs );
+ /* main_editor_tabs = memnew( Tabs );
main_editor_tabs->connect("tab_changed",this,"_editor_select");
main_editor_tabs->set_tab_close_display_policy(Tabs::SHOW_NEVER);
*/
- scene_tabs=memnew( Tabs );
+ scene_tabs = memnew(Tabs);
scene_tabs->add_tab("unsaved");
scene_tabs->set_tab_align(Tabs::ALIGN_CENTER);
- scene_tabs->set_tab_close_display_policy( (bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY) );
- scene_tabs->connect("tab_changed",this,"_scene_tab_changed");
- scene_tabs->connect("right_button_pressed",this,"_scene_tab_script_edited");
+ scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY));
+ scene_tabs->connect("tab_changed", this, "_scene_tab_changed");
+ scene_tabs->connect("right_button_pressed", this, "_scene_tab_script_edited");
scene_tabs->connect("tab_close", this, "_scene_tab_closed");
srt->add_child(scene_tabs);
- scene_root_parent = memnew( PanelContainer );
- scene_root_parent->set_custom_minimum_size(Size2(0,80)*EDSCALE);
-
-
+ scene_root_parent = memnew(PanelContainer);
+ scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE);
//Ref<StyleBox> sp = scene_root_parent->get_stylebox("panel","TabContainer");
//scene_root_parent->add_style_override("panel",sp);
-
/*scene_root_parent->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
scene_root_parent->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END );
scene_root_parent->set_begin( Point2( 0, 0) );
@@ -5441,133 +5134,122 @@ EditorNode::EditorNode() {
srt->add_child(scene_root_parent);
scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL);
-
- scene_root = memnew( Viewport );
+ scene_root = memnew(Viewport);
scene_root->set_disable_3d(true);
-
-
//scene_root_base->add_child(scene_root);
//scene_root->set_meta("_editor_disable_input",true);
- VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(),true);
+ VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true);
scene_root->set_disable_input(true);
scene_root->set_as_audio_listener_2d(true);
//scene_root->set_size_override(true,Size2(GlobalConfig::get_singleton()->get("display/width"),GlobalConfig::get_singleton()->get("display/height")));
//scene_root->set_world_2d( Ref<World2D>( memnew( World2D )) );
-
- viewport = memnew( VBoxContainer );
+ viewport = memnew(VBoxContainer);
viewport->set_v_size_flags(Control::SIZE_EXPAND_FILL);
/*for(int i=0;i<4;i++) {
viewport->set_margin(Margin(i),sp->get_margin(Margin(i)));
}*/
scene_root_parent->add_child(viewport);
-
-
- PanelContainer *top_region = memnew( PanelContainer );
- top_region->add_style_override("panel",gui_base->get_stylebox("hover","Button"));
- HBoxContainer *left_menu_hb = memnew( HBoxContainer );
+ PanelContainer *top_region = memnew(PanelContainer);
+ top_region->add_style_override("panel", gui_base->get_stylebox("hover", "Button"));
+ HBoxContainer *left_menu_hb = memnew(HBoxContainer);
top_region->add_child(left_menu_hb);
menu_hb->add_child(top_region);
PopupMenu *p;
-
-
- file_menu = memnew( MenuButton );
+ file_menu = memnew(MenuButton);
file_menu->set_text(TTR("Scene"));
//file_menu->set_icon(gui_base->get_icon("Save","EditorIcons"));
- left_menu_hb->add_child( file_menu );
+ left_menu_hb->add_child(file_menu);
- prev_scene = memnew( ToolButton );
- prev_scene->set_icon(gui_base->get_icon("PrevScene","EditorIcons"));
+ prev_scene = memnew(ToolButton);
+ prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons"));
prev_scene->set_tooltip(TTR("Go to previously opened scene."));
prev_scene->set_disabled(true);
//left_menu_hb->add_child( prev_scene );
- prev_scene->connect("pressed",this,"_menu_option",make_binds(FILE_OPEN_PREV));
+ prev_scene->connect("pressed", this, "_menu_option", make_binds(FILE_OPEN_PREV));
gui_base->add_child(prev_scene);
- prev_scene->set_pos(Point2(3,24));
+ prev_scene->set_pos(Point2(3, 24));
prev_scene->hide();
-
-
- ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD+KEY_TAB);
- ED_SHORTCUT("editor/prev_tab", TTR("Previous tab"), KEY_MASK_CMD+KEY_MASK_SHIFT+KEY_TAB);
- ED_SHORTCUT("editor/filter_files", TTR("Filter Files.."), KEY_MASK_ALT+KEY_MASK_CMD+KEY_P);
-
+ ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD + KEY_TAB);
+ ED_SHORTCUT("editor/prev_tab", TTR("Previous tab"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_TAB);
+ ED_SHORTCUT("editor/filter_files", TTR("Filter Files.."), KEY_MASK_ALT + KEY_MASK_CMD + KEY_P);
file_menu->set_tooltip(TTR("Operations with scene files."));
- p=file_menu->get_popup();
- p->add_shortcut(ED_SHORTCUT("editor/new_scene",TTR("New Scene")),FILE_NEW_SCENE);
- p->add_shortcut(ED_SHORTCUT("editor/new_inherited_scene",TTR("New Inherited Scene..")),FILE_NEW_INHERITED_SCENE);
- p->add_shortcut(ED_SHORTCUT("editor/open_scene",TTR("Open Scene.."),KEY_MASK_CMD+KEY_O),FILE_OPEN_SCENE);
+ p = file_menu->get_popup();
+ p->add_shortcut(ED_SHORTCUT("editor/new_scene", TTR("New Scene")), FILE_NEW_SCENE);
+ p->add_shortcut(ED_SHORTCUT("editor/new_inherited_scene", TTR("New Inherited Scene..")), FILE_NEW_INHERITED_SCENE);
+ p->add_shortcut(ED_SHORTCUT("editor/open_scene", TTR("Open Scene.."), KEY_MASK_CMD + KEY_O), FILE_OPEN_SCENE);
p->add_separator();
- p->add_shortcut(ED_SHORTCUT("editor/save_scene",TTR("Save Scene"),KEY_MASK_CMD+KEY_S),FILE_SAVE_SCENE);
- p->add_shortcut(ED_SHORTCUT("editor/save_scene_as",TTR("Save Scene As.."),KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S),FILE_SAVE_AS_SCENE);
- p->add_shortcut(ED_SHORTCUT("editor/save_all_scenes",TTR("Save all Scenes"),KEY_MASK_ALT+KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S),FILE_SAVE_ALL_SCENES);
+ p->add_shortcut(ED_SHORTCUT("editor/save_scene", TTR("Save Scene"), KEY_MASK_CMD + KEY_S), FILE_SAVE_SCENE);
+ p->add_shortcut(ED_SHORTCUT("editor/save_scene_as", TTR("Save Scene As.."), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_S), FILE_SAVE_AS_SCENE);
+ p->add_shortcut(ED_SHORTCUT("editor/save_all_scenes", TTR("Save all Scenes"), KEY_MASK_ALT + KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_S), FILE_SAVE_ALL_SCENES);
p->add_separator();
- p->add_shortcut(ED_SHORTCUT("editor/close_scene",TTR("Close Scene"),KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_W),FILE_CLOSE);
+ p->add_shortcut(ED_SHORTCUT("editor/close_scene", TTR("Close Scene"), KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_W), FILE_CLOSE);
p->add_separator();
//p->add_shortcut(ED_SHORTCUT("editor/save_scene",TTR("Close Goto Prev. Scene")),FILE_OPEN_PREV,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_P);
- p->add_submenu_item(TTR("Open Recent"),"RecentScenes",FILE_OPEN_RECENT);
+ p->add_submenu_item(TTR("Open Recent"), "RecentScenes", FILE_OPEN_RECENT);
p->add_separator();
- p->add_shortcut(ED_SHORTCUT("editor/quick_open_scene",TTR("Quick Open Scene.."),KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_O),FILE_QUICK_OPEN_SCENE);
- p->add_shortcut(ED_SHORTCUT("editor/quick_open_script",TTR("Quick Open Script.."),KEY_MASK_ALT+KEY_MASK_CMD+KEY_O),FILE_QUICK_OPEN_SCRIPT);
+ p->add_shortcut(ED_SHORTCUT("editor/quick_open_scene", TTR("Quick Open Scene.."), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_O), FILE_QUICK_OPEN_SCENE);
+ p->add_shortcut(ED_SHORTCUT("editor/quick_open_script", TTR("Quick Open Script.."), KEY_MASK_ALT + KEY_MASK_CMD + KEY_O), FILE_QUICK_OPEN_SCRIPT);
p->add_separator();
- PopupMenu *pm_export = memnew(PopupMenu );
+ PopupMenu *pm_export = memnew(PopupMenu);
pm_export->set_name("Export");
p->add_child(pm_export);
- p->add_submenu_item(TTR("Convert To.."),"Export");
+ p->add_submenu_item(TTR("Convert To.."), "Export");
pm_export->add_separator();
pm_export->add_shortcut(ED_SHORTCUT("editor/convert_to_MeshLibrary", TTR("MeshLibrary..")), FILE_EXPORT_MESH_LIBRARY);
pm_export->add_shortcut(ED_SHORTCUT("editor/convert_to_TileSet", TTR("TileSet..")), FILE_EXPORT_TILESET);
- pm_export->connect("id_pressed",this,"_menu_option");
+ pm_export->connect("id_pressed", this, "_menu_option");
p->add_separator();
- p->add_shortcut(ED_SHORTCUT("editor/undo", TTR("Undo"),KEY_MASK_CMD+KEY_Z),EDIT_UNDO,true);
- p->add_shortcut(ED_SHORTCUT("editor/redo", TTR("Redo"),KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_Z),EDIT_REDO,true);
+ p->add_shortcut(ED_SHORTCUT("editor/undo", TTR("Undo"), KEY_MASK_CMD + KEY_Z), EDIT_UNDO, true);
+ p->add_shortcut(ED_SHORTCUT("editor/redo", TTR("Redo"), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_Z), EDIT_REDO, true);
p->add_separator();
- p->add_item(TTR("Run Script"),FILE_RUN_SCRIPT,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_R);
+ p->add_item(TTR("Run Script"), FILE_RUN_SCRIPT, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_R);
p->add_separator();
- p->add_item(TTR("Project Settings"),RUN_SETTINGS);
+ p->add_item(TTR("Project Settings"), RUN_SETTINGS);
p->add_separator();
- p->add_item(TTR("Revert Scene"),EDIT_REVERT);
+ p->add_item(TTR("Revert Scene"), EDIT_REVERT);
p->add_separator();
#ifdef OSX_ENABLED
- p->add_item(TTR("Quit to Project List"),RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_ALT+KEY_Q);
+ p->add_item(TTR("Quit to Project List"), RUN_PROJECT_MANAGER, KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_Q);
#else
- p->add_item(TTR("Quit to Project List"),RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_Q);
+ p->add_item(TTR("Quit to Project List"), RUN_PROJECT_MANAGER, KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_Q);
#endif
- p->add_item(TTR("Quit"),FILE_QUIT,KEY_MASK_CMD+KEY_Q);
+ p->add_item(TTR("Quit"), FILE_QUIT, KEY_MASK_CMD + KEY_Q);
- recent_scenes = memnew( PopupMenu );
+ recent_scenes = memnew(PopupMenu);
recent_scenes->set_name("RecentScenes");
p->add_child(recent_scenes);
- recent_scenes->connect("id_pressed",this,"_open_recent_scene");
+ recent_scenes->connect("id_pressed", this, "_open_recent_scene");
{
- Control *sp = memnew( Control );
- sp->set_custom_minimum_size(Size2(30,0)*EDSCALE);
+ Control *sp = memnew(Control);
+ sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
menu_hb->add_child(sp);
}
- PanelContainer *editor_region = memnew( PanelContainer );
- editor_region->add_style_override("panel",gui_base->get_stylebox("hover","Button"));
- main_editor_button_vb = memnew( HBoxContainer );
+ PanelContainer *editor_region = memnew(PanelContainer);
+ editor_region->add_style_override("panel", gui_base->get_stylebox("hover", "Button"));
+ main_editor_button_vb = memnew(HBoxContainer);
editor_region->add_child(main_editor_button_vb);
menu_hb->add_child(editor_region);
- distraction_free = memnew( ToolButton );
+ distraction_free = memnew(ToolButton);
main_editor_button_vb->add_child(distraction_free);
- distraction_free->set_shortcut( ED_SHORTCUT("editor/distraction_free_mode",TTR("Distraction Free Mode"),KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F11) );
- distraction_free->connect("pressed",this,"_toggle_distraction_free_mode");
- distraction_free->set_icon(gui_base->get_icon("DistractionFree","EditorIcons"));
+ distraction_free->set_shortcut(ED_SHORTCUT("editor/distraction_free_mode", TTR("Distraction Free Mode"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F11));
+ distraction_free->connect("pressed", this, "_toggle_distraction_free_mode");
+ distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons"));
distraction_free->set_toggle_mode(true);
- //menu_hb->add_spacer();
+//menu_hb->add_spacer();
#if 0
node_menu = memnew( MenuButton );
node_menu->set_text("Node");
@@ -5596,30 +5278,30 @@ EditorNode::EditorNode() {
menu_panel->add_child( resource_menu );
#endif
- import_menu = memnew( MenuButton );
+ import_menu = memnew(MenuButton);
import_menu->set_tooltip(TTR("Import assets to the project."));
import_menu->set_text(TTR("Import"));
//import_menu->set_icon(gui_base->get_icon("Save","EditorIcons"));
- left_menu_hb->add_child( import_menu );
+ left_menu_hb->add_child(import_menu);
- p=import_menu->get_popup();
- p->connect("id_pressed",this,"_menu_option");
+ p = import_menu->get_popup();
+ p->connect("id_pressed", this, "_menu_option");
- tool_menu = memnew( MenuButton );
+ tool_menu = memnew(MenuButton);
tool_menu->set_tooltip(TTR("Miscellaneous project or scene-wide tools."));
tool_menu->set_text(TTR("Tools"));
//tool_menu->set_icon(gui_base->get_icon("Save","EditorIcons"));
- left_menu_hb->add_child( tool_menu );
+ left_menu_hb->add_child(tool_menu);
- p=tool_menu->get_popup();
- p->connect("id_pressed",this,"_menu_option");
- p->add_item(TTR("Orphan Resource Explorer"),TOOLS_ORPHAN_RESOURCES);
+ p = tool_menu->get_popup();
+ p->connect("id_pressed", this, "_menu_option");
+ p->add_item(TTR("Orphan Resource Explorer"), TOOLS_ORPHAN_RESOURCES);
- export_button = memnew( ToolButton );
+ export_button = memnew(ToolButton);
export_button->set_tooltip(TTR("Export the project to many platforms."));
export_button->set_text(TTR("Export"));
- export_button->connect("pressed",this,"_menu_option",varray(FILE_EXPORT_PROJECT));
+ export_button->connect("pressed", this, "_menu_option", varray(FILE_EXPORT_PROJECT));
export_button->set_focus_mode(Control::FOCUS_NONE);
left_menu_hb->add_child(export_button);
@@ -5630,109 +5312,105 @@ EditorNode::EditorNode() {
//s1->set_pos(Point2(210,4));
//s1->set_size(Point2(10,15));
-
- play_cc = memnew( CenterContainer );
+ play_cc = memnew(CenterContainer);
play_cc->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
- gui_base->add_child( play_cc );
+ gui_base->add_child(play_cc);
play_cc->set_area_as_parent_rect();
- play_cc->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,10);
- play_cc->set_margin(MARGIN_TOP,5);
+ play_cc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_BEGIN, 10);
+ play_cc->set_margin(MARGIN_TOP, 5);
- top_region = memnew( PanelContainer );
- top_region->add_style_override("panel",gui_base->get_stylebox("hover","Button"));
+ top_region = memnew(PanelContainer);
+ top_region->add_style_override("panel", gui_base->get_stylebox("hover", "Button"));
play_cc->add_child(top_region);
- HBoxContainer *play_hb = memnew( HBoxContainer );
+ HBoxContainer *play_hb = memnew(HBoxContainer);
top_region->add_child(play_hb);
- play_button = memnew( ToolButton );
+ play_button = memnew(ToolButton);
play_hb->add_child(play_button);
play_button->set_toggle_mode(true);
- play_button->set_icon(gui_base->get_icon("MainPlay","EditorIcons"));
+ play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons"));
play_button->set_focus_mode(Control::FOCUS_NONE);
- play_button->connect("pressed", this,"_menu_option",make_binds(RUN_PLAY));
+ play_button->connect("pressed", this, "_menu_option", make_binds(RUN_PLAY));
play_button->set_tooltip(TTR("Play the project."));
- play_button->set_shortcut(ED_SHORTCUT("editor/play",TTR("Play"),KEY_F5));
-
+ play_button->set_shortcut(ED_SHORTCUT("editor/play", TTR("Play"), KEY_F5));
-
- pause_button = memnew( ToolButton );
+ pause_button = memnew(ToolButton);
//menu_panel->add_child(pause_button); - not needed for now?
pause_button->set_toggle_mode(true);
- pause_button->set_icon(gui_base->get_icon("Pause","EditorIcons"));
+ pause_button->set_icon(gui_base->get_icon("Pause", "EditorIcons"));
pause_button->set_focus_mode(Control::FOCUS_NONE);
//pause_button->connect("pressed", this,"_menu_option",make_binds(RUN_PAUSE));
pause_button->set_tooltip(TTR("Pause the scene"));
pause_button->set_disabled(true);
play_hb->add_child(pause_button);
- pause_button->set_shortcut(ED_SHORTCUT("editor/pause_scene",TTR("Pause Scene"),KEY_F7));
-
+ pause_button->set_shortcut(ED_SHORTCUT("editor/pause_scene", TTR("Pause Scene"), KEY_F7));
- stop_button = memnew( ToolButton );
+ stop_button = memnew(ToolButton);
play_hb->add_child(stop_button);
//stop_button->set_toggle_mode(true);
stop_button->set_focus_mode(Control::FOCUS_NONE);
- stop_button->set_icon(gui_base->get_icon("MainStop","EditorIcons"));
- stop_button->connect("pressed", this,"_menu_option",make_binds(RUN_STOP));
+ stop_button->set_icon(gui_base->get_icon("MainStop", "EditorIcons"));
+ stop_button->connect("pressed", this, "_menu_option", make_binds(RUN_STOP));
stop_button->set_tooltip(TTR("Stop the scene."));
- stop_button->set_shortcut(ED_SHORTCUT("editor/stop",TTR("Stop"),KEY_F8));
+ stop_button->set_shortcut(ED_SHORTCUT("editor/stop", TTR("Stop"), KEY_F8));
- run_native = memnew( EditorRunNative);
+ run_native = memnew(EditorRunNative);
play_hb->add_child(run_native);
- native_play_button = memnew( MenuButton );
+ native_play_button = memnew(MenuButton);
native_play_button->set_text("NTV");
menu_hb->add_child(native_play_button);
native_play_button->hide();
- native_play_button->get_popup()->connect("id_pressed",this,"_run_in_device");
- run_native->connect("native_run",this,"_menu_option",varray(RUN_PLAY_NATIVE));
+ native_play_button->get_popup()->connect("id_pressed", this, "_run_in_device");
+ run_native->connect("native_run", this, "_menu_option", varray(RUN_PLAY_NATIVE));
//VSeparator *s1 = memnew( VSeparator );
//play_hb->add_child(s1);
- play_scene_button = memnew( ToolButton );
+ play_scene_button = memnew(ToolButton);
play_hb->add_child(play_scene_button);
play_scene_button->set_toggle_mode(true);
play_scene_button->set_focus_mode(Control::FOCUS_NONE);
- play_scene_button->set_icon(gui_base->get_icon("PlayScene","EditorIcons"));
- play_scene_button->connect("pressed", this,"_menu_option",make_binds(RUN_PLAY_SCENE));
+ play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons"));
+ play_scene_button->connect("pressed", this, "_menu_option", make_binds(RUN_PLAY_SCENE));
play_scene_button->set_tooltip(TTR("Play the edited scene."));
- play_scene_button->set_shortcut(ED_SHORTCUT("editor/play_scene",TTR("Play Scene"),KEY_F6));
+ play_scene_button->set_shortcut(ED_SHORTCUT("editor/play_scene", TTR("Play Scene"), KEY_F6));
- play_custom_scene_button = memnew( ToolButton );
+ play_custom_scene_button = memnew(ToolButton);
play_hb->add_child(play_custom_scene_button);
play_custom_scene_button->set_toggle_mode(true);
play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE);
- play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom","EditorIcons"));
- play_custom_scene_button->connect("pressed", this,"_menu_option",make_binds(RUN_PLAY_CUSTOM_SCENE));
+ play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons"));
+ play_custom_scene_button->connect("pressed", this, "_menu_option", make_binds(RUN_PLAY_CUSTOM_SCENE));
play_custom_scene_button->set_tooltip(TTR("Play custom scene"));
- play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene",TTR("Play Custom Scene"),KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_F5));
+ play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5));
- debug_button = memnew( MenuButton );
+ debug_button = memnew(MenuButton);
debug_button->set_flat(true);
play_hb->add_child(debug_button);
//debug_button->set_toggle_mode(true);
debug_button->set_focus_mode(Control::FOCUS_NONE);
- debug_button->set_icon(gui_base->get_icon("Remote","EditorIcons"));
+ debug_button->set_icon(gui_base->get_icon("Remote", "EditorIcons"));
//debug_button->connect("pressed", this,"_menu_option",make_binds(RUN_LIVE_DEBUG));
debug_button->set_tooltip(TTR("Debug options"));
- p=debug_button->get_popup();
+ p = debug_button->get_popup();
p->set_hide_on_item_selection(false);
- p->add_check_item(TTR("Deploy with Remote Debug"),RUN_DEPLOY_REMOTE_DEBUG);
- p->set_item_tooltip(p->get_item_count()-1,TTR("When exporting or deploying, the resulting executable will attempt to connect to the IP of this computer in order to be debugged."));
- p->add_check_item(TTR("Small Deploy with Network FS"),RUN_FILE_SERVER);
- p->set_item_tooltip(p->get_item_count()-1,TTR("When this option is enabled, export or deploy will produce a minimal executable.\nThe filesystem will be provided from the project by the editor over the network.\nOn Android, deploy will use the USB cable for faster performance. This option speeds up testing for games with a large footprint."));
+ p->add_check_item(TTR("Deploy with Remote Debug"), RUN_DEPLOY_REMOTE_DEBUG);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("When exporting or deploying, the resulting executable will attempt to connect to the IP of this computer in order to be debugged."));
+ p->add_check_item(TTR("Small Deploy with Network FS"), RUN_FILE_SERVER);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is enabled, export or deploy will produce a minimal executable.\nThe filesystem will be provided from the project by the editor over the network.\nOn Android, deploy will use the USB cable for faster performance. This option speeds up testing for games with a large footprint."));
p->add_separator();
- p->add_check_item(TTR("Visible Collision Shapes"),RUN_DEBUG_COLLISONS);
- p->set_item_tooltip(p->get_item_count()-1,TTR("Collision shapes and raycast nodes (for 2D and 3D) will be visible on the running game if this option is turned on."));
- p->add_check_item(TTR("Visible Navigation"),RUN_DEBUG_NAVIGATION);
- p->set_item_tooltip(p->get_item_count()-1,TTR("Navigation meshes and polygons will be visible on the running game if this option is turned on."));
+ p->add_check_item(TTR("Visible Collision Shapes"), RUN_DEBUG_COLLISONS);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("Collision shapes and raycast nodes (for 2D and 3D) will be visible on the running game if this option is turned on."));
+ p->add_check_item(TTR("Visible Navigation"), RUN_DEBUG_NAVIGATION);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("Navigation meshes and polygons will be visible on the running game if this option is turned on."));
p->add_separator();
- p->add_check_item(TTR("Sync Scene Changes"),RUN_LIVE_DEBUG);
- p->set_item_tooltip(p->get_item_count()-1,TTR("When this option is turned on, any changes made to the scene in the editor will be replicated in the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
- p->add_check_item(TTR("Sync Script Changes"),RUN_RELOAD_SCRIPTS);
- p->set_item_tooltip(p->get_item_count()-1,TTR("When this option is turned on, any script that is saved will be reloaded on the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
- p->connect("id_pressed",this,"_menu_option");
+ p->add_check_item(TTR("Sync Scene Changes"), RUN_LIVE_DEBUG);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is turned on, any changes made to the scene in the editor will be replicated in the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
+ p->add_check_item(TTR("Sync Script Changes"), RUN_RELOAD_SCRIPTS);
+ p->set_item_tooltip(p->get_item_count() - 1, TTR("When this option is turned on, any script that is saved will be reloaded on the running game.\nWhen used remotely on a device, this is more efficient with network filesystem."));
+ p->connect("id_pressed", this, "_menu_option");
/*
run_settings_button = memnew( ToolButton );
@@ -5752,104 +5430,97 @@ EditorNode::EditorNode() {
run_settings_button->connect("pressed", this,"_menu_option",make_binds(RUN_SETTINGS));
*/
-
- progress_hb = memnew( BackgroundProgress );
+ progress_hb = memnew(BackgroundProgress);
menu_hb->add_child(progress_hb);
{
- Control *sp = memnew( Control );
- sp->set_custom_minimum_size(Size2(30,0)*EDSCALE);
+ Control *sp = memnew(Control);
+ sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
menu_hb->add_child(sp);
}
-
- PanelContainer *vu_cont = memnew( PanelContainer );
- vu_cont->add_style_override("panel",gui_base->get_stylebox("hover","Button"));
+ PanelContainer *vu_cont = memnew(PanelContainer);
+ vu_cont->add_style_override("panel", gui_base->get_stylebox("hover", "Button"));
menu_hb->add_child(vu_cont);
- audio_vu = memnew( TextureProgress );
- CenterContainer *vu_cc = memnew( CenterContainer );
+ audio_vu = memnew(TextureProgress);
+ CenterContainer *vu_cc = memnew(CenterContainer);
vu_cc->add_child(audio_vu);
vu_cont->add_child(vu_cc);
- audio_vu->set_under_texture(gui_base->get_icon("VuEmpty","EditorIcons"));
- audio_vu->set_progress_texture(gui_base->get_icon("VuFull","EditorIcons"));
+ audio_vu->set_under_texture(gui_base->get_icon("VuEmpty", "EditorIcons"));
+ audio_vu->set_progress_texture(gui_base->get_icon("VuFull", "EditorIcons"));
audio_vu->set_max(24);
audio_vu->set_min(-80);
audio_vu->set_step(0.01);
audio_vu->set_value(0);
{
- Control *sp = memnew( Control );
- sp->set_custom_minimum_size(Size2(30,0)*EDSCALE);
+ Control *sp = memnew(Control);
+ sp->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
menu_hb->add_child(sp);
}
-
-
- top_region = memnew( PanelContainer );
- top_region->add_style_override("panel",gui_base->get_stylebox("hover","Button"));
- HBoxContainer *right_menu_hb = memnew( HBoxContainer );
+ top_region = memnew(PanelContainer);
+ top_region->add_style_override("panel", gui_base->get_stylebox("hover", "Button"));
+ HBoxContainer *right_menu_hb = memnew(HBoxContainer);
top_region->add_child(right_menu_hb);
menu_hb->add_child(top_region);
-
- settings_menu = memnew( MenuButton );
+ settings_menu = memnew(MenuButton);
settings_menu->set_text(TTR("Settings"));
//settings_menu->set_anchor(MARGIN_RIGHT,ANCHOR_END);
- right_menu_hb->add_child( settings_menu );
- p=settings_menu->get_popup();
+ right_menu_hb->add_child(settings_menu);
+ p = settings_menu->get_popup();
//p->add_item("Export Settings",SETTINGS_EXPORT_PREFERENCES);
- p->add_item(TTR("Editor Settings"),SETTINGS_PREFERENCES);
+ p->add_item(TTR("Editor Settings"), SETTINGS_PREFERENCES);
//p->add_item("Optimization Presets",SETTINGS_OPTIMIZED_PRESETS);
p->add_separator();
- editor_layouts = memnew( PopupMenu );
+ editor_layouts = memnew(PopupMenu);
editor_layouts->set_name("Layouts");
p->add_child(editor_layouts);
- editor_layouts->connect("id_pressed",this,"_layout_menu_option");
+ editor_layouts->connect("id_pressed", this, "_layout_menu_option");
p->add_submenu_item(TTR("Editor Layout"), "Layouts");
- p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode",TTR("Toggle Fullscreen"),KEY_MASK_SHIFT|KEY_F11),SETTINGS_TOGGLE_FULLSCREN);
+ p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_SHIFT | KEY_F11), SETTINGS_TOGGLE_FULLSCREN);
p->add_separator();
- p->add_item(TTR("Install Export Templates"),SETTINGS_LOAD_EXPORT_TEMPLATES);
+ p->add_item(TTR("Install Export Templates"), SETTINGS_LOAD_EXPORT_TEMPLATES);
p->add_separator();
- p->add_item(TTR("About"),SETTINGS_ABOUT);
+ p->add_item(TTR("About"), SETTINGS_ABOUT);
- layout_dialog = memnew( EditorNameDialog );
+ layout_dialog = memnew(EditorNameDialog);
gui_base->add_child(layout_dialog);
layout_dialog->set_hide_on_ok(false);
- layout_dialog->set_size(Size2(175, 70)*EDSCALE);
- layout_dialog->connect("name_confirmed", this,"_dialog_action");
+ layout_dialog->set_size(Size2(175, 70) * EDSCALE);
+ layout_dialog->connect("name_confirmed", this, "_dialog_action");
- sources_button = memnew( ToolButton );
+ sources_button = memnew(ToolButton);
right_menu_hb->add_child(sources_button);
- sources_button->set_icon(gui_base->get_icon("DependencyOk","EditorIcons"));
- sources_button->connect("pressed",this,"_menu_option",varray(SOURCES_REIMPORT));
+ sources_button->set_icon(gui_base->get_icon("DependencyOk", "EditorIcons"));
+ sources_button->connect("pressed", this, "_menu_option", varray(SOURCES_REIMPORT));
sources_button->set_tooltip(TTR("Alerts when an external resource has changed."));
- update_menu = memnew( MenuButton );
+ update_menu = memnew(MenuButton);
update_menu->set_tooltip(TTR("Spins when the editor window repaints!"));
right_menu_hb->add_child(update_menu);
- update_menu->set_icon(gui_base->get_icon("Progress1","EditorIcons"));
- p=update_menu->get_popup();
- p->add_check_item(TTR("Update Always"),SETTINGS_UPDATE_ALWAYS);
- p->add_check_item(TTR("Update Changes"),SETTINGS_UPDATE_CHANGES);
- p->add_separator();
- p->add_check_item(TTR("Disable Update Spinner"),SETTINGS_UPDATE_SPINNER_HIDE);
- p->set_item_checked(1,true);
+ update_menu->set_icon(gui_base->get_icon("Progress1", "EditorIcons"));
+ p = update_menu->get_popup();
+ p->add_check_item(TTR("Update Always"), SETTINGS_UPDATE_ALWAYS);
+ p->add_check_item(TTR("Update Changes"), SETTINGS_UPDATE_CHANGES);
+ p->add_separator();
+ p->add_check_item(TTR("Disable Update Spinner"), SETTINGS_UPDATE_SPINNER_HIDE);
+ p->set_item_checked(1, true);
//sources_button->connect();
-/*
+ /*
Separator *s2 = memnew( VSeparator );
menu_panel->add_child(s2);
s2->set_pos(Point2(338,4));
s2->set_size(Point2(10,15));
*/
-
-
//editor_hsplit = memnew( HSplitContainer );
//main_split->add_child(editor_hsplit);
//editor_hsplit->set_v_size_flags(Control::SIZE_EXPAND_FILL);
@@ -5858,7 +5529,7 @@ EditorNode::EditorNode() {
//editor_hsplit->add_child(editor_vsplit);
//top_pallete = memnew( TabContainer );
- scene_tree_dock = memnew( SceneTreeDock(this,scene_root,editor_selection,editor_data) );
+ scene_tree_dock = memnew(SceneTreeDock(this, scene_root, editor_selection, editor_data));
scene_tree_dock->set_name(TTR("Scene"));
//top_pallete->add_child(scene_tree_dock);
dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(scene_tree_dock);
@@ -5877,7 +5548,6 @@ EditorNode::EditorNode() {
editor_spacer->add_child( top_pallete );
top_pallete->set_area_as_parent_rect();*/
-
//prop_pallete = memnew( TabContainer );
//prop_pallete->set_v_size_flags(Control::SIZE_EXPAND_FILL);
@@ -5889,108 +5559,106 @@ EditorNode::EditorNode() {
editor_spacer->add_child( prop_pallete );
prop_pallete->set_area_as_parent_rect();*/
- VBoxContainer *prop_editor_base = memnew( VBoxContainer );
+ VBoxContainer *prop_editor_base = memnew(VBoxContainer);
prop_editor_base->set_name(TTR("Inspector")); // Properties?
dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(prop_editor_base);
- HBoxContainer *prop_editor_hb = memnew( HBoxContainer );
+ HBoxContainer *prop_editor_hb = memnew(HBoxContainer);
prop_editor_base->add_child(prop_editor_hb);
- prop_editor_vb=prop_editor_base;
+ prop_editor_vb = prop_editor_base;
- resource_new_button = memnew( ToolButton );
+ resource_new_button = memnew(ToolButton);
resource_new_button->set_tooltip(TTR("Create a new resource in memory and edit it."));
- resource_new_button->set_icon(gui_base->get_icon("New","EditorIcons"));
+ resource_new_button->set_icon(gui_base->get_icon("New", "EditorIcons"));
prop_editor_hb->add_child(resource_new_button);
- resource_new_button->connect("pressed",this,"_menu_option",varray(RESOURCE_NEW));
+ resource_new_button->connect("pressed", this, "_menu_option", varray(RESOURCE_NEW));
resource_new_button->set_focus_mode(Control::FOCUS_NONE);
- resource_load_button = memnew( ToolButton );
+ resource_load_button = memnew(ToolButton);
resource_load_button->set_tooltip(TTR("Load an existing resource from disk and edit it."));
- resource_load_button->set_icon(gui_base->get_icon("Load","EditorIcons"));
+ resource_load_button->set_icon(gui_base->get_icon("Load", "EditorIcons"));
prop_editor_hb->add_child(resource_load_button);
- resource_load_button->connect("pressed",this,"_menu_option",varray(RESOURCE_LOAD));
+ resource_load_button->connect("pressed", this, "_menu_option", varray(RESOURCE_LOAD));
resource_load_button->set_focus_mode(Control::FOCUS_NONE);
- resource_save_button = memnew( MenuButton );
+ resource_save_button = memnew(MenuButton);
resource_save_button->set_tooltip(TTR("Save the currently edited resource."));
- resource_save_button->set_icon(gui_base->get_icon("Save","EditorIcons"));
+ resource_save_button->set_icon(gui_base->get_icon("Save", "EditorIcons"));
prop_editor_hb->add_child(resource_save_button);
- resource_save_button->get_popup()->add_item(TTR("Save"),RESOURCE_SAVE);
- resource_save_button->get_popup()->add_item(TTR("Save As.."),RESOURCE_SAVE_AS);
- resource_save_button->get_popup()->connect("id_pressed",this,"_menu_option");
+ resource_save_button->get_popup()->add_item(TTR("Save"), RESOURCE_SAVE);
+ resource_save_button->get_popup()->add_item(TTR("Save As.."), RESOURCE_SAVE_AS);
+ resource_save_button->get_popup()->connect("id_pressed", this, "_menu_option");
resource_save_button->set_focus_mode(Control::FOCUS_NONE);
resource_save_button->set_disabled(true);
prop_editor_hb->add_spacer();
- property_back = memnew( ToolButton );
- property_back->set_icon( gui_base->get_icon("Back","EditorIcons") );
+ property_back = memnew(ToolButton);
+ property_back->set_icon(gui_base->get_icon("Back", "EditorIcons"));
property_back->set_flat(true);
property_back->set_tooltip(TTR("Go to the previous edited object in history."));
property_back->set_disabled(true);
- prop_editor_hb->add_child( property_back );
+ prop_editor_hb->add_child(property_back);
- property_forward = memnew( ToolButton );
- property_forward->set_icon( gui_base->get_icon("Forward","EditorIcons") );
+ property_forward = memnew(ToolButton);
+ property_forward->set_icon(gui_base->get_icon("Forward", "EditorIcons"));
property_forward->set_flat(true);
property_forward->set_tooltip(TTR("Go to the next edited object in history."));
property_forward->set_disabled(true);
- prop_editor_hb->add_child( property_forward );
-
+ prop_editor_hb->add_child(property_forward);
- editor_history_menu = memnew( MenuButton );
+ editor_history_menu = memnew(MenuButton);
editor_history_menu->set_tooltip(TTR("History of recently edited objects."));
- editor_history_menu->set_icon( gui_base->get_icon("History","EditorIcons"));
+ editor_history_menu->set_icon(gui_base->get_icon("History", "EditorIcons"));
prop_editor_hb->add_child(editor_history_menu);
- editor_history_menu->connect("about_to_show",this,"_prepare_history");
- editor_history_menu->get_popup()->connect("id_pressed",this,"_select_history");
+ editor_history_menu->connect("about_to_show", this, "_prepare_history");
+ editor_history_menu->get_popup()->connect("id_pressed", this, "_select_history");
-
- prop_editor_hb = memnew( HBoxContainer ); //again...
+ prop_editor_hb = memnew(HBoxContainer); //again...
prop_editor_base->add_child(prop_editor_hb);
- editor_path = memnew( EditorPath(&editor_history) );
+ editor_path = memnew(EditorPath(&editor_history));
editor_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
prop_editor_hb->add_child(editor_path);
- search_button = memnew( ToolButton );
+ search_button = memnew(ToolButton);
search_button->set_toggle_mode(true);
search_button->set_pressed(false);
- search_button->set_icon(gui_base->get_icon("Zoom","EditorIcons"));
+ search_button->set_icon(gui_base->get_icon("Zoom", "EditorIcons"));
prop_editor_hb->add_child(search_button);
- search_button->connect("toggled",this,"_toggle_search_bar");
+ search_button->connect("toggled", this, "_toggle_search_bar");
- object_menu = memnew( MenuButton );
- object_menu->set_icon(gui_base->get_icon("Tools","EditorIcons"));
- prop_editor_hb->add_child( object_menu );
+ object_menu = memnew(MenuButton);
+ object_menu->set_icon(gui_base->get_icon("Tools", "EditorIcons"));
+ prop_editor_hb->add_child(object_menu);
object_menu->set_tooltip(TTR("Object properties."));
- create_dialog = memnew( CreateDialog );
+ create_dialog = memnew(CreateDialog);
gui_base->add_child(create_dialog);
create_dialog->set_base_type("Resource");
- create_dialog->connect("create",this,"_resource_created");
+ create_dialog->connect("create", this, "_resource_created");
- search_bar = memnew( HBoxContainer );
+ search_bar = memnew(HBoxContainer);
search_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
prop_editor_base->add_child(search_bar);
search_bar->hide();
- Label *l = memnew( Label(TTR("Search:")+" ") );
+ Label *l = memnew(Label(TTR("Search:") + " "));
search_bar->add_child(l);
- search_box = memnew( LineEdit );
+ search_box = memnew(LineEdit);
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search_bar->add_child(search_box);
- ToolButton *clear_button = memnew( ToolButton );
- clear_button->set_icon(gui_base->get_icon("Close","EditorIcons"));
+ ToolButton *clear_button = memnew(ToolButton);
+ clear_button->set_icon(gui_base->get_icon("Close", "EditorIcons"));
search_bar->add_child(clear_button);
- clear_button->connect("pressed",this,"_clear_search_box");
+ clear_button->connect("pressed", this, "_clear_search_box");
- property_editor = memnew( PropertyEditor );
+ property_editor = memnew(PropertyEditor);
property_editor->set_autoclear(true);
property_editor->set_show_categories(true);
property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
@@ -5999,16 +5667,14 @@ EditorNode::EditorNode() {
property_editor->hide_top_label();
property_editor->register_text_enter(search_box);
- prop_editor_base->add_child( property_editor );
+ prop_editor_base->add_child(property_editor);
property_editor->set_undo_redo(&editor_data.get_undo_redo());
-
- import_dock = memnew( ImportDock );
+ import_dock = memnew(ImportDock);
dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(import_dock);
import_dock->set_name(TTR("Import"));
-
- node_dock = memnew( NodeDock );
+ node_dock = memnew(NodeDock);
//node_dock->set_undoredo(&editor_data.get_undo_redo());
if (use_single_dock_column) {
dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(node_dock);
@@ -6016,7 +5682,7 @@ EditorNode::EditorNode() {
dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(node_dock);
}
- filesystem_dock = memnew( FileSystemDock(this) );
+ filesystem_dock = memnew(FileSystemDock(this));
filesystem_dock->set_name(TTR("FileSystem"));
filesystem_dock->set_display_mode(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode")));
@@ -6029,64 +5695,56 @@ EditorNode::EditorNode() {
dock_slot[DOCK_SLOT_LEFT_UR]->add_child(filesystem_dock);
}
//prop_pallete->add_child(filesystem_dock);
- filesystem_dock->connect("open",this,"open_request");
- filesystem_dock->connect("instance",this,"_instance_request");
+ filesystem_dock->connect("open", this, "open_request");
+ filesystem_dock->connect("instance", this, "_instance_request");
const String docks_section = "docks";
- overridden_default_layout=-1;
+ overridden_default_layout = -1;
default_layout.instance();
default_layout->set_value(docks_section, "dock_3", TTR("FileSystem"));
default_layout->set_value(docks_section, "dock_5", TTR("Scene"));
- default_layout->set_value(docks_section, "dock_6", TTR("Inspector")+","+TTR("Node"));
+ default_layout->set_value(docks_section, "dock_6", TTR("Inspector") + "," + TTR("Node"));
- for(int i=0;i<DOCK_SLOT_MAX/2;i++)
- default_layout->set_value(docks_section, "dock_hsplit_"+itos(i+1), 0);
- for(int i=0;i<DOCK_SLOT_MAX/2;i++)
- default_layout->set_value(docks_section, "dock_split_"+itos(i+1), 0);
+ for (int i = 0; i < DOCK_SLOT_MAX / 2; i++)
+ default_layout->set_value(docks_section, "dock_hsplit_" + itos(i + 1), 0);
+ for (int i = 0; i < DOCK_SLOT_MAX / 2; i++)
+ default_layout->set_value(docks_section, "dock_split_" + itos(i + 1), 0);
_update_layouts_menu();
- bottom_panel = memnew( PanelContainer );
- bottom_panel->add_style_override("panel",gui_base->get_stylebox("panelf","Panel"));
+ bottom_panel = memnew(PanelContainer);
+ bottom_panel->add_style_override("panel", gui_base->get_stylebox("panelf", "Panel"));
center_split->add_child(bottom_panel);
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
- bottom_panel_vb = memnew( VBoxContainer );
+ bottom_panel_vb = memnew(VBoxContainer);
bottom_panel->add_child(bottom_panel_vb);
//bottom_panel_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- bottom_panel_hb = memnew( HBoxContainer );
+ bottom_panel_hb = memnew(HBoxContainer);
bottom_panel_vb->add_child(bottom_panel_hb);
+ log = memnew(EditorLog);
-
- log = memnew( EditorLog );
-
- add_bottom_panel_item(TTR("Output"),log);
+ add_bottom_panel_item(TTR("Output"), log);
//left_split->set_dragger_visible(false);
+ old_split_ofs = 0;
- old_split_ofs=0;
-
- center_split->connect("resized",this,"_vp_resized");
-
+ center_split->connect("resized", this, "_vp_resized");
/*PanelContainer *bottom_pc = memnew( PanelContainer );
srt->add_child(bottom_pc);
bottom_hb = memnew( HBoxContainer );
bottom_pc->add_child(bottom_hb);*/
-
//center_vb->add_child( log->get_button() );
//log->get_button()->set_h_size_flags(Control::SIZE_EXPAND_FILL);
-
//progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
-
-
/*
animation_menu = memnew( ToolButton );
animation_menu->set_pos(Point2(500,0));
@@ -6098,41 +5756,22 @@ EditorNode::EditorNode() {
animation_menu->connect("pressed",this,"_animation_visibility_toggle");
*/
-
-
-
-
-
-
-
-
-
-
-
- orphan_resources = memnew( OrphanResourcesDialog );
+ orphan_resources = memnew(OrphanResourcesDialog);
gui_base->add_child(orphan_resources);
-
-
-
-
- confirmation = memnew( ConfirmationDialog );
+ confirmation = memnew(ConfirmationDialog);
gui_base->add_child(confirmation);
- confirmation->connect("confirmed", this,"_menu_confirm_current");
+ confirmation->connect("confirmed", this, "_menu_confirm_current");
- accept = memnew( AcceptDialog );
+ accept = memnew(AcceptDialog);
gui_base->add_child(accept);
- accept->connect("confirmed", this,"_menu_confirm_current");
-
-
-
-
+ accept->connect("confirmed", this, "_menu_confirm_current");
//optimized_save = memnew( OptimizedSaveDialog(&editor_data) );
//gui_base->add_child(optimized_save);
//optimized_save->connect("confirmed",this,"_save_optimized");
- project_export = memnew( ProjectExportDialog );
+ project_export = memnew(ProjectExportDialog);
gui_base->add_child(project_export);
//project_export_settings = memnew( ProjectExportDialog(this) );
@@ -6142,213 +5781,187 @@ EditorNode::EditorNode() {
//gui_base->add_child(optimized_presets);
//optimized_presets->connect("confirmed",this,"_presets_optimized");
-
-
//import_subscene = memnew( EditorSubScene );
//gui_base->add_child(import_subscene);
-
-
- dependency_error = memnew( DependencyErrorDialog );
+ dependency_error = memnew(DependencyErrorDialog);
gui_base->add_child(dependency_error);
- dependency_fixer = memnew( DependencyEditor );
- gui_base->add_child( dependency_fixer );
+ dependency_fixer = memnew(DependencyEditor);
+ gui_base->add_child(dependency_fixer);
- settings_config_dialog = memnew( EditorSettingsDialog );
+ settings_config_dialog = memnew(EditorSettingsDialog);
gui_base->add_child(settings_config_dialog);
- project_settings = memnew( ProjectSettings(&editor_data) );
+ project_settings = memnew(ProjectSettings(&editor_data));
gui_base->add_child(project_settings);
- import_confirmation = memnew( ConfirmationDialog );
+ import_confirmation = memnew(ConfirmationDialog);
import_confirmation->get_ok()->set_text(TTR("Re-Import"));
- import_confirmation->add_button(TTR("Update"),!OS::get_singleton()->get_swap_ok_cancel(),"update");
+ import_confirmation->add_button(TTR("Update"), !OS::get_singleton()->get_swap_ok_cancel(), "update");
import_confirmation->get_label()->set_align(Label::ALIGN_CENTER);
- import_confirmation->connect("confirmed",this,"_import_action",make_binds("re-import"));
- import_confirmation->connect("custom_action",this,"_import_action");
+ import_confirmation->connect("confirmed", this, "_import_action", make_binds("re-import"));
+ import_confirmation->connect("custom_action", this, "_import_action");
gui_base->add_child(import_confirmation);
- open_recent_confirmation = memnew( ConfirmationDialog );
+ open_recent_confirmation = memnew(ConfirmationDialog);
add_child(open_recent_confirmation);
- open_recent_confirmation->connect("confirmed",this,"_open_recent_scene_confirm");
-
-
- run_settings_dialog = memnew( RunSettingsDialog );
- gui_base->add_child( run_settings_dialog );
+ open_recent_confirmation->connect("confirmed", this, "_open_recent_scene_confirm");
+ run_settings_dialog = memnew(RunSettingsDialog);
+ gui_base->add_child(run_settings_dialog);
-
- about = memnew( AcceptDialog );
+ about = memnew(AcceptDialog);
about->set_title(TTR("Thanks from the Godot community!"));
//about->get_cancel()->hide();
about->get_ok()->set_text(TTR("Thanks!"));
about->set_hide_on_ok(true);
- Label *about_text = memnew( Label );
- about_text->set_text(VERSION_FULL_NAME"\n(c) 2008-2017 Juan Linietsky, Ariel Manzur.\n");
- about_text->set_pos(Point2(gui_base->get_icon("Logo","EditorIcons")->get_size().width+30,20));
+ Label *about_text = memnew(Label);
+ about_text->set_text(VERSION_FULL_NAME "\n(c) 2008-2017 Juan Linietsky, Ariel Manzur.\n");
+ about_text->set_pos(Point2(gui_base->get_icon("Logo", "EditorIcons")->get_size().width + 30, 20));
gui_base->add_child(about);
about->add_child(about_text);
- TextureRect *logo = memnew( TextureRect );
+ TextureRect *logo = memnew(TextureRect);
about->add_child(logo);
- logo->set_pos(Point2(20,20));
- logo->set_texture(gui_base->get_icon("Logo","EditorIcons") );
+ logo->set_pos(Point2(20, 20));
+ logo->set_texture(gui_base->get_icon("Logo", "EditorIcons"));
- warning = memnew( AcceptDialog );
+ warning = memnew(AcceptDialog);
gui_base->add_child(warning);
-
-
- file_templates = memnew( FileDialog );
+ file_templates = memnew(FileDialog);
file_templates->set_title(TTR("Import Templates From ZIP File"));
- gui_base->add_child( file_templates );
+ gui_base->add_child(file_templates);
file_templates->set_mode(FileDialog::MODE_OPEN_FILE);
file_templates->set_access(FileDialog::ACCESS_FILESYSTEM);
file_templates->clear_filters();
file_templates->add_filter("*.tpz ; Template Package");
-
- file = memnew( EditorFileDialog );
+ file = memnew(EditorFileDialog);
gui_base->add_child(file);
file->set_current_dir("res://");
- file_export = memnew( FileDialog );
+ file_export = memnew(FileDialog);
file_export->set_access(FileDialog::ACCESS_FILESYSTEM);
gui_base->add_child(file_export);
file_export->set_title(TTR("Export Project"));
- file_export->connect("file_selected", this,"_dialog_action");
+ file_export->connect("file_selected", this, "_dialog_action");
- file_export_lib = memnew( FileDialog );
+ file_export_lib = memnew(FileDialog);
file_export_lib->set_title(TTR("Export Library"));
file_export_lib->set_mode(FileDialog::MODE_SAVE_FILE);
- file_export_lib->connect("file_selected", this,"_dialog_action");
- file_export_lib_merge = memnew( CheckButton );
+ file_export_lib->connect("file_selected", this, "_dialog_action");
+ file_export_lib_merge = memnew(CheckButton);
file_export_lib_merge->set_text(TTR("Merge With Existing"));
file_export_lib_merge->set_pressed(true);
file_export_lib->get_vbox()->add_child(file_export_lib_merge);
gui_base->add_child(file_export_lib);
-
-
-
- file_export_password = memnew( LineEdit );
+ file_export_password = memnew(LineEdit);
file_export_password->set_secret(true);
file_export_password->set_editable(false);
- file_export->get_vbox()->add_margin_child(TTR("Password:"),file_export_password);
+ file_export->get_vbox()->add_margin_child(TTR("Password:"), file_export_password);
-
- file_script = memnew( FileDialog );
+ file_script = memnew(FileDialog);
file_script->set_title(TTR("Open & Run a Script"));
file_script->set_access(FileDialog::ACCESS_FILESYSTEM);
file_script->set_mode(FileDialog::MODE_OPEN_FILE);
List<String> sexts;
- ResourceLoader::get_recognized_extensions_for_type("Script",&sexts);
- for (List<String>::Element*E=sexts.front();E;E=E->next()) {
- file_script->add_filter("*."+E->get());
+ ResourceLoader::get_recognized_extensions_for_type("Script", &sexts);
+ for (List<String>::Element *E = sexts.front(); E; E = E->next()) {
+ file_script->add_filter("*." + E->get());
}
gui_base->add_child(file_script);
- file_script->connect("file_selected",this,"_dialog_action");
+ file_script->connect("file_selected", this, "_dialog_action");
//reimport_dialog = memnew( EditorReImportDialog );
//gui_base->add_child(reimport_dialog);
+ property_forward->connect("pressed", this, "_property_editor_forward");
+ property_back->connect("pressed", this, "_property_editor_back");
+ file_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ object_menu->get_popup()->connect("id_pressed", this, "_menu_option");
- property_forward->connect("pressed", this,"_property_editor_forward");
- property_back->connect("pressed", this,"_property_editor_back");
-
+ update_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ settings_menu->get_popup()->connect("id_pressed", this, "_menu_option");
-
- file_menu->get_popup()->connect("id_pressed", this,"_menu_option");
- object_menu->get_popup()->connect("id_pressed", this,"_menu_option");
-
- update_menu->get_popup()->connect("id_pressed", this,"_menu_option");
- settings_menu->get_popup()->connect("id_pressed", this,"_menu_option");
-
-
- file->connect("file_selected", this,"_dialog_action");
- file_templates->connect("file_selected", this,"_dialog_action");
- property_editor->connect("resource_selected", this,"_resource_selected");
- property_editor->connect("property_keyed", this,"_property_keyed");
+ file->connect("file_selected", this, "_dialog_action");
+ file_templates->connect("file_selected", this, "_dialog_action");
+ property_editor->connect("resource_selected", this, "_resource_selected");
+ property_editor->connect("property_keyed", this, "_property_keyed");
//plugin stuff
- file_server = memnew( EditorFileServer );
-
-
-
-
- add_editor_plugin( memnew( AnimationPlayerEditorPlugin(this) ) );
- add_editor_plugin( memnew( CanvasItemEditorPlugin(this) ) );
- add_editor_plugin( memnew( SpatialEditorPlugin(this) ) );
- add_editor_plugin( memnew( ScriptEditorPlugin(this) ) );
+ file_server = memnew(EditorFileServer);
+ add_editor_plugin(memnew(AnimationPlayerEditorPlugin(this)));
+ add_editor_plugin(memnew(CanvasItemEditorPlugin(this)));
+ add_editor_plugin(memnew(SpatialEditorPlugin(this)));
+ add_editor_plugin(memnew(ScriptEditorPlugin(this)));
EditorAudioBuses *audio_bus_editor = EditorAudioBuses::register_editor();
ScriptTextEditor::register_editor(); //register one for text scripts
if (StreamPeerSSL::is_available()) {
- add_editor_plugin( memnew( AssetLibraryEditorPlugin(this) ) );
+ add_editor_plugin(memnew(AssetLibraryEditorPlugin(this)));
} else {
WARN_PRINT("Asset Library not available, as it requires SSL to work.");
}
//more visually meaningful to have this later
raise_bottom_panel_item(AnimationPlayerEditor::singleton);
- add_editor_plugin( memnew( ShaderEditorPlugin(this) ) );
-/* add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,true) ) );
+ add_editor_plugin(memnew(ShaderEditorPlugin(this)));
+ /* add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,true) ) );
add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,false) ) );
add_editor_plugin( memnew( ShaderEditorPlugin(this,false) ) );*/
- add_editor_plugin( memnew( CameraEditorPlugin(this) ) );
-// add_editor_plugin( memnew( SampleEditorPlugin(this) ) );
-// add_editor_plugin( memnew( SampleLibraryEditorPlugin(this) ) );
- add_editor_plugin( memnew( ThemeEditorPlugin(this) ) );
- add_editor_plugin( memnew( MultiMeshEditorPlugin(this) ) );
- add_editor_plugin( memnew( MeshInstanceEditorPlugin(this) ) );
- add_editor_plugin( memnew( AnimationTreeEditorPlugin(this) ) );
+ add_editor_plugin(memnew(CameraEditorPlugin(this)));
+ // add_editor_plugin( memnew( SampleEditorPlugin(this) ) );
+ // add_editor_plugin( memnew( SampleLibraryEditorPlugin(this) ) );
+ add_editor_plugin(memnew(ThemeEditorPlugin(this)));
+ add_editor_plugin(memnew(MultiMeshEditorPlugin(this)));
+ add_editor_plugin(memnew(MeshInstanceEditorPlugin(this)));
+ add_editor_plugin(memnew(AnimationTreeEditorPlugin(this)));
//add_editor_plugin( memnew( SamplePlayerEditorPlugin(this) ) ); - this is kind of useless at this point
//add_editor_plugin( memnew( MeshLibraryEditorPlugin(this) ) );
//add_editor_plugin( memnew( StreamEditorPlugin(this) ) );
- add_editor_plugin( memnew( StyleBoxEditorPlugin(this) ) );
+ add_editor_plugin(memnew(StyleBoxEditorPlugin(this)));
//add_editor_plugin( memnew( ParticlesEditorPlugin(this) ) );
- add_editor_plugin( memnew( ResourcePreloaderEditorPlugin(this) ) );
- add_editor_plugin( memnew( ItemListEditorPlugin(this) ) );
+ add_editor_plugin(memnew(ResourcePreloaderEditorPlugin(this)));
+ add_editor_plugin(memnew(ItemListEditorPlugin(this)));
//add_editor_plugin( memnew( RichTextEditorPlugin(this) ) );
//add_editor_plugin( memnew( CollisionPolygonEditorPlugin(this) ) );
- add_editor_plugin( memnew( CollisionPolygon2DEditorPlugin(this) ) );
- add_editor_plugin( memnew( TileSetEditorPlugin(this) ) );
- add_editor_plugin( memnew( TileMapEditorPlugin(this) ) );
- add_editor_plugin( memnew( SpriteFramesEditorPlugin(this) ) );
- add_editor_plugin( memnew( TextureRegionEditorPlugin(this) ) );
- add_editor_plugin( memnew( Particles2DEditorPlugin(this) ) );
- add_editor_plugin( memnew( GIProbeEditorPlugin(this) ) );
- add_editor_plugin( memnew( Path2DEditorPlugin(this) ) );
+ add_editor_plugin(memnew(CollisionPolygon2DEditorPlugin(this)));
+ add_editor_plugin(memnew(TileSetEditorPlugin(this)));
+ add_editor_plugin(memnew(TileMapEditorPlugin(this)));
+ add_editor_plugin(memnew(SpriteFramesEditorPlugin(this)));
+ add_editor_plugin(memnew(TextureRegionEditorPlugin(this)));
+ add_editor_plugin(memnew(Particles2DEditorPlugin(this)));
+ add_editor_plugin(memnew(GIProbeEditorPlugin(this)));
+ add_editor_plugin(memnew(Path2DEditorPlugin(this)));
//add_editor_plugin( memnew( PathEditorPlugin(this) ) );
//add_editor_plugin( memnew( BakedLightEditorPlugin(this) ) );
- add_editor_plugin( memnew( Line2DEditorPlugin(this) ) );
- add_editor_plugin( memnew( Polygon2DEditorPlugin(this) ) );
- add_editor_plugin( memnew( LightOccluder2DEditorPlugin(this) ) );
- add_editor_plugin( memnew( NavigationPolygonEditorPlugin(this) ) );
- add_editor_plugin( memnew( ColorRampEditorPlugin(this) ) );
- add_editor_plugin( memnew( CollisionShape2DEditorPlugin(this) ) );
- add_editor_plugin( memnew( TextureEditorPlugin(this) ) );
- add_editor_plugin( memnew( AudioBusesEditorPlugin(audio_bus_editor) ) );
+ add_editor_plugin(memnew(Line2DEditorPlugin(this)));
+ add_editor_plugin(memnew(Polygon2DEditorPlugin(this)));
+ add_editor_plugin(memnew(LightOccluder2DEditorPlugin(this)));
+ add_editor_plugin(memnew(NavigationPolygonEditorPlugin(this)));
+ add_editor_plugin(memnew(ColorRampEditorPlugin(this)));
+ add_editor_plugin(memnew(CollisionShape2DEditorPlugin(this)));
+ add_editor_plugin(memnew(TextureEditorPlugin(this)));
+ add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor)));
//add_editor_plugin( memnew( MaterialEditorPlugin(this) ) );
//add_editor_plugin( memnew( MeshEditorPlugin(this) ) );
- for(int i=0;i<EditorPlugins::get_plugin_count();i++)
- add_editor_plugin( EditorPlugins::create(i,this) );
+ for (int i = 0; i < EditorPlugins::get_plugin_count(); i++)
+ add_editor_plugin(EditorPlugins::create(i, this));
- for(int i=0;i<plugin_init_callback_count;i++) {
+ for (int i = 0; i < plugin_init_callback_count; i++) {
plugin_init_callbacks[i]();
}
-
-
-
/*resource_preview->add_preview_generator( Ref<EditorTexturePreviewPlugin>( memnew(EditorTexturePreviewPlugin )));
resource_preview->add_preview_generator( Ref<EditorPackedScenePreviewPlugin>( memnew(EditorPackedScenePreviewPlugin )));
resource_preview->add_preview_generator( Ref<EditorMaterialPreviewPlugin>( memnew(EditorMaterialPreviewPlugin )));
@@ -6358,128 +5971,115 @@ EditorNode::EditorNode() {
resource_preview->add_preview_generator( Ref<EditorBitmapPreviewPlugin>( memnew(EditorBitmapPreviewPlugin )));
*/
-
- circle_step_msec=OS::get_singleton()->get_ticks_msec();
- circle_step_frame=Engine::get_singleton()->get_frames_drawn();
- circle_step=0;
+ circle_step_msec = OS::get_singleton()->get_ticks_msec();
+ circle_step_frame = Engine::get_singleton()->get_frames_drawn();
+ circle_step = 0;
_rebuild_import_menu();
- editor_plugin_screen=NULL;
+ editor_plugin_screen = NULL;
editor_plugins_over = memnew(EditorPluginList);
//force_top_viewport(true);
_edit_current();
- current=NULL;
+ current = NULL;
PhysicsServer::get_singleton()->set_active(false); // no physics by default if editor
Physics2DServer::get_singleton()->set_active(false); // no physics by default if editor
ScriptServer::set_scripting_enabled(false); // no scripting by default if editor
-
//GlobalConfig::get_singleton()->set("render/room_cull_enabled",false);
- reference_resource_mem=true;
- save_external_resources_mem=true;
+ reference_resource_mem = true;
+ save_external_resources_mem = true;
set_process(true);
OS::get_singleton()->set_low_processor_usage_mode(true);
-
if (0) { //not sure if i want this to happen after all
//store project name in ssettings
String project_name;
//figure it out from path
- project_name=GlobalConfig::get_singleton()->get_resource_path().replace("\\","/");
- print_line("path: "+project_name);
- if (project_name.length() && project_name[project_name.length()-1]=='/')
- project_name=project_name.substr(0,project_name.length()-1);
+ project_name = GlobalConfig::get_singleton()->get_resource_path().replace("\\", "/");
+ print_line("path: " + project_name);
+ if (project_name.length() && project_name[project_name.length() - 1] == '/')
+ project_name = project_name.substr(0, project_name.length() - 1);
- project_name=project_name.replace("/","::");
+ project_name = project_name.replace("/", "::");
- if (project_name!="") {
- EditorSettings::get_singleton()->set("projects/"+project_name,GlobalConfig::get_singleton()->get_resource_path());
- EditorSettings::get_singleton()->raise_order("projects/"+project_name);
+ if (project_name != "") {
+ EditorSettings::get_singleton()->set("projects/" + project_name, GlobalConfig::get_singleton()->get_resource_path());
+ EditorSettings::get_singleton()->raise_order("projects/" + project_name);
EditorSettings::get_singleton()->save();
}
}
- open_imported = memnew( ConfirmationDialog );
+ open_imported = memnew(ConfirmationDialog);
open_imported->get_ok()->set_text(TTR("Open Anyway"));
- new_inherited_button=open_imported->add_button("New Inherited",!OS::get_singleton()->get_swap_ok_cancel(),"inherit");
- open_imported->connect("confirmed",this,"_open_imported");
- open_imported->connect("custom_action",this,"_inherit_imported");
+ new_inherited_button = open_imported->add_button("New Inherited", !OS::get_singleton()->get_swap_ok_cancel(), "inherit");
+ open_imported->connect("confirmed", this, "_open_imported");
+ open_imported->connect("custom_action", this, "_inherit_imported");
gui_base->add_child(open_imported);
-
-
//edited_scene=NULL;
- saved_version=1;
- unsaved_cache=true;
- _last_instanced_scene=NULL;
-
+ saved_version = 1;
+ unsaved_cache = true;
+ _last_instanced_scene = NULL;
- quick_open = memnew( EditorQuickOpen );
+ quick_open = memnew(EditorQuickOpen);
gui_base->add_child(quick_open);
- quick_open->connect("quick_open",this,"_quick_opened");
+ quick_open->connect("quick_open", this, "_quick_opened");
- quick_run = memnew( EditorQuickOpen );
+ quick_run = memnew(EditorQuickOpen);
gui_base->add_child(quick_run);
- quick_run->connect("quick_open",this,"_quick_run");
-
+ quick_run->connect("quick_open", this, "_quick_run");
_update_recent_scenes();
-
editor_data.restore_editor_global_states();
- convert_old=false;
- opening_prev=false;
+ convert_old = false;
+ opening_prev = false;
set_process_unhandled_input(true);
- _playing_edited=false;
+ _playing_edited = false;
//Panel *errors = memnew( Panel );
- load_errors = memnew( RichTextLabel );
+ load_errors = memnew(RichTextLabel);
//load_errors->set_readonly(true);
- load_error_dialog = memnew( AcceptDialog );
+ load_error_dialog = memnew(AcceptDialog);
load_error_dialog->add_child(load_errors);
load_error_dialog->set_title(TTR("Load Errors"));
//load_error_dialog->set_child_rect(load_errors);
gui_base->add_child(load_error_dialog);
-
//EditorImport::add_importer( Ref<EditorImporterCollada>( memnew(EditorImporterCollada )));
- EditorFileSystem::get_singleton()->connect("sources_changed",this,"_sources_changed");
- EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_fs_changed");
-
+ EditorFileSystem::get_singleton()->connect("sources_changed", this, "_sources_changed");
+ EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_fs_changed");
{
List<StringName> tl;
StringName ei = "EditorIcons";
- theme_base->get_theme()->get_icon_list(ei,&tl);
- for(List<StringName>::Element *E=tl.front();E;E=E->next()) {
+ theme_base->get_theme()->get_icon_list(ei, &tl);
+ for (List<StringName>::Element *E = tl.front(); E; E = E->next()) {
if (!ClassDB::class_exists(E->get()))
continue;
- icon_type_cache[E->get()]=theme_base->get_theme()->get_icon(E->get(),ei);
+ icon_type_cache[E->get()] = theme_base->get_theme()->get_icon(E->get(), ei);
}
}
-
-
Node::set_human_readable_collision_renaming(true);
-
- pick_main_scene = memnew( ConfirmationDialog );
+ pick_main_scene = memnew(ConfirmationDialog);
gui_base->add_child(pick_main_scene);
pick_main_scene->get_ok()->set_text("Select");
- pick_main_scene->connect("confirmed",this,"_menu_option",varray(SETTINGS_PICK_MAIN_SCENE));
+ pick_main_scene->connect("confirmed", this, "_menu_option", varray(SETTINGS_PICK_MAIN_SCENE));
//Ref<ImageTexture> it = gui_base->get_icon("logo","Icons");
//OS::get_singleton()->set_icon( it->get_data() );
- for(int i=0;i<_init_callbacks.size();i++)
+ for (int i = 0; i < _init_callbacks.size(); i++)
_init_callbacks[i]();
editor_data.add_edited_scene(-1);
@@ -6488,30 +6088,25 @@ EditorNode::EditorNode() {
{
- _initializing_addons=true;
+ _initializing_addons = true;
Vector<String> addons = GlobalConfig::get_singleton()->get("editor_plugins/enabled");
- for(int i=0;i<addons.size();i++) {
- set_addon_plugin_enabled(addons[i],true);
+ for (int i = 0; i < addons.size(); i++) {
+ set_addon_plugin_enabled(addons[i], true);
}
- _initializing_addons=false;
+ _initializing_addons = false;
}
-
-
_load_docks();
FileAccess::set_file_close_fail_notify_callback(_file_access_close_error_notify);
- waiting_for_first_scan=true;
-
+ waiting_for_first_scan = true;
}
-
EditorNode::~EditorNode() {
-
- memdelete( EditorHelp::get_doc_data() );
+ memdelete(EditorHelp::get_doc_data());
memdelete(editor_selection);
memdelete(editor_plugins_over);
memdelete(file_server);
@@ -6522,29 +6117,26 @@ EditorNode::~EditorNode() {
* EDITOR PLUGIN LIST
*/
-
void EditorPluginList::make_visible(bool p_visible) {
for (int i = 0; i < plugins_list.size(); i++) {
plugins_list[i]->make_visible(p_visible);
}
-
}
-void EditorPluginList::edit(Object* p_object) {
+void EditorPluginList::edit(Object *p_object) {
for (int i = 0; i < plugins_list.size(); i++) {
plugins_list[i]->edit(p_object);
}
-
}
-bool EditorPluginList::forward_gui_input(const Transform2D& p_canvas_xform,const InputEvent& p_event) {
+bool EditorPluginList::forward_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event) {
bool discard = false;
for (int i = 0; i < plugins_list.size(); i++) {
- if (plugins_list[i]->forward_canvas_gui_input(p_canvas_xform,p_event)) {
+ if (plugins_list[i]->forward_canvas_gui_input(p_canvas_xform, p_event)) {
discard = true;
}
}
@@ -6552,7 +6144,7 @@ bool EditorPluginList::forward_gui_input(const Transform2D& p_canvas_xform,const
return discard;
}
-bool EditorPluginList::forward_spatial_gui_input(Camera* p_camera, const InputEvent& p_event) {
+bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const InputEvent &p_event) {
bool discard = false;
for (int i = 0; i < plugins_list.size(); i++) {
@@ -6564,12 +6156,11 @@ bool EditorPluginList::forward_spatial_gui_input(Camera* p_camera, const InputEv
return discard;
}
-void EditorPluginList::forward_draw_over_canvas(const Transform2D& p_canvas_xform,Control* p_canvas) {
+void EditorPluginList::forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas) {
for (int i = 0; i < plugins_list.size(); i++) {
- plugins_list[i]->forward_draw_over_canvas(p_canvas_xform,p_canvas);
+ plugins_list[i]->forward_draw_over_canvas(p_canvas_xform, p_canvas);
}
-
}
bool EditorPluginList::empty() {
diff --git a/editor/editor_node.h b/editor/editor_node.h
index fb0b5c4c25..cb165bdf21 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -29,60 +29,59 @@
#ifndef EDITOR_NODE_H
#define EDITOR_NODE_H
-#include "scene/gui/control.h"
-#include "scene/gui/panel.h"
-#include "scene/gui/tool_button.h"
-#include "scene/gui/menu_button.h"
-#include "scene/gui/tree.h"
-#include "scene/gui/dialogs.h"
-#include "scene/gui/separator.h"
-#include "scene/gui/tab_container.h"
-#include "scene/gui/panel_container.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/split_container.h"
-#include "scene/gui/center_container.h"
-#include "scene/gui/texture_progress.h"
-#include "editor/filesystem_dock.h"
-#include "editor/scene_tree_editor.h"
-#include "editor/property_editor.h"
-#include "editor/create_dialog.h"
#include "editor/call_dialog.h"
-#include "editor/reparent_dialog.h"
#include "editor/connections_dialog.h"
-#include "editor/node_dock.h"
-#include "editor/import_dock.h"
-#include "editor/settings_config_dialog.h"
-#include "editor/groups_editor.h"
+#include "editor/create_dialog.h"
#include "editor/editor_data.h"
#include "editor/editor_path.h"
#include "editor/editor_run.h"
+#include "editor/filesystem_dock.h"
+#include "editor/groups_editor.h"
+#include "editor/import_dock.h"
+#include "editor/node_dock.h"
+#include "editor/property_editor.h"
+#include "editor/reparent_dialog.h"
+#include "editor/scene_tree_editor.h"
+#include "editor/settings_config_dialog.h"
+#include "scene/gui/center_container.h"
+#include "scene/gui/control.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/file_dialog.h"
+#include "scene/gui/menu_button.h"
+#include "scene/gui/panel.h"
+#include "scene/gui/panel_container.h"
+#include "scene/gui/separator.h"
+#include "scene/gui/split_container.h"
+#include "scene/gui/tab_container.h"
+#include "scene/gui/texture_progress.h"
+#include "scene/gui/tool_button.h"
+#include "scene/gui/tree.h"
#include "editor/pane_drag.h"
-#include "editor/script_create_dialog.h"
-#include "editor/run_settings_dialog.h"
-#include "editor/project_settings.h"
-#include "editor/project_export.h"
#include "editor/editor_log.h"
-#include "editor/scene_tree_dock.h"
-#include "editor/resources_dock.h"
#include "editor/editor_run_script.h"
+#include "editor/project_export.h"
+#include "editor/project_settings.h"
+#include "editor/resources_dock.h"
+#include "editor/run_settings_dialog.h"
+#include "editor/scene_tree_dock.h"
+#include "editor/script_create_dialog.h"
+#include "editor/editor_name_dialog.h"
+#include "editor/editor_plugin.h"
#include "editor/editor_run_native.h"
-#include "scene/gui/tabs.h"
-#include "editor/quick_open.h"
-#include "editor/project_export.h"
#include "editor/editor_sub_scene.h"
+#include "editor/project_export.h"
+#include "editor/quick_open.h"
#include "editor_export.h"
#include "editor_reimport_dialog.h"
-#include "editor/editor_plugin.h"
-#include "editor/editor_name_dialog.h"
+#include "scene/gui/tabs.h"
-#include "fileserver/editor_file_server.h"
#include "editor_resource_preview.h"
+#include "fileserver/editor_file_server.h"
#include "scene/gui/viewport_container.h"
-
#include "progress_dialog.h"
#include "editor_scale.h"
@@ -90,10 +89,6 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-
-
-
-
typedef void (*EditorNodeInitCallback)();
typedef void (*EditorPluginInitializeCallback)();
typedef void (*EditorBuildCallback)();
@@ -102,7 +97,7 @@ class EditorPluginList;
class EditorNode : public Node {
- GDCLASS( EditorNode, Node );
+ GDCLASS(EditorNode, Node);
public:
enum DockSlot {
@@ -116,9 +111,10 @@ public:
DOCK_SLOT_RIGHT_BR,
DOCK_SLOT_MAX
};
+
private:
enum {
- HISTORY_SIZE=64
+ HISTORY_SIZE = 64
};
enum MenuOptions {
@@ -194,21 +190,19 @@ private:
DEPENDENCY_UPDATE_IMPORTED,
SCENE_TAB_CLOSE,
- IMPORT_PLUGIN_BASE=100,
+ IMPORT_PLUGIN_BASE = 100,
- OBJECT_METHOD_BASE=500,
+ OBJECT_METHOD_BASE = 500,
- TOOL_MENU_BASE=1000
+ TOOL_MENU_BASE = 1000
};
-
-
//Node *edited_scene; //scene being edited
Viewport *scene_root; //root of the scene being edited
//Ref<ResourceImportMetadata> scene_import_metadata;
- PanelContainer* scene_root_parent;
+ PanelContainer *scene_root_parent;
Control *gui_base;
VBoxContainer *main_vbox;
@@ -240,7 +234,6 @@ private:
//PaneDrag *pd_anim;
Panel *menu_panel;
-
//HSplitContainer *editor_hsplit;
//VSplitContainer *editor_vsplit;
CenterContainer *play_cc;
@@ -335,10 +328,10 @@ private:
EditorQuickOpen *quick_run;
HBoxContainer *main_editor_button_vb;
- Vector<ToolButton*> main_editor_buttons;
- Vector<EditorPlugin*> editor_table;
+ Vector<ToolButton *> main_editor_buttons;
+ Vector<EditorPlugin *> editor_table;
-// EditorReImportDialog *reimport_dialog;
+ // EditorReImportDialog *reimport_dialog;
ProgressDialog *progress_dialog;
BackgroundProgress *progress_hb;
@@ -350,7 +343,6 @@ private:
Button *new_inherited_button;
String open_import_request;
-
TabContainer *dock_slot[DOCK_SLOT_MAX];
Rect2 dock_select_rect[DOCK_SLOT_MAX];
int dock_select_rect_over;
@@ -386,7 +378,7 @@ private:
uint64_t circle_step_frame;
int circle_step;
- Vector<EditorPlugin*> editor_plugins;
+ Vector<EditorPlugin *> editor_plugins;
EditorPlugin *editor_plugin_screen;
EditorPluginList *editor_plugins_over;
@@ -394,13 +386,12 @@ private:
EditorData editor_data;
EditorRun editor_run;
EditorSelection *editor_selection;
-// ProjectExport *project_export;
+ // ProjectExport *project_export;
ProjectExportDialog *project_export;
EditorResourcePreview *resource_preview;
EditorFileServer *file_server;
-
struct BottomPanelItem {
String name;
Control *control;
@@ -421,17 +412,16 @@ private:
void _dialog_action(String p_file);
-
void _edit_current();
- void _dialog_display_file_error(String p_file,Error p_error);
+ void _dialog_display_file_error(String p_file, Error p_error);
int current_option;
//void _animation_visibility_toggle();
void _resource_created();
- void _resource_selected(const RES& p_res,const String& p_property="");
+ void _resource_selected(const RES &p_res, const String &p_property = "");
void _menu_option(int p_option);
void _menu_confirm_current();
- void _menu_option_confirm(int p_option,bool p_confirmed);
+ void _menu_option_confirm(int p_option, bool p_confirmed);
void _update_debug_options();
void _property_editor_forward();
@@ -440,15 +430,14 @@ private:
void _select_history(int p_idx);
void _prepare_history();
-
void _fs_changed();
void _sources_changed(bool p_exist);
void _imported(Node *p_node);
void _node_renamed();
void _editor_select(int p_which);
- void _set_scene_metadata(const String &p_file, int p_idx=-1);
- void _get_scene_metadata(const String& p_file);
+ void _set_scene_metadata(const String &p_file, int p_idx = -1);
+ void _get_scene_metadata(const String &p_file);
void _update_title();
void _update_scene_tabs();
void _close_messages();
@@ -459,37 +448,36 @@ private:
void _save_scene(String p_file, int idx = -1);
+ void _instance_request(const Vector<String> &p_files);
- void _instance_request(const Vector<String>& p_files);
-
- void _property_keyed(const String& p_keyed, const Variant& p_value, bool p_advance);
- void _transform_keyed(Object *sp,const String& p_sub,const Transform& p_key);
+ void _property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance);
+ void _transform_keyed(Object *sp, const String &p_sub, const Transform &p_key);
void _hide_top_editors();
void _display_top_editors(bool p_display);
- void _set_top_editors(Vector<EditorPlugin*> p_editor_plugins_over);
- void _set_editing_top_editors(Object * p_current_object);
+ void _set_top_editors(Vector<EditorPlugin *> p_editor_plugins_over);
+ void _set_editing_top_editors(Object *p_current_object);
void _quick_opened();
void _quick_run();
- void _run(bool p_current=false, const String &p_custom="");
+ void _run(bool p_current = false, const String &p_custom = "");
void _save_optimized();
- void _import_action(const String& p_action);
+ void _import_action(const String &p_action);
void _import(const String &p_file);
- void _add_to_recent_scenes(const String& p_scene);
+ void _add_to_recent_scenes(const String &p_scene);
void _update_recent_scenes();
void _open_recent_scene(int p_idx);
- void _dropped_files(const Vector<String>& p_files,int p_screen);
+ void _dropped_files(const Vector<String> &p_files, int p_screen);
//void _open_recent_scene_confirm();
String _recent_scene;
bool convert_old;
- void _unhandled_input(const InputEvent& p_event);
+ void _unhandled_input(const InputEvent &p_event);
- static void _load_error_notify(void* p_ud,const String& p_text);
+ static void _load_error_notify(void *p_ud, const String &p_text);
bool has_main_screen() const { return true; }
@@ -497,41 +485,37 @@ private:
String import_reload_fn;
- Set<FileDialog*> file_dialogs;
- Set<EditorFileDialog*> editor_file_dialogs;
+ Set<FileDialog *> file_dialogs;
+ Set<EditorFileDialog *> editor_file_dialogs;
- Map<String,Ref<Texture> > icon_type_cache;
+ Map<String, Ref<Texture> > icon_type_cache;
bool _initializing_addons;
- Map<String,EditorPlugin*> plugin_addons;
+ Map<String, EditorPlugin *> plugin_addons;
-
- static Ref<Texture> _file_dialog_get_icon(const String& p_path);
+ static Ref<Texture> _file_dialog_get_icon(const String &p_path);
static void _file_dialog_register(FileDialog *p_dialog);
static void _file_dialog_unregister(FileDialog *p_dialog);
static void _editor_file_dialog_register(EditorFileDialog *p_dialog);
static void _editor_file_dialog_unregister(EditorFileDialog *p_dialog);
-
void _cleanup_scene();
void _remove_edited_scene();
void _remove_scene(int index);
- bool _find_and_save_resource(RES p_res,Map<RES,bool>& processed,int32_t flags);
- bool _find_and_save_edited_subresources(Object *obj,Map<RES,bool>& processed,int32_t flags);
- void _save_edited_subresources(Node* scene,Map<RES,bool>& processed,int32_t flags);
+ bool _find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags);
+ bool _find_and_save_edited_subresources(Object *obj, Map<RES, bool> &processed, int32_t flags);
+ void _save_edited_subresources(Node *scene, Map<RES, bool> &processed, int32_t flags);
- void _find_node_types(Node* p_node, int&count_2d, int&count_3d);
+ void _find_node_types(Node *p_node, int &count_2d, int &count_3d);
void _save_scene_with_preview(String p_file);
+ Map<String, Set<String> > dependency_errors;
- Map<String,Set<String> > dependency_errors;
-
- static void _dependency_error_report(void *ud,const String& p_path,const String& p_dep,const String& p_type) {
- EditorNode*en=(EditorNode*)ud;
+ static void _dependency_error_report(void *ud, const String &p_path, const String &p_dep, const String &p_type) {
+ EditorNode *en = (EditorNode *)ud;
if (!en->dependency_errors.has(p_path))
- en->dependency_errors[p_path]=Set<String>();
- en->dependency_errors[p_path].insert(p_dep+"::"+p_type);
-
+ en->dependency_errors[p_path] = Set<String>();
+ en->dependency_errors[p_path].insert(p_dep + "::" + p_type);
}
struct ExportDefer {
@@ -546,9 +530,9 @@ private:
static Vector<EditorNodeInitCallback> _init_callbacks;
- bool _find_scene_in_use(Node* p_node,const String& p_path) const;
+ bool _find_scene_in_use(Node *p_node, const String &p_path) const;
- void _dock_select_input(const InputEvent& p_input);
+ void _dock_select_input(const InputEvent &p_input);
void _dock_move_left();
void _dock_move_right();
void _dock_select_draw();
@@ -560,14 +544,14 @@ private:
void _scene_tab_script_edited(int p_tab);
Dictionary _get_main_scene_state();
- void _set_main_scene_state(Dictionary p_state,Node* p_for_scene);
+ void _set_main_scene_state(Dictionary p_state, Node *p_for_scene);
int _get_current_main_editor();
void _save_docks();
void _load_docks();
- void _save_docks_to_config(Ref<ConfigFile> p_layout, const String& p_section);
- void _load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section);
+ void _save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section);
+ void _load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section);
void _update_dock_slots_visibility();
void _update_top_menu_visibility();
@@ -580,19 +564,18 @@ private:
void _update_addon_config();
- static void _file_access_close_error_notify(const String& p_str);
+ static void _file_access_close_error_notify(const String &p_str);
void _toggle_distraction_free_mode();
enum {
- MAX_INIT_CALLBACKS=128,
- MAX_BUILD_CALLBACKS=128
+ MAX_INIT_CALLBACKS = 128,
+ MAX_BUILD_CALLBACKS = 128
};
void _inherit_imported(const String &p_action);
void _open_imported();
-
static int plugin_init_callback_count;
static EditorPluginInitializeCallback plugin_init_callbacks[MAX_INIT_CALLBACKS];
@@ -612,14 +595,14 @@ private:
Vector<ToolMenuItem> tool_menu_items;
- void _tool_menu_insert_item(const ToolMenuItem& p_item);
+ void _tool_menu_insert_item(const ToolMenuItem &p_item);
void _rebuild_tool_menu() const;
protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
static void add_plugin_init_callback(EditorPluginInitializeCallback p_callback);
enum EditorTable {
@@ -629,8 +612,7 @@ public:
};
void set_visible_editor(EditorTable p_table) { _editor_select(p_table); }
- static EditorNode* get_singleton() { return singleton; }
-
+ static EditorNode *get_singleton() { return singleton; }
EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; }
EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; }
@@ -640,8 +622,7 @@ public:
static void add_editor_plugin(EditorPlugin *p_editor);
static void remove_editor_plugin(EditorPlugin *p_editor);
- void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE,false); }
-
+ void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE, false); }
void set_docks_visible(bool p_show);
bool get_docks_visible() const;
@@ -649,35 +630,34 @@ public:
void set_distraction_free_mode(bool p_enter);
bool get_distraction_free_mode() const;
- void add_control_to_dock(DockSlot p_slot,Control* p_control);
- void remove_control_from_dock(Control* p_control);
+ void add_control_to_dock(DockSlot p_slot, Control *p_control);
+ void remove_control_from_dock(Control *p_control);
- void set_addon_plugin_enabled(const String& p_addon,bool p_enabled);
+ void set_addon_plugin_enabled(const String &p_addon, bool p_enabled);
bool is_addon_plugin_enabled(const String &p_addon) const;
void edit_node(Node *p_node);
- void edit_resource(const Ref<Resource>& p_resource);
- void open_resource(const String& p_type="");
+ void edit_resource(const Ref<Resource> &p_resource);
+ void open_resource(const String &p_type = "");
- void save_resource_in_path(const Ref<Resource>& p_resource,const String& p_path);
- void save_resource(const Ref<Resource>& p_resource);
- void save_resource_as(const Ref<Resource>& p_resource, const String &p_at_path=String());
+ void save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path);
+ void save_resource(const Ref<Resource> &p_resource);
+ void save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path = String());
- void merge_from_scene() { _menu_option_confirm(FILE_IMPORT_SUBSCENE,false); }
+ void merge_from_scene() { _menu_option_confirm(FILE_IMPORT_SUBSCENE, false); }
static bool has_unsaved_changes() { return singleton->unsaved_cache; }
static HBoxContainer *get_menu_hb() { return singleton->menu_hb; }
- void push_item(Object *p_object,const String& p_property="");
+ void push_item(Object *p_object, const String &p_property = "");
- void open_request(const String& p_path);
+ void open_request(const String &p_path);
bool is_changing_scene() const;
-
static EditorLog *get_log() { return singleton->log; }
- Control* get_viewport();
+ Control *get_viewport();
//void animation_editor_make_visible(bool p_visible);
//void hide_animation_player_editors();
@@ -689,31 +669,31 @@ public:
Viewport *get_scene_root() { return scene_root; } //root of the scene being edited
- void fix_dependencies(const String& p_for_file);
+ void fix_dependencies(const String &p_for_file);
void clear_scene() { _cleanup_scene(); }
- Error load_scene(const String& p_scene, bool p_ignore_broken_deps=false, bool p_set_inherited=false, bool p_clear_errors=true,bool p_force_open_imported=false);
- Error load_resource(const String& p_scene);
+ Error load_scene(const String &p_scene, bool p_ignore_broken_deps = false, bool p_set_inherited = false, bool p_clear_errors = true, bool p_force_open_imported = false);
+ Error load_resource(const String &p_scene);
- bool is_scene_open(const String& p_path);
+ bool is_scene_open(const String &p_path);
void set_current_version(uint64_t p_version);
void set_current_scene(int p_idx);
- static EditorData& get_editor_data() { return singleton->editor_data; }
- EditorHistory * get_editor_history() { return &editor_history; }
+ static EditorData &get_editor_data() { return singleton->editor_data; }
+ EditorHistory *get_editor_history() { return &editor_history; }
static VSplitContainer *get_top_split() { return singleton->top_split; }
void request_instance_scene(const String &p_path);
- void request_instance_scenes(const Vector<String>& p_files);
+ void request_instance_scenes(const Vector<String> &p_files);
FileSystemDock *get_filesystem_dock();
ImportDock *get_import_dock();
SceneTreeDock *get_scene_tree_dock();
- static UndoRedo* get_undo_redo() { return &singleton->editor_data.get_undo_redo(); }
+ static UndoRedo *get_undo_redo() { return &singleton->editor_data.get_undo_redo(); }
EditorSelection *get_editor_selection() { return editor_selection; }
- void set_convert_old_scene(bool p_old) { convert_old=p_old; }
+ void set_convert_old_scene(bool p_old) { convert_old = p_old; }
void notify_child_process_exited();
@@ -722,11 +702,9 @@ public:
Ref<Theme> get_editor_theme() const { return theme; }
+ void show_warning(const String &p_text, const String &p_title = "Warning!");
- void show_warning(const String& p_text,const String& p_title="Warning!");
-
-
- Error export_platform(const String& p_platform, const String& p_path, bool p_debug,const String& p_password,bool p_quit_after=false);
+ Error export_platform(const String &p_platform, const String &p_path, bool p_debug, const String &p_password, bool p_quit_after = false);
static void register_editor_types();
static void unregister_editor_types();
@@ -734,19 +712,19 @@ public:
Control *get_gui_base() { return gui_base; }
Control *get_theme_base() { return gui_base->get_parent_control(); }
- static void add_io_error(const String& p_error);
+ static void add_io_error(const String &p_error);
- static void progress_add_task(const String& p_task,const String& p_label, int p_steps);
- static void progress_task_step(const String& p_task,const String& p_state, int p_step=-1,bool p_force_refresh=true);
- static void progress_end_task(const String& p_task);
+ static void progress_add_task(const String &p_task, const String &p_label, int p_steps);
+ static void progress_task_step(const String &p_task, const String &p_state, int p_step = -1, bool p_force_refresh = true);
+ static void progress_end_task(const String &p_task);
- static void progress_add_task_bg(const String& p_task,const String& p_label, int p_steps);
- static void progress_task_step_bg(const String& p_task,int p_step=-1);
- static void progress_end_task_bg(const String& p_task);
+ static void progress_add_task_bg(const String &p_task, const String &p_label, int p_steps);
+ static void progress_task_step_bg(const String &p_task, int p_step = -1);
+ static void progress_end_task_bg(const String &p_task);
void save_scene(String p_file) { _save_scene(p_file); }
- bool is_scene_in_use(const String& p_path);
+ bool is_scene_in_use(const String &p_path);
void scan_import_changes();
@@ -754,79 +732,79 @@ public:
void update_keying();
- void reload_scene(const String& p_path);
+ void reload_scene(const String &p_path);
bool is_exiting() const { return exiting; }
ToolButton *get_pause_button() { return pause_button; }
-
- ToolButton* add_bottom_panel_item(String p_text,Control *p_item);
+ ToolButton *add_bottom_panel_item(String p_text, Control *p_item);
bool are_bottom_panels_hidden() const;
void make_bottom_panel_item_visible(Control *p_item);
void raise_bottom_panel_item(Control *p_item);
void hide_bottom_panel();
void remove_bottom_panel_item(Control *p_item);
- Variant drag_resource(const Ref<Resource>& p_res,Control* p_from);
- Variant drag_files(const Vector<String>& p_files,Control* p_from);
- Variant drag_files_and_dirs(const Vector<String>& p_files,Control* p_from);
+ Variant drag_resource(const Ref<Resource> &p_res, Control *p_from);
+ Variant drag_files(const Vector<String> &p_files, Control *p_from);
+ Variant drag_files_and_dirs(const Vector<String> &p_files, Control *p_from);
- void add_tool_menu_item(const String& p_name, Object *p_handler, const String& p_callback, const Variant& p_ud = Variant());
- void add_tool_submenu_item(const String& p_name, PopupMenu *p_submenu);
- void remove_tool_menu_item(const String& p_name);
+ void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant());
+ void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu);
+ void remove_tool_menu_item(const String &p_name);
EditorNode();
~EditorNode();
- void get_singleton(const char* arg1, bool arg2);
+ void get_singleton(const char *arg1, bool arg2);
static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); }
static void add_build_callback(EditorBuildCallback p_callback);
-
-
-
};
struct EditorProgress {
String task;
- void step(const String& p_state, int p_step=-1,bool p_force_refresh=true) { EditorNode::progress_task_step(task,p_state,p_step,p_force_refresh); }
- EditorProgress(const String& p_task,const String& p_label,int p_amount) { EditorNode::progress_add_task(p_task,p_label,p_amount); task=p_task; }
+ void step(const String &p_state, int p_step = -1, bool p_force_refresh = true) { EditorNode::progress_task_step(task, p_state, p_step, p_force_refresh); }
+ EditorProgress(const String &p_task, const String &p_label, int p_amount) {
+ EditorNode::progress_add_task(p_task, p_label, p_amount);
+ task = p_task;
+ }
~EditorProgress() { EditorNode::progress_end_task(task); }
};
class EditorPluginList : public Object {
private:
- Vector<EditorPlugin*> plugins_list;
+ Vector<EditorPlugin *> plugins_list;
public:
-
- void set_plugins_list(Vector<EditorPlugin*> p_plugins_list) {
+ void set_plugins_list(Vector<EditorPlugin *> p_plugins_list) {
plugins_list = p_plugins_list;
}
- Vector<EditorPlugin*>& get_plugins_list() {
+ Vector<EditorPlugin *> &get_plugins_list() {
return plugins_list;
}
void make_visible(bool p_visible);
void edit(Object *p_object);
- bool forward_gui_input(const Transform2D& p_canvas_xform,const InputEvent& p_event);
- bool forward_spatial_gui_input(Camera* p_camera, const InputEvent& p_event);
- void forward_draw_over_canvas(const Transform2D& p_canvas_xform,Control* p_canvas);
+ bool forward_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event);
+ bool forward_spatial_gui_input(Camera *p_camera, const InputEvent &p_event);
+ void forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas);
void clear();
bool empty();
EditorPluginList();
~EditorPluginList();
-
-} ;
+};
struct EditorProgressBG {
String task;
- void step(int p_step=-1) { EditorNode::progress_task_step_bg(task,p_step); }
- EditorProgressBG(const String& p_task,const String& p_label,int p_amount) { EditorNode::progress_add_task_bg(p_task,p_label,p_amount); task=p_task; }
+ void step(int p_step = -1) { EditorNode::progress_task_step_bg(task, p_step); }
+ EditorProgressBG(const String &p_task, const String &p_label, int p_amount) {
+ EditorNode::progress_add_task_bg(p_task, p_label, p_amount);
+ task = p_task;
+ }
~EditorProgressBG() { EditorNode::progress_end_task_bg(task); }
};
diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp
index 8cd31c4bcc..0200278dc0 100644
--- a/editor/editor_path.cpp
+++ b/editor/editor_path.cpp
@@ -28,25 +28,25 @@
/*************************************************************************/
#include "editor_path.h"
-#include "editor_scale.h"
#include "editor_node.h"
+#include "editor_scale.h"
-void EditorPath::_add_children_to_popup(Object* p_obj,int p_depth) {
+void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) {
- if (p_depth>8)
+ if (p_depth > 8)
return;
List<PropertyInfo> pinfo;
p_obj->get_property_list(&pinfo);
- for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- if (!(E->get().usage&PROPERTY_USAGE_EDITOR))
+ if (!(E->get().usage & PROPERTY_USAGE_EDITOR))
continue;
- if (E->get().hint!=PROPERTY_HINT_RESOURCE_TYPE)
+ if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE)
continue;
Variant value = p_obj->get(E->get().name);
- if (value.get_type()!=Variant::OBJECT)
+ if (value.get_type() != Variant::OBJECT)
continue;
Object *obj = value;
if (!obj)
@@ -54,69 +54,64 @@ void EditorPath::_add_children_to_popup(Object* p_obj,int p_depth) {
Ref<Texture> icon;
- if (has_icon(obj->get_class(),"EditorIcons"))
- icon=get_icon(obj->get_class(),"EditorIcons");
+ if (has_icon(obj->get_class(), "EditorIcons"))
+ icon = get_icon(obj->get_class(), "EditorIcons");
else
- icon=get_icon("Object","EditorIcons");
+ icon = get_icon("Object", "EditorIcons");
int index = popup->get_item_count();
- popup->add_icon_item(icon,E->get().name.capitalize(),objects.size());
- popup->set_item_h_offset(index,p_depth*10*EDSCALE);
+ popup->add_icon_item(icon, E->get().name.capitalize(), objects.size());
+ popup->set_item_h_offset(index, p_depth * 10 * EDSCALE);
objects.push_back(obj->get_instance_ID());
- _add_children_to_popup(obj,p_depth+1);
+ _add_children_to_popup(obj, p_depth + 1);
}
}
-void EditorPath::_gui_input(const InputEvent& p_event) {
+void EditorPath::_gui_input(const InputEvent &p_event) {
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT && p_event.mouse_button.pressed) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_LEFT && p_event.mouse_button.pressed) {
-
- Object *obj = ObjectDB::get_instance(history->get_path_object( history->get_path_size()-1));
+ Object *obj = ObjectDB::get_instance(history->get_path_object(history->get_path_size() - 1));
if (!obj)
return;
-
-
objects.clear();
popup->clear();
_add_children_to_popup(obj);
- popup->set_pos( get_global_pos() + Vector2(0,get_size().height));
- popup->set_size( Size2(get_size().width,1));
+ popup->set_pos(get_global_pos() + Vector2(0, get_size().height));
+ popup->set_size(Size2(get_size().width, 1));
popup->popup();
}
}
void EditorPath::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_MOUSE_ENTER: {
- mouse_over=true;
+ mouse_over = true;
update();
} break;
case NOTIFICATION_MOUSE_EXIT: {
- mouse_over=false;
+ mouse_over = false;
update();
} break;
case NOTIFICATION_DRAW: {
- RID ci=get_canvas_item();
- Ref<Font> label_font = get_font("font","Label");
+ RID ci = get_canvas_item();
+ Ref<Font> label_font = get_font("font", "Label");
Size2i size = get_size();
- Ref<Texture> sn = get_icon("SmallNext","EditorIcons");
- Ref<StyleBox> sb = get_stylebox("pressed","Button");
-
+ Ref<Texture> sn = get_icon("SmallNext", "EditorIcons");
+ Ref<StyleBox> sb = get_stylebox("pressed", "Button");
- int ofs=sb->get_margin(MARGIN_LEFT);
+ int ofs = sb->get_margin(MARGIN_LEFT);
if (mouse_over) {
- draw_style_box(sb,Rect2(Point2(),get_size()));
+ draw_style_box(sb, Rect2(Point2(), get_size()));
}
- for(int i=0;i<history->get_path_size();i++) {
+ for (int i = 0; i < history->get_path_size(); i++) {
Object *obj = ObjectDB::get_instance(history->get_path_object(i));
if (!obj)
@@ -126,53 +121,50 @@ void EditorPath::_notification(int p_what) {
Ref<Texture> icon;
- if (has_icon(obj->get_class(),"EditorIcons"))
- icon=get_icon(obj->get_class(),"EditorIcons");
+ if (has_icon(obj->get_class(), "EditorIcons"))
+ icon = get_icon(obj->get_class(), "EditorIcons");
else
- icon=get_icon("Object","EditorIcons");
+ icon = get_icon("Object", "EditorIcons");
+ icon->draw(ci, Point2i(ofs, (size.height - icon->get_height()) / 2));
- icon->draw(ci,Point2i(ofs,(size.height-icon->get_height())/2));
+ ofs += icon->get_width();
- ofs+=icon->get_width();
-
- if (i==history->get_path_size()-1) {
+ if (i == history->get_path_size() - 1) {
//add name
- ofs+=4;
+ ofs += 4;
int left = size.width - ofs;
- if (left<0)
+ if (left < 0)
continue;
String name;
if (obj->cast_to<Resource>()) {
Resource *r = obj->cast_to<Resource>();
if (r->get_path().is_resource_file())
- name=r->get_path().get_file();
+ name = r->get_path().get_file();
else
- name=r->get_name();
+ name = r->get_name();
- if (name=="")
- name=r->get_class();
+ if (name == "")
+ name = r->get_class();
} else if (obj->cast_to<Node>()) {
- name=obj->cast_to<Node>()->get_name();
- } else if (obj->cast_to<Resource>() && obj->cast_to<Resource>()->get_name()!="") {
- name=obj->cast_to<Resource>()->get_name();
+ name = obj->cast_to<Node>()->get_name();
+ } else if (obj->cast_to<Resource>() && obj->cast_to<Resource>()->get_name() != "") {
+ name = obj->cast_to<Resource>()->get_name();
} else {
- name=obj->get_class();
+ name = obj->get_class();
}
set_tooltip(obj->get_class());
-
- label_font->draw(ci,Point2i(ofs,(size.height-label_font->get_height())/2+label_font->get_ascent()),name,Color(1,1,1),left);
+ label_font->draw(ci, Point2i(ofs, (size.height - label_font->get_height()) / 2 + label_font->get_ascent()), name, Color(1, 1, 1), left);
} else {
//add arrow
//sn->draw(ci,Point2i(ofs,(size.height-sn->get_height())/2));
//ofs+=sn->get_width();
- ofs+=5; //just looks better! somehow
-
+ ofs += 5; //just looks better! somehow
}
}
@@ -182,15 +174,14 @@ void EditorPath::_notification(int p_what) {
void EditorPath::update_path() {
-
update();
}
void EditorPath::_popup_select(int p_idx) {
- ERR_FAIL_INDEX(p_idx,objects.size());
+ ERR_FAIL_INDEX(p_idx, objects.size());
- Object* obj = ObjectDB::get_instance(objects[p_idx]);
+ Object *obj = ObjectDB::get_instance(objects[p_idx]);
if (!obj)
return;
@@ -199,17 +190,15 @@ void EditorPath::_popup_select(int p_idx) {
void EditorPath::_bind_methods() {
- ClassDB::bind_method("_gui_input",&EditorPath::_gui_input);
- ClassDB::bind_method("_popup_select",&EditorPath::_popup_select);
+ ClassDB::bind_method("_gui_input", &EditorPath::_gui_input);
+ ClassDB::bind_method("_popup_select", &EditorPath::_popup_select);
}
EditorPath::EditorPath(EditorHistory *p_history) {
- history=p_history;
- mouse_over=false;
- popup = memnew( PopupMenu );
- popup->connect("id_pressed",this,"_popup_select");
+ history = p_history;
+ mouse_over = false;
+ popup = memnew(PopupMenu);
+ popup->connect("id_pressed", this, "_popup_select");
add_child(popup);
-
-
}
diff --git a/editor/editor_path.h b/editor/editor_path.h
index fd5b469d07..d781f6609a 100644
--- a/editor/editor_path.h
+++ b/editor/editor_path.h
@@ -29,32 +29,30 @@
#ifndef EDITOR_PATH_H
#define EDITOR_PATH_H
+#include "editor_data.h"
#include "scene/gui/control.h"
#include "scene/gui/popup_menu.h"
-#include "editor_data.h"
class EditorPath : public Control {
- GDCLASS(EditorPath,Control);
+ GDCLASS(EditorPath, Control);
EditorHistory *history;
-
Vector<ObjectID> objects;
PopupMenu *popup;
bool mouse_over;
EditorPath();
void _popup_select(int p_idx);
- void _gui_input(const InputEvent& p_event);
- void _add_children_to_popup(Object* p_obj,int p_depth=0);
-protected:
+ void _gui_input(const InputEvent &p_event);
+ void _add_children_to_popup(Object *p_obj, int p_depth = 0);
+protected:
static void _bind_methods();
void _notification(int p_what);
public:
-
void update_path();
EditorPath(EditorHistory *p_history);
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 85ef96fcc3..2579871d78 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -28,64 +28,60 @@
/*************************************************************************/
#include "editor_plugin.h"
-#include "scene/gui/popup_menu.h"
-#include "scene/3d/camera.h"
-#include "plugins/canvas_item_editor_plugin.h"
-#include "plugins/spatial_editor_plugin.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor_resource_preview.h"
+#include "plugins/canvas_item_editor_plugin.h"
+#include "plugins/spatial_editor_plugin.h"
+#include "scene/3d/camera.h"
+#include "scene/gui/popup_menu.h"
-void EditorPlugin::add_custom_type(const String& p_type, const String& p_base,const Ref<Script>& p_script, const Ref<Texture>& p_icon) {
+void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon) {
- EditorNode::get_editor_data().add_custom_type(p_type,p_base,p_script,p_icon);
+ EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon);
}
-void EditorPlugin::remove_custom_type(const String& p_type){
+void EditorPlugin::remove_custom_type(const String &p_type) {
EditorNode::get_editor_data().remove_custom_type(p_type);
}
+ToolButton *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) {
-ToolButton * EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) {
-
- return EditorNode::get_singleton()->add_bottom_panel_item(p_title,p_control);
+ return EditorNode::get_singleton()->add_bottom_panel_item(p_title, p_control);
}
-void EditorPlugin::add_control_to_dock(DockSlot p_slot,Control *p_control) {
+void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control) {
ERR_FAIL_NULL(p_control);
- EditorNode::get_singleton()->add_control_to_dock(EditorNode::DockSlot(p_slot),p_control);
-
+ EditorNode::get_singleton()->add_control_to_dock(EditorNode::DockSlot(p_slot), p_control);
}
void EditorPlugin::remove_control_from_docks(Control *p_control) {
ERR_FAIL_NULL(p_control);
EditorNode::get_singleton()->remove_control_from_dock(p_control);
-
}
void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
ERR_FAIL_NULL(p_control);
EditorNode::get_singleton()->remove_bottom_panel_item(p_control);
-
}
-Control * EditorPlugin::get_editor_viewport() {
+Control *EditorPlugin::get_editor_viewport() {
return EditorNode::get_singleton()->get_viewport();
}
-void EditorPlugin::edit_resource(const Ref<Resource>& p_resource){
+void EditorPlugin::edit_resource(const Ref<Resource> &p_resource) {
EditorNode::get_singleton()->edit_resource(p_resource);
}
-void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Control *p_control) {
+void EditorPlugin::add_control_to_container(CustomControlContainer p_location, Control *p_control) {
- switch(p_location) {
+ switch (p_location) {
case CONTAINER_TOOLBAR: {
@@ -100,7 +96,7 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Co
case CONTAINER_SPATIAL_EDITOR_SIDE: {
SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control);
- SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control,0);
+ SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
} break;
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
@@ -116,7 +112,7 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Co
case CONTAINER_CANVAS_EDITOR_SIDE: {
CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control);
- CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control,0);
+ CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
} break;
case CONTAINER_CANVAS_EDITOR_BOTTOM: {
@@ -129,17 +125,15 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Co
EditorNode::get_singleton()->get_property_editor_vb()->add_child(p_control);
} break;
-
-
}
}
-void EditorPlugin::add_tool_menu_item(const String& p_name, Object *p_handler, const String& p_callback, const Variant& p_ud) {
+void EditorPlugin::add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud) {
//EditorNode::get_singleton()->add_tool_menu_item(p_name, p_handler, p_callback, p_ud);
}
-void EditorPlugin::add_tool_submenu_item(const String& p_name, Object *p_submenu) {
+void EditorPlugin::add_tool_submenu_item(const String &p_name, Object *p_submenu) {
ERR_FAIL_NULL(p_submenu);
PopupMenu *submenu = p_submenu->cast_to<PopupMenu>();
@@ -147,32 +141,32 @@ void EditorPlugin::add_tool_submenu_item(const String& p_name, Object *p_submenu
//EditorNode::get_singleton()->add_tool_submenu_item(p_name, submenu);
}
-void EditorPlugin::remove_tool_menu_item(const String& p_name) {
+void EditorPlugin::remove_tool_menu_item(const String &p_name) {
//EditorNode::get_singleton()->remove_tool_menu_item(p_name);
}
-Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial* p_spatial) {
+Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial *p_spatial) {
//??
if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) {
- return get_script_instance()->call("create_spatial_gizmo",p_spatial);
+ return get_script_instance()->call("create_spatial_gizmo", p_spatial);
}
return Ref<SpatialEditorGizmo>();
}
-bool EditorPlugin::forward_canvas_gui_input(const Transform2D& p_canvas_xform,const InputEvent& p_event) {
+bool EditorPlugin::forward_canvas_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event) {
if (get_script_instance() && get_script_instance()->has_method("forward_canvas_gui_input")) {
- return get_script_instance()->call("forward_canvas_gui_input",p_canvas_xform,p_event);
+ return get_script_instance()->call("forward_canvas_gui_input", p_canvas_xform, p_event);
}
return false;
}
-void EditorPlugin::forward_draw_over_canvas(const Transform2D& p_canvas_xform,Control *p_canvas) {
+void EditorPlugin::forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas) {
if (get_script_instance() && get_script_instance()->has_method("forward_draw_over_canvas")) {
- get_script_instance()->call("forward_draw_over_canvas",p_canvas_xform,p_canvas);
+ get_script_instance()->call("forward_draw_over_canvas", p_canvas_xform, p_canvas);
}
}
@@ -180,10 +174,10 @@ void EditorPlugin::update_canvas() {
CanvasItemEditor::get_singleton()->get_viewport_control()->update();
}
-bool EditorPlugin::forward_spatial_gui_input(Camera* p_camera,const InputEvent& p_event) {
+bool EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const InputEvent &p_event) {
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_gui_input")) {
- return get_script_instance()->call("forward_spatial_gui_input",p_camera,p_event);
+ return get_script_instance()->call("forward_spatial_gui_input", p_camera, p_event);
}
return false;
@@ -195,7 +189,6 @@ String EditorPlugin::get_name() const {
}
return String();
-
}
bool EditorPlugin::has_main_screen() const {
@@ -204,28 +197,25 @@ bool EditorPlugin::has_main_screen() const {
}
return false;
-
}
void EditorPlugin::make_visible(bool p_visible) {
if (get_script_instance() && get_script_instance()->has_method("make_visible")) {
- get_script_instance()->call("make_visible",p_visible);
+ get_script_instance()->call("make_visible", p_visible);
}
}
-
void EditorPlugin::edit(Object *p_object) {
if (get_script_instance() && get_script_instance()->has_method("edit")) {
- get_script_instance()->call("edit",p_object);
+ get_script_instance()->call("edit", p_object);
}
-
}
bool EditorPlugin::handles(Object *p_object) const {
if (get_script_instance() && get_script_instance()->has_method("handles")) {
- return get_script_instance()->call("handles",p_object);
+ return get_script_instance()->call("handles", p_object);
}
return false;
@@ -239,10 +229,10 @@ Dictionary EditorPlugin::get_state() const {
return Dictionary();
}
-void EditorPlugin::set_state(const Dictionary& p_state) {
+void EditorPlugin::set_state(const Dictionary &p_state) {
if (get_script_instance() && get_script_instance()->has_method("set_state")) {
- get_script_instance()->call("set_state",p_state);
+ get_script_instance()->call("set_state", p_state);
}
}
@@ -251,7 +241,6 @@ void EditorPlugin::clear() {
if (get_script_instance() && get_script_instance()->has_method("clear")) {
get_script_instance()->call("clear");
}
-
}
// if editor references external resources/scenes, save them
@@ -274,12 +263,11 @@ void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
if (get_script_instance() && get_script_instance()->has_method("get_breakpoints")) {
PoolStringArray arr = get_script_instance()->call("get_breakpoints");
- for(int i=0;i<arr.size();i++)
+ for (int i = 0; i < arr.size(); i++)
p_breakpoints->push_back(arr[i]);
}
-
}
-bool EditorPlugin::get_remove_list(List<Node*> *p_list) {
+bool EditorPlugin::get_remove_list(List<Node *> *p_list) {
return false;
}
@@ -294,7 +282,7 @@ void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
}
}
-void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout){
+void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
if (get_script_instance() && get_script_instance()->has_method("get_window_layout")) {
get_script_instance()->call("get_window_layout", p_layout);
@@ -306,11 +294,10 @@ void EditorPlugin::queue_save_layout() const {
EditorNode::get_singleton()->save_layout();
}
-EditorSelection* EditorPlugin::get_selection() {
+EditorSelection *EditorPlugin::get_selection() {
return EditorNode::get_singleton()->get_editor_selection();
}
-
EditorSettings *EditorPlugin::get_editor_settings() {
return EditorSettings::get_singleton();
}
@@ -324,7 +311,7 @@ Control *EditorPlugin::get_base_control() {
return EditorNode::get_singleton()->get_gui_base();
}
-void EditorPlugin::make_bottom_panel_item_visible(Control * p_item) {
+void EditorPlugin::make_bottom_panel_item_visible(Control *p_item) {
EditorNode::get_singleton()->make_bottom_panel_item_visible(p_item);
}
@@ -334,9 +321,9 @@ void EditorPlugin::hide_bottom_panel() {
EditorNode::get_singleton()->hide_bottom_panel();
}
-void EditorPlugin::inspect_object(Object *p_obj,const String& p_for_property) {
+void EditorPlugin::inspect_object(Object *p_obj, const String &p_for_property) {
- EditorNode::get_singleton()->push_item(p_obj,p_for_property);
+ EditorNode::get_singleton()->push_item(p_obj, p_for_property);
}
EditorFileSystem *EditorPlugin::get_resource_file_system() {
@@ -345,88 +332,81 @@ EditorFileSystem *EditorPlugin::get_resource_file_system() {
void EditorPlugin::_bind_methods() {
- ClassDB::bind_method(D_METHOD("add_control_to_container","container","control:Control"),&EditorPlugin::add_control_to_container);
- ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel:ToolButton","control:Control","title"),&EditorPlugin::add_control_to_bottom_panel);
- ClassDB::bind_method(D_METHOD("add_control_to_dock","slot","control:Control"),&EditorPlugin::add_control_to_dock);
- ClassDB::bind_method(D_METHOD("remove_control_from_docks","control:Control"),&EditorPlugin::remove_control_from_docks);
- ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel);
+ ClassDB::bind_method(D_METHOD("add_control_to_container", "container", "control:Control"), &EditorPlugin::add_control_to_container);
+ ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel:ToolButton", "control:Control", "title"), &EditorPlugin::add_control_to_bottom_panel);
+ ClassDB::bind_method(D_METHOD("add_control_to_dock", "slot", "control:Control"), &EditorPlugin::add_control_to_dock);
+ ClassDB::bind_method(D_METHOD("remove_control_from_docks", "control:Control"), &EditorPlugin::remove_control_from_docks);
+ ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel", "control:Control"), &EditorPlugin::remove_control_from_bottom_panel);
//ClassDB::bind_method(D_METHOD("add_tool_menu_item", "name", "handler", "callback", "ud"),&EditorPlugin::add_tool_menu_item,DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("add_tool_submenu_item", "name", "submenu:PopupMenu"),&EditorPlugin::add_tool_submenu_item);
+ ClassDB::bind_method(D_METHOD("add_tool_submenu_item", "name", "submenu:PopupMenu"), &EditorPlugin::add_tool_submenu_item);
//ClassDB::bind_method(D_METHOD("remove_tool_menu_item", "name"),&EditorPlugin::remove_tool_menu_item);
- ClassDB::bind_method(D_METHOD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type);
- ClassDB::bind_method(D_METHOD("remove_custom_type","type"),&EditorPlugin::remove_custom_type);
+ ClassDB::bind_method(D_METHOD("add_custom_type", "type", "base", "script:Script", "icon:Texture"), &EditorPlugin::add_custom_type);
+ ClassDB::bind_method(D_METHOD("remove_custom_type", "type"), &EditorPlugin::remove_custom_type);
ClassDB::bind_method(D_METHOD("get_editor_viewport:Control"), &EditorPlugin::get_editor_viewport);
- ClassDB::bind_method(D_METHOD("get_resource_previewer:EditorResourcePreview"),&EditorPlugin::get_resource_previewer);
- ClassDB::bind_method(D_METHOD("get_resource_filesystem:EditorFileSystem"),&EditorPlugin::get_resource_file_system);
+ ClassDB::bind_method(D_METHOD("get_resource_previewer:EditorResourcePreview"), &EditorPlugin::get_resource_previewer);
+ ClassDB::bind_method(D_METHOD("get_resource_filesystem:EditorFileSystem"), &EditorPlugin::get_resource_file_system);
- ClassDB::bind_method(D_METHOD("inspect_object","object","for_property"),&EditorPlugin::inspect_object,DEFVAL(String()));
- ClassDB::bind_method(D_METHOD("update_canvas"),&EditorPlugin::update_canvas);
+ ClassDB::bind_method(D_METHOD("inspect_object", "object", "for_property"), &EditorPlugin::inspect_object, DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("update_canvas"), &EditorPlugin::update_canvas);
- ClassDB::bind_method(D_METHOD("make_bottom_panel_item_visible","item:Control"), &EditorPlugin::make_bottom_panel_item_visible);
+ ClassDB::bind_method(D_METHOD("make_bottom_panel_item_visible", "item:Control"), &EditorPlugin::make_bottom_panel_item_visible);
ClassDB::bind_method(D_METHOD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
- ClassDB::bind_method(D_METHOD("get_base_control:Control"),&EditorPlugin::get_base_control);
- ClassDB::bind_method(D_METHOD("get_undo_redo:UndoRedo"),&EditorPlugin::_get_undo_redo);
- ClassDB::bind_method(D_METHOD("get_selection:EditorSelection"),&EditorPlugin::get_selection);
- ClassDB::bind_method(D_METHOD("get_editor_settings:EditorSettings"),&EditorPlugin::get_editor_settings);
- ClassDB::bind_method(D_METHOD("queue_save_layout"),&EditorPlugin::queue_save_layout);
- ClassDB::bind_method(D_METHOD("edit_resource"),&EditorPlugin::edit_resource);
-
- ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"forward_canvas_gui_input",PropertyInfo(Variant::TRANSFORM2D,"canvas_xform"),PropertyInfo(Variant::INPUT_EVENT,"event")));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo("forward_draw_over_canvas",PropertyInfo(Variant::TRANSFORM2D,"canvas_xform"),PropertyInfo(Variant::OBJECT,"canvas:Control")));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"forward_spatial_gui_input",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera"),PropertyInfo(Variant::INPUT_EVENT,"event")));
- MethodInfo gizmo = MethodInfo(Variant::OBJECT,"create_spatial_gizmo",PropertyInfo(Variant::OBJECT,"for_spatial:Spatial"));
- gizmo.return_val.hint=PROPERTY_HINT_RESOURCE_TYPE;
- gizmo.return_val.hint_string="EditorSpatialGizmo";
- ClassDB::add_virtual_method(get_class_static(),gizmo);
- ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::STRING,"get_name"));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"has_main_screen"));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo("make_visible",PropertyInfo(Variant::BOOL,"visible")));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo("edit",PropertyInfo(Variant::OBJECT,"object")));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"handles",PropertyInfo(Variant::OBJECT,"object")));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::DICTIONARY,"get_state"));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo("set_state",PropertyInfo(Variant::DICTIONARY,"state")));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo("clear"));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo("save_external_data"));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo("apply_changes"));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::POOL_STRING_ARRAY,"get_breakpoints"));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo("set_window_layout",PropertyInfo(Variant::OBJECT,"layout",PROPERTY_HINT_RESOURCE_TYPE,"ConfigFile")));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo("get_window_layout",PropertyInfo(Variant::OBJECT,"layout",PROPERTY_HINT_RESOURCE_TYPE,"ConfigFile")));
-
- BIND_CONSTANT( CONTAINER_TOOLBAR );
- BIND_CONSTANT( CONTAINER_SPATIAL_EDITOR_MENU );
- BIND_CONSTANT( CONTAINER_SPATIAL_EDITOR_SIDE );
- BIND_CONSTANT( CONTAINER_SPATIAL_EDITOR_BOTTOM );
- BIND_CONSTANT( CONTAINER_CANVAS_EDITOR_MENU );
- BIND_CONSTANT( CONTAINER_CANVAS_EDITOR_SIDE );
- BIND_CONSTANT( CONTAINER_PROPERTY_EDITOR_BOTTOM );
-
-
- BIND_CONSTANT( DOCK_SLOT_LEFT_UL );
- BIND_CONSTANT( DOCK_SLOT_LEFT_BL );
- BIND_CONSTANT( DOCK_SLOT_LEFT_UR );
- BIND_CONSTANT( DOCK_SLOT_LEFT_BR );
- BIND_CONSTANT( DOCK_SLOT_RIGHT_UL );
- BIND_CONSTANT( DOCK_SLOT_RIGHT_BL );
- BIND_CONSTANT( DOCK_SLOT_RIGHT_UR );
- BIND_CONSTANT( DOCK_SLOT_RIGHT_BR );
- BIND_CONSTANT( DOCK_SLOT_MAX );
-
-}
-
-EditorPlugin::EditorPlugin()
-{
- undo_redo=NULL;
-}
-
-
-EditorPlugin::~EditorPlugin()
-{
+ ClassDB::bind_method(D_METHOD("get_base_control:Control"), &EditorPlugin::get_base_control);
+ ClassDB::bind_method(D_METHOD("get_undo_redo:UndoRedo"), &EditorPlugin::_get_undo_redo);
+ ClassDB::bind_method(D_METHOD("get_selection:EditorSelection"), &EditorPlugin::get_selection);
+ ClassDB::bind_method(D_METHOD("get_editor_settings:EditorSettings"), &EditorPlugin::get_editor_settings);
+ ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout);
+ ClassDB::bind_method(D_METHOD("edit_resource"), &EditorPlugin::edit_resource);
+
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::INPUT_EVENT, "event")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_canvas", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "canvas:Control")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::INPUT_EVENT, "event")));
+ MethodInfo gizmo = MethodInfo(Variant::OBJECT, "create_spatial_gizmo", PropertyInfo(Variant::OBJECT, "for_spatial:Spatial"));
+ gizmo.return_val.hint = PROPERTY_HINT_RESOURCE_TYPE;
+ gizmo.return_val.hint_string = "EditorSpatialGizmo";
+ ClassDB::add_virtual_method(get_class_static(), gizmo);
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_name"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "has_main_screen"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("make_visible", PropertyInfo(Variant::BOOL, "visible")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("edit", PropertyInfo(Variant::OBJECT, "object")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles", PropertyInfo(Variant::OBJECT, "object")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::DICTIONARY, "get_state"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_state", PropertyInfo(Variant::DICTIONARY, "state")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("clear"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("save_external_data"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("apply_changes"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::POOL_STRING_ARRAY, "get_breakpoints"));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
+
+ BIND_CONSTANT(CONTAINER_TOOLBAR);
+ BIND_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU);
+ BIND_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE);
+ BIND_CONSTANT(CONTAINER_SPATIAL_EDITOR_BOTTOM);
+ BIND_CONSTANT(CONTAINER_CANVAS_EDITOR_MENU);
+ BIND_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE);
+ BIND_CONSTANT(CONTAINER_PROPERTY_EDITOR_BOTTOM);
+
+ BIND_CONSTANT(DOCK_SLOT_LEFT_UL);
+ BIND_CONSTANT(DOCK_SLOT_LEFT_BL);
+ BIND_CONSTANT(DOCK_SLOT_LEFT_UR);
+ BIND_CONSTANT(DOCK_SLOT_LEFT_BR);
+ BIND_CONSTANT(DOCK_SLOT_RIGHT_UL);
+ BIND_CONSTANT(DOCK_SLOT_RIGHT_BL);
+ BIND_CONSTANT(DOCK_SLOT_RIGHT_UR);
+ BIND_CONSTANT(DOCK_SLOT_RIGHT_BR);
+ BIND_CONSTANT(DOCK_SLOT_MAX);
+}
+
+EditorPlugin::EditorPlugin() {
+ undo_redo = NULL;
+}
+
+EditorPlugin::~EditorPlugin() {
}
-
-
EditorPluginCreateFunc EditorPlugins::creation_funcs[MAX_CREATE_FUNCS];
-int EditorPlugins::creation_func_count=0;
+int EditorPlugins::creation_func_count = 0;
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index 13d8ab0343..611ef72945 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -29,11 +29,11 @@
#ifndef EDITOR_PLUGIN_H
#define EDITOR_PLUGIN_H
+#include "io/config_file.h"
#include "scene/gui/tool_button.h"
#include "scene/main/node.h"
#include "scene/resources/texture.h"
#include "undo_redo.h"
-#include "io/config_file.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -53,23 +53,20 @@ class EditorFileSystem;
class EditorPlugin : public Node {
- GDCLASS( EditorPlugin, Node );
-friend class EditorData;
+ GDCLASS(EditorPlugin, Node);
+ friend class EditorData;
UndoRedo *undo_redo;
- UndoRedo* _get_undo_redo() { return undo_redo; }
+ UndoRedo *_get_undo_redo() { return undo_redo; }
protected:
-
static void _bind_methods();
- UndoRedo& get_undo_redo() { return *undo_redo; }
-
- void add_custom_type(const String& p_type, const String& p_base,const Ref<Script>& p_script, const Ref<Texture>& p_icon);
- void remove_custom_type(const String& p_type);
+ UndoRedo &get_undo_redo() { return *undo_redo; }
+ void add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon);
+ void remove_custom_type(const String &p_type);
public:
-
enum CustomControlContainer {
CONTAINER_TOOLBAR,
CONTAINER_SPATIAL_EDITOR_MENU,
@@ -97,40 +94,40 @@ public:
void add_control_to_container(CustomControlContainer p_location, Control *p_control);
ToolButton *add_control_to_bottom_panel(Control *p_control, const String &p_title);
- void add_control_to_dock(DockSlot p_slot,Control *p_control);
+ void add_control_to_dock(DockSlot p_slot, Control *p_control);
void remove_control_from_docks(Control *p_control);
void remove_control_from_bottom_panel(Control *p_control);
- Control* get_editor_viewport();
- void edit_resource(const Ref<Resource>& p_resource);
+ Control *get_editor_viewport();
+ void edit_resource(const Ref<Resource> &p_resource);
- void add_tool_menu_item(const String& p_name, Object *p_handler, const String& p_callback, const Variant& p_ud = Variant());
- void add_tool_submenu_item(const String& p_name, Object *p_submenu);
- void remove_tool_menu_item(const String& p_name);
+ void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant());
+ void add_tool_submenu_item(const String &p_name, Object *p_submenu);
+ void remove_tool_menu_item(const String &p_name);
- virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial);
- virtual bool forward_canvas_gui_input(const Transform2D& p_canvas_xform, const InputEvent& p_event);
- virtual void forward_draw_over_canvas(const Transform2D& p_canvas_xform,Control *p_canvas);
- virtual bool forward_spatial_gui_input(Camera* p_camera,const InputEvent& p_event);
+ virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial);
+ virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event);
+ virtual void forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas);
+ virtual bool forward_spatial_gui_input(Camera *p_camera, const InputEvent &p_event);
virtual String get_name() const;
virtual bool has_main_screen() const;
virtual void make_visible(bool p_visible);
- virtual void selected_notify() {}//notify that it was raised by the user, not the editor
+ virtual void selected_notify() {} //notify that it was raised by the user, not the editor
virtual void edit(Object *p_object);
virtual bool handles(Object *p_node) const;
virtual Dictionary get_state() const; //save editor state so it can't be reloaded when reloading scene
- virtual void set_state(const Dictionary& p_state) ; //restore editor state (likely was saved with the scene)
- virtual void clear() ; // clear any temporary data in te editor, reset it (likely new scene or load another scene)
- virtual void save_external_data() ; // if editor references external resources/scenes, save them
- virtual void apply_changes() ; // if changes are pending in editor, apply them
+ virtual void set_state(const Dictionary &p_state); //restore editor state (likely was saved with the scene)
+ virtual void clear(); // clear any temporary data in te editor, reset it (likely new scene or load another scene)
+ virtual void save_external_data(); // if editor references external resources/scenes, save them
+ virtual void apply_changes(); // if changes are pending in editor, apply them
virtual void get_breakpoints(List<String> *p_breakpoints);
- virtual bool get_remove_list(List<Node*> *p_list);
+ virtual bool get_remove_list(List<Node *> *p_list);
virtual void set_window_layout(Ref<ConfigFile> p_layout);
virtual void get_window_layout(Ref<ConfigFile> p_layout);
- virtual void edited_scene_changed(){} // if changes are pending in editor, apply them
+ virtual void edited_scene_changed() {} // if changes are pending in editor, apply them
void update_canvas();
- virtual void inspect_object(Object *p_obj,const String& p_for_property=String());
+ virtual void inspect_object(Object *p_obj, const String &p_for_property = String());
void queue_save_layout() const;
@@ -139,7 +136,7 @@ public:
void make_bottom_panel_item_visible(Control *p_item);
void hide_bottom_panel();
- EditorSelection* get_selection();
+ EditorSelection *get_selection();
//EditorImportExport *get_import_export();
EditorSettings *get_editor_settings();
EditorResourcePreview *get_resource_previewer();
@@ -150,52 +147,44 @@ public:
EditorPlugin();
virtual ~EditorPlugin();
-
};
-VARIANT_ENUM_CAST( EditorPlugin::CustomControlContainer );
-VARIANT_ENUM_CAST( EditorPlugin::DockSlot );
-
+VARIANT_ENUM_CAST(EditorPlugin::CustomControlContainer);
+VARIANT_ENUM_CAST(EditorPlugin::DockSlot);
-typedef EditorPlugin* (*EditorPluginCreateFunc)(EditorNode *);
+typedef EditorPlugin *(*EditorPluginCreateFunc)(EditorNode *);
class EditorPlugins {
enum {
- MAX_CREATE_FUNCS=64
+ MAX_CREATE_FUNCS = 64
};
static EditorPluginCreateFunc creation_funcs[MAX_CREATE_FUNCS];
static int creation_func_count;
- template<class T>
+ template <class T>
static EditorPlugin *creator(EditorNode *p_node) {
- return memnew( T(p_node) );
+ return memnew(T(p_node));
}
public:
-
static int get_plugin_count() { return creation_func_count; }
- static EditorPlugin* create(int p_idx,EditorNode* p_editor) { ERR_FAIL_INDEX_V(p_idx,creation_func_count,NULL); return creation_funcs[p_idx](p_editor); }
+ static EditorPlugin *create(int p_idx, EditorNode *p_editor) {
+ ERR_FAIL_INDEX_V(p_idx, creation_func_count, NULL);
+ return creation_funcs[p_idx](p_editor);
+ }
- template<class T>
+ template <class T>
static void add_by_type() {
add_create_func(creator<T>);
}
static void add_create_func(EditorPluginCreateFunc p_func) {
- ERR_FAIL_COND(creation_func_count>=MAX_CREATE_FUNCS);
- creation_funcs[creation_func_count++]=p_func;
+ ERR_FAIL_COND(creation_func_count >= MAX_CREATE_FUNCS);
+ creation_funcs[creation_func_count++] = p_func;
}
-
};
-
-
-
-
-
-
-
#endif
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index 2d879e38cf..3e7b225a8d 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -28,33 +28,32 @@
/*************************************************************************/
#include "editor_plugin_settings.h"
-#include "scene/gui/margin_container.h"
+#include "editor_node.h"
+#include "global_config.h"
#include "io/config_file.h"
#include "os/file_access.h"
#include "os/main_loop.h"
-#include "global_config.h"
-#include "editor_node.h"
+#include "scene/gui/margin_container.h"
void EditorPluginSettings::_notification(int p_what) {
- if (p_what==MainLoop::NOTIFICATION_WM_FOCUS_IN) {
+ if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
update_plugins();
}
}
void EditorPluginSettings::update_plugins() {
-
plugin_list->clear();
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
Error err = da->change_dir("res://addons");
- if (err!=OK) {
+ if (err != OK) {
memdelete(da);
return;
}
- updating=true;
+ updating = true;
TreeItem *root = plugin_list->create_item();
@@ -64,10 +63,10 @@ void EditorPluginSettings::update_plugins() {
Vector<String> plugins;
- while(d!=String()) {
+ while (d != String()) {
bool dir = da->current_is_dir();
- String path = "res://addons/"+d+"/plugin.cfg";
+ String path = "res://addons/" + d + "/plugin.cfg";
if (dir && FileAccess::exists(path)) {
@@ -84,133 +83,126 @@ void EditorPluginSettings::update_plugins() {
Vector<String> active_plugins = GlobalConfig::get_singleton()->get("plugins/active");
- for(int i=0;i<plugins.size();i++) {
+ for (int i = 0; i < plugins.size(); i++) {
Ref<ConfigFile> cf;
cf.instance();
- String path = "res://addons/"+plugins[i]+"/plugin.cfg";
+ String path = "res://addons/" + plugins[i] + "/plugin.cfg";
Error err = cf->load(path);
- if (err!=OK) {
- WARN_PRINTS("Can't load plugin config: "+path);
- } else if (!cf->has_section_key("plugin","name")) {
- WARN_PRINTS("Plugin misses plugin/name: "+path);
- } else if (!cf->has_section_key("plugin","author")) {
- WARN_PRINTS("Plugin misses plugin/author: "+path);
- } else if (!cf->has_section_key("plugin","version")) {
- WARN_PRINTS("Plugin misses plugin/version: "+path);
- } else if (!cf->has_section_key("plugin","description")) {
- WARN_PRINTS("Plugin misses plugin/description: "+path);
- } else if (!cf->has_section_key("plugin","script")) {
- WARN_PRINTS("Plugin misses plugin/script: "+path);
+ if (err != OK) {
+ WARN_PRINTS("Can't load plugin config: " + path);
+ } else if (!cf->has_section_key("plugin", "name")) {
+ WARN_PRINTS("Plugin misses plugin/name: " + path);
+ } else if (!cf->has_section_key("plugin", "author")) {
+ WARN_PRINTS("Plugin misses plugin/author: " + path);
+ } else if (!cf->has_section_key("plugin", "version")) {
+ WARN_PRINTS("Plugin misses plugin/version: " + path);
+ } else if (!cf->has_section_key("plugin", "description")) {
+ WARN_PRINTS("Plugin misses plugin/description: " + path);
+ } else if (!cf->has_section_key("plugin", "script")) {
+ WARN_PRINTS("Plugin misses plugin/script: " + path);
} else {
String d = plugins[i];
- String name = cf->get_value("plugin","name");
- String author = cf->get_value("plugin","author");
- String version = cf->get_value("plugin","version");
- String description = cf->get_value("plugin","description");
- String script = cf->get_value("plugin","script");
+ String name = cf->get_value("plugin", "name");
+ String author = cf->get_value("plugin", "author");
+ String version = cf->get_value("plugin", "version");
+ String description = cf->get_value("plugin", "description");
+ String script = cf->get_value("plugin", "script");
TreeItem *item = plugin_list->create_item(root);
- item->set_text(0,name);
- item->set_tooltip(0,"Name: "+name+"\nPath: "+path+"\nMain Script: "+script);
- item->set_metadata(0,d);
- item->set_text(1,version);
- item->set_metadata(1,script);
- item->set_text(2,author);
- item->set_metadata(2,description);
- item->set_cell_mode(3,TreeItem::CELL_MODE_RANGE);
- item->set_range_config(3,0,1,1);
- item->set_text(3,"Inactive,Active");
- item->set_editable(3,true);
+ item->set_text(0, name);
+ item->set_tooltip(0, "Name: " + name + "\nPath: " + path + "\nMain Script: " + script);
+ item->set_metadata(0, d);
+ item->set_text(1, version);
+ item->set_metadata(1, script);
+ item->set_text(2, author);
+ item->set_metadata(2, description);
+ item->set_cell_mode(3, TreeItem::CELL_MODE_RANGE);
+ item->set_range_config(3, 0, 1, 1);
+ item->set_text(3, "Inactive,Active");
+ item->set_editable(3, true);
if (EditorNode::get_singleton()->is_addon_plugin_enabled(d)) {
- item->set_custom_color(3,Color(0.2,1,0.2));
- item->set_range(3,1);
+ item->set_custom_color(3, Color(0.2, 1, 0.2));
+ item->set_range(3, 1);
} else {
- item->set_custom_color(3,Color(1,0.2,0.2));
- item->set_range(3,0);
+ item->set_custom_color(3, Color(1, 0.2, 0.2));
+ item->set_range(3, 0);
}
}
-
}
- updating=false;
-
+ updating = false;
}
-
void EditorPluginSettings::_plugin_activity_changed() {
if (updating)
return;
- TreeItem *ti=plugin_list->get_edited();
+ TreeItem *ti = plugin_list->get_edited();
ERR_FAIL_COND(!ti);
bool active = ti->get_range(3);
String name = ti->get_metadata(0);
- EditorNode::get_singleton()->set_addon_plugin_enabled(name,active);
+ EditorNode::get_singleton()->set_addon_plugin_enabled(name, active);
bool is_active = EditorNode::get_singleton()->is_addon_plugin_enabled(name);
- if (is_active!=active) {
- updating=true;
- ti->set_range(3,is_active?1:0);
- updating=false;
+ if (is_active != active) {
+ updating = true;
+ ti->set_range(3, is_active ? 1 : 0);
+ updating = false;
}
if (is_active)
- ti->set_custom_color(3,Color(0.2,1,0.2));
+ ti->set_custom_color(3, Color(0.2, 1, 0.2));
else
- ti->set_custom_color(3,Color(1,0.2,0.2));
-
-
+ ti->set_custom_color(3, Color(1, 0.2, 0.2));
}
void EditorPluginSettings::_bind_methods() {
- ClassDB::bind_method("update_plugins",&EditorPluginSettings::update_plugins);
- ClassDB::bind_method("_plugin_activity_changed",&EditorPluginSettings::_plugin_activity_changed);
+ ClassDB::bind_method("update_plugins", &EditorPluginSettings::update_plugins);
+ ClassDB::bind_method("_plugin_activity_changed", &EditorPluginSettings::_plugin_activity_changed);
}
EditorPluginSettings::EditorPluginSettings() {
- HBoxContainer *title_hb = memnew( HBoxContainer );
- title_hb->add_child(memnew( Label(TTR("Installed Plugins:"))));
+ HBoxContainer *title_hb = memnew(HBoxContainer);
+ title_hb->add_child(memnew(Label(TTR("Installed Plugins:"))));
title_hb->add_spacer();
- update_list = memnew( Button(TTR("Update")) );
- update_list->connect("pressed",this,"update_plugins");
+ update_list = memnew(Button(TTR("Update")));
+ update_list->connect("pressed", this, "update_plugins");
title_hb->add_child(update_list);
add_child(title_hb);
- plugin_list = memnew( Tree );
+ plugin_list = memnew(Tree);
plugin_list->set_v_size_flags(SIZE_EXPAND_FILL);
plugin_list->set_columns(4);
plugin_list->set_column_titles_visible(true);
- plugin_list->set_column_title(0,TTR("Name:"));
- plugin_list->set_column_title(1,TTR("Version:"));
- plugin_list->set_column_title(2,TTR("Author:"));
- plugin_list->set_column_title(3,TTR("Status:"));
- plugin_list->set_column_expand(0,true);
- plugin_list->set_column_expand(1,false);
- plugin_list->set_column_expand(2,false);
- plugin_list->set_column_expand(3,false);
- plugin_list->set_column_min_width(1,100);
- plugin_list->set_column_min_width(2,250);
- plugin_list->set_column_min_width(3,80);
+ plugin_list->set_column_title(0, TTR("Name:"));
+ plugin_list->set_column_title(1, TTR("Version:"));
+ plugin_list->set_column_title(2, TTR("Author:"));
+ plugin_list->set_column_title(3, TTR("Status:"));
+ plugin_list->set_column_expand(0, true);
+ plugin_list->set_column_expand(1, false);
+ plugin_list->set_column_expand(2, false);
+ plugin_list->set_column_expand(3, false);
+ plugin_list->set_column_min_width(1, 100);
+ plugin_list->set_column_min_width(2, 250);
+ plugin_list->set_column_min_width(3, 80);
plugin_list->set_hide_root(true);
- plugin_list->connect("item_edited",this,"_plugin_activity_changed");
-
+ plugin_list->connect("item_edited", this, "_plugin_activity_changed");
- MarginContainer *mc = memnew( MarginContainer );
+ MarginContainer *mc = memnew(MarginContainer);
mc->add_child(plugin_list);
mc->set_v_size_flags(SIZE_EXPAND_FILL);
add_child(mc);
- updating=false;
-
+ updating = false;
}
diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h
index e24880a21d..faad933130 100644
--- a/editor/editor_plugin_settings.h
+++ b/editor/editor_plugin_settings.h
@@ -29,31 +29,27 @@
#ifndef EDITORPLUGINSETTINGS_H
#define EDITORPLUGINSETTINGS_H
-
-#include "scene/gui/dialogs.h"
+#include "editor_data.h"
#include "property_editor.h"
+#include "scene/gui/dialogs.h"
#include "undo_redo.h"
-#include "editor_data.h"
class EditorPluginSettings : public VBoxContainer {
- GDCLASS(EditorPluginSettings,VBoxContainer);
+ GDCLASS(EditorPluginSettings, VBoxContainer);
- Button* update_list;
+ Button *update_list;
Tree *plugin_list;
bool updating;
-
void _plugin_activity_changed();
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-
public:
-
void update_plugins();
EditorPluginSettings();
diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp
index d9a4174246..1199779cb8 100644
--- a/editor/editor_profiler.cpp
+++ b/editor/editor_profiler.cpp
@@ -31,46 +31,43 @@
#include "editor_settings.h"
#include "os/os.h"
-void EditorProfiler::_make_metric_ptrs(Metric& m) {
+void EditorProfiler::_make_metric_ptrs(Metric &m) {
- for(int i=0;i<m.categories.size();i++) {
- m.category_ptrs[m.categories[i].signature]=&m.categories[i];
- for(int j=0;j<m.categories[i].items.size();j++) {
- m.item_ptrs[m.categories[i].items[j].signature]=&m.categories[i].items[j];
+ for (int i = 0; i < m.categories.size(); i++) {
+ m.category_ptrs[m.categories[i].signature] = &m.categories[i];
+ for (int j = 0; j < m.categories[i].items.size(); j++) {
+ m.item_ptrs[m.categories[i].items[j].signature] = &m.categories[i].items[j];
}
}
}
-void EditorProfiler::add_frame_metric(const Metric& p_metric,bool p_final) {
+void EditorProfiler::add_frame_metric(const Metric &p_metric, bool p_final) {
++last_metric;
- if (last_metric>=frame_metrics.size())
- last_metric=0;
+ if (last_metric >= frame_metrics.size())
+ last_metric = 0;
-
- frame_metrics[last_metric]=p_metric;
+ frame_metrics[last_metric] = p_metric;
_make_metric_ptrs(frame_metrics[last_metric]);
- updating_frame=true;
+ updating_frame = true;
cursor_metric_edit->set_max(frame_metrics[last_metric].frame_number);
- cursor_metric_edit->set_min(MAX(frame_metrics[last_metric].frame_number-frame_metrics.size(),0));
-
+ cursor_metric_edit->set_min(MAX(frame_metrics[last_metric].frame_number - frame_metrics.size(), 0));
if (!seeking) {
cursor_metric_edit->set_value(frame_metrics[last_metric].frame_number);
- if (hover_metric!=-1) {
+ if (hover_metric != -1) {
hover_metric++;
- if (hover_metric>=frame_metrics.size()) {
- hover_metric=0;
+ if (hover_metric >= frame_metrics.size()) {
+ hover_metric = 0;
}
}
-
}
- updating_frame=false;
+ updating_frame = false;
if (!frame_delay->is_processing()) {
- frame_delay->set_wait_time(p_final?0.1:1);
+ frame_delay->set_wait_time(p_final ? 0.1 : 1);
frame_delay->start();
}
@@ -78,69 +75,63 @@ void EditorProfiler::add_frame_metric(const Metric& p_metric,bool p_final) {
plot_delay->set_wait_time(0.1);
plot_delay->start();
}
-
}
-
-
void EditorProfiler::clear() {
- int metric_size=EditorSettings::get_singleton()->get("debugger/profiler_frame_history_size");
- metric_size = CLAMP(metric_size,60,1024);
+ int metric_size = EditorSettings::get_singleton()->get("debugger/profiler_frame_history_size");
+ metric_size = CLAMP(metric_size, 60, 1024);
frame_metrics.clear();
frame_metrics.resize(metric_size);
- last_metric=-1;
+ last_metric = -1;
variables->clear();
//activate->set_pressed(false);
plot_sigs.clear();
plot_sigs.insert("fixed_frame_time");
plot_sigs.insert("category_frame_time");
- updating_frame=true;
+ updating_frame = true;
cursor_metric_edit->set_min(0);
cursor_metric_edit->set_max(0);
cursor_metric_edit->set_value(0);
- updating_frame=false;
- hover_metric=-1;
- seeking=false;
+ updating_frame = false;
+ hover_metric = -1;
+ seeking = false;
}
-static String _get_percent_txt(float p_value,float p_total) {
- if (p_total==0)
- p_total=0.00001;
- return String::num((p_value/p_total)*100,1)+"%";
+static String _get_percent_txt(float p_value, float p_total) {
+ if (p_total == 0)
+ p_total = 0.00001;
+ return String::num((p_value / p_total) * 100, 1) + "%";
}
-
-String EditorProfiler::_get_time_as_text(Metric &m,float p_time,int p_calls) {
+String EditorProfiler::_get_time_as_text(Metric &m, float p_time, int p_calls) {
int dmode = display_mode->get_selected();
-
- if (dmode==DISPLAY_FRAME_TIME) {
+ if (dmode == DISPLAY_FRAME_TIME) {
return rtos(p_time);
- } else if (dmode==DISPLAY_AVERAGE_TIME) {
- if (p_calls==0)
+ } else if (dmode == DISPLAY_AVERAGE_TIME) {
+ if (p_calls == 0)
return "0";
else
- return rtos(p_time/p_calls);
- } else if (dmode==DISPLAY_FRAME_PERCENT) {
- return _get_percent_txt(p_time,m.frame_time);
- } else if (dmode==DISPLAY_FIXED_FRAME_PERCENT) {
+ return rtos(p_time / p_calls);
+ } else if (dmode == DISPLAY_FRAME_PERCENT) {
+ return _get_percent_txt(p_time, m.frame_time);
+ } else if (dmode == DISPLAY_FIXED_FRAME_PERCENT) {
- return _get_percent_txt(p_time,m.fixed_frame_time);
+ return _get_percent_txt(p_time, m.fixed_frame_time);
}
return "err";
}
-Color EditorProfiler::_get_color_from_signature(const StringName& p_signature) const {
+Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) const {
- double rot = ABS(double(p_signature.hash())/double(0x7FFFFFFF));
+ double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF));
Color c;
- c.set_hsv(rot,1,1);
+ c.set_hsv(rot, 1, 1);
return c;
-
}
void EditorProfiler::_item_edited() {
@@ -148,12 +139,11 @@ void EditorProfiler::_item_edited() {
if (updating_frame)
return;
- TreeItem *item=variables->get_edited();
+ TreeItem *item = variables->get_edited();
if (!item)
return;
- StringName signature=item->get_metadata(0);
- bool checked=item->is_checked(0);
-
+ StringName signature = item->get_metadata(0);
+ bool checked = item->is_checked(0);
if (checked)
plot_sigs.insert(signature);
@@ -173,424 +163,381 @@ void EditorProfiler::_update_plot() {
int w = graph->get_size().width;
int h = graph->get_size().height;
- bool reset_texture=false;
+ bool reset_texture = false;
int desired_len = w * h * 4;
- if (graph_image.size()!=desired_len) {
- reset_texture=true;
+ if (graph_image.size() != desired_len) {
+ reset_texture = true;
graph_image.resize(desired_len);
}
-
PoolVector<uint8_t>::Write wr = graph_image.write();
-
-
//clear
- for(int i=0;i<desired_len;i+=4) {
- wr[i+0]=0;
- wr[i+1]=0;
- wr[i+2]=0;
- wr[i+3]=255;
+ for (int i = 0; i < desired_len; i += 4) {
+ wr[i + 0] = 0;
+ wr[i + 1] = 0;
+ wr[i + 2] = 0;
+ wr[i + 3] = 255;
}
-
//find highest value
- bool use_self = display_time->get_selected()==DISPLAY_SELF_TIME;
- float highest=0;
+ bool use_self = display_time->get_selected() == DISPLAY_SELF_TIME;
+ float highest = 0;
- for(int i=0;i<frame_metrics.size();i++) {
+ for (int i = 0; i < frame_metrics.size(); i++) {
Metric &m = frame_metrics[i];
if (!m.valid)
continue;
- for (Set<StringName>::Element *E=plot_sigs.front();E;E=E->next()) {
+ for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) {
- Map<StringName,Metric::Category*>::Element *F=m.category_ptrs.find(E->get());
+ Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get());
if (F) {
- highest=MAX(F->get()->total_time,highest);
+ highest = MAX(F->get()->total_time, highest);
}
- Map<StringName,Metric::Category::Item*>::Element *G=m.item_ptrs.find(E->get());
+ Map<StringName, Metric::Category::Item *>::Element *G = m.item_ptrs.find(E->get());
if (G) {
if (use_self) {
- highest=MAX(G->get()->self,highest);
+ highest = MAX(G->get()->self, highest);
} else {
- highest=MAX(G->get()->total,highest);
+ highest = MAX(G->get()->total, highest);
}
}
}
}
- if (highest>0) {
+ if (highest > 0) {
//means some data exists..
- highest*=1.2; //leave some upper room
- graph_height=highest;
+ highest *= 1.2; //leave some upper room
+ graph_height = highest;
Vector<int> columnv;
- columnv.resize(h*4);
+ columnv.resize(h * 4);
int *column = columnv.ptr();
- Map<StringName,int> plot_prev;
+ Map<StringName, int> plot_prev;
//Map<StringName,int> plot_max;
uint64_t time = OS::get_singleton()->get_ticks_usec();
- for(int i=0;i<w;i++) {
+ for (int i = 0; i < w; i++) {
-
- for(int j=0;j<h*4;j++) {
- column[j]=0;
+ for (int j = 0; j < h * 4; j++) {
+ column[j] = 0;
}
- int current = i*frame_metrics.size()/w;
- int next = (i+1)*frame_metrics.size()/w;
- if (next>frame_metrics.size()) {
- next=frame_metrics.size();
+ int current = i * frame_metrics.size() / w;
+ int next = (i + 1) * frame_metrics.size() / w;
+ if (next > frame_metrics.size()) {
+ next = frame_metrics.size();
}
- if (next==current)
- next=current+1; //just because for loop must work
+ if (next == current)
+ next = current + 1; //just because for loop must work
- for (Set<StringName>::Element *E=plot_sigs.front();E;E=E->next()) {
+ for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) {
- int plot_pos=-1;
+ int plot_pos = -1;
- for(int j=current;j<next;j++) {
+ for (int j = current; j < next; j++) {
//wrap
- int idx = last_metric+1+j;
- while( idx >= frame_metrics.size() ) {
- idx-=frame_metrics.size();
+ int idx = last_metric + 1 + j;
+ while (idx >= frame_metrics.size()) {
+ idx -= frame_metrics.size();
}
//get
Metric &m = frame_metrics[idx];
- if (m.valid==false)
+ if (m.valid == false)
continue; //skip because invalid
+ float value = 0;
- float value=0;
-
- Map<StringName,Metric::Category*>::Element *F=m.category_ptrs.find(E->get());
+ Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get());
if (F) {
- value=F->get()->total_time;
+ value = F->get()->total_time;
}
- Map<StringName,Metric::Category::Item*>::Element *G=m.item_ptrs.find(E->get());
+ Map<StringName, Metric::Category::Item *>::Element *G = m.item_ptrs.find(E->get());
if (G) {
if (use_self) {
- value=G->get()->self;
+ value = G->get()->self;
} else {
- value=G->get()->total;
+ value = G->get()->total;
}
}
-
- plot_pos = MAX( CLAMP(int(value*h/highest),0,h-1), plot_pos );
-
-
+ plot_pos = MAX(CLAMP(int(value * h / highest), 0, h - 1), plot_pos);
}
- int prev_plot=plot_pos;
- Map<StringName,int>::Element *H=plot_prev.find(E->get());
+ int prev_plot = plot_pos;
+ Map<StringName, int>::Element *H = plot_prev.find(E->get());
if (H) {
- prev_plot=H->get();
- H->get()=plot_pos;
+ prev_plot = H->get();
+ H->get() = plot_pos;
} else {
- plot_prev[E->get()]=plot_pos;
+ plot_prev[E->get()] = plot_pos;
}
- if (plot_pos==-1 && prev_plot==-1) {
+ if (plot_pos == -1 && prev_plot == -1) {
//don't bother drawing
continue;
}
- if (prev_plot!=-1 && plot_pos==-1) {
+ if (prev_plot != -1 && plot_pos == -1) {
- plot_pos=prev_plot;
+ plot_pos = prev_plot;
}
- if (prev_plot==-1 && plot_pos!=-1) {
- prev_plot=plot_pos;
+ if (prev_plot == -1 && plot_pos != -1) {
+ prev_plot = plot_pos;
}
- plot_pos = h- plot_pos -1;
- prev_plot = h- prev_plot -1;
+ plot_pos = h - plot_pos - 1;
+ prev_plot = h - prev_plot - 1;
if (prev_plot > plot_pos) {
- SWAP(prev_plot,plot_pos);
+ SWAP(prev_plot, plot_pos);
}
Color col = _get_color_from_signature(E->get());
- for(int j=prev_plot;j<=plot_pos;j++) {
-
- column[j*4+0]+=Math::fast_ftoi(CLAMP(col.r*255,0,255));
- column[j*4+1]+=Math::fast_ftoi(CLAMP(col.g*255,0,255));
- column[j*4+2]+=Math::fast_ftoi(CLAMP(col.b*255,0,255));
- column[j*4+3]+=1;
+ for (int j = prev_plot; j <= plot_pos; j++) {
+ column[j * 4 + 0] += Math::fast_ftoi(CLAMP(col.r * 255, 0, 255));
+ column[j * 4 + 1] += Math::fast_ftoi(CLAMP(col.g * 255, 0, 255));
+ column[j * 4 + 2] += Math::fast_ftoi(CLAMP(col.b * 255, 0, 255));
+ column[j * 4 + 3] += 1;
}
}
+ for (int j = 0; j < h * 4; j += 4) {
- for(int j=0;j<h*4;j+=4) {
-
- int a = column[j+3];
- if (a>0) {
- column[j+0]/=a;
- column[j+1]/=a;
- column[j+2]/=a;
-
+ int a = column[j + 3];
+ if (a > 0) {
+ column[j + 0] /= a;
+ column[j + 1] /= a;
+ column[j + 2] /= a;
}
- uint8_t r = uint8_t(column[j+0]);
- uint8_t g = uint8_t(column[j+1]);
- uint8_t b = uint8_t(column[j+2]);
+ uint8_t r = uint8_t(column[j + 0]);
+ uint8_t g = uint8_t(column[j + 1]);
+ uint8_t b = uint8_t(column[j + 2]);
- int widx = ((j>>2)*w+i)*4;
- wr[widx+0]=r;
- wr[widx+1]=g;
- wr[widx+2]=b;
- wr[widx+3]=255;
+ int widx = ((j >> 2) * w + i) * 4;
+ wr[widx + 0] = r;
+ wr[widx + 1] = g;
+ wr[widx + 2] = b;
+ wr[widx + 3] = 255;
}
}
time = OS::get_singleton()->get_ticks_usec() - time;
//print_line("Taken: "+rtos(USEC_TO_SEC(time)));
-
}
-
wr = PoolVector<uint8_t>::Write();
- Image img(w,h,0,Image::FORMAT_RGBA8,graph_image);
+ Image img(w, h, 0, Image::FORMAT_RGBA8, graph_image);
if (reset_texture) {
if (graph_texture.is_null()) {
graph_texture.instance();
}
- graph_texture->create(img.get_width(),img.get_height(),img.get_format(),Texture::FLAG_VIDEO_SURFACE);
-
+ graph_texture->create(img.get_width(), img.get_height(), img.get_format(), Texture::FLAG_VIDEO_SURFACE);
}
graph_texture->set_data(img);
-
graph->set_texture(graph_texture);
graph->update();
-
}
void EditorProfiler::_update_frame() {
int cursor_metric = _get_cursor_index();
+ ERR_FAIL_INDEX(cursor_metric, frame_metrics.size());
- ERR_FAIL_INDEX(cursor_metric,frame_metrics.size());
-
- updating_frame=true;
+ updating_frame = true;
variables->clear();
- TreeItem* root = variables->create_item();
+ TreeItem *root = variables->create_item();
Metric &m = frame_metrics[cursor_metric];
-
int dtime = display_time->get_selected();
-
- for(int i=0;i<m.categories.size();i++) {
+ for (int i = 0; i < m.categories.size(); i++) {
TreeItem *category = variables->create_item(root);
- category->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- category->set_editable(0,true);
- category->set_metadata(0,m.categories[i].signature);
- category->set_text(0,String(m.categories[i].name));
- category->set_text(1,_get_time_as_text(m,m.categories[i].total_time,1));
+ category->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ category->set_editable(0, true);
+ category->set_metadata(0, m.categories[i].signature);
+ category->set_text(0, String(m.categories[i].name));
+ category->set_text(1, _get_time_as_text(m, m.categories[i].total_time, 1));
if (plot_sigs.has(m.categories[i].signature)) {
- category->set_checked(0,true);
- category->set_custom_bg_color(0,Color(0,0,0));
- category->set_custom_color(0,_get_color_from_signature(m.categories[i].signature));
+ category->set_checked(0, true);
+ category->set_custom_bg_color(0, Color(0, 0, 0));
+ category->set_custom_color(0, _get_color_from_signature(m.categories[i].signature));
}
-
- for(int j=0;j<m.categories[i].items.size();j++) {
+ for (int j = 0; j < m.categories[i].items.size(); j++) {
Metric::Category::Item &it = m.categories[i].items[j];
TreeItem *item = variables->create_item(category);
- item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- item->set_editable(0,true);
- item->set_text(0,it.name);
- item->set_metadata(0,it.signature);
- item->set_metadata(1,it.script);
- item->set_metadata(2,it.line);
- item->set_tooltip(0,it.script+":"+itos(it.line));
+ item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ item->set_editable(0, true);
+ item->set_text(0, it.name);
+ item->set_metadata(0, it.signature);
+ item->set_metadata(1, it.script);
+ item->set_metadata(2, it.line);
+ item->set_tooltip(0, it.script + ":" + itos(it.line));
float time = dtime == DISPLAY_SELF_TIME ? it.self : it.total;
- item->set_text(1,_get_time_as_text(m,time,it.calls));
+ item->set_text(1, _get_time_as_text(m, time, it.calls));
- item->set_text(2,itos(it.calls));
+ item->set_text(2, itos(it.calls));
if (plot_sigs.has(it.signature)) {
- item->set_checked(0,true);
- item->set_custom_bg_color(0,Color(0,0,0));
- item->set_custom_color(0,_get_color_from_signature(it.signature));
+ item->set_checked(0, true);
+ item->set_custom_bg_color(0, Color(0, 0, 0));
+ item->set_custom_color(0, _get_color_from_signature(it.signature));
}
-
}
}
- updating_frame=false;
-
+ updating_frame = false;
}
-
void EditorProfiler::_activate_pressed() {
if (activate->is_pressed()) {
clear();
- activate->set_icon(get_icon("Stop","EditorIcons"));
+ activate->set_icon(get_icon("Stop", "EditorIcons"));
activate->set_text(TTR("Stop Profiling"));
} else {
- activate->set_icon(get_icon("Play","EditorIcons"));
+ activate->set_icon(get_icon("Play", "EditorIcons"));
activate->set_text(TTR("Start Profiling"));
-
-
}
- emit_signal("enable_profiling",activate->is_pressed());
-
+ emit_signal("enable_profiling", activate->is_pressed());
}
-
void EditorProfiler::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
- activate->set_icon(get_icon("Play","EditorIcons"));
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ activate->set_icon(get_icon("Play", "EditorIcons"));
}
}
void EditorProfiler::_graph_tex_draw() {
- if (last_metric<0)
+ if (last_metric < 0)
return;
if (seeking) {
int max_frames = frame_metrics.size();
- int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number-max_frames+1);
- if (frame<0)
- frame=0;
+ int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1);
+ if (frame < 0)
+ frame = 0;
int cur_x = frame * graph->get_size().x / max_frames;
-
- graph->draw_line(Vector2(cur_x,0),Vector2(cur_x,graph->get_size().y),Color(1,1,1,0.8));
+ graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.8));
}
-
- if (hover_metric!=-1 && frame_metrics[hover_metric].valid) {
-
-
+ if (hover_metric != -1 && frame_metrics[hover_metric].valid) {
int max_frames = frame_metrics.size();
- int frame = frame_metrics[hover_metric].frame_number - (frame_metrics[last_metric].frame_number-max_frames+1);
- if (frame<0)
- frame=0;
+ int frame = frame_metrics[hover_metric].frame_number - (frame_metrics[last_metric].frame_number - max_frames + 1);
+ if (frame < 0)
+ frame = 0;
int cur_x = frame * graph->get_size().x / max_frames;
- graph->draw_line(Vector2(cur_x,0),Vector2(cur_x,graph->get_size().y),Color(1,1,1,0.4));
-
-
+ graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.4));
}
-
}
void EditorProfiler::_graph_tex_mouse_exit() {
- hover_metric=-1;
+ hover_metric = -1;
graph->update();
}
-
void EditorProfiler::_cursor_metric_changed(double) {
if (updating_frame)
return;
-
graph->update();
_update_frame();
-
}
-void EditorProfiler::_graph_tex_input(const InputEvent& p_ev){
+void EditorProfiler::_graph_tex_input(const InputEvent &p_ev) {
- if (last_metric<0)
+ if (last_metric < 0)
return;
if (
- (p_ev.type==InputEvent::MOUSE_BUTTON && p_ev.mouse_button.button_index==BUTTON_LEFT && p_ev.mouse_button.pressed) ||
- (p_ev.type==InputEvent::MOUSE_MOTION) ) {
+ (p_ev.type == InputEvent::MOUSE_BUTTON && p_ev.mouse_button.button_index == BUTTON_LEFT && p_ev.mouse_button.pressed) ||
+ (p_ev.type == InputEvent::MOUSE_MOTION)) {
int x = p_ev.mouse_button.x;
- x=x*frame_metrics.size()/graph->get_size().width;
+ x = x * frame_metrics.size() / graph->get_size().width;
- bool show_hover = x>=0 && x<frame_metrics.size();
+ bool show_hover = x >= 0 && x < frame_metrics.size();
- if (x<0) {
- x=0;
+ if (x < 0) {
+ x = 0;
}
- if (x>=frame_metrics.size()) {
- x=frame_metrics.size()-1;
+ if (x >= frame_metrics.size()) {
+ x = frame_metrics.size() - 1;
}
-
-
- int metric=frame_metrics.size()-x-1;
- metric = last_metric-metric;
- while(metric<0) {
- metric+=frame_metrics.size();
+ int metric = frame_metrics.size() - x - 1;
+ metric = last_metric - metric;
+ while (metric < 0) {
+ metric += frame_metrics.size();
}
-
-
if (show_hover) {
- hover_metric=metric;
+ hover_metric = metric;
} else {
- hover_metric=-1;
+ hover_metric = -1;
}
-
- if (p_ev.type==InputEvent::MOUSE_BUTTON || p_ev.mouse_motion.button_mask&BUTTON_MASK_LEFT) {
+ if (p_ev.type == InputEvent::MOUSE_BUTTON || p_ev.mouse_motion.button_mask & BUTTON_MASK_LEFT) {
//cursor_metric=x;
- updating_frame=true;
+ updating_frame = true;
//metric may be invalid, so look for closest metric that is valid, this makes snap feel better
- bool valid=false;
- for(int i=0;i<frame_metrics.size();i++) {
+ bool valid = false;
+ for (int i = 0; i < frame_metrics.size(); i++) {
if (frame_metrics[metric].valid) {
- valid=true;
+ valid = true;
break;
}
metric++;
- if (metric>=frame_metrics.size())
- metric=0;
+ if (metric >= frame_metrics.size())
+ metric = 0;
}
if (valid)
cursor_metric_edit->set_value(frame_metrics[metric].frame_number);
- updating_frame=false;
+ updating_frame = false;
if (activate->is_pressed()) {
if (!seeking) {
@@ -598,7 +545,7 @@ void EditorProfiler::_graph_tex_input(const InputEvent& p_ev){
}
}
- seeking=true;
+ seeking = true;
if (!frame_delay->is_processing()) {
frame_delay->set_wait_time(0.1);
@@ -607,35 +554,30 @@ void EditorProfiler::_graph_tex_input(const InputEvent& p_ev){
}
graph->update();
-
}
-
}
int EditorProfiler::_get_cursor_index() const {
- if (last_metric<0)
+ if (last_metric < 0)
return 0;
if (!frame_metrics[last_metric].valid)
return 0;
- int diff = (frame_metrics[last_metric].frame_number-cursor_metric_edit->get_value());
+ int diff = (frame_metrics[last_metric].frame_number - cursor_metric_edit->get_value());
int idx = last_metric - diff;
- while (idx<0) {
- idx+=frame_metrics.size();
+ while (idx < 0) {
+ idx += frame_metrics.size();
}
-
return idx;
-
}
void EditorProfiler::disable_seeking() {
- seeking=false;
+ seeking = false;
graph->update();
-
}
void EditorProfiler::_combo_changed(int) {
@@ -646,19 +588,18 @@ void EditorProfiler::_combo_changed(int) {
void EditorProfiler::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_update_frame"),&EditorProfiler::_update_frame);
- ClassDB::bind_method(D_METHOD("_update_plot"),&EditorProfiler::_update_plot);
- ClassDB::bind_method(D_METHOD("_activate_pressed"),&EditorProfiler::_activate_pressed);
- ClassDB::bind_method(D_METHOD("_graph_tex_draw"),&EditorProfiler::_graph_tex_draw);
- ClassDB::bind_method(D_METHOD("_graph_tex_input"),&EditorProfiler::_graph_tex_input);
- ClassDB::bind_method(D_METHOD("_graph_tex_mouse_exit"),&EditorProfiler::_graph_tex_mouse_exit);
- ClassDB::bind_method(D_METHOD("_cursor_metric_changed"),&EditorProfiler::_cursor_metric_changed);
- ClassDB::bind_method(D_METHOD("_combo_changed"),&EditorProfiler::_combo_changed);
-
- ClassDB::bind_method(D_METHOD("_item_edited"),&EditorProfiler::_item_edited);
- ADD_SIGNAL( MethodInfo("enable_profiling",PropertyInfo(Variant::BOOL,"enable")));
- ADD_SIGNAL( MethodInfo("break_request"));
-
+ ClassDB::bind_method(D_METHOD("_update_frame"), &EditorProfiler::_update_frame);
+ ClassDB::bind_method(D_METHOD("_update_plot"), &EditorProfiler::_update_plot);
+ ClassDB::bind_method(D_METHOD("_activate_pressed"), &EditorProfiler::_activate_pressed);
+ ClassDB::bind_method(D_METHOD("_graph_tex_draw"), &EditorProfiler::_graph_tex_draw);
+ ClassDB::bind_method(D_METHOD("_graph_tex_input"), &EditorProfiler::_graph_tex_input);
+ ClassDB::bind_method(D_METHOD("_graph_tex_mouse_exit"), &EditorProfiler::_graph_tex_mouse_exit);
+ ClassDB::bind_method(D_METHOD("_cursor_metric_changed"), &EditorProfiler::_cursor_metric_changed);
+ ClassDB::bind_method(D_METHOD("_combo_changed"), &EditorProfiler::_combo_changed);
+
+ ClassDB::bind_method(D_METHOD("_item_edited"), &EditorProfiler::_item_edited);
+ ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable")));
+ ADD_SIGNAL(MethodInfo("break_request"));
}
void EditorProfiler::set_enabled(bool p_enable) {
@@ -670,115 +611,109 @@ bool EditorProfiler::is_profiling() {
return activate->is_pressed();
}
-EditorProfiler::EditorProfiler()
-{
+EditorProfiler::EditorProfiler() {
- HBoxContainer *hb = memnew( HBoxContainer );
+ HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
- activate = memnew( Button );
+ activate = memnew(Button);
activate->set_toggle_mode(true);
activate->set_text(TTR("Start Profiling"));
- activate->connect("pressed",this,"_activate_pressed");
+ activate->connect("pressed", this, "_activate_pressed");
hb->add_child(activate);
- hb->add_child( memnew( Label(TTR("Measure:") ) ) );
+ hb->add_child(memnew(Label(TTR("Measure:"))));
- display_mode = memnew( OptionButton );
+ display_mode = memnew(OptionButton);
display_mode->add_item(TTR("Frame Time (sec)"));
display_mode->add_item(TTR("Average Time (sec)"));
display_mode->add_item(TTR("Frame %"));
display_mode->add_item(TTR("Fixed Frame %"));
- display_mode->connect("item_selected",this,"_combo_changed");
+ display_mode->connect("item_selected", this, "_combo_changed");
- hb->add_child( display_mode );
+ hb->add_child(display_mode);
- hb->add_child( memnew( Label(TTR("Time:") ) ) );
+ hb->add_child(memnew(Label(TTR("Time:"))));
- display_time = memnew( OptionButton );
+ display_time = memnew(OptionButton);
display_time->add_item(TTR("Inclusive"));
display_time->add_item(TTR("Self"));
- display_time->connect("item_selected",this,"_combo_changed");
+ display_time->connect("item_selected", this, "_combo_changed");
hb->add_child(display_time);
hb->add_spacer();
- hb->add_child( memnew( Label(TTR("Frame #:") ) ) );
+ hb->add_child(memnew(Label(TTR("Frame #:"))));
- cursor_metric_edit = memnew( SpinBox );
+ cursor_metric_edit = memnew(SpinBox);
cursor_metric_edit->set_h_size_flags(SIZE_FILL);
hb->add_child(cursor_metric_edit);
- cursor_metric_edit->connect("value_changed",this,"_cursor_metric_changed");
+ cursor_metric_edit->connect("value_changed", this, "_cursor_metric_changed");
- hb->add_constant_override("separation",8);
+ hb->add_constant_override("separation", 8);
-
-
- h_split = memnew( HSplitContainer );
+ h_split = memnew(HSplitContainer);
add_child(h_split);
h_split->set_v_size_flags(SIZE_EXPAND_FILL);
- variables = memnew( Tree );
- variables->set_custom_minimum_size(Size2(300,0));
+ variables = memnew(Tree);
+ variables->set_custom_minimum_size(Size2(300, 0));
variables->set_hide_folding(true);
h_split->add_child(variables);
variables->set_hide_root(true);
variables->set_columns(3);
variables->set_column_titles_visible(true);
- variables->set_column_title(0,"Name");
- variables->set_column_expand(0,true);
- variables->set_column_min_width(0,60);
- variables->set_column_title(1,"Time");
- variables->set_column_expand(1,false);
- variables->set_column_min_width(1,60);
- variables->set_column_title(2,"Calls");
- variables->set_column_expand(2,false);
- variables->set_column_min_width(2,60);
- variables->connect("item_edited",this,"_item_edited");
-
-
- graph = memnew( TextureRect );
+ variables->set_column_title(0, "Name");
+ variables->set_column_expand(0, true);
+ variables->set_column_min_width(0, 60);
+ variables->set_column_title(1, "Time");
+ variables->set_column_expand(1, false);
+ variables->set_column_min_width(1, 60);
+ variables->set_column_title(2, "Calls");
+ variables->set_column_expand(2, false);
+ variables->set_column_min_width(2, 60);
+ variables->connect("item_edited", this, "_item_edited");
+
+ graph = memnew(TextureRect);
graph->set_expand(true);
graph->set_mouse_filter(MOUSE_FILTER_STOP);
//graph->set_ignore_mouse(false);
- graph->connect("draw",this,"_graph_tex_draw");
- graph->connect("gui_input",this,"_graph_tex_input");
- graph->connect("mouse_exited",this,"_graph_tex_mouse_exit");
+ graph->connect("draw", this, "_graph_tex_draw");
+ graph->connect("gui_input", this, "_graph_tex_input");
+ graph->connect("mouse_exited", this, "_graph_tex_mouse_exit");
h_split->add_child(graph);
graph->set_h_size_flags(SIZE_EXPAND_FILL);
- add_constant_override("separation",3);
+ add_constant_override("separation", 3);
- int metric_size=CLAMP(int(EDITOR_DEF("debugger/profiler_frame_history_size",600)),60,1024);
+ int metric_size = CLAMP(int(EDITOR_DEF("debugger/profiler_frame_history_size", 600)), 60, 1024);
frame_metrics.resize(metric_size);
- last_metric=-1;
+ last_metric = -1;
//cursor_metric=-1;
- hover_metric=-1;
+ hover_metric = -1;
-
- EDITOR_DEF("debugger/profiler_frame_max_functions",64);
+ EDITOR_DEF("debugger/profiler_frame_max_functions", 64);
//display_mode=DISPLAY_FRAME_TIME;
- frame_delay = memnew( Timer );
+ frame_delay = memnew(Timer);
frame_delay->set_wait_time(0.1);
frame_delay->set_one_shot(true);
add_child(frame_delay);
- frame_delay->connect("timeout",this,"_update_frame");
+ frame_delay->connect("timeout", this, "_update_frame");
- plot_delay = memnew( Timer );
+ plot_delay = memnew(Timer);
plot_delay->set_wait_time(0.1);
plot_delay->set_one_shot(true);
add_child(plot_delay);
- plot_delay->connect("timeout",this,"_update_plot");
+ plot_delay->connect("timeout", this, "_update_plot");
plot_sigs.insert("fixed_frame_time");
plot_sigs.insert("category_frame_time");
- seeking=false;
- graph_height=1;
+ seeking = false;
+ graph_height = 1;
//activate->set_disabled(true);
-
}
diff --git a/editor/editor_profiler.h b/editor/editor_profiler.h
index bf89e3939c..c084859942 100644
--- a/editor/editor_profiler.h
+++ b/editor/editor_profiler.h
@@ -29,23 +29,20 @@
#ifndef EDITORPROFILER_H
#define EDITORPROFILER_H
-
#include "scene/gui/box_container.h"
-#include "scene/gui/texture_rect.h"
#include "scene/gui/button.h"
#include "scene/gui/label.h"
-#include "scene/gui/tree.h"
-#include "scene/gui/split_container.h"
#include "scene/gui/option_button.h"
#include "scene/gui/spin_box.h"
-
+#include "scene/gui/split_container.h"
+#include "scene/gui/texture_rect.h"
+#include "scene/gui/tree.h"
class EditorProfiler : public VBoxContainer {
- GDCLASS(EditorProfiler,VBoxContainer)
+ GDCLASS(EditorProfiler, VBoxContainer)
public:
-
struct Metric {
bool valid;
@@ -78,11 +75,13 @@ public:
Vector<Category> categories;
- Map<StringName,Category*> category_ptrs;
- Map<StringName,Category::Item*> item_ptrs;
-
+ Map<StringName, Category *> category_ptrs;
+ Map<StringName, Category::Item *> item_ptrs;
- Metric() { valid=false; frame_number=0; }
+ Metric() {
+ valid = false;
+ frame_number = 0;
+ }
};
enum DisplayMode {
@@ -110,7 +109,7 @@ private:
OptionButton *display_mode;
OptionButton *display_time;
- SpinBox * cursor_metric_edit;
+ SpinBox *cursor_metric_edit;
Vector<Metric> frame_metrics;
int last_metric;
@@ -133,9 +132,9 @@ private:
void _activate_pressed();
- String _get_time_as_text(Metric &m,float p_time,int p_calls);
+ String _get_time_as_text(Metric &m, float p_time, int p_calls);
- void _make_metric_ptrs(Metric& m);
+ void _make_metric_ptrs(Metric &m);
void _item_edited();
void _update_plot();
@@ -143,23 +142,22 @@ private:
void _graph_tex_mouse_exit();
void _graph_tex_draw();
- void _graph_tex_input(const InputEvent& p_ev);
+ void _graph_tex_input(const InputEvent &p_ev);
int _get_cursor_index() const;
- Color _get_color_from_signature(const StringName& p_signature) const;
+ Color _get_color_from_signature(const StringName &p_signature) const;
void _cursor_metric_changed(double);
void _combo_changed(int);
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
- void add_frame_metric(const Metric& p_metric, bool p_final=false);
+public:
+ void add_frame_metric(const Metric &p_metric, bool p_final = false);
void set_enabled(bool p_enable);
bool is_profiling();
bool is_seeking() { return seeking; }
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index ab2226e79a..9eb6758cc2 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -28,37 +28,35 @@
/*************************************************************************/
#include "editor_resource_preview.h"
+#include "editor_scale.h"
#include "editor_settings.h"
-#include "os/file_access.h"
+#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
-#include "global_config.h"
-#include "editor_scale.h"
#include "message_queue.h"
+#include "os/file_access.h"
-bool EditorResourcePreviewGenerator::handles(const String& p_type) const {
+bool EditorResourcePreviewGenerator::handles(const String &p_type) const {
if (get_script_instance() && get_script_instance()->has_method("handles")) {
- return get_script_instance()->call("handles",p_type);
+ return get_script_instance()->call("handles", p_type);
}
ERR_EXPLAIN("EditorResourcePreviewGenerator::handles needs to be overriden");
ERR_FAIL_V(false);
}
-Ref<Texture> EditorResourcePreviewGenerator::generate(const RES& p_from){
+Ref<Texture> EditorResourcePreviewGenerator::generate(const RES &p_from) {
if (get_script_instance() && get_script_instance()->has_method("generate")) {
- return get_script_instance()->call("generate",p_from);
+ return get_script_instance()->call("generate", p_from);
}
ERR_EXPLAIN("EditorResourcePreviewGenerator::generate needs to be overriden");
ERR_FAIL_V(Ref<Texture>());
-
}
-
-Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String& p_path) {
+Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String &p_path) {
if (get_script_instance() && get_script_instance()->has_method("generate_from_path")) {
- return get_script_instance()->call("generate_from_path",p_path);
+ return get_script_instance()->call("generate_from_path", p_path);
}
RES res = ResourceLoader::load(p_path);
@@ -67,78 +65,69 @@ Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String& p_
return generate(res);
}
-
void EditorResourcePreviewGenerator::_bind_methods() {
- ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"handles",PropertyInfo(Variant::STRING,"type")));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::OBJECT,"generate:Texture",PropertyInfo(Variant::OBJECT,"from",PROPERTY_HINT_RESOURCE_TYPE,"Resource")));
- ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::OBJECT,"generate_from_path:Texture",PropertyInfo(Variant::STRING,"path",PROPERTY_HINT_FILE)));
-
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles", PropertyInfo(Variant::STRING, "type")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::OBJECT, "generate:Texture", PropertyInfo(Variant::OBJECT, "from", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::OBJECT, "generate_from_path:Texture", PropertyInfo(Variant::STRING, "path", PROPERTY_HINT_FILE)));
}
EditorResourcePreviewGenerator::EditorResourcePreviewGenerator() {
-
-
}
-
-EditorResourcePreview* EditorResourcePreview::singleton=NULL;
-
+EditorResourcePreview *EditorResourcePreview::singleton = NULL;
void EditorResourcePreview::_thread_func(void *ud) {
- EditorResourcePreview *erp=(EditorResourcePreview*)ud;
+ EditorResourcePreview *erp = (EditorResourcePreview *)ud;
erp->_thread();
-
}
-
-void EditorResourcePreview::_preview_ready(const String& p_str,const Ref<Texture>& p_texture,ObjectID id,const StringName& p_func,const Variant& p_ud) {
+void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture> &p_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) {
//print_line("preview is ready");
preview_mutex->lock();
String path = p_str;
- uint32_t hash=0;
- uint64_t modified_time=0;
+ uint32_t hash = 0;
+ uint64_t modified_time = 0;
if (p_str.begins_with("ID:")) {
- hash=p_str.get_slicec(':',2).to_int();
- path="ID:"+p_str.get_slicec(':',1);
+ hash = p_str.get_slicec(':', 2).to_int();
+ path = "ID:" + p_str.get_slicec(':', 1);
} else {
modified_time = FileAccess::get_modified_time(path);
}
Item item;
- item.order=order++;
- item.preview=p_texture;
- item.last_hash=hash;
- item.modified_time=modified_time;
+ item.order = order++;
+ item.preview = p_texture;
+ item.last_hash = hash;
+ item.modified_time = modified_time;
- cache[path]=item;
+ cache[path] = item;
preview_mutex->unlock();
- MessageQueue::get_singleton()->push_call(id,p_func,path,p_texture,p_ud);
-
+ MessageQueue::get_singleton()->push_call(id, p_func, path, p_texture, p_ud);
}
-Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem& p_item,const String& cache_base) {
+Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem &p_item, const String &cache_base) {
String type;
if (p_item.resource.is_valid())
- type=p_item.resource->get_class();
+ type = p_item.resource->get_class();
else
- type=ResourceLoader::get_resource_type(p_item.path);
+ type = ResourceLoader::get_resource_type(p_item.path);
//print_line("resource type is: "+type);
- if (type=="")
+ if (type == "")
return Ref<Texture>(); //could not guess type
Ref<Texture> generated;
- for(int i=0;i<preview_generators.size();i++) {
+ for (int i = 0; i < preview_generators.size(); i++) {
if (!preview_generators[i]->handles(type))
continue;
@@ -156,17 +145,16 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem& p_item,co
if (generated.is_valid()) {
//print_line("was generated");
int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
- thumbnail_size*=EDSCALE;
+ thumbnail_size *= EDSCALE;
//wow it generated a preview... save cache
- ResourceSaver::save(cache_base+".png",generated);
- FileAccess *f=FileAccess::open(cache_base+".txt",FileAccess::WRITE);
+ ResourceSaver::save(cache_base + ".png", generated);
+ FileAccess *f = FileAccess::open(cache_base + ".txt", FileAccess::WRITE);
f->store_line(itos(thumbnail_size));
f->store_line(itos(FileAccess::get_modified_time(p_item.path)));
f->store_line(FileAccess::get_md5(p_item.path));
memdelete(f);
} else {
//print_line("was not generated");
-
}
}
@@ -176,7 +164,7 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem& p_item,co
void EditorResourcePreview::_thread() {
//print_line("begin thread");
- while(!exit) {
+ while (!exit) {
//print_line("wait for semaphore");
preview_sem->wait();
@@ -186,56 +174,51 @@ void EditorResourcePreview::_thread() {
if (queue.size()) {
-
-
QueueItem item = queue.front()->get();
queue.pop_front();
if (cache.has(item.path)) {
//already has it because someone loaded it, just let it know it's ready
if (item.resource.is_valid()) {
- item.path+=":"+itos(cache[item.path].last_hash); //keep last hash (see description of what this is in condition below)
+ item.path += ":" + itos(cache[item.path].last_hash); //keep last hash (see description of what this is in condition below)
}
- _preview_ready(item.path,cache[item.path].preview,item.id,item.function,item.userdata);
+ _preview_ready(item.path, cache[item.path].preview, item.id, item.function, item.userdata);
preview_mutex->unlock();
} else {
preview_mutex->unlock();
-
Ref<Texture> texture;
//print_line("pop from queue "+item.path);
int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
- thumbnail_size*=EDSCALE;
+ thumbnail_size *= EDSCALE;
+ if (item.resource.is_valid()) {
- if (item.resource.is_valid()){
-
- texture=_generate_preview(item,String());
+ texture = _generate_preview(item, String());
//adding hash to the end of path (should be ID:<objid>:<hash>) because of 5 argument limit to call_deferred
- _preview_ready(item.path+":"+itos(item.resource->hash_edited_version()),texture,item.id,item.function,item.userdata);
+ _preview_ready(item.path + ":" + itos(item.resource->hash_edited_version()), texture, item.id, item.function, item.userdata);
} else {
-
- String temp_path=EditorSettings::get_singleton()->get_settings_path().plus_file("tmp");
+ String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp");
String cache_base = GlobalConfig::get_singleton()->globalize_path(item.path).md5_text();
- cache_base = temp_path.plus_file("resthumb-"+cache_base);
+ cache_base = temp_path.plus_file("resthumb-" + cache_base);
//does not have it, try to load a cached thumbnail
- String file = cache_base+".txt";
+ String file = cache_base + ".txt";
//print_line("cachetxt at "+file);
- FileAccess *f=FileAccess::open(file,FileAccess::READ);
+ FileAccess *f = FileAccess::open(file, FileAccess::READ);
if (!f) {
//print_line("generate because not cached");
//generate
- texture=_generate_preview(item,cache_base);
+ texture = _generate_preview(item, cache_base);
} else {
uint64_t modtime = FileAccess::get_modified_time(item.path);
@@ -244,22 +227,22 @@ void EditorResourcePreview::_thread() {
bool cache_valid = true;
- if (tsize!=thumbnail_size) {
- cache_valid=false;
+ if (tsize != thumbnail_size) {
+ cache_valid = false;
memdelete(f);
- } else if (last_modtime!=modtime) {
+ } else if (last_modtime != modtime) {
String last_md5 = f->get_line();
String md5 = FileAccess::get_md5(item.path);
memdelete(f);
- if (last_md5!=md5) {
+ if (last_md5 != md5) {
- cache_valid=false;
+ cache_valid = false;
} else {
//update modified time
- f=FileAccess::open(file,FileAccess::WRITE);
+ f = FileAccess::open(file, FileAccess::WRITE);
f->store_line(itos(modtime));
f->store_line(md5);
memdelete(f);
@@ -268,172 +251,154 @@ void EditorResourcePreview::_thread() {
memdelete(f);
}
- cache_valid=false;
+ cache_valid = false;
if (cache_valid) {
- texture = ResourceLoader::load(cache_base+".png","ImageTexture",true);
+ texture = ResourceLoader::load(cache_base + ".png", "ImageTexture", true);
if (!texture.is_valid()) {
//well fuck
- cache_valid=false;
+ cache_valid = false;
}
}
if (!cache_valid) {
- texture=_generate_preview(item,cache_base);
+ texture = _generate_preview(item, cache_base);
}
-
}
//print_line("notify of preview ready");
- _preview_ready(item.path,texture,item.id,item.function,item.userdata);
-
+ _preview_ready(item.path, texture, item.id, item.function, item.userdata);
}
}
-
} else {
preview_mutex->unlock();
}
-
}
}
-
-
-void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource>& p_res, Object* p_receiver, const StringName& p_receiver_func, const Variant& p_userdata) {
+void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p_res, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) {
ERR_FAIL_NULL(p_receiver);
ERR_FAIL_COND(!p_res.is_valid());
preview_mutex->lock();
- String path_id = "ID:"+itos(p_res->get_instance_ID());
-
+ String path_id = "ID:" + itos(p_res->get_instance_ID());
- if (cache.has(path_id) && cache[path_id].last_hash==p_res->hash_edited_version()) {
+ if (cache.has(path_id) && cache[path_id].last_hash == p_res->hash_edited_version()) {
- cache[path_id].order=order++;
- p_receiver->call_deferred(p_receiver_func,path_id,cache[path_id].preview,p_userdata);
+ cache[path_id].order = order++;
+ p_receiver->call_deferred(p_receiver_func, path_id, cache[path_id].preview, p_userdata);
preview_mutex->unlock();
return;
-
}
cache.erase(path_id); //erase if exists, since it will be regen
//print_line("send to thread "+p_path);
QueueItem item;
- item.function=p_receiver_func;
- item.id=p_receiver->get_instance_ID();
- item.resource=p_res;
- item.path=path_id;
- item.userdata=p_userdata;
+ item.function = p_receiver_func;
+ item.id = p_receiver->get_instance_ID();
+ item.resource = p_res;
+ item.path = path_id;
+ item.userdata = p_userdata;
queue.push_back(item);
preview_mutex->unlock();
preview_sem->post();
}
-void EditorResourcePreview::queue_resource_preview(const String& p_path, Object* p_receiver, const StringName& p_receiver_func, const Variant& p_userdata) {
+void EditorResourcePreview::queue_resource_preview(const String &p_path, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) {
ERR_FAIL_NULL(p_receiver);
preview_mutex->lock();
if (cache.has(p_path)) {
- cache[p_path].order=order++;
- p_receiver->call_deferred(p_receiver_func,p_path,cache[p_path].preview,p_userdata);
+ cache[p_path].order = order++;
+ p_receiver->call_deferred(p_receiver_func, p_path, cache[p_path].preview, p_userdata);
preview_mutex->unlock();
return;
}
//print_line("send to thread "+p_path);
QueueItem item;
- item.function=p_receiver_func;
- item.id=p_receiver->get_instance_ID();
- item.path=p_path;
- item.userdata=p_userdata;
+ item.function = p_receiver_func;
+ item.id = p_receiver->get_instance_ID();
+ item.path = p_path;
+ item.userdata = p_userdata;
queue.push_back(item);
preview_mutex->unlock();
preview_sem->post();
-
}
-void EditorResourcePreview::add_preview_generator(const Ref<EditorResourcePreviewGenerator>& p_generator) {
+void EditorResourcePreview::add_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator) {
preview_generators.push_back(p_generator);
}
-void EditorResourcePreview::remove_preview_generator(const Ref<EditorResourcePreviewGenerator>& p_generator) {
+void EditorResourcePreview::remove_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator) {
preview_generators.erase(p_generator);
}
-EditorResourcePreview* EditorResourcePreview::get_singleton() {
+EditorResourcePreview *EditorResourcePreview::get_singleton() {
return singleton;
}
void EditorResourcePreview::_bind_methods() {
- ClassDB::bind_method("_preview_ready",&EditorResourcePreview::_preview_ready);
-
- ClassDB::bind_method(D_METHOD("queue_resource_preview","path","receiver","receiver_func","userdata:Variant"),&EditorResourcePreview::queue_resource_preview);
- ClassDB::bind_method(D_METHOD("queue_edited_resource_preview","resource:Resource","receiver","receiver_func","userdata:Variant"),&EditorResourcePreview::queue_edited_resource_preview);
- ClassDB::bind_method(D_METHOD("add_preview_generator","generator:EditorResourcePreviewGenerator"),&EditorResourcePreview::add_preview_generator);
- ClassDB::bind_method(D_METHOD("remove_preview_generator","generator:EditorResourcePreviewGenerator"),&EditorResourcePreview::remove_preview_generator);
- ClassDB::bind_method(D_METHOD("check_for_invalidation","path"),&EditorResourcePreview::check_for_invalidation);
+ ClassDB::bind_method("_preview_ready", &EditorResourcePreview::_preview_ready);
+ ClassDB::bind_method(D_METHOD("queue_resource_preview", "path", "receiver", "receiver_func", "userdata:Variant"), &EditorResourcePreview::queue_resource_preview);
+ ClassDB::bind_method(D_METHOD("queue_edited_resource_preview", "resource:Resource", "receiver", "receiver_func", "userdata:Variant"), &EditorResourcePreview::queue_edited_resource_preview);
+ ClassDB::bind_method(D_METHOD("add_preview_generator", "generator:EditorResourcePreviewGenerator"), &EditorResourcePreview::add_preview_generator);
+ ClassDB::bind_method(D_METHOD("remove_preview_generator", "generator:EditorResourcePreviewGenerator"), &EditorResourcePreview::remove_preview_generator);
+ ClassDB::bind_method(D_METHOD("check_for_invalidation", "path"), &EditorResourcePreview::check_for_invalidation);
- ADD_SIGNAL(MethodInfo("preview_invalidated",PropertyInfo(Variant::STRING,"path")));
+ ADD_SIGNAL(MethodInfo("preview_invalidated", PropertyInfo(Variant::STRING, "path")));
}
-void EditorResourcePreview::check_for_invalidation(const String& p_path) {
+void EditorResourcePreview::check_for_invalidation(const String &p_path) {
preview_mutex->lock();
- bool call_invalidated=false;
+ bool call_invalidated = false;
if (cache.has(p_path)) {
uint64_t modified_time = FileAccess::get_modified_time(p_path);
- if (modified_time!=cache[p_path].modified_time) {
+ if (modified_time != cache[p_path].modified_time) {
cache.erase(p_path);
- call_invalidated=true;
+ call_invalidated = true;
}
}
preview_mutex->unlock();
- if (call_invalidated) {//do outside mutex
- call_deferred("emit_signal","preview_invalidated",p_path);
+ if (call_invalidated) { //do outside mutex
+ call_deferred("emit_signal", "preview_invalidated", p_path);
}
-
-
-
}
EditorResourcePreview::EditorResourcePreview() {
- singleton=this;
+ singleton = this;
preview_mutex = Mutex::create();
- preview_sem = Semaphore::create();
- order=0;
- exit=false;
+ preview_sem = Semaphore::create();
+ order = 0;
+ exit = false;
- thread = Thread::create(_thread_func,this);
+ thread = Thread::create(_thread_func, this);
}
+EditorResourcePreview::~EditorResourcePreview() {
-EditorResourcePreview::~EditorResourcePreview()
-{
-
- exit=true;
+ exit = true;
preview_sem->post();
Thread::wait_to_finish(thread);
memdelete(thread);
memdelete(preview_mutex);
memdelete(preview_sem);
-
-
}
-
diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h
index e4a593330d..ad7f0946e5 100644
--- a/editor/editor_resource_preview.h
+++ b/editor/editor_resource_preview.h
@@ -29,9 +29,9 @@
#ifndef EDITORRESOURCEPREVIEW_H
#define EDITORRESOURCEPREVIEW_H
-#include "scene/main/node.h"
#include "os/semaphore.h"
#include "os/thread.h"
+#include "scene/main/node.h"
#include "scene/resources/texture.h"
/* make previews for:
@@ -52,30 +52,26 @@
-curve and curve2D
*/
-
class EditorResourcePreviewGenerator : public Reference {
- GDCLASS(EditorResourcePreviewGenerator,Reference );
+ GDCLASS(EditorResourcePreviewGenerator, Reference);
protected:
-
static void _bind_methods();
-public:
- virtual bool handles(const String& p_type) const;
- virtual Ref<Texture> generate(const RES& p_from);
- virtual Ref<Texture> generate_from_path(const String& p_path);
+public:
+ virtual bool handles(const String &p_type) const;
+ virtual Ref<Texture> generate(const RES &p_from);
+ virtual Ref<Texture> generate_from_path(const String &p_path);
EditorResourcePreviewGenerator();
};
-
class EditorResourcePreview : public Node {
- GDCLASS(EditorResourcePreview,Node);
-
+ GDCLASS(EditorResourcePreview, Node);
- static EditorResourcePreview* singleton;
+ static EditorResourcePreview *singleton;
struct QueueItem {
Ref<Resource> resource;
@@ -101,31 +97,29 @@ class EditorResourcePreview : public Node {
int order;
- Map<String,Item> cache;
+ Map<String, Item> cache;
- void _preview_ready(const String& p_str,const Ref<Texture>& p_texture, ObjectID id, const StringName &p_func, const Variant &p_ud);
- Ref<Texture> _generate_preview(const QueueItem& p_item, const String &cache_base);
+ void _preview_ready(const String &p_str, const Ref<Texture> &p_texture, ObjectID id, const StringName &p_func, const Variant &p_ud);
+ Ref<Texture> _generate_preview(const QueueItem &p_item, const String &cache_base);
static void _thread_func(void *ud);
void _thread();
Vector<Ref<EditorResourcePreviewGenerator> > preview_generators;
-
protected:
-
static void _bind_methods();
-public:
- static EditorResourcePreview* get_singleton();
+public:
+ static EditorResourcePreview *get_singleton();
//callback funtion is callback(String p_path,Ref<Texture> preview,Variant udata) preview null if could not load
- void queue_resource_preview(const String& p_res, Object* p_receiver, const StringName& p_receiver_func, const Variant& p_userdata);
- void queue_edited_resource_preview(const Ref<Resource>& p_path, Object* p_receiver, const StringName& p_receiver_func, const Variant& p_userdata);
+ void queue_resource_preview(const String &p_res, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata);
+ void queue_edited_resource_preview(const Ref<Resource> &p_path, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata);
- void add_preview_generator(const Ref<EditorResourcePreviewGenerator>& p_generator);
- void remove_preview_generator(const Ref<EditorResourcePreviewGenerator>& p_generator);
- void check_for_invalidation(const String& p_path);
+ void add_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator);
+ void remove_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator);
+ void check_for_invalidation(const String &p_path);
EditorResourcePreview();
~EditorResourcePreview();
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp
index 46e400ae7f..99d32ea958 100644
--- a/editor/editor_run.cpp
+++ b/editor/editor_run.cpp
@@ -28,29 +28,27 @@
/*************************************************************************/
#include "editor_run.h"
-#include "global_config.h"
#include "editor_settings.h"
+#include "global_config.h"
EditorRun::Status EditorRun::get_status() const {
return status;
}
-Error EditorRun::run(const String& p_scene,const String p_custom_args,const List<String>& p_breakpoints) {
+Error EditorRun::run(const String &p_scene, const String p_custom_args, const List<String> &p_breakpoints) {
List<String> args;
-
String resource_path = GlobalConfig::get_singleton()->get_resource_path();
- if (resource_path!="") {
+ if (resource_path != "") {
args.push_back("-path");
- args.push_back(resource_path.replace(" ","%20"));
-
+ args.push_back(resource_path.replace(" ", "%20"));
}
if (true) {
args.push_back("-rdebug");
- args.push_back("localhost:"+String::num(GLOBAL_GET("network/debug/remote_port")));
+ args.push_back("localhost:" + String::num(GLOBAL_GET("network/debug/remote_port")));
}
args.push_back("-epid");
@@ -66,105 +64,101 @@ Error EditorRun::run(const String& p_scene,const String p_custom_args,const List
int screen = EditorSettings::get_singleton()->get("run/window_placement/screen");
- if (screen==0) {
- screen=OS::get_singleton()->get_current_screen();
+ if (screen == 0) {
+ screen = OS::get_singleton()->get_current_screen();
} else {
screen--;
}
Rect2 screen_rect;
- screen_rect.pos=OS::get_singleton()->get_screen_position(screen);
- screen_rect.size=OS::get_singleton()->get_screen_size(screen);
-
+ screen_rect.pos = OS::get_singleton()->get_screen_position(screen);
+ screen_rect.size = OS::get_singleton()->get_screen_size(screen);
Size2 desired_size;
- desired_size.x=GlobalConfig::get_singleton()->get("display/width");
- desired_size.y=GlobalConfig::get_singleton()->get("display/height");
+ desired_size.x = GlobalConfig::get_singleton()->get("display/width");
+ desired_size.y = GlobalConfig::get_singleton()->get("display/height");
Size2 test_size;
- test_size.x=GlobalConfig::get_singleton()->get("display/test_width");
- test_size.y=GlobalConfig::get_singleton()->get("display/test_height");
- if (test_size.x>0 && test_size.y>0) {
+ test_size.x = GlobalConfig::get_singleton()->get("display/test_width");
+ test_size.y = GlobalConfig::get_singleton()->get("display/test_height");
+ if (test_size.x > 0 && test_size.y > 0) {
- desired_size=test_size;
+ desired_size = test_size;
}
+ int window_placement = EditorSettings::get_singleton()->get("run/window_placement/rect");
- int window_placement=EditorSettings::get_singleton()->get("run/window_placement/rect");
-
- switch(window_placement) {
+ switch (window_placement) {
case 0: { // default
args.push_back("-p");
- args.push_back(itos(screen_rect.pos.x)+"x"+itos(screen_rect.pos.y));
+ args.push_back(itos(screen_rect.pos.x) + "x" + itos(screen_rect.pos.y));
} break;
case 1: { // centered
- Vector2 pos=screen_rect.pos+((screen_rect.size-desired_size)/2).floor();
+ Vector2 pos = screen_rect.pos + ((screen_rect.size - desired_size) / 2).floor();
args.push_back("-p");
- args.push_back(itos(pos.x)+"x"+itos(pos.y));
+ args.push_back(itos(pos.x) + "x" + itos(pos.y));
} break;
case 2: { // custom pos
Vector2 pos = EditorSettings::get_singleton()->get("run/window_placement/rect_custom_position");
- pos+=screen_rect.pos;
+ pos += screen_rect.pos;
args.push_back("-p");
- args.push_back(itos(pos.x)+"x"+itos(pos.y));
+ args.push_back(itos(pos.x) + "x" + itos(pos.y));
} break;
case 3: { // force maximized
- Vector2 pos=screen_rect.pos;
+ Vector2 pos = screen_rect.pos;
args.push_back("-p");
- args.push_back(itos(pos.x)+"x"+itos(pos.y));
+ args.push_back(itos(pos.x) + "x" + itos(pos.y));
args.push_back("-mx");
} break;
case 4: { // force fullscreen
- Vector2 pos=screen_rect.pos;
+ Vector2 pos = screen_rect.pos;
args.push_back("-p");
- args.push_back(itos(pos.x)+"x"+itos(pos.y));
+ args.push_back(itos(pos.x) + "x" + itos(pos.y));
args.push_back("-f");
} break;
}
-
-
if (p_breakpoints.size()) {
args.push_back("-bp");
String bpoints;
- for(const List<String>::Element *E=p_breakpoints.front();E;E=E->next()) {
+ for (const List<String>::Element *E = p_breakpoints.front(); E; E = E->next()) {
- bpoints+=E->get().replace(" ","%20");
+ bpoints += E->get().replace(" ", "%20");
if (E->next())
- bpoints+=",";
+ bpoints += ",";
}
args.push_back(bpoints);
}
-
- if (p_scene!="") {
+
+ if (p_scene != "") {
args.push_back(p_scene);
}
- if (p_custom_args!="") {
- Vector<String> cargs=p_custom_args.split(" ",false);
- for(int i=0;i<cargs.size();i++) {
- args.push_back(cargs[i].replace(" ","%20"));
+ if (p_custom_args != "") {
+ Vector<String> cargs = p_custom_args.split(" ", false);
+ for (int i = 0; i < cargs.size(); i++) {
+ args.push_back(cargs[i].replace(" ", "%20"));
}
}
String exec = OS::get_singleton()->get_executable_path();
printf("running: %ls", exec.c_str());
- for (List<String>::Element* E = args.front(); E ; E = E->next()) {
+ for (List<String>::Element *E = args.front(); E; E = E->next()) {
printf(" %ls", E->get().c_str());
};
printf("\n");
- pid=0;
- Error err = OS::get_singleton()->execute(exec,args,false,&pid);
- ERR_FAIL_COND_V(err,err);
+ pid = 0;
+ Error err = OS::get_singleton()->execute(exec, args, false, &pid);
+ ERR_FAIL_COND_V(err, err);
status = STATUS_PLAY;
@@ -173,39 +167,37 @@ Error EditorRun::run(const String& p_scene,const String p_custom_args,const List
void EditorRun::stop() {
- if (status!=STATUS_STOP && pid!=0) {
+ if (status != STATUS_STOP && pid != 0) {
OS::get_singleton()->kill(pid);
}
- status=STATUS_STOP;
+ status = STATUS_STOP;
}
void EditorRun::set_debug_collisions(bool p_debug) {
- debug_collisions=p_debug;
+ debug_collisions = p_debug;
}
-bool EditorRun::get_debug_collisions() const{
+bool EditorRun::get_debug_collisions() const {
return debug_collisions;
}
void EditorRun::set_debug_navigation(bool p_debug) {
- debug_navigation=p_debug;
+ debug_navigation = p_debug;
}
-bool EditorRun::get_debug_navigation() const{
+bool EditorRun::get_debug_navigation() const {
return debug_navigation;
}
-
EditorRun::EditorRun() {
- status=STATUS_STOP;
- debug_collisions=false;
- debug_navigation=false;
-
+ status = STATUS_STOP;
+ debug_collisions = false;
+ debug_navigation = false;
}
diff --git a/editor/editor_run.h b/editor/editor_run.h
index 46c5dc7521..796ff8fa3e 100644
--- a/editor/editor_run.h
+++ b/editor/editor_run.h
@@ -29,8 +29,8 @@
#ifndef EDITOR_RUN_H
#define EDITOR_RUN_H
-#include "scene/main/node.h"
#include "os/os.h"
+#include "scene/main/node.h"
class EditorRun {
public:
enum Status {
@@ -41,16 +41,16 @@ public:
};
OS::ProcessID pid;
-private:
+private:
bool debug_collisions;
bool debug_navigation;
Status status;
-public:
+public:
Status get_status() const;
- Error run(const String& p_scene,const String p_custom_args,const List<String>& p_breakpoints);
- void run_native_notify() { status=STATUS_PLAY; }
+ Error run(const String &p_scene, const String p_custom_args, const List<String> &p_breakpoints);
+ void run_native_notify() { status = STATUS_PLAY; }
void stop();
OS::ProcessID get_pid() const { return pid; }
diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp
index 60a9f53b94..5e27598307 100644
--- a/editor/editor_run_native.cpp
+++ b/editor/editor_run_native.cpp
@@ -100,7 +100,7 @@ void EditorRunNative::_notification(int p_what) {
#endif
}
-void EditorRunNative::_run_native(int p_idx,const String& p_platform) {
+void EditorRunNative::_run_native(int p_idx, const String &p_platform) {
#if 0
Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(p_platform);
@@ -132,58 +132,56 @@ void EditorRunNative::_run_native(int p_idx,const String& p_platform) {
void EditorRunNative::_bind_methods() {
- ClassDB::bind_method("_run_native",&EditorRunNative::_run_native);
+ ClassDB::bind_method("_run_native", &EditorRunNative::_run_native);
ADD_SIGNAL(MethodInfo("native_run"));
}
void EditorRunNative::set_deploy_dumb(bool p_enabled) {
- deploy_dumb=p_enabled;
+ deploy_dumb = p_enabled;
}
-bool EditorRunNative::is_deploy_dumb_enabled() const{
+bool EditorRunNative::is_deploy_dumb_enabled() const {
return deploy_dumb;
}
void EditorRunNative::set_deploy_debug_remote(bool p_enabled) {
- deploy_debug_remote=p_enabled;
+ deploy_debug_remote = p_enabled;
}
-bool EditorRunNative::is_deploy_debug_remote_enabled() const{
+bool EditorRunNative::is_deploy_debug_remote_enabled() const {
return deploy_debug_remote;
}
void EditorRunNative::set_debug_collisions(bool p_debug) {
- debug_collisions=p_debug;
+ debug_collisions = p_debug;
}
-bool EditorRunNative::get_debug_collisions() const{
+bool EditorRunNative::get_debug_collisions() const {
return debug_collisions;
}
void EditorRunNative::set_debug_navigation(bool p_debug) {
- debug_navigation=p_debug;
+ debug_navigation = p_debug;
}
-bool EditorRunNative::get_debug_navigation() const{
+bool EditorRunNative::get_debug_navigation() const {
return debug_navigation;
}
-EditorRunNative::EditorRunNative()
-{
+EditorRunNative::EditorRunNative() {
set_process(true);
- first=true;
- deploy_dumb=false;
- deploy_debug_remote=false;
- debug_collisions=false;
- debug_navigation=false;
-
+ first = true;
+ deploy_dumb = false;
+ deploy_debug_remote = false;
+ debug_collisions = false;
+ debug_navigation = false;
}
diff --git a/editor/editor_run_native.h b/editor/editor_run_native.h
index c62021148b..92eaa8516b 100644
--- a/editor/editor_run_native.h
+++ b/editor/editor_run_native.h
@@ -34,23 +34,22 @@
class EditorRunNative : public HBoxContainer {
- GDCLASS(EditorRunNative,BoxContainer);
+ GDCLASS(EditorRunNative, BoxContainer);
- Map<StringName,MenuButton*> menus;
+ Map<StringName, MenuButton *> menus;
bool first;
bool deploy_dumb;
bool deploy_debug_remote;
bool debug_collisions;
bool debug_navigation;
- void _run_native(int p_idx,const String& p_platform);
+ void _run_native(int p_idx, const String &p_platform);
protected:
-
static void _bind_methods();
void _notification(int p_what);
-public:
+public:
void set_deploy_dumb(bool p_enabled);
bool is_deploy_dumb_enabled() const;
diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp
index 77dc7bd4bf..21c97b4587 100644
--- a/editor/editor_run_script.cpp
+++ b/editor/editor_run_script.cpp
@@ -30,16 +30,15 @@
#include "editor_node.h"
-
void EditorScript::add_root_node(Node *p_node) {
if (!editor) {
- EditorNode::add_io_error("EditorScript::add_root_node: "+TTR("Write your logic in the _run() method."));
+ EditorNode::add_io_error("EditorScript::add_root_node: " + TTR("Write your logic in the _run() method."));
return;
}
if (editor->get_edited_scene()) {
- EditorNode::add_io_error("EditorScript::add_root_node: "+TTR("There is an edited scene already."));
+ EditorNode::add_io_error("EditorScript::add_root_node: " + TTR("There is an edited scene already."));
return;
}
@@ -49,7 +48,7 @@ void EditorScript::add_root_node(Node *p_node) {
Node *EditorScript::get_scene() {
if (!editor) {
- EditorNode::add_io_error("EditorScript::get_scene: "+TTR("Write your logic in the _run() method."));
+ EditorNode::add_io_error("EditorScript::get_scene: " + TTR("Write your logic in the _run() method."));
return NULL;
}
@@ -61,37 +60,32 @@ void EditorScript::_run() {
Ref<Script> s = get_script();
ERR_FAIL_COND(!s.is_valid());
if (!get_script_instance()) {
- EditorNode::add_io_error(TTR("Couldn't instance script:")+"\n "+s->get_path()+"\n"+TTR("Did you forget the 'tool' keyword?"));
+ EditorNode::add_io_error(TTR("Couldn't instance script:") + "\n " + s->get_path() + "\n" + TTR("Did you forget the 'tool' keyword?"));
return;
-
}
Variant::CallError ce;
- ce.error=Variant::CallError::CALL_OK;
- get_script_instance()->call("_run",NULL,0,ce);
- if (ce.error!=Variant::CallError::CALL_OK) {
+ ce.error = Variant::CallError::CALL_OK;
+ get_script_instance()->call("_run", NULL, 0, ce);
+ if (ce.error != Variant::CallError::CALL_OK) {
- EditorNode::add_io_error(TTR("Couldn't run script:")+"\n "+s->get_path()+"\n"+TTR("Did you forget the '_run' method?"));
+ EditorNode::add_io_error(TTR("Couldn't run script:") + "\n " + s->get_path() + "\n" + TTR("Did you forget the '_run' method?"));
}
}
void EditorScript::set_editor(EditorNode *p_editor) {
- editor=p_editor;
+ editor = p_editor;
}
-
void EditorScript::_bind_methods() {
- ClassDB::bind_method(D_METHOD("add_root_node","node"),&EditorScript::add_root_node);
- ClassDB::bind_method(D_METHOD("get_scene"),&EditorScript::get_scene);
- BIND_VMETHOD( MethodInfo("_run") );
-
-
+ ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node);
+ ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene);
+ BIND_VMETHOD(MethodInfo("_run"));
}
EditorScript::EditorScript() {
- editor=NULL;
+ editor = NULL;
}
-
diff --git a/editor/editor_run_script.h b/editor/editor_run_script.h
index 3ab8525cc6..270600db69 100644
--- a/editor/editor_run_script.h
+++ b/editor/editor_run_script.h
@@ -31,18 +31,17 @@
#include "reference.h"
-
class EditorNode;
class EditorScript : public Reference {
- GDCLASS( EditorScript, Reference );
+ GDCLASS(EditorScript, Reference);
EditorNode *editor;
-protected:
+protected:
static void _bind_methods();
-public:
+public:
void add_root_node(Node *p_node);
Node *get_scene();
diff --git a/editor/editor_scale.cpp b/editor/editor_scale.cpp
index 5687f97b22..027f1edc28 100644
--- a/editor/editor_scale.cpp
+++ b/editor/editor_scale.cpp
@@ -34,7 +34,7 @@ static float scale = 1.0;
void editor_set_scale(float p_scale) {
- scale=p_scale;
+ scale = p_scale;
}
float editor_get_scale() {
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index f977a40243..8794a34f62 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -28,84 +28,80 @@
/*************************************************************************/
#include "editor_settings.h"
-#include "os/os.h"
-#include "os/dir_access.h"
-#include "os/file_access.h"
-#include "version.h"
-#include "scene/main/scene_main_loop.h"
-#include "scene/main/node.h"
-#include "io/resource_loader.h"
-#include "io/resource_saver.h"
-#include "scene/main/viewport.h"
-#include "io/config_file.h"
#include "editor_node.h"
#include "global_config.h"
-#include "translations.h"
+#include "io/compression.h"
+#include "io/config_file.h"
#include "io/file_access_memory.h"
+#include "io/resource_loader.h"
+#include "io/resource_saver.h"
#include "io/translation_loader_po.h"
-#include "io/compression.h"
+#include "os/dir_access.h"
+#include "os/file_access.h"
#include "os/keyboard.h"
+#include "os/os.h"
+#include "scene/main/node.h"
+#include "scene/main/scene_main_loop.h"
+#include "scene/main/viewport.h"
+#include "translations.h"
+#include "version.h"
-
-
-
-Ref<EditorSettings> EditorSettings::singleton=NULL;
+Ref<EditorSettings> EditorSettings::singleton = NULL;
EditorSettings *EditorSettings::get_singleton() {
return singleton.ptr();
}
-
-bool EditorSettings::_set(const StringName& p_name, const Variant& p_value) {
+bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) {
_THREAD_SAFE_METHOD_
- if (p_name.operator String()=="shortcuts") {
+ if (p_name.operator String() == "shortcuts") {
- Array arr=p_value;
- ERR_FAIL_COND_V(arr.size() && arr.size()&1,true);
- for(int i=0;i<arr.size();i+=2) {
+ Array arr = p_value;
+ ERR_FAIL_COND_V(arr.size() && arr.size() & 1, true);
+ for (int i = 0; i < arr.size(); i += 2) {
String name = arr[i];
- InputEvent shortcut = arr[i+1];
+ InputEvent shortcut = arr[i + 1];
Ref<ShortCut> sc;
sc.instance();
sc->set_shortcut(shortcut);
- add_shortcut(name,sc);
+ add_shortcut(name, sc);
}
return true;
}
- if (p_value.get_type()==Variant::NIL)
+ if (p_value.get_type() == Variant::NIL)
props.erase(p_name);
else {
if (props.has(p_name))
- props[p_name].variant=p_value;
+ props[p_name].variant = p_value;
else
- props[p_name]=VariantContainer(p_value,last_order++);
+ props[p_name] = VariantContainer(p_value, last_order++);
if (save_changed_setting) {
- props[p_name].save=true;
+ props[p_name].save = true;
}
}
emit_signal("settings_changed");
return true;
}
-bool EditorSettings::_get(const StringName& p_name,Variant &r_ret) const {
+bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const {
_THREAD_SAFE_METHOD_
- if (p_name.operator String()=="shortcuts") {
+ if (p_name.operator String() == "shortcuts") {
Array arr;
- for (const Map<String,Ref<ShortCut> >::Element *E=shortcuts.front();E;E=E->next()) {
+ for (const Map<String, Ref<ShortCut> >::Element *E = shortcuts.front(); E; E = E->next()) {
- Ref<ShortCut> sc=E->get();
+ Ref<ShortCut> sc = E->get();
if (optimize_save) {
if (!sc->has_meta("original")) {
@@ -113,20 +109,20 @@ bool EditorSettings::_get(const StringName& p_name,Variant &r_ret) const {
}
InputEvent original = sc->get_meta("original");
- if (sc->is_shortcut(original) || (original.type==InputEvent::NONE && sc->get_shortcut().type==InputEvent::NONE))
+ if (sc->is_shortcut(original) || (original.type == InputEvent::NONE && sc->get_shortcut().type == InputEvent::NONE))
continue; //not changed from default, don't save
}
arr.push_back(E->key());
arr.push_back(sc->get_shortcut());
}
- r_ret=arr;
+ r_ret = arr;
return true;
}
- const VariantContainer *v=props.getptr(p_name);
+ const VariantContainer *v = props.getptr(p_name);
if (!v) {
- print_line("EditorSettings::_get - Warning, not found: "+String(p_name));
+ print_line("EditorSettings::_get - Warning, not found: " + String(p_name));
return false;
}
r_ret = v->variant;
@@ -140,56 +136,54 @@ struct _EVCSort {
int order;
bool save;
- bool operator<(const _EVCSort& p_vcs) const{ return order< p_vcs.order; }
+ bool operator<(const _EVCSort &p_vcs) const { return order < p_vcs.order; }
};
void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const {
_THREAD_SAFE_METHOD_
- const String *k=NULL;
+ const String *k = NULL;
Set<_EVCSort> vclist;
- while ((k=props.next(k))) {
+ while ((k = props.next(k))) {
- const VariantContainer *v=props.getptr(*k);
+ const VariantContainer *v = props.getptr(*k);
if (v->hide_from_editor)
continue;
_EVCSort vc;
- vc.name=*k;
- vc.order=v->order;
- vc.type=v->variant.get_type();
- vc.save=v->save;
-
+ vc.name = *k;
+ vc.order = v->order;
+ vc.type = v->variant.get_type();
+ vc.save = v->save;
vclist.insert(vc);
}
- for(Set<_EVCSort>::Element *E=vclist.front();E;E=E->next()) {
+ for (Set<_EVCSort>::Element *E = vclist.front(); E; E = E->next()) {
int pinfo = 0;
if (E->get().save || !optimize_save) {
- pinfo|=PROPERTY_USAGE_STORAGE;
+ pinfo |= PROPERTY_USAGE_STORAGE;
}
if (!E->get().name.begins_with("_") && !E->get().name.begins_with("projects/")) {
- pinfo|=PROPERTY_USAGE_EDITOR;
+ pinfo |= PROPERTY_USAGE_EDITOR;
} else {
- pinfo|=PROPERTY_USAGE_STORAGE; //hiddens must always be saved
+ pinfo |= PROPERTY_USAGE_STORAGE; //hiddens must always be saved
}
PropertyInfo pi(E->get().type, E->get().name);
- pi.usage=pinfo;
+ pi.usage = pinfo;
if (hints.has(E->get().name))
- pi=hints[E->get().name];
+ pi = hints[E->get().name];
-
- p_list->push_back( pi );
+ p_list->push_back(pi);
}
- p_list->push_back(PropertyInfo(Variant::ARRAY,"shortcuts",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR)); //do not edit
+ p_list->push_back(PropertyInfo(Variant::ARRAY, "shortcuts", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); //do not edit
}
bool EditorSettings::has(String p_var) const {
@@ -206,33 +200,27 @@ void EditorSettings::erase(String p_var) {
props.erase(p_var);
}
-void EditorSettings::raise_order(const String& p_name) {
+void EditorSettings::raise_order(const String &p_name) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!props.has(p_name));
- props[p_name].order=++last_order;
-
-
+ props[p_name].order = ++last_order;
}
-
-Variant _EDITOR_DEF( const String& p_var, const Variant& p_default) {
+Variant _EDITOR_DEF(const String &p_var, const Variant &p_default) {
if (EditorSettings::get_singleton()->has(p_var))
return EditorSettings::get_singleton()->get(p_var);
- EditorSettings::get_singleton()->set(p_var,p_default);
+ EditorSettings::get_singleton()->set(p_var, p_default);
return p_default;
-
}
-
void EditorSettings::create() {
-
if (singleton.ptr())
return; //pointless
- DirAccess *dir=NULL;
+ DirAccess *dir = NULL;
Variant meta;
String config_path;
@@ -241,7 +229,7 @@ void EditorSettings::create() {
Ref<ConfigFile> extra_config = memnew(ConfigFile);
String exe_path = OS::get_singleton()->get_executable_path().get_base_dir();
- DirAccess* d = DirAccess::create_for_path(exe_path);
+ DirAccess *d = DirAccess::create_for_path(exe_path);
bool self_contained = false;
if (d->file_exists(exe_path + "/._sc_")) {
@@ -260,57 +248,57 @@ void EditorSettings::create() {
if (OS::get_singleton()->has_environment("APPDATA")) {
// Most likely under windows, save here
- config_path=OS::get_singleton()->get_environment("APPDATA");
- config_dir=String(_MKSTR(VERSION_SHORT_NAME)).capitalize();
+ config_path = OS::get_singleton()->get_environment("APPDATA");
+ config_dir = String(_MKSTR(VERSION_SHORT_NAME)).capitalize();
} else if (OS::get_singleton()->has_environment("HOME")) {
- config_path=OS::get_singleton()->get_environment("HOME");
- config_dir="."+String(_MKSTR(VERSION_SHORT_NAME)).to_lower();
+ config_path = OS::get_singleton()->get_environment("HOME");
+ config_dir = "." + String(_MKSTR(VERSION_SHORT_NAME)).to_lower();
}
};
ClassDB::register_class<EditorSettings>(); //otherwise it can't be unserialized
String config_file_path;
- if (config_path!=""){
+ if (config_path != "") {
dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- if (dir->change_dir(config_path)!=OK) {
+ if (dir->change_dir(config_path) != OK) {
ERR_PRINT("Cannot find path for config directory!");
memdelete(dir);
goto fail;
}
- if (dir->change_dir(config_dir)!=OK) {
+ if (dir->change_dir(config_dir) != OK) {
dir->make_dir(config_dir);
- if (dir->change_dir(config_dir)!=OK) {
+ if (dir->change_dir(config_dir) != OK) {
ERR_PRINT("Cannot create config directory!");
memdelete(dir);
goto fail;
}
}
- if (dir->change_dir("templates")!=OK) {
+ if (dir->change_dir("templates") != OK) {
dir->make_dir("templates");
} else {
dir->change_dir("..");
}
- if (dir->change_dir("text_editor_themes")!=OK) {
+ if (dir->change_dir("text_editor_themes") != OK) {
dir->make_dir("text_editor_themes");
} else {
dir->change_dir("..");
}
- if (dir->change_dir("tmp")!=OK) {
+ if (dir->change_dir("tmp") != OK) {
dir->make_dir("tmp");
} else {
dir->change_dir("..");
}
- if (dir->change_dir("config")!=OK) {
+ if (dir->change_dir("config") != OK) {
dir->make_dir("config");
} else {
@@ -319,10 +307,10 @@ void EditorSettings::create() {
dir->change_dir("config");
- String pcp=GlobalConfig::get_singleton()->get_resource_path();
+ String pcp = GlobalConfig::get_singleton()->get_resource_path();
if (pcp.ends_with("/"))
- pcp=config_path.substr(0,pcp.size()-1);
- pcp=pcp.get_file()+"-"+pcp.md5_text();
+ pcp = config_path.substr(0, pcp.size() - 1);
+ pcp = pcp.get_file() + "-" + pcp.md5_text();
if (dir->change_dir(pcp)) {
dir->make_dir(pcp);
@@ -346,17 +334,17 @@ void EditorSettings::create() {
memdelete(dir);
- singleton = ResourceLoader::load(open_path,"EditorSettings");
+ singleton = ResourceLoader::load(open_path, "EditorSettings");
if (singleton.is_null()) {
WARN_PRINT("Could not open config file.");
goto fail;
}
- singleton->save_changed_setting=true;
- singleton->config_file_path=config_file_path;
- singleton->project_config_path=pcp;
- singleton->settings_path=config_path+"/"+config_dir;
+ singleton->save_changed_setting = true;
+ singleton->config_file_path = config_file_path;
+ singleton->project_config_path = pcp;
+ singleton->settings_path = config_path + "/" + config_dir;
if (OS::get_singleton()->is_stdout_verbose()) {
@@ -369,33 +357,28 @@ void EditorSettings::create() {
singleton->list_text_editor_themes();
return;
-
}
-
-
- fail:
+fail:
// patch init projects
if (extra_config->has_section("init_projects")) {
Vector<String> list = extra_config->get_value("init_projects", "list");
- for (int i=0; i<list.size(); i++) {
+ for (int i = 0; i < list.size(); i++) {
list[i] = exe_path + "/" + list[i];
};
extra_config->set_value("init_projects", "list", list);
};
- singleton = Ref<EditorSettings>( memnew( EditorSettings ) );
- singleton->save_changed_setting=true;
- singleton->config_file_path=config_file_path;
- singleton->settings_path=config_path+"/"+config_dir;
+ singleton = Ref<EditorSettings>(memnew(EditorSettings));
+ singleton->save_changed_setting = true;
+ singleton->config_file_path = config_file_path;
+ singleton->settings_path = config_path + "/" + config_dir;
singleton->_load_defaults(extra_config);
singleton->setup_language();
singleton->setup_network();
singleton->list_text_editor_themes();
-
-
}
String EditorSettings::get_settings_path() const {
@@ -403,16 +386,14 @@ String EditorSettings::get_settings_path() const {
return settings_path;
}
-
-
void EditorSettings::setup_language() {
String lang = get("interface/editor_language");
- if (lang=="en")
- return;//none to do
+ if (lang == "en")
+ return; //none to do
- for(int i=0;i<translations.size();i++) {
- if (translations[i]->get_locale()==lang) {
+ for (int i = 0; i < translations.size(); i++) {
+ if (translations[i]->get_locale() == lang) {
TranslationServer::get_singleton()->set_tool_translation(translations[i]);
break;
}
@@ -425,30 +406,27 @@ void EditorSettings::setup_network() {
IP::get_singleton()->get_local_addresses(&local_ip);
String lip;
String hint;
- String current=get("network/debug_host");
+ String current = get("network/debug_host");
- for(List<IP_Address>::Element *E=local_ip.front();E;E=E->next()) {
+ for (List<IP_Address>::Element *E = local_ip.front(); E; E = E->next()) {
String ip = E->get();
- if (ip=="127.0.0.1")
+ if (ip == "127.0.0.1")
continue;
- if (lip=="")
- lip=ip;
- if (ip==current)
- lip=current; //so it saves
- if (hint!="")
- hint+=",";
- hint+=ip;
-
+ if (lip == "")
+ lip = ip;
+ if (ip == current)
+ lip = current; //so it saves
+ if (hint != "")
+ hint += ",";
+ hint += ip;
}
- set("network/debug_host",lip);
- add_property_hint(PropertyInfo(Variant::STRING,"network/debug_host",PROPERTY_HINT_ENUM,hint));
-
+ set("network/debug_host", lip);
+ add_property_hint(PropertyInfo(Variant::STRING, "network/debug_host", PROPERTY_HINT_ENUM, hint));
}
-
void EditorSettings::save() {
//_THREAD_SAFE_METHOD_
@@ -456,14 +434,14 @@ void EditorSettings::save() {
if (!singleton.ptr())
return;
- if (singleton->config_file_path=="") {
+ if (singleton->config_file_path == "") {
ERR_PRINT("Cannot save EditorSettings config, no valid path");
return;
}
- Error err = ResourceSaver::save(singleton->config_file_path,singleton);
+ Error err = ResourceSaver::save(singleton->config_file_path, singleton);
- if (err!=OK) {
+ if (err != OK) {
ERR_PRINT("Can't Save!");
return;
}
@@ -471,7 +449,6 @@ void EditorSettings::save() {
if (OS::get_singleton()->is_stdout_verbose()) {
print_line("EditorSettings Save OK!");
}
-
}
void EditorSettings::destroy() {
@@ -479,69 +456,65 @@ void EditorSettings::destroy() {
if (!singleton.ptr())
return;
save();
- singleton=Ref<EditorSettings>();
+ singleton = Ref<EditorSettings>();
}
void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_THREAD_SAFE_METHOD_
-
{
- String lang_hint="en";
+ String lang_hint = "en";
String host_lang = OS::get_singleton()->get_locale();
String best;
- for(int i=0;i<translations.size();i++) {
+ for (int i = 0; i < translations.size(); i++) {
String locale = translations[i]->get_locale();
- lang_hint+=",";
- lang_hint+=locale;
+ lang_hint += ",";
+ lang_hint += locale;
- if (host_lang==locale) {
- best=locale;
+ if (host_lang == locale) {
+ best = locale;
}
- if (best==String() && host_lang.begins_with(locale)) {
- best=locale;
+ if (best == String() && host_lang.begins_with(locale)) {
+ best = locale;
}
}
- if (best==String()) {
- best="en";
+ if (best == String()) {
+ best = "en";
}
- set("interface/editor_language",best);
- hints["interface/editor_language"]=PropertyInfo(Variant::STRING,"interface/editor_language",PROPERTY_HINT_ENUM,lang_hint,PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
+ set("interface/editor_language", best);
+ hints["interface/editor_language"] = PropertyInfo(Variant::STRING, "interface/editor_language", PROPERTY_HINT_ENUM, lang_hint, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
}
- set("interface/hidpi_mode",0);
- hints["interface/hidpi_mode"]=PropertyInfo(Variant::INT,"interface/hidpi_mode",PROPERTY_HINT_ENUM,"Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
- set("interface/show_script_in_scene_tabs",false);
- set("interface/font_size",14);
- hints["interface/font_size"]=PropertyInfo(Variant::INT,"interface/font_size",PROPERTY_HINT_RANGE,"10,40,1",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
- set("interface/source_font_size",14);
- hints["interface/source_font_size"]=PropertyInfo(Variant::INT,"interface/source_font_size",PROPERTY_HINT_RANGE,"8,96,1",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
- set("interface/custom_font","");
- hints["interface/custom_font"]=PropertyInfo(Variant::STRING,"interface/custom_font",PROPERTY_HINT_GLOBAL_FILE,"*.fnt",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
- set("interface/custom_theme","");
- hints["interface/custom_theme"]=PropertyInfo(Variant::STRING,"interface/custom_theme",PROPERTY_HINT_GLOBAL_FILE,"*.res,*.tres,*.theme",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
-
-
- set("filesystem/directories/autoscan_project_path","");
- hints["filesystem/directories/autoscan_project_path"]=PropertyInfo(Variant::STRING,"filesystem/directories/autoscan_project_path",PROPERTY_HINT_GLOBAL_DIR);
- set("filesystem/directories/default_project_path","");
- hints["filesystem/directories/default_project_path"]=PropertyInfo(Variant::STRING,"filesystem/directories/default_project_path",PROPERTY_HINT_GLOBAL_DIR);
- set("filesystem/directories/default_project_export_path","");
- hints["global/default_project_export_path"]=PropertyInfo(Variant::STRING,"global/default_project_export_path",PROPERTY_HINT_GLOBAL_DIR);
- set("interface/show_script_in_scene_tabs",false);
-
-
- set("text_editor/theme/color_theme","Default");
- hints["text_editor/theme/color_theme"]=PropertyInfo(Variant::STRING,"text_editor/theme/color_theme",PROPERTY_HINT_ENUM,"Default");
-
- set("text_editor/theme/line_spacing",4);
-
+ set("interface/hidpi_mode", 0);
+ hints["interface/hidpi_mode"] = PropertyInfo(Variant::INT, "interface/hidpi_mode", PROPERTY_HINT_ENUM, "Auto,VeryLoDPI,LoDPI,MidDPI,HiDPI", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ set("interface/show_script_in_scene_tabs", false);
+ set("interface/font_size", 14);
+ hints["interface/font_size"] = PropertyInfo(Variant::INT, "interface/font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ set("interface/source_font_size", 14);
+ hints["interface/source_font_size"] = PropertyInfo(Variant::INT, "interface/source_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ set("interface/custom_font", "");
+ hints["interface/custom_font"] = PropertyInfo(Variant::STRING, "interface/custom_font", PROPERTY_HINT_GLOBAL_FILE, "*.fnt", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ set("interface/custom_theme", "");
+ hints["interface/custom_theme"] = PropertyInfo(Variant::STRING, "interface/custom_theme", PROPERTY_HINT_GLOBAL_FILE, "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+
+ set("filesystem/directories/autoscan_project_path", "");
+ hints["filesystem/directories/autoscan_project_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/autoscan_project_path", PROPERTY_HINT_GLOBAL_DIR);
+ set("filesystem/directories/default_project_path", "");
+ hints["filesystem/directories/default_project_path"] = PropertyInfo(Variant::STRING, "filesystem/directories/default_project_path", PROPERTY_HINT_GLOBAL_DIR);
+ set("filesystem/directories/default_project_export_path", "");
+ hints["global/default_project_export_path"] = PropertyInfo(Variant::STRING, "global/default_project_export_path", PROPERTY_HINT_GLOBAL_DIR);
+ set("interface/show_script_in_scene_tabs", false);
+
+ set("text_editor/theme/color_theme", "Default");
+ hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Default");
+
+ set("text_editor/theme/line_spacing", 4);
_load_default_text_editor_theme();
@@ -551,7 +524,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/cursor/scroll_past_end_of_file", false);
set("text_editor/indent/tab_size", 4);
- hints["text_editor/indent/tab_size"]=PropertyInfo(Variant::INT,"text_editor/indent/tab_size",PROPERTY_HINT_RANGE,"1, 64, 1"); // size of 0 crashes.
+ hints["text_editor/indent/tab_size"] = PropertyInfo(Variant::INT, "text_editor/indent/tab_size", PROPERTY_HINT_RANGE, "1, 64, 1"); // size of 0 crashes.
set("text_editor/indent/draw_tabs", true);
set("text_editor/line_numbers/show_line_numbers", true);
@@ -559,124 +532,122 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/line_numbers/show_breakpoint_gutter", true);
set("text_editor/line_numbers/show_line_length_guideline", false);
set("text_editor/line_numbers/line_length_guideline_column", 80);
- hints["text_editor/line_numbers/line_length_guideline_column"]=PropertyInfo(Variant::INT,"text_editor/line_numbers/line_length_guideline_column",PROPERTY_HINT_RANGE,"20, 160, 10");
+ hints["text_editor/line_numbers/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/line_numbers/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 10");
set("text_editor/files/trim_trailing_whitespace_on_save", false);
- set("text_editor/completion/idle_parse_delay",2);
- set("text_editor/tools/create_signal_callbacks",true);
- set("text_editor/files/autosave_interval_secs",0);
+ set("text_editor/completion/idle_parse_delay", 2);
+ set("text_editor/tools/create_signal_callbacks", true);
+ set("text_editor/files/autosave_interval_secs", 0);
set("text_editor/cursor/block_caret", false);
set("text_editor/cursor/caret_blink", false);
set("text_editor/cursor/caret_blink_speed", 0.65);
- hints["text_editor/cursor/caret_blink_speed"]=PropertyInfo(Variant::REAL,"text_editor/cursor/caret_blink_speed",PROPERTY_HINT_RANGE,"0.1, 10, 0.1");
+ hints["text_editor/cursor/caret_blink_speed"] = PropertyInfo(Variant::REAL, "text_editor/cursor/caret_blink_speed", PROPERTY_HINT_RANGE, "0.1, 10, 0.1");
- set("text_editor/theme/font","");
- hints["text_editor/theme/font"]=PropertyInfo(Variant::STRING,"text_editor/theme/font",PROPERTY_HINT_GLOBAL_FILE,"*.fnt");
+ set("text_editor/theme/font", "");
+ hints["text_editor/theme/font"] = PropertyInfo(Variant::STRING, "text_editor/theme/font", PROPERTY_HINT_GLOBAL_FILE, "*.fnt");
set("text_editor/completion/auto_brace_complete", false);
- set("text_editor/files/restore_scripts_on_load",true);
-
+ set("text_editor/files/restore_scripts_on_load", true);
//set("docks/scene_tree/display_old_action_buttons",false);
- set("docks/scene_tree/start_create_dialog_fully_expanded",false);
- set("docks/scene_tree/draw_relationship_lines",false);
- set("docks/scene_tree/relationship_line_color",Color::html("464646"));
+ set("docks/scene_tree/start_create_dialog_fully_expanded", false);
+ set("docks/scene_tree/draw_relationship_lines", false);
+ set("docks/scene_tree/relationship_line_color", Color::html("464646"));
set("editors/grid_map/pick_distance", 5000.0);
- set("editors/3d/grid_color",Color(0,1,0,0.2));
- hints["editors/3d/grid_color"]=PropertyInfo(Variant::COLOR,"editors/3d/grid_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED);
-
- set("editors/3d/default_fov",45.0);
- set("editors/3d/default_z_near",0.1);
- set("editors/3d/default_z_far",500.0);
-
- set("editors/3d/navigation_scheme",0);
- hints["editors/3d/navigation_scheme"]=PropertyInfo(Variant::INT,"editors/3d/navigation_scheme",PROPERTY_HINT_ENUM,"Godot,Maya,Modo");
- set("editors/3d/zoom_style",0);
- hints["editors/3d/zoom_style"]=PropertyInfo(Variant::INT,"editors/3d/zoom_style",PROPERTY_HINT_ENUM,"Vertical, Horizontal");
- set("editors/3d/orbit_modifier",0);
- hints["editors/3d/orbit_modifier"]=PropertyInfo(Variant::INT,"editors/3d/orbit_modifier",PROPERTY_HINT_ENUM,"None,Shift,Alt,Meta,Ctrl");
- set("editors/3d/pan_modifier",1);
- hints["editors/3d/pan_modifier"]=PropertyInfo(Variant::INT,"editors/3d/pan_modifier",PROPERTY_HINT_ENUM,"None,Shift,Alt,Meta,Ctrl");
- set("editors/3d/zoom_modifier",4);
- hints["editors/3d/zoom_modifier"]=PropertyInfo(Variant::INT,"editors/3d/zoom_modifier",PROPERTY_HINT_ENUM,"None,Shift,Alt,Meta,Ctrl");
- set("editors/3d/emulate_numpad",false);
+ set("editors/3d/grid_color", Color(0, 1, 0, 0.2));
+ hints["editors/3d/grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/grid_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+
+ set("editors/3d/default_fov", 45.0);
+ set("editors/3d/default_z_near", 0.1);
+ set("editors/3d/default_z_far", 500.0);
+
+ set("editors/3d/navigation_scheme", 0);
+ hints["editors/3d/navigation_scheme"] = PropertyInfo(Variant::INT, "editors/3d/navigation_scheme", PROPERTY_HINT_ENUM, "Godot,Maya,Modo");
+ set("editors/3d/zoom_style", 0);
+ hints["editors/3d/zoom_style"] = PropertyInfo(Variant::INT, "editors/3d/zoom_style", PROPERTY_HINT_ENUM, "Vertical, Horizontal");
+ set("editors/3d/orbit_modifier", 0);
+ hints["editors/3d/orbit_modifier"] = PropertyInfo(Variant::INT, "editors/3d/orbit_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
+ set("editors/3d/pan_modifier", 1);
+ hints["editors/3d/pan_modifier"] = PropertyInfo(Variant::INT, "editors/3d/pan_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
+ set("editors/3d/zoom_modifier", 4);
+ hints["editors/3d/zoom_modifier"] = PropertyInfo(Variant::INT, "editors/3d/zoom_modifier", PROPERTY_HINT_ENUM, "None,Shift,Alt,Meta,Ctrl");
+ set("editors/3d/emulate_numpad", false);
set("editors/3d/emulate_3_button_mouse", false);
- set("editors/2d/bone_width",5);
- set("editors/2d/bone_color1",Color(1.0,1.0,1.0,0.9));
- set("editors/2d/bone_color2",Color(0.75,0.75,0.75,0.9));
- set("editors/2d/bone_selected_color",Color(0.9,0.45,0.45,0.9));
- set("editors/2d/bone_ik_color",Color(0.9,0.9,0.45,0.9));
+ set("editors/2d/bone_width", 5);
+ set("editors/2d/bone_color1", Color(1.0, 1.0, 1.0, 0.9));
+ set("editors/2d/bone_color2", Color(0.75, 0.75, 0.75, 0.9));
+ set("editors/2d/bone_selected_color", Color(0.9, 0.45, 0.45, 0.9));
+ set("editors/2d/bone_ik_color", Color(0.9, 0.9, 0.45, 0.9));
set("editors/2d/keep_margins_when_changing_anchors", false);
- set("run/window_placement/rect",0);
- hints["run/window_placement/rect"]=PropertyInfo(Variant::INT,"run/window_placement/rect",PROPERTY_HINT_ENUM,"Default,Centered,Custom Position,Force Maximized,Force Full Screen");
- String screen_hints=TTR("Default (Same as Editor)");
- for(int i=0;i<OS::get_singleton()->get_screen_count();i++) {
- screen_hints+=",Monitor "+itos(i+1);
+ set("run/window_placement/rect", 0);
+ hints["run/window_placement/rect"] = PropertyInfo(Variant::INT, "run/window_placement/rect", PROPERTY_HINT_ENUM, "Default,Centered,Custom Position,Force Maximized,Force Full Screen");
+ String screen_hints = TTR("Default (Same as Editor)");
+ for (int i = 0; i < OS::get_singleton()->get_screen_count(); i++) {
+ screen_hints += ",Monitor " + itos(i + 1);
}
- set("run/window_placement/rect_custom_position",Vector2());
- set("run/window_placement/screen",0);
- hints["run/window_placement/screen"]=PropertyInfo(Variant::INT,"run/window_placement/screen",PROPERTY_HINT_ENUM,screen_hints);
+ set("run/window_placement/rect_custom_position", Vector2());
+ set("run/window_placement/screen", 0);
+ hints["run/window_placement/screen"] = PropertyInfo(Variant::INT, "run/window_placement/screen", PROPERTY_HINT_ENUM, screen_hints);
- set("filesystem/on_save/compress_binary_resources",true);
- set("filesystem/on_save/save_modified_external_resources",true);
+ set("filesystem/on_save/compress_binary_resources", true);
+ set("filesystem/on_save/save_modified_external_resources", true);
//set("filesystem/on_save/save_paths_as_relative",false);
//set("filesystem/on_save/save_paths_without_extension",false);
- set("text_editor/tools/create_signal_callbacks",true);
+ set("text_editor/tools/create_signal_callbacks", true);
set("filesystem/file_dialog/show_hidden_files", false);
set("filesystem/file_dialog/display_mode", 0);
- hints["filesystem/file_dialog/display_mode"]=PropertyInfo(Variant::INT,"filesystem/file_dialog/display_mode",PROPERTY_HINT_ENUM,"Thumbnails,List");
+ hints["filesystem/file_dialog/display_mode"] = PropertyInfo(Variant::INT, "filesystem/file_dialog/display_mode", PROPERTY_HINT_ENUM, "Thumbnails,List");
set("filesystem/file_dialog/thumbnail_size", 64);
- hints["filesystem/file_dialog/thumbnail_size"]=PropertyInfo(Variant::INT,"filesystem/file_dialog/thumbnail_size",PROPERTY_HINT_RANGE,"32,128,16");
+ hints["filesystem/file_dialog/thumbnail_size"] = PropertyInfo(Variant::INT, "filesystem/file_dialog/thumbnail_size", PROPERTY_HINT_RANGE, "32,128,16");
set("docks/filesystem/display_mode", 0);
- hints["docks/filesystem/display_mode"]=PropertyInfo(Variant::INT,"docks/filesystem/display_mode",PROPERTY_HINT_ENUM,"Thumbnails,List");
+ hints["docks/filesystem/display_mode"] = PropertyInfo(Variant::INT, "docks/filesystem/display_mode", PROPERTY_HINT_ENUM, "Thumbnails,List");
set("docks/filesystem/thumbnail_size", 64);
- hints["docks/filesystem/thumbnail_size"]=PropertyInfo(Variant::INT,"docks/filesystem/thumbnail_size",PROPERTY_HINT_RANGE,"32,128,16");
+ hints["docks/filesystem/thumbnail_size"] = PropertyInfo(Variant::INT, "docks/filesystem/thumbnail_size", PROPERTY_HINT_RANGE, "32,128,16");
- set("editors/animation/autorename_animation_tracks",true);
- set("editors/animation/confirm_insert_track",true);
+ set("editors/animation/autorename_animation_tracks", true);
+ set("editors/animation/confirm_insert_track", true);
- set("docks/property_editor/texture_preview_width",48);
- set("docks/property_editor/auto_refresh_interval",0.3);
- set("text_editor/help/doc_path","");
+ set("docks/property_editor/texture_preview_width", 48);
+ set("docks/property_editor/auto_refresh_interval", 0.3);
+ set("text_editor/help/doc_path", "");
- set("filesystem/import/ask_save_before_reimport",false);
+ set("filesystem/import/ask_save_before_reimport", false);
- set("filesystem/import/pvrtc_texture_tool","");
+ set("filesystem/import/pvrtc_texture_tool", "");
#ifdef WINDOWS_ENABLED
- hints["filesystem/import/pvrtc_texture_tool"]=PropertyInfo(Variant::STRING,"import/pvrtc_texture_tool",PROPERTY_HINT_GLOBAL_FILE,"*.exe");
+ hints["filesystem/import/pvrtc_texture_tool"] = PropertyInfo(Variant::STRING, "import/pvrtc_texture_tool", PROPERTY_HINT_GLOBAL_FILE, "*.exe");
#else
- hints["import/pvrtc_texture_tool"]=PropertyInfo(Variant::STRING,"import/pvrtc_texture_tool",PROPERTY_HINT_GLOBAL_FILE,"");
+ hints["import/pvrtc_texture_tool"] = PropertyInfo(Variant::STRING, "import/pvrtc_texture_tool", PROPERTY_HINT_GLOBAL_FILE, "");
#endif
// TODO: Rename to "filesystem/import/pvrtc_fast_conversion" to match other names?
- set("filesystem/import/pvrtc_fast_conversion",false);
-
+ set("filesystem/import/pvrtc_fast_conversion", false);
- set("run/auto_save/save_before_running",true);
- set("run/output/always_clear_output_on_play",true);
- set("run/output/always_open_output_on_play",true);
- set("run/output/always_close_output_on_stop",false);
- set("filesystem/resources/save_compressed_resources",true);
- set("filesystem/resources/auto_reload_modified_images",true);
+ set("run/auto_save/save_before_running", true);
+ set("run/output/always_clear_output_on_play", true);
+ set("run/output/always_open_output_on_play", true);
+ set("run/output/always_close_output_on_stop", false);
+ set("filesystem/resources/save_compressed_resources", true);
+ set("filesystem/resources/auto_reload_modified_images", true);
- set("filesystem/import/automatic_reimport_on_sources_changed",true);
+ set("filesystem/import/automatic_reimport_on_sources_changed", true);
if (p_extra_config.is_valid()) {
if (p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) {
Vector<String> list = p_extra_config->get_value("init_projects", "list");
- for (int i=0; i<list.size(); i++) {
+ for (int i = 0; i < list.size(); i++) {
String name = list[i].replace("/", "::");
- set("projects/"+name, list[i]);
+ set("projects/" + name, list[i]);
};
};
@@ -685,7 +656,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
List<String> keys;
p_extra_config->get_section_keys("presets", &keys);
- for (List<String>::Element *E=keys.front();E;E=E->next()) {
+ for (List<String>::Element *E = keys.front(); E; E = E->next()) {
String key = E->get();
Variant val = p_extra_config->get_value("presets", key);
@@ -693,49 +664,45 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
};
};
};
-
-
-
-
}
void EditorSettings::_load_default_text_editor_theme() {
- set("text_editor/highlighting/background_color",Color::html("3b000000"));
+ set("text_editor/highlighting/background_color", Color::html("3b000000"));
set("text_editor/highlighting/completion_background_color", Color::html("2C2A32"));
set("text_editor/highlighting/completion_selected_color", Color::html("434244"));
set("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"));
set("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"));
set("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"));
- set("text_editor/highlighting/caret_color",Color::html("aaaaaa"));
+ set("text_editor/highlighting/caret_color", Color::html("aaaaaa"));
set("text_editor/highlighting/caret_background_color", Color::html("000000"));
- set("text_editor/highlighting/line_number_color",Color::html("66aaaaaa"));
- set("text_editor/highlighting/text_color",Color::html("aaaaaa"));
- set("text_editor/highlighting/text_selected_color",Color::html("000000"));
- set("text_editor/highlighting/keyword_color",Color::html("ffffb3"));
- set("text_editor/highlighting/base_type_color",Color::html("a4ffd4"));
- set("text_editor/highlighting/engine_type_color",Color::html("83d3ff"));
- set("text_editor/highlighting/function_color",Color::html("66a2ce"));
- set("text_editor/highlighting/member_variable_color",Color::html("e64e59"));
- set("text_editor/highlighting/comment_color",Color::html("676767"));
- set("text_editor/highlighting/string_color",Color::html("ef6ebe"));
- set("text_editor/highlighting/number_color",Color::html("EB9532"));
- set("text_editor/highlighting/symbol_color",Color::html("badfff"));
- set("text_editor/highlighting/selection_color",Color::html("7b5dbe"));
- set("text_editor/highlighting/brace_mismatch_color",Color(1,0.2,0.2));
- set("text_editor/highlighting/current_line_color",Color(0.3,0.5,0.8,0.15));
- set("text_editor/highlighting/line_length_guideline_color",Color(0.3,0.5,0.8,0.1));
- set("text_editor/highlighting/mark_color", Color(1.0,0.4,0.4,0.4));
- set("text_editor/highlighting/breakpoint_color", Color(0.8,0.8,0.4,0.2));
- set("text_editor/highlighting/word_highlighted_color",Color(0.8,0.9,0.9,0.15));
- set("text_editor/highlighting/search_result_color",Color(0.05,0.25,0.05,1));
- set("text_editor/highlighting/search_result_border_color",Color(0.1,0.45,0.1,1));
+ set("text_editor/highlighting/line_number_color", Color::html("66aaaaaa"));
+ set("text_editor/highlighting/text_color", Color::html("aaaaaa"));
+ set("text_editor/highlighting/text_selected_color", Color::html("000000"));
+ set("text_editor/highlighting/keyword_color", Color::html("ffffb3"));
+ set("text_editor/highlighting/base_type_color", Color::html("a4ffd4"));
+ set("text_editor/highlighting/engine_type_color", Color::html("83d3ff"));
+ set("text_editor/highlighting/function_color", Color::html("66a2ce"));
+ set("text_editor/highlighting/member_variable_color", Color::html("e64e59"));
+ set("text_editor/highlighting/comment_color", Color::html("676767"));
+ set("text_editor/highlighting/string_color", Color::html("ef6ebe"));
+ set("text_editor/highlighting/number_color", Color::html("EB9532"));
+ set("text_editor/highlighting/symbol_color", Color::html("badfff"));
+ set("text_editor/highlighting/selection_color", Color::html("7b5dbe"));
+ set("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2));
+ set("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15));
+ set("text_editor/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1));
+ set("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4));
+ set("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2));
+ set("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15));
+ set("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1));
+ set("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1));
}
void EditorSettings::notify_changes() {
_THREAD_SAFE_METHOD_
- SceneTree *sml=NULL;
+ SceneTree *sml = NULL;
if (OS::get_singleton()->get_main_loop())
sml = OS::get_singleton()->get_main_loop()->cast_to<SceneTree>();
@@ -750,10 +717,9 @@ void EditorSettings::notify_changes() {
return;
}
root->propagate_notification(NOTIFICATION_EDITOR_SETTINGS_CHANGED);
-
}
-void EditorSettings::_add_property_info_bind(const Dictionary& p_info) {
+void EditorSettings::_add_property_info_bind(const Dictionary &p_info) {
ERR_FAIL_COND(!p_info.has("name"));
ERR_FAIL_COND(!p_info.has("type"));
@@ -772,28 +738,22 @@ void EditorSettings::_add_property_info_bind(const Dictionary& p_info) {
add_property_hint(pinfo);
}
-void EditorSettings::add_property_hint(const PropertyInfo& p_hint) {
+void EditorSettings::add_property_hint(const PropertyInfo &p_hint) {
_THREAD_SAFE_METHOD_
- hints[p_hint.name]=p_hint;
+ hints[p_hint.name] = p_hint;
}
+void EditorSettings::set_favorite_dirs(const Vector<String> &p_favorites) {
-
-
-
-
-void EditorSettings::set_favorite_dirs(const Vector<String>& p_favorites) {
-
- favorite_dirs=p_favorites;
- FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("favorite_dirs"),FileAccess::WRITE);
+ favorite_dirs = p_favorites;
+ FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("favorite_dirs"), FileAccess::WRITE);
if (f) {
- for(int i=0;i<favorite_dirs.size();i++)
+ for (int i = 0; i < favorite_dirs.size(); i++)
f->store_line(favorite_dirs[i]);
memdelete(f);
}
-
}
Vector<String> EditorSettings::get_favorite_dirs() const {
@@ -801,13 +761,12 @@ Vector<String> EditorSettings::get_favorite_dirs() const {
return favorite_dirs;
}
+void EditorSettings::set_recent_dirs(const Vector<String> &p_recent) {
-void EditorSettings::set_recent_dirs(const Vector<String>& p_recent) {
-
- recent_dirs=p_recent;
- FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("recent_dirs"),FileAccess::WRITE);
+ recent_dirs = p_recent;
+ FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("recent_dirs"), FileAccess::WRITE);
if (f) {
- for(int i=0;i<recent_dirs.size();i++)
+ for (int i = 0; i < recent_dirs.size(); i++)
f->store_line(recent_dirs[i]);
memdelete(f);
}
@@ -820,42 +779,39 @@ Vector<String> EditorSettings::get_recent_dirs() const {
String EditorSettings::get_project_settings_path() const {
-
return get_settings_path().plus_file("config").plus_file(project_config_path);
}
-
void EditorSettings::load_favorites() {
- FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("favorite_dirs"),FileAccess::READ);
+ FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("favorite_dirs"), FileAccess::READ);
if (f) {
String line = f->get_line().strip_edges();
- while(line!="") {
+ while (line != "") {
favorite_dirs.push_back(line);
line = f->get_line().strip_edges();
}
memdelete(f);
}
- f = FileAccess::open(get_project_settings_path().plus_file("recent_dirs"),FileAccess::READ);
+ f = FileAccess::open(get_project_settings_path().plus_file("recent_dirs"), FileAccess::READ);
if (f) {
String line = f->get_line().strip_edges();
- while(line!="") {
+ while (line != "") {
recent_dirs.push_back(line);
line = f->get_line().strip_edges();
}
memdelete(f);
}
-
}
void EditorSettings::list_text_editor_themes() {
- String themes="Default";
+ String themes = "Default";
DirAccess *d = DirAccess::open(settings_path + "/text_editor_themes");
if (d) {
d->list_dir_begin();
String file = d->get_next();
- while(file != String()) {
+ while (file != String()) {
if (file.get_extension() == "tet" && file.get_basename().to_lower() != "default") {
themes += "," + file.get_basename();
}
@@ -864,18 +820,18 @@ void EditorSettings::list_text_editor_themes() {
d->list_dir_end();
memdelete(d);
}
- add_property_hint(PropertyInfo(Variant::STRING,"text_editor/theme/color_theme",PROPERTY_HINT_ENUM,themes));
+ add_property_hint(PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, themes));
}
void EditorSettings::load_text_editor_theme() {
if (get("text_editor/theme/color_theme") == "Default") {
- _load_default_text_editor_theme(); // sorry for "Settings changed" console spam
+ _load_default_text_editor_theme(); // sorry for "Settings changed" console spam
return;
}
String theme_path = get_settings_path() + "/text_editor_themes/" + get("text_editor/theme/color_theme") + ".tet";
- Ref<ConfigFile> cf = memnew( ConfigFile );
+ Ref<ConfigFile> cf = memnew(ConfigFile);
Error err = cf->load(theme_path);
if (err != OK) {
@@ -885,7 +841,7 @@ void EditorSettings::load_text_editor_theme() {
List<String> keys;
cf->get_section_keys("color_theme", &keys);
- for(List<String>::Element *E=keys.front();E;E=E->next()) {
+ for (List<String>::Element *E = keys.front(); E; E = E->next()) {
String key = E->get();
String val = cf->get_value("color_theme", key);
@@ -894,7 +850,7 @@ void EditorSettings::load_text_editor_theme() {
// make sure it is actually a color
if (val.is_valid_html_color() && key.find("color") >= 0) {
- props["text_editor/highlighting/"+key].variant = Color::html(val); // change manually to prevent "Settings changed" console spam
+ props["text_editor/highlighting/" + key].variant = Color::html(val); // change manually to prevent "Settings changed" console spam
}
}
}
@@ -940,7 +896,7 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) {
if (p_file.get_file().to_lower() == "default.tet") {
return false;
}
- if(_save_text_editor_theme(p_file)) {
+ if (_save_text_editor_theme(p_file)) {
// switch to theme is saved in the theme directory
list_text_editor_themes();
@@ -957,7 +913,7 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) {
bool EditorSettings::_save_text_editor_theme(String p_file) {
String theme_section = "color_theme";
- Ref<ConfigFile> cf = memnew( ConfigFile ); // hex is better?
+ Ref<ConfigFile> cf = memnew(ConfigFile); // hex is better?
cf->set_value(theme_section, "background_color", ((Color)get("text_editor/highlighting/background_color")).to_html());
cf->set_value(theme_section, "completion_background_color", ((Color)get("text_editor/highlighting/completion_background_color")).to_html());
cf->set_value(theme_section, "completion_selected_color", ((Color)get("text_editor/highlighting/completion_selected_color")).to_html());
@@ -988,7 +944,6 @@ bool EditorSettings::_save_text_editor_theme(String p_file) {
cf->set_value(theme_section, "search_result_color", ((Color)get("text_editor/highlighting/search_result_color")).to_html());
cf->set_value(theme_section, "search_result_border_color", ((Color)get("text_editor/highlighting/search_result_border_color")).to_html());
-
Error err = cf->save(p_file);
if (err == OK) {
@@ -997,27 +952,25 @@ bool EditorSettings::_save_text_editor_theme(String p_file) {
return false;
}
+void EditorSettings::add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcut) {
-void EditorSettings::add_shortcut(const String& p_name, Ref<ShortCut> &p_shortcut) {
-
- shortcuts[p_name]=p_shortcut;
+ shortcuts[p_name] = p_shortcut;
}
-bool EditorSettings::is_shortcut(const String&p_name, const InputEvent &p_event) const{
+bool EditorSettings::is_shortcut(const String &p_name, const InputEvent &p_event) const {
- const Map<String,Ref<ShortCut> >::Element *E=shortcuts.find(p_name);
+ const Map<String, Ref<ShortCut> >::Element *E = shortcuts.find(p_name);
if (!E) {
- ERR_EXPLAIN("Unknown Shortcut: "+p_name);
+ ERR_EXPLAIN("Unknown Shortcut: " + p_name);
ERR_FAIL_V(false);
}
return E->get()->is_shortcut(p_event);
-
}
-Ref<ShortCut> EditorSettings::get_shortcut(const String&p_name) const{
+Ref<ShortCut> EditorSettings::get_shortcut(const String &p_name) const {
- const Map<String,Ref<ShortCut> >::Element *E=shortcuts.find(p_name);
+ const Map<String, Ref<ShortCut> >::Element *E = shortcuts.find(p_name);
if (!E)
return Ref<ShortCut>();
@@ -1026,7 +979,7 @@ Ref<ShortCut> EditorSettings::get_shortcut(const String&p_name) const{
void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) {
- for (const Map<String,Ref<ShortCut> >::Element*E=shortcuts.front();E;E=E->next()) {
+ for (const Map<String, Ref<ShortCut> >::Element *E = shortcuts.front(); E; E = E->next()) {
r_shortcuts->push_back(E->key());
}
@@ -1034,11 +987,11 @@ void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) {
void EditorSettings::set_optimize_save(bool p_optimize) {
- optimize_save=p_optimize;
+ optimize_save = p_optimize;
}
-Variant EditorSettings::get_project_metadata(const String& p_section, const String& p_key, Variant p_default) {
- Ref<ConfigFile> cf = memnew( ConfigFile );
+Variant EditorSettings::get_project_metadata(const String &p_section, const String &p_key, Variant p_default) {
+ Ref<ConfigFile> cf = memnew(ConfigFile);
String path = get_project_settings_path().plus_file("project_metadata.cfg");
Error err = cf->load(path);
if (err != OK) {
@@ -1047,9 +1000,8 @@ Variant EditorSettings::get_project_metadata(const String& p_section, const Stri
return cf->get_value(p_section, p_key, p_default);
}
-void EditorSettings::set_project_metadata(const String& p_section, const String& p_key, Variant p_data)
-{
- Ref<ConfigFile> cf = memnew( ConfigFile );
+void EditorSettings::set_project_metadata(const String &p_section, const String &p_key, Variant p_data) {
+ Ref<ConfigFile> cf = memnew(ConfigFile);
String path = get_project_settings_path().plus_file("project_metadata.cfg");
cf->load(path);
cf->set_value(p_section, p_key, p_data);
@@ -1058,42 +1010,40 @@ void EditorSettings::set_project_metadata(const String& p_section, const String&
void EditorSettings::_bind_methods() {
- ClassDB::bind_method(D_METHOD("erase","property"),&EditorSettings::erase);
- ClassDB::bind_method(D_METHOD("get_settings_path"),&EditorSettings::get_settings_path);
- ClassDB::bind_method(D_METHOD("get_project_settings_path"),&EditorSettings::get_project_settings_path);
+ ClassDB::bind_method(D_METHOD("erase", "property"), &EditorSettings::erase);
+ ClassDB::bind_method(D_METHOD("get_settings_path"), &EditorSettings::get_settings_path);
+ ClassDB::bind_method(D_METHOD("get_project_settings_path"), &EditorSettings::get_project_settings_path);
- ClassDB::bind_method(D_METHOD("add_property_info", "info"),&EditorSettings::_add_property_info_bind);
+ ClassDB::bind_method(D_METHOD("add_property_info", "info"), &EditorSettings::_add_property_info_bind);
- ClassDB::bind_method(D_METHOD("set_favorite_dirs","dirs"),&EditorSettings::set_favorite_dirs);
- ClassDB::bind_method(D_METHOD("get_favorite_dirs"),&EditorSettings::get_favorite_dirs);
+ ClassDB::bind_method(D_METHOD("set_favorite_dirs", "dirs"), &EditorSettings::set_favorite_dirs);
+ ClassDB::bind_method(D_METHOD("get_favorite_dirs"), &EditorSettings::get_favorite_dirs);
- ClassDB::bind_method(D_METHOD("set_recent_dirs","dirs"),&EditorSettings::set_recent_dirs);
- ClassDB::bind_method(D_METHOD("get_recent_dirs"),&EditorSettings::get_recent_dirs);
+ ClassDB::bind_method(D_METHOD("set_recent_dirs", "dirs"), &EditorSettings::set_recent_dirs);
+ ClassDB::bind_method(D_METHOD("get_recent_dirs"), &EditorSettings::get_recent_dirs);
ADD_SIGNAL(MethodInfo("settings_changed"));
-
}
EditorSettings::EditorSettings() {
-
//singleton=this;
- last_order=0;
- optimize_save=true;
- save_changed_setting=true;
+ last_order = 0;
+ optimize_save = true;
+ save_changed_setting = true;
- EditorTranslationList *etl=_editor_translations;
+ EditorTranslationList *etl = _editor_translations;
- while(etl->data) {
+ while (etl->data) {
Vector<uint8_t> data;
data.resize(etl->uncomp_size);
- Compression::decompress(data.ptr(),etl->uncomp_size,etl->data,etl->comp_size,Compression::MODE_DEFLATE);
+ Compression::decompress(data.ptr(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE);
- FileAccessMemory *fa = memnew (FileAccessMemory);
- fa->open_custom(data.ptr(),data.size());
+ FileAccessMemory *fa = memnew(FileAccessMemory);
+ fa->open_custom(data.ptr(), data.size());
- Ref<Translation> tr = TranslationLoaderPO::load_translation(fa,NULL,"translation_"+String(etl->lang));
+ Ref<Translation> tr = TranslationLoaderPO::load_translation(fa, NULL, "translation_" + String(etl->lang));
if (tr.is_valid()) {
tr->set_locale(etl->lang);
@@ -1101,58 +1051,53 @@ EditorSettings::EditorSettings() {
}
etl++;
-
}
_load_defaults();
-
-
}
-
EditorSettings::~EditorSettings() {
//singleton=NULL;
}
-Ref<ShortCut> ED_GET_SHORTCUT(const String& p_path) {
+Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) {
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
if (!sc.is_valid()) {
- ERR_EXPLAIN("Used ED_GET_SHORTCUT with invalid shortcut: "+p_path);
- ERR_FAIL_COND_V(!sc.is_valid(),sc);
+ ERR_EXPLAIN("Used ED_GET_SHORTCUT with invalid shortcut: " + p_path);
+ ERR_FAIL_COND_V(!sc.is_valid(), sc);
}
return sc;
}
-Ref<ShortCut> ED_SHORTCUT(const String& p_path,const String& p_name,uint32_t p_keycode) {
+Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode) {
InputEvent ie;
if (p_keycode) {
- ie.type=InputEvent::KEY;
- ie.key.unicode=p_keycode&KEY_CODE_MASK;
- ie.key.scancode=p_keycode&KEY_CODE_MASK;
- ie.key.mod.shift=bool(p_keycode&KEY_MASK_SHIFT);
- ie.key.mod.alt=bool(p_keycode&KEY_MASK_ALT);
- ie.key.mod.control=bool(p_keycode&KEY_MASK_CTRL);
- ie.key.mod.meta=bool(p_keycode&KEY_MASK_META);
-
+ ie.type = InputEvent::KEY;
+ ie.key.unicode = p_keycode & KEY_CODE_MASK;
+ ie.key.scancode = p_keycode & KEY_CODE_MASK;
+ ie.key.mod.shift = bool(p_keycode & KEY_MASK_SHIFT);
+ ie.key.mod.alt = bool(p_keycode & KEY_MASK_ALT);
+ ie.key.mod.control = bool(p_keycode & KEY_MASK_CTRL);
+ ie.key.mod.meta = bool(p_keycode & KEY_MASK_META);
}
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
if (sc.is_valid()) {
sc->set_name(p_name); //keep name (the ones that come from disk have no name)
- sc->set_meta("original",ie); //to compare against changes
+ sc->set_meta("original", ie); //to compare against changes
return sc;
}
sc.instance();
sc->set_name(p_name);
sc->set_shortcut(ie);
- sc->set_meta("original",ie); //to compare against changes
- EditorSettings::get_singleton()->add_shortcut(p_path,sc);
+ sc->set_meta("original", ie); //to compare against changes
+ EditorSettings::get_singleton()->add_shortcut(p_path, sc);
return sc;
}
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index 809389eb40..4e084e5291 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -31,17 +31,18 @@
#include "object.h"
-#include "resource.h"
-#include "os/thread_safe.h"
#include "core/io/config_file.h"
-#include "translation.h"
+#include "os/thread_safe.h"
+#include "resource.h"
#include "scene/gui/input_action.h"
+#include "translation.h"
class EditorPlugin;
class EditorSettings : public Resource {
- GDCLASS( EditorSettings, Resource );
+ GDCLASS(EditorSettings, Resource);
+
private:
_THREAD_SAFE_CLASS_
@@ -58,24 +59,32 @@ public:
String script;
Vector<String> install_files;
};
-private:
+private:
struct VariantContainer {
int order;
Variant variant;
bool hide_from_editor;
bool save;
- VariantContainer(){ order=0; hide_from_editor=false; save=false;}
- VariantContainer(const Variant& p_variant, int p_order) { variant=p_variant; order=p_order; hide_from_editor=false; }
+ VariantContainer() {
+ order = 0;
+ hide_from_editor = false;
+ save = false;
+ }
+ VariantContainer(const Variant &p_variant, int p_order) {
+ variant = p_variant;
+ order = p_order;
+ hide_from_editor = false;
+ }
};
- HashMap<String,PropertyInfo> hints;
+ HashMap<String, PropertyInfo> hints;
int last_order;
- HashMap<String,VariantContainer> props;
+ HashMap<String, VariantContainer> props;
String resource_path;
- 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;
static Ref<EditorSettings> singleton;
@@ -85,7 +94,6 @@ private:
Ref<Resource> clipboard;
-
bool save_changed_setting;
bool optimize_save; //do not save stuff that came from config but was not set from engine
@@ -102,20 +110,18 @@ private:
Vector<Ref<Translation> > translations;
- Map<String,Ref<ShortCut> > shortcuts;
+ Map<String, Ref<ShortCut> > shortcuts;
- void _add_property_info_bind(const Dictionary& p_info);
+ void _add_property_info_bind(const Dictionary &p_info);
protected:
-
static void _bind_methods();
-public:
+public:
enum {
- NOTIFICATION_EDITOR_SETTINGS_CHANGED=10000
+ NOTIFICATION_EDITOR_SETTINGS_CHANGED = 10000
};
-
bool has(String p_var) const;
static EditorSettings *get_singleton();
void erase(String p_var);
@@ -123,26 +129,25 @@ public:
//String get_global_settings_path() const;
String get_project_settings_path() const;
-
void setup_language();
void setup_network();
- void raise_order(const String& p_name);
+ void raise_order(const String &p_name);
static void create();
static void save();
static void destroy();
void notify_changes();
- void set_resource_clipboard(const Ref<Resource>& p_resource) { clipboard=p_resource; }
+ void set_resource_clipboard(const Ref<Resource> &p_resource) { clipboard = p_resource; }
Ref<Resource> get_resource_clipboard() const { return clipboard; }
- void add_property_hint(const PropertyInfo& p_hint);
+ void add_property_hint(const PropertyInfo &p_hint);
- void set_favorite_dirs(const Vector<String>& p_favorite_dirs);
+ void set_favorite_dirs(const Vector<String> &p_favorite_dirs);
Vector<String> get_favorite_dirs() const;
- void set_recent_dirs(const Vector<String>& p_recent_dirs);
+ void set_recent_dirs(const Vector<String> &p_recent_dirs);
Vector<String> get_recent_dirs() const;
void load_favorites();
@@ -153,28 +158,27 @@ public:
bool save_text_editor_theme();
bool save_text_editor_theme_as(String p_file);
- void add_shortcut(const String& p_name,Ref<ShortCut>& p_shortcut);
- bool is_shortcut(const String&p_name,const InputEvent& p_event) const;
- Ref<ShortCut> get_shortcut(const String&p_name) const;
+ void add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcut);
+ bool is_shortcut(const String &p_name, const InputEvent &p_event) const;
+ Ref<ShortCut> get_shortcut(const String &p_name) const;
void get_shortcut_list(List<String> *r_shortcuts);
void set_optimize_save(bool p_optimize);
- Variant get_project_metadata(const String& p_section, const String& p_key, Variant p_default);
- void set_project_metadata(const String& p_section, const String& p_key, Variant p_data);
+ Variant get_project_metadata(const String &p_section, const String &p_key, Variant p_default);
+ void set_project_metadata(const String &p_section, const String &p_key, Variant p_data);
EditorSettings();
~EditorSettings();
-
};
//not a macro any longer
-#define EDITOR_DEF(m_var,m_val) _EDITOR_DEF(m_var,Variant(m_val))
-Variant _EDITOR_DEF( const String& p_var, const Variant& p_default);
+#define EDITOR_DEF(m_var, m_val) _EDITOR_DEF(m_var, Variant(m_val))
+Variant _EDITOR_DEF(const String &p_var, const Variant &p_default);
-#define ED_IS_SHORTCUT(p_name,p_ev) (EditorSettings::get_singleton()->is_shortcut(p_name,p_ev))
-Ref<ShortCut> ED_SHORTCUT(const String& p_path,const String& p_name,uint32_t p_keycode=0);
-Ref<ShortCut> ED_GET_SHORTCUT(const String& p_path);
+#define ED_IS_SHORTCUT(p_name, p_ev) (EditorSettings::get_singleton()->is_shortcut(p_name, p_ev))
+Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode = 0);
+Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path);
#endif // EDITOR_SETTINGS_H
diff --git a/editor/editor_sub_scene.cpp b/editor/editor_sub_scene.cpp
index 917560b540..01c08bb231 100644
--- a/editor/editor_sub_scene.cpp
+++ b/editor/editor_sub_scene.cpp
@@ -31,27 +31,25 @@
#include "scene/gui/margin_container.h"
#include "scene/resources/packed_scene.h"
-void EditorSubScene::_path_selected(const String& p_path) {
+void EditorSubScene::_path_selected(const String &p_path) {
path->set_text(p_path);
_path_changed(p_path);
-
}
-void EditorSubScene::_path_changed(const String& p_path) {
+void EditorSubScene::_path_changed(const String &p_path) {
tree->clear();
-
if (scene) {
memdelete(scene);
- scene=NULL;
+ scene = NULL;
}
- if (p_path=="")
+ if (p_path == "")
return;
- Ref<PackedScene> ps = ResourceLoader::load(p_path,"PackedScene");
+ Ref<PackedScene> ps = ResourceLoader::load(p_path, "PackedScene");
if (ps.is_null())
return;
@@ -60,10 +58,7 @@ void EditorSubScene::_path_changed(const String& p_path) {
if (!scene)
return;
- _fill_tree(scene,NULL);
-
-
-
+ _fill_tree(scene, NULL);
}
void EditorSubScene::_path_browse() {
@@ -71,45 +66,37 @@ void EditorSubScene::_path_browse() {
file_dialog->popup_centered_ratio();
}
-
void EditorSubScene::_notification(int p_what) {
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (!is_visible_in_tree()) {
-
-
}
}
}
-
-void EditorSubScene::_fill_tree(Node* p_node,TreeItem *p_parent) {
+void EditorSubScene::_fill_tree(Node *p_node, TreeItem *p_parent) {
TreeItem *it = tree->create_item(p_parent);
- it->set_metadata(0,p_node);
- it->set_text(0,p_node->get_name());
- it->set_editable(0,false);
- it->set_selectable(0,true);
- if (has_icon(p_node->get_class(),"EditorIcons")) {
- it->set_icon(0,get_icon(p_node->get_class(),"EditorIcons"));
-
+ it->set_metadata(0, p_node);
+ it->set_text(0, p_node->get_name());
+ it->set_editable(0, false);
+ it->set_selectable(0, true);
+ if (has_icon(p_node->get_class(), "EditorIcons")) {
+ it->set_icon(0, get_icon(p_node->get_class(), "EditorIcons"));
}
- 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_owner()!=scene)
+ if (c->get_owner() != scene)
continue;
- _fill_tree(c,it);
+ _fill_tree(c, it);
}
-
}
-
void EditorSubScene::ok_pressed() {
-
TreeItem *s = tree->get_selected();
if (!s)
return;
@@ -119,29 +106,26 @@ void EditorSubScene::ok_pressed() {
emit_signal("subscene_selected");
hide();
clear();
-
-
}
+void EditorSubScene::_reown(Node *p_node, List<Node *> *p_to_reown) {
-void EditorSubScene::_reown(Node* p_node,List<Node*> *p_to_reown) {
-
- if (p_node==scene) {
+ if (p_node == scene) {
scene->set_filename("");
p_to_reown->push_back(p_node);
- } else if (p_node->get_owner()==scene){
+ } else if (p_node->get_owner() == scene) {
p_to_reown->push_back(p_node);
}
- for(int i=0;i<p_node->get_child_count();i++) {
- Node *c=p_node->get_child(i);
- _reown(c,p_to_reown);
+ for (int i = 0; i < p_node->get_child_count(); i++) {
+ Node *c = p_node->get_child(i);
+ _reown(c, p_to_reown);
}
}
-void EditorSubScene::move(Node* p_new_parent, Node* p_new_owner) {
+void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) {
if (!scene) {
return;
@@ -156,27 +140,24 @@ void EditorSubScene::move(Node* p_new_parent, Node* p_new_owner) {
return;
}
- List<Node*> to_reown;
- _reown(selnode,&to_reown);
+ List<Node *> to_reown;
+ _reown(selnode, &to_reown);
- if (selnode!=scene) {
+ if (selnode != scene) {
selnode->get_parent()->remove_child(selnode);
}
p_new_parent->add_child(selnode);
- for (List<Node*>::Element *E=to_reown.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = to_reown.front(); E; E = E->next()) {
E->get()->set_owner(p_new_owner);
}
- if (selnode!=scene) {
+ if (selnode != scene) {
memdelete(scene);
}
- scene=NULL;
-
+ scene = NULL;
//return selnode;
-
-
}
void EditorSubScene::clear() {
@@ -187,52 +168,49 @@ void EditorSubScene::clear() {
void EditorSubScene::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_path_selected"),&EditorSubScene::_path_selected);
- ClassDB::bind_method(D_METHOD("_path_changed"),&EditorSubScene::_path_changed);
- ClassDB::bind_method(D_METHOD("_path_browse"),&EditorSubScene::_path_browse);
- ADD_SIGNAL( MethodInfo("subscene_selected"));
-
+ ClassDB::bind_method(D_METHOD("_path_selected"), &EditorSubScene::_path_selected);
+ ClassDB::bind_method(D_METHOD("_path_changed"), &EditorSubScene::_path_changed);
+ ClassDB::bind_method(D_METHOD("_path_browse"), &EditorSubScene::_path_browse);
+ ADD_SIGNAL(MethodInfo("subscene_selected"));
}
-
EditorSubScene::EditorSubScene() {
- scene=NULL;
+ scene = NULL;
set_title(TTR("Select Node(s) to Import"));
set_hide_on_ok(false);
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
//set_child_rect(vb);
- HBoxContainer *hb = memnew( HBoxContainer );
- path = memnew( LineEdit );
- path->connect("text_entered",this,"_path_changed");
+ HBoxContainer *hb = memnew(HBoxContainer);
+ path = memnew(LineEdit);
+ path->connect("text_entered", this, "_path_changed");
hb->add_child(path);
path->set_h_size_flags(SIZE_EXPAND_FILL);
- Button *b = memnew( Button );
+ Button *b = memnew(Button);
b->set_text(" .. ");
hb->add_child(b);
- b->connect("pressed",this,"_path_browse");
- vb->add_margin_child(TTR("Scene Path:"),hb);
+ b->connect("pressed", this, "_path_browse");
+ vb->add_margin_child(TTR("Scene Path:"), hb);
- tree = memnew( Tree );
+ tree = memnew(Tree);
tree->set_v_size_flags(SIZE_EXPAND_FILL);
- vb->add_margin_child(TTR("Import From Node:"),tree,true);
- tree->connect("item_activated",this,"_ok",make_binds(),CONNECT_DEFERRED);
+ vb->add_margin_child(TTR("Import From Node:"), tree, true);
+ tree->connect("item_activated", this, "_ok", make_binds(), CONNECT_DEFERRED);
- file_dialog = memnew( EditorFileDialog );
+ file_dialog = memnew(EditorFileDialog);
List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions);
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
- for(List<String>::Element *E = extensions.front();E;E=E->next() ) {
+ for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
- file_dialog->add_filter("*."+E->get());
+ file_dialog->add_filter("*." + E->get());
}
file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
add_child(file_dialog);
- file_dialog->connect("file_selected",this,"_path_selected");
-
+ file_dialog->connect("file_selected", this, "_path_selected");
}
diff --git a/editor/editor_sub_scene.h b/editor/editor_sub_scene.h
index 46cdceafa5..9739f49a45 100644
--- a/editor/editor_sub_scene.h
+++ b/editor/editor_sub_scene.h
@@ -29,14 +29,13 @@
#ifndef EDITOR_SUB_SCENE_H
#define EDITOR_SUB_SCENE_H
+#include "editor/editor_file_dialog.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
-#include "editor/editor_file_dialog.h"
class EditorSubScene : public ConfirmationDialog {
- GDCLASS(EditorSubScene,ConfirmationDialog);
-
+ GDCLASS(EditorSubScene, ConfirmationDialog);
LineEdit *path;
Tree *tree;
@@ -44,24 +43,20 @@ class EditorSubScene : public ConfirmationDialog {
EditorFileDialog *file_dialog;
- void _fill_tree(Node* p_node,TreeItem *p_parent);
- void _reown(Node* p_node,List<Node*> *p_to_reown);
+ void _fill_tree(Node *p_node, TreeItem *p_parent);
+ void _reown(Node *p_node, List<Node *> *p_to_reown);
void ok_pressed();
-
protected:
-
-
void _notification(int p_what);
static void _bind_methods();
void _path_browse();
- void _path_selected(const String& p_path);
- void _path_changed(const String& p_path);
+ void _path_selected(const String &p_path);
+ void _path_changed(const String &p_path);
public:
-
- void move(Node* p_new_parent, Node* p_new_owner);
+ void move(Node *p_new_parent, Node *p_new_owner);
void clear();
EditorSubScene();
};
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 7657996b81..adb4c8162e 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -28,47 +28,45 @@
/*************************************************************************/
#include "editor_themes.h"
-#include "editor_icons.h"
-#include "editor_fonts.h"
-#include "editor_settings.h"
#include "core/io/resource_loader.h"
+#include "editor_fonts.h"
+#include "editor_icons.h"
#include "editor_scale.h"
+#include "editor_settings.h"
-Ref<Theme> create_editor_theme()
-{
- Ref<Theme> theme = Ref<Theme>( memnew( Theme ) );
+Ref<Theme> create_editor_theme() {
+ Ref<Theme> theme = Ref<Theme>(memnew(Theme));
editor_register_fonts(theme);
editor_register_icons(theme);
- Ref<StyleBoxTexture> focus_sbt=memnew( StyleBoxTexture );
- focus_sbt->set_texture(theme->get_icon("EditorFocus","EditorIcons"));
- for(int i=0;i<4;i++) {
- focus_sbt->set_margin_size(Margin(i),16*EDSCALE);
- focus_sbt->set_default_margin(Margin(i),16*EDSCALE);
+ Ref<StyleBoxTexture> focus_sbt = memnew(StyleBoxTexture);
+ focus_sbt->set_texture(theme->get_icon("EditorFocus", "EditorIcons"));
+ for (int i = 0; i < 4; i++) {
+ focus_sbt->set_margin_size(Margin(i), 16 * EDSCALE);
+ focus_sbt->set_default_margin(Margin(i), 16 * EDSCALE);
}
focus_sbt->set_draw_center(false);
- theme->set_stylebox("EditorFocus","EditorStyles",focus_sbt);
- theme->set_color("prop_category","Editor",Color::hex(0x3f3a44ff));
- theme->set_color("prop_section","Editor",Color::hex(0x35313aff));
- theme->set_color("prop_subsection","Editor",Color::hex(0x312e37ff));
- theme->set_color("fg_selected","Editor",Color::html("ffbd8e8e"));
- theme->set_color("fg_error","Editor",Color::html("ffbd8e8e"));
+ theme->set_stylebox("EditorFocus", "EditorStyles", focus_sbt);
+ theme->set_color("prop_category", "Editor", Color::hex(0x3f3a44ff));
+ theme->set_color("prop_section", "Editor", Color::hex(0x35313aff));
+ theme->set_color("prop_subsection", "Editor", Color::hex(0x312e37ff));
+ theme->set_color("fg_selected", "Editor", Color::html("ffbd8e8e"));
+ theme->set_color("fg_error", "Editor", Color::html("ffbd8e8e"));
return theme;
}
-Ref<Theme> create_custom_theme()
-{
+Ref<Theme> create_custom_theme() {
Ref<Theme> theme;
String custom_theme = EditorSettings::get_singleton()->get("interface/custom_theme");
- if (custom_theme!="") {
+ if (custom_theme != "") {
theme = ResourceLoader::load(custom_theme);
}
String global_font = EditorSettings::get_singleton()->get("interface/custom_font");
- if (global_font!="") {
+ if (global_font != "") {
Ref<Font> fnt = ResourceLoader::load(global_font);
if (fnt.is_valid()) {
if (!theme.is_valid()) {
diff --git a/editor/file_type_cache.cpp b/editor/file_type_cache.cpp
index 891669db13..7db0182a37 100644
--- a/editor/file_type_cache.cpp
+++ b/editor/file_type_cache.cpp
@@ -31,32 +31,31 @@
#include "global_config.h"
#include "os/file_access.h"
-FileTypeCache* FileTypeCache::singleton=NULL;
+FileTypeCache *FileTypeCache::singleton = NULL;
-bool FileTypeCache::has_file(const String& p_path) const {
+bool FileTypeCache::has_file(const String &p_path) const {
GLOBAL_LOCK_FUNCTION
return file_type_map.has(p_path);
}
-String FileTypeCache::get_file_type(const String& p_path) const{
+String FileTypeCache::get_file_type(const String &p_path) const {
GLOBAL_LOCK_FUNCTION
- ERR_FAIL_COND_V(!file_type_map.has(p_path),"");
+ ERR_FAIL_COND_V(!file_type_map.has(p_path), "");
return file_type_map[p_path];
-
}
-void FileTypeCache::set_file_type(const String& p_path,const String& p_type){
+void FileTypeCache::set_file_type(const String &p_path, const String &p_type) {
GLOBAL_LOCK_FUNCTION
- file_type_map[p_path]=p_type;
+ file_type_map[p_path] = p_type;
}
void FileTypeCache::load() {
GLOBAL_LOCK_FUNCTION
- String project=GlobalConfig::get_singleton()->get_resource_path();
- FileAccess *f =FileAccess::open(project+"/file_type_cache.cch",FileAccess::READ);
+ String project = GlobalConfig::get_singleton()->get_resource_path();
+ FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::READ);
if (!f) {
@@ -65,44 +64,42 @@ void FileTypeCache::load() {
}
file_type_map.clear();
- while(!f->eof_reached()) {
+ while (!f->eof_reached()) {
- String path=f->get_line();
+ String path = f->get_line();
if (f->eof_reached())
break;
- String type=f->get_line();
- set_file_type(path,type);
+ String type = f->get_line();
+ set_file_type(path, type);
}
memdelete(f);
-
}
void FileTypeCache::save() {
GLOBAL_LOCK_FUNCTION
- String project=GlobalConfig::get_singleton()->get_resource_path();
- FileAccess *f =FileAccess::open(project+"/file_type_cache.cch",FileAccess::WRITE);
+ String project = GlobalConfig::get_singleton()->get_resource_path();
+ FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::WRITE);
if (!f) {
ERR_EXPLAIN(TTR("Can't open file_type_cache.cch for writing, not saving file type cache!"));
ERR_FAIL();
}
- const String *K=NULL;
+ const String *K = NULL;
- while((K=file_type_map.next(K))) {
+ while ((K = file_type_map.next(K))) {
f->store_line(*K);
f->store_line(file_type_map[*K]);
}
memdelete(f);
-
}
FileTypeCache::FileTypeCache() {
ERR_FAIL_COND(singleton);
- singleton=this;
+ singleton = this;
}
diff --git a/editor/file_type_cache.h b/editor/file_type_cache.h
index 25755f168c..fa2c7b46af 100644
--- a/editor/file_type_cache.h
+++ b/editor/file_type_cache.h
@@ -33,19 +33,18 @@
class FileTypeCache : Object {
- GDCLASS(FileTypeCache,Object);
+ GDCLASS(FileTypeCache, Object);
- HashMap<String,String> file_type_map;
+ HashMap<String, String> file_type_map;
+ static FileTypeCache *singleton;
- static FileTypeCache* singleton;
public:
+ static FileTypeCache *get_singleton() { return singleton; }
- static FileTypeCache* get_singleton() { return singleton; }
-
- bool has_file(const String& p_path) const;
- String get_file_type(const String& p_path) const;
- void set_file_type(const String& p_path,const String& p_type);
+ bool has_file(const String &p_path) const;
+ String get_file_type(const String &p_path) const;
+ void set_file_type(const String &p_path, const String &p_type);
void load();
void save();
@@ -53,6 +52,4 @@ public:
FileTypeCache();
};
-
-
#endif // FILE_TYPE_CACHE_H
diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp
index 2e5dbf6248..20a4809e36 100644
--- a/editor/fileserver/editor_file_server.cpp
+++ b/editor/fileserver/editor_file_server.cpp
@@ -28,12 +28,12 @@
/*************************************************************************/
#include "editor_file_server.h"
+#include "../editor_settings.h"
#include "io/marshalls.h"
#include "io/marshalls.h"
-#include "../editor_settings.h"
//#define DEBUG_PRINT(m_p) print_line(m_p)
-#define DEBUG_TIME(m_what) printf("MS: %s - %lli\n",m_what,OS::get_singleton()->get_ticks_usec());
+#define DEBUG_TIME(m_what) printf("MS: %s - %lli\n", m_what, OS::get_singleton()->get_ticks_usec());
//#define DEBUG_TIME(m_what)
@@ -43,59 +43,55 @@ void EditorFileServer::_close_client(ClientData *cd) {
cd->efs->wait_mutex->lock();
cd->efs->to_wait.insert(cd->thread);
cd->efs->wait_mutex->unlock();
- while(cd->files.size()) {
+ while (cd->files.size()) {
memdelete(cd->files.front()->get());
cd->files.erase(cd->files.front());
}
memdelete(cd);
-
}
-void EditorFileServer::_subthread_start(void*s) {
-
- ClientData *cd = (ClientData*)s;
+void EditorFileServer::_subthread_start(void *s) {
+ ClientData *cd = (ClientData *)s;
cd->connection->set_nodelay(true);
uint8_t buf4[8];
- Error err = cd->connection->get_data(buf4,4);
- if (err!=OK) {
+ Error err = cd->connection->get_data(buf4, 4);
+ if (err != OK) {
_close_client(cd);
- ERR_FAIL_COND(err!=OK);
+ ERR_FAIL_COND(err != OK);
}
+ int passlen = decode_uint32(buf4);
-
- int passlen=decode_uint32(buf4);
-
- if (passlen>512) {
+ if (passlen > 512) {
_close_client(cd);
- ERR_FAIL_COND(passlen>512);
- } else if (passlen>0) {
+ ERR_FAIL_COND(passlen > 512);
+ } else if (passlen > 0) {
Vector<char> passutf8;
- passutf8.resize(passlen+1);
- err = cd->connection->get_data((uint8_t*)passutf8.ptr(),passlen);
- if (err!=OK) {
+ passutf8.resize(passlen + 1);
+ err = cd->connection->get_data((uint8_t *)passutf8.ptr(), passlen);
+ if (err != OK) {
_close_client(cd);
- ERR_FAIL_COND(err!=OK);
+ ERR_FAIL_COND(err != OK);
}
- passutf8[passlen]=0;
+ passutf8[passlen] = 0;
String s;
s.parse_utf8(passutf8.ptr());
- if (s!=cd->efs->password) {
- encode_uint32(ERR_INVALID_DATA,buf4);
- cd->connection->put_data(buf4,4);
+ if (s != cd->efs->password) {
+ encode_uint32(ERR_INVALID_DATA, buf4);
+ cd->connection->put_data(buf4, 4);
OS::get_singleton()->delay_usec(1000000);
_close_client(cd);
ERR_PRINT("CLIENT PASSWORD MISMATCH");
ERR_FAIL();
}
} else {
- if (cd->efs->password!="") {
- encode_uint32(ERR_INVALID_DATA,buf4);
- cd->connection->put_data(buf4,4);
+ if (cd->efs->password != "") {
+ encode_uint32(ERR_INVALID_DATA, buf4);
+ cd->connection->put_data(buf4, 4);
OS::get_singleton()->delay_usec(1000000);
_close_client(cd);
ERR_PRINT("CLIENT PASSWORD MISMATCH (should be empty!)");
@@ -103,163 +99,161 @@ void EditorFileServer::_subthread_start(void*s) {
}
}
- encode_uint32(OK,buf4);
- cd->connection->put_data(buf4,4);
+ encode_uint32(OK, buf4);
+ cd->connection->put_data(buf4, 4);
- while(!cd->quit) {
+ while (!cd->quit) {
//wait for ID
- err = cd->connection->get_data(buf4,4);
+ err = cd->connection->get_data(buf4, 4);
//#define DEBUG_PRINT(m_p) print_line(m_p)
DEBUG_TIME("get_data")
- if (err!=OK) {
+ if (err != OK) {
_close_client(cd);
- ERR_FAIL_COND(err!=OK);
+ ERR_FAIL_COND(err != OK);
}
- int id=decode_uint32(buf4);
+ int id = decode_uint32(buf4);
//wait for command
- err = cd->connection->get_data(buf4,4);
- if (err!=OK) {
+ err = cd->connection->get_data(buf4, 4);
+ if (err != OK) {
_close_client(cd);
- ERR_FAIL_COND(err!=OK);
+ ERR_FAIL_COND(err != OK);
}
- int cmd=decode_uint32(buf4);
+ int cmd = decode_uint32(buf4);
- switch(cmd) {
+ switch (cmd) {
case FileAccessNetwork::COMMAND_FILE_EXISTS:
case FileAccessNetwork::COMMAND_GET_MODTIME:
case FileAccessNetwork::COMMAND_OPEN_FILE: {
DEBUG_TIME("open_file")
- err = cd->connection->get_data(buf4,4);
- if (err!=OK) {
+ err = cd->connection->get_data(buf4, 4);
+ if (err != OK) {
_close_client(cd);
- ERR_FAIL_COND(err!=OK);
+ ERR_FAIL_COND(err != OK);
}
- int namelen=decode_uint32(buf4);
+ int namelen = decode_uint32(buf4);
Vector<char> fileutf8;
- fileutf8.resize(namelen+1);
- err = cd->connection->get_data((uint8_t*)fileutf8.ptr(),namelen);
- if (err!=OK) {
+ fileutf8.resize(namelen + 1);
+ err = cd->connection->get_data((uint8_t *)fileutf8.ptr(), namelen);
+ if (err != OK) {
_close_client(cd);
- ERR_FAIL_COND(err!=OK);
+ ERR_FAIL_COND(err != OK);
}
- fileutf8[namelen]=0;
+ fileutf8[namelen] = 0;
String s;
s.parse_utf8(fileutf8.ptr());
- if (cmd==FileAccessNetwork::COMMAND_FILE_EXISTS) {
- print_line("FILE EXISTS: "+s);
+ if (cmd == FileAccessNetwork::COMMAND_FILE_EXISTS) {
+ print_line("FILE EXISTS: " + s);
}
- if (cmd==FileAccessNetwork::COMMAND_GET_MODTIME) {
- print_line("MOD TIME: "+s);
+ if (cmd == FileAccessNetwork::COMMAND_GET_MODTIME) {
+ print_line("MOD TIME: " + s);
}
- if (cmd==FileAccessNetwork::COMMAND_OPEN_FILE) {
- print_line("OPEN: "+s);
+ if (cmd == FileAccessNetwork::COMMAND_OPEN_FILE) {
+ print_line("OPEN: " + s);
}
- if ( !s.begins_with("res://")) {
+ if (!s.begins_with("res://")) {
_close_client(cd);
ERR_FAIL_COND(!s.begins_with("res://"));
}
ERR_CONTINUE(cd->files.has(id));
- if (cmd==FileAccessNetwork::COMMAND_FILE_EXISTS) {
+ if (cmd == FileAccessNetwork::COMMAND_FILE_EXISTS) {
- encode_uint32(id,buf4);
- cd->connection->put_data(buf4,4);
- encode_uint32(FileAccessNetwork::RESPONSE_FILE_EXISTS,buf4);
- cd->connection->put_data(buf4,4);
- encode_uint32(FileAccess::exists(s),buf4);
- cd->connection->put_data(buf4,4);
+ encode_uint32(id, buf4);
+ cd->connection->put_data(buf4, 4);
+ encode_uint32(FileAccessNetwork::RESPONSE_FILE_EXISTS, buf4);
+ cd->connection->put_data(buf4, 4);
+ encode_uint32(FileAccess::exists(s), buf4);
+ cd->connection->put_data(buf4, 4);
DEBUG_TIME("open_file_end")
break;
}
- if (cmd==FileAccessNetwork::COMMAND_GET_MODTIME) {
+ if (cmd == FileAccessNetwork::COMMAND_GET_MODTIME) {
- encode_uint32(id,buf4);
- cd->connection->put_data(buf4,4);
- encode_uint32(FileAccessNetwork::RESPONSE_GET_MODTIME,buf4);
- cd->connection->put_data(buf4,4);
- encode_uint64(FileAccess::get_modified_time(s),buf4);
- cd->connection->put_data(buf4,8);
+ encode_uint32(id, buf4);
+ cd->connection->put_data(buf4, 4);
+ encode_uint32(FileAccessNetwork::RESPONSE_GET_MODTIME, buf4);
+ cd->connection->put_data(buf4, 4);
+ encode_uint64(FileAccess::get_modified_time(s), buf4);
+ cd->connection->put_data(buf4, 8);
DEBUG_TIME("open_file_end")
break;
}
- FileAccess *fa = FileAccess::open(s,FileAccess::READ);
+ FileAccess *fa = FileAccess::open(s, FileAccess::READ);
if (!fa) {
//not found, continue
- encode_uint32(id,buf4);
- cd->connection->put_data(buf4,4);
- encode_uint32(FileAccessNetwork::RESPONSE_OPEN,buf4);
- cd->connection->put_data(buf4,4);
- encode_uint32(ERR_FILE_NOT_FOUND,buf4);
- cd->connection->put_data(buf4,4);
+ encode_uint32(id, buf4);
+ cd->connection->put_data(buf4, 4);
+ encode_uint32(FileAccessNetwork::RESPONSE_OPEN, buf4);
+ cd->connection->put_data(buf4, 4);
+ encode_uint32(ERR_FILE_NOT_FOUND, buf4);
+ cd->connection->put_data(buf4, 4);
DEBUG_TIME("open_file_end")
break;
-
}
- encode_uint32(id,buf4);
- cd->connection->put_data(buf4,4);
- encode_uint32(FileAccessNetwork::RESPONSE_OPEN,buf4);
- cd->connection->put_data(buf4,4);
- encode_uint32(OK,buf4);
- cd->connection->put_data(buf4,4);
- encode_uint64(fa->get_len(),buf4);
- cd->connection->put_data(buf4,8);
+ encode_uint32(id, buf4);
+ cd->connection->put_data(buf4, 4);
+ encode_uint32(FileAccessNetwork::RESPONSE_OPEN, buf4);
+ cd->connection->put_data(buf4, 4);
+ encode_uint32(OK, buf4);
+ cd->connection->put_data(buf4, 4);
+ encode_uint64(fa->get_len(), buf4);
+ cd->connection->put_data(buf4, 8);
- cd->files[id]=fa;
+ cd->files[id] = fa;
DEBUG_TIME("open_file_end")
} break;
case FileAccessNetwork::COMMAND_READ_BLOCK: {
- err = cd->connection->get_data(buf4,8);
- if (err!=OK) {
+ err = cd->connection->get_data(buf4, 8);
+ if (err != OK) {
_close_client(cd);
- ERR_FAIL_COND(err!=OK);
+ ERR_FAIL_COND(err != OK);
}
ERR_CONTINUE(!cd->files.has(id));
uint64_t offset = decode_uint64(buf4);
- err = cd->connection->get_data(buf4,4);
- if (err!=OK) {
+ err = cd->connection->get_data(buf4, 4);
+ if (err != OK) {
_close_client(cd);
- ERR_FAIL_COND(err!=OK);
+ ERR_FAIL_COND(err != OK);
}
- int blocklen=decode_uint32(buf4);
- ERR_CONTINUE(blocklen > (16*1024*1024));
+ int blocklen = decode_uint32(buf4);
+ ERR_CONTINUE(blocklen > (16 * 1024 * 1024));
cd->files[id]->seek(offset);
Vector<uint8_t> buf;
buf.resize(blocklen);
- int read = cd->files[id]->get_buffer(buf.ptr(),blocklen);
- ERR_CONTINUE(read<0);
+ int read = cd->files[id]->get_buffer(buf.ptr(), blocklen);
+ ERR_CONTINUE(read < 0);
- print_line("GET BLOCK - offset: "+itos(offset)+", blocklen: "+itos(blocklen));
+ print_line("GET BLOCK - offset: " + itos(offset) + ", blocklen: " + itos(blocklen));
//not found, continue
- encode_uint32(id,buf4);
- cd->connection->put_data(buf4,4);
- encode_uint32(FileAccessNetwork::RESPONSE_DATA,buf4);
- cd->connection->put_data(buf4,4);
- encode_uint64(offset,buf4);
- cd->connection->put_data(buf4,8);
- encode_uint32(read,buf4);
- cd->connection->put_data(buf4,4);
- cd->connection->put_data(buf.ptr(),read);
-
+ encode_uint32(id, buf4);
+ cd->connection->put_data(buf4, 4);
+ encode_uint32(FileAccessNetwork::RESPONSE_DATA, buf4);
+ cd->connection->put_data(buf4, 4);
+ encode_uint64(offset, buf4);
+ cd->connection->put_data(buf4, 8);
+ encode_uint32(read, buf4);
+ cd->connection->put_data(buf4, 4);
+ cd->connection->put_data(buf.ptr(), read);
} break;
case FileAccessNetwork::COMMAND_CLOSE: {
@@ -273,31 +267,30 @@ void EditorFileServer::_subthread_start(void*s) {
}
_close_client(cd);
-
}
-void EditorFileServer::_thread_start(void*s) {
+void EditorFileServer::_thread_start(void *s) {
- EditorFileServer *self=(EditorFileServer*)s;
- while(!self->quit) {
+ EditorFileServer *self = (EditorFileServer *)s;
+ while (!self->quit) {
- if (self->cmd==CMD_ACTIVATE) {
+ if (self->cmd == CMD_ACTIVATE) {
self->server->listen(self->port);
- self->active=true;
- self->cmd=CMD_NONE;
- } else if (self->cmd==CMD_STOP) {
+ self->active = true;
+ self->cmd = CMD_NONE;
+ } else if (self->cmd == CMD_STOP) {
self->server->stop();
- self->active=false;
- self->cmd=CMD_NONE;
+ self->active = false;
+ self->cmd = CMD_NONE;
}
if (self->active) {
if (self->server->is_connection_available()) {
- ClientData *cd = memnew( ClientData);
- cd->connection=self->server->take_connection();
- cd->efs=self;
- cd->quit=false;
- cd->thread=Thread::create(_subthread_start,cd);
+ ClientData *cd = memnew(ClientData);
+ cd->connection = self->server->take_connection();
+ cd->efs = self;
+ cd->quit = false;
+ cd->thread = Thread::create(_subthread_start, cd);
}
}
@@ -314,18 +307,14 @@ void EditorFileServer::_thread_start(void*s) {
OS::get_singleton()->delay_usec(100000);
}
-
-
}
void EditorFileServer::start() {
-
stop();
- port=EDITOR_DEF("filesystem/file_server/port",6010);
- password=EDITOR_DEF("filesystem/file_server/password","");
- cmd=CMD_ACTIVATE;
-
+ port = EDITOR_DEF("filesystem/file_server/port", 6010);
+ password = EDITOR_DEF("filesystem/file_server/password", "");
+ cmd = CMD_ACTIVATE;
}
bool EditorFileServer::is_active() const {
@@ -333,28 +322,27 @@ bool EditorFileServer::is_active() const {
return active;
}
-void EditorFileServer::stop(){
+void EditorFileServer::stop() {
- cmd=CMD_STOP;
+ cmd = CMD_STOP;
}
EditorFileServer::EditorFileServer() {
server = TCP_Server::create_ref();
wait_mutex = Mutex::create();
- quit=false;
- active=false;
- cmd=CMD_NONE;
- thread=Thread::create(_thread_start,this);
+ quit = false;
+ active = false;
+ cmd = CMD_NONE;
+ thread = Thread::create(_thread_start, this);
- EDITOR_DEF("filesystem/file_server/port",6010);
- EDITOR_DEF("filesystem/file_server/password","");
+ EDITOR_DEF("filesystem/file_server/port", 6010);
+ EDITOR_DEF("filesystem/file_server/password", "");
}
EditorFileServer::~EditorFileServer() {
-
- quit=true;
+ quit = true;
Thread::wait_to_finish(thread);
memdelete(thread);
memdelete(wait_mutex);
diff --git a/editor/fileserver/editor_file_server.h b/editor/fileserver/editor_file_server.h
index 31f8ae84b8..cf97f685f7 100644
--- a/editor/fileserver/editor_file_server.h
+++ b/editor/fileserver/editor_file_server.h
@@ -29,15 +29,15 @@
#ifndef EDITOR_FILE_SERVER_H
#define EDITOR_FILE_SERVER_H
+#include "io/file_access_network.h"
+#include "io/packet_peer.h"
+#include "io/tcp_server.h"
#include "object.h"
#include "os/thread.h"
-#include "io/tcp_server.h"
-#include "io/packet_peer.h"
-#include "io/file_access_network.h"
class EditorFileServer : public Object {
- GDCLASS(EditorFileServer,Object);
+ GDCLASS(EditorFileServer, Object);
enum Command {
CMD_NONE,
@@ -45,26 +45,24 @@ class EditorFileServer : public Object {
CMD_STOP,
};
-
struct ClientData {
Thread *thread;
Ref<StreamPeerTCP> connection;
- Map<int,FileAccess*> files;
+ Map<int, FileAccess *> files;
EditorFileServer *efs;
bool quit;
-
};
Ref<TCP_Server> server;
- Set<Thread*> to_wait;
+ Set<Thread *> to_wait;
static void _close_client(ClientData *cd);
- static void _subthread_start(void*s);
+ static void _subthread_start(void *s);
Mutex *wait_mutex;
Thread *thread;
- static void _thread_start(void*);
+ static void _thread_start(void *);
bool quit;
Command cmd;
@@ -72,9 +70,7 @@ class EditorFileServer : public Object {
int port;
bool active;
-
public:
-
void start();
void stop();
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index bce0e9148a..fe1f984f39 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -28,101 +28,97 @@
/*************************************************************************/
#include "filesystem_dock.h"
-#include "os/dir_access.h"
-#include "os/file_access.h"
+#include "editor_node.h"
+#include "editor_settings.h"
#include "global_config.h"
#include "io/resource_loader.h"
+#include "os/dir_access.h"
+#include "os/file_access.h"
#include "os/os.h"
-#include "editor_node.h"
-#include "editor_settings.h"
#include "scene/main/viewport.h"
-bool FileSystemDock::_create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir) {
+bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir) {
TreeItem *item = tree->create_item(p_parent);
- String dname=p_dir->get_name();
- if (dname=="")
- dname="res://";
+ String dname = p_dir->get_name();
+ if (dname == "")
+ dname = "res://";
else {
// collapse every tree item but the root folder
item->set_collapsed(true);
}
- item->set_text(0,dname);
- item->set_icon(0,get_icon("Folder","EditorIcons"));
- item->set_selectable(0,true);
+ item->set_text(0, dname);
+ item->set_icon(0, get_icon("Folder", "EditorIcons"));
+ item->set_selectable(0, true);
String lpath = p_dir->get_path();
- if (lpath!="res://" && lpath.ends_with("/")) {
- lpath=lpath.substr(0,lpath.length()-1);
+ if (lpath != "res://" && lpath.ends_with("/")) {
+ lpath = lpath.substr(0, lpath.length() - 1);
}
- item->set_metadata(0,lpath);
- if (lpath==path) {
+ item->set_metadata(0, lpath);
+ if (lpath == path) {
item->select(0);
}
- for(int i=0;i<p_dir->get_subdir_count();i++)
- _create_tree(item,p_dir->get_subdir(i));
+ for (int i = 0; i < p_dir->get_subdir_count(); i++)
+ _create_tree(item, p_dir->get_subdir(i));
return true;
}
-
void FileSystemDock::_update_tree() {
tree->clear();
- updating_tree=true;
+ updating_tree = true;
TreeItem *root = tree->create_item();
TreeItem *favorites = tree->create_item(root);
- favorites->set_icon(0, get_icon("Favorites","EditorIcons") );
- favorites->set_text(0,TTR("Favorites:"));
- favorites->set_selectable(0,false);
- Vector<String> faves = EditorSettings::get_singleton()->get_favorite_dirs();
- for(int i=0;i<faves.size();i++) {
+ favorites->set_icon(0, get_icon("Favorites", "EditorIcons"));
+ favorites->set_text(0, TTR("Favorites:"));
+ favorites->set_selectable(0, false);
+ Vector<String> faves = EditorSettings::get_singleton()->get_favorite_dirs();
+ for (int i = 0; i < faves.size(); i++) {
if (!faves[i].begins_with("res://"))
continue;
TreeItem *ti = tree->create_item(favorites);
String fv = faves[i];
- if (fv=="res://")
- ti->set_text(0,"/");
+ if (fv == "res://")
+ ti->set_text(0, "/");
else
- ti->set_text(0,faves[i].get_file());
- ti->set_icon(0,get_icon("Folder","EditorIcons"));
- ti->set_selectable(0,true);
- ti->set_metadata(0,faves[i]);
+ ti->set_text(0, faves[i].get_file());
+ ti->set_icon(0, get_icon("Folder", "EditorIcons"));
+ ti->set_selectable(0, true);
+ ti->set_metadata(0, faves[i]);
}
- _create_tree(root,EditorFileSystem::get_singleton()->get_filesystem());
- updating_tree=false;
-
+ _create_tree(root, EditorFileSystem::get_singleton()->get_filesystem());
+ updating_tree = false;
}
-
void FileSystemDock::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_RESIZED: {
+ bool new_mode = get_size().height < get_viewport_rect().size.height * 3 / 4;
- bool new_mode = get_size().height < get_viewport_rect().size.height*3/4;
-
- if (new_mode != split_mode ) {
+ if (new_mode != split_mode) {
- split_mode=new_mode;
+ split_mode = new_mode;
//print_line("SPLIT MODE? "+itos(split_mode));
if (split_mode) {
file_list_vb->hide();
- tree->set_custom_minimum_size(Size2(0,0));
+ tree->set_custom_minimum_size(Size2(0, 0));
tree->set_v_size_flags(SIZE_EXPAND_FILL);
button_back->show();
} else {
tree->show();
file_list_vb->show();
- tree->set_custom_minimum_size(Size2(0,200)*EDSCALE);
+ tree->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
tree->set_v_size_flags(SIZE_FILL);
button_back->hide();
if (!EditorFileSystem::get_singleton()->is_scanning()) {
@@ -131,42 +127,40 @@ void FileSystemDock::_notification(int p_what) {
}
}
-
} break;
case NOTIFICATION_ENTER_TREE: {
if (initialized)
return;
- initialized=true;
+ initialized = true;
- EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_fs_changed");
- EditorResourcePreview::get_singleton()->connect("preview_invalidated",this,"_preview_invalidated");
+ EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_fs_changed");
+ EditorResourcePreview::get_singleton()->connect("preview_invalidated", this, "_preview_invalidated");
- button_reload->set_icon( get_icon("Reload","EditorIcons"));
- button_favorite->set_icon( get_icon("Favorites","EditorIcons"));
+ button_reload->set_icon(get_icon("Reload", "EditorIcons"));
+ button_favorite->set_icon(get_icon("Favorites", "EditorIcons"));
//button_instance->set_icon( get_icon("Add","EditorIcons"));
//button_open->set_icon( get_icon("Folder","EditorIcons"));
- button_back->set_icon( get_icon("Filesystem","EditorIcons"));
+ button_back->set_icon(get_icon("Filesystem", "EditorIcons"));
if (display_mode == DISPLAY_THUMBNAILS) {
- button_display_mode->set_icon(get_icon("FileList","EditorIcons"));
+ button_display_mode->set_icon(get_icon("FileList", "EditorIcons"));
} else {
- button_display_mode->set_icon(get_icon("FileThumbnail","EditorIcons"));
+ button_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons"));
}
- button_display_mode->connect("pressed",this,"_change_file_display");
+ button_display_mode->connect("pressed", this, "_change_file_display");
//file_options->set_icon( get_icon("Tools","EditorIcons"));
- files->connect("item_activated",this,"_select_file");
- button_hist_next->connect("pressed",this,"_fw_history");
- button_hist_prev->connect("pressed",this,"_bw_history");
- search_icon->set_texture( get_icon("Zoom","EditorIcons"));
-
- button_hist_next->set_icon( get_icon("Forward","EditorIcons"));
- button_hist_prev->set_icon( get_icon("Back","EditorIcons"));
- file_options->connect("id_pressed",this,"_file_option");
- folder_options->connect("id_pressed",this,"_folder_option");
-
-
- button_back->connect("pressed",this,"_go_to_tree",varray(),CONNECT_DEFERRED);
- current_path->connect("text_entered",this,"_go_to_dir");
+ files->connect("item_activated", this, "_select_file");
+ button_hist_next->connect("pressed", this, "_fw_history");
+ button_hist_prev->connect("pressed", this, "_bw_history");
+ search_icon->set_texture(get_icon("Zoom", "EditorIcons"));
+
+ button_hist_next->set_icon(get_icon("Forward", "EditorIcons"));
+ button_hist_prev->set_icon(get_icon("Back", "EditorIcons"));
+ file_options->connect("id_pressed", this, "_file_option");
+ folder_options->connect("id_pressed", this, "_folder_option");
+
+ button_back->connect("pressed", this, "_go_to_tree", varray(), CONNECT_DEFERRED);
+ current_path->connect("text_entered", this, "_go_to_dir");
_update_tree(); //maybe it finished already
if (EditorFileSystem::get_singleton()->is_scanning()) {
@@ -176,7 +170,7 @@ void FileSystemDock::_notification(int p_what) {
} break;
case NOTIFICATION_PROCESS: {
if (EditorFileSystem::get_singleton()->is_scanning()) {
- scanning_progress->set_value(EditorFileSystem::get_singleton()->get_scanning_progress()*100);
+ scanning_progress->set_value(EditorFileSystem::get_singleton()->get_scanning_progress() * 100);
}
} break;
case NOTIFICATION_EXIT_TREE: {
@@ -185,16 +179,15 @@ void FileSystemDock::_notification(int p_what) {
case NOTIFICATION_DRAG_BEGIN: {
Dictionary dd = get_viewport()->gui_get_drag_data();
- if (tree->is_visible_in_tree() && dd.has("type") ) {
- if ( (String(dd["type"])=="files") || (String(dd["type"])=="files_and_dirs") || (String(dd["type"])=="resource")) {
+ if (tree->is_visible_in_tree() && dd.has("type")) {
+ if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) {
tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
}
- if ( (String(dd["type"])=="favorite") ) {
+ if ((String(dd["type"]) == "favorite")) {
tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
}
}
-
} break;
case NOTIFICATION_DRAG_END: {
@@ -212,65 +205,57 @@ void FileSystemDock::_notification(int p_what) {
}
} break;
}
-
}
-
-
-
void FileSystemDock::_dir_selected() {
TreeItem *ti = tree->get_selected();
if (!ti)
return;
String dir = ti->get_metadata(0);
- bool found=false;
+ bool found = false;
Vector<String> favorites = EditorSettings::get_singleton()->get_favorite_dirs();
- for(int i=0;i<favorites.size();i++) {
+ for (int i = 0; i < favorites.size(); i++) {
- if (favorites[i]==dir) {
- found=true;
+ if (favorites[i] == dir) {
+ found = true;
break;
}
}
-
button_favorite->set_pressed(found);
if (!split_mode) {
_open_pressed(); //go directly to dir
}
-
}
-
void FileSystemDock::_favorites_pressed() {
TreeItem *sel = tree->get_selected();
if (!sel)
- return ;
+ return;
String dir = sel->get_metadata(0);
int idx = -1;
Vector<String> favorites = EditorSettings::get_singleton()->get_favorite_dirs();
- for(int i=0;i<favorites.size();i++) {
+ for (int i = 0; i < favorites.size(); i++) {
- if (favorites[i]==dir) {
- idx=i;
+ if (favorites[i] == dir) {
+ idx = i;
break;
}
}
- if (button_favorite->is_pressed() && idx==-1) {
+ if (button_favorite->is_pressed() && idx == -1) {
favorites.push_back(dir);
EditorSettings::get_singleton()->set_favorite_dirs(favorites);
_update_tree();
- } else if (!button_favorite->is_pressed() && idx!=-1) {
+ } else if (!button_favorite->is_pressed() && idx != -1) {
favorites.remove(idx);
EditorSettings::get_singleton()->set_favorite_dirs(favorites);
_update_tree();
}
-
}
String FileSystemDock::get_selected_path() const {
@@ -279,7 +264,7 @@ String FileSystemDock::get_selected_path() const {
if (!sel)
return "";
String path = sel->get_metadata(0);
- return "res://"+path;
+ return "res://" + path;
}
String FileSystemDock::get_current_path() const {
@@ -287,22 +272,22 @@ String FileSystemDock::get_current_path() const {
return path;
}
-void FileSystemDock::navigate_to_path(const String& p_path) {
+void FileSystemDock::navigate_to_path(const String &p_path) {
// If the path is a file, do not only go to the directory in the tree, also select the file in the file list.
- String dir_path="";
- String file_name="";
- DirAccess* dirAccess=DirAccess::open("res://");
+ String dir_path = "";
+ String file_name = "";
+ DirAccess *dirAccess = DirAccess::open("res://");
if (dirAccess->file_exists(p_path)) {
- dir_path=p_path.get_base_dir();
- file_name=p_path.get_file();
+ dir_path = p_path.get_base_dir();
+ file_name = p_path.get_file();
} else if (dirAccess->dir_exists(p_path)) {
- dir_path=p_path;
+ dir_path = p_path;
} else {
ERR_EXPLAIN(TTR("Cannot navigate to '" + p_path + "' as it has not been found in the file system!"));
ERR_FAIL();
}
- path=dir_path;
+ path = dir_path;
_update_tree();
tree->ensure_cursor_is_visible();
@@ -310,9 +295,9 @@ void FileSystemDock::navigate_to_path(const String& p_path) {
_open_pressed(); // Seems to be the only way to get into the file view. This also pushes to history.
// Focus the given file.
- for (int i=0; i<files->get_item_count(); i++) {
+ for (int i = 0; i < files->get_item_count(); i++) {
if (files->get_item_text(i) == file_name) {
- files->select(i,true);
+ files->select(i, true);
files->ensure_current_is_visible();
break;
}
@@ -320,42 +305,40 @@ void FileSystemDock::navigate_to_path(const String& p_path) {
}
}
-void FileSystemDock::_thumbnail_done(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata) {
+void FileSystemDock::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata) {
- bool valid=false;
+ bool valid = false;
if (search_box->is_visible()) {
- valid=true;
+ valid = true;
} else {
- valid=(path==p_path.get_base_dir());
+ valid = (path == p_path.get_base_dir());
}
if (p_preview.is_valid() && valid) {
- Array uarr=p_udata;
- int idx=uarr[0];
- String file=uarr[1];
- if (idx>=files->get_item_count())
+ Array uarr = p_udata;
+ int idx = uarr[0];
+ String file = uarr[1];
+ if (idx >= files->get_item_count())
return;
- if (files->get_item_text(idx)!=file)
+ if (files->get_item_text(idx) != file)
return;
String fpath = files->get_item_metadata(idx);
- if (fpath!=p_path)
+ if (fpath != p_path)
return;
- files->set_item_icon(idx,p_preview);
-
+ files->set_item_icon(idx, p_preview);
}
-
}
void FileSystemDock::_change_file_display() {
if (button_display_mode->is_pressed()) {
display_mode = DISPLAY_LIST;
- button_display_mode->set_icon( get_icon("FileThumbnail","EditorIcons"));
+ button_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons"));
} else {
display_mode = DISPLAY_THUMBNAILS;
- button_display_mode->set_icon( get_icon("FileList","EditorIcons"));
+ button_display_mode->set_icon(get_icon("FileList", "EditorIcons"));
}
EditorSettings::get_singleton()->set("docks/filesystem/display_mode", display_mode);
@@ -363,32 +346,30 @@ void FileSystemDock::_change_file_display() {
_update_files(true);
}
-void FileSystemDock::_search(EditorFileSystemDirectory *p_path,List<FileInfo>* matches,int p_max_items) {
+void FileSystemDock::_search(EditorFileSystemDirectory *p_path, List<FileInfo> *matches, int p_max_items) {
- if (matches->size()>p_max_items)
+ if (matches->size() > p_max_items)
return;
- for(int i=0;i<p_path->get_subdir_count();i++) {
- _search(p_path->get_subdir(i),matches,p_max_items);
-
+ for (int i = 0; i < p_path->get_subdir_count(); i++) {
+ _search(p_path->get_subdir(i), matches, p_max_items);
}
String match = search_box->get_text();
- for(int i=0;i<p_path->get_file_count();i++) {
+ for (int i = 0; i < p_path->get_file_count(); i++) {
String file = p_path->get_file(i);
- if (file.find(match)!=-1) {
+ if (file.find(match) != -1) {
FileInfo fi;
- fi.name=file;
- fi.type=p_path->get_file_type(i);
- fi.path=p_path->get_file_path(i);
- fi.import_status=0;
-
+ fi.name = file;
+ fi.type = p_path->get_file_type(i);
+ fi.path = p_path->get_file_path(i);
+ fi.import_status = 0;
matches->push_back(fi);
- if (matches->size()>p_max_items)
+ if (matches->size() > p_max_items)
return;
}
}
@@ -400,7 +381,7 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
if (p_keep_selection) {
- for(int i=0;i<files->get_item_count();i++) {
+ for (int i = 0; i < files->get_item_count(); i++) {
if (files->is_selected(i))
cselection.insert(files->get_item_text(i));
@@ -411,48 +392,47 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
current_path->set_text(path);
-
EditorFileSystemDirectory *efd = EditorFileSystem::get_singleton()->get_filesystem_path(path);
if (!efd)
return;
int thumbnail_size = EditorSettings::get_singleton()->get("docks/filesystem/thumbnail_size");
- thumbnail_size*=EDSCALE;
+ thumbnail_size *= EDSCALE;
Ref<Texture> folder_thumbnail;
Ref<Texture> file_thumbnail;
bool use_thumbnails = (display_mode == DISPLAY_THUMBNAILS);
- bool use_folders = search_box->get_text().length()==0 && split_mode;
+ bool use_folders = search_box->get_text().length() == 0 && split_mode;
if (use_thumbnails) { //thumbnails
files->set_max_columns(0);
files->set_icon_mode(ItemList::ICON_MODE_TOP);
- files->set_fixed_column_width(thumbnail_size*3/2);
+ files->set_fixed_column_width(thumbnail_size * 3 / 2);
files->set_max_text_lines(2);
- files->set_fixed_icon_size(Size2(thumbnail_size,thumbnail_size));
+ files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
- if (!has_icon("ResizedFolder","EditorIcons")) {
- Ref<ImageTexture> folder = get_icon("FolderBig","EditorIcons");
+ if (!has_icon("ResizedFolder", "EditorIcons")) {
+ Ref<ImageTexture> folder = get_icon("FolderBig", "EditorIcons");
Image img = folder->get_data();
- img.resize(thumbnail_size,thumbnail_size);
- Ref<ImageTexture> resized_folder = Ref<ImageTexture>( memnew( ImageTexture));
- resized_folder->create_from_image(img,0);
- Theme::get_default()->set_icon("ResizedFolder","EditorIcons",resized_folder);
+ img.resize(thumbnail_size, thumbnail_size);
+ Ref<ImageTexture> resized_folder = Ref<ImageTexture>(memnew(ImageTexture));
+ resized_folder->create_from_image(img, 0);
+ Theme::get_default()->set_icon("ResizedFolder", "EditorIcons", resized_folder);
}
- folder_thumbnail = get_icon("ResizedFolder","EditorIcons");
+ folder_thumbnail = get_icon("ResizedFolder", "EditorIcons");
- if (!has_icon("ResizedFile","EditorIcons")) {
- Ref<ImageTexture> file = get_icon("FileBig","EditorIcons");
+ if (!has_icon("ResizedFile", "EditorIcons")) {
+ Ref<ImageTexture> file = get_icon("FileBig", "EditorIcons");
Image img = file->get_data();
- img.resize(thumbnail_size,thumbnail_size);
- Ref<ImageTexture> resized_file = Ref<ImageTexture>( memnew( ImageTexture));
- resized_file->create_from_image(img,0);
- Theme::get_default()->set_icon("ResizedFile","EditorIcons",resized_file);
+ img.resize(thumbnail_size, thumbnail_size);
+ Ref<ImageTexture> resized_file = Ref<ImageTexture>(memnew(ImageTexture));
+ resized_file->create_from_image(img, 0);
+ Theme::get_default()->set_icon("ResizedFile", "EditorIcons", resized_file);
}
- file_thumbnail = get_icon("ResizedFile","EditorIcons");
+ file_thumbnail = get_icon("ResizedFile", "EditorIcons");
} else {
@@ -461,137 +441,124 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
files->set_max_text_lines(1);
files->set_fixed_column_width(0);
files->set_fixed_icon_size(Size2());
-
}
if (use_folders) {
- if (path!="res://") {
+ if (path != "res://") {
if (use_thumbnails) {
- files->add_item("..",folder_thumbnail,true);
+ files->add_item("..", folder_thumbnail, true);
} else {
- files->add_item("..",get_icon("folder","FileDialog"),true);
+ files->add_item("..", get_icon("folder", "FileDialog"), true);
}
String bd = path.get_base_dir();
- if (bd!="res://" && !bd.ends_with("/"))
- bd+="/";
+ if (bd != "res://" && !bd.ends_with("/"))
+ bd += "/";
- files->set_item_metadata(files->get_item_count()-1,bd);
+ files->set_item_metadata(files->get_item_count() - 1, bd);
}
- for(int i=0;i<efd->get_subdir_count();i++) {
-
- String dname=efd->get_subdir(i)->get_name();
+ for (int i = 0; i < efd->get_subdir_count(); i++) {
+ String dname = efd->get_subdir(i)->get_name();
if (use_thumbnails) {
- files->add_item(dname,folder_thumbnail,true);
+ files->add_item(dname, folder_thumbnail, true);
} else {
- files->add_item(dname,get_icon("folder","FileDialog"),true);
+ files->add_item(dname, get_icon("folder", "FileDialog"), true);
}
- files->set_item_metadata(files->get_item_count()-1,path.plus_file(dname)+"/");
+ files->set_item_metadata(files->get_item_count() - 1, path.plus_file(dname) + "/");
if (cselection.has(dname))
- files->select(files->get_item_count()-1,false);
+ files->select(files->get_item_count() - 1, false);
}
}
-
List<FileInfo> filelist;
if (search_box->get_text().length()) {
- if (search_box->get_text().length()>1) {
- _search(EditorFileSystem::get_singleton()->get_filesystem(),&filelist,128);
+ if (search_box->get_text().length() > 1) {
+ _search(EditorFileSystem::get_singleton()->get_filesystem(), &filelist, 128);
}
filelist.sort();
} else {
- for(int i=0;i<efd->get_file_count();i++) {
+ for (int i = 0; i < efd->get_file_count(); i++) {
FileInfo fi;
- fi.name=efd->get_file(i);
- fi.path=path.plus_file(fi.name);
- fi.type=efd->get_file_type(i);
- fi.import_status=0;
-
-
+ fi.name = efd->get_file(i);
+ fi.path = path.plus_file(fi.name);
+ fi.type = efd->get_file_type(i);
+ fi.import_status = 0;
filelist.push_back(fi);
}
}
- StringName ei="EditorIcons"; //make it faster..
- StringName oi="Object";
-
+ StringName ei = "EditorIcons"; //make it faster..
+ StringName oi = "Object";
- for(List<FileInfo>::Element *E=filelist.front();E;E=E->next()) {
- String fname=E->get().name;
+ for (List<FileInfo>::Element *E = filelist.front(); E; E = E->next()) {
+ String fname = E->get().name;
String fp = E->get().path;
StringName type = E->get().type;
Ref<Texture> type_icon;
- String tooltip=fname;
+ String tooltip = fname;
- if (E->get().import_status==0) {
+ if (E->get().import_status == 0) {
- if (has_icon(type,ei)) {
- type_icon=get_icon(type,ei);
+ if (has_icon(type, ei)) {
+ type_icon = get_icon(type, ei);
} else {
- type_icon=get_icon(oi,ei);
+ type_icon = get_icon(oi, ei);
}
- } else if (E->get().import_status==1) {
- type_icon=get_icon("DependencyOk","EditorIcons");
- } else if (E->get().import_status==2) {
- type_icon=get_icon("DependencyChanged","EditorIcons");
- tooltip+"\nStatus: Needs Re-Import";
- } else if (E->get().import_status==3) {
- type_icon=get_icon("ImportFail","EditorIcons");
- tooltip+"\nStatus: Missing Dependencies";
+ } else if (E->get().import_status == 1) {
+ type_icon = get_icon("DependencyOk", "EditorIcons");
+ } else if (E->get().import_status == 2) {
+ type_icon = get_icon("DependencyChanged", "EditorIcons");
+ tooltip + "\nStatus: Needs Re-Import";
+ } else if (E->get().import_status == 3) {
+ type_icon = get_icon("ImportFail", "EditorIcons");
+ tooltip + "\nStatus: Missing Dependencies";
}
if (E->get().sources.size()) {
- for(int i=0;i<E->get().sources.size();i++) {
- tooltip+="\nSource: "+E->get().sources[i];
+ for (int i = 0; i < E->get().sources.size(); i++) {
+ tooltip += "\nSource: " + E->get().sources[i];
}
}
-
-
if (use_thumbnails) {
- files->add_item(fname,file_thumbnail,true);
- files->set_item_metadata(files->get_item_count()-1,fp);
- files->set_item_tag_icon(files->get_item_count()-1,type_icon);
+ files->add_item(fname, file_thumbnail, true);
+ files->set_item_metadata(files->get_item_count() - 1, fp);
+ files->set_item_tag_icon(files->get_item_count() - 1, type_icon);
Array udata;
udata.resize(2);
- udata[0]=files->get_item_count()-1;
- udata[1]=fname;
- EditorResourcePreview::get_singleton()->queue_resource_preview(fp,this,"_thumbnail_done",udata);
+ udata[0] = files->get_item_count() - 1;
+ udata[1] = fname;
+ EditorResourcePreview::get_singleton()->queue_resource_preview(fp, this, "_thumbnail_done", udata);
} else {
- files->add_item(fname,type_icon,true);
- files->set_item_metadata(files->get_item_count()-1,fp);
-
+ files->add_item(fname, type_icon, true);
+ files->set_item_metadata(files->get_item_count() - 1, fp);
}
if (cselection.has(fname))
- files->select(files->get_item_count()-1,false);
-
- files->set_item_tooltip(files->get_item_count()-1,tooltip);
-
+ files->select(files->get_item_count() - 1, false);
+ files->set_item_tooltip(files->get_item_count() - 1, tooltip);
}
-
-
}
void FileSystemDock::_select_file(int p_idx) {
- files->select(p_idx,true);
+ files->select(p_idx, true);
_file_option(FILE_OPEN);
}
@@ -607,33 +574,30 @@ void FileSystemDock::_go_to_tree() {
//file_options->hide();
}
-void FileSystemDock::_go_to_dir(const String& p_dir){
+void FileSystemDock::_go_to_dir(const String &p_dir) {
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- if (da->change_dir(p_dir)==OK) {
- path=da->get_current_dir();
+ if (da->change_dir(p_dir) == OK) {
+ path = da->get_current_dir();
_update_files(false);
}
current_path->set_text(path);
memdelete(da);
-
-
}
-void FileSystemDock::_preview_invalidated(const String& p_path) {
+void FileSystemDock::_preview_invalidated(const String &p_path) {
- if (p_path.get_base_dir()==path && search_box->get_text()==String() && file_list_vb->is_visible_in_tree()) {
+ if (p_path.get_base_dir() == path && search_box->get_text() == String() && file_list_vb->is_visible_in_tree()) {
+ for (int i = 0; i < files->get_item_count(); i++) {
- for(int i=0;i<files->get_item_count();i++) {
-
- if (files->get_item_metadata(i)==p_path) {
+ if (files->get_item_metadata(i) == p_path) {
//re-request preview
Array udata;
udata.resize(2);
- udata[0]=i;
- udata[1]=files->get_item_text(i);
- EditorResourcePreview::get_singleton()->queue_resource_preview(p_path,this,"_thumbnail_done",udata);
+ udata[0] = i;
+ udata[1] = files->get_item_text(i);
+ EditorResourcePreview::get_singleton()->queue_resource_preview(p_path, this, "_thumbnail_done", udata);
break;
}
}
@@ -642,15 +606,14 @@ void FileSystemDock::_preview_invalidated(const String& p_path) {
void FileSystemDock::_fs_changed() {
- button_hist_prev->set_disabled(history_pos==0);
- button_hist_next->set_disabled(history_pos+1==history.size());
+ button_hist_prev->set_disabled(history_pos == 0);
+ button_hist_next->set_disabled(history_pos + 1 == history.size());
scanning_vb->hide();
split_box->show();
if (tree->is_visible()) {
button_favorite->show();
_update_tree();
-
}
if (file_list_vb->is_visible()) {
@@ -669,25 +632,23 @@ void FileSystemDock::_set_scanning_mode() {
scanning_vb->show();
set_process(true);
if (EditorFileSystem::get_singleton()->is_scanning()) {
- scanning_progress->set_value(EditorFileSystem::get_singleton()->get_scanning_progress()*100);
+ scanning_progress->set_value(EditorFileSystem::get_singleton()->get_scanning_progress() * 100);
} else {
scanning_progress->set_value(0);
}
-
}
void FileSystemDock::_fw_history() {
- if (history_pos<history.size()-1)
+ if (history_pos < history.size() - 1)
history_pos++;
- path=history[history_pos];
+ path = history[history_pos];
if (tree->is_visible()) {
_update_tree();
tree->grab_focus();
tree->ensure_cursor_is_visible();
-
}
if (file_list_vb->is_visible()) {
@@ -695,18 +656,16 @@ void FileSystemDock::_fw_history() {
current_path->set_text(path);
}
- button_hist_prev->set_disabled(history_pos==0);
- button_hist_next->set_disabled(history_pos+1==history.size());
-
+ button_hist_prev->set_disabled(history_pos == 0);
+ button_hist_next->set_disabled(history_pos + 1 == history.size());
}
void FileSystemDock::_bw_history() {
- if (history_pos>0)
+ if (history_pos > 0)
history_pos--;
- path=history[history_pos];
-
+ path = history[history_pos];
if (tree->is_visible()) {
_update_tree();
@@ -719,44 +678,40 @@ void FileSystemDock::_bw_history() {
current_path->set_text(path);
}
- button_hist_prev->set_disabled(history_pos==0);
- button_hist_next->set_disabled(history_pos+1==history.size());
-
+ button_hist_prev->set_disabled(history_pos == 0);
+ button_hist_next->set_disabled(history_pos + 1 == history.size());
}
void FileSystemDock::_push_to_history() {
- history.resize(history_pos+1);
- if (history[history_pos]!=path) {
+ history.resize(history_pos + 1);
+ if (history[history_pos] != path) {
history.push_back(path);
history_pos++;
}
- button_hist_prev->set_disabled(history_pos==0);
- button_hist_next->set_disabled(history_pos+1==history.size());
-
+ button_hist_prev->set_disabled(history_pos == 0);
+ button_hist_next->set_disabled(history_pos + 1 == history.size());
}
+void FileSystemDock::_find_inside_move_files(EditorFileSystemDirectory *efsd, Vector<String> &files) {
-void FileSystemDock::_find_inside_move_files(EditorFileSystemDirectory *efsd,Vector<String>& files) {
-
- for(int i=0;i<efsd->get_subdir_count();i++) {
- _find_inside_move_files(efsd->get_subdir(i),files);
+ for (int i = 0; i < efsd->get_subdir_count(); i++) {
+ _find_inside_move_files(efsd->get_subdir(i), files);
}
- for(int i=0;i<efsd->get_file_count();i++) {
+ for (int i = 0; i < efsd->get_file_count(); i++) {
files.push_back(efsd->get_file_path(i));
}
-
}
-void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd,Map<String,String> &renames,List<String>& to_remaps) {
+void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, Map<String, String> &renames, List<String> &to_remaps) {
- for(int i=0;i<efsd->get_subdir_count();i++) {
- _find_remaps(efsd->get_subdir(i),renames,to_remaps);
+ for (int i = 0; i < efsd->get_subdir_count(); i++) {
+ _find_remaps(efsd->get_subdir(i), renames, to_remaps);
}
- for(int i=0;i<efsd->get_file_count();i++) {
- Vector<String> deps=efsd->get_file_deps(i);
- for(int j=0;j<deps.size();j++) {
+ for (int i = 0; i < efsd->get_file_count(); i++) {
+ Vector<String> deps = efsd->get_file_deps(i);
+ for (int j = 0; j < deps.size(); j++) {
if (renames.has(deps[j])) {
to_remaps.push_back(efsd->get_file_path(i));
break;
@@ -765,10 +720,9 @@ void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd,Map<String,Str
}
}
+void FileSystemDock::_rename_operation(const String &p_to_path) {
-void FileSystemDock::_rename_operation(const String& p_to_path) {
-
- if (move_files[0]==p_to_path) {
+ if (move_files[0] == p_to_path) {
EditorNode::get_singleton()->show_warning(TTR("Same source and destination files, doing nothing."));
return;
}
@@ -777,33 +731,33 @@ void FileSystemDock::_rename_operation(const String& p_to_path) {
return;
}
- Map<String,String> renames;
- renames[move_files[0]]=p_to_path;
+ Map<String, String> renames;
+ renames[move_files[0]] = p_to_path;
List<String> remap;
- _find_remaps(EditorFileSystem::get_singleton()->get_filesystem(),renames,remap);
- print_line("found files to remap: "+itos(remap.size()));
+ _find_remaps(EditorFileSystem::get_singleton()->get_filesystem(), renames, remap);
+ print_line("found files to remap: " + itos(remap.size()));
//perform remaps
- for(List<String>::Element *E=remap.front();E;E=E->next()) {
+ for (List<String>::Element *E = remap.front(); E; E = E->next()) {
- Error err = ResourceLoader::rename_dependencies(E->get(),renames);
- print_line("remapping: "+E->get());
+ Error err = ResourceLoader::rename_dependencies(E->get(), renames);
+ print_line("remapping: " + E->get());
- if (err!=OK) {
- EditorNode::get_singleton()->add_io_error("Can't rename deps for:\n"+E->get()+"\n");
+ if (err != OK) {
+ EditorNode::get_singleton()->add_io_error("Can't rename deps for:\n" + E->get() + "\n");
}
}
//finally, perform moves
- DirAccess *da=DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- Error err = da->rename(move_files[0],p_to_path);
- print_line("moving file "+move_files[0]+" to "+p_to_path);
- if (err!=OK) {
- EditorNode::get_singleton()->add_io_error("Error moving file:\n"+move_files[0]+"\n");
+ Error err = da->rename(move_files[0], p_to_path);
+ print_line("moving file " + move_files[0] + " to " + p_to_path);
+ if (err != OK) {
+ EditorNode::get_singleton()->add_io_error("Error moving file:\n" + move_files[0] + "\n");
}
//rescan everything
@@ -812,10 +766,9 @@ void FileSystemDock::_rename_operation(const String& p_to_path) {
_rescan();
}
+void FileSystemDock::_move_operation(const String &p_to_path) {
-void FileSystemDock::_move_operation(const String& p_to_path) {
-
- if (p_to_path==path) {
+ if (p_to_path == path) {
EditorNode::get_singleton()->show_warning(TTR("Same source and destination paths, doing nothing."));
return;
}
@@ -824,78 +777,78 @@ void FileSystemDock::_move_operation(const String& p_to_path) {
Vector<String> inside_files;
- for(int i=0;i<move_dirs.size();i++) {
+ for (int i = 0; i < move_dirs.size(); i++) {
if (p_to_path.begins_with(move_dirs[i])) {
EditorNode::get_singleton()->show_warning(TTR("Can't move directories to within themselves."));
return;
}
- EditorFileSystemDirectory *efsd=EditorFileSystem::get_singleton()->get_filesystem_path(move_dirs[i]);
+ EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem_path(move_dirs[i]);
if (!efsd)
continue;
- _find_inside_move_files(efsd,inside_files);
+ _find_inside_move_files(efsd, inside_files);
}
//make list of remaps
- Map<String,String> renames;
- String repfrom=path=="res://"?path:String(path+"/");
- String repto=p_to_path=="res://"?p_to_path:String(p_to_path+"/");
+ Map<String, String> renames;
+ String repfrom = path == "res://" ? path : String(path + "/");
+ String repto = p_to_path == "res://" ? p_to_path : String(p_to_path + "/");
- for(int i=0;i<move_files.size();i++) {
- renames[move_files[i]]=move_files[i].replace_first(repfrom,repto);
- print_line("move file "+move_files[i]+" -> "+renames[move_files[i]]);
+ for (int i = 0; i < move_files.size(); i++) {
+ renames[move_files[i]] = move_files[i].replace_first(repfrom, repto);
+ print_line("move file " + move_files[i] + " -> " + renames[move_files[i]]);
}
- for(int i=0;i<inside_files.size();i++) {
- renames[inside_files[i]]=inside_files[i].replace_first(repfrom,repto);
- print_line("inside file "+inside_files[i]+" -> "+renames[inside_files[i]]);
+ for (int i = 0; i < inside_files.size(); i++) {
+ renames[inside_files[i]] = inside_files[i].replace_first(repfrom, repto);
+ print_line("inside file " + inside_files[i] + " -> " + renames[inside_files[i]]);
}
//make list of files that will be run the remapping
List<String> remap;
- _find_remaps(EditorFileSystem::get_singleton()->get_filesystem(),renames,remap);
- print_line("found files to remap: "+itos(remap.size()));
+ _find_remaps(EditorFileSystem::get_singleton()->get_filesystem(), renames, remap);
+ print_line("found files to remap: " + itos(remap.size()));
//perform remaps
- for(List<String>::Element *E=remap.front();E;E=E->next()) {
+ for (List<String>::Element *E = remap.front(); E; E = E->next()) {
- Error err = ResourceLoader::rename_dependencies(E->get(),renames);
- print_line("remapping: "+E->get());
+ Error err = ResourceLoader::rename_dependencies(E->get(), renames);
+ print_line("remapping: " + E->get());
- if (err!=OK) {
- EditorNode::get_singleton()->add_io_error("Can't rename deps for:\n"+E->get()+"\n");
+ if (err != OK) {
+ EditorNode::get_singleton()->add_io_error("Can't rename deps for:\n" + E->get() + "\n");
}
}
//finally, perform moves
- DirAccess *da=DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- for(int i=0;i<move_files.size();i++) {
+ for (int i = 0; i < move_files.size(); i++) {
- String to = move_files[i].replace_first(repfrom,repto);
- Error err = da->rename(move_files[i],to);
- print_line("moving file "+move_files[i]+" to "+to);
- if (err!=OK) {
- EditorNode::get_singleton()->add_io_error("Error moving file:\n"+move_files[i]+"\n");
+ String to = move_files[i].replace_first(repfrom, repto);
+ Error err = da->rename(move_files[i], to);
+ print_line("moving file " + move_files[i] + " to " + to);
+ if (err != OK) {
+ EditorNode::get_singleton()->add_io_error("Error moving file:\n" + move_files[i] + "\n");
}
}
- for(int i=0;i<move_dirs.size();i++) {
+ for (int i = 0; i < move_dirs.size(); i++) {
String mdir = move_dirs[i];
- if (mdir=="res://")
+ if (mdir == "res://")
continue;
if (mdir.ends_with("/")) {
- mdir=mdir.substr(0,mdir.length()-1);
+ mdir = mdir.substr(0, mdir.length() - 1);
}
String to = p_to_path.plus_file(mdir.get_file());
- Error err = da->rename(mdir,to);
- print_line("moving dir "+mdir+" to "+to);
- if (err!=OK) {
- EditorNode::get_singleton()->add_io_error("Error moving dir:\n"+move_dirs[i]+"\n");
+ Error err = da->rename(mdir, to);
+ print_line("moving dir " + mdir + " to " + to);
+ if (err != OK) {
+ EditorNode::get_singleton()->add_io_error("Error moving dir:\n" + move_dirs[i] + "\n");
}
}
@@ -903,48 +856,44 @@ void FileSystemDock::_move_operation(const String& p_to_path) {
//rescan everything
print_line("call rescan!");
_rescan();
-
}
void FileSystemDock::_file_option(int p_option) {
- switch(p_option) {
-
+ switch (p_option) {
case FILE_SHOW_IN_EXPLORER:
case FILE_OPEN: {
- int idx=-1;
- for(int i=0;i<files->get_item_count();i++) {
+ int idx = -1;
+ for (int i = 0; i < files->get_item_count(); i++) {
if (files->is_selected(i)) {
- idx=i;
+ idx = i;
break;
}
}
- if (idx<0)
+ if (idx < 0)
return;
-
-
String path = files->get_item_metadata(idx);
if (p_option == FILE_SHOW_IN_EXPLORER) {
String dir = GlobalConfig::get_singleton()->globalize_path(path);
dir = dir.substr(0, dir.find_last("/"));
- OS::get_singleton()->shell_open(String("file://")+dir);
+ OS::get_singleton()->shell_open(String("file://") + dir);
return;
}
if (path.ends_with("/")) {
- if (path!="res://") {
- path=path.substr(0,path.length()-1);
+ if (path != "res://") {
+ path = path.substr(0, path.length() - 1);
}
- this->path=path;
+ this->path = path;
_update_files(false);
current_path->set_text(path);
_push_to_history();
} else {
- if (ResourceLoader::get_resource_type(path)=="PackedScene") {
+ if (ResourceLoader::get_resource_type(path) == "PackedScene") {
editor->open_request(path);
} else {
@@ -957,11 +906,11 @@ void FileSystemDock::_file_option(int p_option) {
Vector<String> paths;
- for (int i = 0; i<files->get_item_count(); i++) {
+ for (int i = 0; i < files->get_item_count(); i++) {
if (!files->is_selected(i))
continue;
- String path =files->get_item_metadata(i);
- if (EditorFileSystem::get_singleton()->get_file_type(path)=="PackedScene") {
+ String path = files->get_item_metadata(i);
+ if (EditorFileSystem::get_singleton()->get_file_type(path) == "PackedScene") {
paths.push_back(path);
}
}
@@ -973,7 +922,7 @@ void FileSystemDock::_file_option(int p_option) {
case FILE_DEPENDENCIES: {
int idx = files->get_current();
- if (idx<0 || idx>=files->get_item_count())
+ if (idx < 0 || idx >= files->get_item_count())
break;
String path = files->get_item_metadata(idx);
deps_editor->edit(path);
@@ -981,7 +930,7 @@ void FileSystemDock::_file_option(int p_option) {
case FILE_OWNERS: {
int idx = files->get_current();
- if (idx<0 || idx>=files->get_item_count())
+ if (idx < 0 || idx >= files->get_item_count())
break;
String path = files->get_item_metadata(idx);
owners_editor->show(path);
@@ -991,53 +940,49 @@ void FileSystemDock::_file_option(int p_option) {
move_dirs.clear();
move_files.clear();
- for(int i=0;i<files->get_item_count();i++) {
+ for (int i = 0; i < files->get_item_count(); i++) {
String path = files->get_item_metadata(i);
if (!files->is_selected(i))
continue;
- if (files->get_item_text(i)=="..") {
- EditorNode::get_singleton()->show_warning(TTR("Can't operate on '..'"));
- return;
- }
+ if (files->get_item_text(i) == "..") {
+ EditorNode::get_singleton()->show_warning(TTR("Can't operate on '..'"));
+ return;
+ }
if (path.ends_with("/")) {
- move_dirs.push_back(path.substr(0,path.length()-1));
+ move_dirs.push_back(path.substr(0, path.length() - 1));
} else {
move_files.push_back(path);
}
}
-
- if (move_dirs.empty() && move_files.size()==1) {
+ if (move_dirs.empty() && move_files.size() == 1) {
rename_dialog->clear_filters();
- rename_dialog->add_filter("*."+move_files[0].get_extension());
+ rename_dialog->add_filter("*." + move_files[0].get_extension());
rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
rename_dialog->set_current_path(move_files[0]);
rename_dialog->popup_centered_ratio();
- rename_dialog->set_title(TTR("Pick New Name and Location For:")+" "+move_files[0].get_file());
-
+ rename_dialog->set_title(TTR("Pick New Name and Location For:") + " " + move_files[0].get_file());
} else {
//just move
move_dialog->popup_centered_ratio();
}
-
} break;
case FILE_REMOVE: {
Vector<String> torem;
- for(int i=0;i<files->get_item_count();i++) {
+ for (int i = 0; i < files->get_item_count(); i++) {
String path = files->get_item_metadata(i);
if (path.ends_with("/") || !files->is_selected(i))
continue;
torem.push_back(path);
-
}
if (torem.empty()) {
@@ -1055,9 +1000,8 @@ void FileSystemDock::_file_option(int p_option) {
} break;
case FILE_REIMPORT: {
-
Vector<String> reimport;
- for(int i=0;i<files->get_item_count();i++) {
+ for (int i = 0; i < files->get_item_count(); i++) {
if (!files->is_selected(i))
continue;
@@ -1066,8 +1010,8 @@ void FileSystemDock::_file_option(int p_option) {
reimport.push_back(path);
}
- ERR_FAIL_COND(reimport.size()==0);
-/*
+ ERR_FAIL_COND(reimport.size() == 0);
+ /*
Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(reimport[0]);
ERR_FAIL_COND(!rimd.is_valid());
String editor=rimd->get_editor();
@@ -1091,7 +1035,7 @@ void FileSystemDock::_file_option(int p_option) {
case FILE_COPY_PATH:
int idx = files->get_current();
- if (idx<0 || idx>=files->get_item_count())
+ if (idx < 0 || idx >= files->get_item_count())
break;
String path = files->get_item_metadata(idx);
OS::get_singleton()->set_clipboard(path);
@@ -1103,18 +1047,18 @@ void FileSystemDock::_folder_option(int p_option) {
TreeItem *item = tree->get_selected();
TreeItem *child = item->get_children();
- switch(p_option) {
-
+ switch (p_option) {
+
case FOLDER_EXPAND_ALL:
item->set_collapsed(false);
- while(child) {
+ while (child) {
child->set_collapsed(false);
child = child->get_next();
}
break;
case FOLDER_COLLAPSE_ALL:
- while(child) {
+ while (child) {
child->set_collapsed(true);
child = child->get_next();
}
@@ -1122,8 +1066,7 @@ void FileSystemDock::_folder_option(int p_option) {
}
}
-void FileSystemDock::_open_pressed(){
-
+void FileSystemDock::_open_pressed() {
TreeItem *sel = tree->get_selected();
if (!sel) {
@@ -1149,22 +1092,20 @@ void FileSystemDock::_open_pressed(){
_push_to_history();
//emit_signal("open",path);
-
}
-void FileSystemDock::_dir_rmb_pressed(const Vector2& p_pos) {
+void FileSystemDock::_dir_rmb_pressed(const Vector2 &p_pos) {
folder_options->clear();
- folder_options->set_size(Size2(1,1));
+ folder_options->set_size(Size2(1, 1));
- folder_options->add_item(TTR("Expand all"),FOLDER_EXPAND_ALL);
- folder_options->add_item(TTR("Collapse all"),FOLDER_COLLAPSE_ALL);
+ folder_options->add_item(TTR("Expand all"), FOLDER_EXPAND_ALL);
+ folder_options->add_item(TTR("Collapse all"), FOLDER_COLLAPSE_ALL);
folder_options->set_pos(files->get_global_pos() + p_pos);
folder_options->popup();
}
-
-void FileSystemDock::_search_changed(const String& p_text) {
+void FileSystemDock::_search_changed(const String &p_text) {
if (!search_box->is_visible_in_tree())
return; //wtf
@@ -1176,14 +1117,12 @@ void FileSystemDock::_rescan() {
_set_scanning_mode();
EditorFileSystem::get_singleton()->scan();
-
}
-void FileSystemDock::fix_dependencies(const String& p_for_file) {
+void FileSystemDock::fix_dependencies(const String &p_for_file) {
deps_editor->edit(p_for_file);
}
-
void FileSystemDock::focus_on_filter() {
if (!search_box->is_visible_in_tree()) {
@@ -1205,39 +1144,37 @@ void FileSystemDock::set_display_mode(int p_mode) {
_change_file_display();
}
+Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-Variant FileSystemDock::get_drag_data_fw(const Point2& p_point,Control* p_from) {
-
- if (p_from==tree) {
+ if (p_from == tree) {
TreeItem *selected = tree->get_selected();
if (!selected)
return Variant();
String path = selected->get_metadata(0);
- if (path==String())
+ if (path == String())
return Variant();
if (!path.ends_with("/"))
- path=path+"/";
+ path = path + "/";
Vector<String> paths;
paths.push_back(path);
- Dictionary d = EditorNode::get_singleton()->drag_files(paths,p_from);
+ Dictionary d = EditorNode::get_singleton()->drag_files(paths, p_from);
- if (selected->get_parent() && tree->get_root()->get_children()==selected->get_parent()) {
+ if (selected->get_parent() && tree->get_root()->get_children() == selected->get_parent()) {
//a favorite.. treat as such
- d["type"]="favorite";
+ d["type"] = "favorite";
}
return d;
-
}
- if (p_from==files) {
+ if (p_from == files) {
List<int> seldirs;
List<int> selfiles;
- for (int i = 0; i<files->get_item_count(); i++) {
+ for (int i = 0; i < files->get_item_count(); i++) {
if (files->is_selected(i)) {
String path = files->get_item_metadata(i);
if (path.ends_with("/"))
@@ -1261,35 +1198,34 @@ Variant FileSystemDock::get_drag_data_fw(const Point2& p_point,Control* p_from)
}
}*/
- if (selfiles.size()>0 && seldirs.size()==0) {
+ if (selfiles.size() > 0 && seldirs.size() == 0) {
Vector<String> fnames;
- for(List<int>::Element *E=selfiles.front();E;E=E->next()) {
+ for (List<int>::Element *E = selfiles.front(); E; E = E->next()) {
fnames.push_back(files->get_item_metadata(E->get()));
}
- return EditorNode::get_singleton()->drag_files(fnames,p_from);
+ return EditorNode::get_singleton()->drag_files(fnames, p_from);
}
- if (selfiles.size()>0 || seldirs.size()>0) {
+ if (selfiles.size() > 0 || seldirs.size() > 0) {
Vector<String> fnames;
- for(List<int>::Element *E=selfiles.front();E;E=E->next()) {
+ for (List<int>::Element *E = selfiles.front(); E; E = E->next()) {
fnames.push_back(files->get_item_metadata(E->get()));
}
- for(List<int>::Element *E=seldirs.front();E;E=E->next()) {
+ for (List<int>::Element *E = seldirs.front(); E; E = E->next()) {
fnames.push_back(files->get_item_metadata(E->get()));
}
- return EditorNode::get_singleton()->drag_files_and_dirs(fnames,p_from);
+ return EditorNode::get_singleton()->drag_files_and_dirs(fnames, p_from);
}
-
}
return Variant();
}
-bool FileSystemDock::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{
+bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
Dictionary drag_data = p_data;
- if (drag_data.has("type") && String(drag_data["type"])=="favorite") {
+ if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
//moving favorite around
TreeItem *ti = tree->get_item_at_pos(p_point);
@@ -1298,34 +1234,32 @@ bool FileSystemDock::can_drop_data_fw(const Point2& p_point,const Variant& p_dat
int what = tree->get_drop_section_at_pos(p_point);
- if (ti==tree->get_root()->get_children()) {
- return (what==1); //the parent, first fav
+ if (ti == tree->get_root()->get_children()) {
+ return (what == 1); //the parent, first fav
}
- if (ti->get_parent() && tree->get_root()->get_children()==ti->get_parent()) {
+ if (ti->get_parent() && tree->get_root()->get_children() == ti->get_parent()) {
return true; // a favorite
}
- if (ti==tree->get_root()->get_children()->get_next()) {
- return (what==-1); //the tree, last fav
+ if (ti == tree->get_root()->get_children()->get_next()) {
+ return (what == -1); //the tree, last fav
}
return false;
-
}
-
- if (drag_data.has("type") && String(drag_data["type"])=="resource") {
+ if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
return true;
}
- if (drag_data.has("type") && ( String(drag_data["type"])=="files" || String(drag_data["type"])=="files_and_dirs")) {
+ if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) {
Vector<String> fnames = drag_data["files"];
- if (p_from==files) {
+ if (p_from == files) {
int at_pos = files->get_item_at_pos(p_point);
- if (at_pos!=-1) {
+ if (at_pos != -1) {
String dir = files->get_item_metadata(at_pos);
if (dir.ends_with("/"))
@@ -1333,31 +1267,30 @@ bool FileSystemDock::can_drop_data_fw(const Point2& p_point,const Variant& p_dat
}
}
- if (p_from==tree) {
+ if (p_from == tree) {
TreeItem *ti = tree->get_item_at_pos(p_point);
if (!ti)
return false;
String path = ti->get_metadata(0);
- if (path==String())
+ if (path == String())
return false;
return true;
}
-
}
return false;
}
-void FileSystemDock::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){
+void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
- if (!can_drop_data_fw(p_point,p_data,p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from))
return;
Dictionary drag_data = p_data;
- if (drag_data.has("type") && String(drag_data["type"])=="favorite") {
+ if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
//moving favorite around
TreeItem *ti = tree->get_item_at_pos(p_point);
@@ -1366,131 +1299,126 @@ void FileSystemDock::drop_data_fw(const Point2& p_point,const Variant& p_data,Co
Vector<String> files = drag_data["files"];
- ERR_FAIL_COND(files.size()!=1);
+ ERR_FAIL_COND(files.size() != 1);
String swap = files[0];
- if (swap!="res://" && swap.ends_with("/")) {
- swap=swap.substr(0,swap.length()-1);
+ if (swap != "res://" && swap.ends_with("/")) {
+ swap = swap.substr(0, swap.length() - 1);
}
int what = tree->get_drop_section_at_pos(p_point);
- TreeItem *swap_item=NULL;
+ TreeItem *swap_item = NULL;
- if (ti==tree->get_root()->get_children()) {
- swap_item=tree->get_root()->get_children()->get_children();
+ if (ti == tree->get_root()->get_children()) {
+ swap_item = tree->get_root()->get_children()->get_children();
- } else if (ti->get_parent() && tree->get_root()->get_children()==ti->get_parent()) {
- if (what==-1) {
- swap_item=ti;
+ } else if (ti->get_parent() && tree->get_root()->get_children() == ti->get_parent()) {
+ if (what == -1) {
+ swap_item = ti;
} else {
- swap_item=ti->get_next();
+ swap_item = ti->get_next();
}
}
String swap_with;
if (swap_item) {
- swap_with=swap_item->get_metadata(0);
- if (swap_with!="res://" && swap_with.ends_with("/")) {
- swap_with=swap_with.substr(0,swap_with.length()-1);
+ swap_with = swap_item->get_metadata(0);
+ if (swap_with != "res://" && swap_with.ends_with("/")) {
+ swap_with = swap_with.substr(0, swap_with.length() - 1);
}
}
- if (swap==swap_with)
+ if (swap == swap_with)
return;
Vector<String> dirs = EditorSettings::get_singleton()->get_favorite_dirs();
- ERR_FAIL_COND(dirs.find(swap)==-1);
- ERR_FAIL_COND(swap_with!=String() && dirs.find(swap_with)==-1);
+ ERR_FAIL_COND(dirs.find(swap) == -1);
+ ERR_FAIL_COND(swap_with != String() && dirs.find(swap_with) == -1);
dirs.erase(swap);
- if (swap_with==String()) {
+ if (swap_with == String()) {
dirs.push_back(swap);
} else {
int idx = dirs.find(swap_with);
- dirs.insert(idx,swap);
+ dirs.insert(idx, swap);
}
EditorSettings::get_singleton()->set_favorite_dirs(dirs);
_update_tree();
return;
-
}
- if (drag_data.has("type") && String(drag_data["type"])=="resource") {
+ if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
Ref<Resource> res = drag_data["resource"];
if (!res.is_valid()) {
return;
}
-
- if (p_from==tree) {
+ if (p_from == tree) {
TreeItem *ti = tree->get_item_at_pos(p_point);
if (!ti)
return;
String path = ti->get_metadata(0);
- if (path==String())
+ if (path == String())
return;
- EditorNode::get_singleton()->save_resource_as(res,path);
+ EditorNode::get_singleton()->save_resource_as(res, path);
return;
-
}
- if (p_from==files) {
- String save_path=path;
+ if (p_from == files) {
+ String save_path = path;
int at_pos = files->get_item_at_pos(p_point);
- if (at_pos!=-1) {
+ if (at_pos != -1) {
String to_dir = files->get_item_metadata(at_pos);
if (to_dir.ends_with("/")) {
- save_path=to_dir;
- if (save_path!="res://")
- save_path=save_path.substr(0,save_path.length()-1);
+ save_path = to_dir;
+ if (save_path != "res://")
+ save_path = save_path.substr(0, save_path.length() - 1);
}
-
}
- EditorNode::get_singleton()->save_resource_as(res,save_path);
+ EditorNode::get_singleton()->save_resource_as(res, save_path);
return;
}
}
- if (drag_data.has("type") && ( String(drag_data["type"])=="files" || String(drag_data["type"])=="files_and_dirs")) {
+ if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) {
- if (p_from==files || p_from==tree) {
+ if (p_from == files || p_from == tree) {
String to_dir;
- if (p_from==files) {
+ if (p_from == files) {
int at_pos = files->get_item_at_pos(p_point);
- ERR_FAIL_COND(at_pos==-1);
+ ERR_FAIL_COND(at_pos == -1);
to_dir = files->get_item_metadata(at_pos);
- } else {
+ } else {
TreeItem *ti = tree->get_item_at_pos(p_point);
if (!ti)
return;
to_dir = ti->get_metadata(0);
- ERR_FAIL_COND(to_dir==String());
-
+ ERR_FAIL_COND(to_dir == String());
}
- if (to_dir!="res://" && to_dir.ends_with("/")) {
- to_dir=to_dir.substr(0,to_dir.length()-1);
+ if (to_dir != "res://" && to_dir.ends_with("/")) {
+ to_dir = to_dir.substr(0, to_dir.length() - 1);
}
Vector<String> fnames = drag_data["files"];
move_files.clear();
move_dirs.clear();
- for(int i=0;i<fnames.size();i++) {
+ for (int i = 0; i < fnames.size(); i++) {
if (fnames[i].ends_with("/"))
move_dirs.push_back(fnames[i]);
else
@@ -1500,27 +1428,26 @@ void FileSystemDock::drop_data_fw(const Point2& p_point,const Variant& p_data,Co
_move_operation(to_dir);
}
}
-
}
-void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
+void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
Vector<String> filenames;
- bool all_scenes=true;
- bool all_can_reimport=true;
+ bool all_scenes = true;
+ bool all_can_reimport = true;
Set<String> types;
- for(int i=0;i<files->get_item_count();i++) {
+ for (int i = 0; i < files->get_item_count(); i++) {
if (!files->is_selected(i))
continue;
String path = files->get_item_metadata(i);
- if (files->get_item_text(i)=="..") {
+ if (files->get_item_text(i) == "..") {
// no operate on ..
- return;
+ return;
}
if (path.ends_with("/")) {
@@ -1528,63 +1455,58 @@ void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
return;
}
-
- EditorFileSystemDirectory *efsd=NULL;
+ EditorFileSystemDirectory *efsd = NULL;
int pos;
- efsd = EditorFileSystem::get_singleton()->find_file(path,&pos);
+ efsd = EditorFileSystem::get_singleton()->find_file(path, &pos);
if (efsd) {
-
} else {
- all_can_reimport=false;
-
+ all_can_reimport = false;
}
filenames.push_back(path);
- if (EditorFileSystem::get_singleton()->get_file_type(path)!="PackedScene")
- all_scenes=false;
+ if (EditorFileSystem::get_singleton()->get_file_type(path) != "PackedScene")
+ all_scenes = false;
}
-
- if (filenames.size()==0)
+ if (filenames.size() == 0)
return;
file_options->clear();
- file_options->set_size(Size2(1,1));
+ file_options->set_size(Size2(1, 1));
- file_options->add_item(TTR("Open"),FILE_OPEN);
+ file_options->add_item(TTR("Open"), FILE_OPEN);
if (all_scenes) {
- file_options->add_item(TTR("Instance"),FILE_INSTANCE);
+ file_options->add_item(TTR("Instance"), FILE_INSTANCE);
}
file_options->add_separator();
- if (filenames.size()==1) {
- file_options->add_item(TTR("Edit Dependencies.."),FILE_DEPENDENCIES);
- file_options->add_item(TTR("View Owners.."),FILE_OWNERS);
+ if (filenames.size() == 1) {
+ file_options->add_item(TTR("Edit Dependencies.."), FILE_DEPENDENCIES);
+ file_options->add_item(TTR("View Owners.."), FILE_OWNERS);
file_options->add_separator();
}
- if (filenames.size()==1) {
+ if (filenames.size() == 1) {
file_options->add_item(TTR("Copy Path"), FILE_COPY_PATH);
- file_options->add_item(TTR("Rename or Move.."),FILE_MOVE);
+ file_options->add_item(TTR("Rename or Move.."), FILE_MOVE);
} else {
- file_options->add_item(TTR("Move To.."),FILE_MOVE);
+ file_options->add_item(TTR("Move To.."), FILE_MOVE);
}
-
- file_options->add_item(TTR("Delete"),FILE_REMOVE);
+ file_options->add_item(TTR("Delete"), FILE_REMOVE);
//file_options->add_item(TTR("Info"),FILE_INFO);
file_options->add_separator();
- file_options->add_item(TTR("Show In File Manager"),FILE_SHOW_IN_EXPLORER);
+ file_options->add_item(TTR("Show In File Manager"), FILE_SHOW_IN_EXPLORER);
- if (all_can_reimport && types.size()==1) { //all can reimport and are of the same type
+ if (all_can_reimport && types.size() == 1) { //all can reimport and are of the same type
-/*
+ /*
bool valid=true;
Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(types.front()->get());
if (rimp.is_valid()) {
@@ -1605,24 +1527,21 @@ void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
file_options->set_pos(files->get_global_pos() + p_pos);
file_options->popup();
-
}
-void FileSystemDock::select_file(const String& p_file) {
+void FileSystemDock::select_file(const String &p_file) {
_go_to_dir(p_file.get_base_dir());
- for(int i=0;i<files->get_item_count();i++) {
- if (files->get_item_metadata(i)==p_file) {
+ for (int i = 0; i < files->get_item_count(); i++) {
+ if (files->get_item_metadata(i) == p_file) {
files->select(i);
files->ensure_current_is_visible();
break;
}
}
-
}
-void FileSystemDock::_file_multi_selected(int p_index,bool p_selected) {
-
+void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) {
_file_selected();
}
@@ -1633,27 +1552,27 @@ void FileSystemDock::_file_selected() {
Vector<String> imports;
String import_type;
- for(int i=0;i<files->get_item_count();i++) {
+ for (int i = 0; i < files->get_item_count(); i++) {
if (!files->is_selected(i))
continue;
String p = files->get_item_metadata(i);
- if (!FileAccess::exists(p+".import")) {
+ if (!FileAccess::exists(p + ".import")) {
imports.clear();
break;
}
Ref<ConfigFile> cf;
cf.instance();
- Error err = cf->load(p+".import");
- if (err!=OK) {
+ Error err = cf->load(p + ".import");
+ if (err != OK) {
imports.clear();
break;
}
- String type = cf->get_value("remap","type");
- if (import_type=="") {
- import_type=type;
- } else if (import_type!=type) {
+ String type = cf->get_value("remap", "type");
+ if (import_type == "") {
+ import_type = type;
+ } else if (import_type != type) {
//all should be the same type
imports.clear();
break;
@@ -1661,27 +1580,25 @@ void FileSystemDock::_file_selected() {
imports.push_back(p);
}
-
- if (imports.size()==0) {
+ if (imports.size() == 0) {
EditorNode::get_singleton()->get_import_dock()->clear();
- } else if (imports.size()==1) {
+ } else if (imports.size() == 1) {
EditorNode::get_singleton()->get_import_dock()->set_edit_path(imports[0]);
} else {
EditorNode::get_singleton()->get_import_dock()->set_edit_multiple_paths(imports);
}
}
-
void FileSystemDock::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_update_tree"),&FileSystemDock::_update_tree);
- ClassDB::bind_method(D_METHOD("_rescan"),&FileSystemDock::_rescan);
- ClassDB::bind_method(D_METHOD("_favorites_pressed"),&FileSystemDock::_favorites_pressed);
+ ClassDB::bind_method(D_METHOD("_update_tree"), &FileSystemDock::_update_tree);
+ ClassDB::bind_method(D_METHOD("_rescan"), &FileSystemDock::_rescan);
+ ClassDB::bind_method(D_METHOD("_favorites_pressed"), &FileSystemDock::_favorites_pressed);
//ClassDB::bind_method(D_METHOD("_instance_pressed"),&ScenesDock::_instance_pressed);
- ClassDB::bind_method(D_METHOD("_open_pressed"),&FileSystemDock::_open_pressed);
- ClassDB::bind_method(D_METHOD("_dir_rmb_pressed"),&FileSystemDock::_dir_rmb_pressed);
+ ClassDB::bind_method(D_METHOD("_open_pressed"), &FileSystemDock::_open_pressed);
+ ClassDB::bind_method(D_METHOD("_dir_rmb_pressed"), &FileSystemDock::_dir_rmb_pressed);
- ClassDB::bind_method(D_METHOD("_thumbnail_done"),&FileSystemDock::_thumbnail_done);
+ ClassDB::bind_method(D_METHOD("_thumbnail_done"), &FileSystemDock::_thumbnail_done);
ClassDB::bind_method(D_METHOD("_select_file"), &FileSystemDock::_select_file);
ClassDB::bind_method(D_METHOD("_go_to_tree"), &FileSystemDock::_go_to_tree);
ClassDB::bind_method(D_METHOD("_go_to_dir"), &FileSystemDock::_go_to_dir);
@@ -1700,46 +1617,42 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &FileSystemDock::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &FileSystemDock::can_drop_data_fw);
ClassDB::bind_method(D_METHOD("drop_data_fw"), &FileSystemDock::drop_data_fw);
- ClassDB::bind_method(D_METHOD("_files_list_rmb_select"),&FileSystemDock::_files_list_rmb_select);
-
- ClassDB::bind_method(D_METHOD("_preview_invalidated"),&FileSystemDock::_preview_invalidated);
- ClassDB::bind_method(D_METHOD("_file_selected"),&FileSystemDock::_file_selected);
- ClassDB::bind_method(D_METHOD("_file_multi_selected"),&FileSystemDock::_file_multi_selected);
+ ClassDB::bind_method(D_METHOD("_files_list_rmb_select"), &FileSystemDock::_files_list_rmb_select);
+ ClassDB::bind_method(D_METHOD("_preview_invalidated"), &FileSystemDock::_preview_invalidated);
+ ClassDB::bind_method(D_METHOD("_file_selected"), &FileSystemDock::_file_selected);
+ ClassDB::bind_method(D_METHOD("_file_multi_selected"), &FileSystemDock::_file_multi_selected);
ADD_SIGNAL(MethodInfo("instance", PropertyInfo(Variant::POOL_STRING_ARRAY, "files")));
ADD_SIGNAL(MethodInfo("open"));
-
}
FileSystemDock::FileSystemDock(EditorNode *p_editor) {
- editor=p_editor;
-
+ editor = p_editor;
- HBoxContainer *toolbar_hbc = memnew( HBoxContainer );
+ HBoxContainer *toolbar_hbc = memnew(HBoxContainer);
add_child(toolbar_hbc);
- button_hist_prev = memnew( ToolButton );
+ button_hist_prev = memnew(ToolButton);
toolbar_hbc->add_child(button_hist_prev);
button_hist_prev->set_disabled(true);
button_hist_prev->set_tooltip(TTR("Previous Directory"));
- button_hist_next = memnew( ToolButton );
+ button_hist_next = memnew(ToolButton);
toolbar_hbc->add_child(button_hist_next);
button_hist_next->set_disabled(true);
button_hist_prev->set_focus_mode(FOCUS_NONE);
button_hist_next->set_focus_mode(FOCUS_NONE);
button_hist_next->set_tooltip(TTR("Next Directory"));
- current_path=memnew( LineEdit );
+ current_path = memnew(LineEdit);
current_path->set_h_size_flags(SIZE_EXPAND_FILL);
toolbar_hbc->add_child(current_path);
-
- button_reload = memnew( Button );
+ button_reload = memnew(Button);
button_reload->set_flat(true);
- button_reload->connect("pressed",this,"_rescan");
+ button_reload->connect("pressed", this, "_rescan");
toolbar_hbc->add_child(button_reload);
button_reload->set_focus_mode(FOCUS_NONE);
button_reload->set_tooltip(TTR("Re-Scan Filesystem"));
@@ -1747,11 +1660,10 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
//toolbar_hbc->add_spacer();
-
- button_favorite = memnew( Button );
+ button_favorite = memnew(Button);
button_favorite->set_flat(true);
button_favorite->set_toggle_mode(true);
- button_favorite->connect("pressed",this,"_favorites_pressed");
+ button_favorite->connect("pressed", this, "_favorites_pressed");
toolbar_hbc->add_child(button_favorite);
button_favorite->set_tooltip(TTR("Toggle folder status as Favorite"));
@@ -1759,9 +1671,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
//Control *spacer = memnew( Control);
-
-
-/*
+ /*
button_open = memnew( Button );
button_open->set_flat(true);
button_open->connect("pressed",this,"_open_pressed");
@@ -1780,112 +1690,106 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
button_instance->set_tooltip(TTR("Instance the selected scene(s) as child of the selected node."));
*/
- file_options = memnew( PopupMenu );
+ file_options = memnew(PopupMenu);
add_child(file_options);
- folder_options = memnew ( PopupMenu );
+ folder_options = memnew(PopupMenu);
add_child(folder_options);
- split_box = memnew( VSplitContainer );
+ split_box = memnew(VSplitContainer);
add_child(split_box);
split_box->set_v_size_flags(SIZE_EXPAND_FILL);
- tree = memnew( Tree );
+ tree = memnew(Tree);
tree->set_hide_root(true);
split_box->add_child(tree);
tree->set_drag_forwarding(this);
tree->set_allow_rmb_select(true);
-
//tree->set_v_size_flags(SIZE_EXPAND_FILL);
- tree->connect("item_edited",this,"_favorite_toggled");
- tree->connect("item_activated",this,"_open_pressed");
- tree->connect("cell_selected",this,"_dir_selected");
- tree->connect("item_rmb_selected",this,"_dir_rmb_pressed");
+ tree->connect("item_edited", this, "_favorite_toggled");
+ tree->connect("item_activated", this, "_open_pressed");
+ tree->connect("cell_selected", this, "_dir_selected");
+ tree->connect("item_rmb_selected", this, "_dir_rmb_pressed");
- files = memnew( ItemList );
+ files = memnew(ItemList);
files->set_v_size_flags(SIZE_EXPAND_FILL);
files->set_select_mode(ItemList::SELECT_MULTI);
files->set_drag_forwarding(this);
- files->connect("item_rmb_selected",this,"_files_list_rmb_select");
- files->connect("item_selected",this,"_file_selected");
- files->connect("multi_selected",this,"_file_multi_selected");
+ files->connect("item_rmb_selected", this, "_files_list_rmb_select");
+ files->connect("item_selected", this, "_file_selected");
+ files->connect("multi_selected", this, "_file_multi_selected");
files->set_allow_rmb_select(true);
- file_list_vb = memnew( VBoxContainer );
+ file_list_vb = memnew(VBoxContainer);
split_box->add_child(file_list_vb);
file_list_vb->set_v_size_flags(SIZE_EXPAND_FILL);
- path_hb = memnew( HBoxContainer );
+ path_hb = memnew(HBoxContainer);
file_list_vb->add_child(path_hb);
- button_back = memnew( ToolButton );
+ button_back = memnew(ToolButton);
path_hb->add_child(button_back);
button_back->hide();
- search_box = memnew( LineEdit );
+ search_box = memnew(LineEdit);
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
path_hb->add_child(search_box);
- search_box->connect("text_changed",this,"_search_changed");
+ search_box->connect("text_changed", this, "_search_changed");
- search_icon = memnew( TextureRect );
+ search_icon = memnew(TextureRect);
search_icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
path_hb->add_child(search_icon);
- button_display_mode = memnew( ToolButton );
+ button_display_mode = memnew(ToolButton);
path_hb->add_child(button_display_mode);
button_display_mode->set_toggle_mode(true);
file_list_vb->add_child(files);
-
- scanning_vb = memnew( VBoxContainer );
- Label *slabel = memnew( Label );
+ scanning_vb = memnew(VBoxContainer);
+ Label *slabel = memnew(Label);
slabel->set_text("Scanning Files,\nPlease Wait..");
slabel->set_align(Label::ALIGN_CENTER);
scanning_vb->add_child(slabel);
- scanning_progress = memnew( ProgressBar );
+ scanning_progress = memnew(ProgressBar);
scanning_vb->add_child(scanning_progress);
add_child(scanning_vb);
scanning_vb->hide();
-
-
- deps_editor = memnew( DependencyEditor );
+ deps_editor = memnew(DependencyEditor);
add_child(deps_editor);
- owners_editor = memnew( DependencyEditorOwners);
+ owners_editor = memnew(DependencyEditorOwners);
add_child(owners_editor);
- remove_dialog = memnew( DependencyRemoveDialog);
+ remove_dialog = memnew(DependencyRemoveDialog);
add_child(remove_dialog);
- move_dialog = memnew( EditorDirDialog );
+ move_dialog = memnew(EditorDirDialog);
add_child(move_dialog);
- move_dialog->connect("dir_selected",this,"_move_operation");
+ move_dialog->connect("dir_selected", this, "_move_operation");
move_dialog->get_ok()->set_text(TTR("Move"));
- rename_dialog = memnew( EditorFileDialog );
+ rename_dialog = memnew(EditorFileDialog);
rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
- rename_dialog->connect("file_selected",this,"_rename_operation");
+ rename_dialog->connect("file_selected", this, "_rename_operation");
add_child(rename_dialog);
- updating_tree=false;
- initialized=false;
+ updating_tree = false;
+ initialized = false;
history.push_back("res://");
- history_pos=0;
+ history_pos = 0;
- split_mode=false;
+ split_mode = false;
display_mode = DISPLAY_THUMBNAILS;
- path="res://";
-
+ path = "res://";
- add_constant_override("separation",3);
+ add_constant_override("separation", 3);
}
FileSystemDock::~FileSystemDock() {
-
}
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index 916321d8fd..1a4b5ae977 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -29,36 +29,36 @@
#ifndef FILESYSTEM_DOCK_H
#define FILESYSTEM_DOCK_H
-#include "scene/main/timer.h"
+#include "scene/gui/box_container.h"
#include "scene/gui/control.h"
-#include "scene/gui/tree.h"
+#include "scene/gui/item_list.h"
#include "scene/gui/label.h"
-#include "scene/gui/tool_button.h"
-#include "scene/gui/option_button.h"
-#include "scene/gui/box_container.h"
#include "scene/gui/menu_button.h"
-#include "scene/gui/item_list.h"
+#include "scene/gui/option_button.h"
#include "scene/gui/progress_bar.h"
#include "scene/gui/split_container.h"
+#include "scene/gui/tool_button.h"
+#include "scene/gui/tree.h"
+#include "scene/main/timer.h"
#include "os/dir_access.h"
#include "os/thread.h"
-#include "editor_file_system.h"
-#include "editor_dir_dialog.h"
#include "dependency_editor.h"
+#include "editor_dir_dialog.h"
+#include "editor_file_system.h"
class EditorNode;
-
class FileSystemDock : public VBoxContainer {
- GDCLASS( FileSystemDock, VBoxContainer );
+ GDCLASS(FileSystemDock, VBoxContainer);
public:
enum DisplayMode {
DISPLAY_THUMBNAILS,
DISPLAY_LIST
};
+
private:
enum FileMenu {
FILE_OPEN,
@@ -78,7 +78,6 @@ private:
FOLDER_COLLAPSE_ALL
};
-
VBoxContainer *scanning_vb;
ProgressBar *scanning_progress;
VSplitContainer *split_box;
@@ -114,7 +113,6 @@ private:
Vector<String> move_dirs;
Vector<String> move_files;
-
Vector<String> history;
int history_pos;
@@ -123,26 +121,23 @@ private:
bool initialized;
bool updating_tree;
- Tree * tree; //directories
+ Tree *tree; //directories
ItemList *files;
-
void _file_multi_selected(int p_index, bool p_selected);
void _file_selected();
-
void _go_to_tree();
- void _go_to_dir(const String& p_dir);
+ void _go_to_dir(const String &p_dir);
void _select_file(int p_idx);
- bool _create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir);
- void _thumbnail_done(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata);
- void _find_inside_move_files(EditorFileSystemDirectory *efsd,Vector<String>& files);
- void _find_remaps(EditorFileSystemDirectory *efsd,Map<String,String> &renames,List<String>& to_remaps);
-
- void _rename_operation(const String& p_to_path);
- void _move_operation(const String& p_to_path);
+ bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir);
+ void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata);
+ void _find_inside_move_files(EditorFileSystemDirectory *efsd, Vector<String> &files);
+ void _find_remaps(EditorFileSystemDirectory *efsd, Map<String, String> &renames, List<String> &to_remaps);
+ void _rename_operation(const String &p_to_path);
+ void _move_operation(const String &p_to_path);
void _file_option(int p_option);
void _folder_option(int p_option);
@@ -154,21 +149,17 @@ private:
void _bw_history();
void _push_to_history();
-
void _dir_selected();
void _update_tree();
void _rescan();
void _set_scanning_mode();
-
void _favorites_pressed();
void _open_pressed();
- void _dir_rmb_pressed(const Vector2& local_mouse_pos);
- void _search_changed(const String& p_text);
-
-
- void _files_list_rmb_select(int p_item,const Vector2& p_pos);
+ void _dir_rmb_pressed(const Vector2 &local_mouse_pos);
+ void _search_changed(const String &p_text);
+ void _files_list_rmb_select(int p_item, const Vector2 &p_pos);
struct FileInfo {
String name;
@@ -177,41 +168,40 @@ private:
int import_status; //0 not imported, 1 - ok, 2- must reimport, 3- broken
Vector<String> sources;
- bool operator<(const FileInfo& fi) const {
+ bool operator<(const FileInfo &fi) const {
return name < fi.name;
}
};
- void _search(EditorFileSystemDirectory *p_path, List<FileInfo>* matches, int p_max_items);
+ void _search(EditorFileSystemDirectory *p_path, List<FileInfo> *matches, int p_max_items);
- Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
- bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
- void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
- void _preview_invalidated(const String& p_path);
+ void _preview_invalidated(const String &p_path);
protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
String get_selected_path() const;
String get_current_path() const;
- void navigate_to_path(const String& p_path);
+ void navigate_to_path(const String &p_path);
void focus_on_filter();
- void fix_dependencies(const String& p_for_file);
+ void fix_dependencies(const String &p_for_file);
void set_display_mode(int p_mode);
int get_split_offset() { return split_box->get_split_offset(); }
void set_split_offset(int p_offset) { split_box->set_split_offset(p_offset); }
- void select_file(const String& p_file);
+ void select_file(const String &p_file);
FileSystemDock(EditorNode *p_editor);
~FileSystemDock();
};
-
#endif // SCENES_DOCK_H
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index 90f0bab6dd..c9e9acd7f2 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -28,18 +28,18 @@
/*************************************************************************/
#include "groups_editor.h"
+#include "editor_node.h"
#include "scene/gui/box_container.h"
#include "scene/gui/label.h"
-#include "editor_node.h"
#include "scene/resources/packed_scene.h"
-void GroupsEditor::_add_group(const String& p_group) {
+void GroupsEditor::_add_group(const String &p_group) {
if (!node)
return;
String name = group_name->get_text();
- if (name.strip_edges()=="")
+ if (name.strip_edges() == "")
return;
if (node->is_in_group(name))
@@ -47,12 +47,12 @@ void GroupsEditor::_add_group(const String& p_group) {
undo_redo->create_action(TTR("Add to Group"));
- undo_redo->add_do_method(node,"add_to_group",name,true);
- undo_redo->add_do_method(this,"update_tree");
- undo_redo->add_undo_method(node,"remove_from_group",name);
- undo_redo->add_undo_method(this,"update_tree");
- undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(),"update_tree"); //to force redraw of scene tree
- undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(),"update_tree"); //to force redraw of scene tree
+ undo_redo->add_do_method(node, "add_to_group", name, true);
+ undo_redo->add_do_method(this, "update_tree");
+ undo_redo->add_undo_method(node, "remove_from_group", name);
+ undo_redo->add_undo_method(this, "update_tree");
+ undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
+ undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
undo_redo->commit_action();
@@ -72,19 +72,19 @@ void GroupsEditor::_remove_group(Object *p_item, int p_column, int p_id) {
undo_redo->create_action(TTR("Remove from Group"));
- undo_redo->add_do_method(node,"remove_from_group",name);
- undo_redo->add_do_method(this,"update_tree");
- undo_redo->add_undo_method(node,"add_to_group",name,true);
- undo_redo->add_undo_method(this,"update_tree");
- undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(),"update_tree"); //to force redraw of scene tree
- undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(),"update_tree"); //to force redraw of scene tree
+ undo_redo->add_do_method(node, "remove_from_group", name);
+ undo_redo->add_do_method(this, "update_tree");
+ undo_redo->add_undo_method(node, "add_to_group", name, true);
+ undo_redo->add_undo_method(this, "update_tree");
+ undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
+ undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree
undo_redo->commit_action();
}
struct _GroupInfoComparator {
- bool operator()(const Node::GroupInfo& p_a, const Node::GroupInfo& p_b) const {
+ bool operator()(const Node::GroupInfo &p_a, const Node::GroupInfo &p_b) const {
return p_a.name.operator String() < p_b.name.operator String();
}
};
@@ -100,89 +100,83 @@ void GroupsEditor::update_tree() {
node->get_groups(&groups);
groups.sort_custom<_GroupInfoComparator>();
- TreeItem *root=tree->create_item();
+ TreeItem *root = tree->create_item();
- for(List<GroupInfo>::Element *E=groups.front();E;E=E->next()) {
+ for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) {
Node::GroupInfo gi = E->get();
if (!gi.persistent)
continue;
Node *n = node;
- bool can_be_deleted=true;
+ bool can_be_deleted = true;
- while(n) {
+ while (n) {
- Ref<SceneState> ss = (n==EditorNode::get_singleton()->get_edited_scene()) ? n->get_scene_inherited_state() : n->get_scene_instance_state();
+ Ref<SceneState> ss = (n == EditorNode::get_singleton()->get_edited_scene()) ? n->get_scene_inherited_state() : n->get_scene_instance_state();
if (ss.is_valid()) {
int path = ss->find_node_by_path(n->get_path_to(node));
- if (path!=-1) {
- if (ss->is_node_in_group(path,gi.name)) {
- can_be_deleted=false;
+ if (path != -1) {
+ if (ss->is_node_in_group(path, gi.name)) {
+ can_be_deleted = false;
}
}
}
- n=n->get_owner();
+ n = n->get_owner();
}
-
- TreeItem *item=tree->create_item(root);
+ TreeItem *item = tree->create_item(root);
item->set_text(0, gi.name);
if (can_be_deleted) {
item->add_button(0, get_icon("Remove", "EditorIcons"), 0);
} else {
- item->set_selectable(0,false);
+ item->set_selectable(0, false);
}
-
}
}
-void GroupsEditor::set_current(Node* p_node) {
+void GroupsEditor::set_current(Node *p_node) {
- node=p_node;
+ node = p_node;
update_tree();
}
void GroupsEditor::_bind_methods() {
- ClassDB::bind_method("_add_group",&GroupsEditor::_add_group);
- ClassDB::bind_method("_remove_group",&GroupsEditor::_remove_group);
- ClassDB::bind_method("update_tree",&GroupsEditor::update_tree);
+ ClassDB::bind_method("_add_group", &GroupsEditor::_add_group);
+ ClassDB::bind_method("_remove_group", &GroupsEditor::_remove_group);
+ ClassDB::bind_method("update_tree", &GroupsEditor::update_tree);
}
GroupsEditor::GroupsEditor() {
- node=NULL;
+ node = NULL;
VBoxContainer *vbc = this;
- HBoxContainer *hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
vbc->add_child(hbc);
- group_name = memnew( LineEdit );
+ group_name = memnew(LineEdit);
group_name->set_h_size_flags(SIZE_EXPAND_FILL);
hbc->add_child(group_name);
- group_name->connect("text_entered",this,"_add_group");
+ group_name->connect("text_entered", this, "_add_group");
- add = memnew( Button );
+ add = memnew(Button);
add->set_text(TTR("Add"));
hbc->add_child(add);
- add->connect("pressed", this,"_add_group", varray(String()));
+ add->connect("pressed", this, "_add_group", varray(String()));
- tree = memnew( Tree );
+ tree = memnew(Tree);
tree->set_hide_root(true);
tree->set_v_size_flags(SIZE_EXPAND_FILL);
vbc->add_child(tree);
- tree->connect("button_pressed",this,"_remove_group");
- add_constant_override("separation",3*EDSCALE);
+ tree->connect("button_pressed", this, "_remove_group");
+ add_constant_override("separation", 3 * EDSCALE);
}
-GroupsEditor::~GroupsEditor()
-{
+GroupsEditor::~GroupsEditor() {
}
-
-
-
diff --git a/editor/groups_editor.h b/editor/groups_editor.h
index 9ab75c6cfd..2b27a3a70c 100644
--- a/editor/groups_editor.h
+++ b/editor/groups_editor.h
@@ -29,10 +29,10 @@
#ifndef GROUPS_EDITOR_H
#define GROUPS_EDITOR_H
-#include "scene/gui/dialogs.h"
#include "scene/gui/button.h"
-#include "scene/gui/tree.h"
+#include "scene/gui/dialogs.h"
#include "scene/gui/line_edit.h"
+#include "scene/gui/tree.h"
#include "undo_redo.h"
/**
@@ -41,7 +41,7 @@
class GroupsEditor : public VBoxContainer {
- GDCLASS(GroupsEditor,VBoxContainer);
+ GDCLASS(GroupsEditor, VBoxContainer);
Node *node;
@@ -52,16 +52,16 @@ class GroupsEditor : public VBoxContainer {
UndoRedo *undo_redo;
void update_tree();
- void _add_group(const String& p_group="");
+ void _add_group(const String &p_group = "");
void _remove_group(Object *p_item, int p_column, int p_id);
void _close();
-protected:
+protected:
static void _bind_methods();
-public:
- void set_undo_redo(UndoRedo *p_undoredo) { undo_redo=p_undoredo; }
- void set_current(Node* p_node);
+public:
+ void set_undo_redo(UndoRedo *p_undoredo) { undo_redo = p_undoredo; }
+ void set_current(Node *p_node);
GroupsEditor();
~GroupsEditor();
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 7098e8812b..b4ce666e0c 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -28,22 +28,20 @@
/*************************************************************************/
#include "editor_import_collada.h"
-
-#include "scene/3d/spatial.h"
-#include "scene/3d/skeleton.h"
-#include "scene/3d/path.h"
+#include "editor/collada/collada.h"
+#include "editor/editor_node.h"
+#include "os/os.h"
#include "scene/3d/camera.h"
#include "scene/3d/light.h"
-#include "scene/animation/animation_player.h"
#include "scene/3d/mesh_instance.h"
+#include "scene/3d/path.h"
+#include "scene/3d/skeleton.h"
+#include "scene/3d/spatial.h"
+#include "scene/animation/animation_player.h"
#include "scene/resources/animation.h"
#include "scene/resources/packed_scene.h"
-#include "os/os.h"
-#include "editor/collada/collada.h"
-#include "editor/editor_node.h"
#include <iostream>
-
struct ColladaImport {
Collada collada;
@@ -57,7 +55,10 @@ struct ColladaImport {
int bone;
List<int> anim_tracks;
- NodeMap() { node=NULL; bone=-1; }
+ NodeMap() {
+ node = NULL;
+ bone = -1;
+ }
};
bool found_ambient;
@@ -68,30 +69,28 @@ struct ColladaImport {
bool use_mesh_builtin_materials;
float bake_fps;
-
-
- Map<String,NodeMap> node_map; //map from collada node to engine node
- Map<String,String> node_name_map; //map from collada node to engine node
+ Map<String, NodeMap> node_map; //map from collada node to engine node
+ Map<String, String> node_name_map; //map from collada node to engine node
Map<String, Ref<Mesh> > mesh_cache;
Map<String, Ref<Curve3D> > curve_cache;
Map<String, Ref<Material> > material_cache;
- Map<Collada::Node*,Skeleton*> skeleton_map;
+ Map<Collada::Node *, Skeleton *> skeleton_map;
- Map< Skeleton*, Map< String, int> > skeleton_bone_map;
+ Map<Skeleton *, Map<String, int> > skeleton_bone_map;
Set<String> valid_animated_nodes;
Vector<int> valid_animated_properties;
- Map<String,bool> bones_with_animation;
+ Map<String, bool> bones_with_animation;
- Error _populate_skeleton(Skeleton *p_skeleton,Collada::Node *p_node, int &r_bone, int p_parent);
+ Error _populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent);
Error _create_scene_skeletons(Collada::Node *p_node);
Error _create_scene(Collada::Node *p_node, Spatial *p_parent);
Error _create_resources(Collada::Node *p_node);
- Error _create_material(const String& p_material);
- Error _create_mesh_surfaces(bool p_optimize, Ref<Mesh>& p_mesh, const Map<String,Collada::NodeGeometry::Material>& p_material_map, const Collada::MeshData &meshdata, const Transform& p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_data, const Collada::MorphControllerData *p_morph_data, Vector<Ref<Mesh> > p_morph_meshes=Vector<Ref<Mesh> >(), bool p_for_morph=false, bool p_use_mesh_material=false);
- Error load(const String& p_path, int p_flags, bool p_force_make_tangents=false);
+ Error _create_material(const String &p_material);
+ Error _create_mesh_surfaces(bool p_optimize, Ref<Mesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_data, const Collada::MorphControllerData *p_morph_data, Vector<Ref<Mesh> > p_morph_meshes = Vector<Ref<Mesh> >(), bool p_for_morph = false, bool p_use_mesh_material = false);
+ Error load(const String &p_path, int p_flags, bool p_force_make_tangents = false);
void _fix_param_animation_tracks();
- void create_animation(int p_clip,bool p_make_tracks_in_all_bones, bool p_import_value_tracks);
+ void create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks);
void create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks);
Set<String> tracks_in_clips;
@@ -101,51 +100,47 @@ struct ColladaImport {
ColladaImport() {
- found_ambient=false;
- found_directional=false;
- force_make_tangents=false;
- apply_mesh_xform_to_vertices=true;
- bake_fps=15;
-
+ found_ambient = false;
+ found_directional = false;
+ force_make_tangents = false;
+ apply_mesh_xform_to_vertices = true;
+ bake_fps = 15;
}
};
+Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent) {
-Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton,Collada::Node *p_node, int &r_bone, int p_parent) {
-
-
- if (p_node->type!=Collada::Node::TYPE_JOINT)
+ if (p_node->type != Collada::Node::TYPE_JOINT)
return OK;
- Collada::NodeJoint *joint = static_cast<Collada::NodeJoint*>(p_node);
+ Collada::NodeJoint *joint = static_cast<Collada::NodeJoint *>(p_node);
- print_line("populating joint "+joint->name);
+ print_line("populating joint " + joint->name);
p_skeleton->add_bone(p_node->name);
- if (p_parent>=0)
- p_skeleton->set_bone_parent(r_bone,p_parent);
+ if (p_parent >= 0)
+ p_skeleton->set_bone_parent(r_bone, p_parent);
NodeMap nm;
- nm.node=p_skeleton;
+ nm.node = p_skeleton;
nm.bone = r_bone;
- node_map[p_node->id]=nm;
- node_name_map[p_node->name]=p_node->id;
+ node_map[p_node->id] = nm;
+ node_name_map[p_node->name] = p_node->id;
- skeleton_bone_map[p_skeleton][joint->sid]=r_bone;
+ skeleton_bone_map[p_skeleton][joint->sid] = r_bone;
if (collada.state.bone_rest_map.has(joint->sid)) {
- p_skeleton->set_bone_rest(r_bone,collada.fix_transform(collada.state.bone_rest_map[joint->sid]));
+ p_skeleton->set_bone_rest(r_bone, collada.fix_transform(collada.state.bone_rest_map[joint->sid]));
//should map this bone to something for animation?
} else {
- print_line("no rest: "+joint->sid);
+ print_line("no rest: " + joint->sid);
WARN_PRINT("Joint has no rest..");
}
-
int id = r_bone++;
- for(int i=0;i<p_node->children.size();i++) {
+ for (int i = 0; i < p_node->children.size(); i++) {
- Error err = _populate_skeleton(p_skeleton,p_node->children[i],r_bone,id);
+ Error err = _populate_skeleton(p_skeleton, p_node->children[i], r_bone, id);
if (err)
return err;
}
@@ -153,70 +148,61 @@ Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton,Collada::Node *p_no
return OK;
}
-
void ColladaImport::_pre_process_lights(Collada::Node *p_node) {
+ if (p_node->type == Collada::Node::TYPE_LIGHT) {
- if (p_node->type==Collada::Node::TYPE_LIGHT) {
-
-
- Collada::NodeLight *light=static_cast<Collada::NodeLight*>(p_node);
+ Collada::NodeLight *light = static_cast<Collada::NodeLight *>(p_node);
if (collada.state.light_data_map.has(light->light)) {
Collada::LightData &ld = collada.state.light_data_map[light->light];
- if (ld.mode==Collada::LightData::MODE_AMBIENT) {
- found_ambient=true;
- ambient=ld.color;
+ if (ld.mode == Collada::LightData::MODE_AMBIENT) {
+ found_ambient = true;
+ ambient = ld.color;
}
- if (ld.mode==Collada::LightData::MODE_DIRECTIONAL) {
- found_directional=true;
+ if (ld.mode == Collada::LightData::MODE_DIRECTIONAL) {
+ found_directional = true;
}
}
-
}
-
- for(int i=0;i<p_node->children.size();i++)
+ for (int i = 0; i < p_node->children.size(); i++)
_pre_process_lights(p_node->children[i]);
}
Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) {
+ if (p_node->type == Collada::Node::TYPE_SKELETON) {
- if (p_node->type==Collada::Node::TYPE_SKELETON) {
-
- Skeleton *sk = memnew( Skeleton );
+ Skeleton *sk = memnew(Skeleton);
int bone = 0;
- for(int i=0;i<p_node->children.size();i++) {
+ for (int i = 0; i < p_node->children.size(); i++) {
- _populate_skeleton(sk,p_node->children[i],bone,-1);
+ _populate_skeleton(sk, p_node->children[i], bone, -1);
}
sk->localize_rests(); //after creating skeleton, rests must be localized...!
- skeleton_map[p_node]=sk;
+ skeleton_map[p_node] = sk;
}
-
- for(int i=0;i<p_node->children.size();i++) {
+ for (int i = 0; i < p_node->children.size(); i++) {
Error err = _create_scene_skeletons(p_node->children[i]);
if (err)
return err;
}
return OK;
-
}
-
Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
- Spatial * node=NULL;
+ Spatial *node = NULL;
- switch(p_node->type) {
+ switch (p_node->type) {
case Collada::Node::TYPE_NODE: {
- node = memnew( Spatial );
+ node = memnew(Spatial);
} break;
case Collada::Node::TYPE_JOINT: {
@@ -225,29 +211,29 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
case Collada::Node::TYPE_LIGHT: {
//node = memnew( Light)
- Collada::NodeLight *light = static_cast<Collada::NodeLight*>(p_node);
+ Collada::NodeLight *light = static_cast<Collada::NodeLight *>(p_node);
if (collada.state.light_data_map.has(light->light)) {
Collada::LightData &ld = collada.state.light_data_map[light->light];
- if (ld.mode==Collada::LightData::MODE_AMBIENT) {
+ if (ld.mode == Collada::LightData::MODE_AMBIENT) {
if (found_directional)
return OK; //do nothing not needed
- if (!bool(GLOBAL_DEF("collada/use_ambient",false)))
+ if (!bool(GLOBAL_DEF("collada/use_ambient", false)))
return OK;
//well, it's an ambient light..
- Light *l = memnew( DirectionalLight );
+ Light *l = memnew(DirectionalLight);
//l->set_color(Light::COLOR_AMBIENT,ld.color);
//l->set_color(Light::COLOR_DIFFUSE,Color(0,0,0));
//l->set_color(Light::COLOR_SPECULAR,Color(0,0,0));
node = l;
- } else if (ld.mode==Collada::LightData::MODE_DIRECTIONAL) {
+ } else if (ld.mode == Collada::LightData::MODE_DIRECTIONAL) {
//well, it's an ambient light..
- Light *l = memnew( DirectionalLight );
+ Light *l = memnew(DirectionalLight);
/*
if (found_ambient) //use it here
l->set_color(Light::COLOR_AMBIENT,ambient);
@@ -260,10 +246,10 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
Light *l;
- if (ld.mode==Collada::LightData::MODE_OMNI)
- l=memnew( OmniLight );
+ if (ld.mode == Collada::LightData::MODE_OMNI)
+ l = memnew(OmniLight);
else {
- l=memnew( SpotLight );
+ l = memnew(SpotLight);
//l->set_parameter(Light::PARAM_SPOT_ANGLE,ld.spot_angle);
//l->set_parameter(Light::PARAM_SPOT_ATTENUATION,ld.spot_exp);
}
@@ -272,37 +258,36 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
//l->set_color(Light::COLOR_DIFFUSE,ld.color);
//l->set_color(Light::COLOR_SPECULAR,Color(1,1,1));
//l->approximate_opengl_attenuation(ld.constant_att,ld.linear_att,ld.quad_att);
- node=l;
+ node = l;
}
} else {
- node = memnew( Spatial );
+ node = memnew(Spatial);
}
} break;
case Collada::Node::TYPE_CAMERA: {
- Collada::NodeCamera *cam = static_cast<Collada::NodeCamera*>(p_node);
- Camera *camera = memnew( Camera );
+ Collada::NodeCamera *cam = static_cast<Collada::NodeCamera *>(p_node);
+ Camera *camera = memnew(Camera);
if (collada.state.camera_data_map.has(cam->camera)) {
const Collada::CameraData &cd = collada.state.camera_data_map[cam->camera];
- switch(cd.mode) {
+ switch (cd.mode) {
case Collada::CameraData::MODE_ORTHOGONAL: {
if (cd.orthogonal.y_mag) {
camera->set_keep_aspect_mode(Camera::KEEP_HEIGHT);
- camera->set_orthogonal(cd.orthogonal.y_mag*2.0 ,cd.z_near,cd.z_far);
+ camera->set_orthogonal(cd.orthogonal.y_mag * 2.0, cd.z_near, cd.z_far);
} else if (!cd.orthogonal.y_mag && cd.orthogonal.x_mag) {
-
camera->set_keep_aspect_mode(Camera::KEEP_WIDTH);
- camera->set_orthogonal(cd.orthogonal.x_mag*2.0,cd.z_near,cd.z_far);
+ camera->set_orthogonal(cd.orthogonal.x_mag * 2.0, cd.z_near, cd.z_far);
}
} break;
@@ -310,97 +295,94 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
if (cd.perspective.y_fov) {
- camera->set_perspective(cd.perspective.y_fov,cd.z_near,cd.z_far);
+ camera->set_perspective(cd.perspective.y_fov, cd.z_near, cd.z_far);
} else if (!cd.perspective.y_fov && cd.perspective.x_fov) {
- camera->set_perspective(cd.perspective.x_fov / cd.aspect,cd.z_near,cd.z_far);
+ camera->set_perspective(cd.perspective.x_fov / cd.aspect, cd.z_near, cd.z_far);
}
} break;
}
-
}
- node=camera;
+ node = camera;
} break;
case Collada::Node::TYPE_GEOMETRY: {
- Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry*>(p_node);
+ Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node);
if (collada.state.curve_data_map.has(ng->source)) {
- node = memnew( Path );
+ node = memnew(Path);
} else {
//mesh since nothing else
- node = memnew( MeshInstance );
- node->cast_to<MeshInstance>()->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT,true);
+ node = memnew(MeshInstance);
+ node->cast_to<MeshInstance>()->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true);
}
} break;
case Collada::Node::TYPE_SKELETON: {
- ERR_FAIL_COND_V(!skeleton_map.has(p_node),ERR_CANT_CREATE);
+ ERR_FAIL_COND_V(!skeleton_map.has(p_node), ERR_CANT_CREATE);
Skeleton *sk = skeleton_map[p_node];
- node=sk;
+ node = sk;
} break;
-
}
- if (p_node->name!="")
+ if (p_node->name != "")
node->set_name(p_node->name);
NodeMap nm;
- nm.node=node;
- node_map[p_node->id]=nm;
- node_name_map[p_node->name]=p_node->id;
+ nm.node = node;
+ node_map[p_node->id] = nm;
+ node_name_map[p_node->name] = p_node->id;
Transform xf = p_node->default_transform;
- xf = collada.fix_transform( xf ) * p_node->post_transform;
+ xf = collada.fix_transform(xf) * p_node->post_transform;
node->set_transform(xf);
p_parent->add_child(node);
node->set_owner(scene);
- if (p_node->empty_draw_type!="") {
+ if (p_node->empty_draw_type != "") {
node->set_meta("empty_draw_type", Variant(p_node->empty_draw_type));
}
-
- for(int i=0;i<p_node->children.size();i++) {
- Error err = _create_scene(p_node->children[i],node);
+ for (int i = 0; i < p_node->children.size(); i++) {
+
+ Error err = _create_scene(p_node->children[i], node);
if (err)
return err;
}
return OK;
}
+Error ColladaImport::_create_material(const String &p_target) {
-Error ColladaImport::_create_material(const String& p_target) {
+ ERR_FAIL_COND_V(material_cache.has(p_target), ERR_ALREADY_EXISTS);
+ ERR_FAIL_COND_V(!collada.state.material_map.has(p_target), ERR_INVALID_PARAMETER);
+ Collada::Material &src_mat = collada.state.material_map[p_target];
+ ERR_FAIL_COND_V(!collada.state.effect_map.has(src_mat.instance_effect), ERR_INVALID_PARAMETER);
+ Collada::Effect &effect = collada.state.effect_map[src_mat.instance_effect];
- ERR_FAIL_COND_V(material_cache.has(p_target),ERR_ALREADY_EXISTS);
- ERR_FAIL_COND_V(!collada.state.material_map.has(p_target),ERR_INVALID_PARAMETER);
- Collada::Material &src_mat=collada.state.material_map[p_target];
- ERR_FAIL_COND_V(!collada.state.effect_map.has(src_mat.instance_effect),ERR_INVALID_PARAMETER);
- Collada::Effect &effect=collada.state.effect_map[src_mat.instance_effect];
+ Ref<FixedSpatialMaterial> material = memnew(FixedSpatialMaterial);
- Ref<FixedSpatialMaterial> material= memnew( FixedSpatialMaterial );
-
- if (src_mat.name!="")
+ if (src_mat.name != "")
material->set_name(src_mat.name);
- else if (effect.name!="")
+ else if (effect.name != "")
material->set_name(effect.name);
// DIFFUSE
- if (effect.diffuse.texture!="") {
+ if (effect.diffuse.texture != "") {
- String texfile = effect.get_texture_path(effect.diffuse.texture,collada);
- if (texfile!="") {
+ String texfile = effect.get_texture_path(effect.diffuse.texture, collada);
+ if (texfile != "") {
- Ref<Texture> texture = ResourceLoader::load(texfile,"Texture");
+ Ref<Texture> texture = ResourceLoader::load(texfile, "Texture");
if (texture.is_valid()) {
- material->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,texture);
- material->set_albedo(Color(1,1,1,1));
+ material->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO, texture);
+ material->set_albedo(Color(1, 1, 1, 1));
//material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,1));
} else {
missing_textures.push_back(texfile.get_file());
@@ -412,154 +394,140 @@ Error ColladaImport::_create_material(const String& p_target) {
// SPECULAR
- if (effect.specular.texture!="") {
+ if (effect.specular.texture != "") {
- String texfile = effect.get_texture_path(effect.specular.texture,collada);
- if (texfile!="") {
+ String texfile = effect.get_texture_path(effect.specular.texture, collada);
+ if (texfile != "") {
- Ref<Texture> texture = ResourceLoader::load(texfile,"Texture");
+ Ref<Texture> texture = ResourceLoader::load(texfile, "Texture");
if (texture.is_valid()) {
- material->set_texture(FixedSpatialMaterial::TEXTURE_SPECULAR,texture);
- material->set_specular(Color(1,1,1,1));
+ material->set_texture(FixedSpatialMaterial::TEXTURE_SPECULAR, texture);
+ material->set_specular(Color(1, 1, 1, 1));
//material->set_texture(FixedSpatialMaterial::PARAM_SPECULAR,texture);
//material->set_parameter(FixedSpatialMaterial::PARAM_SPECULAR,Color(1,1,1,1));
} else {
missing_textures.push_back(texfile.get_file());
}
-
}
} else {
material->set_metalness(effect.specular.color.get_v());
}
-
// EMISSION
- if (effect.emission.texture!="") {
+ if (effect.emission.texture != "") {
- String texfile = effect.get_texture_path(effect.emission.texture,collada);
- if (texfile!="") {
+ String texfile = effect.get_texture_path(effect.emission.texture, collada);
+ if (texfile != "") {
- Ref<Texture> texture = ResourceLoader::load(texfile,"Texture");
+ Ref<Texture> texture = ResourceLoader::load(texfile, "Texture");
if (texture.is_valid()) {
- material->set_feature(FixedSpatialMaterial::FEATURE_EMISSION,true);
- material->set_texture(FixedSpatialMaterial::TEXTURE_EMISSION,texture);
- material->set_emission(Color(1,1,1,1));
+ material->set_feature(FixedSpatialMaterial::FEATURE_EMISSION, true);
+ material->set_texture(FixedSpatialMaterial::TEXTURE_EMISSION, texture);
+ material->set_emission(Color(1, 1, 1, 1));
//material->set_parameter(FixedSpatialMaterial::PARAM_EMISSION,Color(1,1,1,1));
- }else {
+ } else {
missing_textures.push_back(texfile.get_file());
}
-
}
} else {
- if (effect.emission.color!=Color()) {
- material->set_feature(FixedSpatialMaterial::FEATURE_EMISSION,true);
+ if (effect.emission.color != Color()) {
+ material->set_feature(FixedSpatialMaterial::FEATURE_EMISSION, true);
material->set_emission(effect.emission.color);
}
}
// NORMAL
- if (effect.bump.texture!="") {
+ if (effect.bump.texture != "") {
- String texfile = effect.get_texture_path(effect.bump.texture,collada);
- if (texfile!="") {
+ String texfile = effect.get_texture_path(effect.bump.texture, collada);
+ if (texfile != "") {
- Ref<Texture> texture = ResourceLoader::load(texfile,"Texture");
+ Ref<Texture> texture = ResourceLoader::load(texfile, "Texture");
if (texture.is_valid()) {
- material->set_feature(FixedSpatialMaterial::FEATURE_NORMAL_MAPPING,true);
- material->set_texture(FixedSpatialMaterial::TEXTURE_NORMAL,texture);
+ material->set_feature(FixedSpatialMaterial::FEATURE_NORMAL_MAPPING, true);
+ material->set_texture(FixedSpatialMaterial::TEXTURE_NORMAL, texture);
//material->set_emission(Color(1,1,1,1));
//material->set_texture(FixedSpatialMaterial::PARAM_NORMAL,texture);
- }else {
+ } else {
//missing_textures.push_back(texfile.get_file());
}
-
}
}
-
- float roughness = Math::sqrt(1.0-((Math::log(effect.shininess)/Math::log(2.0))/8.0)); //not very right..
+ float roughness = Math::sqrt(1.0 - ((Math::log(effect.shininess) / Math::log(2.0)) / 8.0)); //not very right..
material->set_roughness(roughness);
if (effect.double_sided) {
material->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
}
- material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,effect.unshaded);
-
+ material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, effect.unshaded);
-
- material_cache[p_target]=material;
+ material_cache[p_target] = material;
return OK;
}
-
-static void _generate_normals(const PoolVector<int>& p_indices,const PoolVector<Vector3>& p_vertices,PoolVector<Vector3>&r_normals) {
-
+static void _generate_normals(const PoolVector<int> &p_indices, const PoolVector<Vector3> &p_vertices, PoolVector<Vector3> &r_normals) {
r_normals.resize(p_vertices.size());
PoolVector<Vector3>::Write narrayw = r_normals.write();
- int iacount=p_indices.size()/3;
+ int iacount = p_indices.size() / 3;
PoolVector<int>::Read index_arrayr = p_indices.read();
PoolVector<Vector3>::Read vertex_arrayr = p_vertices.read();
- for(int idx=0;idx<iacount;idx++) {
+ for (int idx = 0; idx < iacount; idx++) {
- Vector3 v[3]={
- vertex_arrayr[index_arrayr[idx*3+0]],
- vertex_arrayr[index_arrayr[idx*3+1]],
- vertex_arrayr[index_arrayr[idx*3+2]]
+ Vector3 v[3] = {
+ vertex_arrayr[index_arrayr[idx * 3 + 0]],
+ vertex_arrayr[index_arrayr[idx * 3 + 1]],
+ vertex_arrayr[index_arrayr[idx * 3 + 2]]
};
- Vector3 normal = Plane(v[0],v[1],v[2]).normal;
+ Vector3 normal = Plane(v[0], v[1], v[2]).normal;
- narrayw[index_arrayr[idx*3+0]]+=normal;
- narrayw[index_arrayr[idx*3+1]]+=normal;
- narrayw[index_arrayr[idx*3+2]]+=normal;
+ narrayw[index_arrayr[idx * 3 + 0]] += normal;
+ narrayw[index_arrayr[idx * 3 + 1]] += normal;
+ narrayw[index_arrayr[idx * 3 + 2]] += normal;
}
- int vlen=p_vertices.size();
+ int vlen = p_vertices.size();
- for(int idx=0;idx<vlen;idx++) {
+ for (int idx = 0; idx < vlen; idx++) {
narrayw[idx].normalize();
}
-
}
+static void _generate_tangents_and_binormals(const PoolVector<int> &p_indices, const PoolVector<Vector3> &p_vertices, const PoolVector<Vector3> &p_uvs, const PoolVector<Vector3> &p_normals, PoolVector<real_t> &r_tangents) {
-static void _generate_tangents_and_binormals(const PoolVector<int>& p_indices,const PoolVector<Vector3>& p_vertices,const PoolVector<Vector3>& p_uvs,const PoolVector<Vector3>& p_normals,PoolVector<real_t>&r_tangents) {
-
- int vlen=p_vertices.size();
+ int vlen = p_vertices.size();
Vector<Vector3> tangents;
tangents.resize(vlen);
Vector<Vector3> binormals;
binormals.resize(vlen);
-
- int iacount=p_indices.size()/3;
+ int iacount = p_indices.size() / 3;
PoolVector<int>::Read index_arrayr = p_indices.read();
PoolVector<Vector3>::Read vertex_arrayr = p_vertices.read();
PoolVector<Vector3>::Read narrayr = p_normals.read();
PoolVector<Vector3>::Read uvarrayr = p_uvs.read();
+ for (int idx = 0; idx < iacount; idx++) {
- for(int idx=0;idx<iacount;idx++) {
+ Vector3 v1 = vertex_arrayr[index_arrayr[idx * 3 + 0]];
+ Vector3 v2 = vertex_arrayr[index_arrayr[idx * 3 + 1]];
+ Vector3 v3 = vertex_arrayr[index_arrayr[idx * 3 + 2]];
-
- Vector3 v1 = vertex_arrayr[ index_arrayr[idx*3+0] ];
- Vector3 v2 = vertex_arrayr[ index_arrayr[idx*3+1] ];
- Vector3 v3 = vertex_arrayr[ index_arrayr[idx*3+2] ];
-
- Vector3 w1 = uvarrayr[ index_arrayr[idx*3+0] ];
- Vector3 w2 = uvarrayr[ index_arrayr[idx*3+1] ];
- Vector3 w3 = uvarrayr[ index_arrayr[idx*3+2] ];
+ Vector3 w1 = uvarrayr[index_arrayr[idx * 3 + 0]];
+ Vector3 w2 = uvarrayr[index_arrayr[idx * 3 + 1]];
+ Vector3 w3 = uvarrayr[index_arrayr[idx * 3 + 2]];
real_t x1 = v2.x - v1.x;
real_t x2 = v3.x - v1.x;
@@ -573,169 +541,165 @@ static void _generate_tangents_and_binormals(const PoolVector<int>& p_indices,co
real_t t1 = w2.y - w1.y;
real_t t2 = w3.y - w1.y;
- real_t r = (s1 * t2 - s2 * t1);
+ real_t r = (s1 * t2 - s2 * t1);
Vector3 tangent;
Vector3 binormal;
- if (r==0) {
+ if (r == 0) {
- binormal=Vector3();
- tangent=Vector3();
+ binormal = Vector3();
+ tangent = Vector3();
} else {
tangent = Vector3((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r,
- (t2 * z1 - t1 * z2) * r).normalized();
+ (t2 * z1 - t1 * z2) * r)
+ .normalized();
binormal = Vector3((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r,
- (s1 * z2 - s2 * z1) * r).normalized();
+ (s1 * z2 - s2 * z1) * r)
+ .normalized();
}
- tangents[ index_arrayr[idx*3+0] ]+=tangent;
- binormals[ index_arrayr[idx*3+0] ]+=binormal;
- tangents[ index_arrayr[idx*3+1] ]+=tangent;
- binormals[ index_arrayr[idx*3+1] ]+=binormal;
- tangents[ index_arrayr[idx*3+2] ]+=tangent;
- binormals[ index_arrayr[idx*3+2] ]+=binormal;
+ tangents[index_arrayr[idx * 3 + 0]] += tangent;
+ binormals[index_arrayr[idx * 3 + 0]] += binormal;
+ tangents[index_arrayr[idx * 3 + 1]] += tangent;
+ binormals[index_arrayr[idx * 3 + 1]] += binormal;
+ tangents[index_arrayr[idx * 3 + 2]] += tangent;
+ binormals[index_arrayr[idx * 3 + 2]] += binormal;
//print_line(itos(idx)+" tangent: "+tangent);
//print_line(itos(idx)+" binormal: "+binormal);
}
- r_tangents.resize(vlen*4);
+ r_tangents.resize(vlen * 4);
PoolVector<real_t>::Write tarrayw = r_tangents.write();
- for(int idx=0;idx<vlen;idx++) {
+ for (int idx = 0; idx < vlen; idx++) {
Vector3 tangent = tangents[idx];
Vector3 bingen = narrayr[idx].cross(tangent);
float dir;
- if (bingen.dot(binormals[idx]) < 0 )
- dir=-1.0;
+ if (bingen.dot(binormals[idx]) < 0)
+ dir = -1.0;
else
- dir=+1.0;
+ dir = +1.0;
- tarrayw[idx*4+0]=tangent.x;
- tarrayw[idx*4+1]=tangent.y;
- tarrayw[idx*4+2]=tangent.z;
- tarrayw[idx*4+3]=dir;
+ tarrayw[idx * 4 + 0] = tangent.x;
+ tarrayw[idx * 4 + 1] = tangent.y;
+ tarrayw[idx * 4 + 2] = tangent.z;
+ tarrayw[idx * 4 + 3] = dir;
}
}
-Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,const Map<String,Collada::NodeGeometry::Material>& p_material_map,const Collada::MeshData &meshdata,const Transform& p_local_xform,const Vector<int> &bone_remap, const Collada::SkinControllerData *skin_controller, const Collada::MorphControllerData *p_morph_data,Vector<Ref<Mesh> > p_morph_meshes,bool p_for_morph,bool p_use_mesh_material) {
-
+Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<Mesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<Mesh> > p_morph_meshes, bool p_for_morph, bool p_use_mesh_material) {
- bool local_xform_mirror=p_local_xform.basis.determinant() < 0;
+ bool local_xform_mirror = p_local_xform.basis.determinant() < 0;
if (p_morph_data) {
//add morphie target
- ERR_FAIL_COND_V( !p_morph_data->targets.has("MORPH_TARGET"), ERR_INVALID_DATA );
+ ERR_FAIL_COND_V(!p_morph_data->targets.has("MORPH_TARGET"), ERR_INVALID_DATA);
String mt = p_morph_data->targets["MORPH_TARGET"];
- ERR_FAIL_COND_V( !p_morph_data->sources.has(mt), ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!p_morph_data->sources.has(mt), ERR_INVALID_DATA);
int morph_targets = p_morph_data->sources[mt].sarray.size();
- for(int i=0;i<morph_targets;i++) {
+ for (int i = 0; i < morph_targets; i++) {
String target = p_morph_data->sources[mt].sarray[i];
- ERR_FAIL_COND_V( !collada.state.mesh_data_map.has(target), ERR_INVALID_DATA );
+ ERR_FAIL_COND_V(!collada.state.mesh_data_map.has(target), ERR_INVALID_DATA);
String name = collada.state.mesh_data_map[target].name;
p_mesh->add_blend_shape(name);
}
- if (p_morph_data->mode=="RELATIVE")
+ if (p_morph_data->mode == "RELATIVE")
p_mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_RELATIVE);
- else if (p_morph_data->mode=="NORMALIZED")
+ else if (p_morph_data->mode == "NORMALIZED")
p_mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_NORMALIZED);
}
+ int surface = 0;
+ for (int p_i = 0; p_i < meshdata.primitives.size(); p_i++) {
- int surface=0;
- for(int p_i = 0; p_i < meshdata.primitives.size(); p_i ++ ) {
-
-
-
- const Collada::MeshData::Primitives& p = meshdata.primitives[p_i];
+ const Collada::MeshData::Primitives &p = meshdata.primitives[p_i];
/* VERTEX SOURCE */
- ERR_FAIL_COND_V(!p.sources.has("VERTEX"),ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!p.sources.has("VERTEX"), ERR_INVALID_DATA);
String vertex_src_id = p.sources["VERTEX"].source;
- int vertex_ofs=p.sources["VERTEX"].offset;
+ int vertex_ofs = p.sources["VERTEX"].offset;
- ERR_FAIL_COND_V(!meshdata.vertices.has(vertex_src_id),ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!meshdata.vertices.has(vertex_src_id), ERR_INVALID_DATA);
- ERR_FAIL_COND_V(!meshdata.vertices[vertex_src_id].sources.has("POSITION"),ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!meshdata.vertices[vertex_src_id].sources.has("POSITION"), ERR_INVALID_DATA);
String position_src_id = meshdata.vertices[vertex_src_id].sources["POSITION"];
- ERR_FAIL_COND_V(!meshdata.sources.has(position_src_id),ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!meshdata.sources.has(position_src_id), ERR_INVALID_DATA);
- const Collada::MeshData::Source *vertex_src=&meshdata.sources[position_src_id];
+ const Collada::MeshData::Source *vertex_src = &meshdata.sources[position_src_id];
/* NORMAL SOURCE */
- const Collada::MeshData::Source *normal_src=NULL;
- int normal_ofs=0;
+ const Collada::MeshData::Source *normal_src = NULL;
+ int normal_ofs = 0;
if (p.sources.has("NORMAL")) {
String normal_source_id = p.sources["NORMAL"].source;
normal_ofs = p.sources["NORMAL"].offset;
- ERR_FAIL_COND_V( !meshdata.sources.has(normal_source_id),ERR_INVALID_DATA);
- normal_src=&meshdata.sources[normal_source_id];
+ ERR_FAIL_COND_V(!meshdata.sources.has(normal_source_id), ERR_INVALID_DATA);
+ normal_src = &meshdata.sources[normal_source_id];
}
- const Collada::MeshData::Source *binormal_src=NULL;
- int binormal_ofs=0;
+ const Collada::MeshData::Source *binormal_src = NULL;
+ int binormal_ofs = 0;
if (p.sources.has("TEXBINORMAL")) {
String binormal_source_id = p.sources["TEXBINORMAL"].source;
binormal_ofs = p.sources["TEXBINORMAL"].offset;
- ERR_FAIL_COND_V( !meshdata.sources.has(binormal_source_id),ERR_INVALID_DATA);
- binormal_src=&meshdata.sources[binormal_source_id];
+ ERR_FAIL_COND_V(!meshdata.sources.has(binormal_source_id), ERR_INVALID_DATA);
+ binormal_src = &meshdata.sources[binormal_source_id];
}
- const Collada::MeshData::Source *tangent_src=NULL;
- int tangent_ofs=0;
+ const Collada::MeshData::Source *tangent_src = NULL;
+ int tangent_ofs = 0;
if (p.sources.has("TEXTANGENT")) {
String tangent_source_id = p.sources["TEXTANGENT"].source;
tangent_ofs = p.sources["TEXTANGENT"].offset;
- ERR_FAIL_COND_V( !meshdata.sources.has(tangent_source_id),ERR_INVALID_DATA);
- tangent_src=&meshdata.sources[tangent_source_id];
+ ERR_FAIL_COND_V(!meshdata.sources.has(tangent_source_id), ERR_INVALID_DATA);
+ tangent_src = &meshdata.sources[tangent_source_id];
}
-
- const Collada::MeshData::Source *uv_src=NULL;
- int uv_ofs=0;
+ const Collada::MeshData::Source *uv_src = NULL;
+ int uv_ofs = 0;
if (p.sources.has("TEXCOORD0")) {
String uv_source_id = p.sources["TEXCOORD0"].source;
uv_ofs = p.sources["TEXCOORD0"].offset;
- ERR_FAIL_COND_V( !meshdata.sources.has(uv_source_id),ERR_INVALID_DATA);
- uv_src=&meshdata.sources[uv_source_id];
+ ERR_FAIL_COND_V(!meshdata.sources.has(uv_source_id), ERR_INVALID_DATA);
+ uv_src = &meshdata.sources[uv_source_id];
}
- const Collada::MeshData::Source *uv2_src=NULL;
- int uv2_ofs=0;
+ const Collada::MeshData::Source *uv2_src = NULL;
+ int uv2_ofs = 0;
if (p.sources.has("TEXCOORD1")) {
String uv2_source_id = p.sources["TEXCOORD1"].source;
uv2_ofs = p.sources["TEXCOORD1"].offset;
- ERR_FAIL_COND_V( !meshdata.sources.has(uv2_source_id),ERR_INVALID_DATA);
- uv2_src=&meshdata.sources[uv2_source_id];
+ ERR_FAIL_COND_V(!meshdata.sources.has(uv2_source_id), ERR_INVALID_DATA);
+ uv2_src = &meshdata.sources[uv2_source_id];
}
-
- const Collada::MeshData::Source *color_src=NULL;
- int color_ofs=0;
+ const Collada::MeshData::Source *color_src = NULL;
+ int color_ofs = 0;
if (p.sources.has("COLOR")) {
String color_source_id = p.sources["COLOR"].source;
color_ofs = p.sources["COLOR"].offset;
- ERR_FAIL_COND_V( !meshdata.sources.has(color_source_id), ERR_INVALID_DATA );
- color_src=&meshdata.sources[color_source_id];
+ ERR_FAIL_COND_V(!meshdata.sources.has(color_source_id), ERR_INVALID_DATA);
+ color_src = &meshdata.sources[color_source_id];
}
//find largest source..
@@ -744,14 +708,14 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
/* ADD WEIGHTS IF EXIST */
/************************/
- Map<int,Vector<Collada::Vertex::Weight> > pre_weights;
+ Map<int, Vector<Collada::Vertex::Weight> > pre_weights;
- bool has_weights=false;
+ bool has_weights = false;
if (skin_controller) {
- const Collada::SkinControllerData::Source *weight_src=NULL;
- int weight_ofs=0;
+ const Collada::SkinControllerData::Source *weight_src = NULL;
+ int weight_ofs = 0;
if (skin_controller->weights.sources.has("WEIGHT")) {
@@ -760,11 +724,10 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
if (skin_controller->sources.has(weight_id)) {
weight_src = &skin_controller->sources[weight_id];
-
}
}
- int joint_ofs=0;
+ int joint_ofs = 0;
if (skin_controller->weights.sources.has("JOINT")) {
@@ -773,67 +736,62 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
//should be OK, given this was pre-checked.
- int index_ofs=0;
+ int index_ofs = 0;
int wstride = skin_controller->weights.sources.size();
- for(int w_i=0;w_i<skin_controller->weights.sets.size();w_i++) {
+ for (int w_i = 0; w_i < skin_controller->weights.sets.size(); w_i++) {
int amount = skin_controller->weights.sets[w_i];
Vector<Collada::Vertex::Weight> weights;
- for (int a_i=0;a_i<amount;a_i++) {
+ for (int a_i = 0; a_i < amount; a_i++) {
Collada::Vertex::Weight w;
- int read_from = index_ofs+a_i*wstride;
- ERR_FAIL_INDEX_V(read_from+wstride-1,skin_controller->weights.indices.size(),ERR_INVALID_DATA);
- int weight_index = skin_controller->weights.indices[read_from+weight_ofs];
- ERR_FAIL_INDEX_V(weight_index,weight_src->array.size(),ERR_INVALID_DATA);
+ int read_from = index_ofs + a_i * wstride;
+ ERR_FAIL_INDEX_V(read_from + wstride - 1, skin_controller->weights.indices.size(), ERR_INVALID_DATA);
+ int weight_index = skin_controller->weights.indices[read_from + weight_ofs];
+ ERR_FAIL_INDEX_V(weight_index, weight_src->array.size(), ERR_INVALID_DATA);
w.weight = weight_src->array[weight_index];
- int bone_index = skin_controller->weights.indices[read_from+joint_ofs];
- if (bone_index==-1)
+ int bone_index = skin_controller->weights.indices[read_from + joint_ofs];
+ if (bone_index == -1)
continue; //ignore this weight (refers to bind shape)
- ERR_FAIL_INDEX_V(bone_index,bone_remap.size(),ERR_INVALID_DATA);
-
- w.bone_idx=bone_remap[bone_index];
+ ERR_FAIL_INDEX_V(bone_index, bone_remap.size(), ERR_INVALID_DATA);
+ w.bone_idx = bone_remap[bone_index];
weights.push_back(w);
}
/* FIX WEIGHTS */
-
-
weights.sort();
- if (weights.size()>4) {
+ if (weights.size() > 4) {
//cap to 4 and make weights add up 1
weights.resize(4);
-
}
//make sure weights allways add up to 1
- float total=0;
- for(int i=0;i<weights.size();i++)
- total+=weights[i].weight;
+ float total = 0;
+ for (int i = 0; i < weights.size(); i++)
+ total += weights[i].weight;
if (total)
- for(int i=0;i<weights.size();i++)
- weights[i].weight/=total;
+ for (int i = 0; i < weights.size(); i++)
+ weights[i].weight /= total;
- if (weights.size()==0 || total==0) { //if nothing, add a weight to bone 0
+ if (weights.size() == 0 || total == 0) { //if nothing, add a weight to bone 0
//no weights assigned
Collada::Vertex::Weight w;
- w.bone_idx=0;
- w.weight=1.0;
+ w.bone_idx = 0;
+ w.weight = 1.0;
weights.clear();
weights.push_back(w);
-
}
- pre_weights[w_i]=weights;
+ pre_weights[w_i] = weights;
/*
for(Set<int>::Element *E=vertex_map[w_i].front();E;E=E->next()) {
@@ -845,16 +803,11 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
}*/
-
-
-
- index_ofs+=wstride*amount;
-
+ index_ofs += wstride * amount;
}
//vertices need to be localized
- has_weights=true;
-
+ has_weights = true;
}
Set<Collada::Vertex> vertex_set; //vertex set will be the vertices
@@ -870,131 +823,121 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
// This is, however, more incompatible with standard video cards, so arrays must be converted.
// Must convert to GL/DX format.
- int _prim_ofs=0;
- int vertidx=0;
- for(int p_i=0;p_i<p.count;p_i++) {
-
+ int _prim_ofs = 0;
+ int vertidx = 0;
+ for (int p_i = 0; p_i < p.count; p_i++) {
int amount;
if (p.polygons.size()) {
- ERR_FAIL_INDEX_V(p_i,p.polygons.size(),ERR_INVALID_DATA);
- amount=p.polygons[p_i];
+ ERR_FAIL_INDEX_V(p_i, p.polygons.size(), ERR_INVALID_DATA);
+ amount = p.polygons[p_i];
} else {
- amount=3; //triangles;
+ amount = 3; //triangles;
}
//COLLADA_PRINT("amount: "+itos(amount));
- int prev2[2]={0,0};
+ int prev2[2] = { 0, 0 };
- for(int j=0;j<amount;j++) {
+ for (int j = 0; j < amount; j++) {
- int src=_prim_ofs;
+ int src = _prim_ofs;
//_prim_ofs+=p.sources.size()
- ERR_FAIL_INDEX_V(src,p.indices.size(),ERR_INVALID_DATA);
+ ERR_FAIL_INDEX_V(src, p.indices.size(), ERR_INVALID_DATA);
Collada::Vertex vertex;
if (!p_optimize)
- vertex.uid=vertidx++;
-
+ vertex.uid = vertidx++;
-
- int vertex_index=p.indices[src+vertex_ofs]; //used for index field (later used by controllers)
- int vertex_pos = (vertex_src->stride?vertex_src->stride:3) * vertex_index;
- ERR_FAIL_INDEX_V(vertex_pos,vertex_src->array.size(),ERR_INVALID_DATA);
- vertex.vertex=Vector3(vertex_src->array[vertex_pos+0],vertex_src->array[vertex_pos+1],vertex_src->array[vertex_pos+2]);
+ int vertex_index = p.indices[src + vertex_ofs]; //used for index field (later used by controllers)
+ int vertex_pos = (vertex_src->stride ? vertex_src->stride : 3) * vertex_index;
+ ERR_FAIL_INDEX_V(vertex_pos, vertex_src->array.size(), ERR_INVALID_DATA);
+ vertex.vertex = Vector3(vertex_src->array[vertex_pos + 0], vertex_src->array[vertex_pos + 1], vertex_src->array[vertex_pos + 2]);
if (pre_weights.has(vertex_index)) {
- vertex.weights=pre_weights[vertex_index];
+ vertex.weights = pre_weights[vertex_index];
}
if (normal_src) {
-
-
- int normal_pos = (normal_src->stride?normal_src->stride:3) * p.indices[src+normal_ofs];
- ERR_FAIL_INDEX_V(normal_pos,normal_src->array.size(),ERR_INVALID_DATA);
- vertex.normal=Vector3(normal_src->array[normal_pos+0],normal_src->array[normal_pos+1],normal_src->array[normal_pos+2]);
- vertex.normal=vertex.normal.snapped(0.001);
-
+ int normal_pos = (normal_src->stride ? normal_src->stride : 3) * p.indices[src + normal_ofs];
+ ERR_FAIL_INDEX_V(normal_pos, normal_src->array.size(), ERR_INVALID_DATA);
+ vertex.normal = Vector3(normal_src->array[normal_pos + 0], normal_src->array[normal_pos + 1], normal_src->array[normal_pos + 2]);
+ vertex.normal = vertex.normal.snapped(0.001);
if (tangent_src && binormal_src) {
- int binormal_pos = (binormal_src->stride?binormal_src->stride:3) * p.indices[src+binormal_ofs];
- ERR_FAIL_INDEX_V(binormal_pos,binormal_src->array.size(),ERR_INVALID_DATA);
- Vector3 binormal =Vector3(binormal_src->array[binormal_pos+0],binormal_src->array[binormal_pos+1],binormal_src->array[binormal_pos+2]);
+ int binormal_pos = (binormal_src->stride ? binormal_src->stride : 3) * p.indices[src + binormal_ofs];
+ ERR_FAIL_INDEX_V(binormal_pos, binormal_src->array.size(), ERR_INVALID_DATA);
+ Vector3 binormal = Vector3(binormal_src->array[binormal_pos + 0], binormal_src->array[binormal_pos + 1], binormal_src->array[binormal_pos + 2]);
- int tangent_pos = (tangent_src->stride?tangent_src->stride:3) * p.indices[src+tangent_ofs];
- ERR_FAIL_INDEX_V(tangent_pos,tangent_src->array.size(),ERR_INVALID_DATA);
- Vector3 tangent =Vector3(tangent_src->array[tangent_pos+0],tangent_src->array[tangent_pos+1],tangent_src->array[tangent_pos+2]);
+ int tangent_pos = (tangent_src->stride ? tangent_src->stride : 3) * p.indices[src + tangent_ofs];
+ ERR_FAIL_INDEX_V(tangent_pos, tangent_src->array.size(), ERR_INVALID_DATA);
+ Vector3 tangent = Vector3(tangent_src->array[tangent_pos + 0], tangent_src->array[tangent_pos + 1], tangent_src->array[tangent_pos + 2]);
- vertex.tangent.normal=tangent;
- vertex.tangent.d= vertex.normal.cross(tangent).dot(binormal) > 0 ? 1 : -1;
+ vertex.tangent.normal = tangent;
+ vertex.tangent.d = vertex.normal.cross(tangent).dot(binormal) > 0 ? 1 : -1;
}
-
}
-
if (uv_src) {
- int uv_pos = (uv_src->stride?uv_src->stride:2) * p.indices[src+uv_ofs];
- ERR_FAIL_INDEX_V(uv_pos,uv_src->array.size(),ERR_INVALID_DATA);
- vertex.uv=Vector3(uv_src->array[uv_pos+0],1.0-uv_src->array[uv_pos+1],0);
+ int uv_pos = (uv_src->stride ? uv_src->stride : 2) * p.indices[src + uv_ofs];
+ ERR_FAIL_INDEX_V(uv_pos, uv_src->array.size(), ERR_INVALID_DATA);
+ vertex.uv = Vector3(uv_src->array[uv_pos + 0], 1.0 - uv_src->array[uv_pos + 1], 0);
}
if (uv2_src) {
- int uv2_pos = (uv2_src->stride?uv2_src->stride:2) * p.indices[src+uv2_ofs];
- ERR_FAIL_INDEX_V(uv2_pos,uv2_src->array.size(),ERR_INVALID_DATA);
- vertex.uv2=Vector3(uv2_src->array[uv2_pos+0],1.0-uv2_src->array[uv2_pos+1],0);
+ int uv2_pos = (uv2_src->stride ? uv2_src->stride : 2) * p.indices[src + uv2_ofs];
+ ERR_FAIL_INDEX_V(uv2_pos, uv2_src->array.size(), ERR_INVALID_DATA);
+ vertex.uv2 = Vector3(uv2_src->array[uv2_pos + 0], 1.0 - uv2_src->array[uv2_pos + 1], 0);
}
if (color_src) {
- int color_pos = (color_src->stride?color_src->stride:3) * p.indices[src+color_ofs]; // colors are RGB in collada..
- ERR_FAIL_INDEX_V(color_pos,color_src->array.size(),ERR_INVALID_DATA);
- vertex.color=Color(color_src->array[color_pos+0],color_src->array[color_pos+1],color_src->array[color_pos+2],(color_src->stride>3)?color_src->array[color_pos+3]:1.0);
-
+ int color_pos = (color_src->stride ? color_src->stride : 3) * p.indices[src + color_ofs]; // colors are RGB in collada..
+ ERR_FAIL_INDEX_V(color_pos, color_src->array.size(), ERR_INVALID_DATA);
+ vertex.color = Color(color_src->array[color_pos + 0], color_src->array[color_pos + 1], color_src->array[color_pos + 2], (color_src->stride > 3) ? color_src->array[color_pos + 3] : 1.0);
}
#ifndef NO_UP_AXIS_SWAP
- if (collada.state.up_axis==Vector3::AXIS_Z) {
+ if (collada.state.up_axis == Vector3::AXIS_Z) {
- SWAP( vertex.vertex.z, vertex.vertex.y );
+ SWAP(vertex.vertex.z, vertex.vertex.y);
vertex.vertex.z = -vertex.vertex.z;
- SWAP( vertex.normal.z, vertex.normal.y );
+ SWAP(vertex.normal.z, vertex.normal.y);
vertex.normal.z = -vertex.normal.z;
- SWAP( vertex.tangent.normal.z, vertex.tangent.normal.y );
+ SWAP(vertex.tangent.normal.z, vertex.tangent.normal.y);
vertex.tangent.normal.z = -vertex.tangent.normal.z;
-
}
#endif
vertex.fix_unit_scale(collada);
- int index=0;
+ int index = 0;
//COLLADA_PRINT("vertex: "+vertex.vertex);
if (vertex_set.has(vertex)) {
- index=vertex_set.find(vertex)->get().idx;
+ index = vertex_set.find(vertex)->get().idx;
} else {
- index=vertex_set.size();
- vertex.idx=index;
+ index = vertex_set.size();
+ vertex.idx = index;
vertex_set.insert(vertex);
}
- /* if (!vertex_map.has(vertex_index))
+ /* if (!vertex_map.has(vertex_index))
vertex_map[vertex_index]=Set<int>();
vertex_map[vertex_index].insert(index); //should be outside..*/
//build triangles if needed
- if (j==0)
- prev2[0]=index;
+ if (j == 0)
+ prev2[0] = index;
- if (j>=2) {
+ if (j >= 2) {
//insert indices in reverse order (collada uses CCW as frontface)
if (local_xform_mirror) {
@@ -1009,32 +952,28 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
}
}
- prev2[1]=index;
- _prim_ofs+=p.vertex_size;
+ prev2[1] = index;
+ _prim_ofs += p.vertex_size;
}
-
}
-
-
Vector<Collada::Vertex> vertex_array; //there we go, vertex array
vertex_array.resize(vertex_set.size());
- for(Set<Collada::Vertex>::Element *F=vertex_set.front();F;F=F->next()) {
+ for (Set<Collada::Vertex>::Element *F = vertex_set.front(); F; F = F->next()) {
- vertex_array[F->get().idx]=F->get();
+ vertex_array[F->get().idx] = F->get();
}
-
if (has_weights) {
//if skeleton, localize
Transform local_xform = p_local_xform;
- for(int i=0;i<vertex_array.size();i++) {
+ for (int i = 0; i < vertex_array.size(); i++) {
- vertex_array[i].vertex=local_xform.xform(vertex_array[i].vertex);
- vertex_array[i].normal=local_xform.basis.xform(vertex_array[i].normal).normalized();
- vertex_array[i].tangent.normal=local_xform.basis.xform(vertex_array[i].tangent.normal).normalized();
+ vertex_array[i].vertex = local_xform.xform(vertex_array[i].vertex);
+ vertex_array[i].normal = local_xform.basis.xform(vertex_array[i].normal).normalized();
+ vertex_array[i].tangent.normal = local_xform.basis.xform(vertex_array[i].tangent.normal).normalized();
if (local_xform_mirror) {
//i shouldn't do this? wtf?
//vertex_array[i].normal*=-1.0;
@@ -1043,51 +982,46 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
}
}
-
PoolVector<int> index_array;
index_array.resize(indices_list.size());
PoolVector<int>::Write index_arrayw = index_array.write();
- int iidx=0;
- for(List<int>::Element *F=indices_list.front();F;F=F->next()) {
+ int iidx = 0;
+ for (List<int>::Element *F = indices_list.front(); F; F = F->next()) {
- index_arrayw[iidx++]=F->get();
+ index_arrayw[iidx++] = F->get();
}
- index_arrayw=PoolVector<int>::Write();
-
+ index_arrayw = PoolVector<int>::Write();
/*****************/
/* MAKE SURFACES */
/*****************/
-
{
Ref<FixedSpatialMaterial> material;
//find material
- Mesh::PrimitiveType primitive=Mesh::PRIMITIVE_TRIANGLES;
+ Mesh::PrimitiveType primitive = Mesh::PRIMITIVE_TRIANGLES;
{
if (p_material_map.has(p.material)) {
- String target=p_material_map[p.material].target;
+ String target = p_material_map[p.material].target;
if (!material_cache.has(target)) {
Error err = _create_material(target);
if (!err)
- material=material_cache[target];
+ material = material_cache[target];
} else
- material=material_cache[target];
+ material = material_cache[target];
- } else if (p.material!=""){
- print_line("Warning, unreferenced material in geometry instance: "+p.material);
+ } else if (p.material != "") {
+ print_line("Warning, unreferenced material in geometry instance: " + p.material);
}
}
-
-
PoolVector<Vector3> final_vertex_array;
PoolVector<Vector3> final_normal_array;
PoolVector<float> final_tangent_array;
@@ -1097,34 +1031,30 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
PoolVector<int> final_bone_array;
PoolVector<float> final_weight_array;
- uint32_t final_format=0;
+ uint32_t final_format = 0;
//create format
- final_format=Mesh::ARRAY_FORMAT_VERTEX|Mesh::ARRAY_FORMAT_INDEX;
+ final_format = Mesh::ARRAY_FORMAT_VERTEX | Mesh::ARRAY_FORMAT_INDEX;
if (normal_src) {
- final_format|=Mesh::ARRAY_FORMAT_NORMAL;
+ final_format |= Mesh::ARRAY_FORMAT_NORMAL;
if (uv_src && binormal_src && tangent_src) {
- final_format|=Mesh::ARRAY_FORMAT_TANGENT;
+ final_format |= Mesh::ARRAY_FORMAT_TANGENT;
}
-
}
-
-
if (color_src)
- final_format|=Mesh::ARRAY_FORMAT_COLOR;
+ final_format |= Mesh::ARRAY_FORMAT_COLOR;
if (uv_src)
- final_format|=Mesh::ARRAY_FORMAT_TEX_UV;
+ final_format |= Mesh::ARRAY_FORMAT_TEX_UV;
if (uv2_src)
- final_format|=Mesh::ARRAY_FORMAT_TEX_UV2;
+ final_format |= Mesh::ARRAY_FORMAT_TEX_UV2;
if (has_weights) {
- final_format|=Mesh::ARRAY_FORMAT_WEIGHTS;
- final_format|=Mesh::ARRAY_FORMAT_BONES;
+ final_format |= Mesh::ARRAY_FORMAT_WEIGHTS;
+ final_format |= Mesh::ARRAY_FORMAT_BONES;
}
-
//set arrays
int vlen = vertex_array.size();
@@ -1135,27 +1065,24 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
PoolVector<Vector3>::Write varrayw = varray.write();
- for(int k=0;k<vlen;k++)
- varrayw[k]=vertex_array[k].vertex;
+ for (int k = 0; k < vlen; k++)
+ varrayw[k] = vertex_array[k].vertex;
varrayw = PoolVector<Vector3>::Write();
- final_vertex_array=varray;
-
+ final_vertex_array = varray;
}
-
if (uv_src) { //compute uv first, may be needed for computing tangent/bionrmal
PoolVector<Vector3> uvarray;
uvarray.resize(vertex_array.size());
PoolVector<Vector3>::Write uvarrayw = uvarray.write();
- for(int k=0;k<vlen;k++) {
- uvarrayw[k]=vertex_array[k].uv;
+ for (int k = 0; k < vlen; k++) {
+ uvarrayw[k] = vertex_array[k].uv;
}
uvarrayw = PoolVector<Vector3>::Write();
- final_uv_array=uvarray;
-
+ final_uv_array = uvarray;
}
if (uv2_src) { //compute uv first, may be needed for computing tangent/bionrmal
@@ -1163,13 +1090,12 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
uv2array.resize(vertex_array.size());
PoolVector<Vector3>::Write uv2arrayw = uv2array.write();
- for(int k=0;k<vlen;k++) {
- uv2arrayw[k]=vertex_array[k].uv2;
+ for (int k = 0; k < vlen; k++) {
+ uv2arrayw[k] = vertex_array[k].uv2;
}
uv2arrayw = PoolVector<Vector3>::Write();
- final_uv2_array=uv2array;
-
+ final_uv2_array = uv2array;
}
if (normal_src) {
@@ -1177,12 +1103,12 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
narray.resize(vertex_array.size());
PoolVector<Vector3>::Write narrayw = narray.write();
- for(int k=0;k<vlen;k++) {
- narrayw[k]=vertex_array[k].normal;
+ for (int k = 0; k < vlen; k++) {
+ narrayw[k] = vertex_array[k].normal;
}
narrayw = PoolVector<Vector3>::Write();
- final_normal_array=narray;
+ final_normal_array = narray;
/*
PoolVector<Vector3> altnaray;
@@ -1192,91 +1118,82 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
print_line(rtos(altnaray[i].dot(final_normal_array[i])));
*/
- } else if (primitive==Mesh::PRIMITIVE_TRIANGLES) {
+ } else if (primitive == Mesh::PRIMITIVE_TRIANGLES) {
//generate normals (even if unused later)
- _generate_normals(index_array,final_vertex_array,final_normal_array);
+ _generate_normals(index_array, final_vertex_array, final_normal_array);
if (OS::get_singleton()->is_stdout_verbose())
print_line("Collada: Triangle mesh lacks normals, so normals were generated.");
- final_format|=Mesh::ARRAY_FORMAT_NORMAL;
-
+ final_format |= Mesh::ARRAY_FORMAT_NORMAL;
}
if (final_normal_array.size() && uv_src && binormal_src && tangent_src && !force_make_tangents) {
PoolVector<real_t> tarray;
- tarray.resize(vertex_array.size()*4);
+ tarray.resize(vertex_array.size() * 4);
PoolVector<real_t>::Write tarrayw = tarray.write();
-
- for(int k=0;k<vlen;k++) {
- tarrayw[k*4+0]=vertex_array[k].tangent.normal.x;
- tarrayw[k*4+1]=vertex_array[k].tangent.normal.y;
- tarrayw[k*4+2]=vertex_array[k].tangent.normal.z;
- tarrayw[k*4+3]=vertex_array[k].tangent.d;
-
+ for (int k = 0; k < vlen; k++) {
+ tarrayw[k * 4 + 0] = vertex_array[k].tangent.normal.x;
+ tarrayw[k * 4 + 1] = vertex_array[k].tangent.normal.y;
+ tarrayw[k * 4 + 2] = vertex_array[k].tangent.normal.z;
+ tarrayw[k * 4 + 3] = vertex_array[k].tangent.d;
}
tarrayw = PoolVector<real_t>::Write();
- final_tangent_array=tarray;
- } else if (final_normal_array.size() && primitive==Mesh::PRIMITIVE_TRIANGLES && final_uv_array.size() && (force_make_tangents || (material.is_valid()))){
+ final_tangent_array = tarray;
+ } else if (final_normal_array.size() && primitive == Mesh::PRIMITIVE_TRIANGLES && final_uv_array.size() && (force_make_tangents || (material.is_valid()))) {
//if this uses triangles, there are uvs and the material is using a normalmap, generate tangents and binormals, because they WILL be needed
//generate binormals/tangents
- _generate_tangents_and_binormals(index_array,final_vertex_array,final_uv_array,final_normal_array,final_tangent_array);
- final_format|=Mesh::ARRAY_FORMAT_TANGENT;
+ _generate_tangents_and_binormals(index_array, final_vertex_array, final_uv_array, final_normal_array, final_tangent_array);
+ final_format |= Mesh::ARRAY_FORMAT_TANGENT;
if (OS::get_singleton()->is_stdout_verbose())
print_line("Collada: Triangle mesh lacks tangents (And normalmap was used), so tangents were generated.");
-
}
-
if (color_src) {
PoolVector<Color> colorarray;
colorarray.resize(vertex_array.size());
PoolVector<Color>::Write colorarrayw = colorarray.write();
- for(int k=0;k<vlen;k++) {
- colorarrayw[k]=vertex_array[k].color;
+ for (int k = 0; k < vlen; k++) {
+ colorarrayw[k] = vertex_array[k].color;
}
colorarrayw = PoolVector<Color>::Write();
- final_color_array=colorarray;
+ final_color_array = colorarray;
}
if (has_weights) {
PoolVector<float> weightarray;
PoolVector<int> bonearray;
- weightarray.resize(vertex_array.size()*4);
+ weightarray.resize(vertex_array.size() * 4);
PoolVector<float>::Write weightarrayw = weightarray.write();
- bonearray.resize(vertex_array.size()*4);
+ bonearray.resize(vertex_array.size() * 4);
PoolVector<int>::Write bonearrayw = bonearray.write();
- for(int k=0;k<vlen;k++) {
- float sum=0;
+ for (int k = 0; k < vlen; k++) {
+ float sum = 0;
- for(int l=0;l<VS::ARRAY_WEIGHTS_SIZE;l++) {
- if (l<vertex_array[k].weights.size()) {
- weightarrayw[k*VS::ARRAY_WEIGHTS_SIZE+l]=vertex_array[k].weights[l].weight;
- sum+=weightarrayw[k*VS::ARRAY_WEIGHTS_SIZE+l];
- bonearrayw[k*VS::ARRAY_WEIGHTS_SIZE+l]=int(vertex_array[k].weights[l].bone_idx);
+ for (int l = 0; l < VS::ARRAY_WEIGHTS_SIZE; l++) {
+ if (l < vertex_array[k].weights.size()) {
+ weightarrayw[k * VS::ARRAY_WEIGHTS_SIZE + l] = vertex_array[k].weights[l].weight;
+ sum += weightarrayw[k * VS::ARRAY_WEIGHTS_SIZE + l];
+ bonearrayw[k * VS::ARRAY_WEIGHTS_SIZE + l] = int(vertex_array[k].weights[l].bone_idx);
//COLLADA_PRINT(itos(k)+": "+rtos(bonearrayw[k*VS::ARRAY_WEIGHTS_SIZE+l])+":"+rtos(weightarray[k*VS::ARRAY_WEIGHTS_SIZE+l]));
} else {
- weightarrayw[k*VS::ARRAY_WEIGHTS_SIZE+l]=0;
- bonearrayw[k*VS::ARRAY_WEIGHTS_SIZE+l]=0;
-
+ weightarrayw[k * VS::ARRAY_WEIGHTS_SIZE + l] = 0;
+ bonearrayw[k * VS::ARRAY_WEIGHTS_SIZE + l] = 0;
}
-
-
}
/*
if (sum<0.8)
COLLADA_PRINT("ERROR SUMMING INDEX "+itos(k)+" had weights: "+itos(vertex_array[k].weights.size()));
*/
-
}
weightarrayw = PoolVector<float>::Write();
@@ -1286,8 +1203,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
final_bone_array = bonearray;
}
-
-
////////////////////////////
// FINALLY CREATE SUFRACE //
////////////////////////////
@@ -1295,30 +1210,29 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
Array d;
d.resize(VS::ARRAY_MAX);
- d[Mesh::ARRAY_INDEX]=index_array;
- d[Mesh::ARRAY_VERTEX]=final_vertex_array;
+ d[Mesh::ARRAY_INDEX] = index_array;
+ d[Mesh::ARRAY_VERTEX] = final_vertex_array;
if (final_normal_array.size())
- d[Mesh::ARRAY_NORMAL]=final_normal_array;
+ d[Mesh::ARRAY_NORMAL] = final_normal_array;
if (final_tangent_array.size())
- d[Mesh::ARRAY_TANGENT]=final_tangent_array;
+ d[Mesh::ARRAY_TANGENT] = final_tangent_array;
if (final_uv_array.size())
- d[Mesh::ARRAY_TEX_UV]=final_uv_array;
+ d[Mesh::ARRAY_TEX_UV] = final_uv_array;
if (final_uv2_array.size())
- d[Mesh::ARRAY_TEX_UV2]=final_uv2_array;
+ d[Mesh::ARRAY_TEX_UV2] = final_uv2_array;
if (final_color_array.size())
- d[Mesh::ARRAY_COLOR]=final_color_array;
+ d[Mesh::ARRAY_COLOR] = final_color_array;
if (final_weight_array.size())
- d[Mesh::ARRAY_WEIGHTS]=final_weight_array;
+ d[Mesh::ARRAY_WEIGHTS] = final_weight_array;
if (final_bone_array.size())
- d[Mesh::ARRAY_BONES]=final_bone_array;
-
+ d[Mesh::ARRAY_BONES] = final_bone_array;
Array mr;
- ////////////////////////////
- // THEN THE MORPH TARGETS //
- ////////////////////////////
+////////////////////////////
+// THEN THE MORPH TARGETS //
+////////////////////////////
#if 0
if (p_morph_data) {
@@ -1426,14 +1340,14 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
int pos = m_i*stride;
Vector3 vtx( m->array[pos+0], m->array[pos+1], m->array[pos+2] );
- #ifndef NO_UP_AXIS_SWAP
+#ifndef NO_UP_AXIS_SWAP
if (collada.state.up_axis==Vector3::AXIS_Z) {
SWAP( vtx.z, vtx.y );
vtx.z = -vtx.z;
}
- #endif
+#endif
Collada::Vertex vertex;
vertex.vertex=vtx;
@@ -1483,24 +1397,23 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
}
#endif
- for(int mi=0;mi<p_morph_meshes.size();mi++) {
+ for (int mi = 0; mi < p_morph_meshes.size(); mi++) {
//print_line("want surface "+itos(mi)+" has "+itos(p_morph_meshes[mi]->get_surface_count()));
Array a = p_morph_meshes[mi]->surface_get_arrays(surface);
//add valid weight and bone arrays if they exist, TODO check if they are unique to shape (generally not)
if (final_weight_array.size())
- a[Mesh::ARRAY_WEIGHTS]=final_weight_array;
+ a[Mesh::ARRAY_WEIGHTS] = final_weight_array;
if (final_bone_array.size())
- a[Mesh::ARRAY_BONES]=final_bone_array;
+ a[Mesh::ARRAY_BONES] = final_bone_array;
- a[Mesh::ARRAY_INDEX]=Variant();
+ a[Mesh::ARRAY_INDEX] = Variant();
//a.resize(Mesh::ARRAY_MAX); //no need for index
mr.push_back(a);
}
-
- p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES,d,mr,p_for_morph?0:Mesh::ARRAY_COMPRESS_DEFAULT);
+ p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, d, mr, p_for_morph ? 0 : Mesh::ARRAY_COMPRESS_DEFAULT);
if (material.is_valid()) {
if (p_use_mesh_material) {
@@ -1517,21 +1430,15 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
surface++;
}
-
return OK;
-
}
-
Error ColladaImport::_create_resources(Collada::Node *p_node) {
+ if (p_node->type == Collada::Node::TYPE_GEOMETRY && node_map.has(p_node->id)) {
- if (p_node->type==Collada::Node::TYPE_GEOMETRY && node_map.has(p_node->id)) {
-
-
- Spatial * node=node_map[p_node->id].node;
- Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry*>(p_node);
-
+ Spatial *node = node_map[p_node->id].node;
+ Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node);
if (node->cast_to<Path>()) {
@@ -1544,96 +1451,86 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
path->set_curve(curve_cache[ng->source]);
} else {
- Ref<Curve3D> c = memnew( Curve3D );
+ Ref<Curve3D> c = memnew(Curve3D);
const Collada::CurveData &cd = collada.state.curve_data_map[ng->source];
- ERR_FAIL_COND_V( !cd.control_vertices.has("POSITION") , ERR_INVALID_DATA);
- ERR_FAIL_COND_V( !cd.control_vertices.has("IN_TANGENT") , ERR_INVALID_DATA);
- ERR_FAIL_COND_V( !cd.control_vertices.has("OUT_TANGENT") , ERR_INVALID_DATA);
- ERR_FAIL_COND_V( !cd.control_vertices.has("INTERPOLATION") , ERR_INVALID_DATA);
-
+ ERR_FAIL_COND_V(!cd.control_vertices.has("POSITION"), ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!cd.control_vertices.has("IN_TANGENT"), ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!cd.control_vertices.has("OUT_TANGENT"), ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!cd.control_vertices.has("INTERPOLATION"), ERR_INVALID_DATA);
- ERR_FAIL_COND_V( !cd.sources.has(cd.control_vertices["POSITION"] ) , ERR_INVALID_DATA);
- const Collada::CurveData::Source &vertices = cd.sources[ cd.control_vertices["POSITION"] ];
- ERR_FAIL_COND_V( vertices.stride!=3, ERR_INVALID_DATA );
+ ERR_FAIL_COND_V(!cd.sources.has(cd.control_vertices["POSITION"]), ERR_INVALID_DATA);
+ const Collada::CurveData::Source &vertices = cd.sources[cd.control_vertices["POSITION"]];
+ ERR_FAIL_COND_V(vertices.stride != 3, ERR_INVALID_DATA);
- ERR_FAIL_COND_V( !cd.sources.has(cd.control_vertices["IN_TANGENT"] ) , ERR_INVALID_DATA);
- const Collada::CurveData::Source &in_tangents = cd.sources[ cd.control_vertices["IN_TANGENT"] ];
- ERR_FAIL_COND_V( in_tangents.stride!=3 , ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!cd.sources.has(cd.control_vertices["IN_TANGENT"]), ERR_INVALID_DATA);
+ const Collada::CurveData::Source &in_tangents = cd.sources[cd.control_vertices["IN_TANGENT"]];
+ ERR_FAIL_COND_V(in_tangents.stride != 3, ERR_INVALID_DATA);
- ERR_FAIL_COND_V( !cd.sources.has(cd.control_vertices["OUT_TANGENT"] ), ERR_INVALID_DATA );
- const Collada::CurveData::Source &out_tangents = cd.sources[ cd.control_vertices["OUT_TANGENT"] ];
- ERR_FAIL_COND_V( out_tangents.stride!=3, ERR_INVALID_DATA );
+ ERR_FAIL_COND_V(!cd.sources.has(cd.control_vertices["OUT_TANGENT"]), ERR_INVALID_DATA);
+ const Collada::CurveData::Source &out_tangents = cd.sources[cd.control_vertices["OUT_TANGENT"]];
+ ERR_FAIL_COND_V(out_tangents.stride != 3, ERR_INVALID_DATA);
- ERR_FAIL_COND_V( !cd.sources.has(cd.control_vertices["INTERPOLATION"] ), ERR_INVALID_DATA );
- const Collada::CurveData::Source &interps = cd.sources[ cd.control_vertices["INTERPOLATION"] ];
- ERR_FAIL_COND_V( interps.stride!=1, ERR_INVALID_DATA );
+ ERR_FAIL_COND_V(!cd.sources.has(cd.control_vertices["INTERPOLATION"]), ERR_INVALID_DATA);
+ const Collada::CurveData::Source &interps = cd.sources[cd.control_vertices["INTERPOLATION"]];
+ ERR_FAIL_COND_V(interps.stride != 1, ERR_INVALID_DATA);
- const Collada::CurveData::Source *tilts=NULL;
+ const Collada::CurveData::Source *tilts = NULL;
if (cd.control_vertices.has("TILT") && cd.sources.has(cd.control_vertices["TILT"]))
- tilts=&cd.sources[ cd.control_vertices["TILT"] ];
-
+ tilts = &cd.sources[cd.control_vertices["TILT"]];
if (tilts) {
print_line("FOUND TILTS!!!");
}
- int pc = vertices.array.size()/3;
- for(int i=0;i<pc;i++) {
+ int pc = vertices.array.size() / 3;
+ for (int i = 0; i < pc; i++) {
- Vector3 pos( vertices.array[i*3+0], vertices.array[i*3+1], vertices.array[i*3+2] );
- Vector3 in( in_tangents.array[i*3+0], in_tangents.array[i*3+1], in_tangents.array[i*3+2] );
- Vector3 out( out_tangents.array[i*3+0], out_tangents.array[i*3+1], out_tangents.array[i*3+2] );
+ Vector3 pos(vertices.array[i * 3 + 0], vertices.array[i * 3 + 1], vertices.array[i * 3 + 2]);
+ Vector3 in(in_tangents.array[i * 3 + 0], in_tangents.array[i * 3 + 1], in_tangents.array[i * 3 + 2]);
+ Vector3 out(out_tangents.array[i * 3 + 0], out_tangents.array[i * 3 + 1], out_tangents.array[i * 3 + 2]);
#ifndef NO_UP_AXIS_SWAP
- if (collada.state.up_axis==Vector3::AXIS_Z) {
-
- SWAP(pos.y,pos.z);
- pos.z=-pos.z;
- SWAP(in.y,in.z);
- in.z=-in.z;
- SWAP(out.y,out.z);
- out.z=-out.z;
+ if (collada.state.up_axis == Vector3::AXIS_Z) {
+
+ SWAP(pos.y, pos.z);
+ pos.z = -pos.z;
+ SWAP(in.y, in.z);
+ in.z = -in.z;
+ SWAP(out.y, out.z);
+ out.z = -out.z;
}
#endif
- pos*=collada.state.unit_scale;
- in*=collada.state.unit_scale;
- out*=collada.state.unit_scale;
+ pos *= collada.state.unit_scale;
+ in *= collada.state.unit_scale;
+ out *= collada.state.unit_scale;
- c->add_point(pos,in-pos,out-pos);
+ c->add_point(pos, in - pos, out - pos);
if (tilts)
- c->set_point_tilt(i,tilts->array[i]);
-
+ c->set_point_tilt(i, tilts->array[i]);
}
- curve_cache[ng->source]=c;
+ curve_cache[ng->source] = c;
path->set_curve(c);
-
}
-
-
}
-
if (node->cast_to<MeshInstance>()) {
-
- Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry*>(p_node);
+ Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node);
MeshInstance *mi = node->cast_to<MeshInstance>();
+ ERR_FAIL_COND_V(!mi, ERR_BUG);
- ERR_FAIL_COND_V(!mi,ERR_BUG);
-
-
- Collada::SkinControllerData *skin=NULL;
- Collada::MorphControllerData *morph=NULL;
+ Collada::SkinControllerData *skin = NULL;
+ Collada::MorphControllerData *morph = NULL;
String meshid;
Transform apply_xform;
Vector<int> bone_remap;
Vector<Ref<Mesh> > morphs;
- print_line("mesh: "+String(mi->get_name()));
+ print_line("mesh: " + String(mi->get_name()));
if (ng->controller) {
@@ -1643,95 +1540,93 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
if (collada.state.skin_controller_data_map.has(ngsource)) {
-
- ERR_FAIL_COND_V(!collada.state.skin_controller_data_map.has(ngsource),ERR_INVALID_DATA);
- skin=&collada.state.skin_controller_data_map[ngsource];
+ ERR_FAIL_COND_V(!collada.state.skin_controller_data_map.has(ngsource), ERR_INVALID_DATA);
+ skin = &collada.state.skin_controller_data_map[ngsource];
Vector<String> skeletons = ng->skeletons;
- ERR_FAIL_COND_V( skeletons.empty(), ERR_INVALID_DATA );
+ ERR_FAIL_COND_V(skeletons.empty(), ERR_INVALID_DATA);
String skname = skeletons[0];
if (!node_map.has(skname)) {
- print_line("no node for skeleton "+skname);
+ print_line("no node for skeleton " + skname);
}
- ERR_FAIL_COND_V( !node_map.has(skname), ERR_INVALID_DATA );
+ ERR_FAIL_COND_V(!node_map.has(skname), ERR_INVALID_DATA);
NodeMap nmsk = node_map[skname];
Skeleton *sk = nmsk.node->cast_to<Skeleton>();
- ERR_FAIL_COND_V( !sk, ERR_INVALID_DATA );
- ERR_FAIL_COND_V( !skeleton_bone_map.has(sk), ERR_INVALID_DATA );
- Map<String, int> &bone_remap_map=skeleton_bone_map[sk];
+ ERR_FAIL_COND_V(!sk, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!skeleton_bone_map.has(sk), ERR_INVALID_DATA);
+ Map<String, int> &bone_remap_map = skeleton_bone_map[sk];
-
- meshid=skin->base;
+ meshid = skin->base;
if (collada.state.morph_controller_data_map.has(meshid)) {
//it's a morph!!
morph = &collada.state.morph_controller_data_map[meshid];
- ngsource=meshid;
- meshid=morph->mesh;
+ ngsource = meshid;
+ meshid = morph->mesh;
} else {
- ngsource="";
+ ngsource = "";
}
if (apply_mesh_xform_to_vertices) {
- apply_xform=collada.fix_transform(p_node->default_transform);
+ apply_xform = collada.fix_transform(p_node->default_transform);
node->set_transform(Transform());
} else {
- apply_xform=Transform();
+ apply_xform = Transform();
}
- Collada::SkinControllerData::Source *joint_src=NULL;
+ Collada::SkinControllerData::Source *joint_src = NULL;
- ERR_FAIL_COND_V(!skin->weights.sources.has("JOINT"),ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!skin->weights.sources.has("JOINT"), ERR_INVALID_DATA);
String joint_id = skin->weights.sources["JOINT"].source;
- ERR_FAIL_COND_V(!skin->sources.has(joint_id),ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!skin->sources.has(joint_id), ERR_INVALID_DATA);
joint_src = &skin->sources[joint_id];
bone_remap.resize(joint_src->sarray.size());
- for(int i=0;i<bone_remap.size();i++) {
+ for (int i = 0; i < bone_remap.size(); i++) {
String str = joint_src->sarray[i];
if (!bone_remap_map.has(str)) {
- print_line("bone not found for remap: "+str);
- print_line("in skeleton: "+skname);
+ print_line("bone not found for remap: " + str);
+ print_line("in skeleton: " + skname);
}
- ERR_FAIL_COND_V( !bone_remap_map.has(str), ERR_INVALID_DATA );
- bone_remap[i]=bone_remap_map[str];
+ ERR_FAIL_COND_V(!bone_remap_map.has(str), ERR_INVALID_DATA);
+ bone_remap[i] = bone_remap_map[str];
}
}
if (collada.state.morph_controller_data_map.has(ngsource)) {
- print_line("is morph "+ngsource);
+ print_line("is morph " + ngsource);
//it's a morph!!
morph = &collada.state.morph_controller_data_map[ngsource];
- meshid=morph->mesh;
- printf("KKmorph: %p\n",morph);
- print_line("morph mshid: "+meshid);
+ meshid = morph->mesh;
+ printf("KKmorph: %p\n", morph);
+ print_line("morph mshid: " + meshid);
Vector<String> targets;
morph->targets.has("MORPH_TARGET");
String target = morph->targets["MORPH_TARGET"];
- bool valid=false;
+ bool valid = false;
if (morph->sources.has(target)) {
- valid=true;
+ valid = true;
Vector<String> names = morph->sources[target].sarray;
- for(int i=0;i<names.size();i++) {
+ for (int i = 0; i < names.size(); i++) {
- String meshid=names[i];
+ String meshid = names[i];
if (collada.state.mesh_data_map.has(meshid)) {
- Ref<Mesh> mesh=Ref<Mesh>(memnew( Mesh ));
+ Ref<Mesh> mesh = Ref<Mesh>(memnew(Mesh));
const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
- Error err = _create_mesh_surfaces(false,mesh,ng->material_map,meshdata,apply_xform,bone_remap,skin,NULL,Vector<Ref<Mesh> >(),true);
- ERR_FAIL_COND_V(err,err);
+ Error err = _create_mesh_surfaces(false, mesh, ng->material_map, meshdata, apply_xform, bone_remap, skin, NULL, Vector<Ref<Mesh> >(), true);
+ ERR_FAIL_COND_V(err, err);
morphs.push_back(mesh);
} else {
- valid=false;
+ valid = false;
}
}
}
@@ -1739,38 +1634,36 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
if (!valid)
morphs.clear();
- ngsource="";
+ ngsource = "";
}
- if (ngsource!=""){
- ERR_EXPLAIN("Controller Instance Source '"+ngsource+"' is neither skin or morph!");
- ERR_FAIL_V( ERR_INVALID_DATA );
+ if (ngsource != "") {
+ ERR_EXPLAIN("Controller Instance Source '" + ngsource + "' is neither skin or morph!");
+ ERR_FAIL_V(ERR_INVALID_DATA);
}
-
-
} else {
- meshid=ng->source;
+ meshid = ng->source;
}
Ref<Mesh> mesh;
if (mesh_cache.has(meshid)) {
- mesh=mesh_cache[meshid];
+ mesh = mesh_cache[meshid];
} else {
if (collada.state.mesh_data_map.has(meshid)) {
//bleh, must ignore invalid
- ERR_FAIL_COND_V(!collada.state.mesh_data_map.has(meshid),ERR_INVALID_DATA);
- mesh=Ref<Mesh>(memnew( Mesh ));
+ ERR_FAIL_COND_V(!collada.state.mesh_data_map.has(meshid), ERR_INVALID_DATA);
+ mesh = Ref<Mesh>(memnew(Mesh));
const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
- mesh->set_name( meshdata.name );
- Error err = _create_mesh_surfaces(morphs.size()==0,mesh,ng->material_map,meshdata,apply_xform,bone_remap,skin,morph,morphs,false,use_mesh_builtin_materials);
- ERR_FAIL_COND_V(err,err);
+ mesh->set_name(meshdata.name);
+ Error err = _create_mesh_surfaces(morphs.size() == 0, mesh, ng->material_map, meshdata, apply_xform, bone_remap, skin, morph, morphs, false, use_mesh_builtin_materials);
+ ERR_FAIL_COND_V(err, err);
- mesh_cache[meshid]=mesh;
+ mesh_cache[meshid] = mesh;
} else {
- print_line("Warning, will not import geometry: "+meshid);
+ print_line("Warning, will not import geometry: " + meshid);
}
}
@@ -1780,33 +1673,32 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
if (!use_mesh_builtin_materials) {
const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
- for(int i=0;i<meshdata.primitives.size();i++) {
+ for (int i = 0; i < meshdata.primitives.size(); i++) {
- String matname=meshdata.primitives[i].material;
+ String matname = meshdata.primitives[i].material;
if (ng->material_map.has(matname)) {
- String target=ng->material_map[matname].target;
+ String target = ng->material_map[matname].target;
Ref<Material> material;
if (!material_cache.has(target)) {
Error err = _create_material(target);
if (!err)
- material=material_cache[target];
+ material = material_cache[target];
} else
- material=material_cache[target];
+ material = material_cache[target];
- mi->set_surface_material(i,material);
- } else if (matname!=""){
- print_line("Warning, unreferenced material in geometry instance: "+matname);
+ mi->set_surface_material(i, material);
+ } else if (matname != "") {
+ print_line("Warning, unreferenced material in geometry instance: " + matname);
}
-
}
}
}
}
}
- for(int i=0;i<p_node->children.size();i++) {
+ for (int i = 0; i < p_node->children.size(); i++) {
Error err = _create_resources(p_node->children[i]);
if (err)
@@ -1815,64 +1707,60 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
return OK;
}
+Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_tangents) {
-Error ColladaImport::load(const String& p_path,int p_flags,bool p_force_make_tangents) {
-
- Error err = collada.load(p_path,p_flags);
- ERR_FAIL_COND_V(err,err);
+ Error err = collada.load(p_path, p_flags);
+ ERR_FAIL_COND_V(err, err);
- force_make_tangents=p_force_make_tangents;
- ERR_FAIL_COND_V( !collada.state.visual_scene_map.has( collada.state.root_visual_scene ), ERR_INVALID_DATA );
- Collada::VisualScene &vs = collada.state.visual_scene_map[ collada.state.root_visual_scene ];
+ force_make_tangents = p_force_make_tangents;
+ ERR_FAIL_COND_V(!collada.state.visual_scene_map.has(collada.state.root_visual_scene), ERR_INVALID_DATA);
+ Collada::VisualScene &vs = collada.state.visual_scene_map[collada.state.root_visual_scene];
- scene = memnew( Spatial ); // root
+ scene = memnew(Spatial); // root
//determine what's going on with the lights
- for(int i=0;i<vs.root_nodes.size();i++) {
+ for (int i = 0; i < vs.root_nodes.size(); i++) {
_pre_process_lights(vs.root_nodes[i]);
-
}
//import scene
- for(int i=0;i<vs.root_nodes.size();i++) {
+ for (int i = 0; i < vs.root_nodes.size(); i++) {
Error err = _create_scene_skeletons(vs.root_nodes[i]);
- if (err!=OK) {
+ if (err != OK) {
memdelete(scene);
- ERR_FAIL_COND_V(err,err);
+ ERR_FAIL_COND_V(err, err);
}
}
- for(int i=0;i<vs.root_nodes.size();i++) {
+ for (int i = 0; i < vs.root_nodes.size(); i++) {
- Error err = _create_scene(vs.root_nodes[i],scene);
- if (err!=OK) {
+ Error err = _create_scene(vs.root_nodes[i], scene);
+ if (err != OK) {
memdelete(scene);
- ERR_FAIL_COND_V(err,err);
+ ERR_FAIL_COND_V(err, err);
}
Error err2 = _create_resources(vs.root_nodes[i]);
- if (err2!=OK) {
+ if (err2 != OK) {
memdelete(scene);
- ERR_FAIL_COND_V(err2,err2);
+ ERR_FAIL_COND_V(err2, err2);
}
}
//optatively, set unit scale in the root
scene->set_transform(collada.get_root_transform());
-
return OK;
-
}
void ColladaImport::_fix_param_animation_tracks() {
- for (Map<String,Collada::Node*>::Element *E=collada.state.scene_map.front();E;E=E->next()) {
+ for (Map<String, Collada::Node *>::Element *E = collada.state.scene_map.front(); E; E = E->next()) {
Collada::Node *n = E->get();
- switch(n->type) {
+ switch (n->type) {
case Collada::Node::TYPE_NODE: {
// ? do nothing
@@ -1891,86 +1779,77 @@ void ColladaImport::_fix_param_animation_tracks() {
} break;
case Collada::Node::TYPE_GEOMETRY: {
- Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry*>(n);
+ Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(n);
// test source(s)
String source = ng->source;
- while (source!="") {
+ while (source != "") {
if (collada.state.skin_controller_data_map.has(source)) {
- const Collada::SkinControllerData& skin = collada.state.skin_controller_data_map[source];
+ const Collada::SkinControllerData &skin = collada.state.skin_controller_data_map[source];
//nothing to animate here i think
- source=skin.base;
+ source = skin.base;
} else if (collada.state.morph_controller_data_map.has(source)) {
-
- const Collada::MorphControllerData& morph = collada.state.morph_controller_data_map[source];
+ const Collada::MorphControllerData &morph = collada.state.morph_controller_data_map[source];
if (morph.targets.has("MORPH_WEIGHT") && morph.targets.has("MORPH_TARGET")) {
-
String weights = morph.targets["MORPH_WEIGHT"];
String targets = morph.targets["MORPH_TARGET"];
//fails here
if (morph.sources.has(targets) && morph.sources.has(weights)) {
- const Collada::MorphControllerData::Source &weight_src=morph.sources[weights];
- const Collada::MorphControllerData::Source &target_src=morph.sources[targets];
-
+ const Collada::MorphControllerData::Source &weight_src = morph.sources[weights];
+ const Collada::MorphControllerData::Source &target_src = morph.sources[targets];
ERR_FAIL_COND(weight_src.array.size() != target_src.sarray.size());
- for(int i=0;i<weight_src.array.size();i++) {
+ for (int i = 0; i < weight_src.array.size(); i++) {
- String track_name = weights+"("+itos(i)+")";
+ String track_name = weights + "(" + itos(i) + ")";
String mesh_name = target_src.sarray[i];
if (collada.state.mesh_name_map.has(mesh_name) && collada.state.referenced_tracks.has(track_name)) {
+ const Vector<int> &rt = collada.state.referenced_tracks[track_name];
- const Vector<int>&rt = collada.state.referenced_tracks[track_name];
-
- for(int rti=0;rti<rt.size();rti++) {
+ for (int rti = 0; rti < rt.size(); rti++) {
Collada::AnimationTrack *at = &collada.state.animation_tracks[rt[rti]];
- at->target=E->key();
- at->param="morph/"+collada.state.mesh_name_map[mesh_name];
- at->property=true;
+ at->target = E->key();
+ at->param = "morph/" + collada.state.mesh_name_map[mesh_name];
+ at->property = true;
//at->param
}
}
}
}
}
- source=morph.mesh;
+ source = morph.mesh;
} else {
- source=""; // for now nothing else supported
+ source = ""; // for now nothing else supported
}
}
} break;
-
}
}
-
}
void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks) {
-
_fix_param_animation_tracks();
- for(int i=0;i<collada.state.animation_clips.size();i++) {
+ for (int i = 0; i < collada.state.animation_clips.size(); i++) {
- for(int j=0;j<collada.state.animation_clips[i].tracks.size();j++)
+ for (int j = 0; j < collada.state.animation_clips[i].tracks.size(); j++)
tracks_in_clips.insert(collada.state.animation_clips[i].tracks[j]);
}
-
-
- for(int i=0;i<collada.state.animation_tracks.size();i++) {
+ for (int i = 0; i < collada.state.animation_tracks.size(); i++) {
Collada::AnimationTrack &at = collada.state.animation_tracks[i];
//print_line("CHANNEL: "+at.target+" PARAM: "+at.param);
@@ -1981,16 +1860,15 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im
if (node_name_map.has(at.target)) {
- node=node_name_map[at.target];
+ node = node_name_map[at.target];
} else {
- print_line("Coudlnt find node: "+at.target);
+ print_line("Coudlnt find node: " + at.target);
continue;
}
} else {
- node=at.target;
+ node = at.target;
}
-
if (at.property) {
valid_animated_properties.push_back(i);
@@ -2000,22 +1878,19 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im
node_map[node].anim_tracks.push_back(i);
valid_animated_nodes.insert(node);
}
-
}
- create_animation(-1,p_make_tracks_in_all_bones, p_import_value_tracks);
+ create_animation(-1, p_make_tracks_in_all_bones, p_import_value_tracks);
//print_line("clipcount: "+itos(collada.state.animation_clips.size()));
- for(int i=0;i<collada.state.animation_clips.size();i++)
+ for (int i = 0; i < collada.state.animation_clips.size(); i++)
create_animation(i, p_make_tracks_in_all_bones, p_import_value_tracks);
-
}
void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks) {
- Ref<Animation> animation = Ref<Animation>( memnew( Animation ));
-
+ Ref<Animation> animation = Ref<Animation>(memnew(Animation));
- if (p_clip==-1) {
+ if (p_clip == -1) {
//print_line("default");
animation->set_name("default");
@@ -2024,33 +1899,32 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
animation->set_name(collada.state.animation_clips[p_clip].name);
}
- for(Map<String,NodeMap>::Element *E=node_map.front();E;E=E->next()) {
+ for (Map<String, NodeMap>::Element *E = node_map.front(); E; E = E->next()) {
- if (E->get().bone<0)
+ if (E->get().bone < 0)
continue;
- bones_with_animation[E->key()]=false;
+ bones_with_animation[E->key()] = false;
}
//store and validate tracks
- if (p_clip==-1) {
+ if (p_clip == -1) {
//main anim
}
Set<int> track_filter;
+ if (p_clip == -1) {
- if (p_clip==-1) {
-
- for(int i=0;i<collada.state.animation_clips.size();i++) {
+ for (int i = 0; i < collada.state.animation_clips.size(); i++) {
int tc = collada.state.animation_clips[i].tracks.size();
- for(int j=0;j<tc;j++) {
+ for (int j = 0; j < tc; j++) {
String n = collada.state.animation_clips[i].tracks[j];
if (collada.state.by_id_tracks.has(n)) {
- const Vector<int>&ti = collada.state.by_id_tracks[n];
- for(int k=0;k<ti.size();k++) {
+ const Vector<int> &ti = collada.state.by_id_tracks[n];
+ for (int k = 0; k < ti.size(); k++) {
track_filter.insert(ti[k]);
}
}
@@ -2059,18 +1933,17 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
} else {
int tc = collada.state.animation_clips[p_clip].tracks.size();
- for(int j=0;j<tc;j++) {
+ for (int j = 0; j < tc; j++) {
String n = collada.state.animation_clips[p_clip].tracks[j];
if (collada.state.by_id_tracks.has(n)) {
- const Vector<int>&ti = collada.state.by_id_tracks[n];
- for(int k=0;k<ti.size();k++) {
+ const Vector<int> &ti = collada.state.by_id_tracks[n];
+ for (int k = 0; k < ti.size(); k++) {
track_filter.insert(ti[k]);
}
}
}
-
}
//animation->set_loop(true);
@@ -2078,37 +1951,33 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
Vector<float> base_snapshots;
- float f=0;
- float snapshot_interval = 1.0/bake_fps; //should be customizable somewhere...
+ float f = 0;
+ float snapshot_interval = 1.0 / bake_fps; //should be customizable somewhere...
- float anim_length=collada.state.animation_length;
- if (p_clip>=0 && collada.state.animation_clips[p_clip].end)
- anim_length=collada.state.animation_clips[p_clip].end;
+ float anim_length = collada.state.animation_length;
+ if (p_clip >= 0 && collada.state.animation_clips[p_clip].end)
+ anim_length = collada.state.animation_clips[p_clip].end;
- while(f<anim_length) {
+ while (f < anim_length) {
base_snapshots.push_back(f);
- f+=snapshot_interval;
+ f += snapshot_interval;
- if (f>=anim_length) {
+ if (f >= anim_length) {
base_snapshots.push_back(anim_length);
-
}
}
//print_line("anim len: "+rtos(anim_length));
animation->set_length(anim_length);
- bool tracks_found=false;
-
-
+ bool tracks_found = false;
- for(Set<String>::Element* E=valid_animated_nodes.front();E;E=E->next()) {
+ for (Set<String>::Element *E = valid_animated_nodes.front(); E; E = E->next()) {
// take snapshots
-
if (!collada.state.scene_map.has(E->get())) {
continue;
@@ -2117,14 +1986,13 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
NodeMap &nm = node_map[E->get()];
String path = scene->get_path_to(nm.node);
- if (nm.bone>=0) {
- Skeleton *sk = static_cast<Skeleton*>(nm.node);
+ if (nm.bone >= 0) {
+ Skeleton *sk = static_cast<Skeleton *>(nm.node);
String name = sk->get_bone_name(nm.bone);
- path=path+":"+name;
+ path = path + ":" + name;
}
- bool found_anim=false;
-
+ bool found_anim = false;
Collada::Node *cn = collada.state.scene_map[E->get()];
if (cn->ignore_anim) {
@@ -2132,34 +2000,27 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
continue;
}
-
-
animation->add_track(Animation::TYPE_TRANSFORM);
- int track = animation->get_track_count() -1;
- animation->track_set_path( track , path );
- animation->track_set_imported( track , true ); //helps merging later
+ int track = animation->get_track_count() - 1;
+ animation->track_set_path(track, path);
+ animation->track_set_imported(track, true); //helps merging later
Vector<float> snapshots = base_snapshots;
- if (nm.anim_tracks.size()==1) {
+ if (nm.anim_tracks.size() == 1) {
//use snapshot keys from anim track instead, because this was most likely exported baked
Collada::AnimationTrack &at = collada.state.animation_tracks[nm.anim_tracks.front()->get()];
snapshots.clear();
- for(int i=0;i<at.keys.size();i++)
+ for (int i = 0; i < at.keys.size(); i++)
snapshots.push_back(at.keys[i].time);
-
-
}
+ for (int i = 0; i < snapshots.size(); i++) {
- for(int i=0;i<snapshots.size();i++) {
-
-
- for(List<int>::Element *ET=nm.anim_tracks.front();ET;ET=ET->next()) {
+ for (List<int>::Element *ET = nm.anim_tracks.front(); ET; ET = ET->next()) {
//apply tracks
-
- if (p_clip==-1) {
+ if (p_clip == -1) {
if (track_filter.has(ET->get())) {
@@ -2169,66 +2030,61 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
if (!track_filter.has(ET->get()))
continue;
-
}
- found_anim=true;
+ found_anim = true;
Collada::AnimationTrack &at = collada.state.animation_tracks[ET->get()];
- int xform_idx=-1;
- for(int j=0;j<cn->xform_list.size();j++) {
+ int xform_idx = -1;
+ for (int j = 0; j < cn->xform_list.size(); j++) {
+ if (cn->xform_list[j].id == at.param) {
- if (cn->xform_list[j].id==at.param) {
-
- xform_idx=j;
+ xform_idx = j;
break;
}
}
- if (xform_idx==-1) {
- print_line("couldnt find matching node "+at.target+" xform for track "+at.param);
- continue;
+ if (xform_idx == -1) {
+ print_line("couldnt find matching node " + at.target + " xform for track " + at.param);
+ continue;
}
- ERR_CONTINUE(xform_idx==-1);
+ ERR_CONTINUE(xform_idx == -1);
Vector<float> data = at.get_value_at_time(snapshots[i]);
ERR_CONTINUE(data.empty());
-
Collada::Node::XForm &xf = cn->xform_list[xform_idx];
- if (at.component=="ANGLE") {
- ERR_CONTINUE(data.size()!=1);
- ERR_CONTINUE(xf.op!=Collada::Node::XForm::OP_ROTATE);
- ERR_CONTINUE(xf.data.size()<4);
- xf.data[3]=data[0];
- } else if (at.component=="X" || at.component=="Y" || at.component=="Z") {
- int cn=at.component[0]-'X';
- ERR_CONTINUE(cn>=xf.data.size());
- ERR_CONTINUE(data.size()>1);
- xf.data[cn]=data[0];
- } else if (data.size()==xf.data.size()) {
-
- xf.data=data;
+ if (at.component == "ANGLE") {
+ ERR_CONTINUE(data.size() != 1);
+ ERR_CONTINUE(xf.op != Collada::Node::XForm::OP_ROTATE);
+ ERR_CONTINUE(xf.data.size() < 4);
+ xf.data[3] = data[0];
+ } else if (at.component == "X" || at.component == "Y" || at.component == "Z") {
+ int cn = at.component[0] - 'X';
+ ERR_CONTINUE(cn >= xf.data.size());
+ ERR_CONTINUE(data.size() > 1);
+ xf.data[cn] = data[0];
+ } else if (data.size() == xf.data.size()) {
+
+ xf.data = data;
} else {
-
- if ( data.size()!=xf.data.size() ) {
- print_line("component "+at.component+" datasize "+itos(data.size())+" xfdatasize "+itos(xf.data.size()));
+ if (data.size() != xf.data.size()) {
+ print_line("component " + at.component + " datasize " + itos(data.size()) + " xfdatasize " + itos(xf.data.size()));
}
- ERR_CONTINUE( data.size()!=xf.data.size() );
+ ERR_CONTINUE(data.size() != xf.data.size());
}
}
Transform xform = cn->compute_transform(collada);
xform = collada.fix_transform(xform) * cn->post_transform;
-
- if (nm.bone>=0) {
+ if (nm.bone >= 0) {
//make bone transform relative to rest (in case of skeleton)
Skeleton *sk = nm.node->cast_to<Skeleton>();
if (sk) {
@@ -2245,29 +2101,25 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
Vector3 s = xform.basis.get_scale();
Vector3 l = xform.origin;
- animation->transform_track_insert_key(track,snapshots[i],l,q,s);
-
+ animation->transform_track_insert_key(track, snapshots[i], l, q, s);
}
-
-
- if (nm.bone>=0) {
+ if (nm.bone >= 0) {
if (found_anim)
- bones_with_animation[E->get()]=true;
+ bones_with_animation[E->get()] = true;
}
if (found_anim)
- tracks_found=true;
+ tracks_found = true;
else {
- animation->remove_track( track );
+ animation->remove_track(track);
}
-
}
if (p_make_tracks_in_all_bones) {
//some bones may lack animation, but since we don't store pose as a property, we must add keyframes!
- for(Map<String,bool>::Element *E=bones_with_animation.front();E;E=E->next()) {
+ for (Map<String, bool>::Element *E = bones_with_animation.front(); E; E = E->next()) {
if (E->get())
continue;
@@ -2276,22 +2128,21 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
NodeMap &nm = node_map[E->key()];
String path = scene->get_path_to(nm.node);
- ERR_CONTINUE( nm.bone <0 );
- Skeleton *sk = static_cast<Skeleton*>(nm.node);
+ ERR_CONTINUE(nm.bone < 0);
+ Skeleton *sk = static_cast<Skeleton *>(nm.node);
String name = sk->get_bone_name(nm.bone);
- path=path+":"+name;
+ path = path + ":" + name;
Collada::Node *cn = collada.state.scene_map[E->key()];
if (cn->ignore_anim) {
- print_line("warning, ignoring animation on node: "+path);
+ print_line("warning, ignoring animation on node: " + path);
continue;
}
animation->add_track(Animation::TYPE_TRANSFORM);
- int track = animation->get_track_count() -1;
- animation->track_set_path( track , path );
- animation->track_set_imported( track , true ); //helps merging later
-
+ int track = animation->get_track_count() - 1;
+ animation->track_set_path(track, path);
+ animation->track_set_imported(track, true); //helps merging later
Transform xform = cn->compute_transform(collada);
xform = collada.fix_transform(xform) * cn->post_transform;
@@ -2303,33 +2154,27 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
Vector3 s = xform.basis.get_scale();
Vector3 l = xform.origin;
- animation->transform_track_insert_key(track,0,l,q,s);
+ animation->transform_track_insert_key(track, 0, l, q, s);
- tracks_found=true;
+ tracks_found = true;
}
}
-
-
if (p_import_value_tracks) {
for (int i = 0; i < valid_animated_properties.size(); i++) {
-
int ti = valid_animated_properties[i];
if (p_clip == -1) {
if (track_filter.has(ti))
continue;
- }
- else {
+ } else {
if (!track_filter.has(ti))
continue;
-
}
-
Collada::AnimationTrack &at = collada.state.animation_tracks[ti];
// take snapshots
@@ -2346,7 +2191,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
animation->track_set_path(track, path);
animation->track_set_imported(track, true); //helps merging later
-
for (int i = 0; i < at.keys.size(); i++) {
float time = at.keys[i].time;
@@ -2356,12 +2200,10 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
//push a float
value = data[0];
- }
- else if (data.size() == 16) {
+ } else if (data.size() == 16) {
//matrix
print_line("value keys for matrices not supported");
- }
- else {
+ } else {
print_line("don't know what to do with this amount of value keys: " + itos(data.size()));
}
@@ -2369,55 +2211,43 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
animation->track_insert_key(track, time, value);
}
-
tracks_found = true;
-
}
}
-
-
if (tracks_found) {
animations.push_back(animation);
}
-
-
-
}
-
/*********************************************************************************/
/*************************************** SCENE ***********************************/
/*********************************************************************************/
-
#define DEBUG_ANIMATION
-
uint32_t EditorSceneImporterCollada::get_import_flags() const {
- return IMPORT_SCENE|IMPORT_ANIMATION;
-
+ return IMPORT_SCENE | IMPORT_ANIMATION;
}
void EditorSceneImporterCollada::get_extensions(List<String> *r_extensions) const {
-
r_extensions->push_back("dae");
}
-Node* EditorSceneImporterCollada::import_scene(const String& p_path, uint32_t p_flags,int p_bake_fps, List<String> *r_missing_deps, Error* r_err) {
+Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
ColladaImport state;
- uint32_t flags=Collada::IMPORT_FLAG_SCENE;
- if (p_flags&IMPORT_ANIMATION)
- flags|=Collada::IMPORT_FLAG_ANIMATION;
+ uint32_t flags = Collada::IMPORT_FLAG_SCENE;
+ if (p_flags & IMPORT_ANIMATION)
+ flags |= Collada::IMPORT_FLAG_ANIMATION;
- state.use_mesh_builtin_materials=!(p_flags&IMPORT_MATERIALS_IN_INSTANCES);
- state.bake_fps=p_bake_fps;
+ state.use_mesh_builtin_materials = !(p_flags & IMPORT_MATERIALS_IN_INSTANCES);
+ state.bake_fps = p_bake_fps;
- Error err = state.load(p_path,flags,p_flags&EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS);
+ Error err = state.load(p_path, flags, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS);
- ERR_FAIL_COND_V(err!=OK,NULL);
+ ERR_FAIL_COND_V(err != OK, NULL);
if (state.missing_textures.size()) {
@@ -2427,82 +2257,70 @@ Node* EditorSceneImporterCollada::import_scene(const String& p_path, uint32_t p_
}
*/
-
if (r_missing_deps) {
- for(int i=0;i<state.missing_textures.size();i++) {
+ for (int i = 0; i < state.missing_textures.size(); i++) {
//EditorNode::add_io_error("Texture Not Found: "+state.missing_textures[i]);
r_missing_deps->push_back(state.missing_textures[i]);
}
-
}
}
- if (p_flags&IMPORT_ANIMATION) {
+ if (p_flags & IMPORT_ANIMATION) {
- state.create_animations(p_flags&IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS,p_flags&EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS);
- AnimationPlayer *ap = memnew( AnimationPlayer );
- for(int i=0;i<state.animations.size();i++) {
+ state.create_animations(p_flags & IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS, p_flags & EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS);
+ AnimationPlayer *ap = memnew(AnimationPlayer);
+ for (int i = 0; i < state.animations.size(); i++) {
String name;
- if (state.animations[i]->get_name()=="")
- name="default";
+ if (state.animations[i]->get_name() == "")
+ name = "default";
else
- name=state.animations[i]->get_name();
+ name = state.animations[i]->get_name();
- if (p_flags&IMPORT_ANIMATION_DETECT_LOOP) {
+ if (p_flags & IMPORT_ANIMATION_DETECT_LOOP) {
if (name.begins_with("loop") || name.ends_with("loop") || name.begins_with("cycle") || name.ends_with("cycle")) {
state.animations[i]->set_loop(true);
}
}
- ap->add_animation(name,state.animations[i]);
+ ap->add_animation(name, state.animations[i]);
}
state.scene->add_child(ap);
ap->set_owner(state.scene);
-
}
return state.scene;
-
}
-Ref<Animation> EditorSceneImporterCollada::import_animation(const String& p_path,uint32_t p_flags) {
-
+Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path, uint32_t p_flags) {
ColladaImport state;
+ state.use_mesh_builtin_materials = false;
- state.use_mesh_builtin_materials=false;
-
- Error err = state.load(p_path,Collada::IMPORT_FLAG_ANIMATION,p_flags&EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS);
- ERR_FAIL_COND_V(err!=OK,RES());
+ Error err = state.load(p_path, Collada::IMPORT_FLAG_ANIMATION, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS);
+ ERR_FAIL_COND_V(err != OK, RES());
-
- state.create_animations(p_flags&EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS,p_flags&EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS);
+ state.create_animations(p_flags & EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS, p_flags & EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS);
if (state.scene)
memdelete(state.scene);
- if (state.animations.size()==0)
+ if (state.animations.size() == 0)
return Ref<Animation>();
- Ref<Animation> anim=state.animations[0];
- anim=state.animations[0];
+ Ref<Animation> anim = state.animations[0];
+ anim = state.animations[0];
print_line("Anim Load OK");
String base = p_path.get_basename().to_lower();
- if (p_flags&IMPORT_ANIMATION_DETECT_LOOP) {
+ if (p_flags & IMPORT_ANIMATION_DETECT_LOOP) {
if (base.begins_with("loop") || base.ends_with("loop") || base.begins_with("cycle") || base.ends_with("cycle")) {
anim->set_loop(true);
}
}
-
return anim;
}
-
EditorSceneImporterCollada::EditorSceneImporterCollada() {
-
-
}
-
diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h
index 5c7624bd33..f9e9c10980 100644
--- a/editor/import/editor_import_collada.h
+++ b/editor/import/editor_import_collada.h
@@ -31,21 +31,17 @@
#include "editor/import/resource_importer_scene.h"
-
-
class EditorSceneImporterCollada : public EditorSceneImporter {
- GDCLASS(EditorSceneImporterCollada,EditorSceneImporter );
-public:
+ GDCLASS(EditorSceneImporterCollada, EditorSceneImporter);
+public:
virtual uint32_t get_import_flags() const;
virtual void get_extensions(List<String> *r_extensions) const;
- virtual Node* import_scene(const String& p_path,uint32_t p_flags,int p_bake_fps,List<String> *r_missing_deps=NULL,Error* r_err=NULL);
- virtual Ref<Animation> import_animation(const String& p_path,uint32_t p_flags);
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = NULL, Error *r_err = NULL);
+ virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags);
EditorSceneImporterCollada();
};
-
#endif
-
diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp
index faf62d2839..3be89920fb 100644
--- a/editor/import/resource_importer_csv_translation.cpp
+++ b/editor/import/resource_importer_csv_translation.cpp
@@ -28,21 +28,21 @@
/*************************************************************************/
#include "resource_importer_csv_translation.h"
+#include "compressed_translation.h"
+#include "io/resource_saver.h"
#include "os/file_access.h"
#include "translation.h"
-#include "io/resource_saver.h"
-#include "compressed_translation.h"
String ResourceImporterCSVTranslation::get_importer_name() const {
return "csv_translation";
}
-String ResourceImporterCSVTranslation::get_visible_name() const{
+String ResourceImporterCSVTranslation::get_visible_name() const {
return "CSV Translation";
}
-void ResourceImporterCSVTranslation::get_recognized_extensions(List<String> *p_extensions) const{
+void ResourceImporterCSVTranslation::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("csv");
}
@@ -51,12 +51,12 @@ String ResourceImporterCSVTranslation::get_save_extension() const {
return ""; //does not save a single resoure
}
-String ResourceImporterCSVTranslation::get_resource_type() const{
+String ResourceImporterCSVTranslation::get_resource_type() const {
return "StreamCSVTranslation";
}
-bool ResourceImporterCSVTranslation::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const {
+bool ResourceImporterCSVTranslation::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
return true;
}
@@ -69,33 +69,27 @@ String ResourceImporterCSVTranslation::get_preset_name(int p_idx) const {
return "";
}
+void ResourceImporterCSVTranslation::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-void ResourceImporterCSVTranslation::get_import_options(List<ImportOption> *r_options,int p_preset) const {
-
-
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"compress"),true));
-
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true));
}
-
-
-Error ResourceImporterCSVTranslation::import(const String& p_source_file, const String& p_save_path, const Map<StringName,Variant>& p_options, List<String>* r_platform_variants, List<String> *r_gen_files) {
-
+Error ResourceImporterCSVTranslation::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
bool compress = p_options["compress"];
- FileAccessRef f = FileAccess::open(p_source_file,FileAccess::READ);
+ FileAccessRef f = FileAccess::open(p_source_file, FileAccess::READ);
- ERR_FAIL_COND_V( !f, ERR_INVALID_PARAMETER );
+ ERR_FAIL_COND_V(!f, ERR_INVALID_PARAMETER);
Vector<String> line = f->get_csv_line();
- if (line.size()<=1) {
+ if (line.size() <= 1) {
return ERR_PARSE_ERROR;
}
Vector<String> locales;
Vector<Ref<Translation> > translations;
- for(int i=1;i<line.size();i++) {
+ for (int i = 1; i < line.size(); i++) {
String locale = line[i];
if (!TranslationServer::is_locale_valid(locale)) {
@@ -111,44 +105,38 @@ Error ResourceImporterCSVTranslation::import(const String& p_source_file, const
line = f->get_csv_line();
- while(line.size()==locales.size()+1) {
+ while (line.size() == locales.size() + 1) {
String key = line[0];
- if (key!="") {
+ if (key != "") {
- for(int i=1;i<line.size();i++) {
- translations[i-1]->add_message(key,line[i]);
+ for (int i = 1; i < line.size(); i++) {
+ translations[i - 1]->add_message(key, line[i]);
}
}
line = f->get_csv_line();
}
-
- for(int i=0;i<translations.size();i++) {
+ for (int i = 0; i < translations.size(); i++) {
Ref<Translation> xlt = translations[i];
if (compress) {
- Ref<PHashTranslation> cxl = memnew( PHashTranslation );
- cxl->generate( xlt );
- xlt=cxl;
+ Ref<PHashTranslation> cxl = memnew(PHashTranslation);
+ cxl->generate(xlt);
+ xlt = cxl;
}
- String save_path = p_source_file.get_basename()+"."+translations[i]->get_locale()+".xl";
+ String save_path = p_source_file.get_basename() + "." + translations[i]->get_locale() + ".xl";
- ResourceSaver::save(save_path,xlt);
+ ResourceSaver::save(save_path, xlt);
if (r_gen_files) {
r_gen_files->push_back(save_path);
}
}
-
-
return OK;
-
}
-ResourceImporterCSVTranslation::ResourceImporterCSVTranslation()
-{
-
+ResourceImporterCSVTranslation::ResourceImporterCSVTranslation() {
}
diff --git a/editor/import/resource_importer_csv_translation.h b/editor/import/resource_importer_csv_translation.h
index a25e6a0fa8..8b1e1b5827 100644
--- a/editor/import/resource_importer_csv_translation.h
+++ b/editor/import/resource_importer_csv_translation.h
@@ -31,9 +31,8 @@
#include "io/resource_import.h"
-
class ResourceImporterCSVTranslation : public ResourceImporter {
- GDCLASS(ResourceImporterCSVTranslation,ResourceImporter)
+ GDCLASS(ResourceImporterCSVTranslation, ResourceImporter)
public:
virtual String get_importer_name() const;
virtual String get_visible_name() const;
@@ -44,10 +43,10 @@ public:
virtual int get_preset_count() const;
virtual String get_preset_name(int p_idx) const;
- virtual void get_import_options(List<ImportOption> *r_options,int p_preset=0) const;
- virtual bool get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const;
+ virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
+ virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
- virtual Error import(const String& p_source_file,const String& p_save_path,const Map<StringName,Variant>& p_options,List<String>* r_platform_variants,List<String>* r_gen_files=NULL);
+ virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL);
ResourceImporterCSVTranslation();
};
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 3b3e0e3a00..145071d4cb 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -29,21 +29,21 @@
#include "resource_importer_obj.h"
#include "io/resource_saver.h"
+#include "os/file_access.h"
#include "scene/resources/mesh.h"
#include "scene/resources/surface_tool.h"
#include "scene/resources/surface_tool.h"
-#include "os/file_access.h"
String ResourceImporterOBJ::get_importer_name() const {
return "obj_mesh";
}
-String ResourceImporterOBJ::get_visible_name() const{
+String ResourceImporterOBJ::get_visible_name() const {
return "OBJ As Mesh";
}
-void ResourceImporterOBJ::get_recognized_extensions(List<String> *p_extensions) const{
+void ResourceImporterOBJ::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("obj");
}
@@ -51,12 +51,12 @@ String ResourceImporterOBJ::get_save_extension() const {
return "msh";
}
-String ResourceImporterOBJ::get_resource_type() const{
+String ResourceImporterOBJ::get_resource_type() const {
return "Mesh";
}
-bool ResourceImporterOBJ::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const {
+bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
return true;
}
@@ -69,138 +69,129 @@ String ResourceImporterOBJ::get_preset_name(int p_idx) const {
return String();
}
+void ResourceImporterOBJ::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-void ResourceImporterOBJ::get_import_options(List<ImportOption> *r_options,int p_preset) const {
-
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"generate/tangents"),true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"generate/normals"),true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate/tangents"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate/normals"), true));
//not for nowp
//r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"import/materials")));
//r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"import/textures")));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"force/flip_faces"),false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"force/smooth_shading"),true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"force/weld_vertices"),true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"force/weld_tolerance",PROPERTY_HINT_RANGE,"0.00001,16,0.00001"),0.0001));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/flip_faces"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/smooth_shading"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/weld_vertices"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "force/weld_tolerance", PROPERTY_HINT_RANGE, "0.00001,16,0.00001"), 0.0001));
//r_options->push_back(PropertyInfo(Variant::INT,"compress/bitrate",PROPERTY_HINT_ENUM,"64,96,128,192"));
-
}
+Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
+ FileAccessRef f = FileAccess::open(p_source_file, FileAccess::READ);
+ ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
-Error ResourceImporterOBJ::import(const String& p_source_file, const String& p_save_path, const Map<StringName,Variant>& p_options, List<String>* r_platform_variants, List<String> *r_gen_files) {
-
- FileAccessRef f = FileAccess::open(p_source_file,FileAccess::READ);
- ERR_FAIL_COND_V(!f,ERR_CANT_OPEN);
-
- Ref<Mesh> mesh = Ref<Mesh>( memnew( Mesh ) );
- Map<String,Ref<Material> > name_map;
-
+ Ref<Mesh> mesh = Ref<Mesh>(memnew(Mesh));
+ Map<String, Ref<Material> > name_map;
-
- bool generate_normals=p_options["generate/normals"];
- bool generate_tangents=p_options["generate/tangents"];
- bool flip_faces=p_options["force/flip_faces"];
- bool force_smooth=p_options["force/smooth_shading"];
- bool weld_vertices=p_options["force/weld_vertices"];
- float weld_tolerance=p_options["force/weld_tolerance"];
+ bool generate_normals = p_options["generate/normals"];
+ bool generate_tangents = p_options["generate/tangents"];
+ bool flip_faces = p_options["force/flip_faces"];
+ bool force_smooth = p_options["force/smooth_shading"];
+ bool weld_vertices = p_options["force/weld_vertices"];
+ float weld_tolerance = p_options["force/weld_tolerance"];
Vector<Vector3> vertices;
Vector<Vector3> normals;
Vector<Vector2> uvs;
String name;
- Ref<SurfaceTool> surf_tool = memnew( SurfaceTool) ;
+ Ref<SurfaceTool> surf_tool = memnew(SurfaceTool);
surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
if (force_smooth)
surf_tool->add_smooth_group(true);
- int has_index_data=false;
-
- while(true) {
+ int has_index_data = false;
+ while (true) {
String l = f->get_line().strip_edges();
if (l.begins_with("v ")) {
//vertex
- Vector<String> v = l.split(" ",false);
- ERR_FAIL_COND_V(v.size()<4,ERR_INVALID_DATA);
+ Vector<String> v = l.split(" ", false);
+ ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA);
Vector3 vtx;
- vtx.x=v[1].to_float();
- vtx.y=v[2].to_float();
- vtx.z=v[3].to_float();
+ vtx.x = v[1].to_float();
+ vtx.y = v[2].to_float();
+ vtx.z = v[3].to_float();
vertices.push_back(vtx);
- } else if (l.begins_with("vt ")) {
+ } else if (l.begins_with("vt ")) {
//uv
- Vector<String> v = l.split(" ",false);
- ERR_FAIL_COND_V(v.size()<3,ERR_INVALID_DATA);
+ Vector<String> v = l.split(" ", false);
+ ERR_FAIL_COND_V(v.size() < 3, ERR_INVALID_DATA);
Vector2 uv;
- uv.x=v[1].to_float();
- uv.y=1.0-v[2].to_float();
+ uv.x = v[1].to_float();
+ uv.y = 1.0 - v[2].to_float();
uvs.push_back(uv);
} else if (l.begins_with("vn ")) {
//normal
- Vector<String> v = l.split(" ",false);
- ERR_FAIL_COND_V(v.size()<4,ERR_INVALID_DATA);
+ Vector<String> v = l.split(" ", false);
+ ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA);
Vector3 nrm;
- nrm.x=v[1].to_float();
- nrm.y=v[2].to_float();
- nrm.z=v[3].to_float();
+ nrm.x = v[1].to_float();
+ nrm.y = v[2].to_float();
+ nrm.z = v[3].to_float();
normals.push_back(nrm);
} else if (l.begins_with("f ")) {
- //vertex
+ //vertex
- has_index_data=true;
- Vector<String> v = l.split(" ",false);
- ERR_FAIL_COND_V(v.size()<4,ERR_INVALID_DATA);
+ has_index_data = true;
+ Vector<String> v = l.split(" ", false);
+ ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA);
//not very fast, could be sped up
-
Vector<String> face[3];
face[0] = v[1].split("/");
face[1] = v[2].split("/");
- ERR_FAIL_COND_V(face[0].size()==0,ERR_PARSE_ERROR);
- ERR_FAIL_COND_V(face[0].size()!=face[1].size(),ERR_PARSE_ERROR);
- for(int i=2;i<v.size()-1;i++) {
+ ERR_FAIL_COND_V(face[0].size() == 0, ERR_PARSE_ERROR);
+ ERR_FAIL_COND_V(face[0].size() != face[1].size(), ERR_PARSE_ERROR);
+ for (int i = 2; i < v.size() - 1; i++) {
- face[2] = v[i+1].split("/");
- ERR_FAIL_COND_V(face[0].size()!=face[2].size(),ERR_PARSE_ERROR);
- for(int j=0;j<3;j++) {
+ face[2] = v[i + 1].split("/");
+ ERR_FAIL_COND_V(face[0].size() != face[2].size(), ERR_PARSE_ERROR);
+ for (int j = 0; j < 3; j++) {
- int idx=j;
+ int idx = j;
- if (!flip_faces && idx<2) {
- idx=1^idx;
+ if (!flip_faces && idx < 2) {
+ idx = 1 ^ idx;
}
-
- if (face[idx].size()==3) {
- int norm = face[idx][2].to_int()-1;
- ERR_FAIL_INDEX_V(norm,normals.size(),ERR_PARSE_ERROR);
+ if (face[idx].size() == 3) {
+ int norm = face[idx][2].to_int() - 1;
+ ERR_FAIL_INDEX_V(norm, normals.size(), ERR_PARSE_ERROR);
surf_tool->add_normal(normals[norm]);
}
- if (face[idx].size()>=2 && face[idx][1]!=String()) {
+ if (face[idx].size() >= 2 && face[idx][1] != String()) {
- int uv = face[idx][1].to_int()-1;
- ERR_FAIL_INDEX_V(uv,uvs.size(),ERR_PARSE_ERROR);
+ int uv = face[idx][1].to_int() - 1;
+ ERR_FAIL_INDEX_V(uv, uvs.size(), ERR_PARSE_ERROR);
surf_tool->add_uv(uvs[uv]);
}
- int vtx = face[idx][0].to_int()-1;
- ERR_FAIL_INDEX_V(vtx,vertices.size(),ERR_PARSE_ERROR);
+ int vtx = face[idx][0].to_int() - 1;
+ ERR_FAIL_INDEX_V(vtx, vertices.size(), ERR_PARSE_ERROR);
Vector3 vertex = vertices[vtx];
if (weld_vertices)
- vertex=vertex.snapped(weld_tolerance);
+ vertex = vertex.snapped(weld_tolerance);
surf_tool->add_vertex(vertex);
}
- face[1]=face[2];
+ face[1] = face[2];
}
} else if (l.begins_with("s ") && !force_smooth) { //smoothing
- String what = l.substr(2,l.length()).strip_edges();
- if (what=="off")
+ String what = l.substr(2, l.length()).strip_edges();
+ if (what == "off")
surf_tool->add_smooth_group(false);
else
surf_tool->add_smooth_group(true);
@@ -216,27 +207,27 @@ Error ResourceImporterOBJ::import(const String& p_source_file, const String& p_s
surf_tool->index();
mesh = surf_tool->commit(mesh);
- if (name=="")
- name=vformat(TTR("Surface %d"),mesh->get_surface_count()-1);
- mesh->surface_set_name(mesh->get_surface_count()-1,name);
- name="";
+ if (name == "")
+ name = vformat(TTR("Surface %d"), mesh->get_surface_count() - 1);
+ mesh->surface_set_name(mesh->get_surface_count() - 1, name);
+ name = "";
surf_tool->clear();
surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
if (force_smooth)
surf_tool->add_smooth_group(true);
- has_index_data=false;
+ has_index_data = false;
if (f->eof_reached())
break;
}
if (l.begins_with("o ")) //name
- name=l.substr(2,l.length()).strip_edges();
+ name = l.substr(2, l.length()).strip_edges();
}
}
-/*
+ /*
TODO, check existing materials and merge?
//re-apply materials if exist
for(int i=0;i<mesh->get_surface_count();i++) {
@@ -247,13 +238,10 @@ Error ResourceImporterOBJ::import(const String& p_source_file, const String& p_s
}
*/
- Error err = ResourceSaver::save(p_save_path+".msh",mesh);
+ Error err = ResourceSaver::save(p_save_path + ".msh", mesh);
return err;
-
}
-ResourceImporterOBJ::ResourceImporterOBJ()
-{
-
+ResourceImporterOBJ::ResourceImporterOBJ() {
}
diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h
index e4e426f9e8..de2f2eceda 100644
--- a/editor/import/resource_importer_obj.h
+++ b/editor/import/resource_importer_obj.h
@@ -29,11 +29,10 @@
#ifndef RESOURCEIMPORTEROBJ_H
#define RESOURCEIMPORTEROBJ_H
-
#include "io/resource_import.h"
class ResourceImporterOBJ : public ResourceImporter {
- GDCLASS(ResourceImporterOBJ,ResourceImporter)
+ GDCLASS(ResourceImporterOBJ, ResourceImporter)
public:
virtual String get_importer_name() const;
virtual String get_visible_name() const;
@@ -44,13 +43,12 @@ public:
virtual int get_preset_count() const;
virtual String get_preset_name(int p_idx) const;
- virtual void get_import_options(List<ImportOption> *r_options,int p_preset=0) const;
- virtual bool get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const;
+ virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
+ virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
- virtual Error import(const String& p_source_file,const String& p_save_path,const Map<StringName,Variant>& p_options,List<String>* r_platform_variants,List<String>* r_gen_files=NULL);
+ virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL);
ResourceImporterOBJ();
};
-
#endif // RESOURCEIMPORTEROBJ_H
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 3f81b30bf6..8a78376f13 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -28,56 +28,51 @@
/*************************************************************************/
#include "resource_importer_scene.h"
-#include "scene/resources/packed_scene.h"
-#include "io/resource_saver.h"
#include "editor/editor_node.h"
+#include "io/resource_saver.h"
+#include "scene/resources/packed_scene.h"
+#include "scene/3d/body_shape.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/navigation.h"
-#include "scene/3d/room_instance.h"
-#include "scene/3d/body_shape.h"
#include "scene/3d/physics_body.h"
#include "scene/3d/portal.h"
+#include "scene/3d/room_instance.h"
#include "scene/3d/vehicle_body.h"
-#include "scene/resources/sphere_shape.h"
#include "scene/resources/box_shape.h"
-#include "scene/resources/ray_shape.h"
#include "scene/resources/plane_shape.h"
-
+#include "scene/resources/ray_shape.h"
+#include "scene/resources/sphere_shape.h"
void EditorScenePostImport::_bind_methods() {
- BIND_VMETHOD( MethodInfo("post_import",PropertyInfo(Variant::OBJECT,"scene")) );
-
+ BIND_VMETHOD(MethodInfo("post_import", PropertyInfo(Variant::OBJECT, "scene")));
}
-Node *EditorScenePostImport::post_import(Node* p_scene) {
+Node *EditorScenePostImport::post_import(Node *p_scene) {
if (get_script_instance())
- return get_script_instance()->call("post_import",p_scene);
+ return get_script_instance()->call("post_import", p_scene);
return p_scene;
}
EditorScenePostImport::EditorScenePostImport() {
-
-
}
-
String ResourceImporterScene::get_importer_name() const {
return "scene";
}
-String ResourceImporterScene::get_visible_name() const{
+String ResourceImporterScene::get_visible_name() const {
return "Scene";
}
-void ResourceImporterScene::get_recognized_extensions(List<String> *p_extensions) const{
+void ResourceImporterScene::get_recognized_extensions(List<String> *p_extensions) const {
- for (Set< Ref<EditorSceneImporter> >::Element *E=importers.front();E;E=E->next()) {
+ for (Set<Ref<EditorSceneImporter> >::Element *E = importers.front(); E; E = E->next()) {
E->get()->get_extensions(p_extensions);
}
}
@@ -86,30 +81,29 @@ String ResourceImporterScene::get_save_extension() const {
return "scn";
}
-String ResourceImporterScene::get_resource_type() const{
+String ResourceImporterScene::get_resource_type() const {
return "PackedScene";
}
-bool ResourceImporterScene::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const {
+bool ResourceImporterScene::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
if (p_option.begins_with("animation/")) {
- if (p_option!="animation/import" && !bool(p_options["animation/import"]))
+ if (p_option != "animation/import" && !bool(p_options["animation/import"]))
return false;
- if (p_option.begins_with("animation/optimizer/") && p_option!="animation/optimizer/enabled" && !bool(p_options["animation/optimizer/enabled"]))
+ if (p_option.begins_with("animation/optimizer/") && p_option != "animation/optimizer/enabled" && !bool(p_options["animation/optimizer/enabled"]))
return false;
if (p_option.begins_with("animation/clip_")) {
int max_clip = p_options["animation/clips/amount"];
- int clip = p_option.get_slice("/",1).get_slice("_",1).to_int()-1;
- if (clip>=max_clip)
+ int clip = p_option.get_slice("/", 1).get_slice("_", 1).to_int() - 1;
+ if (clip >= max_clip)
return false;
}
}
return true;
-
}
int ResourceImporterScene::get_preset_count() const {
@@ -120,37 +114,34 @@ String ResourceImporterScene::get_preset_name(int p_idx) const {
return "";
}
+static bool _teststr(const String &p_what, const String &p_str) {
-static bool _teststr(const String& p_what,const String& p_str) {
-
- if (p_what.findn("$"+p_str)!=-1) //blender and other stuff
+ if (p_what.findn("$" + p_str) != -1) //blender and other stuff
return true;
- if (p_what.to_lower().ends_with("-"+p_str)) //collada only supports "_" and "-" besides letters
+ if (p_what.to_lower().ends_with("-" + p_str)) //collada only supports "_" and "-" besides letters
return true;
- if (p_what.to_lower().ends_with("_"+p_str)) //collada only supports "_" and "-" besides letters
+ if (p_what.to_lower().ends_with("_" + p_str)) //collada only supports "_" and "-" besides letters
return true;
return false;
}
-static String _fixstr(const String& p_what,const String& p_str) {
+static String _fixstr(const String &p_what, const String &p_str) {
- if (p_what.findn("$"+p_str)!=-1) //blender and other stuff
- return p_what.replace("$"+p_str,"");
- if (p_what.to_lower().ends_with("-"+p_str)) //collada only supports "_" and "-" besides letters
- return p_what.substr(0,p_what.length()-(p_str.length()+1));
- if (p_what.to_lower().ends_with("_"+p_str)) //collada only supports "_" and "-" besides letters
- return p_what.substr(0,p_what.length()-(p_str.length()+1));
+ if (p_what.findn("$" + p_str) != -1) //blender and other stuff
+ return p_what.replace("$" + p_str, "");
+ if (p_what.to_lower().ends_with("-" + p_str)) //collada only supports "_" and "-" besides letters
+ return p_what.substr(0, p_what.length() - (p_str.length() + 1));
+ if (p_what.to_lower().ends_with("_" + p_str)) //collada only supports "_" and "-" besides letters
+ return p_what.substr(0, p_what.length() - (p_str.length() + 1));
return p_what;
}
-
-Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,Ref<Shape> > &collision_map) {
+Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, Ref<Shape> > &collision_map) {
// children first..
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
-
- Node *r = _fix_node(p_node->get_child(i),p_root,collision_map);
+ Node *r = _fix_node(p_node->get_child(i), p_root, collision_map);
if (!r) {
print_line("was erased..");
i--; //was erased
@@ -159,35 +150,32 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
String name = p_node->get_name();
- bool isroot = p_node==p_root;
-
+ bool isroot = p_node == p_root;
- if (!isroot && _teststr(name,"noimp")) {
+ if (!isroot && _teststr(name, "noimp")) {
memdelete(p_node);
return NULL;
}
-
if (p_node->cast_to<MeshInstance>()) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
- bool bb=false;
-
- if ((_teststr(name,"bb"))) {
- bb=true;
- } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(),"bb"))) {
- bb=true;
+ bool bb = false;
+ if ((_teststr(name, "bb"))) {
+ bb = true;
+ } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(), "bb"))) {
+ bb = true;
}
if (bb) {
- mi->set_flag(GeometryInstance::FLAG_BILLBOARD,true);
+ mi->set_flag(GeometryInstance::FLAG_BILLBOARD, true);
if (mi->get_mesh().is_valid()) {
Ref<Mesh> m = mi->get_mesh();
- for(int i=0;i<m->get_surface_count();i++) {
+ for (int i = 0; i < m->get_surface_count(); i++) {
Ref<FixedSpatialMaterial> fm = m->surface_get_material(i);
if (fm.is_valid()) {
@@ -201,7 +189,6 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
}
}
-
if (p_node->cast_to<MeshInstance>()) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
@@ -210,24 +197,23 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
if (m.is_valid()) {
- for(int i=0;i<m->get_surface_count();i++) {
+ for (int i = 0; i < m->get_surface_count(); i++) {
Ref<FixedSpatialMaterial> mat = m->surface_get_material(i);
if (!mat.is_valid())
continue;
- if (_teststr(mat->get_name(),"alpha")) {
+ if (_teststr(mat->get_name(), "alpha")) {
- mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
- mat->set_name(_fixstr(mat->get_name(),"alpha"));
+ mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
+ mat->set_name(_fixstr(mat->get_name(), "alpha"));
}
- if (_teststr(mat->get_name(),"vcol")) {
+ if (_teststr(mat->get_name(), "vcol")) {
- mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
- mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
- mat->set_name(_fixstr(mat->get_name(),"vcol"));
+ mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_name(_fixstr(mat->get_name(), "vcol"));
}
-
}
}
}
@@ -238,52 +224,48 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
List<StringName> anims;
ap->get_animation_list(&anims);
- for(List<StringName>::Element *E=anims.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = anims.front(); E; E = E->next()) {
- Ref<Animation> anim=ap->get_animation(E->get());
+ Ref<Animation> anim = ap->get_animation(E->get());
ERR_CONTINUE(anim.is_null());
- for(int i=0;i<anim->get_track_count();i++) {
+ for (int i = 0; i < anim->get_track_count(); i++) {
NodePath path = anim->track_get_path(i);
- for(int j=0;j<path.get_name_count();j++) {
+ for (int j = 0; j < path.get_name_count(); j++) {
String node = path.get_name(j);
- if (_teststr(node,"noimp")) {
+ if (_teststr(node, "noimp")) {
anim->remove_track(i);
i--;
break;
}
}
}
-
}
}
-
if (p_node->cast_to<MeshInstance>()) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
String str;
- if ((_teststr(name,"imp"))) {
- str=name;
- } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(),"imp"))) {
- str=mi->get_mesh()->get_name();
-
+ if ((_teststr(name, "imp"))) {
+ str = name;
+ } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(), "imp"))) {
+ str = mi->get_mesh()->get_name();
}
-
if (p_node->get_parent() && p_node->get_parent()->cast_to<MeshInstance>()) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>();
- String d=str.substr(str.find("imp")+3,str.length());
- if (d!="") {
- if ((d[0]<'0' || d[0]>'9'))
- d=d.substr(1,d.length());
- if (d.length() && d[0]>='0' && d[0]<='9') {
+ String d = str.substr(str.find("imp") + 3, str.length());
+ if (d != "") {
+ if ((d[0] < '0' || d[0] > '9'))
+ d = d.substr(1, d.length());
+ if (d.length() && d[0] >= '0' && d[0] <= '9') {
float dist = d.to_double();
- mi->set_flag(GeometryInstance::FLAG_BILLBOARD,true);
- mi->set_flag(GeometryInstance::FLAG_BILLBOARD_FIX_Y,true);
+ mi->set_flag(GeometryInstance::FLAG_BILLBOARD, true);
+ mi->set_flag(GeometryInstance::FLAG_BILLBOARD_FIX_Y, true);
//mi->set_draw_range_begin(dist);
//mi->set_draw_range_end(100000);
@@ -293,7 +275,7 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
if (mi->get_mesh().is_valid()) {
Ref<Mesh> m = mi->get_mesh();
- for(int i=0;i<m->get_surface_count();i++) {
+ for (int i = 0; i < m->get_surface_count(); i++) {
Ref<FixedSpatialMaterial> fm = m->surface_get_material(i);
if (fm.is_valid()) {
@@ -367,24 +349,24 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
//mi->set_baked_light_texture_id(layer);
}
#endif
- if (_teststr(name,"colonly")) {
+ if (_teststr(name, "colonly")) {
if (isroot)
return p_node;
if (p_node->cast_to<MeshInstance>()) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
- Node * col = mi->create_trimesh_collision_node();
- ERR_FAIL_COND_V(!col,NULL);
+ Node *col = mi->create_trimesh_collision_node();
+ ERR_FAIL_COND_V(!col, NULL);
- col->set_name(_fixstr(name,"colonly"));
+ col->set_name(_fixstr(name, "colonly"));
col->cast_to<Spatial>()->set_transform(mi->get_transform());
p_node->replace_by(col);
memdelete(p_node);
- p_node=col;
+ p_node = col;
StaticBody *sb = col->cast_to<StaticBody>();
- CollisionShape *colshape = memnew( CollisionShape);
+ CollisionShape *colshape = memnew(CollisionShape);
colshape->set_shape(sb->get_shape(0));
colshape->set_name("shape");
sb->add_child(colshape);
@@ -392,29 +374,29 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
} else if (p_node->has_meta("empty_draw_type")) {
String empty_draw_type = String(p_node->get_meta("empty_draw_type"));
print_line(empty_draw_type);
- StaticBody *sb = memnew( StaticBody);
- sb->set_name(_fixstr(name,"colonly"));
+ StaticBody *sb = memnew(StaticBody);
+ sb->set_name(_fixstr(name, "colonly"));
sb->cast_to<Spatial>()->set_transform(p_node->cast_to<Spatial>()->get_transform());
p_node->replace_by(sb);
memdelete(p_node);
- CollisionShape *colshape = memnew( CollisionShape);
+ CollisionShape *colshape = memnew(CollisionShape);
if (empty_draw_type == "CUBE") {
- BoxShape *boxShape = memnew( BoxShape);
+ BoxShape *boxShape = memnew(BoxShape);
boxShape->set_extents(Vector3(1, 1, 1));
colshape->set_shape(boxShape);
colshape->set_name("BoxShape");
} else if (empty_draw_type == "SINGLE_ARROW") {
- RayShape *rayShape = memnew( RayShape);
+ RayShape *rayShape = memnew(RayShape);
rayShape->set_length(1);
colshape->set_shape(rayShape);
colshape->set_name("RayShape");
sb->cast_to<Spatial>()->rotate_x(Math_PI / 2);
} else if (empty_draw_type == "IMAGE") {
- PlaneShape *planeShape = memnew( PlaneShape);
+ PlaneShape *planeShape = memnew(PlaneShape);
colshape->set_shape(planeShape);
colshape->set_name("PlaneShape");
} else {
- SphereShape *sphereShape = memnew( SphereShape);
+ SphereShape *sphereShape = memnew(SphereShape);
sphereShape->set_radius(1);
colshape->set_shape(sphereShape);
colshape->set_name("SphereShape");
@@ -423,7 +405,7 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
colshape->set_owner(sb->get_owner());
}
- } else if (_teststr(name,"rigid") && p_node->cast_to<MeshInstance>()) {
+ } else if (_teststr(name, "rigid") && p_node->cast_to<MeshInstance>()) {
if (isroot)
return p_node;
@@ -433,17 +415,17 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
Rect3 aabb = mi->get_aabb();
// create a new rigid body collision node
- RigidBody * rigid_body = memnew( RigidBody );
- Node * col = rigid_body;
- ERR_FAIL_COND_V(!col,NULL);
+ RigidBody *rigid_body = memnew(RigidBody);
+ Node *col = rigid_body;
+ ERR_FAIL_COND_V(!col, NULL);
// remove node name postfix
- col->set_name(_fixstr(name,"rigid"));
+ col->set_name(_fixstr(name, "rigid"));
// get mesh instance xform matrix to the rigid body collision node
col->cast_to<Spatial>()->set_transform(mi->get_transform());
// save original node by duplicating it into a new instance and correcting the name
- Node * mesh = p_node->duplicate();
- mesh->set_name(_fixstr(name,"rigid"));
+ Node *mesh = p_node->duplicate();
+ mesh->set_name(_fixstr(name, "rigid"));
// reset the xform matrix of the duplicated node so it can inherit parent node xform
mesh->cast_to<Spatial>()->set_transform(Transform(Basis()));
// reparent the new mesh node to the rigid body collision node
@@ -452,69 +434,67 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
// replace the original node with the rigid body collision node
p_node->replace_by(col);
memdelete(p_node);
- p_node=col;
+ p_node = col;
// create an alias for the rigid body collision node
RigidBody *rb = col->cast_to<RigidBody>();
// create a new Box collision shape and set the right extents
- Ref<BoxShape> shape = memnew( BoxShape );
+ Ref<BoxShape> shape = memnew(BoxShape);
shape->set_extents(aabb.get_size() * 0.5);
- CollisionShape *colshape = memnew( CollisionShape);
+ CollisionShape *colshape = memnew(CollisionShape);
colshape->set_name("shape");
colshape->set_shape(shape);
// reparent the new collision shape to the rigid body collision node
rb->add_child(colshape);
colshape->set_owner(p_node->get_owner());
- } else if (_teststr(name,"col") && p_node->cast_to<MeshInstance>()) {
-
+ } else if (_teststr(name, "col") && p_node->cast_to<MeshInstance>()) {
MeshInstance *mi = p_node->cast_to<MeshInstance>();
- mi->set_name(_fixstr(name,"col"));
- Node *col= mi->create_trimesh_collision_node();
- ERR_FAIL_COND_V(!col,NULL);
+ mi->set_name(_fixstr(name, "col"));
+ Node *col = mi->create_trimesh_collision_node();
+ ERR_FAIL_COND_V(!col, NULL);
col->set_name("col");
p_node->add_child(col);
- StaticBody *sb=col->cast_to<StaticBody>();
- CollisionShape *colshape = memnew( CollisionShape);
+ StaticBody *sb = col->cast_to<StaticBody>();
+ CollisionShape *colshape = memnew(CollisionShape);
colshape->set_shape(sb->get_shape(0));
colshape->set_name("shape");
col->add_child(colshape);
colshape->set_owner(p_node->get_owner());
sb->set_owner(p_node->get_owner());
- } else if (_teststr(name,"navmesh") && p_node->cast_to<MeshInstance>()) {
+ } else if (_teststr(name, "navmesh") && p_node->cast_to<MeshInstance>()) {
if (isroot)
return p_node;
MeshInstance *mi = p_node->cast_to<MeshInstance>();
- Ref<Mesh> mesh=mi->get_mesh();
- ERR_FAIL_COND_V(mesh.is_null(),NULL);
- NavigationMeshInstance *nmi = memnew( NavigationMeshInstance );
-
+ Ref<Mesh> mesh = mi->get_mesh();
+ ERR_FAIL_COND_V(mesh.is_null(), NULL);
+ NavigationMeshInstance *nmi = memnew(NavigationMeshInstance);
- nmi->set_name(_fixstr(name,"navmesh"));
- Ref<NavigationMesh> nmesh = memnew( NavigationMesh);
+ nmi->set_name(_fixstr(name, "navmesh"));
+ Ref<NavigationMesh> nmesh = memnew(NavigationMesh);
nmesh->create_from_mesh(mesh);
nmi->set_navigation_mesh(nmesh);
nmi->cast_to<Spatial>()->set_transform(mi->get_transform());
p_node->replace_by(nmi);
memdelete(p_node);
- p_node=nmi;
- } else if (_teststr(name,"vehicle")) {
+ p_node = nmi;
+ } else if (_teststr(name, "vehicle")) {
if (isroot)
return p_node;
Node *owner = p_node->get_owner();
Spatial *s = p_node->cast_to<Spatial>();
- VehicleBody *bv = memnew( VehicleBody );
- String n = _fixstr(p_node->get_name(),"vehicle");
+ VehicleBody *bv = memnew(VehicleBody);
+ String n = _fixstr(p_node->get_name(), "vehicle");
bv->set_name(n);
p_node->replace_by(bv);
p_node->set_name(n);
@@ -524,18 +504,17 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
bv->set_transform(s->get_transform());
s->set_transform(Transform());
- p_node=bv;
-
+ p_node = bv;
- } else if (_teststr(name,"wheel")) {
+ } else if (_teststr(name, "wheel")) {
if (isroot)
return p_node;
Node *owner = p_node->get_owner();
Spatial *s = p_node->cast_to<Spatial>();
- VehicleWheel *bv = memnew( VehicleWheel );
- String n = _fixstr(p_node->get_name(),"wheel");
+ VehicleWheel *bv = memnew(VehicleWheel);
+ String n = _fixstr(p_node->get_name(), "wheel");
bv->set_name(n);
p_node->replace_by(bv);
p_node->set_name(n);
@@ -545,10 +524,9 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
bv->set_transform(s->get_transform());
s->set_transform(Transform());
- p_node=bv;
-
- } else if (_teststr(name,"room") && p_node->cast_to<MeshInstance>()) {
+ p_node = bv;
+ } else if (_teststr(name, "room") && p_node->cast_to<MeshInstance>()) {
if (isroot)
return p_node;
@@ -556,42 +534,40 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
MeshInstance *mi = p_node->cast_to<MeshInstance>();
PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID);
-
BSP_Tree bsptree(faces);
- Ref<RoomBounds> area = memnew( RoomBounds );
+ Ref<RoomBounds> area = memnew(RoomBounds);
//area->set_bounds(faces);
//area->set_geometry_hint(faces);
-
- Room * room = memnew( Room );
- room->set_name(_fixstr(name,"room"));
+ Room *room = memnew(Room);
+ room->set_name(_fixstr(name, "room"));
room->set_transform(mi->get_transform());
room->set_room(area);
p_node->replace_by(room);
memdelete(p_node);
- p_node=room;
+ p_node = room;
- } else if (_teststr(name,"room")) {
+ } else if (_teststr(name, "room")) {
if (isroot)
return p_node;
Spatial *dummy = p_node->cast_to<Spatial>();
- ERR_FAIL_COND_V(!dummy,NULL);
+ ERR_FAIL_COND_V(!dummy, NULL);
- Room * room = memnew( Room );
- room->set_name(_fixstr(name,"room"));
+ Room *room = memnew(Room);
+ room->set_name(_fixstr(name, "room"));
room->set_transform(dummy->get_transform());
p_node->replace_by(room);
memdelete(p_node);
- p_node=room;
+ p_node = room;
//room->compute_room_from_subtree();
- } else if (_teststr(name,"portal") && p_node->cast_to<MeshInstance>()) {
+ } else if (_teststr(name, "portal") && p_node->cast_to<MeshInstance>()) {
if (isroot)
return p_node;
@@ -599,78 +575,76 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
MeshInstance *mi = p_node->cast_to<MeshInstance>();
PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID);
- ERR_FAIL_COND_V(faces.size()==0,NULL);
+ ERR_FAIL_COND_V(faces.size() == 0, NULL);
//step 1 compute the plane
Set<Vector3> points;
Plane plane;
Vector3 center;
- for(int i=0;i<faces.size();i++) {
+ for (int i = 0; i < faces.size(); i++) {
Face3 f = faces.get(i);
Plane p = f.get_plane();
- plane.normal+=p.normal;
- plane.d+=p.d;
+ plane.normal += p.normal;
+ plane.d += p.d;
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
Vector3 v = f.vertex[i].snapped(0.01);
if (!points.has(v)) {
points.insert(v);
- center+=v;
+ center += v;
}
}
}
plane.normal.normalize();
- plane.d/=faces.size();
- center/=points.size();
+ plane.d /= faces.size();
+ center /= points.size();
//step 2, create points
Transform t;
t.basis.from_z(plane.normal);
t.basis.transpose();
- t.origin=center;
+ t.origin = center;
Vector<Point2> portal_points;
- for(Set<Vector3>::Element *E=points.front();E;E=E->next()) {
+ for (Set<Vector3>::Element *E = points.front(); E; E = E->next()) {
Vector3 local = t.xform_inv(E->get());
- portal_points.push_back(Point2(local.x,local.y));
+ portal_points.push_back(Point2(local.x, local.y));
}
// step 3 bubbly sort points
- int swaps=0;
+ int swaps = 0;
do {
- swaps=0;
+ swaps = 0;
- for(int i=0;i<portal_points.size()-1;i++) {
+ for (int i = 0; i < portal_points.size() - 1; i++) {
float a = portal_points[i].angle();
- float b = portal_points[i+1].angle();
+ float b = portal_points[i + 1].angle();
- if (a>b) {
- SWAP( portal_points[i], portal_points[i+1] );
+ if (a > b) {
+ SWAP(portal_points[i], portal_points[i + 1]);
swaps++;
}
-
}
- } while(swaps);
+ } while (swaps);
-
- Portal *portal = memnew( Portal );
+ Portal *portal = memnew(Portal);
portal->set_shape(portal_points);
- portal->set_transform( mi->get_transform() * t);
+ portal->set_transform(mi->get_transform() * t);
p_node->replace_by(portal);
memdelete(p_node);
- p_node=portal;
+ p_node = portal;
} else if (p_node->cast_to<MeshInstance>()) {
@@ -681,9 +655,9 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
Ref<Mesh> mesh = mi->get_mesh();
if (!mesh.is_null()) {
- if (_teststr(mesh->get_name(),"col")) {
+ if (_teststr(mesh->get_name(), "col")) {
- mesh->set_name( _fixstr(mesh->get_name(),"col") );
+ mesh->set_name(_fixstr(mesh->get_name(), "col"));
Ref<Shape> shape;
if (collision_map.has(mesh)) {
@@ -693,9 +667,7 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
shape = mesh->create_trimesh_shape();
if (!shape.is_null())
- collision_map[mesh]=shape;
-
-
+ collision_map[mesh] = shape;
}
if (!shape.is_null()) {
@@ -711,15 +683,14 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
static_body->set_owner( mi->get_owner() );
#endif
}
-
}
- for(int i=0;i<mesh->get_surface_count();i++) {
+ for (int i = 0; i < mesh->get_surface_count(); i++) {
Ref<FixedSpatialMaterial> fm = mesh->surface_get_material(i);
if (fm.is_valid()) {
String name = fm->get_name();
- /* if (_teststr(name,"alpha")) {
+ /* if (_teststr(name,"alpha")) {
fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
name=_fixstr(name,"alpha");
}
@@ -731,22 +702,18 @@ Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,R
fm->set_name(name);
}
}
-
}
-
}
-
return p_node;
}
-
-void ResourceImporterScene::_create_clips(Node *scene, const Array& p_clips,bool p_bake_all) {
+void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, bool p_bake_all) {
if (!scene->has_node(String("AnimationPlayer")))
return;
- Node* n = scene->get_node(String("AnimationPlayer"));
+ Node *n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
ERR_FAIL_COND(!anim);
@@ -754,185 +721,173 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array& p_clips,bool
if (!anim->has_animation("default"))
return;
-
Ref<Animation> default_anim = anim->get_animation("default");
- for(int i=0;i<p_clips.size();i+=4) {
+ for (int i = 0; i < p_clips.size(); i += 4) {
String name = p_clips[i];
- float from=p_clips[i+1];
- float to=p_clips[i+2];
- bool loop=p_clips[i+3];
- if (from>=to)
+ float from = p_clips[i + 1];
+ float to = p_clips[i + 2];
+ bool loop = p_clips[i + 3];
+ if (from >= to)
continue;
- Ref<Animation> new_anim = memnew( Animation );
-
- for(int j=0;j<default_anim->get_track_count();j++) {
+ Ref<Animation> new_anim = memnew(Animation);
+ for (int j = 0; j < default_anim->get_track_count(); j++) {
List<float> keys;
int kc = default_anim->track_get_key_count(j);
- int dtrack=-1;
- for(int k=0;k<kc;k++) {
+ int dtrack = -1;
+ for (int k = 0; k < kc; k++) {
- float kt = default_anim->track_get_key_time(j,k);
- if (kt>=from && kt<to) {
+ float kt = default_anim->track_get_key_time(j, k);
+ if (kt >= from && kt < to) {
//found a key within range, so create track
- if (dtrack==-1) {
+ if (dtrack == -1) {
new_anim->add_track(default_anim->track_get_type(j));
- dtrack = new_anim->get_track_count()-1;
- new_anim->track_set_path(dtrack,default_anim->track_get_path(j));
+ dtrack = new_anim->get_track_count() - 1;
+ new_anim->track_set_path(dtrack, default_anim->track_get_path(j));
- if (kt>(from+0.01) && k>0) {
+ if (kt > (from + 0.01) && k > 0) {
- if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) {
+ if (default_anim->track_get_type(j) == Animation::TYPE_TRANSFORM) {
Quat q;
Vector3 p;
Vector3 s;
- default_anim->transform_track_interpolate(j,from,&p,&q,&s);
- new_anim->transform_track_insert_key(dtrack,0,p,q,s);
+ default_anim->transform_track_interpolate(j, from, &p, &q, &s);
+ new_anim->transform_track_insert_key(dtrack, 0, p, q, s);
}
}
-
}
- if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) {
+ if (default_anim->track_get_type(j) == Animation::TYPE_TRANSFORM) {
Quat q;
Vector3 p;
Vector3 s;
- default_anim->transform_track_get_key(j,k,&p,&q,&s);
- new_anim->transform_track_insert_key(dtrack,kt-from,p,q,s);
+ default_anim->transform_track_get_key(j, k, &p, &q, &s);
+ new_anim->transform_track_insert_key(dtrack, kt - from, p, q, s);
}
-
}
- if (dtrack!=-1 && kt>=to) {
+ if (dtrack != -1 && kt >= to) {
- if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) {
+ if (default_anim->track_get_type(j) == Animation::TYPE_TRANSFORM) {
Quat q;
Vector3 p;
Vector3 s;
- default_anim->transform_track_interpolate(j,to,&p,&q,&s);
- new_anim->transform_track_insert_key(dtrack,to-from,p,q,s);
+ default_anim->transform_track_interpolate(j, to, &p, &q, &s);
+ new_anim->transform_track_insert_key(dtrack, to - from, p, q, s);
}
}
-
}
- if (dtrack==-1 && p_bake_all) {
+ if (dtrack == -1 && p_bake_all) {
new_anim->add_track(default_anim->track_get_type(j));
- dtrack = new_anim->get_track_count()-1;
- new_anim->track_set_path(dtrack,default_anim->track_get_path(j));
- if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) {
-
+ dtrack = new_anim->get_track_count() - 1;
+ new_anim->track_set_path(dtrack, default_anim->track_get_path(j));
+ if (default_anim->track_get_type(j) == Animation::TYPE_TRANSFORM) {
Quat q;
Vector3 p;
Vector3 s;
- default_anim->transform_track_interpolate(j,from,&p,&q,&s);
- new_anim->transform_track_insert_key(dtrack,0,p,q,s);
- default_anim->transform_track_interpolate(j,to,&p,&q,&s);
- new_anim->transform_track_insert_key(dtrack,to-from,p,q,s);
+ default_anim->transform_track_interpolate(j, from, &p, &q, &s);
+ new_anim->transform_track_insert_key(dtrack, 0, p, q, s);
+ default_anim->transform_track_interpolate(j, to, &p, &q, &s);
+ new_anim->transform_track_insert_key(dtrack, to - from, p, q, s);
}
-
}
}
-
new_anim->set_loop(loop);
- new_anim->set_length(to-from);
- anim->add_animation(name,new_anim);
+ new_anim->set_length(to - from);
+ anim->add_animation(name, new_anim);
}
anim->remove_animation("default"); //remove default (no longer needed)
}
-void ResourceImporterScene::_filter_anim_tracks(Ref<Animation> anim,Set<String> &keep) {
+void ResourceImporterScene::_filter_anim_tracks(Ref<Animation> anim, Set<String> &keep) {
Ref<Animation> a = anim;
ERR_FAIL_COND(!a.is_valid());
- print_line("From Anim "+anim->get_name()+":");
+ print_line("From Anim " + anim->get_name() + ":");
- for(int j=0;j<a->get_track_count();j++) {
+ for (int j = 0; j < a->get_track_count(); j++) {
String path = a->track_get_path(j);
if (!keep.has(path)) {
- print_line("Remove: "+path);
+ print_line("Remove: " + path);
a->remove_track(j);
j--;
}
-
}
}
-
-void ResourceImporterScene::_filter_tracks(Node *scene, const String& p_text) {
+void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) {
if (!scene->has_node(String("AnimationPlayer")))
return;
- Node* n = scene->get_node(String("AnimationPlayer"));
+ Node *n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
ERR_FAIL_COND(!anim);
Vector<String> strings = p_text.split("\n");
- for(int i=0;i<strings.size();i++) {
+ for (int i = 0; i < strings.size(); i++) {
- strings[i]=strings[i].strip_edges();
+ strings[i] = strings[i].strip_edges();
}
List<StringName> anim_names;
anim->get_animation_list(&anim_names);
- for(List<StringName>::Element *E=anim_names.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) {
String name = E->get();
- bool valid_for_this=false;
- bool valid=false;
+ bool valid_for_this = false;
+ bool valid = false;
Set<String> keep;
Set<String> keep_local;
-
- for(int i=0;i<strings.size();i++) {
-
+ for (int i = 0; i < strings.size(); i++) {
if (strings[i].begins_with("@")) {
- valid_for_this=false;
- for(Set<String>::Element *F=keep_local.front();F;F=F->next()) {
+ valid_for_this = false;
+ for (Set<String>::Element *F = keep_local.front(); F; F = F->next()) {
keep.insert(F->get());
}
keep_local.clear();
- Vector<String> filters=strings[i].substr(1,strings[i].length()).split(",");
- for(int j=0;j<filters.size();j++) {
+ Vector<String> filters = strings[i].substr(1, strings[i].length()).split(",");
+ for (int j = 0; j < filters.size(); j++) {
String fname = filters[j].strip_edges();
- if (fname=="")
+ if (fname == "")
continue;
int fc = fname[0];
bool plus;
- if (fc=='+')
- plus=true;
- else if (fc=='-')
- plus=false;
+ if (fc == '+')
+ plus = true;
+ else if (fc == '-')
+ plus = false;
else
continue;
- String filter=fname.substr(1,fname.length()).strip_edges();
+ String filter = fname.substr(1, fname.length()).strip_edges();
if (!name.matchn(filter))
continue;
- valid_for_this=plus;
+ valid_for_this = plus;
}
if (valid_for_this)
- valid=true;
+ valid = true;
} else if (valid_for_this) {
@@ -940,23 +895,23 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String& p_text) {
if (!a.is_valid())
continue;
- for(int j=0;j<a->get_track_count();j++) {
+ for (int j = 0; j < a->get_track_count(); j++) {
String path = a->track_get_path(j);
String tname = strings[i];
- if (tname=="")
+ if (tname == "")
continue;
int fc = tname[0];
bool plus;
- if (fc=='+')
- plus=true;
- else if (fc=='-')
- plus=false;
+ if (fc == '+')
+ plus = true;
+ else if (fc == '-')
+ plus = false;
else
continue;
- String filter=tname.substr(1,tname.length()).strip_edges();
+ String filter = tname.substr(1, tname.length()).strip_edges();
if (!path.matchn(filter))
continue;
@@ -967,93 +922,83 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String& p_text) {
keep_local.erase(path);
}
}
-
}
-
}
if (valid) {
- for(Set<String>::Element *F=keep_local.front();F;F=F->next()) {
+ for (Set<String>::Element *F = keep_local.front(); F; F = F->next()) {
keep.insert(F->get());
}
- _filter_anim_tracks(anim->get_animation(name),keep);
+ _filter_anim_tracks(anim->get_animation(name), keep);
} else {
-
}
-
}
-
-
-
}
-void ResourceImporterScene::_optimize_animations(Node *scene, float p_max_lin_error,float p_max_ang_error,float p_max_angle) {
+void ResourceImporterScene::_optimize_animations(Node *scene, float p_max_lin_error, float p_max_ang_error, float p_max_angle) {
if (!scene->has_node(String("AnimationPlayer")))
return;
- Node* n = scene->get_node(String("AnimationPlayer"));
+ Node *n = scene->get_node(String("AnimationPlayer"));
ERR_FAIL_COND(!n);
AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
ERR_FAIL_COND(!anim);
-
List<StringName> anim_names;
anim->get_animation_list(&anim_names);
- for(List<StringName>::Element *E=anim_names.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) {
Ref<Animation> a = anim->get_animation(E->get());
- a->optimize(p_max_lin_error,p_max_ang_error,Math::deg2rad(p_max_angle));
+ a->optimize(p_max_lin_error, p_max_ang_error, Math::deg2rad(p_max_angle));
}
}
+static String _make_extname(const String &p_str) {
-static String _make_extname(const String& p_str) {
-
- String ext_name=p_str.replace(".","_");
- ext_name=ext_name.replace(":","_");
- ext_name=ext_name.replace("\"","_");
- ext_name=ext_name.replace("<","_");
- ext_name=ext_name.replace(">","_");
- ext_name=ext_name.replace("/","_");
- ext_name=ext_name.replace("|","_");
- ext_name=ext_name.replace("\\","_");
- ext_name=ext_name.replace("?","_");
- ext_name=ext_name.replace("*","_");
+ String ext_name = p_str.replace(".", "_");
+ ext_name = ext_name.replace(":", "_");
+ ext_name = ext_name.replace("\"", "_");
+ ext_name = ext_name.replace("<", "_");
+ ext_name = ext_name.replace(">", "_");
+ ext_name = ext_name.replace("/", "_");
+ ext_name = ext_name.replace("|", "_");
+ ext_name = ext_name.replace("\\", "_");
+ ext_name = ext_name.replace("?", "_");
+ ext_name = ext_name.replace("*", "_");
return ext_name;
}
-void ResourceImporterScene::_make_external_resources(Node* p_node,const String& p_base_path, bool p_make_materials, bool p_make_meshes, Map<Ref<Material>,Ref<Material> >& p_materials, Map<Ref<Mesh>,Ref<Mesh> >& p_meshes) {
+void ResourceImporterScene::_make_external_resources(Node *p_node, const String &p_base_path, bool p_make_materials, bool p_make_meshes, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<Mesh>, Ref<Mesh> > &p_meshes) {
List<PropertyInfo> pi;
p_node->get_property_list(&pi);
- for (List<PropertyInfo>::Element *E=pi.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) {
- if (E->get().type==Variant::OBJECT) {
+ if (E->get().type == Variant::OBJECT) {
Ref<Material> mat = p_node->get(E->get().name);
- if (p_make_materials && mat.is_valid() && mat->get_name()!="") {
-
+ if (p_make_materials && mat.is_valid() && mat->get_name() != "") {
if (!p_materials.has(mat)) {
- String ext_name = p_base_path+"."+_make_extname(mat->get_name())+".mtl";
+ String ext_name = p_base_path + "." + _make_extname(mat->get_name()) + ".mtl";
if (FileAccess::exists(ext_name)) {
//if exists, use it
Ref<Material> existing = ResourceLoader::load(ext_name);
- p_materials[mat]=existing;
+ p_materials[mat] = existing;
} else {
- ResourceSaver::save(ext_name,mat,ResourceSaver::FLAG_CHANGE_PATH);
- p_materials[mat]=mat;
+ ResourceSaver::save(ext_name, mat, ResourceSaver::FLAG_CHANGE_PATH);
+ p_materials[mat] = mat;
}
}
- if (p_materials[mat]!=mat) {
+ if (p_materials[mat] != mat) {
- p_node->set(E->get().name,p_materials[mat]);
+ p_node->set(E->get().name, p_materials[mat]);
}
} else {
@@ -1061,62 +1006,57 @@ void ResourceImporterScene::_make_external_resources(Node* p_node,const String&
if (mesh.is_valid()) {
- bool mesh_just_added=false;
+ bool mesh_just_added = false;
if (p_make_meshes) {
if (!p_meshes.has(mesh)) {
- String ext_name = p_base_path+"."+_make_extname(mesh->get_name())+".msh";
+ String ext_name = p_base_path + "." + _make_extname(mesh->get_name()) + ".msh";
if (FileAccess::exists(ext_name)) {
//if exists, use it
Ref<Mesh> existing = ResourceLoader::load(ext_name);
- p_meshes[mesh]=existing;
+ p_meshes[mesh] = existing;
} else {
- ResourceSaver::save(ext_name,mesh,ResourceSaver::FLAG_CHANGE_PATH);
- p_meshes[mesh]=mesh;
- mesh_just_added=true;
+ ResourceSaver::save(ext_name, mesh, ResourceSaver::FLAG_CHANGE_PATH);
+ p_meshes[mesh] = mesh;
+ mesh_just_added = true;
}
-
-
}
}
-
- if (p_make_materials){
+ if (p_make_materials) {
if (mesh_just_added || !p_meshes.has(mesh)) {
-
- for(int i=0;i<mesh->get_surface_count();i++) {
- mat=mesh->surface_get_material(i);
- if (!mat.is_valid() || mat->get_name()=="")
+ for (int i = 0; i < mesh->get_surface_count(); i++) {
+ mat = mesh->surface_get_material(i);
+ if (!mat.is_valid() || mat->get_name() == "")
continue;
if (!p_materials.has(mat)) {
- String ext_name = p_base_path+"."+_make_extname(mat->get_name())+".mtl";
+ String ext_name = p_base_path + "." + _make_extname(mat->get_name()) + ".mtl";
if (FileAccess::exists(ext_name)) {
//if exists, use it
Ref<Material> existing = ResourceLoader::load(ext_name);
- p_materials[mat]=existing;
+ p_materials[mat] = existing;
} else {
- ResourceSaver::save(ext_name,mat,ResourceSaver::FLAG_CHANGE_PATH);
- p_materials[mat]=mat;
+ ResourceSaver::save(ext_name, mat, ResourceSaver::FLAG_CHANGE_PATH);
+ p_materials[mat] = mat;
}
}
- if (p_materials[mat]!=mat) {
+ if (p_materials[mat] != mat) {
- mesh->surface_set_material(i,p_materials[mat]);
+ mesh->surface_set_material(i, p_materials[mat]);
}
-
}
- if(!p_make_meshes) {
- p_meshes[mesh]=Ref<Mesh>(); //save it anyway, so it won't be checked again
+ if (!p_make_meshes) {
+ p_meshes[mesh] = Ref<Mesh>(); //save it anyway, so it won't be checked again
}
}
}
@@ -1125,72 +1065,69 @@ void ResourceImporterScene::_make_external_resources(Node* p_node,const String&
}
}
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- _make_external_resources(p_node->get_child(i),p_base_path,p_make_materials,p_make_meshes,p_materials,p_meshes);
+ _make_external_resources(p_node->get_child(i), p_base_path, p_make_materials, p_make_meshes, p_materials, p_meshes);
}
}
+void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-void ResourceImporterScene::get_import_options(List<ImportOption> *r_options,int p_preset) const {
-
-
- r_options->push_back(ImportOption(PropertyInfo(Variant::STRING,"nodes/root_type",PROPERTY_HINT_TYPE_STRING,"Node"),"Spatial"));
- r_options->push_back(ImportOption(PropertyInfo(Variant::STRING,"nodes/root_name"),"Scene Root"));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_type", PROPERTY_HINT_TYPE_STRING, "Node"), "Spatial"));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_name"), "Scene Root"));
List<String> script_extentions;
- ResourceLoader::get_recognized_extensions_for_type("Script",&script_extentions);
+ ResourceLoader::get_recognized_extensions_for_type("Script", &script_extentions);
String script_ext_hint;
- for(List<String>::Element *E=script_extentions.front();E;E=E->next()) {
- if (script_ext_hint!="")
- script_ext_hint+=",";
- script_ext_hint+="*."+E->get();
+ for (List<String>::Element *E = script_extentions.front(); E; E = E->next()) {
+ if (script_ext_hint != "")
+ script_ext_hint += ",";
+ script_ext_hint += "*." + E->get();
}
- r_options->push_back(ImportOption(PropertyInfo(Variant::STRING,"nodes/custom_script",PROPERTY_HINT_FILE,script_ext_hint),""));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"materials/location",PROPERTY_HINT_ENUM,"Node,Mesh"),0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"materials/storage",PROPERTY_HINT_ENUM,"Bult-In,Files"),0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"geometry/compress"),true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"geometry/ensure_tangents"),true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"geometry/storage",PROPERTY_HINT_ENUM,"Built-In,Files"),0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"animation/import",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED),true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"animation/fps",PROPERTY_HINT_RANGE,"1,120,1"),15));
- r_options->push_back(ImportOption(PropertyInfo(Variant::STRING,"animation/filter_script",PROPERTY_HINT_MULTILINE_TEXT),""));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"animation/optimizer/enabled",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED),true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"animation/optimizer/max_linear_error"),0.05));
- r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"animation/optimizer/max_angular_error"),0.01));
- r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"animation/optimizer/max_angle"),22));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"animation/optimizer/remove_unused_tracks"),true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"animation/clips/amount",PROPERTY_HINT_RANGE,"0,256,1",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED),0));
- for(int i=0;i<256;i++) {
- r_options->push_back(ImportOption(PropertyInfo(Variant::STRING,"animation/clip_"+itos(i+1)+"/name"),""));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"animation/clip_"+itos(i+1)+"/start_frame"),0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"animation/clip_"+itos(i+1)+"/end_frame"),0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"animation/clip_"+itos(i+1)+"/loops"),false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/custom_script", PROPERTY_HINT_FILE, script_ext_hint), ""));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/location", PROPERTY_HINT_ENUM, "Node,Mesh"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/storage", PROPERTY_HINT_ENUM, "Bult-In,Files"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "geometry/compress"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "geometry/ensure_tangents"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "geometry/storage", PROPERTY_HINT_ENUM, "Built-In,Files"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "animation/filter_script", PROPERTY_HINT_MULTILINE_TEXT), ""));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/optimizer/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/optimizer/max_linear_error"), 0.05));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/optimizer/max_angular_error"), 0.01));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/optimizer/max_angle"), 22));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/optimizer/remove_unused_tracks"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "animation/clips/amount", PROPERTY_HINT_RANGE, "0,256,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 0));
+ for (int i = 0; i < 256; i++) {
+ r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "animation/clip_" + itos(i + 1) + "/name"), ""));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "animation/clip_" + itos(i + 1) + "/start_frame"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "animation/clip_" + itos(i + 1) + "/end_frame"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/clip_" + itos(i + 1) + "/loops"), false));
}
}
-Error ResourceImporterScene::import(const String& p_source_file, const String& p_save_path, const Map<StringName,Variant>& p_options, List<String>* r_platform_variants, List<String> *r_gen_files) {
+Error ResourceImporterScene::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
- String src_path=p_source_file;
+ String src_path = p_source_file;
Ref<EditorSceneImporter> importer;
- String ext=src_path.get_extension().to_lower();
-
+ String ext = src_path.get_extension().to_lower();
- EditorProgress progress("import",TTR("Import Scene"),104);
- progress.step(TTR("Importing Scene.."),0);
+ EditorProgress progress("import", TTR("Import Scene"), 104);
+ progress.step(TTR("Importing Scene.."), 0);
- for(Set< Ref<EditorSceneImporter> >::Element *E=importers.front();E;E=E->next()) {
+ for (Set<Ref<EditorSceneImporter> >::Element *E = importers.front(); E; E = E->next()) {
List<String> extensions;
E->get()->get_extensions(&extensions);
- for(List<String>::Element *F=extensions.front();F;F=F->next()) {
+ for (List<String>::Element *F = extensions.front(); F; F = F->next()) {
- if (F->get().to_lower()==ext) {
+ if (F->get().to_lower() == ext) {
importer = E->get();
break;
@@ -1201,145 +1138,135 @@ Error ResourceImporterScene::import(const String& p_source_file, const String& p
break;
}
- ERR_FAIL_COND_V(!importer.is_valid(),ERR_FILE_UNRECOGNIZED);
+ ERR_FAIL_COND_V(!importer.is_valid(), ERR_FILE_UNRECOGNIZED);
- float fps=p_options["animation/fps"];
+ float fps = p_options["animation/fps"];
-
-
- int import_flags=EditorSceneImporter::IMPORT_ANIMATION_DETECT_LOOP;
+ int import_flags = EditorSceneImporter::IMPORT_ANIMATION_DETECT_LOOP;
if (!bool(p_options["animation/optimizer/remove_unused_tracks"]))
- import_flags|=EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS;
+ import_flags |= EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS;
if (bool(p_options["animation/import"]))
- import_flags|=EditorSceneImporter::IMPORT_ANIMATION;
+ import_flags |= EditorSceneImporter::IMPORT_ANIMATION;
if (bool(p_options["geometry/ensure_tangents"]))
- import_flags|=EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS;
-
- if (int(p_options["materials/location"])==0)
- import_flags|=EditorSceneImporter::IMPORT_MATERIALS_IN_INSTANCES;
+ import_flags |= EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS;
+ if (int(p_options["materials/location"]) == 0)
+ import_flags |= EditorSceneImporter::IMPORT_MATERIALS_IN_INSTANCES;
- Error err=OK;
+ Error err = OK;
List<String> missing_deps; // for now, not much will be done with this
- Node *scene = importer->import_scene(src_path,import_flags,fps,&missing_deps,&err);
- if (!scene || err!=OK) {
+ Node *scene = importer->import_scene(src_path, import_flags, fps, &missing_deps, &err);
+ if (!scene || err != OK) {
return err;
}
String root_type = p_options["nodes/root_type"];
- if (scene->get_class()!=root_type) {
+ if (scene->get_class() != root_type) {
Object *base = ClassDB::instance(root_type);
Node *base_node = NULL;
if (base)
- base_node=base->cast_to<Node>();
+ base_node = base->cast_to<Node>();
if (base_node) {
scene->replace_by(base_node);
memdelete(scene);
- scene=base_node;
+ scene = base_node;
}
}
scene->set_name(p_options["nodes/root_name"]);
-
- err=OK;
+ err = OK;
String animation_filter = String(p_options["animation/filter_script"]).strip_edges();
bool use_optimizer = p_options["animation/optimizer/enabled"];
- float anim_optimizer_linerr=p_options["animation/optimizer/max_linear_error"];
- float anim_optimizer_angerr=p_options["animation/optimizer/max_angular_error"];
- float anim_optimizer_maxang=p_options["animation/optimizer/max_angle"];
+ float anim_optimizer_linerr = p_options["animation/optimizer/max_linear_error"];
+ float anim_optimizer_angerr = p_options["animation/optimizer/max_angular_error"];
+ float anim_optimizer_maxang = p_options["animation/optimizer/max_angle"];
- Map<Ref<Mesh>,Ref<Shape> > collision_map;
+ Map<Ref<Mesh>, Ref<Shape> > collision_map;
- scene=_fix_node(scene,scene,collision_map);
+ scene = _fix_node(scene, scene, collision_map);
if (use_optimizer) {
- _optimize_animations(scene,anim_optimizer_linerr,anim_optimizer_angerr,anim_optimizer_maxang);
+ _optimize_animations(scene, anim_optimizer_linerr, anim_optimizer_angerr, anim_optimizer_maxang);
}
Array animation_clips;
{
-
int clip_count = p_options["animation/clips/amount"];
- for(int i=0;i<clip_count;i++) {
- String name = p_options["animation/clip_"+itos(i+1)+"/name"];
- int from_frame = p_options["animation/clip_"+itos(i+1)+"/start_frame"];
- int end_frame = p_options["animation/clip_"+itos(i+1)+"/end_frame"];
- bool loop = p_options["animation/clip_"+itos(i+1)+"/loops"];
+ for (int i = 0; i < clip_count; i++) {
+ String name = p_options["animation/clip_" + itos(i + 1) + "/name"];
+ int from_frame = p_options["animation/clip_" + itos(i + 1) + "/start_frame"];
+ int end_frame = p_options["animation/clip_" + itos(i + 1) + "/end_frame"];
+ bool loop = p_options["animation/clip_" + itos(i + 1) + "/loops"];
animation_clips.push_back(name);
- animation_clips.push_back(from_frame/fps);
- animation_clips.push_back(end_frame/fps);
+ animation_clips.push_back(from_frame / fps);
+ animation_clips.push_back(end_frame / fps);
animation_clips.push_back(loop);
}
-
}
if (animation_clips.size()) {
- _create_clips(scene,animation_clips,!bool(p_options["animation/optimizer/remove_unused_tracks"]));
+ _create_clips(scene, animation_clips, !bool(p_options["animation/optimizer/remove_unused_tracks"]));
}
- if (animation_filter!="") {
- _filter_tracks(scene,animation_filter);
+ if (animation_filter != "") {
+ _filter_tracks(scene, animation_filter);
}
-
bool external_materials = p_options["materials/storage"];
bool external_meshes = p_options["geometry/storage"];
if (external_materials || external_meshes) {
Map<Ref<Material>, Ref<Material> > mat_map;
Map<Ref<Mesh>, Ref<Mesh> > mesh_map;
- _make_external_resources(scene,p_source_file.get_basename(),external_materials,external_meshes,mat_map,mesh_map);
+ _make_external_resources(scene, p_source_file.get_basename(), external_materials, external_meshes, mat_map, mesh_map);
}
- progress.step(TTR("Running Custom Script.."),2);
+ progress.step(TTR("Running Custom Script.."), 2);
String post_import_script_path = p_options["nodes/custom_script"];
- Ref<EditorScenePostImport> post_import_script;
+ Ref<EditorScenePostImport> post_import_script;
- if (post_import_script_path!="") {
- post_import_script_path = post_import_script_path; // FIXME: is there a good reason for this?
+ if (post_import_script_path != "") {
+ post_import_script_path = post_import_script_path; // FIXME: is there a good reason for this?
Ref<Script> scr = ResourceLoader::load(post_import_script_path);
if (!scr.is_valid()) {
- EditorNode::add_io_error(TTR("Couldn't load post-import script:")+" "+post_import_script_path);
+ EditorNode::add_io_error(TTR("Couldn't load post-import script:") + " " + post_import_script_path);
} else {
- post_import_script = Ref<EditorScenePostImport>( memnew( EditorScenePostImport ) );
+ post_import_script = Ref<EditorScenePostImport>(memnew(EditorScenePostImport));
post_import_script->set_script(scr.get_ref_ptr());
if (!post_import_script->get_script_instance()) {
- EditorNode::add_io_error(TTR("Invalid/broken script for post-import (check console):")+" "+post_import_script_path);
+ EditorNode::add_io_error(TTR("Invalid/broken script for post-import (check console):") + " " + post_import_script_path);
post_import_script.unref();
return ERR_CANT_CREATE;
}
}
}
-
if (post_import_script.is_valid()) {
scene = post_import_script->post_import(scene);
if (!scene) {
- EditorNode::add_io_error(TTR("Error running post-import script:")+" "+post_import_script_path);
+ EditorNode::add_io_error(TTR("Error running post-import script:") + " " + post_import_script_path);
return err;
}
-
-
}
- progress.step(TTR("Saving.."),104);
+ progress.step(TTR("Saving.."), 104);
- Ref<PackedScene> packer = memnew( PackedScene );
+ Ref<PackedScene> packer = memnew(PackedScene);
packer->pack(scene);
- print_line("SAVING TO: "+p_save_path+".scn");
- err = ResourceSaver::save(p_save_path+".scn",packer); //do not take over, let the changed files reload themselves
+ print_line("SAVING TO: " + p_save_path + ".scn");
+ err = ResourceSaver::save(p_save_path + ".scn", packer); //do not take over, let the changed files reload themselves
memdelete(scene);
@@ -1348,9 +1275,8 @@ Error ResourceImporterScene::import(const String& p_source_file, const String& p
return OK;
}
-ResourceImporterScene *ResourceImporterScene::singleton=NULL;
+ResourceImporterScene *ResourceImporterScene::singleton = NULL;
-ResourceImporterScene::ResourceImporterScene()
-{
- singleton=this;
+ResourceImporterScene::ResourceImporterScene() {
+ singleton = this;
}
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index ab6b223839..799d458837 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -37,56 +37,53 @@ class Material;
class EditorSceneImporter : public Reference {
- GDCLASS(EditorSceneImporter,Reference );
-public:
+ GDCLASS(EditorSceneImporter, Reference);
+public:
enum ImportFlags {
- IMPORT_SCENE=1,
- IMPORT_ANIMATION=2,
- IMPORT_ANIMATION_DETECT_LOOP=4,
- IMPORT_ANIMATION_OPTIMIZE=8,
- IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS=16,
- IMPORT_ANIMATION_KEEP_VALUE_TRACKS=32,
- IMPORT_GENERATE_TANGENT_ARRAYS=256,
- IMPORT_FAIL_ON_MISSING_DEPENDENCIES=512,
- IMPORT_MATERIALS_IN_INSTANCES=1024
+ IMPORT_SCENE = 1,
+ IMPORT_ANIMATION = 2,
+ IMPORT_ANIMATION_DETECT_LOOP = 4,
+ IMPORT_ANIMATION_OPTIMIZE = 8,
+ IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS = 16,
+ IMPORT_ANIMATION_KEEP_VALUE_TRACKS = 32,
+ IMPORT_GENERATE_TANGENT_ARRAYS = 256,
+ IMPORT_FAIL_ON_MISSING_DEPENDENCIES = 512,
+ IMPORT_MATERIALS_IN_INSTANCES = 1024
};
- virtual uint32_t get_import_flags() const=0;
- virtual void get_extensions(List<String> *r_extensions) const=0;
- virtual Node* import_scene(const String& p_path,uint32_t p_flags,int p_bake_fps,List<String> *r_missing_deps,Error* r_err=NULL)=0;
- virtual Ref<Animation> import_animation(const String& p_path,uint32_t p_flags)=0;
-
-
+ virtual uint32_t get_import_flags() const = 0;
+ virtual void get_extensions(List<String> *r_extensions) const = 0;
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL) = 0;
+ virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags) = 0;
EditorSceneImporter() {}
};
class EditorScenePostImport : public Reference {
- GDCLASS(EditorScenePostImport,Reference );
-protected:
+ GDCLASS(EditorScenePostImport, Reference);
+protected:
static void _bind_methods();
-public:
- virtual Node* post_import(Node* p_scene);
+public:
+ virtual Node *post_import(Node *p_scene);
EditorScenePostImport();
};
-
class ResourceImporterScene : public ResourceImporter {
- GDCLASS(ResourceImporterScene,ResourceImporter)
+ GDCLASS(ResourceImporterScene, ResourceImporter)
- Set< Ref<EditorSceneImporter> > importers;
+ Set<Ref<EditorSceneImporter> > importers;
static ResourceImporterScene *singleton;
-public:
+public:
static ResourceImporterScene *get_singleton() { return singleton; }
- const Set< Ref<EditorSceneImporter> >& get_importers() const { return importers; }
+ const Set<Ref<EditorSceneImporter> > &get_importers() const { return importers; }
void add_importer(Ref<EditorSceneImporter> p_importer) { importers.insert(p_importer); }
@@ -96,26 +93,24 @@ public:
virtual String get_save_extension() const;
virtual String get_resource_type() const;
-
virtual int get_preset_count() const;
virtual String get_preset_name(int p_idx) const;
- virtual void get_import_options(List<ImportOption> *r_options,int p_preset=0) const;
- virtual bool get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const;
+ virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
+ virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
- void _make_external_resources(Node* p_node,const String& p_base_path, bool p_make_materials, bool p_make_meshes, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<Mesh>, Ref<Mesh> > &p_meshes);
+ void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_materials, bool p_make_meshes, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<Mesh>, Ref<Mesh> > &p_meshes);
- Node* _fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,Ref<Shape> > &collision_map);
+ Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, Ref<Shape> > &collision_map);
- void _create_clips(Node *scene, const Array& p_clips,bool p_bake_all);
- void _filter_anim_tracks(Ref<Animation> anim,Set<String> &keep);
- void _filter_tracks(Node *scene, const String& p_text);
- void _optimize_animations(Node *scene, float p_max_lin_error,float p_max_ang_error,float p_max_angle);
+ void _create_clips(Node *scene, const Array &p_clips, bool p_bake_all);
+ void _filter_anim_tracks(Ref<Animation> anim, Set<String> &keep);
+ void _filter_tracks(Node *scene, const String &p_text);
+ void _optimize_animations(Node *scene, float p_max_lin_error, float p_max_ang_error, float p_max_angle);
- virtual Error import(const String& p_source_file,const String& p_save_path,const Map<StringName,Variant>& p_options,List<String>* r_platform_variants,List<String>* r_gen_files=NULL);
+ virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL);
ResourceImporterScene();
};
-
#endif // RESOURCEIMPORTERSCENE_H
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index f7bd944ceb..cb419e0f4a 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -28,48 +28,41 @@
/*************************************************************************/
#include "resource_importer_texture.h"
-#include "io/image_loader.h"
-#include "scene/resources/texture.h"
#include "editor/editor_file_system.h"
#include "io/config_file.h"
+#include "io/image_loader.h"
+#include "scene/resources/texture.h"
-
-void ResourceImporterTexture::_texture_reimport_srgb(const Ref<StreamTexture>& p_tex) {
+void ResourceImporterTexture::_texture_reimport_srgb(const Ref<StreamTexture> &p_tex) {
singleton->mutex->lock();
StringName path = p_tex->get_path();
if (!singleton->make_flags.has(path)) {
- singleton->make_flags[path]=0;
+ singleton->make_flags[path] = 0;
}
- singleton->make_flags[path]|=MAKE_SRGB_FLAG;
+ singleton->make_flags[path] |= MAKE_SRGB_FLAG;
- print_line("requesting srgb for "+String(path));
+ print_line("requesting srgb for " + String(path));
singleton->mutex->unlock();
-
}
-
-
-void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture>& p_tex) {
-
+void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture> &p_tex) {
singleton->mutex->lock();
StringName path = p_tex->get_path();
if (!singleton->make_flags.has(path)) {
- singleton->make_flags[path]=0;
+ singleton->make_flags[path] = 0;
}
- singleton->make_flags[path]|=MAKE_3D_FLAG;
+ singleton->make_flags[path] |= MAKE_3D_FLAG;
- print_line("requesting 3d for "+String(path));
+ print_line("requesting 3d for " + String(path));
singleton->mutex->unlock();
-
-
}
void ResourceImporterTexture::update_imports() {
@@ -85,38 +78,36 @@ void ResourceImporterTexture::update_imports() {
}
Vector<String> to_reimport;
- for (Map<StringName,int>::Element *E=make_flags.front();E;E=E->next()) {
-
- print_line("checking for reimport "+String(E->key()));
+ for (Map<StringName, int>::Element *E = make_flags.front(); E; E = E->next()) {
+ print_line("checking for reimport " + String(E->key()));
Ref<ConfigFile> cf;
cf.instance();
- String src_path = String(E->key())+".import";
+ String src_path = String(E->key()) + ".import";
Error err = cf->load(src_path);
- ERR_CONTINUE(err!=OK);
+ ERR_CONTINUE(err != OK);
- bool changed=false;
- if (E->get()&MAKE_SRGB_FLAG && int(cf->get_value("params","flags/srgb"))==2) {
- cf->set_value("params","flags/srgb",1);
- changed=true;
+ bool changed = false;
+ if (E->get() & MAKE_SRGB_FLAG && int(cf->get_value("params", "flags/srgb")) == 2) {
+ cf->set_value("params", "flags/srgb", 1);
+ changed = true;
}
- if (E->get()&MAKE_3D_FLAG && bool(cf->get_value("params","detect_3d"))) {
- cf->set_value("params","detect_3d",false);
- cf->set_value("params","compress/mode",2);
- cf->set_value("params","flags/repeat",true);
- cf->set_value("params","flags/filter",true);
- cf->set_value("params","flags/mipmaps",true);
- changed=true;
+ if (E->get() & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d"))) {
+ cf->set_value("params", "detect_3d", false);
+ cf->set_value("params", "compress/mode", 2);
+ cf->set_value("params", "flags/repeat", true);
+ cf->set_value("params", "flags/filter", true);
+ cf->set_value("params", "flags/mipmaps", true);
+ changed = true;
}
if (changed) {
cf->save(src_path);
to_reimport.push_back(E->key());
}
-
}
make_flags.clear();
@@ -126,21 +117,18 @@ void ResourceImporterTexture::update_imports() {
if (to_reimport.size()) {
EditorFileSystem::get_singleton()->reimport_files(to_reimport);
}
-
}
-
-
String ResourceImporterTexture::get_importer_name() const {
return "texture";
}
-String ResourceImporterTexture::get_visible_name() const{
+String ResourceImporterTexture::get_visible_name() const {
return "Texture";
}
-void ResourceImporterTexture::get_recognized_extensions(List<String> *p_extensions) const{
+void ResourceImporterTexture::get_recognized_extensions(List<String> *p_extensions) const {
ImageLoader::get_recognized_extensions(p_extensions);
}
@@ -148,14 +136,14 @@ String ResourceImporterTexture::get_save_extension() const {
return "stex";
}
-String ResourceImporterTexture::get_resource_type() const{
+String ResourceImporterTexture::get_resource_type() const {
return "StreamTexture";
}
-bool ResourceImporterTexture::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const {
+bool ResourceImporterTexture::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
- if (p_option=="compress/lossy_quality" && int(p_options["compress/mode"])!=COMPRESS_LOSSY)
+ if (p_option == "compress/lossy_quality" && int(p_options["compress/mode"]) != COMPRESS_LOSSY)
return false;
return true;
@@ -166,7 +154,7 @@ int ResourceImporterTexture::get_preset_count() const {
}
String ResourceImporterTexture::get_preset_name(int p_idx) const {
- static const char* preset_names[]={
+ static const char *preset_names[] = {
"2D, Detect 3D",
"2D",
"2D Pixel",
@@ -176,30 +164,25 @@ String ResourceImporterTexture::get_preset_name(int p_idx) const {
return preset_names[p_idx];
}
-
-void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options,int p_preset) const {
-
-
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"compress/mode",PROPERTY_HINT_ENUM,"Lossless,Lossy,Video RAM,Uncompressed",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED),p_preset==PRESET_3D?2:0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"compress/lossy_quality",PROPERTY_HINT_RANGE,"0,1,0.01"),0.7));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"flags/repeat",PROPERTY_HINT_ENUM,"Disabled,Enabled,Mirrored"),p_preset==PRESET_3D?1:0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"flags/filter"),p_preset==PRESET_2D_PIXEL?false:true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"flags/mipmaps"),p_preset==PRESET_3D?true:false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"flags/anisotropic"),false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"flags/srgb",PROPERTY_HINT_ENUM,"Disable,Enable,Detect"),2));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"process/fix_alpha_border"),p_preset!=PRESET_3D?true:false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"process/premult_alpha"),true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"stream"),false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"size_limit",PROPERTY_HINT_RANGE,"0,4096,1"),0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"detect_3d"),p_preset==PRESET_DETECT));
-
+void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const {
+
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Lossy,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 2 : 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), p_preset == PRESET_3D ? 1 : 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), p_preset == PRESET_2D_PIXEL ? false : true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), p_preset == PRESET_3D ? true : false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/anisotropic"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/srgb", PROPERTY_HINT_ENUM, "Disable,Enable,Detect"), 2));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/fix_alpha_border"), p_preset != PRESET_3D ? true : false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/premult_alpha"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "stream"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "detect_3d"), p_preset == PRESET_DETECT));
}
+void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb) {
-void ResourceImporterTexture::_save_stex(const Image& p_image, const String& p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb) {
-
-
- FileAccess *f = FileAccess::open(p_to_path,FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE);
f->store_8('G');
f->store_8('D');
f->store_8('S');
@@ -209,17 +192,16 @@ void ResourceImporterTexture::_save_stex(const Image& p_image, const String& p_t
f->store_32(p_image.get_height());
f->store_32(p_texture_flags);
- uint32_t format=0;
+ uint32_t format = 0;
if (p_streamable)
- format|=StreamTexture::FORMAT_BIT_STREAM;
- if (p_mipmaps || p_compress_mode==COMPRESS_VIDEO_RAM) //VRAM always uses mipmaps
- format|=StreamTexture::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit
+ format |= StreamTexture::FORMAT_BIT_STREAM;
+ if (p_mipmaps || p_compress_mode == COMPRESS_VIDEO_RAM) //VRAM always uses mipmaps
+ format |= StreamTexture::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit
if (p_detect_3d)
- format|=StreamTexture::FORMAT_BIT_DETECT_3D;
+ format |= StreamTexture::FORMAT_BIT_DETECT_3D;
if (p_detect_srgb)
- format|=StreamTexture::FORMAT_BIT_DETECT_SRGB;
-
+ format |= StreamTexture::FORMAT_BIT_DETECT_SRGB;
switch (p_compress_mode) {
case COMPRESS_LOSSLESS: {
@@ -233,13 +215,13 @@ void ResourceImporterTexture::_save_stex(const Image& p_image, const String& p_t
int mmc = image.get_mipmap_count() + 1;
- format|=StreamTexture::FORMAT_BIT_LOSSLESS;
+ format |= StreamTexture::FORMAT_BIT_LOSSLESS;
f->store_32(format);
f->store_32(mmc);
- for(int i=0;i<mmc;i++) {
+ for (int i = 0; i < mmc; i++) {
- if (i>0) {
+ if (i > 0) {
image.shrink_x2();
}
@@ -247,12 +229,10 @@ void ResourceImporterTexture::_save_stex(const Image& p_image, const String& p_t
int data_len = data.size();
f->store_32(data_len);
- PoolVector<uint8_t>::Read r= data.read();
- f->store_buffer(r.ptr(),data_len);
-
+ PoolVector<uint8_t>::Read r = data.read();
+ f->store_buffer(r.ptr(), data_len);
}
-
} break;
case COMPRESS_LOSSY: {
Image image = p_image;
@@ -264,23 +244,22 @@ void ResourceImporterTexture::_save_stex(const Image& p_image, const String& p_t
int mmc = image.get_mipmap_count() + 1;
- format|=StreamTexture::FORMAT_BIT_LOSSY;
+ format |= StreamTexture::FORMAT_BIT_LOSSY;
f->store_32(format);
f->store_32(mmc);
- for(int i=0;i<mmc;i++) {
+ for (int i = 0; i < mmc; i++) {
- if (i>0) {
+ if (i > 0) {
image.shrink_x2();
}
- PoolVector<uint8_t> data = Image::lossy_packer(image,p_lossy_quality);
+ PoolVector<uint8_t> data = Image::lossy_packer(image, p_lossy_quality);
int data_len = data.size();
f->store_32(data_len);
PoolVector<uint8_t>::Read r = data.read();
- f->store_buffer(r.ptr(),data_len);
-
+ f->store_buffer(r.ptr(), data_len);
}
} break;
case COMPRESS_VIDEO_RAM: {
@@ -293,10 +272,10 @@ void ResourceImporterTexture::_save_stex(const Image& p_image, const String& p_t
f->store_32(format);
- PoolVector<uint8_t> data=image.get_data();
+ PoolVector<uint8_t> data = image.get_data();
int dl = data.size();
PoolVector<uint8_t>::Read r = data.read();
- f->store_buffer(r.ptr(),dl);
+ f->store_buffer(r.ptr(), dl);
} break;
case COMPRESS_UNCOMPRESSED: {
@@ -311,11 +290,11 @@ void ResourceImporterTexture::_save_stex(const Image& p_image, const String& p_t
format |= image.get_format();
f->store_32(format);
- PoolVector<uint8_t> data=image.get_data();
+ PoolVector<uint8_t> data = image.get_data();
int dl = data.size();
PoolVector<uint8_t>::Read r = data.read();
- f->store_buffer(r.ptr(),dl);
+ f->store_buffer(r.ptr(), dl);
} break;
}
@@ -323,54 +302,52 @@ void ResourceImporterTexture::_save_stex(const Image& p_image, const String& p_t
memdelete(f);
}
-Error ResourceImporterTexture::import(const String& p_source_file, const String& p_save_path, const Map<StringName,Variant>& p_options, List<String>* r_platform_variants, List<String> *r_gen_files) {
+Error ResourceImporterTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
int compress_mode = p_options["compress/mode"];
- float lossy= p_options["compress/lossy_quality"];
- int repeat= p_options["flags/repeat"];
- bool filter= p_options["flags/filter"];
- bool mipmaps= p_options["flags/mipmaps"];
- bool anisotropic= p_options["flags/anisotropic"];
- int srgb= p_options["flags/srgb"];
- bool fix_alpha_border= p_options["process/fix_alpha_border"];
- bool premult_alpha= p_options["process/premult_alpha"];
+ float lossy = p_options["compress/lossy_quality"];
+ int repeat = p_options["flags/repeat"];
+ bool filter = p_options["flags/filter"];
+ bool mipmaps = p_options["flags/mipmaps"];
+ bool anisotropic = p_options["flags/anisotropic"];
+ int srgb = p_options["flags/srgb"];
+ bool fix_alpha_border = p_options["process/fix_alpha_border"];
+ bool premult_alpha = p_options["process/premult_alpha"];
bool stream = p_options["stream"];
int size_limit = p_options["size_limit"];
-
Image image;
- Error err = ImageLoader::load_image(p_source_file,&image);
- if (err!=OK)
+ Error err = ImageLoader::load_image(p_source_file, &image);
+ if (err != OK)
return err;
-
- int tex_flags=0;
- if (repeat>0)
- tex_flags|=Texture::FLAG_REPEAT;
- if (repeat==2)
- tex_flags|=Texture::FLAG_MIRRORED_REPEAT;
+ int tex_flags = 0;
+ if (repeat > 0)
+ tex_flags |= Texture::FLAG_REPEAT;
+ if (repeat == 2)
+ tex_flags |= Texture::FLAG_MIRRORED_REPEAT;
if (filter)
- tex_flags|=Texture::FLAG_FILTER;
- if (mipmaps || compress_mode==COMPRESS_VIDEO_RAM)
- tex_flags|=Texture::FLAG_MIPMAPS;
+ tex_flags |= Texture::FLAG_FILTER;
+ if (mipmaps || compress_mode == COMPRESS_VIDEO_RAM)
+ tex_flags |= Texture::FLAG_MIPMAPS;
if (anisotropic)
- tex_flags|=Texture::FLAG_ANISOTROPIC_FILTER;
- if (srgb==1)
- tex_flags|=Texture::FLAG_CONVERT_TO_LINEAR;
+ tex_flags |= Texture::FLAG_ANISOTROPIC_FILTER;
+ if (srgb == 1)
+ tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR;
- if (size_limit >0 && (image.get_width()>size_limit || image.get_height()>size_limit )) {
+ if (size_limit > 0 && (image.get_width() > size_limit || image.get_height() > size_limit)) {
//limit size
if (image.get_width() >= image.get_height()) {
int new_width = size_limit;
int new_height = image.get_height() * new_width / image.get_width();
- image.resize(new_width,new_height,Image::INTERPOLATE_CUBIC);
+ image.resize(new_width, new_height, Image::INTERPOLATE_CUBIC);
} else {
int new_height = size_limit;
int new_width = image.get_width() * new_height / image.get_height();
- image.resize(new_width,new_height,Image::INTERPOLATE_CUBIC);
+ image.resize(new_width, new_height, Image::INTERPOLATE_CUBIC);
}
}
@@ -383,40 +360,37 @@ Error ResourceImporterTexture::import(const String& p_source_file, const String&
}
bool detect_3d = p_options["detect_3d"];
- bool detect_srgb = srgb==2;
+ bool detect_srgb = srgb == 2;
- if (compress_mode==COMPRESS_VIDEO_RAM) {
+ if (compress_mode == COMPRESS_VIDEO_RAM) {
//must import in all formats
//Android, GLES 2.x
- _save_stex(image,p_save_path+".etc.stex",compress_mode,lossy,Image::COMPRESS_ETC,mipmaps,tex_flags,stream,detect_3d,detect_srgb);
+ _save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, tex_flags, stream, detect_3d, detect_srgb);
r_platform_variants->push_back("etc");
//_save_stex(image,p_save_path+".etc2.stex",compress_mode,lossy,Image::COMPRESS_ETC2,mipmaps,tex_flags,stream);
//r_platform_variants->push_back("etc2");
- _save_stex(image,p_save_path+".s3tc.stex",compress_mode,lossy,Image::COMPRESS_S3TC,mipmaps,tex_flags,stream,detect_3d,detect_srgb);
+ _save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb);
r_platform_variants->push_back("s3tc");
} else {
//import normally
- _save_stex(image,p_save_path+".stex",compress_mode,lossy,Image::COMPRESS_16BIT /*this is ignored */,mipmaps,tex_flags,stream,detect_3d,detect_srgb);
+ _save_stex(image, p_save_path + ".stex", compress_mode, lossy, Image::COMPRESS_16BIT /*this is ignored */, mipmaps, tex_flags, stream, detect_3d, detect_srgb);
}
return OK;
}
-ResourceImporterTexture *ResourceImporterTexture::singleton=NULL;
+ResourceImporterTexture *ResourceImporterTexture::singleton = NULL;
-ResourceImporterTexture::ResourceImporterTexture()
-{
+ResourceImporterTexture::ResourceImporterTexture() {
- singleton=this;
- StreamTexture::request_3d_callback=_texture_reimport_3d;
- StreamTexture::request_srgb_callback=_texture_reimport_srgb;
+ singleton = this;
+ StreamTexture::request_3d_callback = _texture_reimport_3d;
+ StreamTexture::request_srgb_callback = _texture_reimport_srgb;
mutex = Mutex::create();
}
-ResourceImporterTexture::~ResourceImporterTexture()
-{
+ResourceImporterTexture::~ResourceImporterTexture() {
memdelete(mutex);
}
-
diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h
index 2667fb1601..9be016884d 100644
--- a/editor/import/resource_importer_texture.h
+++ b/editor/import/resource_importer_texture.h
@@ -33,29 +33,23 @@
class StreamTexture;
class ResourceImporterTexture : public ResourceImporter {
- GDCLASS(ResourceImporterTexture,ResourceImporter)
-
-
+ GDCLASS(ResourceImporterTexture, ResourceImporter)
protected:
-
enum {
- MAKE_3D_FLAG=1,
- MAKE_SRGB_FLAG=2
+ MAKE_3D_FLAG = 1,
+ MAKE_SRGB_FLAG = 2
};
Mutex *mutex;
- Map<StringName,int> make_flags;
-
- static void _texture_reimport_srgb(const Ref<StreamTexture>& p_tex);
- static void _texture_reimport_3d(const Ref<StreamTexture>& p_tex);
-
-
+ Map<StringName, int> make_flags;
+ static void _texture_reimport_srgb(const Ref<StreamTexture> &p_tex);
+ static void _texture_reimport_3d(const Ref<StreamTexture> &p_tex);
static ResourceImporterTexture *singleton;
-public:
+public:
static ResourceImporterTexture *get_singleton() { return singleton; }
virtual String get_importer_name() const;
virtual String get_visible_name() const;
@@ -63,7 +57,6 @@ public:
virtual String get_save_extension() const;
virtual String get_resource_type() const;
-
enum Preset {
PRESET_DETECT,
PRESET_2D,
@@ -81,13 +74,12 @@ public:
virtual int get_preset_count() const;
virtual String get_preset_name(int p_idx) const;
- virtual void get_import_options(List<ImportOption> *r_options,int p_preset=0) const;
- virtual bool get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const;
-
- void _save_stex(const Image& p_image, const String& p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable,bool p_detect_3d,bool p_detect_srgb);
+ virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
+ virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
- virtual Error import(const String& p_source_file,const String& p_save_path,const Map<StringName,Variant>& p_options,List<String>* r_platform_variants,List<String>* r_gen_files=NULL);
+ void _save_stex(const Image &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb);
+ virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL);
void update_imports();
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index 684ef4dc5c..c28c7dd425 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -28,21 +28,21 @@
/*************************************************************************/
#include "resource_importer_wav.h"
-#include "scene/resources/audio_stream_sample.h"
-#include "os/file_access.h"
#include "io/marshalls.h"
#include "io/resource_saver.h"
+#include "os/file_access.h"
+#include "scene/resources/audio_stream_sample.h"
String ResourceImporterWAV::get_importer_name() const {
return "wav";
}
-String ResourceImporterWAV::get_visible_name() const{
+String ResourceImporterWAV::get_visible_name() const {
return "Microsoft WAV";
}
-void ResourceImporterWAV::get_recognized_extensions(List<String> *p_extensions) const{
+void ResourceImporterWAV::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("wav");
}
@@ -50,12 +50,12 @@ String ResourceImporterWAV::get_save_extension() const {
return "smp";
}
-String ResourceImporterWAV::get_resource_type() const{
+String ResourceImporterWAV::get_resource_type() const {
return "AudioStreamSample";
}
-bool ResourceImporterWAV::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const {
+bool ResourceImporterWAV::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
return true;
}
@@ -68,84 +68,78 @@ String ResourceImporterWAV::get_preset_name(int p_idx) const {
return String();
}
+void ResourceImporterWAV::get_import_options(List<ImportOption> *r_options, int p_preset) const {
-void ResourceImporterWAV::get_import_options(List<ImportOption> *r_options,int p_preset) const {
-
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"force/8_bit"),false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"force/mono"),false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"force/max_rate"),false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"force/max_rate_hz",PROPERTY_HINT_EXP_RANGE,"11025,192000,1"),44100));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"edit/trim"),true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"edit/normalize"),true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"edit/loop"),false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"compress/mode",PROPERTY_HINT_ENUM,"Disabled,RAM (Ima-ADPCM)"),0));
-
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/8_bit"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/mono"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/max_rate"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "force/max_rate_hz", PROPERTY_HINT_EXP_RANGE, "11025,192000,1"), 44100));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/trim"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/normalize"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/loop"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Disabled,RAM (Ima-ADPCM)"), 0));
}
-
-Error ResourceImporterWAV::import(const String& p_source_file, const String& p_save_path, const Map<StringName,Variant>& p_options, List<String>* r_platform_variants, List<String> *r_gen_files) {
+Error ResourceImporterWAV::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
/* STEP 1, READ WAVE FILE */
Error err;
- FileAccess *file=FileAccess::open(p_source_file, FileAccess::READ,&err);
+ FileAccess *file = FileAccess::open(p_source_file, FileAccess::READ, &err);
- ERR_FAIL_COND_V( err!=OK, ERR_CANT_OPEN );
+ ERR_FAIL_COND_V(err != OK, ERR_CANT_OPEN);
/* 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( ERR_FILE_UNRECOGNIZED );
+ ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
}
-
/* 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( ERR_FILE_UNRECOGNIZED );
+ ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
}
- int format_bits=0;
- int format_channels=0;
+ int format_bits = 0;
+ int format_channels = 0;
- AudioStreamSample::LoopMode loop=AudioStreamSample::LOOP_DISABLED;
- bool format_found=false;
- bool data_found=false;
- int format_freq=0;
- int loop_begin=0;
- int loop_end=0;
+ AudioStreamSample::LoopMode loop = AudioStreamSample::LOOP_DISABLED;
+ bool format_found = false;
+ bool data_found = false;
+ int format_freq = 0;
+ int loop_begin = 0;
+ int loop_end = 0;
int frames;
Vector<float> data;
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()) {
@@ -153,107 +147,96 @@ Error ResourceImporterWAV::import(const String& p_source_file, const String& p_s
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;
-
}
- frames=chunksize;
+ 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));
*/
- int len=frames;
- if (format_channels==2)
- len*=2;
- if (format_bits>8)
- len*=2;
-
-
- data.resize(frames*format_channels);
-
- for (int i=0;i<frames;i++) {
+ int len = frames;
+ if (format_channels == 2)
+ len *= 2;
+ if (format_bits > 8)
+ len *= 2;
+ data.resize(frames * format_channels);
- for (int c=0;c<format_channels;c++) {
+ for (int i = 0; i < frames; i++) {
+ 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;
- data[i*format_channels+c]=float(*sp)/128.0;
+ data[i * format_channels + c] = float(*sp) / 128.0;
} else {
//16+ bits samples are SIGNED
// if sample is > 16 bits, just read extra bytes
- uint32_t s=0;
- for (int b=0;b<(format_bits>>3);b++) {
+ uint32_t s = 0;
+ for (int b = 0; b < (format_bits >> 3); b++) {
- s|=((uint32_t)file->get_8())<<(b*8);
+ s |= ((uint32_t)file->get_8()) << (b * 8);
}
- s<<=(32-format_bits);
- int32_t ss=s;
+ s <<= (32 - format_bits);
+ int32_t ss = s;
-
- data[i*format_channels+c]=(ss>>16)/32768.0;
+ data[i * format_channels + c] = (ss >> 16) / 32768.0;
}
}
-
}
-
-
if (file->eof_reached()) {
file->close();
memdelete(file);
@@ -262,18 +245,17 @@ Error ResourceImporterWAV::import(const String& p_source_file, const String& p_s
}
}
- 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()?AudioStreamSample::LOOP_PING_PONG:AudioStreamSample::LOOP_FORWARD;
- loop_begin=file->get_32();
- loop_end=file->get_32();
-
+ loop = file->get_32() ? AudioStreamSample::LOOP_PING_PONG : AudioStreamSample::LOOP_FORWARD;
+ loop_begin = file->get_32();
+ loop_end = file->get_32();
}
- file->seek( file_pos+chunksize );
+ file->seek(file_pos + chunksize);
}
file->close();
@@ -281,19 +263,17 @@ Error ResourceImporterWAV::import(const String& p_source_file, const String& p_s
// STEP 2, APPLY CONVERSIONS
-
- bool is16=format_bits!=8;
- int rate=format_freq;
+ bool is16 = format_bits != 8;
+ int rate = format_freq;
print_line("Input Sample: ");
- print_line("\tframes: "+itos(frames));
- print_line("\tformat_channels: "+itos(format_channels));
- print_line("\t16bits: "+itos(is16));
- print_line("\trate: "+itos(rate));
- print_line("\tloop: "+itos(loop));
- print_line("\tloop begin: "+itos(loop_begin));
- print_line("\tloop end: "+itos(loop_end));
-
+ print_line("\tframes: " + itos(frames));
+ print_line("\tformat_channels: " + itos(format_channels));
+ print_line("\t16bits: " + itos(is16));
+ print_line("\trate: " + itos(rate));
+ print_line("\tloop: " + itos(loop));
+ print_line("\tloop begin: " + itos(loop_begin));
+ print_line("\tloop end: " + itos(loop_end));
//apply frequency limit
@@ -303,64 +283,62 @@ Error ResourceImporterWAV::import(const String& p_source_file, const String& p_s
//resampleeee!!!
int new_data_frames = frames * limit_rate_hz / rate;
Vector<float> new_data;
- new_data.resize( new_data_frames * format_channels );
- for(int c=0;c<format_channels;c++) {
+ new_data.resize(new_data_frames * format_channels);
+ for (int c = 0; c < format_channels; c++) {
- for(int i=0;i<new_data_frames;i++) {
+ for (int i = 0; i < new_data_frames; i++) {
//simple cubic interpolation should be enough.
float pos = float(i) * frames / new_data_frames;
- float mu = pos-Math::floor(pos);
+ float mu = pos - Math::floor(pos);
int ipos = int(Math::floor(pos));
- float y0=data[MAX(0,ipos-1)*format_channels+c];
- float y1=data[ipos*format_channels+c];
- float y2=data[MIN(frames-1,ipos+1)*format_channels+c];
- float y3=data[MIN(frames-1,ipos+2)*format_channels+c];
+ float y0 = data[MAX(0, ipos - 1) * format_channels + c];
+ float y1 = data[ipos * format_channels + c];
+ float y2 = data[MIN(frames - 1, ipos + 1) * format_channels + c];
+ float y3 = data[MIN(frames - 1, ipos + 2) * format_channels + c];
- float mu2 = mu*mu;
+ float mu2 = mu * mu;
float a0 = y3 - y2 - y0 + y1;
float a1 = y0 - y1 - a0;
float a2 = y2 - y0;
float a3 = y1;
- float res=(a0*mu*mu2+a1*mu2+a2*mu+a3);
+ float res = (a0 * mu * mu2 + a1 * mu2 + a2 * mu + a3);
- new_data[i*format_channels+c]=res;
+ new_data[i * format_channels + c] = res;
}
}
if (loop) {
- loop_begin=loop_begin*new_data_frames/frames;
- loop_end=loop_end*new_data_frames/frames;
+ loop_begin = loop_begin * new_data_frames / frames;
+ loop_end = loop_end * new_data_frames / frames;
}
- data=new_data;
- rate=limit_rate_hz;
- frames=new_data_frames;
+ data = new_data;
+ rate = limit_rate_hz;
+ frames = new_data_frames;
}
-
bool normalize = p_options["edit/normalize"];
if (normalize) {
- float max=0;
- for(int i=0;i<data.size();i++) {
+ float max = 0;
+ for (int i = 0; i < data.size(); i++) {
float amp = Math::abs(data[i]);
- if (amp>max)
- max=amp;
+ if (amp > max)
+ max = amp;
}
- if (max>0) {
+ if (max > 0) {
- float mult=1.0/max;
- for(int i=0;i<data.size();i++) {
+ float mult = 1.0 / max;
+ for (int i = 0; i < data.size(); i++) {
- data[i]*=mult;
+ data[i] *= mult;
}
-
}
}
@@ -368,111 +346,108 @@ Error ResourceImporterWAV::import(const String& p_source_file, const String& p_s
if (trim && !loop) {
- int first=0;
- int last=(frames*format_channels)-1;
- bool found=false;
+ int first = 0;
+ int last = (frames * format_channels) - 1;
+ bool found = false;
float limit = Math::db2linear((float)-30);
- for(int i=0;i<data.size();i++) {
+ for (int i = 0; i < data.size(); i++) {
float amp = Math::abs(data[i]);
if (!found && amp > limit) {
- first=i;
- found=true;
+ first = i;
+ found = true;
}
if (found && amp > limit) {
- last=i;
+ last = i;
}
}
- first/=format_channels;
- last/=format_channels;
+ first /= format_channels;
+ last /= format_channels;
- if (first<last) {
+ if (first < last) {
Vector<float> new_data;
- new_data.resize((last-first+1)*format_channels);
- for(int i=first*format_channels;i<=last*format_channels;i++) {
- new_data[i-first*format_channels]=data[i];
+ new_data.resize((last - first + 1) * format_channels);
+ for (int i = first * format_channels; i <= last * format_channels; i++) {
+ new_data[i - first * format_channels] = data[i];
}
- data=new_data;
- frames=data.size()/format_channels;
+ data = new_data;
+ frames = data.size() / format_channels;
}
-
}
bool make_loop = p_options["edit/loop"];
if (make_loop && !loop) {
- loop=AudioStreamSample::LOOP_FORWARD;
- loop_begin=0;
- loop_end=frames;
+ loop = AudioStreamSample::LOOP_FORWARD;
+ loop_begin = 0;
+ loop_end = frames;
}
int compression = p_options["compress/mode"];
bool force_mono = p_options["force/mono"];
-
- if (force_mono && format_channels==2) {
+ if (force_mono && format_channels == 2) {
Vector<float> new_data;
- new_data.resize(data.size()/2);
- for(int i=0;i<frames;i++) {
- new_data[i]=(data[i*2+0]+data[i*2+1])/2.0;
+ new_data.resize(data.size() / 2);
+ for (int i = 0; i < frames; i++) {
+ new_data[i] = (data[i * 2 + 0] + data[i * 2 + 1]) / 2.0;
}
- data=new_data;
- format_channels=1;
+ data = new_data;
+ format_channels = 1;
}
bool force_8_bit = p_options["force/8_bit"];
if (force_8_bit) {
- is16=false;
+ is16 = false;
}
-
PoolVector<uint8_t> dst_data;
AudioStreamSample::Format dst_format;
- if ( compression == 1) {
+ if (compression == 1) {
- dst_format=AudioStreamSample::FORMAT_IMA_ADPCM;
- if (format_channels==1) {
- _compress_ima_adpcm(data,dst_data);
+ dst_format = AudioStreamSample::FORMAT_IMA_ADPCM;
+ if (format_channels == 1) {
+ _compress_ima_adpcm(data, dst_data);
} else {
//byte interleave
Vector<float> left;
Vector<float> right;
- int tframes = data.size()/2;
+ int tframes = data.size() / 2;
left.resize(tframes);
right.resize(tframes);
- for(int i=0;i<tframes;i++) {
- left[i]=data[i*2+0];
- right[i]=data[i*2+1];
+ for (int i = 0; i < tframes; i++) {
+ left[i] = data[i * 2 + 0];
+ right[i] = data[i * 2 + 1];
}
PoolVector<uint8_t> bleft;
PoolVector<uint8_t> bright;
- _compress_ima_adpcm(left,bleft);
- _compress_ima_adpcm(right,bright);
+ _compress_ima_adpcm(left, bleft);
+ _compress_ima_adpcm(right, bright);
int dl = bleft.size();
- dst_data.resize( dl *2 );
+ dst_data.resize(dl * 2);
- PoolVector<uint8_t>::Write w=dst_data.write();
- PoolVector<uint8_t>::Read rl=bleft.read();
- PoolVector<uint8_t>::Read rr=bright.read();
+ PoolVector<uint8_t>::Write w = dst_data.write();
+ PoolVector<uint8_t>::Read rl = bleft.read();
+ PoolVector<uint8_t>::Read rr = bright.read();
- for(int i=0;i<dl;i++) {
- w[i*2+0]=rl[i];
- w[i*2+1]=rr[i];
+ for (int i = 0; i < dl; i++) {
+ w[i * 2 + 0] = rl[i];
+ w[i * 2 + 1] = rr[i];
}
}
@@ -480,26 +455,25 @@ Error ResourceImporterWAV::import(const String& p_source_file, const String& p_s
} else {
- dst_format=is16?AudioStreamSample::FORMAT_16_BITS:AudioStreamSample::FORMAT_8_BITS;
- dst_data.resize( data.size() * (is16?2:1));
+ dst_format = is16 ? AudioStreamSample::FORMAT_16_BITS : AudioStreamSample::FORMAT_8_BITS;
+ dst_data.resize(data.size() * (is16 ? 2 : 1));
{
PoolVector<uint8_t>::Write w = dst_data.write();
- int ds=data.size();
- for(int i=0;i<ds;i++) {
+ int ds = data.size();
+ for (int i = 0; i < ds; i++) {
if (is16) {
- int16_t v = CLAMP(data[i]*32768,-32768,32767);
- encode_uint16(v,&w[i*2]);
+ int16_t v = CLAMP(data[i] * 32768, -32768, 32767);
+ encode_uint16(v, &w[i * 2]);
} else {
- int8_t v = CLAMP(data[i]*128,-128,127);
- w[i]=v;
+ int8_t v = CLAMP(data[i] * 128, -128, 127);
+ w[i] = v;
}
}
}
}
-
Ref<AudioStreamSample> sample;
sample.instance();
sample->set_data(dst_data);
@@ -508,17 +482,14 @@ Error ResourceImporterWAV::import(const String& p_source_file, const String& p_s
sample->set_loop_mode(loop);
sample->set_loop_begin(loop_begin);
sample->set_loop_end(loop_end);
- sample->set_stereo(format_channels==2);
-
- ResourceSaver::save(p_save_path+".smp",sample);
+ sample->set_stereo(format_channels == 2);
+ ResourceSaver::save(p_save_path + ".smp", sample);
return OK;
-
}
-void ResourceImporterWAV::_compress_ima_adpcm(const Vector<float>& p_data,PoolVector<uint8_t>& dst_data) {
-
+void ResourceImporterWAV::_compress_ima_adpcm(const Vector<float> &p_data, PoolVector<uint8_t> &dst_data) {
/*p_sample_data->data = (void*)malloc(len);
xm_s8 *dataptr=(xm_s8*)p_sample_data->data;*/
@@ -540,41 +511,37 @@ void ResourceImporterWAV::_compress_ima_adpcm(const Vector<float>& p_data,PoolVe
-1, -1, -1, -1, 2, 4, 6, 8
};
-
int datalen = p_data.size();
- int datamax=datalen;
- if (datalen&1)
+ int datamax = datalen;
+ if (datalen & 1)
datalen++;
- dst_data.resize(datalen/2+4);
+ dst_data.resize(datalen / 2 + 4);
PoolVector<uint8_t>::Write w = dst_data.write();
-
- int i,step_idx=0,prev=0;
+ int i, step_idx = 0, prev = 0;
uint8_t *out = w.ptr();
//int16_t xm_prev=0;
- const float *in=p_data.ptr();
-
+ const float *in = p_data.ptr();
/* initial value is zero */
- *(out++) =0;
- *(out++) =0;
+ *(out++) = 0;
+ *(out++) = 0;
/* Table index initial value */
- *(out++) =0;
+ *(out++) = 0;
/* unused */
- *(out++) =0;
+ *(out++) = 0;
- for (i=0;i<datalen;i++) {
- int step,diff,vpdiff,mask;
+ for (i = 0; i < datalen; i++) {
+ int step, diff, vpdiff, mask;
uint8_t nibble;
int16_t xm_sample;
- if (i>=datamax)
- xm_sample=0;
+ if (i >= datamax)
+ xm_sample = 0;
else {
-
- xm_sample=CLAMP(in[i]*32767.0,-32768,32767);
+ xm_sample = CLAMP(in[i] * 32767.0, -32768, 32767);
/*
if (xm_sample==32767 || xm_sample==-32768)
printf("clippy!\n",xm_sample);
@@ -584,16 +551,16 @@ void ResourceImporterWAV::_compress_ima_adpcm(const Vector<float>& p_data,PoolVe
//xm_sample=xm_sample+xm_prev;
//xm_prev=xm_sample;
- diff = (int)xm_sample - prev ;
+ diff = (int)xm_sample - prev;
- nibble=0 ;
- step = _ima_adpcm_step_table[ step_idx ];
- vpdiff = step >> 3 ;
+ nibble = 0;
+ step = _ima_adpcm_step_table[step_idx];
+ vpdiff = step >> 3;
if (diff < 0) {
- nibble=8;
- diff=-diff ;
+ nibble = 8;
+ diff = -diff;
}
- mask = 4 ;
+ mask = 4;
while (mask) {
if (diff >= step) {
@@ -603,45 +570,38 @@ void ResourceImporterWAV::_compress_ima_adpcm(const Vector<float>& p_data,PoolVe
vpdiff += step;
}
- step >>= 1 ;
- mask >>= 1 ;
+ step >>= 1;
+ mask >>= 1;
};
- if (nibble&8)
- prev-=vpdiff ;
+ if (nibble & 8)
+ prev -= vpdiff;
else
- prev+=vpdiff ;
+ prev += vpdiff;
if (prev > 32767) {
//printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip up %i\n",i,xm_sample,prev,diff,vpdiff,prev);
- prev=32767;
+ prev = 32767;
} else if (prev < -32768) {
//printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip down %i\n",i,xm_sample,prev,diff,vpdiff,prev);
- prev = -32768 ;
+ prev = -32768;
}
step_idx += _ima_adpcm_index_table[nibble];
- if (step_idx< 0)
- step_idx= 0 ;
- else if (step_idx> 88)
- step_idx= 88 ;
-
+ if (step_idx < 0)
+ step_idx = 0;
+ else if (step_idx > 88)
+ step_idx = 88;
- if (i&1) {
- *out|=nibble<<4;
+ if (i & 1) {
+ *out |= nibble << 4;
out++;
} else {
- *out=nibble;
+ *out = nibble;
}
/*dataptr[i]=prev>>8;*/
}
-
-
-
-
}
-ResourceImporterWAV::ResourceImporterWAV()
-{
-
+ResourceImporterWAV::ResourceImporterWAV() {
}
diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h
index bc93799fee..b78ab1e7bf 100644
--- a/editor/import/resource_importer_wav.h
+++ b/editor/import/resource_importer_wav.h
@@ -29,11 +29,10 @@
#ifndef RESOURCEIMPORTWAV_H
#define RESOURCEIMPORTWAV_H
-
#include "io/resource_import.h"
class ResourceImporterWAV : public ResourceImporter {
- GDCLASS(ResourceImporterWAV,ResourceImporter)
+ GDCLASS(ResourceImporterWAV, ResourceImporter)
public:
virtual String get_importer_name() const;
virtual String get_visible_name() const;
@@ -41,16 +40,15 @@ public:
virtual String get_save_extension() const;
virtual String get_resource_type() const;
-
virtual int get_preset_count() const;
virtual String get_preset_name(int p_idx) const;
- virtual void get_import_options(List<ImportOption> *r_options,int p_preset=0) const;
- virtual bool get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const;
+ virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
+ virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
- void _compress_ima_adpcm(const Vector<float>& p_data,PoolVector<uint8_t>& dst_data);
+ void _compress_ima_adpcm(const Vector<float> &p_data, PoolVector<uint8_t> &dst_data);
- virtual Error import(const String& p_source_file,const String& p_save_path,const Map<StringName,Variant>& p_options,List<String>* r_platform_variants,List<String>* r_gen_files=NULL);
+ virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL);
ResourceImporterWAV();
};
diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp
index 910274a13e..d245450114 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -29,38 +29,36 @@
#include "import_dock.h"
class ImportDockParameters : public Object {
- GDCLASS(ImportDockParameters,Object)
+ GDCLASS(ImportDockParameters, Object)
public:
- Map<StringName,Variant> values;
+ Map<StringName, Variant> values;
List<PropertyInfo> properties;
Ref<ResourceImporter> importer;
Vector<String> paths;
-
- bool _set(const StringName& p_name, const Variant& p_value) {
+ bool _set(const StringName &p_name, const Variant &p_value) {
if (values.has(p_name)) {
- values[p_name]=p_value;
+ values[p_name] = p_value;
return true;
}
return false;
}
- bool _get(const StringName& p_name,Variant &r_ret) const {
+ bool _get(const StringName &p_name, Variant &r_ret) const {
if (values.has(p_name)) {
- r_ret=values[p_name];
+ r_ret = values[p_name];
return true;
}
return false;
-
}
- void _get_property_list( List<PropertyInfo> *p_list) const {
+ void _get_property_list(List<PropertyInfo> *p_list) const {
- for (const List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) {
- if (!importer->get_option_visibility(E->get().name,values))
+ for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
+ if (!importer->get_option_visibility(E->get().name, values))
continue;
p_list->push_back(E->get());
}
@@ -71,18 +69,17 @@ public:
}
};
-void ImportDock::set_edit_path(const String& p_path) {
+void ImportDock::set_edit_path(const String &p_path) {
Ref<ConfigFile> config;
config.instance();
- Error err = config->load(p_path+".import");
- if (err!=OK) {
+ Error err = config->load(p_path + ".import");
+ if (err != OK) {
clear();
return;
}
-
- params->importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(config->get_value("remap","importer"));
+ params->importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(config->get_value("remap", "importer"));
if (params->importer.is_null()) {
clear();
return;
@@ -94,44 +91,44 @@ void ImportDock::set_edit_path(const String& p_path) {
params->properties.clear();
params->values.clear();
- for (List<ResourceImporter::ImportOption>::Element *E=options.front();E;E=E->next()) {
+ for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
params->properties.push_back(E->get().option);
- if (config->has_section_key("params",E->get().option.name)) {
- params->values[E->get().option.name]=config->get_value("params",E->get().option.name);
+ if (config->has_section_key("params", E->get().option.name)) {
+ params->values[E->get().option.name] = config->get_value("params", E->get().option.name);
} else {
- params->values[E->get().option.name]=E->get().default_value;
+ params->values[E->get().option.name] = E->get().default_value;
}
}
params->update();
List<Ref<ResourceImporter> > importers;
- ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_path.get_extension(),&importers);
- List<Pair<String,String> > importer_names;
+ ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_path.get_extension(), &importers);
+ List<Pair<String, String> > importer_names;
- for (List<Ref<ResourceImporter> > ::Element *E=importers.front();E;E=E->next()) {
- importer_names.push_back(Pair<String,String>(E->get()->get_visible_name(),E->get()->get_importer_name()));
+ for (List<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) {
+ importer_names.push_back(Pair<String, String>(E->get()->get_visible_name(), E->get()->get_importer_name()));
}
- importer_names.sort_custom<PairSort<String,String> >();
+ importer_names.sort_custom<PairSort<String, String> >();
import_as->clear();
- for (List<Pair<String,String> >::Element *E=importer_names.front();E;E=E->next()) {
+ for (List<Pair<String, String> >::Element *E = importer_names.front(); E; E = E->next()) {
import_as->add_item(E->get().first);
- import_as->set_item_metadata(import_as->get_item_count()-1,E->get().second);
- if (E->get().second==params->importer->get_importer_name()) {
- import_as->select(import_as->get_item_count()-1);
+ import_as->set_item_metadata(import_as->get_item_count() - 1, E->get().second);
+ if (E->get().second == params->importer->get_importer_name()) {
+ import_as->select(import_as->get_item_count() - 1);
}
}
preset->get_popup()->clear();
- if (params->importer->get_preset_count()==0) {
+ if (params->importer->get_preset_count() == 0) {
preset->get_popup()->add_item(TTR("Default"));
} else {
- for (int i=0;i<params->importer->get_preset_count();i++) {
+ for (int i = 0; i < params->importer->get_preset_count(); i++) {
preset->get_popup()->add_item(params->importer->get_preset_name(i));
}
}
@@ -144,22 +141,22 @@ void ImportDock::set_edit_path(const String& p_path) {
imported->set_text(p_path.get_file());
}
-void ImportDock::set_edit_multiple_paths(const Vector<String>& p_paths) {
+void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
clear();
//use the value that is repeated the mot
- Map<String,Dictionary> value_frequency;
+ Map<String, Dictionary> value_frequency;
- for(int i=0;i<p_paths.size();i++) {
+ for (int i = 0; i < p_paths.size(); i++) {
Ref<ConfigFile> config;
config.instance();
- Error err = config->load(p_paths[i]+".import");
- ERR_CONTINUE(err!=OK);
+ Error err = config->load(p_paths[i] + ".import");
+ ERR_CONTINUE(err != OK);
- if (i==0) {
- params->importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(config->get_value("remap","importer"));
+ if (i == 0) {
+ params->importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(config->get_value("remap", "importer"));
if (params->importer.is_null()) {
clear();
return;
@@ -167,24 +164,22 @@ void ImportDock::set_edit_multiple_paths(const Vector<String>& p_paths) {
}
List<String> keys;
- config->get_section_keys("params",&keys);
+ config->get_section_keys("params", &keys);
-
- for (List<String>::Element *E=keys.front();E;E=E->next()) {
+ for (List<String>::Element *E = keys.front(); E; E = E->next()) {
if (!value_frequency.has(E->get())) {
- value_frequency[E->get()]=Dictionary();
+ value_frequency[E->get()] = Dictionary();
}
- Variant value = config->get_value("params",E->get());
+ Variant value = config->get_value("params", E->get());
if (value_frequency[E->get()].has(value)) {
- value_frequency[E->get()][value]=int(value_frequency[E->get()][value])+1;
+ value_frequency[E->get()][value] = int(value_frequency[E->get()][value]) + 1;
} else {
- value_frequency[E->get()][value]=1;
+ value_frequency[E->get()][value] = 1;
}
}
-
}
ERR_FAIL_COND(params->importer.is_null());
@@ -195,86 +190,84 @@ void ImportDock::set_edit_multiple_paths(const Vector<String>& p_paths) {
params->properties.clear();
params->values.clear();
- for (List<ResourceImporter::ImportOption>::Element *E=options.front();E;E=E->next()) {
+ for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
params->properties.push_back(E->get().option);
if (value_frequency.has(E->get().option.name)) {
Dictionary d = value_frequency[E->get().option.name];
- int freq=0;
+ int freq = 0;
List<Variant> v;
d.get_key_list(&v);
Variant value;
- for (List<Variant>::Element *F=v.front();F;F=F->next()) {
+ for (List<Variant>::Element *F = v.front(); F; F = F->next()) {
int f = d[F->get()];
- if (f>freq) {
- value=F->get();
+ if (f > freq) {
+ value = F->get();
}
}
- params->values[E->get().option.name]=value;
+ params->values[E->get().option.name] = value;
} else {
- params->values[E->get().option.name]=E->get().default_value;
+ params->values[E->get().option.name] = E->get().default_value;
}
}
params->update();
List<Ref<ResourceImporter> > importers;
- ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_paths[0].get_extension(),&importers);
- List<Pair<String,String> > importer_names;
+ ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_paths[0].get_extension(), &importers);
+ List<Pair<String, String> > importer_names;
- for (List<Ref<ResourceImporter> > ::Element *E=importers.front();E;E=E->next()) {
- importer_names.push_back(Pair<String,String>(E->get()->get_visible_name(),E->get()->get_importer_name()));
+ for (List<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) {
+ importer_names.push_back(Pair<String, String>(E->get()->get_visible_name(), E->get()->get_importer_name()));
}
- importer_names.sort_custom<PairSort<String,String> >();
+ importer_names.sort_custom<PairSort<String, String> >();
import_as->clear();
- for (List<Pair<String,String> >::Element *E=importer_names.front();E;E=E->next()) {
+ for (List<Pair<String, String> >::Element *E = importer_names.front(); E; E = E->next()) {
import_as->add_item(E->get().first);
- import_as->set_item_metadata(import_as->get_item_count()-1,E->get().second);
- if (E->get().second==params->importer->get_importer_name()) {
- import_as->select(import_as->get_item_count()-1);
+ import_as->set_item_metadata(import_as->get_item_count() - 1, E->get().second);
+ if (E->get().second == params->importer->get_importer_name()) {
+ import_as->select(import_as->get_item_count() - 1);
}
}
preset->get_popup()->clear();
- if (params->importer->get_preset_count()==0) {
+ if (params->importer->get_preset_count() == 0) {
preset->get_popup()->add_item(TTR("Default"));
} else {
- for (int i=0;i<params->importer->get_preset_count();i++) {
+ for (int i = 0; i < params->importer->get_preset_count(); i++) {
preset->get_popup()->add_item(params->importer->get_preset_name(i));
}
}
- params->paths=p_paths;
+ params->paths = p_paths;
import->set_disabled(false);
import_as->set_disabled(false);
- imported->set_text(itos(p_paths.size())+TTR(" Files"));
+ imported->set_text(itos(p_paths.size()) + TTR(" Files"));
}
void ImportDock::_preset_selected(int p_idx) {
- print_line("preset selected? "+p_idx);
+ print_line("preset selected? " + p_idx);
List<ResourceImporter::ImportOption> options;
- params->importer->get_import_options(&options,p_idx);
+ params->importer->get_import_options(&options, p_idx);
- for (List<ResourceImporter::ImportOption>::Element *E=options.front();E;E=E->next()) {
+ for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) {
- params->values[E->get().option.name]=E->get().default_value;
+ params->values[E->get().option.name] = E->get().default_value;
}
params->update();
-
}
-
void ImportDock::clear() {
imported->set_text("");
@@ -285,72 +278,68 @@ void ImportDock::clear() {
params->properties.clear();
params->update();
preset->get_popup()->clear();
-
}
void ImportDock::_reimport() {
- for(int i=0;i<params->paths.size();i++) {
+ for (int i = 0; i < params->paths.size(); i++) {
Ref<ConfigFile> config;
config.instance();
- Error err = config->load(params->paths[i]+".import");
- ERR_CONTINUE(err!=OK);
+ Error err = config->load(params->paths[i] + ".import");
+ ERR_CONTINUE(err != OK);
config->erase_section("params");
- for (List<PropertyInfo>::Element *E=params->properties.front();E;E=E->next()) {
- config->set_value("params",E->get().name,params->values[E->get().name]);
+ for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) {
+ config->set_value("params", E->get().name, params->values[E->get().name]);
}
- config->save(params->paths[i]+".import");
+ config->save(params->paths[i] + ".import");
}
EditorFileSystem::get_singleton()->reimport_files(params->paths);
EditorFileSystem::get_singleton()->emit_signal("filesystem_changed"); //it changed, so force emitting the signal
-
}
void ImportDock::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_reimport"),&ImportDock::_reimport);
- ClassDB::bind_method(D_METHOD("_preset_selected"),&ImportDock::_preset_selected);
+ ClassDB::bind_method(D_METHOD("_reimport"), &ImportDock::_reimport);
+ ClassDB::bind_method(D_METHOD("_preset_selected"), &ImportDock::_preset_selected);
}
ImportDock::ImportDock() {
-
- imported = memnew( LineEdit );
+ imported = memnew(LineEdit);
imported->set_editable(false);
add_child(imported);
HBoxContainer *hb = memnew(HBoxContainer);
- add_margin_child(TTR("Import As:"),hb);
- import_as = memnew( OptionButton );
+ add_margin_child(TTR("Import As:"), hb);
+ import_as = memnew(OptionButton);
hb->add_child(import_as);
import_as->set_h_size_flags(SIZE_EXPAND_FILL);
- preset = memnew( MenuButton );
+ preset = memnew(MenuButton);
preset->set_text(TTR("Preset.."));
- preset->get_popup()->connect("index_pressed",this,"_preset_selected");
+ preset->get_popup()->connect("index_pressed", this, "_preset_selected");
hb->add_child(preset);
- import_opts = memnew( PropertyEditor );
+ import_opts = memnew(PropertyEditor);
add_child(import_opts);
import_opts->set_v_size_flags(SIZE_EXPAND_FILL);
import_opts->hide_top_label();
import_opts->set_hide_script(true);
- hb = memnew( HBoxContainer );
+ hb = memnew(HBoxContainer);
add_child(hb);
- import = memnew( Button );
+ import = memnew(Button);
import->set_text(TTR("Reimport"));
- import->connect("pressed",this,"_reimport");
+ import->connect("pressed", this, "_reimport");
hb->add_spacer();
hb->add_child(import);
hb->add_spacer();
- params = memnew( ImportDockParameters );
+ params = memnew(ImportDockParameters);
import_opts->edit(params);
-
}
ImportDock::~ImportDock() {
diff --git a/editor/import_dock.h b/editor/import_dock.h
index 0153955d32..2c78b922eb 100644
--- a/editor/import_dock.h
+++ b/editor/import_dock.h
@@ -29,16 +29,16 @@
#ifndef IMPORTDOCK_H
#define IMPORTDOCK_H
-#include "io/resource_import.h"
#include "editor_file_system.h"
+#include "io/resource_import.h"
+#include "property_editor.h"
#include "scene/gui/box_container.h"
#include "scene/gui/option_button.h"
#include "scene/gui/popup_menu.h"
-#include "property_editor.h"
class ImportDockParameters;
class ImportDock : public VBoxContainer {
- GDCLASS(ImportDock,VBoxContainer)
+ GDCLASS(ImportDock, VBoxContainer)
LineEdit *imported;
OptionButton *import_as;
@@ -46,7 +46,7 @@ class ImportDock : public VBoxContainer {
PropertyEditor *import_opts;
List<PropertyInfo> properties;
- Map<StringName,Variant> property_values;
+ Map<StringName, Variant> property_values;
Button *import;
@@ -55,12 +55,13 @@ class ImportDock : public VBoxContainer {
void _preset_selected(int p_idx);
void _reimport();
+
protected:
static void _bind_methods();
-public:
- void set_edit_path(const String& p_path);
- void set_edit_multiple_paths(const Vector<String>& p_paths);
+public:
+ void set_edit_path(const String &p_path);
+ void set_edit_multiple_paths(const Vector<String> &p_paths);
void clear();
ImportDock();
diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h
index be6ed5fa87..83a7e5f54b 100644
--- a/editor/inspector_dock.h
+++ b/editor/inspector_dock.h
@@ -29,9 +29,8 @@
#ifndef INSPECTOR_DOCK_H
#define INSPECTOR_DOCK_H
-#include "scene/gui/box_container.h"
#include "property_editor.h"
-
+#include "scene/gui/box_container.h"
//this is for now bundled in EditorNode, will be moved away here eventually
diff --git a/editor/io_plugins/editor_atlas.cpp b/editor/io_plugins/editor_atlas.cpp
index c5f1ee73cf..1aa480f442 100644
--- a/editor/io_plugins/editor_atlas.cpp
+++ b/editor/io_plugins/editor_atlas.cpp
@@ -35,7 +35,7 @@ struct _EditorAtlasWorkRect {
Size2i s;
Point2i p;
int idx;
- _FORCE_INLINE_ bool operator<(const _EditorAtlasWorkRect& p_r) const { return s.width > p_r.s.width; };
+ _FORCE_INLINE_ bool operator<(const _EditorAtlasWorkRect &p_r) const { return s.width > p_r.s.width; };
};
struct _EditorAtlasWorkRectResult {
@@ -45,7 +45,7 @@ struct _EditorAtlasWorkRectResult {
int max_h;
};
-void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, Size2i& r_size) {
+void EditorAtlas::fit(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size) {
//super simple, almost brute force scanline stacking fitter
//it's pretty basic for now, but it tries to make sure that the aspect ratio of the
@@ -55,106 +55,98 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S
// for example, it will prioritize a 1024x1024 atlas (works everywhere) instead of a
// 256x8192 atlas (won't work anywhere).
- ERR_FAIL_COND(p_rects.size()==0);
+ ERR_FAIL_COND(p_rects.size() == 0);
Vector<_EditorAtlasWorkRect> wrects;
wrects.resize(p_rects.size());
- for(int i=0;i<p_rects.size();i++) {
- wrects[i].s=p_rects[i];
- wrects[i].idx=i;
+ for (int i = 0; i < p_rects.size(); i++) {
+ wrects[i].s = p_rects[i];
+ wrects[i].idx = i;
}
wrects.sort();
int widest = wrects[0].s.width;
Vector<_EditorAtlasWorkRectResult> results;
- for(int i=0;i<=12;i++) {
+ for (int i = 0; i <= 12; i++) {
- int w = 1<<i;
- int max_h=0;
- int max_w=0;
- if ( w < widest )
+ int w = 1 << i;
+ int max_h = 0;
+ int max_w = 0;
+ if (w < widest)
continue;
Vector<int> hmax;
hmax.resize(w);
- for(int j=0;j<w;j++)
- hmax[j]=0;
+ for (int j = 0; j < w; j++)
+ hmax[j] = 0;
//place them
- int ofs=0;
+ int ofs = 0;
- for(int j=0;j<wrects.size();j++) {
+ for (int j = 0; j < wrects.size(); j++) {
+ if (ofs + wrects[j].s.width > w) {
- if (ofs+wrects[j].s.width > w) {
-
- ofs=0;
+ ofs = 0;
}
- int from_y=0;
- for(int k=0;k<wrects[j].s.width;k++) {
+ int from_y = 0;
+ for (int k = 0; k < wrects[j].s.width; k++) {
- if (hmax[ofs+k] > from_y)
- from_y=hmax[ofs+k];
+ if (hmax[ofs + k] > from_y)
+ from_y = hmax[ofs + k];
}
- wrects[j].p.x=ofs;
- wrects[j].p.y=from_y;
-
+ wrects[j].p.x = ofs;
+ wrects[j].p.y = from_y;
+ int end_h = from_y + wrects[j].s.height;
+ int end_w = ofs + wrects[j].s.width;
- int end_h = from_y+wrects[j].s.height;
- int end_w = ofs+wrects[j].s.width;
+ for (int k = 0; k < wrects[j].s.width; k++) {
- for(int k=0;k<wrects[j].s.width;k++) {
-
- hmax[ofs+k]=end_h;
+ hmax[ofs + k] = end_h;
}
if (end_h > max_h)
- max_h=end_h;
+ max_h = end_h;
if (end_w > max_w)
- max_w=end_w;
-
- ofs+=wrects[j].s.width;
+ max_w = end_w;
+ ofs += wrects[j].s.width;
}
_EditorAtlasWorkRectResult result;
- result.result=wrects;
- result.max_h=max_h;
- result.max_w=max_w;
+ result.result = wrects;
+ result.max_h = max_h;
+ result.max_w = max_w;
results.push_back(result);
-
}
//find the result with the best aspect ratio
- int best=-1;
- float best_aspect=1e20;
+ int best = -1;
+ float best_aspect = 1e20;
- for(int i=0;i<results.size();i++) {
+ for (int i = 0; i < results.size(); i++) {
float h = results[i].max_h;
float w = results[i].max_w;
- float aspect = h>w ? h/w : w/h;
+ float aspect = h > w ? h / w : w / h;
if (aspect < best_aspect) {
- best=i;
- best_aspect=aspect;
+ best = i;
+ best_aspect = aspect;
}
}
r_result.resize(p_rects.size());
- for(int i=0;i<p_rects.size();i++) {
+ for (int i = 0; i < p_rects.size(); i++) {
- r_result[ results[best].result[i].idx ]=results[best].result[i].p;
+ r_result[results[best].result[i].idx] = results[best].result[i].p;
}
- r_size=Size2(results[best].max_w,results[best].max_h );
-
+ r_size = Size2(results[best].max_w, results[best].max_h);
}
-
-
diff --git a/editor/io_plugins/editor_atlas.h b/editor/io_plugins/editor_atlas.h
index e0cf76576e..1fb8a8ed4e 100644
--- a/editor/io_plugins/editor_atlas.h
+++ b/editor/io_plugins/editor_atlas.h
@@ -34,10 +34,7 @@
class EditorAtlas {
public:
-
- static void fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, Size2i& r_size);
-
-
+ static void fit(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size);
};
#endif // EDITOR_ATLAS_H
diff --git a/editor/io_plugins/editor_bitmask_import_plugin.cpp b/editor/io_plugins/editor_bitmask_import_plugin.cpp
index 7282cbe4e7..bccf6c262f 100644
--- a/editor/io_plugins/editor_bitmask_import_plugin.cpp
+++ b/editor/io_plugins/editor_bitmask_import_plugin.cpp
@@ -28,15 +28,15 @@
/*************************************************************************/
#include "editor_bitmask_import_plugin.h"
#if 0
-#include "io/image_loader.h"
-#include "editor/editor_file_dialog.h"
#include "editor/editor_dir_dialog.h"
+#include "editor/editor_file_dialog.h"
#include "editor/editor_node.h"
+#include "editor/editor_settings.h"
#include "editor/property_editor.h"
+#include "io/image_loader.h"
+#include "io/marshalls.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
-#include "io/marshalls.h"
-#include "editor/editor_settings.h"
class _EditorBitMaskImportOptions : public Object {
diff --git a/editor/io_plugins/editor_export_scene.cpp b/editor/io_plugins/editor_export_scene.cpp
index a593b870f9..e6066b9075 100644
--- a/editor/io_plugins/editor_export_scene.cpp
+++ b/editor/io_plugins/editor_export_scene.cpp
@@ -28,13 +28,13 @@
/*************************************************************************/
#include "editor_export_scene.h"
#if 0
+#include "editor/editor_settings.h"
+#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/dir_access.h"
#include "os/file_access.h"
-#include "editor/editor_settings.h"
#include "scene/resources/packed_scene.h"
-#include "global_config.h"
Vector<uint8_t> EditorSceneExportPlugin::custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) {
diff --git a/editor/io_plugins/editor_font_import_plugin.cpp b/editor/io_plugins/editor_font_import_plugin.cpp
index c792ad717a..bad3b36383 100644
--- a/editor/io_plugins/editor_font_import_plugin.cpp
+++ b/editor/io_plugins/editor_font_import_plugin.cpp
@@ -28,13 +28,13 @@
/*************************************************************************/
#include "editor_font_import_plugin.h"
#if 0
-#include "scene/gui/dialogs.h"
#include "editor/editor_file_dialog.h"
#include "editor/editor_node.h"
-#include "os/file_access.h"
#include "editor_atlas.h"
#include "io/image_loader.h"
#include "io/resource_saver.h"
+#include "os/file_access.h"
+#include "scene/gui/dialogs.h"
#ifdef FREETYPE_ENABLED
#include <ft2build.h>
@@ -1406,7 +1406,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe
for(int si=0;si<2;si++) {
-#define S_VAR(m_v) (String(si==0?"shadow/":"shadow2/")+m_v)
+#define S_VAR(m_v) (String(si == 0 ? "shadow/" : "shadow2/") + m_v)
if (from->get_option(S_VAR("enabled")).operator bool()) {
int r = from->get_option(S_VAR("radius"));
diff --git a/editor/io_plugins/editor_mesh_import_plugin.cpp b/editor/io_plugins/editor_mesh_import_plugin.cpp
index df9d0a62e6..f4d0868d16 100644
--- a/editor/io_plugins/editor_mesh_import_plugin.cpp
+++ b/editor/io_plugins/editor_mesh_import_plugin.cpp
@@ -30,14 +30,14 @@
#if 0
-#include "editor/editor_file_dialog.h"
#include "editor/editor_dir_dialog.h"
+#include "editor/editor_file_dialog.h"
#include "editor/editor_node.h"
#include "editor/property_editor.h"
//#include "scene/resources/sample.h"
+#include "io/marshalls.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
-#include "io/marshalls.h"
#include "scene/resources/surface_tool.h"
class _EditorMeshImportOptions : public Object {
diff --git a/editor/io_plugins/editor_sample_import_plugin.cpp b/editor/io_plugins/editor_sample_import_plugin.cpp
index d446d39027..a21d41d8c8 100644
--- a/editor/io_plugins/editor_sample_import_plugin.cpp
+++ b/editor/io_plugins/editor_sample_import_plugin.cpp
@@ -28,14 +28,14 @@
/*************************************************************************/
#include "editor_sample_import_plugin.h"
-#include "editor/editor_file_dialog.h"
#include "editor/editor_dir_dialog.h"
+#include "editor/editor_file_dialog.h"
#include "editor/editor_node.h"
+#include "editor/editor_settings.h"
#include "editor/property_editor.h"
+#include "io/marshalls.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
-#include "io/marshalls.h"
-#include "editor/editor_settings.h"
#if 0
diff --git a/editor/io_plugins/editor_scene_import_plugin.cpp b/editor/io_plugins/editor_scene_import_plugin.cpp
index 963968ce47..52a554f6d1 100644
--- a/editor/io_plugins/editor_scene_import_plugin.cpp
+++ b/editor/io_plugins/editor_scene_import_plugin.cpp
@@ -28,27 +28,27 @@
/*************************************************************************/
#include "editor_scene_import_plugin.h"
#if 0
-#include "global_config.h"
+#include "editor/create_dialog.h"
#include "editor/editor_node.h"
-#include "scene/resources/packed_scene.h"
-#include "scene/resources/box_shape.h"
-#include "os/file_access.h"
-#include "scene/3d/path.h"
-#include "scene/animation/animation_player.h"
+#include "global_config.h"
#include "io/resource_saver.h"
+#include "os/file_access.h"
+#include "os/os.h"
+#include "scene/3d/body_shape.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/navigation.h"
-#include "scene/3d/room_instance.h"
-#include "scene/3d/body_shape.h"
+#include "scene/3d/path.h"
#include "scene/3d/physics_body.h"
#include "scene/3d/portal.h"
+#include "scene/3d/room_instance.h"
#include "scene/3d/vehicle_body.h"
+#include "scene/animation/animation_player.h"
+#include "scene/resources/box_shape.h"
+#include "scene/resources/packed_scene.h"
#include "scene/resources/sphere_shape.h"
#include <scene/resources/box_shape.h>
-#include <scene/resources/ray_shape.h>
#include <scene/resources/plane_shape.h>
-#include "editor/create_dialog.h"
-#include "os/os.h"
+#include <scene/resources/ray_shape.h>
@@ -2086,9 +2086,6 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
return p_node;
}
-
-
-
#if 0
Error EditorImport::import_scene(const String& p_path,const String& p_dest_path,const String& p_resource_path,uint32_t p_flags,ImageFormat p_image_format,ImageCompression p_image_compression,uint32_t p_image_flags,float p_quality,uint32_t animation_flags,Node **r_scene,Ref<EditorPostImport> p_post_import) {
diff --git a/editor/io_plugins/editor_scene_import_plugin.h b/editor/io_plugins/editor_scene_import_plugin.h
index 2ae0693600..e365a003a3 100644
--- a/editor/io_plugins/editor_scene_import_plugin.h
+++ b/editor/io_plugins/editor_scene_import_plugin.h
@@ -29,21 +29,21 @@
#ifndef EDITOR_SCENE_IMPORT_PLUGIN_H
#define EDITOR_SCENE_IMPORT_PLUGIN_H
#if 0
+#include "editor/editor_dir_dialog.h"
+#include "editor/editor_file_system.h"
+#include "editor/editor_import_export.h"
+#include "editor/io_plugins/editor_texture_import_plugin.h"
#include "scene/gui/dialogs.h"
-#include "scene/gui/tree.h"
+#include "scene/gui/file_dialog.h"
#include "scene/gui/label.h"
-#include "scene/gui/option_button.h"
#include "scene/gui/line_edit.h"
-#include "scene/gui/file_dialog.h"
+#include "scene/gui/option_button.h"
#include "scene/gui/progress_bar.h"
#include "scene/gui/slider.h"
#include "scene/gui/spin_box.h"
-#include "scene/resources/mesh.h"
-#include "editor/editor_file_system.h"
-#include "editor/editor_dir_dialog.h"
-#include "editor/editor_import_export.h"
-#include "editor/io_plugins/editor_texture_import_plugin.h"
+#include "scene/gui/tree.h"
#include "scene/resources/animation.h"
+#include "scene/resources/mesh.h"
class EditorNode;
diff --git a/editor/io_plugins/editor_scene_importer_fbxconv.cpp b/editor/io_plugins/editor_scene_importer_fbxconv.cpp
index d75a26a948..a2fe4a649b 100644
--- a/editor/io_plugins/editor_scene_importer_fbxconv.cpp
+++ b/editor/io_plugins/editor_scene_importer_fbxconv.cpp
@@ -28,9 +28,9 @@
/*************************************************************************/
#include "editor_scene_importer_fbxconv.h"
+#include "editor/editor_settings.h"
#include "os/file_access.h"
#include "os/os.h"
-#include "editor/editor_settings.h"
#include "scene/3d/mesh_instance.h"
#include "scene/animation/animation_player.h"
diff --git a/editor/io_plugins/editor_texture_import_plugin.cpp b/editor/io_plugins/editor_texture_import_plugin.cpp
index 8bafe80673..32742483bc 100644
--- a/editor/io_plugins/editor_texture_import_plugin.cpp
+++ b/editor/io_plugins/editor_texture_import_plugin.cpp
@@ -28,16 +28,16 @@
/*************************************************************************/
#include "editor_texture_import_plugin.h"
#if 0
-#include "io/image_loader.h"
#include "editor/editor_node.h"
-#include "io/resource_saver.h"
-#include "editor_atlas.h"
#include "editor/editor_settings.h"
-#include "io/md5.h"
-#include "io/marshalls.h"
+#include "editor_atlas.h"
#include "global_config.h"
-#include "scene/gui/check_button.h"
+#include "io/image_loader.h"
+#include "io/marshalls.h"
+#include "io/md5.h"
+#include "io/resource_saver.h"
#include "scene/gui/button_group.h"
+#include "scene/gui/check_button.h"
#include "scene/gui/margin_container.h"
#include "scene/io/resource_format_image.h"
diff --git a/editor/io_plugins/editor_texture_import_plugin.h b/editor/io_plugins/editor_texture_import_plugin.h
index f63bc57ecd..5d0d21f116 100644
--- a/editor/io_plugins/editor_texture_import_plugin.h
+++ b/editor/io_plugins/editor_texture_import_plugin.h
@@ -29,24 +29,19 @@
#ifndef EDITOR_TEXTURE_IMPORT_PLUGIN_H
#define EDITOR_TEXTURE_IMPORT_PLUGIN_H
-
-
-
-
-
#if 0
+#include "editor/editor_dir_dialog.h"
+#include "editor/editor_file_system.h"
#include "editor/editor_import_export.h"
#include "scene/gui/dialogs.h"
-#include "scene/gui/tree.h"
+#include "scene/gui/file_dialog.h"
#include "scene/gui/label.h"
-#include "scene/gui/option_button.h"
#include "scene/gui/line_edit.h"
-#include "scene/gui/file_dialog.h"
+#include "scene/gui/option_button.h"
#include "scene/gui/progress_bar.h"
#include "scene/gui/slider.h"
#include "scene/gui/spin_box.h"
-#include "editor/editor_file_system.h"
-#include "editor/editor_dir_dialog.h"
+#include "scene/gui/tree.h"
diff --git a/editor/io_plugins/editor_translation_import_plugin.cpp b/editor/io_plugins/editor_translation_import_plugin.cpp
index 0fd298d6d3..9aa9f043b3 100644
--- a/editor/io_plugins/editor_translation_import_plugin.cpp
+++ b/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -29,16 +29,16 @@
#include "editor_translation_import_plugin.h"
#if 0
-#include "scene/gui/file_dialog.h"
#include "editor/editor_dir_dialog.h"
#include "editor/editor_node.h"
#include "editor/property_editor.h"
+#include "scene/gui/file_dialog.h"
//#include "scene/resources/sample.h"
+#include "compressed_translation.h"
+#include "editor/project_settings.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
#include "translation.h"
-#include "compressed_translation.h"
-#include "editor/project_settings.h"
class EditorTranslationImportDialog : public ConfirmationDialog {
diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp
index 0428d7ef30..e0e6838402 100644
--- a/editor/multi_node_edit.cpp
+++ b/editor/multi_node_edit.cpp
@@ -28,15 +28,15 @@
/*************************************************************************/
#include "multi_node_edit.h"
-#include "editor_node.h"
#include "core/helper/math_fieldwise.h"
+#include "editor_node.h"
-bool MultiNodeEdit::_set(const StringName& p_name, const Variant& p_value){
+bool MultiNodeEdit::_set(const StringName &p_name, const Variant &p_value) {
return _set_impl(p_name, p_value, "");
}
-bool MultiNodeEdit::_set_impl(const StringName& p_name, const Variant& p_value, const String& p_field) {
+bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, const String &p_field) {
Node *es = EditorNode::get_singleton()->get_edited_scene();
if (!es)
@@ -44,112 +44,109 @@ bool MultiNodeEdit::_set_impl(const StringName& p_name, const Variant& p_value,
String name = p_name;
- if (name=="scripts") { // script set is intercepted at object level (check Variant Object::get() ) ,so use a different name
- name="script";
+ if (name == "scripts") { // script set is intercepted at object level (check Variant Object::get() ) ,so use a different name
+ name = "script";
}
- UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- ur->create_action(TTR("MultiNode Set")+" "+String(name));
- for (const List<NodePath>::Element *E=nodes.front();E;E=E->next()) {
+ ur->create_action(TTR("MultiNode Set") + " " + String(name));
+ for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) {
if (!es->has_node(E->get()))
continue;
- Node*n=es->get_node(E->get());
+ Node *n = es->get_node(E->get());
if (!n)
continue;
if (p_value.get_type() == Variant::NODE_PATH) {
Node *tonode = n->get_node(p_value);
NodePath p_path = n->get_path_to(tonode);
- ur->add_do_property(n,name,p_path);
+ ur->add_do_property(n, name, p_path);
} else {
Variant new_value;
- if (p_field=="") {
+ if (p_field == "") {
// whole value
- new_value=p_value;
+ new_value = p_value;
} else {
// only one field
- new_value=fieldwise_assign(n->get(name),p_value,p_field);
+ new_value = fieldwise_assign(n->get(name), p_value, p_field);
}
- ur->add_do_property(n,name,new_value);
+ ur->add_do_property(n, name, new_value);
}
- ur->add_undo_property(n,name,n->get(name));
-
-
+ ur->add_undo_property(n, name, n->get(name));
}
- ur->add_do_method(EditorNode::get_singleton()->get_property_editor(),"refresh");
- ur->add_undo_method(EditorNode::get_singleton()->get_property_editor(),"refresh");
+ ur->add_do_method(EditorNode::get_singleton()->get_property_editor(), "refresh");
+ ur->add_undo_method(EditorNode::get_singleton()->get_property_editor(), "refresh");
ur->commit_action();
return true;
}
-bool MultiNodeEdit::_get(const StringName& p_name,Variant &r_ret) const {
+bool MultiNodeEdit::_get(const StringName &p_name, Variant &r_ret) const {
Node *es = EditorNode::get_singleton()->get_edited_scene();
if (!es)
return false;
- String name=p_name;
- if (name=="scripts") { // script set is intercepted at object level (check Variant Object::get() ) ,so use a different name
- name="script";
+ String name = p_name;
+ if (name == "scripts") { // script set is intercepted at object level (check Variant Object::get() ) ,so use a different name
+ name = "script";
}
- for (const List<NodePath>::Element *E=nodes.front();E;E=E->next()) {
+ for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) {
if (!es->has_node(E->get()))
continue;
- const Node*n=es->get_node(E->get());
+ const Node *n = es->get_node(E->get());
if (!n)
continue;
bool found;
- r_ret=n->get(name,&found);
+ r_ret = n->get(name, &found);
if (found)
return true;
-
}
return false;
}
-void MultiNodeEdit::_get_property_list( List<PropertyInfo> *p_list) const{
+void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const {
- HashMap<String,PLData> usage;
+ HashMap<String, PLData> usage;
Node *es = EditorNode::get_singleton()->get_edited_scene();
if (!es)
return;
- int nc=0;
+ int nc = 0;
- List<PLData*> datas;
+ List<PLData *> datas;
- for (const List<NodePath>::Element *E=nodes.front();E;E=E->next()) {
+ for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) {
if (!es->has_node(E->get()))
continue;
- Node*n=es->get_node(E->get());
+ Node *n = es->get_node(E->get());
if (!n)
continue;
List<PropertyInfo> plist;
- n->get_property_list(&plist,true);
+ n->get_property_list(&plist, true);
- for(List<PropertyInfo>::Element *F=plist.front();F;F=F->next()) {
+ for (List<PropertyInfo>::Element *F = plist.front(); F; F = F->next()) {
- if (F->get().name=="script")
+ if (F->get().name == "script")
continue; //added later manually, since this is intercepted before being set (check Variant Object::get() )
if (!usage.has(F->get().name)) {
PLData pld;
- pld.uses=0;
- pld.info=F->get();
- usage[F->get().name]=pld;
+ pld.uses = 0;
+ pld.info = F->get();
+ usage[F->get().name] = pld;
datas.push_back(usage.getptr(F->get().name));
}
@@ -159,16 +156,14 @@ void MultiNodeEdit::_get_property_list( List<PropertyInfo> *p_list) const{
nc++;
}
- for (List<PLData*>::Element *E=datas.front();E;E=E->next()) {
+ for (List<PLData *>::Element *E = datas.front(); E; E = E->next()) {
- if (nc==E->get()->uses) {
+ if (nc == E->get()->uses) {
p_list->push_back(E->get()->info);
}
}
- p_list->push_back(PropertyInfo(Variant::OBJECT,"scripts",PROPERTY_HINT_RESOURCE_TYPE,"Script"));
-
-
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "scripts", PROPERTY_HINT_RESOURCE_TYPE, "Script"));
}
void MultiNodeEdit::clear_nodes() {
@@ -176,16 +171,15 @@ void MultiNodeEdit::clear_nodes() {
nodes.clear();
}
-void MultiNodeEdit::add_node(const NodePath& p_node){
+void MultiNodeEdit::add_node(const NodePath &p_node) {
nodes.push_back(p_node);
}
-void MultiNodeEdit::set_property_field(const StringName& p_property, const Variant& p_value, const String& p_field) {
+void MultiNodeEdit::set_property_field(const StringName &p_property, const Variant &p_value, const String &p_field) {
_set_impl(p_property, p_value, p_field);
}
-MultiNodeEdit::MultiNodeEdit()
-{
+MultiNodeEdit::MultiNodeEdit() {
}
diff --git a/editor/multi_node_edit.h b/editor/multi_node_edit.h
index 26e557c1cb..2307968794 100644
--- a/editor/multi_node_edit.h
+++ b/editor/multi_node_edit.h
@@ -33,7 +33,7 @@
class MultiNodeEdit : public Reference {
- GDCLASS(MultiNodeEdit,Reference);
+ GDCLASS(MultiNodeEdit, Reference);
List<NodePath> nodes;
struct PLData {
@@ -41,23 +41,18 @@ class MultiNodeEdit : public Reference {
PropertyInfo info;
};
- bool _set_impl(const StringName& p_name, const Variant& p_value, const String& p_field);
-
+ bool _set_impl(const StringName &p_name, const Variant &p_value, const String &p_field);
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;
public:
-
-
-
void clear_nodes();
- void add_node(const NodePath& p_node);
+ void add_node(const NodePath &p_node);
- void set_property_field(const StringName& p_property, const Variant& p_value, const String& p_field);
+ void set_property_field(const StringName &p_property, const Variant &p_value, const String &p_field);
MultiNodeEdit();
};
diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp
index fed3d2efb4..d76a427e1f 100644
--- a/editor/node_dock.cpp
+++ b/editor/node_dock.cpp
@@ -38,7 +38,7 @@ void NodeDock::show_groups() {
connections->hide();
}
-void NodeDock::show_connections(){
+void NodeDock::show_connections() {
groups_button->set_pressed(false);
connections_button->set_pressed(true);
@@ -46,24 +46,23 @@ void NodeDock::show_connections(){
connections->show();
}
-
void NodeDock::_bind_methods() {
- ClassDB::bind_method(D_METHOD("show_groups"),&NodeDock::show_groups);
- ClassDB::bind_method(D_METHOD("show_connections"),&NodeDock::show_connections);
+ ClassDB::bind_method(D_METHOD("show_groups"), &NodeDock::show_groups);
+ ClassDB::bind_method(D_METHOD("show_connections"), &NodeDock::show_connections);
}
void NodeDock::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
- connections_button->set_icon(get_icon("Connect","EditorIcons"));
- groups_button->set_icon(get_icon("Groups","EditorIcons"));
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ connections_button->set_icon(get_icon("Connect", "EditorIcons"));
+ groups_button->set_icon(get_icon("Groups", "EditorIcons"));
}
}
-NodeDock *NodeDock::singleton=NULL;
+NodeDock *NodeDock::singleton = NULL;
-void NodeDock::set_node(Node* p_node) {
+void NodeDock::set_node(Node *p_node) {
connections->set_node(p_node);
groups->set_current(p_node);
@@ -84,50 +83,47 @@ void NodeDock::set_node(Node* p_node) {
}
}
-NodeDock::NodeDock()
-{
- singleton=this;
+NodeDock::NodeDock() {
+ singleton = this;
set_name(TTR("Node"));
- mode_hb = memnew( HBoxContainer );
+ mode_hb = memnew(HBoxContainer);
add_child(mode_hb);
mode_hb->hide();
-
- connections_button = memnew( ToolButton );
+ connections_button = memnew(ToolButton);
connections_button->set_text(TTR("Signals"));
connections_button->set_toggle_mode(true);
connections_button->set_pressed(true);
connections_button->set_h_size_flags(SIZE_EXPAND_FILL);
mode_hb->add_child(connections_button);
- connections_button->connect("pressed",this,"show_connections");
+ connections_button->connect("pressed", this, "show_connections");
- groups_button = memnew( ToolButton );
+ groups_button = memnew(ToolButton);
groups_button->set_text(TTR("Groups"));
groups_button->set_toggle_mode(true);
groups_button->set_pressed(false);
groups_button->set_h_size_flags(SIZE_EXPAND_FILL);
mode_hb->add_child(groups_button);
- groups_button->connect("pressed",this,"show_groups");
+ groups_button->connect("pressed", this, "show_groups");
- connections = memnew( ConnectionsDock(EditorNode::get_singleton()) );
+ connections = memnew(ConnectionsDock(EditorNode::get_singleton()));
connections->set_undoredo(EditorNode::get_singleton()->get_undo_redo());
add_child(connections);
connections->set_v_size_flags(SIZE_EXPAND_FILL);
connections->hide();
- groups = memnew( GroupsEditor );
+ groups = memnew(GroupsEditor);
groups->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
add_child(groups);
groups->set_v_size_flags(SIZE_EXPAND_FILL);
groups->hide();
- select_a_node = memnew( Label );
+ select_a_node = memnew(Label);
select_a_node->set_text(TTR("Select a Node to edit Signals and Groups."));
select_a_node->set_v_size_flags(SIZE_EXPAND_FILL);
select_a_node->set_valign(Label::VALIGN_CENTER);
select_a_node->set_align(Label::ALIGN_CENTER);
select_a_node->set_autowrap(true);
add_child(select_a_node);
-
}
diff --git a/editor/node_dock.h b/editor/node_dock.h
index df41ecf5bd..b7d91899d8 100644
--- a/editor/node_dock.h
+++ b/editor/node_dock.h
@@ -34,7 +34,7 @@
class NodeDock : public VBoxContainer {
- GDCLASS(NodeDock,VBoxContainer);
+ GDCLASS(NodeDock, VBoxContainer);
ToolButton *connections_button;
ToolButton *groups_button;
@@ -44,18 +44,16 @@ class NodeDock : public VBoxContainer {
HBoxContainer *mode_hb;
- Label* select_a_node;
+ Label *select_a_node;
protected:
-
static void _bind_methods();
void _notification(int p_what);
public:
-
static NodeDock *singleton;
- void set_node(Node* p_node);
+ void set_node(Node *p_node);
void show_groups();
void show_connections();
diff --git a/editor/output_strings.cpp b/editor/output_strings.cpp
index cb43bb9230..0894a92731 100644
--- a/editor/output_strings.cpp
+++ b/editor/output_strings.cpp
@@ -28,80 +28,76 @@
/*************************************************************************/
#include "output_strings.h"
-
-
void OutputStrings::update_scrollbars() {
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
- v_scroll->set_anchor( MARGIN_LEFT, ANCHOR_END );
- v_scroll->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- v_scroll->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
+ v_scroll->set_anchor(MARGIN_LEFT, ANCHOR_END);
+ v_scroll->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ v_scroll->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
- v_scroll->set_begin( Point2(vmin.width, 0) );
- v_scroll->set_end( Point2(0,0 ) );
+ v_scroll->set_begin(Point2(vmin.width, 0));
+ v_scroll->set_end(Point2(0, 0));
- h_scroll->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- h_scroll->set_anchor( MARGIN_TOP, ANCHOR_END );
- h_scroll->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
+ h_scroll->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ h_scroll->set_anchor(MARGIN_TOP, ANCHOR_END);
+ h_scroll->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
- h_scroll->set_begin( Point2( 0, hmin.y) );
- h_scroll->set_end( Point2(vmin.x, 0) );
+ h_scroll->set_begin(Point2(0, hmin.y));
+ h_scroll->set_end(Point2(vmin.x, 0));
- margin.y=hmin.y;
- margin.x=vmin.x;
+ margin.y = hmin.y;
+ margin.x = vmin.x;
- Ref<StyleBox> tree_st = get_stylebox("bg","Tree");
- int page = ((size_height-(int)margin.y-tree_st->get_margin(MARGIN_TOP)) / font_height);
+ Ref<StyleBox> tree_st = get_stylebox("bg", "Tree");
+ int page = ((size_height - (int)margin.y - tree_st->get_margin(MARGIN_TOP)) / font_height);
v_scroll->set_page(page);
-
}
void OutputStrings::_notification(int p_what) {
- switch(p_what) {
-
+ switch (p_what) {
case NOTIFICATION_DRAW: {
if (following) {
- updating=true;
- v_scroll->set_value( v_scroll->get_max() - v_scroll->get_page() );
- updating=false;
+ updating = true;
+ v_scroll->set_value(v_scroll->get_max() - v_scroll->get_page());
+ updating = false;
}
RID ci = get_canvas_item();
Size2 size = get_size();
- Ref<Font> font = get_font("font","Tree");
- Ref<StyleBox> tree_st = get_stylebox("bg","Tree");
- tree_st->draw(ci,Rect2(Point2(),size));
- Color color = get_color("font_color","Tree");
- Ref<Texture> icon_error = get_icon("Error","EditorIcons");
- Ref<Texture> icon_warning = get_icon("Warning","EditorIcons");
+ Ref<Font> font = get_font("font", "Tree");
+ Ref<StyleBox> tree_st = get_stylebox("bg", "Tree");
+ tree_st->draw(ci, Rect2(Point2(), size));
+ Color color = get_color("font_color", "Tree");
+ Ref<Texture> icon_error = get_icon("Error", "EditorIcons");
+ Ref<Texture> icon_warning = get_icon("Warning", "EditorIcons");
//int lines = (size_height-(int)margin.y) / font_height;
- Point2 ofs=tree_st->get_offset();
+ Point2 ofs = tree_st->get_offset();
LineMap::Element *E = line_map.find(v_scroll->get_value());
float h_ofs = (int)h_scroll->get_value();
- Point2 icon_ofs=Point2(0,(font_height-(int)icon_error->get_height())/2);
+ Point2 icon_ofs = Point2(0, (font_height - (int)icon_error->get_height()) / 2);
- while( E && ofs.y < (size_height-(int)margin.y) ) {
+ while (E && ofs.y < (size_height - (int)margin.y)) {
String str = E->get().text;
- Point2 line_ofs=ofs;
+ Point2 line_ofs = ofs;
- switch(E->get().type) {
+ switch (E->get().type) {
case LINE_WARNING: {
- icon_warning->draw(ci,line_ofs+icon_ofs);
+ icon_warning->draw(ci, line_ofs + icon_ofs);
} break;
case LINE_ERROR: {
- icon_error->draw(ci,line_ofs+icon_ofs);
+ icon_error->draw(ci, line_ofs + icon_ofs);
} break;
case LINE_LINK: {
@@ -109,21 +105,21 @@ void OutputStrings::_notification(int p_what) {
default: {}
}
- line_ofs.y+=font->get_ascent();
- line_ofs.x+=icon_error->get_width()+4;
+ line_ofs.y += font->get_ascent();
+ line_ofs.x += icon_error->get_width() + 4;
- for(int i=0;i<str.length();i++) {
- if (line_ofs.x-h_ofs < 0 ) {
- line_ofs.x+=font->get_char_size(str[i],str[i+1]).width;
- } else if (line_ofs.x-h_ofs > size.width - margin.width) {
+ for (int i = 0; i < str.length(); i++) {
+ if (line_ofs.x - h_ofs < 0) {
+ line_ofs.x += font->get_char_size(str[i], str[i + 1]).width;
+ } else if (line_ofs.x - h_ofs > size.width - margin.width) {
break;
} else {
- line_ofs.x+=font->draw_char(ci,Point2(line_ofs.x-h_ofs,line_ofs.y),str[i],str[i+1],color);
+ line_ofs.x += font->draw_char(ci, Point2(line_ofs.x - h_ofs, line_ofs.y), str[i], str[i + 1], color);
}
}
- ofs.y+=font_height;
- E=E->next();
+ ofs.y += font_height;
+ E = E->next();
}
} break;
@@ -131,13 +127,11 @@ void OutputStrings::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_RESIZED: {
-
- font_height = get_font("font","Tree")->get_height();
+ font_height = get_font("font", "Tree")->get_height();
size_height = get_size().height;
update_scrollbars();
} break;
}
-
}
void OutputStrings::_hscroll_changed(float p_value) {
@@ -152,33 +146,31 @@ void OutputStrings::_vscroll_changed(float p_value) {
if (updating)
return;
//user changed scroll
- following=(p_value+v_scroll->get_page())>=v_scroll->get_max();
+ following = (p_value + v_scroll->get_page()) >= v_scroll->get_max();
update();
}
-void OutputStrings::add_line(const String& p_text, const Variant& p_meta, const LineType p_type) {
+void OutputStrings::add_line(const String &p_text, const Variant &p_meta, const LineType p_type) {
+ Vector<String> strings = p_text.split("\n");
- Vector<String> strings=p_text.split("\n");
+ for (int i = 0; i < strings.size(); i++) {
- for(int i=0;i<strings.size();i++) {
-
- if (strings[i].length()==0)
+ if (strings[i].length() == 0)
continue;
int last = line_map.empty() ? 0 : (line_map.back()->key() + 1);
Line l;
- l.text=strings[i];
- l.meta=p_meta;
- l.type=p_type;
- line_map.insert(last,l);
+ l.text = strings[i];
+ l.meta = p_meta;
+ l.type = p_type;
+ line_map.insert(last, l);
- updating=true;
- v_scroll->set_max(last+1);
+ updating = true;
+ v_scroll->set_max(last + 1);
v_scroll->set_min(line_map.front()->key());
- updating=false;
-
+ updating = false;
}
while (line_map.size() > line_max_count) {
@@ -186,30 +178,27 @@ void OutputStrings::add_line(const String& p_text, const Variant& p_meta, const
line_map.erase(line_map.front());
}
-
update();
-
}
-
void OutputStrings::_bind_methods() {
- ClassDB::bind_method("_vscroll_changed",&OutputStrings::_vscroll_changed);
- ClassDB::bind_method("_hscroll_changed",&OutputStrings::_hscroll_changed);
+ ClassDB::bind_method("_vscroll_changed", &OutputStrings::_vscroll_changed);
+ ClassDB::bind_method("_hscroll_changed", &OutputStrings::_hscroll_changed);
}
OutputStrings::OutputStrings() {
- following=true;
- updating=false;
- line_max_count=4096;
- h_scroll = memnew( HScrollBar );
- v_scroll = memnew( VScrollBar );
+ following = true;
+ updating = false;
+ line_max_count = 4096;
+ h_scroll = memnew(HScrollBar);
+ v_scroll = memnew(VScrollBar);
add_child(h_scroll);
add_child(v_scroll);
- size_height=1;
- font_height=1;
+ size_height = 1;
+ font_height = 1;
update_scrollbars();
- h_scroll->connect("value_changed", this,"_hscroll_changed");
- v_scroll->connect("value_changed", this,"_vscroll_changed");
+ h_scroll->connect("value_changed", this, "_hscroll_changed");
+ v_scroll->connect("value_changed", this, "_vscroll_changed");
}
diff --git a/editor/output_strings.h b/editor/output_strings.h
index cc721ef652..392b1d4dc8 100644
--- a/editor/output_strings.h
+++ b/editor/output_strings.h
@@ -29,16 +29,15 @@
#ifndef OUTPUT_STRINGS_H
#define OUTPUT_STRINGS_H
-
+#include "map.h"
#include "scene/gui/control.h"
#include "scene/gui/scroll_bar.h"
-#include "map.h"
class OutputStrings : public Control {
- GDCLASS( OutputStrings, Control );
-public:
+ GDCLASS(OutputStrings, Control);
+public:
enum LineType {
LINE_NORMAL,
@@ -46,23 +45,21 @@ public:
LINE_ERROR,
LINE_LINK
};
-private:
+private:
struct Line {
-
LineType type;
Variant meta;
String text;
};
-
int font_height;
int size_height;
Size2 margin;
- typedef Map<int,Line> LineMap;
- Map<int,Line> line_map;
+ typedef Map<int, Line> LineMap;
+ Map<int, Line> line_map;
VScrollBar *v_scroll;
HScrollBar *h_scroll;
@@ -74,14 +71,13 @@ private:
void _vscroll_changed(float p_value);
void _hscroll_changed(float p_value);
void update_scrollbars();
-protected:
+protected:
static void _bind_methods();
void _notification(int p_what);
public:
-
- void add_line(const String& p_text, const Variant& p_meta=Variant(), const LineType p_type=LINE_NORMAL);
+ void add_line(const String &p_text, const Variant &p_meta = Variant(), const LineType p_type = LINE_NORMAL);
OutputStrings();
};
diff --git a/editor/pane_drag.cpp b/editor/pane_drag.cpp
index 122abd37b9..253b217049 100644
--- a/editor/pane_drag.cpp
+++ b/editor/pane_drag.cpp
@@ -28,48 +28,50 @@
/*************************************************************************/
#include "pane_drag.h"
+void PaneDrag::_gui_input(const InputEvent &p_input) {
-void PaneDrag::_gui_input(const InputEvent& p_input) {
+ if (p_input.type == InputEvent::MOUSE_MOTION && p_input.mouse_motion.button_mask & BUTTON_MASK_LEFT) {
- if (p_input.type==InputEvent::MOUSE_MOTION && p_input.mouse_motion.button_mask&BUTTON_MASK_LEFT) {
-
- emit_signal("dragged",Point2(p_input.mouse_motion.relative_x,p_input.mouse_motion.relative_y));
+ emit_signal("dragged", Point2(p_input.mouse_motion.relative_x, p_input.mouse_motion.relative_y));
}
}
void PaneDrag::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
- Ref<Texture> icon = mouse_over?get_icon("PaneDragHover","EditorIcons"):get_icon("PaneDrag","EditorIcons");
+ Ref<Texture> icon = mouse_over ? get_icon("PaneDragHover", "EditorIcons") : get_icon("PaneDrag", "EditorIcons");
if (!icon.is_null())
- icon->draw(get_canvas_item(),Point2(0,0));
+ icon->draw(get_canvas_item(), Point2(0, 0));
} break;
- case NOTIFICATION_MOUSE_ENTER: mouse_over=true; update(); break;
- case NOTIFICATION_MOUSE_EXIT: mouse_over=false; update(); break;
+ case NOTIFICATION_MOUSE_ENTER:
+ mouse_over = true;
+ update();
+ break;
+ case NOTIFICATION_MOUSE_EXIT:
+ mouse_over = false;
+ update();
+ break;
}
-
}
Size2 PaneDrag::get_minimum_size() const {
- Ref<Texture> icon=get_icon("PaneDrag","EditorIcons");
+ Ref<Texture> icon = get_icon("PaneDrag", "EditorIcons");
if (!icon.is_null())
return icon->get_size();
return Size2();
-
}
void PaneDrag::_bind_methods() {
- ClassDB::bind_method("_gui_input",&PaneDrag::_gui_input);
- ADD_SIGNAL(MethodInfo("dragged",PropertyInfo(Variant::VECTOR2,"amount")));
+ ClassDB::bind_method("_gui_input", &PaneDrag::_gui_input);
+ ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::VECTOR2, "amount")));
}
PaneDrag::PaneDrag() {
- mouse_over=false;
-
+ mouse_over = false;
}
diff --git a/editor/pane_drag.h b/editor/pane_drag.h
index 8796fc2594..30ca6c20a2 100644
--- a/editor/pane_drag.h
+++ b/editor/pane_drag.h
@@ -33,17 +33,16 @@
class PaneDrag : public Control {
- GDCLASS( PaneDrag, Control );
+ GDCLASS(PaneDrag, Control);
bool mouse_over;
-
protected:
-
- void _gui_input(const InputEvent& p_input);
+ void _gui_input(const InputEvent &p_input);
void _notification(int p_what);
virtual Size2 get_minimum_size() const;
static void _bind_methods();
+
public:
PaneDrag();
};
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 2e6792bbaa..90d2847103 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -28,17 +28,17 @@
/*************************************************************************/
#include "animation_player_editor_plugin.h"
+#include "editor/animation_editor.h"
+#include "editor/editor_settings.h"
#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/keyboard.h"
-#include "editor/editor_settings.h"
-#include "editor/animation_editor.h"
void AnimationPlayerEditor::_node_removed(Node *p_node) {
if (player && player == p_node) {
- player=NULL;
+ player = NULL;
set_process(false);
@@ -47,18 +47,15 @@ void AnimationPlayerEditor::_node_removed(Node *p_node) {
key_editor->show_select_node_warning(true);
_update_player();
//editor->animation_editor_make_visible(false);
-
}
}
void AnimationPlayerEditor::_gui_input(InputEvent p_event) {
-
-
}
void AnimationPlayerEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_PROCESS) {
+ if (p_what == NOTIFICATION_PROCESS) {
if (!player)
return;
@@ -68,7 +65,7 @@ void AnimationPlayerEditor::_notification(int p_what) {
if (player->is_playing()) {
{
- String animname=player->get_current_animation();
+ String animname = player->get_current_animation();
if (player->has_animation(animname)) {
Ref<Animation> anim = player->get_animation(animname);
@@ -88,41 +85,41 @@ void AnimationPlayerEditor::_notification(int p_what) {
frame->set_value(player->get_current_animation_pos());
}
- last_active=player->is_playing();
+ last_active = player->is_playing();
//seek->set_val(player->get_pos());
updating = false;
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
//editor->connect("hide_animation_player_editors",this,"_hide_anim_editors");
- add_anim->set_icon( get_icon("New","EditorIcons") );
- rename_anim->set_icon( get_icon("Rename","EditorIcons") );
- duplicate_anim->set_icon( get_icon("Duplicate","EditorIcons") );
- autoplay->set_icon( get_icon("AutoPlay","EditorIcons") );
- load_anim->set_icon( get_icon("Folder","EditorIcons") );
+ add_anim->set_icon(get_icon("New", "EditorIcons"));
+ rename_anim->set_icon(get_icon("Rename", "EditorIcons"));
+ duplicate_anim->set_icon(get_icon("Duplicate", "EditorIcons"));
+ autoplay->set_icon(get_icon("AutoPlay", "EditorIcons"));
+ load_anim->set_icon(get_icon("Folder", "EditorIcons"));
save_anim->set_icon(get_icon("Save", "EditorIcons"));
save_anim->get_popup()->connect("id_pressed", this, "_animation_save_menu");
- remove_anim->set_icon( get_icon("Remove","EditorIcons") );
+ remove_anim->set_icon(get_icon("Remove", "EditorIcons"));
- blend_anim->set_icon( get_icon("Blend","EditorIcons") );
- play->set_icon( get_icon("PlayStart","EditorIcons") );
- play_from->set_icon( get_icon("Play","EditorIcons") );
- play_bw->set_icon( get_icon("PlayStartBackwards","EditorIcons") );
- play_bw_from->set_icon( get_icon("PlayBackwards","EditorIcons") );
+ blend_anim->set_icon(get_icon("Blend", "EditorIcons"));
+ play->set_icon(get_icon("PlayStart", "EditorIcons"));
+ play_from->set_icon(get_icon("Play", "EditorIcons"));
+ play_bw->set_icon(get_icon("PlayStartBackwards", "EditorIcons"));
+ play_bw_from->set_icon(get_icon("PlayBackwards", "EditorIcons"));
- autoplay_icon=get_icon("AutoPlay","EditorIcons");
- stop->set_icon( get_icon("Stop","EditorIcons") );
- resource_edit_anim->set_icon( get_icon("EditResource","EditorIcons") );
- pin->set_icon(get_icon("Pin","EditorIcons") );
- tool_anim->set_icon(get_icon("Tools","EditorIcons"));
- tool_anim->get_popup()->connect("id_pressed",this,"_animation_tool_menu");
+ autoplay_icon = get_icon("AutoPlay", "EditorIcons");
+ stop->set_icon(get_icon("Stop", "EditorIcons"));
+ resource_edit_anim->set_icon(get_icon("EditResource", "EditorIcons"));
+ pin->set_icon(get_icon("Pin", "EditorIcons"));
+ tool_anim->set_icon(get_icon("Tools", "EditorIcons"));
+ tool_anim->get_popup()->connect("id_pressed", this, "_animation_tool_menu");
blend_editor.next->connect("item_selected", this, "_blend_editor_next_changed");
- nodename->set_icon(get_icon("AnimationPlayer","EditorIcons"));
+ nodename->set_icon(get_icon("AnimationPlayer", "EditorIcons"));
-/*
+ /*
anim_editor_load->set_normal_texture( get_icon("AnimGet","EditorIcons"));
anim_editor_store->set_normal_texture( get_icon("AnimSet","EditorIcons"));
anim_editor_load->set_pressed_texture( get_icon("AnimGet","EditorIcons"));
@@ -131,7 +128,7 @@ void AnimationPlayerEditor::_notification(int p_what) {
anim_editor_store->set_hover_texture( get_icon("AnimSetHl","EditorIcons"));
*/
- get_tree()->connect("node_removed",this,"_node_removed");
+ get_tree()->connect("node_removed", this, "_node_removed");
}
}
@@ -139,46 +136,44 @@ void AnimationPlayerEditor::_autoplay_pressed() {
if (updating)
return;
- if (animation->get_item_count()==0) {
+ if (animation->get_item_count() == 0) {
return;
}
- String current = animation->get_item_text( animation->get_selected() );
- if (player->get_autoplay()==current) {
+ String current = animation->get_item_text(animation->get_selected());
+ if (player->get_autoplay() == current) {
//unset
undo_redo->create_action(TTR("Toggle Autoplay"));
- undo_redo->add_do_method(player,"set_autoplay","");
- undo_redo->add_undo_method(player,"set_autoplay",player->get_autoplay());
- undo_redo->add_do_method(this,"_animation_player_changed",player);
- undo_redo->add_undo_method(this,"_animation_player_changed",player);
+ undo_redo->add_do_method(player, "set_autoplay", "");
+ undo_redo->add_undo_method(player, "set_autoplay", player->get_autoplay());
+ undo_redo->add_do_method(this, "_animation_player_changed", player);
+ undo_redo->add_undo_method(this, "_animation_player_changed", player);
undo_redo->commit_action();
-
} else {
//set
undo_redo->create_action(TTR("Toggle Autoplay"));
- undo_redo->add_do_method(player,"set_autoplay",current);
- undo_redo->add_undo_method(player,"set_autoplay",player->get_autoplay());
- undo_redo->add_do_method(this,"_animation_player_changed",player);
- undo_redo->add_undo_method(this,"_animation_player_changed",player);
+ undo_redo->add_do_method(player, "set_autoplay", current);
+ undo_redo->add_undo_method(player, "set_autoplay", player->get_autoplay());
+ undo_redo->add_do_method(this, "_animation_player_changed", player);
+ undo_redo->add_undo_method(this, "_animation_player_changed", player);
undo_redo->commit_action();
}
-
}
void AnimationPlayerEditor::_play_pressed() {
String current;
- if (animation->get_selected()>=0 && animation->get_selected()<animation->get_item_count()) {
+ if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
- current = animation->get_item_text( animation->get_selected() );
+ current = animation->get_item_text(animation->get_selected());
}
- if (current!="") {
+ if (current != "") {
- if (current==player->get_current_animation())
+ if (current == player->get_current_animation())
player->stop(); //so it wont blend with itself
- player->play(current );
+ player->play(current);
}
//unstop
@@ -190,21 +185,21 @@ void AnimationPlayerEditor::_play_pressed() {
void AnimationPlayerEditor::_play_from_pressed() {
String current;
- if (animation->get_selected()>=0 && animation->get_selected()<animation->get_item_count()) {
+ if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
- current = animation->get_item_text( animation->get_selected() );
+ current = animation->get_item_text(animation->get_selected());
}
- if (current!="") {
+ if (current != "") {
float time = player->get_current_animation_pos();
- if (current==player->get_current_animation() && player->is_playing()) {
+ if (current == player->get_current_animation() && player->is_playing()) {
player->stop(); //so it wont blend with itself
}
- player->play( current );
+ player->play(current);
player->seek(time);
}
@@ -214,20 +209,19 @@ void AnimationPlayerEditor::_play_from_pressed() {
//pause->set_pressed(false);
}
-
void AnimationPlayerEditor::_play_bw_pressed() {
String current;
- if (animation->get_selected()>=0 && animation->get_selected()<animation->get_item_count()) {
+ if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
- current = animation->get_item_text( animation->get_selected() );
+ current = animation->get_item_text(animation->get_selected());
}
- if (current!="") {
+ if (current != "") {
- if (current==player->get_current_animation())
+ if (current == player->get_current_animation())
player->stop(); //so it wont blend with itself
- player->play(current,-1,-1,true);
+ player->play(current, -1, -1, true);
}
//unstop
@@ -239,18 +233,18 @@ void AnimationPlayerEditor::_play_bw_pressed() {
void AnimationPlayerEditor::_play_bw_from_pressed() {
String current;
- if (animation->get_selected()>=0 && animation->get_selected()<animation->get_item_count()) {
+ if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
- current = animation->get_item_text( animation->get_selected() );
+ current = animation->get_item_text(animation->get_selected());
}
- if (current!="") {
+ if (current != "") {
float time = player->get_current_animation_pos();
- if (current==player->get_current_animation())
+ if (current == player->get_current_animation())
player->stop(); //so it wont blend with itself
- player->play(current,-1,-1,true);
+ player->play(current, -1, -1, true);
player->seek(time);
}
@@ -279,17 +273,16 @@ void AnimationPlayerEditor::_animation_selected(int p_which) {
// when selecting an animation, the idea is that the only interesting behavior
// ui-wise is that it should play/blend the next one if currently playing
String current;
- if (animation->get_selected()>=0 && animation->get_selected()<animation->get_item_count()) {
+ if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
- current = animation->get_item_text( animation->get_selected() );
+ current = animation->get_item_text(animation->get_selected());
}
- if (current!="") {
-
+ if (current != "") {
- player->set_current_animation( current );
+ player->set_current_animation(current);
- Ref<Animation> anim = player->get_animation(current);
+ Ref<Animation> anim = player->get_animation(current);
{
key_editor->set_animation(anim);
@@ -304,76 +297,69 @@ void AnimationPlayerEditor::_animation_selected(int p_which) {
else
frame->set_step(0.00001);
-
-
} else {
key_editor->set_animation(Ref<Animation>());
key_editor->set_root(NULL);
-
}
-
- autoplay->set_pressed(current==player->get_autoplay());
+ autoplay->set_pressed(current == player->get_autoplay());
}
void AnimationPlayerEditor::_animation_new() {
- renaming=false;
+ renaming = false;
name_title->set_text(TTR("New Animation Name:"));
- int count=1;
- String base=TTR("New Anim");
- while(true) {
- String attempt = base;
- if (count>1)
- attempt+=" ("+itos(count)+")";
+ int count = 1;
+ String base = TTR("New Anim");
+ while (true) {
+ String attempt = base;
+ if (count > 1)
+ attempt += " (" + itos(count) + ")";
if (player->has_animation(attempt)) {
count++;
continue;
}
- base=attempt;
+ base = attempt;
break;
}
name->set_text(base);
- name_dialog->popup_centered(Size2(300,90));
+ name_dialog->popup_centered(Size2(300, 90));
name->select_all();
name->grab_focus();
}
void AnimationPlayerEditor::_animation_rename() {
- if (animation->get_item_count()==0)
+ if (animation->get_item_count() == 0)
return;
int selected = animation->get_selected();
String selected_name = animation->get_item_text(selected);
name_title->set_text(TTR("Change Animation Name:"));
name->set_text(selected_name);
- renaming=true;
- name_dialog->popup_centered(Size2(300,90));
+ renaming = true;
+ name_dialog->popup_centered(Size2(300, 90));
name->select_all();
name->grab_focus();
-
}
void AnimationPlayerEditor::_animation_load() {
ERR_FAIL_COND(!player);
- file->set_mode( EditorFileDialog::MODE_OPEN_FILE );
+ file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
file->clear_filters();
List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("Animation",&extensions);
- for (List<String>::Element *E=extensions.front();E;E=E->next()) {
-
- file->add_filter("*."+E->get()+" ; "+E->get().to_upper() );
+ ResourceLoader::get_recognized_extensions_for_type("Animation", &extensions);
+ for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
+ file->add_filter("*." + E->get() + " ; " + E->get().to_upper());
}
file->popup_centered_ratio();
current_option = RESOURCE_LOAD;
}
-
-void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource>& p_resource, const String& p_path) {
+void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resource, const String &p_path) {
int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
@@ -393,29 +379,27 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource>& p_resou
}
//EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
- ((Resource*)p_resource.ptr())->set_path(path);
+ ((Resource *)p_resource.ptr())->set_path(path);
editor->emit_signal("resource_saved", p_resource);
-
}
-void AnimationPlayerEditor::_animation_save(const Ref<Resource>& p_resource) {
+void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) {
if (p_resource->get_path().is_resource_file()) {
_animation_save_in_path(p_resource, p_resource->get_path());
- }
- else {
+ } else {
_animation_save_as(p_resource);
}
}
-void AnimationPlayerEditor::_animation_save_as(const Ref<Resource>& p_resource) {
+void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) {
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
List<String> extensions;
ResourceSaver::get_recognized_extensions(p_resource, &extensions);
file->clear_filters();
- for (int i = 0; i<extensions.size(); i++) {
+ for (int i = 0; i < extensions.size(); i++) {
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
@@ -429,20 +413,17 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource>& p_resource)
file->set_current_path(p_resource->get_path().replacen("." + ext, "." + extensions.front()->get()));
}
}
- }
- else {
+ } else {
String existing;
if (extensions.size()) {
- if( p_resource->get_name() != "" ) {
+ if (p_resource->get_name() != "") {
existing = p_resource->get_name() + "." + extensions.front()->get().to_lower();
- }
- else {
+ } else {
existing = "new_" + p_resource->get_class().to_lower() + "." + extensions.front()->get().to_lower();
}
}
file->set_current_path(existing);
-
}
file->popup_centered_ratio();
file->set_title(TTR("Save Resource As.."));
@@ -471,25 +452,23 @@ void AnimationPlayerEditor::_animation_remove_confirmed() {
undo_redo->commit_action();
}
-void AnimationPlayerEditor::_select_anim_by_name(const String& p_anim) {
+void AnimationPlayerEditor::_select_anim_by_name(const String &p_anim) {
- int idx=-1;
- for(int i=0;i<animation->get_item_count();i++) {
+ int idx = -1;
+ for (int i = 0; i < animation->get_item_count(); i++) {
- if (animation->get_item_text(i)==p_anim) {
+ if (animation->get_item_text(i) == p_anim) {
- idx=i;
+ idx = i;
break;
}
}
- ERR_FAIL_COND(idx==-1);
-
+ ERR_FAIL_COND(idx == -1);
animation->select(idx);
_animation_selected(idx);
-
}
void AnimationPlayerEditor::_animation_name_edited() {
@@ -497,13 +476,13 @@ void AnimationPlayerEditor::_animation_name_edited() {
player->stop();
String new_name = name->get_text();
- if (new_name=="" || new_name.find(":")!=-1 || new_name.find("/")!=-1) {
+ if (new_name == "" || new_name.find(":") != -1 || new_name.find("/") != -1) {
error_dialog->set_text(TTR("ERROR: Invalid animation name!"));
error_dialog->popup_centered_minsize();
return;
}
- if (renaming && animation->get_item_count()>0 && animation->get_item_text(animation->get_selected())==new_name) {
+ if (renaming && animation->get_item_count() > 0 && animation->get_item_text(animation->get_selected()) == new_name) {
name_dialog->hide();
return;
}
@@ -516,51 +495,49 @@ void AnimationPlayerEditor::_animation_name_edited() {
if (renaming) {
String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim = player->get_animation(current);
+ Ref<Animation> anim = player->get_animation(current);
undo_redo->create_action(TTR("Rename Animation"));
- undo_redo->add_do_method(player,"rename_animation",current,new_name);
- undo_redo->add_do_method(anim.ptr(),"set_name",new_name);
- undo_redo->add_undo_method(player,"rename_animation",new_name,current);
- undo_redo->add_undo_method(anim.ptr(),"set_name",current);
- undo_redo->add_do_method(this,"_animation_player_changed",player);
- undo_redo->add_undo_method(this,"_animation_player_changed",player);
+ undo_redo->add_do_method(player, "rename_animation", current, new_name);
+ undo_redo->add_do_method(anim.ptr(), "set_name", new_name);
+ undo_redo->add_undo_method(player, "rename_animation", new_name, current);
+ undo_redo->add_undo_method(anim.ptr(), "set_name", current);
+ undo_redo->add_do_method(this, "_animation_player_changed", player);
+ undo_redo->add_undo_method(this, "_animation_player_changed", player);
undo_redo->commit_action();
_select_anim_by_name(new_name);
} else {
- Ref<Animation> new_anim = Ref<Animation>(memnew( Animation ));
+ Ref<Animation> new_anim = Ref<Animation>(memnew(Animation));
new_anim->set_name(new_name);
undo_redo->create_action(TTR("Add Animation"));
- undo_redo->add_do_method(player,"add_animation",new_name,new_anim);
- undo_redo->add_undo_method(player,"remove_animation",new_name);
- undo_redo->add_do_method(this,"_animation_player_changed",player);
- undo_redo->add_undo_method(this,"_animation_player_changed",player);
+ undo_redo->add_do_method(player, "add_animation", new_name, new_anim);
+ undo_redo->add_undo_method(player, "remove_animation", new_name);
+ undo_redo->add_do_method(this, "_animation_player_changed", player);
+ undo_redo->add_undo_method(this, "_animation_player_changed", player);
undo_redo->commit_action();
_select_anim_by_name(new_name);
-
}
name_dialog->hide();
}
-
void AnimationPlayerEditor::_blend_editor_next_changed(const int p_idx) {
- if (animation->get_item_count()==0)
+ if (animation->get_item_count() == 0)
return;
String current = animation->get_item_text(animation->get_selected());
undo_redo->create_action(TTR("Blend Next Changed"));
- undo_redo->add_do_method(player,"animation_set_next",current,blend_editor.next->get_item_text(p_idx));
- undo_redo->add_undo_method(player,"animation_set_next",current,player->animation_get_next(current));
- undo_redo->add_do_method(this,"_animation_player_changed",player);
- undo_redo->add_undo_method(this,"_animation_player_changed",player);
+ undo_redo->add_do_method(player, "animation_set_next", current, blend_editor.next->get_item_text(p_idx));
+ undo_redo->add_undo_method(player, "animation_set_next", current, player->animation_get_next(current));
+ undo_redo->add_do_method(this, "_animation_player_changed", player);
+ undo_redo->add_undo_method(this, "_animation_player_changed", player);
undo_redo->commit_action();
}
@@ -571,37 +548,37 @@ void AnimationPlayerEditor::_animation_blend() {
blend_editor.tree->clear();
- if (animation->get_item_count()==0)
+ if (animation->get_item_count() == 0)
return;
String current = animation->get_item_text(animation->get_selected());
- blend_editor.dialog->popup_centered(Size2(400,400));
+ blend_editor.dialog->popup_centered(Size2(400, 400));
blend_editor.tree->set_hide_root(true);
- blend_editor.tree->set_column_min_width(0,10);
- blend_editor.tree->set_column_min_width(1,3);
+ blend_editor.tree->set_column_min_width(0, 10);
+ blend_editor.tree->set_column_min_width(1, 3);
List<StringName> anims;
player->get_animation_list(&anims);
TreeItem *root = blend_editor.tree->create_item();
- updating_blends=true;
+ updating_blends = true;
int i = 0;
bool anim_found = false;
blend_editor.next->clear();
blend_editor.next->add_item("", i);
- for(List<StringName>::Element *E=anims.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = anims.front(); E; E = E->next()) {
- String to=E->get();
- TreeItem *blend=blend_editor.tree->create_item(root);
- blend->set_editable(0,false);
- blend->set_editable(1,true);
- blend->set_text(0,to);
- blend->set_cell_mode(1,TreeItem::CELL_MODE_RANGE);
- blend->set_range_config(1,0,3600,0.001);
- blend->set_range(1,player->get_blend_time(current,to));
+ String to = E->get();
+ TreeItem *blend = blend_editor.tree->create_item(root);
+ blend->set_editable(0, false);
+ blend->set_editable(1, true);
+ blend->set_text(0, to);
+ blend->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
+ blend->set_range_config(1, 0, 3600, 0.001);
+ blend->set_range(1, player->get_blend_time(current, to));
i++;
blend_editor.next->add_item(to, i);
@@ -617,7 +594,7 @@ void AnimationPlayerEditor::_animation_blend() {
player->animation_set_next(current, blend_editor.next->get_item_text(0));
}
- updating_blends=false;
+ updating_blends = false;
}
void AnimationPlayerEditor::_blend_edited() {
@@ -625,7 +602,7 @@ void AnimationPlayerEditor::_blend_edited() {
if (updating_blends)
return;
- if (animation->get_item_count()==0)
+ if (animation->get_item_count() == 0)
return;
String current = animation->get_item_text(animation->get_selected());
@@ -634,18 +611,18 @@ void AnimationPlayerEditor::_blend_edited() {
if (!selected)
return;
- updating_blends=true;
- String to=selected->get_text(0);
+ updating_blends = true;
+ String to = selected->get_text(0);
float blend_time = selected->get_range(1);
- float prev_blend_time = player->get_blend_time(current,to);
+ float prev_blend_time = player->get_blend_time(current, to);
undo_redo->create_action(TTR("Change Blend Time"));
- undo_redo->add_do_method(player,"set_blend_time",current,to,blend_time);
- undo_redo->add_undo_method(player,"set_blend_time",current,to,prev_blend_time);
- undo_redo->add_do_method(this,"_animation_player_changed",player);
- undo_redo->add_undo_method(this,"_animation_player_changed",player);
+ undo_redo->add_do_method(player, "set_blend_time", current, to, blend_time);
+ undo_redo->add_undo_method(player, "set_blend_time", current, to, prev_blend_time);
+ undo_redo->add_do_method(this, "_animation_player_changed", player);
+ undo_redo->add_undo_method(this, "_animation_player_changed", player);
undo_redo->commit_action();
- updating_blends=false;
+ updating_blends = false;
}
void AnimationPlayerEditor::ensure_visibility() {
@@ -658,20 +635,17 @@ void AnimationPlayerEditor::ensure_visibility() {
Dictionary AnimationPlayerEditor::get_state() const {
-
Dictionary d;
- d["visible"]=is_visible_in_tree();
+ d["visible"] = is_visible_in_tree();
if (EditorNode::get_singleton()->get_edited_scene() && is_visible_in_tree() && player) {
- d["player"]=EditorNode::get_singleton()->get_edited_scene()->get_path_to(player);
- d["animation"]=player->get_current_animation();
-
+ d["player"] = EditorNode::get_singleton()->get_edited_scene()->get_path_to(player);
+ d["animation"] = player->get_current_animation();
}
return d;
-
}
-void AnimationPlayerEditor::set_state(const Dictionary& p_state) {
+void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
if (p_state.has("visible") && p_state["visible"]) {
@@ -680,7 +654,7 @@ void AnimationPlayerEditor::set_state(const Dictionary& p_state) {
Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["player"]);
if (n && n->cast_to<AnimationPlayer>() && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) {
- player=n->cast_to<AnimationPlayer>();
+ player = n->cast_to<AnimationPlayer>();
_update_player();
show();
set_process(true);
@@ -692,28 +666,24 @@ void AnimationPlayerEditor::set_state(const Dictionary& p_state) {
_select_anim_by_name(anim);
_animation_edit();
}
-
}
}
-
}
-
void AnimationPlayerEditor::_animation_resource_edit() {
if (animation->get_item_count()) {
String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim = player->get_animation(current);
+ Ref<Animation> anim = player->get_animation(current);
editor->edit_resource(anim);
}
-
}
void AnimationPlayerEditor::_animation_edit() {
if (animation->get_item_count()) {
String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim = player->get_animation(current);
+ Ref<Animation> anim = player->get_animation(current);
key_editor->set_animation(anim);
Node *root = player->get_node(player->get_root());
if (root) {
@@ -724,9 +694,7 @@ void AnimationPlayerEditor::_animation_edit() {
key_editor->set_animation(Ref<Animation>());
key_editor->set_root(NULL);
-
}
-
}
void AnimationPlayerEditor::_dialog_action(String p_file) {
@@ -740,12 +708,10 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
if (p_file.find_last("/") != -1) {
p_file = p_file.substr(p_file.find_last("/") + 1, p_file.length());
-
}
if (p_file.find_last("\\") != -1) {
p_file = p_file.substr(p_file.find_last("\\") + 1, p_file.length());
-
}
if (p_file.find(".") != -1)
@@ -756,7 +722,6 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
undo_redo->add_undo_method(player, "remove_animation", p_file);
if (player->has_animation(p_file)) {
undo_redo->add_undo_method(player, "add_animation", p_file, player->get_animation(p_file));
-
}
undo_redo->add_do_method(this, "_animation_player_changed", player);
undo_redo->add_undo_method(this, "_animation_player_changed", player);
@@ -771,7 +736,7 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
ERR_FAIL_COND(!anim->cast_to<Resource>())
- RES current_res = RES(anim->cast_to<Resource>());
+ RES current_res = RES(anim->cast_to<Resource>());
_animation_save_in_path(current_res, p_file);
}
@@ -779,7 +744,7 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
}
}
-void AnimationPlayerEditor::_scale_changed(const String& p_scale) {
+void AnimationPlayerEditor::_scale_changed(const String &p_scale) {
player->set_speed_scale(p_scale.to_double());
}
@@ -789,8 +754,7 @@ void AnimationPlayerEditor::_update_animation() {
// the purpose of _update_animation is to reflect the current state
// of the animation player in the current editor..
- updating=true;
-
+ updating = true;
if (player->is_playing()) {
@@ -803,24 +767,23 @@ void AnimationPlayerEditor::_update_animation() {
stop->set_pressed(true);
}
- scale->set_text( String::num(player->get_speed_scale(),2) );
- String current=player->get_current_animation();
+ scale->set_text(String::num(player->get_speed_scale(), 2));
+ String current = player->get_current_animation();
- for (int i=0;i<animation->get_item_count();i++) {
+ for (int i = 0; i < animation->get_item_count(); i++) {
- if (animation->get_item_text(i)==current) {
+ if (animation->get_item_text(i) == current) {
animation->select(i);
break;
}
}
- updating=false;
+ updating = false;
}
void AnimationPlayerEditor::_update_player() {
-
- updating=true;
+ updating = true;
List<StringName> animlist;
if (player)
player->get_animation_list(&animlist);
@@ -831,78 +794,70 @@ void AnimationPlayerEditor::_update_player() {
else
nodename->set_text("<empty>");
-
- add_anim->set_disabled(player==NULL);
- load_anim->set_disabled(player==NULL);
- stop->set_disabled(animlist.size()==0);
- play->set_disabled(animlist.size()==0);
- play_bw->set_disabled(animlist.size()==0);
- play_bw_from->set_disabled(animlist.size()==0);
- play_from->set_disabled(animlist.size()==0);
- autoplay->set_disabled(animlist.size()==0);
- duplicate_anim->set_disabled(animlist.size()==0);
- rename_anim->set_disabled(animlist.size()==0);
- blend_anim->set_disabled(animlist.size()==0);
- remove_anim->set_disabled(animlist.size()==0);
- resource_edit_anim->set_disabled(animlist.size()==0);
+ add_anim->set_disabled(player == NULL);
+ load_anim->set_disabled(player == NULL);
+ stop->set_disabled(animlist.size() == 0);
+ play->set_disabled(animlist.size() == 0);
+ play_bw->set_disabled(animlist.size() == 0);
+ play_bw_from->set_disabled(animlist.size() == 0);
+ play_from->set_disabled(animlist.size() == 0);
+ autoplay->set_disabled(animlist.size() == 0);
+ duplicate_anim->set_disabled(animlist.size() == 0);
+ rename_anim->set_disabled(animlist.size() == 0);
+ blend_anim->set_disabled(animlist.size() == 0);
+ remove_anim->set_disabled(animlist.size() == 0);
+ resource_edit_anim->set_disabled(animlist.size() == 0);
save_anim->set_disabled(animlist.size() == 0);
- tool_anim->set_disabled(player==NULL);
+ tool_anim->set_disabled(player == NULL);
+ int active_idx = -1;
+ for (List<StringName>::Element *E = animlist.front(); E; E = E->next()) {
- int active_idx=-1;
- for (List<StringName>::Element *E=animlist.front();E;E=E->next()) {
-
- if (player->get_autoplay()==E->get())
- animation->add_icon_item(autoplay_icon,E->get());
+ if (player->get_autoplay() == E->get())
+ animation->add_icon_item(autoplay_icon, E->get());
else
animation->add_item(E->get());
- if (player->get_current_animation()==E->get())
- active_idx=animation->get_item_count()-1;
-
+ if (player->get_current_animation() == E->get())
+ active_idx = animation->get_item_count() - 1;
}
if (!player)
return;
- updating=false;
- if (active_idx!=-1) {
+ updating = false;
+ if (active_idx != -1) {
animation->select(active_idx);
- autoplay->set_pressed(animation->get_item_text(active_idx)==player->get_autoplay());
+ autoplay->set_pressed(animation->get_item_text(active_idx) == player->get_autoplay());
_animation_selected(active_idx);
- } else if (animation->get_item_count()>0){
+ } else if (animation->get_item_count() > 0) {
animation->select(0);
- autoplay->set_pressed(animation->get_item_text(0)==player->get_autoplay());
+ autoplay->set_pressed(animation->get_item_text(0) == player->get_autoplay());
_animation_selected(0);
}
//pause->set_pressed(player->is_paused());
-
if (animation->get_item_count()) {
String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim = player->get_animation(current);
+ Ref<Animation> anim = player->get_animation(current);
key_editor->set_animation(anim);
Node *root = player->get_node(player->get_root());
if (root) {
key_editor->set_root(root);
}
-
}
_update_animation();
}
-
-
void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
-
if (player && pin->is_pressed())
return; //ignore, pinned
- player=p_player;
+ player = p_player;
if (player) {
_update_player();
@@ -911,29 +866,25 @@ void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
key_editor->show_select_node_warning(true);
//hide();
-
}
-
}
-
void AnimationPlayerEditor::_animation_duplicate() {
-
if (!animation->get_item_count())
return;
String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim = player->get_animation(current);
+ Ref<Animation> anim = player->get_animation(current);
if (!anim.is_valid())
return;
- Ref<Animation> new_anim = memnew( Animation );
+ Ref<Animation> new_anim = memnew(Animation);
List<PropertyInfo> plist;
anim->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) {
new_anim->set(E->get().name, anim->get(E->get().name));
}
@@ -941,78 +892,73 @@ void AnimationPlayerEditor::_animation_duplicate() {
new_anim->set_path("");
String new_name = current;
- while(player->has_animation(new_name)) {
+ while (player->has_animation(new_name)) {
- new_name=new_name+" (copy)";
+ new_name = new_name + " (copy)";
}
-
undo_redo->create_action(TTR("Duplicate Animation"));
- undo_redo->add_do_method(player,"add_animation",new_name,new_anim);
- undo_redo->add_undo_method(player,"remove_animation",new_name);
- undo_redo->add_do_method(player,"animation_set_next",new_name,player->animation_get_next(current));
- undo_redo->add_do_method(this,"_animation_player_changed",player);
- undo_redo->add_undo_method(this,"_animation_player_changed",player);
+ undo_redo->add_do_method(player, "add_animation", new_name, new_anim);
+ undo_redo->add_undo_method(player, "remove_animation", new_name);
+ undo_redo->add_do_method(player, "animation_set_next", new_name, player->animation_get_next(current));
+ undo_redo->add_do_method(this, "_animation_player_changed", player);
+ undo_redo->add_undo_method(this, "_animation_player_changed", player);
undo_redo->commit_action();
+ for (int i = 0; i < animation->get_item_count(); i++) {
- for(int i=0;i<animation->get_item_count();i++) {
-
- if (animation->get_item_text(i)==new_name) {
+ if (animation->get_item_text(i) == new_name) {
animation->select(i);
_animation_selected(i);
return;
}
}
-
}
-void AnimationPlayerEditor::_seek_value_changed(float p_value,bool p_set) {
+void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set) {
if (updating || !player || player->is_playing()) {
return;
};
-
- updating=true;
- String current=player->get_current_animation(); //animation->get_item_text( animation->get_selected() );
+ updating = true;
+ String current = player->get_current_animation(); //animation->get_item_text( animation->get_selected() );
if (current == "" || !player->has_animation(current)) {
- updating=false;
- current="";
+ updating = false;
+ current = "";
return;
};
Ref<Animation> anim;
- anim=player->get_animation(current);
+ anim = player->get_animation(current);
float pos = anim->get_length() * (p_value / frame->get_max());
float step = anim->get_step();
if (step) {
- pos=Math::stepify(pos, step);
- if (pos<0)
- pos=0;
- if (pos>=anim->get_length())
- pos=anim->get_length();
+ pos = Math::stepify(pos, step);
+ if (pos < 0)
+ pos = 0;
+ if (pos >= anim->get_length())
+ pos = anim->get_length();
}
if (player->is_valid() && !p_set) {
float cpos = player->get_current_animation_pos();
- player->seek_delta(pos,pos-cpos);
+ player->seek_delta(pos, pos - cpos);
} else {
- player->seek(pos,true);
+ player->seek(pos, true);
}
-
key_editor->set_anim_pos(pos);
- updating=true;
+ updating = true;
};
void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) {
- if (player==p_pl && is_visible_in_tree()) {
+ if (player == p_pl && is_visible_in_tree()) {
_update_player();
if (blend_editor.dialog->is_visible_in_tree())
@@ -1020,11 +966,9 @@ void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) {
}
}
-
-
void AnimationPlayerEditor::_list_changed() {
- if(is_visible_in_tree())
+ if (is_visible_in_tree())
_update_player();
}
#if 0
@@ -1095,9 +1039,7 @@ void AnimationPlayerEditor::_editor_load(){
void AnimationPlayerEditor::_animation_key_editor_anim_len_changed(float p_len) {
-
frame->set_max(p_len);
-
}
void AnimationPlayerEditor::_animation_key_editor_anim_step_changed(float p_len) {
@@ -1106,49 +1048,43 @@ void AnimationPlayerEditor::_animation_key_editor_anim_step_changed(float p_len)
frame->set_step(p_len);
else
frame->set_step(0.00001);
-
}
-
-void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos,bool p_drag) {
+void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag) {
if (!is_visible_in_tree())
return;
if (!player)
return;
- if (player->is_playing() )
+ if (player->is_playing())
return;
- updating=true;
- frame->set_value(p_pos);
- updating=false;
- _seek_value_changed(p_pos,!p_drag);
+ updating = true;
+ frame->set_value(p_pos);
+ updating = false;
+ _seek_value_changed(p_pos, !p_drag);
EditorNode::get_singleton()->get_property_editor()->refresh();
-
-
//seekit
}
void AnimationPlayerEditor::_hide_anim_editors() {
- player=NULL;
+ player = NULL;
hide();
set_process(false);
key_editor->set_animation(Ref<Animation>());
key_editor->set_root(NULL);
key_editor->show_select_node_warning(true);
- //editor->animation_editor_make_visible(false);
-
+ //editor->animation_editor_make_visible(false);
}
-
void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
- switch(p_option) {
+ switch (p_option) {
case TOOL_COPY_ANIM: {
@@ -1159,7 +1095,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
}
String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim = player->get_animation(current);
+ Ref<Animation> anim = player->get_animation(current);
//editor->edit_resource(anim);
EditorSettings::get_singleton()->set_resource_clipboard(anim);
@@ -1174,28 +1110,27 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
}
String name = anim->get_name();
- if (name=="") {
- name=TTR("Pasted Animation");
+ if (name == "") {
+ name = TTR("Pasted Animation");
}
- int idx=1;
+ int idx = 1;
String base = name;
while (player->has_animation(name)) {
idx++;
- name=base+" "+itos(idx);
+ name = base + " " + itos(idx);
}
undo_redo->create_action(TTR("Paste Animation"));
- undo_redo->add_do_method(player,"add_animation",name,anim);
- undo_redo->add_undo_method(player,"remove_animation",name);
- undo_redo->add_do_method(this,"_animation_player_changed",player);
- undo_redo->add_undo_method(this,"_animation_player_changed",player);
+ undo_redo->add_do_method(player, "add_animation", name, anim);
+ undo_redo->add_undo_method(player, "remove_animation", name);
+ undo_redo->add_do_method(this, "_animation_player_changed", player);
+ undo_redo->add_undo_method(this, "_animation_player_changed", player);
undo_redo->commit_action();
_select_anim_by_name(name);
-
} break;
case TOOL_EDIT_RESOURCE: {
@@ -1206,11 +1141,10 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
}
String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim = player->get_animation(current);
+ Ref<Animation> anim = player->get_animation(current);
editor->edit_resource(anim);
} break;
-
}
}
@@ -1221,21 +1155,21 @@ void AnimationPlayerEditor::_animation_save_menu(int p_option) {
Ref<Animation> anim = player->get_animation(current);
switch (p_option) {
- case ANIM_SAVE:
- _animation_save(anim);
- break;
- case ANIM_SAVE_AS:
- _animation_save_as(anim);
- break;
+ case ANIM_SAVE:
+ _animation_save(anim);
+ break;
+ case ANIM_SAVE_AS:
+ _animation_save_as(anim);
+ break;
}
}
}
-void AnimationPlayerEditor::_unhandled_key_input(const InputEvent& p_ev) {
+void AnimationPlayerEditor::_unhandled_key_input(const InputEvent &p_ev) {
- if (is_visible_in_tree() && p_ev.type==InputEvent::KEY && p_ev.key.pressed && !p_ev.key.echo && !p_ev.key.mod.alt && !p_ev.key.mod.control && !p_ev.key.mod.meta) {
+ if (is_visible_in_tree() && p_ev.type == InputEvent::KEY && p_ev.key.pressed && !p_ev.key.echo && !p_ev.key.mod.alt && !p_ev.key.mod.control && !p_ev.key.mod.meta) {
- switch(p_ev.key.scancode) {
+ switch (p_ev.key.scancode) {
case KEY_A: {
if (!p_ev.key.mod.shift)
@@ -1258,130 +1192,119 @@ void AnimationPlayerEditor::_unhandled_key_input(const InputEvent& p_ev) {
void AnimationPlayerEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_gui_input"),&AnimationPlayerEditor::_gui_input);
- ClassDB::bind_method(D_METHOD("_node_removed"),&AnimationPlayerEditor::_node_removed);
- ClassDB::bind_method(D_METHOD("_play_pressed"),&AnimationPlayerEditor::_play_pressed);
- ClassDB::bind_method(D_METHOD("_play_from_pressed"),&AnimationPlayerEditor::_play_from_pressed);
- ClassDB::bind_method(D_METHOD("_play_bw_pressed"),&AnimationPlayerEditor::_play_bw_pressed);
- ClassDB::bind_method(D_METHOD("_play_bw_from_pressed"),&AnimationPlayerEditor::_play_bw_from_pressed);
- ClassDB::bind_method(D_METHOD("_stop_pressed"),&AnimationPlayerEditor::_stop_pressed);
- ClassDB::bind_method(D_METHOD("_autoplay_pressed"),&AnimationPlayerEditor::_autoplay_pressed);
- ClassDB::bind_method(D_METHOD("_pause_pressed"),&AnimationPlayerEditor::_pause_pressed);
- ClassDB::bind_method(D_METHOD("_animation_selected"),&AnimationPlayerEditor::_animation_selected);
- ClassDB::bind_method(D_METHOD("_animation_name_edited"),&AnimationPlayerEditor::_animation_name_edited);
- ClassDB::bind_method(D_METHOD("_animation_new"),&AnimationPlayerEditor::_animation_new);
- ClassDB::bind_method(D_METHOD("_animation_rename"),&AnimationPlayerEditor::_animation_rename);
- ClassDB::bind_method(D_METHOD("_animation_load"),&AnimationPlayerEditor::_animation_load);
- ClassDB::bind_method(D_METHOD("_animation_remove"),&AnimationPlayerEditor::_animation_remove);
- ClassDB::bind_method(D_METHOD("_animation_remove_confirmed"),&AnimationPlayerEditor::_animation_remove_confirmed);
- ClassDB::bind_method(D_METHOD("_animation_blend"),&AnimationPlayerEditor::_animation_blend);
- ClassDB::bind_method(D_METHOD("_animation_edit"),&AnimationPlayerEditor::_animation_edit);
- ClassDB::bind_method(D_METHOD("_animation_resource_edit"),&AnimationPlayerEditor::_animation_resource_edit);
- ClassDB::bind_method(D_METHOD("_dialog_action"),&AnimationPlayerEditor::_dialog_action);
- ClassDB::bind_method(D_METHOD("_seek_value_changed"),&AnimationPlayerEditor::_seek_value_changed,DEFVAL(true));
- ClassDB::bind_method(D_METHOD("_animation_player_changed"),&AnimationPlayerEditor::_animation_player_changed);
- ClassDB::bind_method(D_METHOD("_blend_edited"),&AnimationPlayerEditor::_blend_edited);
+ ClassDB::bind_method(D_METHOD("_gui_input"), &AnimationPlayerEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_node_removed"), &AnimationPlayerEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_play_pressed"), &AnimationPlayerEditor::_play_pressed);
+ ClassDB::bind_method(D_METHOD("_play_from_pressed"), &AnimationPlayerEditor::_play_from_pressed);
+ ClassDB::bind_method(D_METHOD("_play_bw_pressed"), &AnimationPlayerEditor::_play_bw_pressed);
+ ClassDB::bind_method(D_METHOD("_play_bw_from_pressed"), &AnimationPlayerEditor::_play_bw_from_pressed);
+ ClassDB::bind_method(D_METHOD("_stop_pressed"), &AnimationPlayerEditor::_stop_pressed);
+ ClassDB::bind_method(D_METHOD("_autoplay_pressed"), &AnimationPlayerEditor::_autoplay_pressed);
+ ClassDB::bind_method(D_METHOD("_pause_pressed"), &AnimationPlayerEditor::_pause_pressed);
+ ClassDB::bind_method(D_METHOD("_animation_selected"), &AnimationPlayerEditor::_animation_selected);
+ ClassDB::bind_method(D_METHOD("_animation_name_edited"), &AnimationPlayerEditor::_animation_name_edited);
+ ClassDB::bind_method(D_METHOD("_animation_new"), &AnimationPlayerEditor::_animation_new);
+ ClassDB::bind_method(D_METHOD("_animation_rename"), &AnimationPlayerEditor::_animation_rename);
+ ClassDB::bind_method(D_METHOD("_animation_load"), &AnimationPlayerEditor::_animation_load);
+ ClassDB::bind_method(D_METHOD("_animation_remove"), &AnimationPlayerEditor::_animation_remove);
+ ClassDB::bind_method(D_METHOD("_animation_remove_confirmed"), &AnimationPlayerEditor::_animation_remove_confirmed);
+ ClassDB::bind_method(D_METHOD("_animation_blend"), &AnimationPlayerEditor::_animation_blend);
+ ClassDB::bind_method(D_METHOD("_animation_edit"), &AnimationPlayerEditor::_animation_edit);
+ ClassDB::bind_method(D_METHOD("_animation_resource_edit"), &AnimationPlayerEditor::_animation_resource_edit);
+ ClassDB::bind_method(D_METHOD("_dialog_action"), &AnimationPlayerEditor::_dialog_action);
+ ClassDB::bind_method(D_METHOD("_seek_value_changed"), &AnimationPlayerEditor::_seek_value_changed, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("_animation_player_changed"), &AnimationPlayerEditor::_animation_player_changed);
+ ClassDB::bind_method(D_METHOD("_blend_edited"), &AnimationPlayerEditor::_blend_edited);
//ClassDB::bind_method(D_METHOD("_seek_frame_changed"),&AnimationPlayerEditor::_seek_frame_changed);
- ClassDB::bind_method(D_METHOD("_scale_changed"),&AnimationPlayerEditor::_scale_changed);
+ ClassDB::bind_method(D_METHOD("_scale_changed"), &AnimationPlayerEditor::_scale_changed);
//ClassDB::bind_method(D_METHOD("_editor_store_all"),&AnimationPlayerEditor::_editor_store_all);
//ClassDB::bind_method(D_METHOD("_editor_load_all"),&AnimationPlayerEditor::_editor_load_all);
- ClassDB::bind_method(D_METHOD("_list_changed"),&AnimationPlayerEditor::_list_changed);
- ClassDB::bind_method(D_METHOD("_animation_key_editor_seek"),&AnimationPlayerEditor::_animation_key_editor_seek);
- ClassDB::bind_method(D_METHOD("_animation_key_editor_anim_len_changed"),&AnimationPlayerEditor::_animation_key_editor_anim_len_changed);
- ClassDB::bind_method(D_METHOD("_animation_key_editor_anim_step_changed"),&AnimationPlayerEditor::_animation_key_editor_anim_step_changed);
- ClassDB::bind_method(D_METHOD("_hide_anim_editors"),&AnimationPlayerEditor::_hide_anim_editors);
- ClassDB::bind_method(D_METHOD("_animation_duplicate"),&AnimationPlayerEditor::_animation_duplicate);
- ClassDB::bind_method(D_METHOD("_blend_editor_next_changed"),&AnimationPlayerEditor::_blend_editor_next_changed);
- ClassDB::bind_method(D_METHOD("_unhandled_key_input"),&AnimationPlayerEditor::_unhandled_key_input);
- ClassDB::bind_method(D_METHOD("_animation_tool_menu"),&AnimationPlayerEditor::_animation_tool_menu);
+ ClassDB::bind_method(D_METHOD("_list_changed"), &AnimationPlayerEditor::_list_changed);
+ ClassDB::bind_method(D_METHOD("_animation_key_editor_seek"), &AnimationPlayerEditor::_animation_key_editor_seek);
+ ClassDB::bind_method(D_METHOD("_animation_key_editor_anim_len_changed"), &AnimationPlayerEditor::_animation_key_editor_anim_len_changed);
+ ClassDB::bind_method(D_METHOD("_animation_key_editor_anim_step_changed"), &AnimationPlayerEditor::_animation_key_editor_anim_step_changed);
+ ClassDB::bind_method(D_METHOD("_hide_anim_editors"), &AnimationPlayerEditor::_hide_anim_editors);
+ ClassDB::bind_method(D_METHOD("_animation_duplicate"), &AnimationPlayerEditor::_animation_duplicate);
+ ClassDB::bind_method(D_METHOD("_blend_editor_next_changed"), &AnimationPlayerEditor::_blend_editor_next_changed);
+ ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &AnimationPlayerEditor::_unhandled_key_input);
+ ClassDB::bind_method(D_METHOD("_animation_tool_menu"), &AnimationPlayerEditor::_animation_tool_menu);
ClassDB::bind_method(D_METHOD("_animation_save_menu"), &AnimationPlayerEditor::_animation_save_menu);
-
-
-
-
}
-AnimationPlayerEditor *AnimationPlayerEditor::singleton=NULL;
+AnimationPlayerEditor *AnimationPlayerEditor::singleton = NULL;
AnimationPlayer *AnimationPlayerEditor::get_player() const {
return player;
}
AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
- editor=p_editor;
- singleton=this;
+ editor = p_editor;
+ singleton = this;
- updating=false;
+ updating = false;
set_focus_mode(FOCUS_ALL);
- player=NULL;
- add_style_override("panel", get_stylebox("panel","Panel"));
-
+ player = NULL;
+ add_style_override("panel", get_stylebox("panel", "Panel"));
- Label * l;
+ Label *l;
/*l= memnew( Label );
l->set_text("Animation Player:");
add_child(l);*/
- HBoxContainer *hb = memnew( HBoxContainer );
+ HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
-
- play_bw_from = memnew( ToolButton );
+ play_bw_from = memnew(ToolButton);
play_bw_from->set_tooltip(TTR("Play selected animation backwards from current pos. (A)"));
hb->add_child(play_bw_from);
- play_bw = memnew( ToolButton );
+ play_bw = memnew(ToolButton);
play_bw->set_tooltip(TTR("Play selected animation backwards from end. (Shift+A)"));
hb->add_child(play_bw);
- stop = memnew( ToolButton );
+ stop = memnew(ToolButton);
stop->set_toggle_mode(true);
hb->add_child(stop);
stop->set_tooltip(TTR("Stop animation playback. (S)"));
- play = memnew( ToolButton );
+ play = memnew(ToolButton);
play->set_tooltip(TTR("Play selected animation from start. (Shift+D)"));
hb->add_child(play);
-
- play_from = memnew( ToolButton );
+ play_from = memnew(ToolButton);
play_from->set_tooltip(TTR("Play selected animation from current pos. (D)"));
hb->add_child(play_from);
-
-
//pause = memnew( Button );
//pause->set_toggle_mode(true);
//hb->add_child(pause);
- frame = memnew( SpinBox );
+ frame = memnew(SpinBox);
hb->add_child(frame);
- frame->set_custom_minimum_size(Size2(60,0));
+ frame->set_custom_minimum_size(Size2(60, 0));
frame->set_stretch_ratio(2);
frame->set_tooltip(TTR("Animation position (in seconds)."));
- hb->add_child( memnew( VSeparator));
+ hb->add_child(memnew(VSeparator));
- scale = memnew( LineEdit );
+ scale = memnew(LineEdit);
hb->add_child(scale);
scale->set_h_size_flags(SIZE_EXPAND_FILL);
scale->set_stretch_ratio(1);
scale->set_tooltip(TTR("Scale animation playback globally for the node."));
scale->hide();
-
- add_anim = memnew( ToolButton );
+ add_anim = memnew(ToolButton);
ED_SHORTCUT("animation_player_editor/add_animation", TTR("Create new animation in player."));
add_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/add_animation"));
add_anim->set_tooltip(TTR("Create new animation in player."));
hb->add_child(add_anim);
-
- load_anim = memnew( ToolButton );
+ load_anim = memnew(ToolButton);
ED_SHORTCUT("animation_player_editor/load_from_disk", TTR("Load animation from disk."));
add_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/load_from_disk"));
load_anim->set_tooltip(TTR("Load an animation from disk."));
@@ -1402,159 +1325,146 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
add_child(delete_dialog);
delete_dialog->connect("confirmed", this, "_animation_remove_confirmed");
- duplicate_anim = memnew( ToolButton );
+ duplicate_anim = memnew(ToolButton);
hb->add_child(duplicate_anim);
ED_SHORTCUT("animation_player_editor/duplicate_animation", TTR("Duplicate Animation"));
duplicate_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/duplicate_animation"));
duplicate_anim->set_tooltip(TTR("Duplicate Animation"));
- rename_anim = memnew( ToolButton );
+ rename_anim = memnew(ToolButton);
hb->add_child(rename_anim);
ED_SHORTCUT("animation_player_editor/rename_animation", TTR("Rename Animation"));
rename_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/rename_animation"));
rename_anim->set_tooltip(TTR("Rename Animation"));
- remove_anim = memnew( ToolButton );
+ remove_anim = memnew(ToolButton);
hb->add_child(remove_anim);
ED_SHORTCUT("animation_player_editor/remove_animation", TTR("Remove Animation"));
remove_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/remove_animation"));
remove_anim->set_tooltip(TTR("Remove Animation"));
-
- animation = memnew( OptionButton );
+ animation = memnew(OptionButton);
hb->add_child(animation);
animation->set_h_size_flags(SIZE_EXPAND_FILL);
animation->set_tooltip(TTR("Display list of animations in player."));
animation->set_clip_text(true);
- autoplay = memnew( ToolButton );
+ autoplay = memnew(ToolButton);
hb->add_child(autoplay);
autoplay->set_tooltip(TTR("Autoplay on Load"));
-
-
- blend_anim = memnew( ToolButton );
+ blend_anim = memnew(ToolButton);
hb->add_child(blend_anim);
blend_anim->set_tooltip(TTR("Edit Target Blend Times"));
- tool_anim = memnew( MenuButton);
+ tool_anim = memnew(MenuButton);
//tool_anim->set_flat(false);
tool_anim->set_tooltip(TTR("Animation Tools"));
- tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/copy_animation", TTR("Copy Animation")),TOOL_COPY_ANIM);
- tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/paste_animation", TTR("Paste Animation")),TOOL_PASTE_ANIM);
+ tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/copy_animation", TTR("Copy Animation")), TOOL_COPY_ANIM);
+ tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/paste_animation", TTR("Paste Animation")), TOOL_PASTE_ANIM);
//tool_anim->get_popup()->add_separator();
//tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM);
hb->add_child(tool_anim);
- nodename = memnew( Button );
+ nodename = memnew(Button);
hb->add_child(nodename);
- pin = memnew( ToolButton );
+ pin = memnew(ToolButton);
pin->set_toggle_mode(true);
hb->add_child(pin);
-
-
- resource_edit_anim= memnew( Button );
+ resource_edit_anim = memnew(Button);
hb->add_child(resource_edit_anim);
resource_edit_anim->hide();
-
file = memnew(EditorFileDialog);
add_child(file);
- name_dialog = memnew( ConfirmationDialog );
+ name_dialog = memnew(ConfirmationDialog);
name_dialog->set_title(TTR("Create New Animation"));
name_dialog->set_hide_on_ok(false);
add_child(name_dialog);
- name = memnew( LineEdit );
+ name = memnew(LineEdit);
name_dialog->add_child(name);
- name->set_pos(Point2(18,30));
- name->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,10);
+ name->set_pos(Point2(18, 30));
+ name->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 10);
name_dialog->register_text_enter(name);
-
- l = memnew( Label );
+ l = memnew(Label);
l->set_text(TTR("Animation Name:"));
- l->set_pos( Point2(10,10) );
+ l->set_pos(Point2(10, 10));
name_dialog->add_child(l);
- name_title=l;
+ name_title = l;
- error_dialog = memnew( ConfirmationDialog );
+ error_dialog = memnew(ConfirmationDialog);
error_dialog->get_ok()->set_text(TTR("Close"));
//error_dialog->get_cancel()->set_text("Close");
error_dialog->set_text(TTR("Error!"));
add_child(error_dialog);
- name_dialog->connect("confirmed", this,"_animation_name_edited");
+ name_dialog->connect("confirmed", this, "_animation_name_edited");
- blend_editor.dialog = memnew( AcceptDialog );
+ blend_editor.dialog = memnew(AcceptDialog);
add_child(blend_editor.dialog);
blend_editor.dialog->get_ok()->set_text(TTR("Close"));
blend_editor.dialog->set_hide_on_ok(true);
- VBoxContainer *blend_vb = memnew( VBoxContainer);
+ VBoxContainer *blend_vb = memnew(VBoxContainer);
blend_editor.dialog->add_child(blend_vb);
//blend_editor.dialog->set_child_rect(blend_vb);
- blend_editor.tree = memnew( Tree );
+ blend_editor.tree = memnew(Tree);
blend_editor.tree->set_columns(2);
- blend_vb->add_margin_child(TTR("Blend Times:"),blend_editor.tree,true);
- blend_editor.next = memnew( OptionButton );
- blend_vb->add_margin_child(TTR("Next (Auto Queue):"),blend_editor.next);
+ blend_vb->add_margin_child(TTR("Blend Times:"), blend_editor.tree, true);
+ blend_editor.next = memnew(OptionButton);
+ blend_vb->add_margin_child(TTR("Next (Auto Queue):"), blend_editor.next);
blend_editor.dialog->set_title(TTR("Cross-Animation Blend Times"));
- updating_blends=false;
+ updating_blends = false;
- blend_editor.tree->connect("item_edited",this,"_blend_edited");
+ blend_editor.tree->connect("item_edited", this, "_blend_edited");
-
- autoplay->connect("pressed", this,"_autoplay_pressed");
+ autoplay->connect("pressed", this, "_autoplay_pressed");
autoplay->set_toggle_mode(true);
- play->connect("pressed", this,"_play_pressed");
- play_from->connect("pressed", this,"_play_from_pressed");
- play_bw->connect("pressed", this,"_play_bw_pressed");
- play_bw_from->connect("pressed", this,"_play_bw_from_pressed");
- stop->connect("pressed", this,"_stop_pressed");
+ play->connect("pressed", this, "_play_pressed");
+ play_from->connect("pressed", this, "_play_from_pressed");
+ play_bw->connect("pressed", this, "_play_bw_pressed");
+ play_bw_from->connect("pressed", this, "_play_bw_from_pressed");
+ stop->connect("pressed", this, "_stop_pressed");
//pause->connect("pressed", this,"_pause_pressed");
- add_anim->connect("pressed", this,"_animation_new");
- rename_anim->connect("pressed", this,"_animation_rename");
- load_anim->connect("pressed", this,"_animation_load");
- duplicate_anim->connect("pressed", this,"_animation_duplicate");
+ add_anim->connect("pressed", this, "_animation_new");
+ rename_anim->connect("pressed", this, "_animation_rename");
+ load_anim->connect("pressed", this, "_animation_load");
+ duplicate_anim->connect("pressed", this, "_animation_duplicate");
//frame->connect("text_entered", this,"_seek_frame_changed");
- blend_anim->connect("pressed", this,"_animation_blend");
- remove_anim->connect("pressed", this,"_animation_remove");
- animation->connect("item_selected", this,"_animation_selected",Vector<Variant>(),true);
- resource_edit_anim->connect("pressed", this,"_animation_resource_edit");
- file->connect("file_selected", this,"_dialog_action");
- frame->connect("value_changed", this, "_seek_value_changed",Vector<Variant>(),true);
- scale->connect("text_entered", this, "_scale_changed",Vector<Variant>(),true);
-
+ blend_anim->connect("pressed", this, "_animation_blend");
+ remove_anim->connect("pressed", this, "_animation_remove");
+ animation->connect("item_selected", this, "_animation_selected", Vector<Variant>(), true);
+ resource_edit_anim->connect("pressed", this, "_animation_resource_edit");
+ file->connect("file_selected", this, "_dialog_action");
+ frame->connect("value_changed", this, "_seek_value_changed", Vector<Variant>(), true);
+ scale->connect("text_entered", this, "_scale_changed", Vector<Variant>(), true);
-
- renaming=false;
- last_active=false;
+ renaming = false;
+ last_active = false;
set_process_unhandled_key_input(true);
- key_editor = memnew( AnimationKeyEditor);
+ key_editor = memnew(AnimationKeyEditor);
add_child(key_editor);
- add_constant_override("separation",get_constant("separation","VBoxContainer"));
+ add_constant_override("separation", get_constant("separation", "VBoxContainer"));
key_editor->set_v_size_flags(SIZE_EXPAND_FILL);
- key_editor->connect("timeline_changed",this,"_animation_key_editor_seek");
- key_editor->connect("animation_len_changed",this,"_animation_key_editor_anim_len_changed");
- key_editor->connect("animation_step_changed",this,"_animation_key_editor_anim_step_changed");
+ key_editor->connect("timeline_changed", this, "_animation_key_editor_seek");
+ key_editor->connect("animation_len_changed", this, "_animation_key_editor_anim_len_changed");
+ key_editor->connect("animation_step_changed", this, "_animation_key_editor_anim_step_changed");
_update_player();
}
-
void AnimationPlayerEditorPlugin::edit(Object *p_object) {
anim_editor->set_undo_redo(&get_undo_redo());
if (!p_object)
return;
anim_editor->edit(p_object->cast_to<AnimationPlayer>());
-
-
}
bool AnimationPlayerEditorPlugin::handles(Object *p_object) const {
@@ -1575,16 +1485,15 @@ void AnimationPlayerEditorPlugin::make_visible(bool p_visible) {
//anim_editor->hide();
//anim_editor->set_idle_process(false);
}
-
}
AnimationPlayerEditorPlugin::AnimationPlayerEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- anim_editor = memnew( AnimationPlayerEditor(editor) );
+ editor = p_node;
+ anim_editor = memnew(AnimationPlayerEditor(editor));
anim_editor->set_undo_redo(editor->get_undo_redo());
- editor->add_bottom_panel_item(TTR("Animation"),anim_editor);
+ editor->add_bottom_panel_item(TTR("Animation"), anim_editor);
/*
editor->get_viewport()->add_child(anim_editor);
anim_editor->set_area_as_parent_rect();
@@ -1593,12 +1502,7 @@ AnimationPlayerEditorPlugin::AnimationPlayerEditorPlugin(EditorNode *p_node) {
anim_editor->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END);
anim_editor->set_margin( MARGIN_RIGHT, 0 );*/
anim_editor->hide();
-
-
-
}
-
-AnimationPlayerEditorPlugin::~AnimationPlayerEditorPlugin()
-{
+AnimationPlayerEditorPlugin::~AnimationPlayerEditorPlugin() {
}
diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h
index d9b6ad52ff..0eee4afcd4 100644
--- a/editor/plugins/animation_player_editor_plugin.h
+++ b/editor/plugins/animation_player_editor_plugin.h
@@ -29,14 +29,13 @@
#ifndef ANIMATION_PLAYER_EDITOR_PLUGIN_H
#define ANIMATION_PLAYER_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/animation/animation_player.h"
#include "scene/gui/dialogs.h"
-#include "scene/gui/texture_button.h"
#include "scene/gui/slider.h"
#include "scene/gui/spin_box.h"
-
+#include "scene/gui/texture_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -44,7 +43,7 @@
class AnimationKeyEditor;
class AnimationPlayerEditor : public VBoxContainer {
- GDCLASS(AnimationPlayerEditor, VBoxContainer );
+ GDCLASS(AnimationPlayerEditor, VBoxContainer);
EditorNode *editor;
AnimationPlayer *player;
@@ -65,7 +64,6 @@ class AnimationPlayerEditor : public VBoxContainer {
RESOURCE_SAVE
};
-
OptionButton *animation;
Button *stop;
Button *play;
@@ -97,30 +95,27 @@ class AnimationPlayerEditor : public VBoxContainer {
EditorFileDialog *file;
AcceptDialog *accept;
- ConfirmationDialog* delete_dialog;
+ ConfirmationDialog *delete_dialog;
int current_option;
struct BlendEditor {
- AcceptDialog * dialog;
+ AcceptDialog *dialog;
Tree *tree;
OptionButton *next;
} blend_editor;
-
ConfirmationDialog *name_dialog;
ConfirmationDialog *error_dialog;
bool renaming;
-
bool updating;
bool updating_blends;
AnimationKeyEditor *key_editor;
-
- void _select_anim_by_name(const String& p_anim);
+ void _select_anim_by_name(const String &p_anim);
void _play_pressed();
void _play_from_pressed();
void _play_bw_pressed();
@@ -134,9 +129,9 @@ class AnimationPlayerEditor : public VBoxContainer {
void _animation_name_edited();
void _animation_load();
- void _animation_save_in_path(const Ref<Resource>& p_resource, const String& p_path);
- void _animation_save(const Ref<Resource>& p_resource);
- void _animation_save_as(const Ref<Resource>& p_resource);
+ void _animation_save_in_path(const Ref<Resource> &p_resource, const String &p_path);
+ void _animation_save(const Ref<Resource> &p_resource);
+ void _animation_save_as(const Ref<Resource> &p_resource);
void _animation_remove();
void _animation_remove_confirmed();
@@ -144,10 +139,10 @@ class AnimationPlayerEditor : public VBoxContainer {
void _animation_edit();
void _animation_duplicate();
void _animation_resource_edit();
- void _scale_changed(const String& p_scale);
+ void _scale_changed(const String &p_scale);
void _dialog_action(String p_file);
- void _seek_frame_changed(const String& p_frame);
- void _seek_value_changed(float p_value, bool p_set=false);
+ void _seek_frame_changed(const String &p_frame);
+ void _seek_value_changed(float p_value, bool p_set = false);
void _blend_editor_next_changed(const int p_idx);
void _list_changed();
@@ -155,7 +150,6 @@ class AnimationPlayerEditor : public VBoxContainer {
void _update_player();
void _blend_edited();
-
void _hide_anim_editors();
void _animation_player_changed(Object *p_pl);
@@ -164,46 +158,43 @@ class AnimationPlayerEditor : public VBoxContainer {
void _animation_key_editor_anim_len_changed(float p_new);
void _animation_key_editor_anim_step_changed(float p_len);
- void _unhandled_key_input(const InputEvent& p_ev);
+ void _unhandled_key_input(const InputEvent &p_ev);
void _animation_tool_menu(int p_option);
void _animation_save_menu(int p_option);
-
AnimationPlayerEditor();
-protected:
+protected:
void _notification(int p_what);
void _gui_input(InputEvent p_event);
void _node_removed(Node *p_node);
static void _bind_methods();
-public:
+public:
AnimationPlayer *get_player() const;
static AnimationPlayerEditor *singleton;
- AnimationKeyEditor* get_key_editor() { return key_editor; }
+ AnimationKeyEditor *get_key_editor() { return key_editor; }
Dictionary get_state() const;
- void set_state(const Dictionary& p_state);
-
+ void set_state(const Dictionary &p_state);
void ensure_visibility();
- void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; }
+ void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
void edit(AnimationPlayer *p_player);
AnimationPlayerEditor(EditorNode *p_editor);
};
class AnimationPlayerEditorPlugin : public EditorPlugin {
- GDCLASS( AnimationPlayerEditorPlugin, EditorPlugin );
+ GDCLASS(AnimationPlayerEditorPlugin, EditorPlugin);
AnimationPlayerEditor *anim_editor;
EditorNode *editor;
public:
-
virtual Dictionary get_state() const { return anim_editor->get_state(); }
- virtual void set_state(const Dictionary& p_state) { anim_editor->set_state(p_state); }
+ virtual void set_state(const Dictionary &p_state) { anim_editor->set_state(p_state); }
virtual String get_name() const { return "Anim"; }
bool has_main_screen() const { return false; }
@@ -213,7 +204,6 @@ public:
AnimationPlayerEditorPlugin(EditorNode *p_node);
~AnimationPlayerEditorPlugin();
-
};
#endif // ANIMATION_PLAYER_EDITOR_PLUGIN_H
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index 988136d475..7800fde7a8 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -28,18 +28,17 @@
/*************************************************************************/
#include "animation_tree_editor_plugin.h"
-#include "scene/gui/menu_button.h"
-#include "scene/gui/panel.h"
-#include "scene/main/viewport.h"
-#include "core/io/resource_loader.h"
#include "core/global_config.h"
+#include "core/io/resource_loader.h"
#include "os/input.h"
#include "os/keyboard.h"
+#include "scene/gui/menu_button.h"
+#include "scene/gui/panel.h"
+#include "scene/main/viewport.h"
-void AnimationTreeEditor::edit(AnimationTreePlayer* p_anim_tree) {
-
+void AnimationTreeEditor::edit(AnimationTreePlayer *p_anim_tree) {
- anim_tree=p_anim_tree;
+ anim_tree = p_anim_tree;
if (!anim_tree) {
hide();
@@ -55,59 +54,54 @@ void AnimationTreeEditor::edit(AnimationTreePlayer* p_anim_tree) {
play_button->set_pressed(p_anim_tree->is_active());
//read the orders
}
-
}
Size2 AnimationTreeEditor::_get_maximum_size() {
Size2 max;
- for(List<StringName>::Element *E=order.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
Point2 pos = anim_tree->node_get_pos(E->get());
- if (click_type==CLICK_NODE && click_node==E->get()) {
+ if (click_type == CLICK_NODE && click_node == E->get()) {
- pos+=click_motion-click_pos;
+ pos += click_motion - click_pos;
}
- pos+=get_node_size(E->get());
- if (pos.x>max.x)
- max.x=pos.x;
- if (pos.y>max.y)
- max.y=pos.y;
-
+ pos += get_node_size(E->get());
+ if (pos.x > max.x)
+ max.x = pos.x;
+ if (pos.y > max.y)
+ max.y = pos.y;
}
return max;
}
+const char *AnimationTreeEditor::_node_type_names[] = { "Output", "Animation", "OneShot", "Mix", "Blend2", "Blend3", "Blend4", "TimeScale", "TimeSeek", "Transition" };
-const char* AnimationTreeEditor::_node_type_names[]={"Output","Animation","OneShot","Mix","Blend2","Blend3","Blend4","TimeScale","TimeSeek","Transition"};
-
-Size2 AnimationTreeEditor::get_node_size(const StringName& p_node) const {
+Size2 AnimationTreeEditor::get_node_size(const StringName &p_node) const {
- AnimationTreePlayer::NodeType type=anim_tree->node_get_type(p_node);
+ AnimationTreePlayer::NodeType type = anim_tree->node_get_type(p_node);
- Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
- Ref<Font> font = get_font("font","PopupMenu");
+ Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
+ Ref<Font> font = get_font("font", "PopupMenu");
Size2 size = style->get_minimum_size();
- int count=2; // title and name
+ int count = 2; // title and name
int inputs = anim_tree->node_get_input_count(p_node);
- count += inputs?inputs:1;
+ count += inputs ? inputs : 1;
String name = p_node;
+ float name_w = font->get_string_size(name).width;
+ float type_w = font->get_string_size(String(_node_type_names[type])).width;
+ float max_w = MAX(name_w, type_w);
- float name_w = font->get_string_size( name ).width;
- float type_w = font->get_string_size( String(_node_type_names[type]) ).width;
- float max_w=MAX(name_w,type_w);
-
-
-
- switch(type) {
+ switch (type) {
case AnimationTreePlayer::NODE_TIMESEEK:
- case AnimationTreePlayer::NODE_OUTPUT: {} break;
+ case AnimationTreePlayer::NODE_OUTPUT: {
+ } break;
case AnimationTreePlayer::NODE_ANIMATION:
case AnimationTreePlayer::NODE_ONESHOT:
case AnimationTreePlayer::NODE_MIX:
@@ -117,19 +111,18 @@ Size2 AnimationTreeEditor::get_node_size(const StringName& p_node) const {
case AnimationTreePlayer::NODE_TIMESCALE:
case AnimationTreePlayer::NODE_TRANSITION: {
-
- size.height+=font->get_height();
+ size.height += font->get_height();
} break;
- case AnimationTreePlayer::NODE_MAX: {}
+ case AnimationTreePlayer::NODE_MAX: {
+ }
}
- size.x+=max_w+20;
- size.y+=count*(font->get_height()+get_constant("vseparation","PopupMenu"));
+ size.x += max_w + 20;
+ size.y += count * (font->get_height() + get_constant("vseparation", "PopupMenu"));
return size;
}
-
void AnimationTreeEditor::_edit_dialog_changede(String) {
edit_dialog->hide();
@@ -152,69 +145,67 @@ void AnimationTreeEditor::_edit_dialog_changed() {
if (renaming_edit) {
- if (anim_tree->node_rename(edited_node,edit_line[0]->get_text())==OK) {
- for(List<StringName>::Element* E=order.front();E;E=E->next()) {
+ if (anim_tree->node_rename(edited_node, edit_line[0]->get_text()) == OK) {
+ for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
if (E->get() == edited_node)
- E->get()=edit_line[0]->get_text();
+ E->get() = edit_line[0]->get_text();
}
- edited_node=edit_line[0]->get_text();
+ edited_node = edit_line[0]->get_text();
}
update();
return;
}
- AnimationTreePlayer::NodeType type=anim_tree->node_get_type(edited_node);
+ AnimationTreePlayer::NodeType type = anim_tree->node_get_type(edited_node);
- switch(type) {
+ switch (type) {
- case AnimationTreePlayer::NODE_TIMESCALE:
- anim_tree->timescale_node_set_scale(edited_node,edit_line[0]->get_text().to_double());
+ case AnimationTreePlayer::NODE_TIMESCALE:
+ anim_tree->timescale_node_set_scale(edited_node, edit_line[0]->get_text().to_double());
break;
- case AnimationTreePlayer::NODE_ONESHOT:
- anim_tree->oneshot_node_set_fadein_time(edited_node,edit_line[0]->get_text().to_double());
- anim_tree->oneshot_node_set_fadeout_time(edited_node,edit_line[1]->get_text().to_double());
- anim_tree->oneshot_node_set_autorestart_delay(edited_node,edit_line[2]->get_text().to_double());
- anim_tree->oneshot_node_set_autorestart_random_delay(edited_node,edit_line[3]->get_text().to_double());
- anim_tree->oneshot_node_set_autorestart(edited_node,edit_check->is_pressed());
- anim_tree->oneshot_node_set_mix_mode(edited_node,edit_option->get_selected());
+ case AnimationTreePlayer::NODE_ONESHOT:
+ anim_tree->oneshot_node_set_fadein_time(edited_node, edit_line[0]->get_text().to_double());
+ anim_tree->oneshot_node_set_fadeout_time(edited_node, edit_line[1]->get_text().to_double());
+ anim_tree->oneshot_node_set_autorestart_delay(edited_node, edit_line[2]->get_text().to_double());
+ anim_tree->oneshot_node_set_autorestart_random_delay(edited_node, edit_line[3]->get_text().to_double());
+ anim_tree->oneshot_node_set_autorestart(edited_node, edit_check->is_pressed());
+ anim_tree->oneshot_node_set_mix_mode(edited_node, edit_option->get_selected());
break;
- case AnimationTreePlayer::NODE_MIX:
+ case AnimationTreePlayer::NODE_MIX:
- anim_tree->mix_node_set_amount(edited_node,edit_scroll[0]->get_value());
- break;
- case AnimationTreePlayer::NODE_BLEND2:
- anim_tree->blend2_node_set_amount(edited_node,edit_scroll[0]->get_value());
+ anim_tree->mix_node_set_amount(edited_node, edit_scroll[0]->get_value());
+ break;
+ case AnimationTreePlayer::NODE_BLEND2:
+ anim_tree->blend2_node_set_amount(edited_node, edit_scroll[0]->get_value());
- break;
+ break;
- case AnimationTreePlayer::NODE_BLEND3:
- anim_tree->blend3_node_set_amount(edited_node,edit_scroll[0]->get_value());
+ case AnimationTreePlayer::NODE_BLEND3:
+ anim_tree->blend3_node_set_amount(edited_node, edit_scroll[0]->get_value());
- break;
+ break;
case AnimationTreePlayer::NODE_BLEND4:
- anim_tree->blend4_node_set_amount(edited_node,Point2(edit_scroll[0]->get_value(),edit_scroll[1]->get_value()));
+ anim_tree->blend4_node_set_amount(edited_node, Point2(edit_scroll[0]->get_value(), edit_scroll[1]->get_value()));
break;
- case AnimationTreePlayer::NODE_TRANSITION: {
- anim_tree->transition_node_set_xfade_time(edited_node,edit_line[0]->get_text().to_double());
- if (anim_tree->transition_node_get_current(edited_node)!=edit_option->get_selected())
- anim_tree->transition_node_set_current(edited_node,edit_option->get_selected());
+ case AnimationTreePlayer::NODE_TRANSITION: {
+ anim_tree->transition_node_set_xfade_time(edited_node, edit_line[0]->get_text().to_double());
+ if (anim_tree->transition_node_get_current(edited_node) != edit_option->get_selected())
+ anim_tree->transition_node_set_current(edited_node, edit_option->get_selected());
} break;
default: {}
}
-
}
void AnimationTreeEditor::_edit_dialog_animation_changed() {
-
Ref<Animation> anim = property_editor->get_variant().operator RefPtr();
- anim_tree->animation_node_set_animation(edited_node,anim);
+ anim_tree->animation_node_set_animation(edited_node, anim);
update();
}
@@ -235,26 +226,26 @@ void AnimationTreeEditor::_play_toggled() {
anim_tree->set_active(play_button->is_pressed());
}
-
void AnimationTreeEditor::_master_anim_menu_item(int p_item) {
- if(p_item == 0) _edit_filters();
+ if (p_item == 0)
+ _edit_filters();
else {
String str = master_anim_popup->get_item_text(p_item);
- anim_tree->animation_node_set_master_animation(edited_node,str);
+ anim_tree->animation_node_set_master_animation(edited_node, str);
}
update();
}
void AnimationTreeEditor::_popup_edit_dialog() {
- updating_edit=true;
+ updating_edit = true;
- for(int i=0;i<2;i++)
+ for (int i = 0; i < 2; i++)
edit_scroll[i]->hide();
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
edit_line[i]->hide();
edit_label[i]->hide();
@@ -265,32 +256,31 @@ void AnimationTreeEditor::_popup_edit_dialog() {
filter_button->hide();
edit_check->hide();
- Point2 pos = anim_tree->node_get_pos(edited_node)-Point2(h_scroll->get_value(),v_scroll->get_value());
- Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
+ Point2 pos = anim_tree->node_get_pos(edited_node) - Point2(h_scroll->get_value(), v_scroll->get_value());
+ Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
Size2 size = get_node_size(edited_node);
- Point2 popup_pos( pos.x+style->get_margin(MARGIN_LEFT), pos.y+size.y-style->get_margin(MARGIN_BOTTOM));
- popup_pos+=get_global_pos();
+ Point2 popup_pos(pos.x + style->get_margin(MARGIN_LEFT), pos.y + size.y - style->get_margin(MARGIN_BOTTOM));
+ popup_pos += get_global_pos();
if (renaming_edit) {
edit_label[0]->set_text(TTR("New name:"));
- edit_label[0]->set_pos(Point2(5,5));
+ edit_label[0]->set_pos(Point2(5, 5));
edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15,25));
+ edit_line[0]->set_begin(Point2(15, 25));
edit_line[0]->set_text(edited_node);
edit_line[0]->show();
- edit_dialog->set_size(Size2(150,50));
+ edit_dialog->set_size(Size2(150, 50));
} else {
- AnimationTreePlayer::NodeType type=anim_tree->node_get_type(edited_node);
+ AnimationTreePlayer::NodeType type = anim_tree->node_get_type(edited_node);
-
- switch(type) {
+ switch (type) {
case AnimationTreePlayer::NODE_ANIMATION:
- if (anim_tree->get_master_player()!=NodePath() && anim_tree->has_node(anim_tree->get_master_player()) && anim_tree->get_node(anim_tree->get_master_player())->cast_to<AnimationPlayer>()) {
+ if (anim_tree->get_master_player() != NodePath() && anim_tree->has_node(anim_tree->get_master_player()) && anim_tree->get_node(anim_tree->get_master_player())->cast_to<AnimationPlayer>()) {
AnimationPlayer *ap = anim_tree->get_node(anim_tree->get_master_player())->cast_to<AnimationPlayer>();
master_anim_popup->clear();
@@ -299,302 +289,293 @@ void AnimationTreeEditor::_popup_edit_dialog() {
List<StringName> sn;
ap->get_animation_list(&sn);
sn.sort_custom<StringName::AlphCompare>();
- for (List<StringName>::Element *E=sn.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = sn.front(); E; E = E->next()) {
master_anim_popup->add_item(E->get());
}
master_anim_popup->set_pos(popup_pos);
master_anim_popup->popup();
} else {
- property_editor->edit(this,"",Variant::OBJECT,anim_tree->animation_node_get_animation(edited_node),PROPERTY_HINT_RESOURCE_TYPE,"Animation");
+ property_editor->edit(this, "", Variant::OBJECT, anim_tree->animation_node_get_animation(edited_node), PROPERTY_HINT_RESOURCE_TYPE, "Animation");
property_editor->set_pos(popup_pos);
property_editor->popup();
- updating_edit=false;
+ updating_edit = false;
}
return;
- case AnimationTreePlayer::NODE_TIMESCALE:
+ case AnimationTreePlayer::NODE_TIMESCALE:
edit_label[0]->set_text(TTR("Scale:"));
- edit_label[0]->set_pos(Point2(5,5));
+ edit_label[0]->set_pos(Point2(5, 5));
edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15,25));
+ edit_line[0]->set_begin(Point2(15, 25));
edit_line[0]->set_text(rtos(anim_tree->timescale_node_get_scale(edited_node)));
edit_line[0]->show();
- edit_dialog->set_size(Size2(150,50));
+ edit_dialog->set_size(Size2(150, 50));
break;
- case AnimationTreePlayer::NODE_ONESHOT:
+ case AnimationTreePlayer::NODE_ONESHOT:
edit_label[0]->set_text(TTR("Fade In (s):"));
- edit_label[0]->set_pos(Point2(5,5));
+ edit_label[0]->set_pos(Point2(5, 5));
edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15,25));
+ edit_line[0]->set_begin(Point2(15, 25));
edit_line[0]->set_text(rtos(anim_tree->oneshot_node_get_fadein_time(edited_node)));
edit_line[0]->show();
edit_label[1]->set_text(TTR("Fade Out (s):"));
- edit_label[1]->set_pos(Point2(5,55));
+ edit_label[1]->set_pos(Point2(5, 55));
edit_label[1]->show();
- edit_line[1]->set_begin(Point2(15,75));
+ edit_line[1]->set_begin(Point2(15, 75));
edit_line[1]->set_text(rtos(anim_tree->oneshot_node_get_fadeout_time(edited_node)));
edit_line[1]->show();
edit_option->clear();
- edit_option->add_item(TTR("Blend"),0);
- edit_option->add_item(TTR("Mix"),1);
- edit_option->set_begin(Point2(15,105));
+ edit_option->add_item(TTR("Blend"), 0);
+ edit_option->add_item(TTR("Mix"), 1);
+ edit_option->set_begin(Point2(15, 105));
- edit_option->select( anim_tree->oneshot_node_get_mix_mode(edited_node));
+ edit_option->select(anim_tree->oneshot_node_get_mix_mode(edited_node));
edit_option->show();
edit_check->set_text(TTR("Auto Restart:"));
- edit_check->set_begin(Point2(15,125));
+ edit_check->set_begin(Point2(15, 125));
edit_check->set_pressed(anim_tree->oneshot_node_has_autorestart(edited_node));
edit_check->show();
edit_label[2]->set_text(TTR("Restart (s):"));
- edit_label[2]->set_pos(Point2(5,145));
+ edit_label[2]->set_pos(Point2(5, 145));
edit_label[2]->show();
- edit_line[2]->set_begin(Point2(15,165));
+ edit_line[2]->set_begin(Point2(15, 165));
edit_line[2]->set_text(rtos(anim_tree->oneshot_node_get_autorestart_delay(edited_node)));
edit_line[2]->show();
edit_label[3]->set_text(TTR("Random Restart (s):"));
- edit_label[3]->set_pos(Point2(5,195));
+ edit_label[3]->set_pos(Point2(5, 195));
edit_label[3]->show();
- edit_line[3]->set_begin(Point2(15,215));
+ edit_line[3]->set_begin(Point2(15, 215));
edit_line[3]->set_text(rtos(anim_tree->oneshot_node_get_autorestart_random_delay(edited_node)));
edit_line[3]->show();
- filter_button->set_begin(Point2(10,245));
+ filter_button->set_begin(Point2(10, 245));
filter_button->show();
- edit_button->set_begin(Point2(10,268));
+ edit_button->set_begin(Point2(10, 268));
edit_button->set_text(TTR("Start!"));
edit_button->show();
- edit_dialog->set_size(Size2(180,293));
+ edit_dialog->set_size(Size2(180, 293));
+
+ break;
+
+ case AnimationTreePlayer::NODE_MIX:
+
+ edit_label[0]->set_text(TTR("Amount:"));
+ edit_label[0]->set_pos(Point2(5, 5));
+ edit_label[0]->show();
+ edit_scroll[0]->set_min(0);
+ edit_scroll[0]->set_max(1);
+ edit_scroll[0]->set_value(anim_tree->mix_node_get_amount(edited_node));
+ edit_scroll[0]->set_begin(Point2(15, 25));
+ edit_scroll[0]->show();
+ edit_dialog->set_size(Size2(150, 50));
break;
+ case AnimationTreePlayer::NODE_BLEND2:
+ edit_label[0]->set_text(TTR("Blend:"));
+ edit_label[0]->set_pos(Point2(5, 5));
+ edit_label[0]->show();
+ edit_scroll[0]->set_min(0);
+ edit_scroll[0]->set_max(1);
+ edit_scroll[0]->set_value(anim_tree->blend2_node_get_amount(edited_node));
+ edit_scroll[0]->set_begin(Point2(15, 25));
+ edit_scroll[0]->show();
+ filter_button->set_begin(Point2(10, 47));
+ filter_button->show();
+ edit_dialog->set_size(Size2(150, 74));
- case AnimationTreePlayer::NODE_MIX:
-
- edit_label[0]->set_text(TTR("Amount:"));
- edit_label[0]->set_pos(Point2(5,5));
- edit_label[0]->show();
- edit_scroll[0]->set_min(0);
- edit_scroll[0]->set_max(1);
- edit_scroll[0]->set_value(anim_tree->mix_node_get_amount(edited_node));
- edit_scroll[0]->set_begin(Point2(15,25));
- edit_scroll[0]->show();
- edit_dialog->set_size(Size2(150,50));
-
- break;
- case AnimationTreePlayer::NODE_BLEND2:
- edit_label[0]->set_text(TTR("Blend:"));
- edit_label[0]->set_pos(Point2(5,5));
- edit_label[0]->show();
- edit_scroll[0]->set_min(0);
- edit_scroll[0]->set_max(1);
- edit_scroll[0]->set_value(anim_tree->blend2_node_get_amount(edited_node));
- edit_scroll[0]->set_begin(Point2(15,25));
- edit_scroll[0]->show();
- filter_button->set_begin(Point2(10,47));
- filter_button->show();
- edit_dialog->set_size(Size2(150,74));
-
- break;
-
- case AnimationTreePlayer::NODE_BLEND3:
- edit_label[0]->set_text(TTR("Blend:"));
- edit_label[0]->set_pos(Point2(5,5));
- edit_label[0]->show();
- edit_scroll[0]->set_min(-1);
- edit_scroll[0]->set_max(1);
- edit_scroll[0]->set_value(anim_tree->blend3_node_get_amount(edited_node));
- edit_scroll[0]->set_begin(Point2(15,25));
- edit_scroll[0]->show();
- edit_dialog->set_size(Size2(150,50));
-
- break;
+ break;
+
+ case AnimationTreePlayer::NODE_BLEND3:
+ edit_label[0]->set_text(TTR("Blend:"));
+ edit_label[0]->set_pos(Point2(5, 5));
+ edit_label[0]->show();
+ edit_scroll[0]->set_min(-1);
+ edit_scroll[0]->set_max(1);
+ edit_scroll[0]->set_value(anim_tree->blend3_node_get_amount(edited_node));
+ edit_scroll[0]->set_begin(Point2(15, 25));
+ edit_scroll[0]->show();
+ edit_dialog->set_size(Size2(150, 50));
+
+ break;
case AnimationTreePlayer::NODE_BLEND4:
edit_label[0]->set_text(TTR("Blend 0:"));
- edit_label[0]->set_pos(Point2(5,5));
+ edit_label[0]->set_pos(Point2(5, 5));
edit_label[0]->show();
edit_scroll[0]->set_min(0);
edit_scroll[0]->set_max(1);
edit_scroll[0]->set_value(anim_tree->blend4_node_get_amount(edited_node).x);
- edit_scroll[0]->set_begin(Point2(15,25));
+ edit_scroll[0]->set_begin(Point2(15, 25));
edit_scroll[0]->show();
edit_label[1]->set_text(TTR("Blend 1:"));
- edit_label[1]->set_pos(Point2(5,55));
+ edit_label[1]->set_pos(Point2(5, 55));
edit_label[1]->show();
edit_scroll[1]->set_min(0);
edit_scroll[1]->set_max(1);
edit_scroll[1]->set_value(anim_tree->blend4_node_get_amount(edited_node).y);
- edit_scroll[1]->set_begin(Point2(15,75));
+ edit_scroll[1]->set_begin(Point2(15, 75));
edit_scroll[1]->show();
- edit_dialog->set_size(Size2(150,100));
+ edit_dialog->set_size(Size2(150, 100));
break;
- case AnimationTreePlayer::NODE_TRANSITION: {
-
+ case AnimationTreePlayer::NODE_TRANSITION: {
- edit_label[0]->set_text(TTR("X-Fade Time (s):"));
- edit_label[0]->set_pos(Point2(5,5));
- edit_label[0]->show();
- edit_line[0]->set_begin(Point2(15,25));
- edit_line[0]->set_text(rtos(anim_tree->transition_node_get_xfade_time(edited_node)));
- edit_line[0]->show();
+ edit_label[0]->set_text(TTR("X-Fade Time (s):"));
+ edit_label[0]->set_pos(Point2(5, 5));
+ edit_label[0]->show();
+ edit_line[0]->set_begin(Point2(15, 25));
+ edit_line[0]->set_text(rtos(anim_tree->transition_node_get_xfade_time(edited_node)));
+ edit_line[0]->show();
- edit_label[1]->set_text(TTR("Current:"));
- edit_label[1]->set_pos(Point2(5,55));
- edit_label[1]->show();
- edit_option->set_begin(Point2(15,75));
+ edit_label[1]->set_text(TTR("Current:"));
+ edit_label[1]->set_pos(Point2(5, 55));
+ edit_label[1]->show();
+ edit_option->set_begin(Point2(15, 75));
- edit_option->clear();
+ edit_option->clear();
- for(int i=0;i<anim_tree->transition_node_get_input_count(edited_node);i++) {
- edit_option->add_item(itos(i),i);
- }
+ for (int i = 0; i < anim_tree->transition_node_get_input_count(edited_node); i++) {
+ edit_option->add_item(itos(i), i);
+ }
- edit_option->select(anim_tree->transition_node_get_current(edited_node));
- edit_option->show();
- edit_dialog->set_size(Size2(150,100));
+ edit_option->select(anim_tree->transition_node_get_current(edited_node));
+ edit_option->show();
+ edit_dialog->set_size(Size2(150, 100));
} break;
default: {}
-
}
-
}
-
-
edit_dialog->set_pos(popup_pos);
edit_dialog->popup();
- updating_edit=false;
+ updating_edit = false;
}
-void AnimationTreeEditor::_draw_node(const StringName& p_node) {
+void AnimationTreeEditor::_draw_node(const StringName &p_node) {
RID ci = get_canvas_item();
- AnimationTreePlayer::NodeType type=anim_tree->node_get_type(p_node);
-
- Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
- Ref<Font> font = get_font("font","PopupMenu");
- Color font_color = get_color("font_color","PopupMenu");
- Color font_color_title = get_color("font_color_hover","PopupMenu");
- font_color_title.a*=0.8;
- Ref<Texture> slot_icon = get_icon("NodeRealSlot","EditorIcons");
+ AnimationTreePlayer::NodeType type = anim_tree->node_get_type(p_node);
+ Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
+ Ref<Font> font = get_font("font", "PopupMenu");
+ Color font_color = get_color("font_color", "PopupMenu");
+ Color font_color_title = get_color("font_color_hover", "PopupMenu");
+ font_color_title.a *= 0.8;
+ Ref<Texture> slot_icon = get_icon("NodeRealSlot", "EditorIcons");
- Size2 size=get_node_size(p_node);
+ Size2 size = get_node_size(p_node);
Point2 pos = anim_tree->node_get_pos(p_node);
- if (click_type==CLICK_NODE && click_node==p_node) {
-
- pos+=click_motion-click_pos;
- if (pos.x<5)
- pos.x=5;
- if (pos.y<5)
- pos.y=5;
+ if (click_type == CLICK_NODE && click_node == p_node) {
+ pos += click_motion - click_pos;
+ if (pos.x < 5)
+ pos.x = 5;
+ if (pos.y < 5)
+ pos.y = 5;
}
- pos-=Point2(h_scroll->get_value(),v_scroll->get_value());
+ pos -= Point2(h_scroll->get_value(), v_scroll->get_value());
- style->draw(ci,Rect2(pos,size));
+ style->draw(ci, Rect2(pos, size));
- float w = size.width-style->get_minimum_size().width;
- float h = font->get_height()+get_constant("vseparation","PopupMenu");
+ float w = size.width - style->get_minimum_size().width;
+ float h = font->get_height() + get_constant("vseparation", "PopupMenu");
- Point2 ofs=style->get_offset()+pos;
- Point2 ascofs(0,font->get_ascent());
+ Point2 ofs = style->get_offset() + pos;
+ Point2 ascofs(0, font->get_ascent());
Color bx = font_color_title;
- bx.a*=0.1;
- draw_rect(Rect2(ofs,Size2(size.width-style->get_minimum_size().width,font->get_height())),bx);
- font->draw_halign(ci,ofs+ascofs,HALIGN_CENTER,w,String(_node_type_names[type]),font_color_title);
+ bx.a *= 0.1;
+ draw_rect(Rect2(ofs, Size2(size.width - style->get_minimum_size().width, font->get_height())), bx);
+ font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, String(_node_type_names[type]), font_color_title);
- ofs.y+=h;
- font->draw_halign(ci,ofs+ascofs,HALIGN_CENTER,w,p_node,font_color);
- ofs.y+=h;
+ ofs.y += h;
+ font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, p_node, font_color);
+ ofs.y += h;
- int count=2; // title and name
+ int count = 2; // title and name
int inputs = anim_tree->node_get_input_count(p_node);
- count += inputs?inputs:1;
+ count += inputs ? inputs : 1;
- float icon_h_ofs = Math::floor(( font->get_height()-slot_icon->get_height())/2.0 )+1;
+ float icon_h_ofs = Math::floor((font->get_height() - slot_icon->get_height()) / 2.0) + 1;
- if (type!=AnimationTreePlayer::NODE_OUTPUT)
- slot_icon->draw(ci,ofs+Point2(w,icon_h_ofs)); //output
+ if (type != AnimationTreePlayer::NODE_OUTPUT)
+ slot_icon->draw(ci, ofs + Point2(w, icon_h_ofs)); //output
if (inputs) {
- for(int i=0;i<inputs;i++) {
+ for (int i = 0; i < inputs; i++) {
- slot_icon->draw(ci,ofs+Point2(-slot_icon->get_width(),icon_h_ofs));
+ slot_icon->draw(ci, ofs + Point2(-slot_icon->get_width(), icon_h_ofs));
String text;
- switch(type) {
-
- case AnimationTreePlayer::NODE_TIMESCALE:
- case AnimationTreePlayer::NODE_TIMESEEK: text="in"; break;
- case AnimationTreePlayer::NODE_OUTPUT: text="out"; break;
- case AnimationTreePlayer::NODE_ANIMATION: break;
- case AnimationTreePlayer::NODE_ONESHOT: text=(i==0?"in":"add"); break;
- case AnimationTreePlayer::NODE_BLEND2:
- case AnimationTreePlayer::NODE_MIX: text=(i==0?"a":"b"); break;
- case AnimationTreePlayer::NODE_BLEND3:
- switch(i) {
- case 0: text="b-"; break;
- case 1: text="a"; break;
- case 2: text="b+"; break;
-
- }
- break;
-
-
- case AnimationTreePlayer::NODE_BLEND4:
- switch(i) {
- case 0: text="a0"; break;
- case 1: text="b0"; break;
- case 2: text="a1"; break;
- case 3: text="b1"; break;
- }
- break;
-
- case AnimationTreePlayer::NODE_TRANSITION:
- text=itos(i);
- if (anim_tree->transition_node_has_input_auto_advance(p_node,i))
- text+="->";
-
- break;
- default: {}
+ switch (type) {
+
+ case AnimationTreePlayer::NODE_TIMESCALE:
+ case AnimationTreePlayer::NODE_TIMESEEK: text = "in"; break;
+ case AnimationTreePlayer::NODE_OUTPUT: text = "out"; break;
+ case AnimationTreePlayer::NODE_ANIMATION: break;
+ case AnimationTreePlayer::NODE_ONESHOT: text = (i == 0 ? "in" : "add"); break;
+ case AnimationTreePlayer::NODE_BLEND2:
+ case AnimationTreePlayer::NODE_MIX: text = (i == 0 ? "a" : "b"); break;
+ case AnimationTreePlayer::NODE_BLEND3:
+ switch (i) {
+ case 0: text = "b-"; break;
+ case 1: text = "a"; break;
+ case 2: text = "b+"; break;
+ }
+ break;
+
+ case AnimationTreePlayer::NODE_BLEND4:
+ switch (i) {
+ case 0: text = "a0"; break;
+ case 1: text = "b0"; break;
+ case 2: text = "a1"; break;
+ case 3: text = "b1"; break;
+ }
+ break;
+
+ case AnimationTreePlayer::NODE_TRANSITION:
+ text = itos(i);
+ if (anim_tree->transition_node_has_input_auto_advance(p_node, i))
+ text += "->";
+
+ break;
+ default: {}
}
- font->draw(ci,ofs+ascofs+Point2(3,0),text,font_color);
+ font->draw(ci, ofs + ascofs + Point2(3, 0), text, font_color);
- ofs.y+=h;
+ ofs.y += h;
}
} else {
- ofs.y+=h;
+ ofs.y += h;
}
- Ref<StyleBox> pg_bg=get_stylebox("bg","ProgressBar");
- Ref<StyleBox> pg_fill=get_stylebox("fill","ProgressBar");
- Rect2 pg_rect(ofs,Size2(w,h));
+ Ref<StyleBox> pg_bg = get_stylebox("bg", "ProgressBar");
+ Ref<StyleBox> pg_fill = get_stylebox("fill", "ProgressBar");
+ Rect2 pg_rect(ofs, Size2(w, h));
- bool editable=true;
- switch(type) {
+ bool editable = true;
+ switch (type) {
case AnimationTreePlayer::NODE_ANIMATION: {
Ref<Animation> anim = anim_tree->animation_node_get_animation(p_node);
String text;
- if (anim_tree->animation_node_get_master_animation(p_node)!="")
- text=anim_tree->animation_node_get_master_animation(p_node);
+ if (anim_tree->animation_node_get_master_animation(p_node) != "")
+ text = anim_tree->animation_node_get_master_animation(p_node);
else if (anim.is_null())
- text="load..";
+ text = "load..";
else
- text=anim->get_name();
+ text = anim->get_name();
- font->draw_halign(ci,ofs+ascofs,HALIGN_CENTER,w,text,font_color_title);
+ font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, text, font_color_title);
} break;
case AnimationTreePlayer::NODE_ONESHOT:
@@ -605,16 +586,16 @@ void AnimationTreeEditor::_draw_node(const StringName& p_node) {
case AnimationTreePlayer::NODE_TIMESCALE:
case AnimationTreePlayer::NODE_TRANSITION: {
- font->draw_halign(ci,ofs+ascofs,HALIGN_CENTER,w,"edit..",font_color_title);
+ font->draw_halign(ci, ofs + ascofs, HALIGN_CENTER, w, "edit..", font_color_title);
} break;
- default: editable=false;
+ default: editable = false;
}
if (editable) {
- Ref<Texture> arrow = get_icon("arrow","Tree");
- Point2 arrow_ofs( w-arrow->get_width(),Math::floor( (h-arrow->get_height())/2) );
- arrow->draw(ci,ofs+arrow_ofs);
+ Ref<Texture> arrow = get_icon("arrow", "Tree");
+ Point2 arrow_ofs(w - arrow->get_width(), Math::floor((h - arrow->get_height()) / 2));
+ arrow->draw(ci, ofs + arrow_ofs);
}
}
@@ -627,110 +608,104 @@ void AnimationTreeEditor::_node_param_changed() {
}
#endif
-AnimationTreeEditor::ClickType AnimationTreeEditor::_locate_click(const Point2& p_click,StringName *p_node_id,int *p_slot_index) const {
-
+AnimationTreeEditor::ClickType AnimationTreeEditor::_locate_click(const Point2 &p_click, StringName *p_node_id, int *p_slot_index) const {
- Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
- Ref<Font> font = get_font("font","PopupMenu");
+ Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
+ Ref<Font> font = get_font("font", "PopupMenu");
- float h = (font->get_height()+get_constant("vseparation","PopupMenu"));
+ float h = (font->get_height() + get_constant("vseparation", "PopupMenu"));
- for(const List<StringName>::Element *E=order.back();E;E=E->prev()) {
+ for (const List<StringName>::Element *E = order.back(); E; E = E->prev()) {
StringName node = E->get();
- AnimationTreePlayer::NodeType type=anim_tree->node_get_type(node);
+ AnimationTreePlayer::NodeType type = anim_tree->node_get_type(node);
Point2 pos = anim_tree->node_get_pos(node);
Size2 size = get_node_size(node);
- pos-=Point2(h_scroll->get_value(),v_scroll->get_value());
+ pos -= Point2(h_scroll->get_value(), v_scroll->get_value());
- if (!Rect2(pos,size).has_point(p_click))
+ if (!Rect2(pos, size).has_point(p_click))
continue;
if (p_node_id)
- *p_node_id=node;
+ *p_node_id = node;
- pos=p_click-pos;
+ pos = p_click - pos;
- float y = pos.y-style->get_offset().height;
+ float y = pos.y - style->get_offset().height;
- if (y<2*h)
+ if (y < 2 * h)
return CLICK_NODE;
- y-=2*h;
+ y -= 2 * h;
int inputs = anim_tree->node_get_input_count(node);
- int count = MAX(inputs,1);
+ int count = MAX(inputs, 1);
- if (inputs==0 || (pos.x > size.width/2 && type != AnimationTreePlayer::NODE_OUTPUT)) {
+ if (inputs == 0 || (pos.x > size.width / 2 && type != AnimationTreePlayer::NODE_OUTPUT)) {
- if (y<count*h) {
+ if (y < count * h) {
if (p_slot_index)
- *p_slot_index=0;
+ *p_slot_index = 0;
return CLICK_OUTPUT_SLOT;
}
}
- for(int i=0;i<count;i++) {
+ for (int i = 0; i < count; i++) {
- if (y<h) {
+ if (y < h) {
if (p_slot_index)
- *p_slot_index=i;
+ *p_slot_index = i;
return CLICK_INPUT_SLOT;
}
- y-=h;
+ y -= h;
}
- bool has_parameters = type!=AnimationTreePlayer::NODE_OUTPUT && type!=AnimationTreePlayer::NODE_TIMESEEK;
+ bool has_parameters = type != AnimationTreePlayer::NODE_OUTPUT && type != AnimationTreePlayer::NODE_TIMESEEK;
return has_parameters ? CLICK_PARAMETER : CLICK_NODE;
}
return CLICK_NONE;
}
-Point2 AnimationTreeEditor::_get_slot_pos(const StringName& p_node,bool p_input,int p_slot) {
+Point2 AnimationTreeEditor::_get_slot_pos(const StringName &p_node, bool p_input, int p_slot) {
- Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
- Ref<Font> font = get_font("font","PopupMenu");
- Ref<Texture> slot_icon = get_icon("NodeRealSlot","EditorIcons");
+ Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
+ Ref<Font> font = get_font("font", "PopupMenu");
+ Ref<Texture> slot_icon = get_icon("NodeRealSlot", "EditorIcons");
- Size2 size=get_node_size(p_node);
+ Size2 size = get_node_size(p_node);
Point2 pos = anim_tree->node_get_pos(p_node);
- if (click_type==CLICK_NODE && click_node==p_node) {
-
- pos+=click_motion-click_pos;
- if (pos.x<5)
- pos.x=5;
- if (pos.y<5)
- pos.y=5;
+ if (click_type == CLICK_NODE && click_node == p_node) {
+ pos += click_motion - click_pos;
+ if (pos.x < 5)
+ pos.x = 5;
+ if (pos.y < 5)
+ pos.y = 5;
}
- pos-=Point2(h_scroll->get_value(),v_scroll->get_value());
+ pos -= Point2(h_scroll->get_value(), v_scroll->get_value());
+ float w = size.width - style->get_minimum_size().width;
+ float h = font->get_height() + get_constant("vseparation", "PopupMenu");
- float w = size.width-style->get_minimum_size().width;
- float h = font->get_height()+get_constant("vseparation","PopupMenu");
+ pos += style->get_offset();
+ pos.y += h * 2;
- pos+=style->get_offset();
+ pos.y += h * p_slot;
- pos.y+=h*2;
-
- pos.y+=h*p_slot;
-
- pos+=Point2( -slot_icon->get_width()/2.0, h/2.0).floor();
-
- if(!p_input) {
- pos.x+=w+slot_icon->get_width();
+ pos += Point2(-slot_icon->get_width() / 2.0, h / 2.0).floor();
+ if (!p_input) {
+ pos.x += w + slot_icon->get_width();
}
return pos;
-
}
#if 0
@@ -761,123 +736,117 @@ void AnimationTreeEditor::_node_edit_property(const StringName& p_node) {
void AnimationTreeEditor::_gui_input(InputEvent p_event) {
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
if (p_event.mouse_button.pressed) {
-
- if (p_event.mouse_button.button_index==1) {
- click_pos=Point2(p_event.mouse_button.x,p_event.mouse_button.y);
- click_motion=click_pos;
- click_type = _locate_click(click_pos,&click_node,&click_slot);
- if( click_type!=CLICK_NONE) {
+ if (p_event.mouse_button.button_index == 1) {
+ click_pos = Point2(p_event.mouse_button.x, p_event.mouse_button.y);
+ click_motion = click_pos;
+ click_type = _locate_click(click_pos, &click_node, &click_slot);
+ if (click_type != CLICK_NONE) {
order.erase(click_node);
order.push_back(click_node);
update();
}
- switch(click_type) {
+ switch (click_type) {
case CLICK_INPUT_SLOT: {
- click_pos=_get_slot_pos(click_node,true,click_slot);
+ click_pos = _get_slot_pos(click_node, true, click_slot);
} break;
case CLICK_OUTPUT_SLOT: {
- click_pos=_get_slot_pos(click_node,false,click_slot);
+ click_pos = _get_slot_pos(click_node, false, click_slot);
} break;
case CLICK_PARAMETER: {
- edited_node=click_node;
- renaming_edit=false;
+ edited_node = click_node;
+ renaming_edit = false;
_popup_edit_dialog();
//open editor
//_node_edit_property(click_node);
} break;
- default:{}
+ default: {}
}
}
- if (p_event.mouse_button.button_index==2) {
+ if (p_event.mouse_button.button_index == 2) {
- if (click_type!=CLICK_NONE) {
- click_type=CLICK_NONE;
+ if (click_type != CLICK_NONE) {
+ click_type = CLICK_NONE;
update();
} else {
// try to disconnect/remove
- Point2 rclick_pos=Point2(p_event.mouse_button.x,p_event.mouse_button.y);
- rclick_type = _locate_click(rclick_pos,&rclick_node,&rclick_slot);
- if (rclick_type==CLICK_INPUT_SLOT || rclick_type==CLICK_OUTPUT_SLOT) {
+ Point2 rclick_pos = Point2(p_event.mouse_button.x, p_event.mouse_button.y);
+ rclick_type = _locate_click(rclick_pos, &rclick_node, &rclick_slot);
+ if (rclick_type == CLICK_INPUT_SLOT || rclick_type == CLICK_OUTPUT_SLOT) {
node_popup->clear();
- node_popup->add_item(TTR("Disconnect"),NODE_DISCONNECT);
- if (anim_tree->node_get_type(rclick_node)==AnimationTreePlayer::NODE_TRANSITION) {
- node_popup->add_item(TTR("Add Input"),NODE_ADD_INPUT);
- if (rclick_type==CLICK_INPUT_SLOT) {
- if (anim_tree->transition_node_has_input_auto_advance(rclick_node,rclick_slot))
- node_popup->add_item(TTR("Clear Auto-Advance"),NODE_CLEAR_AUTOADVANCE);
+ node_popup->add_item(TTR("Disconnect"), NODE_DISCONNECT);
+ if (anim_tree->node_get_type(rclick_node) == AnimationTreePlayer::NODE_TRANSITION) {
+ node_popup->add_item(TTR("Add Input"), NODE_ADD_INPUT);
+ if (rclick_type == CLICK_INPUT_SLOT) {
+ if (anim_tree->transition_node_has_input_auto_advance(rclick_node, rclick_slot))
+ node_popup->add_item(TTR("Clear Auto-Advance"), NODE_CLEAR_AUTOADVANCE);
else
- node_popup->add_item(TTR("Set Auto-Advance"),NODE_SET_AUTOADVANCE);
- node_popup->add_item(TTR("Delete Input"),NODE_DELETE_INPUT);
-
+ node_popup->add_item(TTR("Set Auto-Advance"), NODE_SET_AUTOADVANCE);
+ node_popup->add_item(TTR("Delete Input"), NODE_DELETE_INPUT);
}
}
- node_popup->set_pos(rclick_pos+get_global_pos());
+ node_popup->set_pos(rclick_pos + get_global_pos());
node_popup->popup();
-
}
- if (rclick_type==CLICK_NODE) {
+ if (rclick_type == CLICK_NODE) {
node_popup->clear();
- node_popup->add_item(TTR("Rename"),NODE_RENAME);
- node_popup->add_item(TTR("Remove"),NODE_ERASE);
- if (anim_tree->node_get_type(rclick_node)==AnimationTreePlayer::NODE_TRANSITION)
- node_popup->add_item(TTR("Add Input"),NODE_ADD_INPUT);
- node_popup->set_pos(rclick_pos+get_global_pos());
+ node_popup->add_item(TTR("Rename"), NODE_RENAME);
+ node_popup->add_item(TTR("Remove"), NODE_ERASE);
+ if (anim_tree->node_get_type(rclick_node) == AnimationTreePlayer::NODE_TRANSITION)
+ node_popup->add_item(TTR("Add Input"), NODE_ADD_INPUT);
+ node_popup->set_pos(rclick_pos + get_global_pos());
node_popup->popup();
}
-
-
}
}
} else {
- if (p_event.mouse_button.button_index==1 && click_type!=CLICK_NONE) {
+ if (p_event.mouse_button.button_index == 1 && click_type != CLICK_NONE) {
- switch(click_type) {
+ switch (click_type) {
case CLICK_INPUT_SLOT:
case CLICK_OUTPUT_SLOT: {
- Point2 dst_click_pos=Point2(p_event.mouse_button.x,p_event.mouse_button.y);
+ Point2 dst_click_pos = Point2(p_event.mouse_button.x, p_event.mouse_button.y);
StringName id;
int slot;
- ClickType dst_click_type = _locate_click(dst_click_pos,&id,&slot);
+ ClickType dst_click_type = _locate_click(dst_click_pos, &id, &slot);
- if (dst_click_type==CLICK_INPUT_SLOT && click_type==CLICK_OUTPUT_SLOT) {
-
- anim_tree->connect_nodes(click_node,id,slot);
+ if (dst_click_type == CLICK_INPUT_SLOT && click_type == CLICK_OUTPUT_SLOT) {
+ anim_tree->connect_nodes(click_node, id, slot);
}
- if (click_type==CLICK_INPUT_SLOT && dst_click_type==CLICK_OUTPUT_SLOT) {
+ if (click_type == CLICK_INPUT_SLOT && dst_click_type == CLICK_OUTPUT_SLOT) {
- anim_tree->connect_nodes(id,click_node,click_slot);
+ anim_tree->connect_nodes(id, click_node, click_slot);
}
} break;
case CLICK_NODE: {
- Point2 new_pos = anim_tree->node_get_pos(click_node)+(click_motion-click_pos);
- if (new_pos.x<5)
- new_pos.x=5;
- if (new_pos.y<5)
- new_pos.y=5;
- anim_tree->node_set_pos(click_node,new_pos);
+ Point2 new_pos = anim_tree->node_get_pos(click_node) + (click_motion - click_pos);
+ if (new_pos.x < 5)
+ new_pos.x = 5;
+ if (new_pos.y < 5)
+ new_pos.y = 5;
+ anim_tree->node_set_pos(click_node, new_pos);
} break;
default: {}
}
- click_type=CLICK_NONE;
+ click_type = CLICK_NONE;
update();
}
}
@@ -885,89 +854,85 @@ void AnimationTreeEditor::_gui_input(InputEvent p_event) {
case InputEvent::MOUSE_MOTION: {
- if (p_event.mouse_motion.button_mask&1 && click_type!=CLICK_NONE) {
+ if (p_event.mouse_motion.button_mask & 1 && click_type != CLICK_NONE) {
- click_motion=Point2(p_event.mouse_button.x,p_event.mouse_button.y);
+ click_motion = Point2(p_event.mouse_button.x, p_event.mouse_button.y);
update();
}
- if ((p_event.mouse_motion.button_mask&4 || Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
+ if ((p_event.mouse_motion.button_mask & 4 || Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
- h_scroll->set_value( h_scroll->get_value() - p_event.mouse_motion.relative_x );
- v_scroll->set_value( v_scroll->get_value() - p_event.mouse_motion.relative_y );
+ h_scroll->set_value(h_scroll->get_value() - p_event.mouse_motion.relative_x);
+ v_scroll->set_value(v_scroll->get_value() - p_event.mouse_motion.relative_y);
update();
}
} break;
}
-
}
-
-void AnimationTreeEditor::_draw_cos_line(const Vector2& p_from, const Vector2& p_to,const Color& p_color) {
+void AnimationTreeEditor::_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) {
- draw_line(prev,p,p_color,2);
+ draw_line(prev, p, p_color, 2);
}
- prev=p;
+ prev = p;
}
}
void AnimationTreeEditor::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- play_button->set_icon( get_icon("Play","EditorIcons") );
- add_menu->set_icon( get_icon("Add","EditorIcons") );
+ play_button->set_icon(get_icon("Play", "EditorIcons"));
+ add_menu->set_icon(get_icon("Add", "EditorIcons"));
} break;
case NOTIFICATION_DRAW: {
-
_update_scrollbars();
//VisualServer::get_singleton()->canvas_item_add_rect(get_canvas_item(),Rect2(Point2(),get_size()),Color(0,0,0,1));
- get_stylebox("bg","Tree")->draw(get_canvas_item(),Rect2(Point2(),get_size()));
+ get_stylebox("bg", "Tree")->draw(get_canvas_item(), Rect2(Point2(), get_size()));
- for(List<StringName>::Element *E=order.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = order.front(); E; E = E->next()) {
_draw_node(E->get());
}
- if (click_type==CLICK_INPUT_SLOT || click_type==CLICK_OUTPUT_SLOT) {
+ if (click_type == CLICK_INPUT_SLOT || click_type == CLICK_OUTPUT_SLOT) {
- _draw_cos_line(click_pos,click_motion,Color(0.5,1,0.5,0.8));
+ _draw_cos_line(click_pos, click_motion, Color(0.5, 1, 0.5, 0.8));
}
List<AnimationTreePlayer::Connection> connections;
anim_tree->get_connection_list(&connections);
- for(List<AnimationTreePlayer::Connection>::Element *E=connections.front();E;E=E->next()) {
+ for (List<AnimationTreePlayer::Connection>::Element *E = connections.front(); E; E = E->next()) {
- const AnimationTreePlayer::Connection &c=E->get();
- Point2 source = _get_slot_pos(c.src_node,false,0);
- Point2 dest = _get_slot_pos(c.dst_node,true,c.dst_input);
- Color col = Color(1,1,0.5,0.8);
-/*
+ const AnimationTreePlayer::Connection &c = E->get();
+ Point2 source = _get_slot_pos(c.src_node, false, 0);
+ Point2 dest = _get_slot_pos(c.dst_node, true, c.dst_input);
+ Color col = Color(1, 1, 0.5, 0.8);
+ /*
if (click_type==CLICK_NODE && click_node==c.src_node) {
source+=click_motion-click_pos;
@@ -978,27 +943,25 @@ void AnimationTreeEditor::_notification(int p_what) {
dest+=click_motion-click_pos;
}*/
- _draw_cos_line(source,dest,col);
-
+ _draw_cos_line(source, dest, col);
}
- switch(anim_tree->get_last_error()) {
+ switch (anim_tree->get_last_error()) {
case AnimationTreePlayer::CONNECT_OK: {
- Ref<Font> f = get_font("font","Label");
- f->draw(get_canvas_item(),Point2(5,25+f->get_ascent()),TTR("Animation tree is valid."),Color(0,1,0.6,0.8));
+ Ref<Font> f = get_font("font", "Label");
+ f->draw(get_canvas_item(), Point2(5, 25 + f->get_ascent()), TTR("Animation tree is valid."), Color(0, 1, 0.6, 0.8));
} break;
default: {
- Ref<Font> f = get_font("font","Label");
- f->draw(get_canvas_item(),Point2(5,25+f->get_ascent()),TTR("Animation tree is invalid."),Color(1,0.6,0.0,0.8));
+ Ref<Font> f = get_font("font", "Label");
+ f->draw(get_canvas_item(), Point2(5, 25 + f->get_ascent()), TTR("Animation tree is invalid."), Color(1, 0.6, 0.0, 0.8));
} break;
}
} break;
}
-
}
void AnimationTreeEditor::_update_scrollbars() {
@@ -1007,72 +970,69 @@ void AnimationTreeEditor::_update_scrollbars() {
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, 0) );
- v_scroll->set_end( Point2(size.width, size.height) );
-
- 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, 0));
+ v_scroll->set_end(Point2(size.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_maximum_size();
if (min.height < size.height - hmin.height) {
v_scroll->hide();
- offset.y=0;
+ offset.y = 0;
} else {
v_scroll->show();
v_scroll->set_max(min.height);
v_scroll->set_page(size.height - hmin.height);
- offset.y=v_scroll->get_value();
+ offset.y = v_scroll->get_value();
}
if (min.width < size.width - vmin.width) {
h_scroll->hide();
- offset.x=0;
+ offset.x = 0;
} else {
h_scroll->show();
h_scroll->set_max(min.width);
h_scroll->set_page(size.width - vmin.width);
- offset.x=h_scroll->get_value();
+ offset.x = h_scroll->get_value();
}
}
void AnimationTreeEditor::_scroll_moved(float) {
- offset.x=h_scroll->get_value();
- offset.y=v_scroll->get_value();
+ offset.x = h_scroll->get_value();
+ offset.y = v_scroll->get_value();
update();
}
-
void AnimationTreeEditor::_node_menu_item(int p_item) {
- switch(p_item) {
+ switch (p_item) {
case NODE_DISCONNECT: {
- if (rclick_type==CLICK_INPUT_SLOT) {
+ if (rclick_type == CLICK_INPUT_SLOT) {
- anim_tree->disconnect_nodes(rclick_node,rclick_slot);
+ anim_tree->disconnect_nodes(rclick_node, rclick_slot);
update();
}
- if (rclick_type==CLICK_OUTPUT_SLOT) {
-
+ if (rclick_type == CLICK_OUTPUT_SLOT) {
List<AnimationTreePlayer::Connection> connections;
anim_tree->get_connection_list(&connections);
- for(List<AnimationTreePlayer::Connection>::Element *E=connections.front();E;E=E->next()) {
+ for (List<AnimationTreePlayer::Connection>::Element *E = connections.front(); E; E = E->next()) {
- const AnimationTreePlayer::Connection &c=E->get();
- if( c.dst_node==rclick_node) {
+ const AnimationTreePlayer::Connection &c = E->get();
+ if (c.dst_node == rclick_node) {
- anim_tree->disconnect_nodes(c.dst_node,c.dst_input);
+ anim_tree->disconnect_nodes(c.dst_node, c.dst_input);
}
}
update();
@@ -1081,37 +1041,37 @@ void AnimationTreeEditor::_node_menu_item(int p_item) {
} break;
case NODE_RENAME: {
- renaming_edit=true;
- edited_node=rclick_node;
+ renaming_edit = true;
+ edited_node = rclick_node;
_popup_edit_dialog();
} break;
case NODE_ADD_INPUT: {
- anim_tree->transition_node_set_input_count(rclick_node, anim_tree->transition_node_get_input_count(rclick_node)+1);
+ anim_tree->transition_node_set_input_count(rclick_node, anim_tree->transition_node_get_input_count(rclick_node) + 1);
update();
} break;
- case NODE_DELETE_INPUT: {
+ case NODE_DELETE_INPUT: {
- anim_tree->transition_node_delete_input(rclick_node, rclick_slot);
- update();
- } break;
+ anim_tree->transition_node_delete_input(rclick_node, rclick_slot);
+ update();
+ } break;
case NODE_SET_AUTOADVANCE: {
- anim_tree->transition_node_set_input_auto_advance(rclick_node,rclick_slot,true);
+ anim_tree->transition_node_set_input_auto_advance(rclick_node, rclick_slot, true);
update();
} break;
- case NODE_CLEAR_AUTOADVANCE: {
+ case NODE_CLEAR_AUTOADVANCE: {
- anim_tree->transition_node_set_input_auto_advance(rclick_node,rclick_slot,false);
+ anim_tree->transition_node_set_input_auto_advance(rclick_node, rclick_slot, false);
update();
} break;
case NODE_ERASE: {
- if (rclick_node=="out")
+ if (rclick_node == "out")
break;
order.erase(rclick_node);
anim_tree->remove_node(rclick_node);
@@ -1122,7 +1082,7 @@ void AnimationTreeEditor::_node_menu_item(int p_item) {
StringName AnimationTreeEditor::_add_node(int p_item) {
- static const char* bname[] = {
+ static const char *bname[] = {
"out",
"anim",
"oneshot",
@@ -1136,27 +1096,26 @@ StringName AnimationTreeEditor::_add_node(int p_item) {
};
String name;
- int idx=1;
+ int idx = 1;
- while(true) {
+ while (true) {
name = bname[p_item];
- if (idx>1)
- name+=" "+itos(idx);
+ if (idx > 1)
+ name += " " + itos(idx);
if (anim_tree->node_exists(name))
idx++;
else
break;
}
-
- anim_tree->add_node((AnimationTreePlayer::NodeType)p_item,name);
- anim_tree->node_set_pos(name,Point2(last_x,last_y));
+ anim_tree->add_node((AnimationTreePlayer::NodeType)p_item, name);
+ anim_tree->node_set_pos(name, Point2(last_x, last_y));
order.push_back(name);
- last_x+=10;
- last_y+=10;
- last_x=last_x % (int)get_size().width;
- last_y=last_y % (int)get_size().height;
+ last_x += 10;
+ last_y += 10;
+ last_x = last_x % (int)get_size().width;
+ last_y = last_y % (int)get_size().height;
update();
return name;
@@ -1166,27 +1125,27 @@ void AnimationTreeEditor::_file_dialog_selected(String p_path) {
switch (file_op) {
- case MENU_IMPORT_ANIMATIONS: {
- Vector<String> files = file_dialog->get_selected_files();
+ case MENU_IMPORT_ANIMATIONS: {
+ Vector<String> files = file_dialog->get_selected_files();
- for (int i=0; i<files.size(); i++) {
+ for (int i = 0; i < files.size(); i++) {
- StringName node = _add_node(AnimationTreePlayer::NODE_ANIMATION);
+ StringName node = _add_node(AnimationTreePlayer::NODE_ANIMATION);
- RES anim = ResourceLoader::load(files[i]);
- anim_tree->animation_node_set_animation(node,anim);
- //anim_tree->node_set_name(node, files[i].get_file());
- };
- } break;
+ RES anim = ResourceLoader::load(files[i]);
+ anim_tree->animation_node_set_animation(node, anim);
+ //anim_tree->node_set_name(node, files[i].get_file());
+ };
+ } break;
- default:
- break;
+ default:
+ break;
};
};
void AnimationTreeEditor::_add_menu_item(int p_item) {
- if (p_item==MENU_GRAPH_CLEAR) {
+ if (p_item == MENU_GRAPH_CLEAR) {
//clear
} else if (p_item == MENU_IMPORT_ANIMATIONS) {
@@ -1203,49 +1162,46 @@ void AnimationTreeEditor::_add_menu_item(int p_item) {
Size2 AnimationTreeEditor::get_minimum_size() const {
- return Size2(10,200);
+ return Size2(10, 200);
}
-void AnimationTreeEditor::_find_paths_for_filter(const StringName& p_node,Set<String>& paths) {
+void AnimationTreeEditor::_find_paths_for_filter(const StringName &p_node, Set<String> &paths) {
- ERR_FAIL_COND( !anim_tree->node_exists(p_node) );
+ ERR_FAIL_COND(!anim_tree->node_exists(p_node));
- for(int i=0;i<anim_tree->node_get_input_count(p_node);i++) {
+ for (int i = 0; i < anim_tree->node_get_input_count(p_node); i++) {
- StringName port = anim_tree->node_get_input_source(p_node,i);
- if (port==StringName())
+ StringName port = anim_tree->node_get_input_source(p_node, i);
+ if (port == StringName())
continue;
- _find_paths_for_filter(port,paths);
+ _find_paths_for_filter(port, paths);
}
- if (anim_tree->node_get_type(p_node)==AnimationTreePlayer::NODE_ANIMATION) {
+ if (anim_tree->node_get_type(p_node) == AnimationTreePlayer::NODE_ANIMATION) {
Ref<Animation> anim = anim_tree->animation_node_get_animation(p_node);
if (anim.is_valid()) {
- for(int i=0;i<anim->get_track_count();i++) {
+ for (int i = 0; i < anim->get_track_count(); i++) {
paths.insert(anim->track_get_path(i));
}
}
}
}
-
void AnimationTreeEditor::_filter_edited() {
-
TreeItem *ed = filter->get_edited();
if (!ed)
return;
- if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_ONESHOT) {
- anim_tree->oneshot_node_set_filter_path(edited_node,ed->get_metadata(0),ed->is_checked(0));
- } else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_BLEND2) {
- anim_tree->blend2_node_set_filter_path(edited_node,ed->get_metadata(0),ed->is_checked(0));
- } else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_ANIMATION) {
- anim_tree->animation_node_set_filter_path(edited_node,ed->get_metadata(0),ed->is_checked(0));
+ if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ONESHOT) {
+ anim_tree->oneshot_node_set_filter_path(edited_node, ed->get_metadata(0), ed->is_checked(0));
+ } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_BLEND2) {
+ anim_tree->blend2_node_set_filter_path(edited_node, ed->get_metadata(0), ed->is_checked(0));
+ } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ANIMATION) {
+ anim_tree->animation_node_set_filter_path(edited_node, ed->get_metadata(0), ed->is_checked(0));
}
-
}
void AnimationTreeEditor::_edit_filters() {
@@ -1254,47 +1210,44 @@ void AnimationTreeEditor::_edit_filters() {
filter->clear();
Set<String> npb;
- _find_paths_for_filter(edited_node,npb);
+ _find_paths_for_filter(edited_node, npb);
TreeItem *root = filter->create_item();
filter->set_hide_root(true);
- Map<String,TreeItem*> pm;
+ Map<String, TreeItem *> pm;
- Node *base = anim_tree->get_node( anim_tree->get_base_path() );
+ Node *base = anim_tree->get_node(anim_tree->get_base_path());
- for(Set<String>::Element *E=npb.front();E;E=E->next()) {
+ for (Set<String>::Element *E = npb.front(); E; E = E->next()) {
- TreeItem *parent=root;
- String descr=E->get();
+ TreeItem *parent = root;
+ String descr = E->get();
if (base) {
NodePath np = E->get();
- if (np.get_property()!=StringName()) {
+ if (np.get_property() != StringName()) {
Node *n = base->get_node(np);
Skeleton *s = n->cast_to<Skeleton>();
if (s) {
- String skelbase = E->get().substr(0,E->get().find(":"));
-
+ String skelbase = E->get().substr(0, E->get().find(":"));
int bidx = s->find_bone(np.get_property());
- if (bidx!=-1) {
+ if (bidx != -1) {
int bparent = s->get_bone_parent(bidx);
//
- if (bparent!=-1) {
-
+ if (bparent != -1) {
- String bpn = skelbase+":"+s->get_bone_name(bparent);
+ String bpn = skelbase + ":" + s->get_bone_name(bparent);
if (pm.has(bpn)) {
- parent=pm[bpn];
- descr=np.get_property();
+ parent = pm[bpn];
+ descr = np.get_property();
}
} else {
if (pm.has(skelbase)) {
- parent=pm[skelbase];
-
+ parent = pm[skelbase];
}
}
}
@@ -1303,43 +1256,40 @@ void AnimationTreeEditor::_edit_filters() {
}
TreeItem *it = filter->create_item(parent);
- it->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- it->set_text(0,descr);
- it->set_metadata(0,NodePath(E->get()));
- it->set_editable(0,true);
- if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_ONESHOT) {
- it->set_checked(0, anim_tree->oneshot_node_is_path_filtered(edited_node,E->get()));
- } else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_BLEND2) {
- it->set_checked(0, anim_tree->blend2_node_is_path_filtered(edited_node,E->get()));
- } else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_ANIMATION) {
- it->set_checked(0, anim_tree->animation_node_is_path_filtered(edited_node,E->get()));
+ it->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ it->set_text(0, descr);
+ it->set_metadata(0, NodePath(E->get()));
+ it->set_editable(0, true);
+ if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ONESHOT) {
+ it->set_checked(0, anim_tree->oneshot_node_is_path_filtered(edited_node, E->get()));
+ } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_BLEND2) {
+ it->set_checked(0, anim_tree->blend2_node_is_path_filtered(edited_node, E->get()));
+ } else if (anim_tree->node_get_type(edited_node) == AnimationTreePlayer::NODE_ANIMATION) {
+ it->set_checked(0, anim_tree->animation_node_is_path_filtered(edited_node, E->get()));
}
- pm[E->get()]=it;
+ pm[E->get()] = it;
}
-
-
}
void AnimationTreeEditor::_bind_methods() {
- ClassDB::bind_method( "_add_menu_item", &AnimationTreeEditor::_add_menu_item );
- ClassDB::bind_method( "_node_menu_item", &AnimationTreeEditor::_node_menu_item );
- ClassDB::bind_method( "_gui_input", &AnimationTreeEditor::_gui_input );
+ ClassDB::bind_method("_add_menu_item", &AnimationTreeEditor::_add_menu_item);
+ ClassDB::bind_method("_node_menu_item", &AnimationTreeEditor::_node_menu_item);
+ ClassDB::bind_method("_gui_input", &AnimationTreeEditor::_gui_input);
//ClassDB::bind_method( "_node_param_changed", &AnimationTreeEditor::_node_param_changed );
- ClassDB::bind_method( "_scroll_moved", &AnimationTreeEditor::_scroll_moved );
- ClassDB::bind_method( "_edit_dialog_changeds", &AnimationTreeEditor::_edit_dialog_changeds );
- ClassDB::bind_method( "_edit_dialog_changede", &AnimationTreeEditor::_edit_dialog_changede );
- ClassDB::bind_method( "_edit_dialog_changedf", &AnimationTreeEditor::_edit_dialog_changedf );
- ClassDB::bind_method( "_edit_dialog_changed", &AnimationTreeEditor::_edit_dialog_changed );
- ClassDB::bind_method( "_edit_dialog_animation_changed", &AnimationTreeEditor::_edit_dialog_animation_changed );
- ClassDB::bind_method( "_edit_dialog_edit_animation", &AnimationTreeEditor::_edit_dialog_edit_animation );
- ClassDB::bind_method( "_play_toggled", &AnimationTreeEditor::_play_toggled );
- ClassDB::bind_method( "_edit_oneshot_start", &AnimationTreeEditor::_edit_oneshot_start );
- ClassDB::bind_method( "_file_dialog_selected", &AnimationTreeEditor::_file_dialog_selected);
- ClassDB::bind_method( "_master_anim_menu_item", &AnimationTreeEditor::_master_anim_menu_item);
- ClassDB::bind_method( "_edit_filters", &AnimationTreeEditor::_edit_filters);
- ClassDB::bind_method( "_filter_edited", &AnimationTreeEditor::_filter_edited);
-
+ ClassDB::bind_method("_scroll_moved", &AnimationTreeEditor::_scroll_moved);
+ ClassDB::bind_method("_edit_dialog_changeds", &AnimationTreeEditor::_edit_dialog_changeds);
+ ClassDB::bind_method("_edit_dialog_changede", &AnimationTreeEditor::_edit_dialog_changede);
+ ClassDB::bind_method("_edit_dialog_changedf", &AnimationTreeEditor::_edit_dialog_changedf);
+ ClassDB::bind_method("_edit_dialog_changed", &AnimationTreeEditor::_edit_dialog_changed);
+ ClassDB::bind_method("_edit_dialog_animation_changed", &AnimationTreeEditor::_edit_dialog_animation_changed);
+ ClassDB::bind_method("_edit_dialog_edit_animation", &AnimationTreeEditor::_edit_dialog_edit_animation);
+ ClassDB::bind_method("_play_toggled", &AnimationTreeEditor::_play_toggled);
+ ClassDB::bind_method("_edit_oneshot_start", &AnimationTreeEditor::_edit_oneshot_start);
+ ClassDB::bind_method("_file_dialog_selected", &AnimationTreeEditor::_file_dialog_selected);
+ ClassDB::bind_method("_master_anim_menu_item", &AnimationTreeEditor::_master_anim_menu_item);
+ ClassDB::bind_method("_edit_filters", &AnimationTreeEditor::_edit_filters);
+ ClassDB::bind_method("_filter_edited", &AnimationTreeEditor::_filter_edited);
}
AnimationTreeEditor::AnimationTreeEditor() {
@@ -1349,149 +1299,141 @@ AnimationTreeEditor::AnimationTreeEditor() {
PopupMenu *p;
List<PropertyInfo> defaults;
- add_menu = memnew( MenuButton );
+ add_menu = memnew(MenuButton);
//add_menu->set_
- add_menu->set_pos( Point2( 0,0) );
- add_menu->set_size( Point2( 25,15) );
- add_child( add_menu );
-
- p=add_menu->get_popup();
- p->add_item(TTR("Animation Node"),AnimationTreePlayer::NODE_ANIMATION);
- p->add_item(TTR("OneShot Node"),AnimationTreePlayer::NODE_ONESHOT);
- p->add_item(TTR("Mix Node"),AnimationTreePlayer::NODE_MIX);
- p->add_item(TTR("Blend2 Node"),AnimationTreePlayer::NODE_BLEND2);
- p->add_item(TTR("Blend3 Node"),AnimationTreePlayer::NODE_BLEND3);
- p->add_item(TTR("Blend4 Node"),AnimationTreePlayer::NODE_BLEND4);
- p->add_item(TTR("TimeScale Node"),AnimationTreePlayer::NODE_TIMESCALE);
- p->add_item(TTR("TimeSeek Node"),AnimationTreePlayer::NODE_TIMESEEK);
- p->add_item(TTR("Transition Node"),AnimationTreePlayer::NODE_TRANSITION);
+ add_menu->set_pos(Point2(0, 0));
+ add_menu->set_size(Point2(25, 15));
+ add_child(add_menu);
+
+ p = add_menu->get_popup();
+ p->add_item(TTR("Animation Node"), AnimationTreePlayer::NODE_ANIMATION);
+ p->add_item(TTR("OneShot Node"), AnimationTreePlayer::NODE_ONESHOT);
+ p->add_item(TTR("Mix Node"), AnimationTreePlayer::NODE_MIX);
+ p->add_item(TTR("Blend2 Node"), AnimationTreePlayer::NODE_BLEND2);
+ p->add_item(TTR("Blend3 Node"), AnimationTreePlayer::NODE_BLEND3);
+ p->add_item(TTR("Blend4 Node"), AnimationTreePlayer::NODE_BLEND4);
+ p->add_item(TTR("TimeScale Node"), AnimationTreePlayer::NODE_TIMESCALE);
+ p->add_item(TTR("TimeSeek Node"), AnimationTreePlayer::NODE_TIMESEEK);
+ p->add_item(TTR("Transition Node"), AnimationTreePlayer::NODE_TRANSITION);
p->add_separator();
p->add_item(TTR("Import Animations.."), MENU_IMPORT_ANIMATIONS); // wtf
p->add_separator();
- p->add_item(TTR("Clear"),MENU_GRAPH_CLEAR);
+ p->add_item(TTR("Clear"), MENU_GRAPH_CLEAR);
- p->connect("id_pressed", this,"_add_menu_item");
+ p->connect("id_pressed", this, "_add_menu_item");
play_button = memnew(Button);
- play_button->set_pos(Point2(25,0));
- play_button->set_size(Point2(25,15));
+ play_button->set_pos(Point2(25, 0));
+ play_button->set_size(Point2(25, 15));
add_child(play_button);
play_button->set_toggle_mode(true);
- play_button->connect("pressed", this,"_play_toggled");
-
-
+ play_button->connect("pressed", this, "_play_toggled");
+ last_x = 50;
+ last_y = 50;
-
- last_x=50;
- last_y=50;
-
- property_editor = memnew( CustomPropertyEditor );
+ property_editor = memnew(CustomPropertyEditor);
add_child(property_editor);
- property_editor->connect("variant_changed", this,"_edit_dialog_animation_changed");
- property_editor->connect("resource_edit_request", this, "_edit_dialog_edit_animation");
+ property_editor->connect("variant_changed", this, "_edit_dialog_animation_changed");
+ property_editor->connect("resource_edit_request", this, "_edit_dialog_edit_animation");
- h_scroll = memnew( HScrollBar );
- v_scroll = memnew( VScrollBar );
+ h_scroll = memnew(HScrollBar);
+ v_scroll = memnew(VScrollBar);
add_child(h_scroll);
add_child(v_scroll);
- 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");
- node_popup= memnew(PopupMenu );
+ node_popup = memnew(PopupMenu);
add_child(node_popup);
node_popup->set_as_toplevel(true);
- master_anim_popup = memnew( PopupMenu );
+ master_anim_popup = memnew(PopupMenu);
add_child(master_anim_popup);
- master_anim_popup->connect("id_pressed",this,"_master_anim_menu_item");
+ master_anim_popup->connect("id_pressed", this, "_master_anim_menu_item");
+ node_popup->connect("id_pressed", this, "_node_menu_item");
- node_popup->connect("id_pressed", this,"_node_menu_item");
+ updating_edit = false;
- updating_edit=false;
-
- edit_dialog = memnew( PopupPanel );
+ edit_dialog = memnew(PopupPanel);
//edit_dialog->get_ok()->hide();
//edit_dialog->get_cancel()->hide();
add_child(edit_dialog);
- edit_option = memnew( OptionButton );
- edit_option->set_anchor( MARGIN_RIGHT, ANCHOR_END );
+ edit_option = memnew(OptionButton);
+ edit_option->set_anchor(MARGIN_RIGHT, ANCHOR_END);
edit_option->set_margin(MARGIN_RIGHT, 10);
edit_dialog->add_child(edit_option);
- edit_option->connect("item_selected", this,"_edit_dialog_changedf");
+ edit_option->connect("item_selected", this, "_edit_dialog_changedf");
edit_option->hide();
-
- for(int i=0;i<2;i++) {
- edit_scroll[i] = memnew ( HSlider );
- edit_scroll[i]->set_anchor( MARGIN_RIGHT, ANCHOR_END );
+ for (int i = 0; i < 2; i++) {
+ edit_scroll[i] = memnew(HSlider);
+ edit_scroll[i]->set_anchor(MARGIN_RIGHT, ANCHOR_END);
edit_scroll[i]->set_margin(MARGIN_RIGHT, 10);
edit_dialog->add_child(edit_scroll[i]);
edit_scroll[i]->hide();
- edit_scroll[i]->connect("value_changed", this,"_edit_dialog_changedf");
+ edit_scroll[i]->connect("value_changed", this, "_edit_dialog_changedf");
}
- for(int i=0;i<4;i++) {
- edit_line[i] = memnew ( LineEdit );
- edit_line[i]->set_anchor( MARGIN_RIGHT, ANCHOR_END );
+ for (int i = 0; i < 4; i++) {
+ edit_line[i] = memnew(LineEdit);
+ edit_line[i]->set_anchor(MARGIN_RIGHT, ANCHOR_END);
edit_line[i]->set_margin(MARGIN_RIGHT, 10);
edit_dialog->add_child(edit_line[i]);
edit_line[i]->hide();
- edit_line[i]->connect("text_changed", this,"_edit_dialog_changeds");
- edit_line[i]->connect("text_entered", this,"_edit_dialog_changede");
- edit_label[i] = memnew ( Label );
+ edit_line[i]->connect("text_changed", this, "_edit_dialog_changeds");
+ edit_line[i]->connect("text_entered", this, "_edit_dialog_changede");
+ edit_label[i] = memnew(Label);
edit_dialog->add_child(edit_label[i]);
edit_label[i]->hide();
}
- edit_button = memnew( Button );
- edit_button->set_anchor( MARGIN_RIGHT, ANCHOR_END );
+ edit_button = memnew(Button);
+ edit_button->set_anchor(MARGIN_RIGHT, ANCHOR_END);
edit_button->set_margin(MARGIN_RIGHT, 10);
edit_dialog->add_child(edit_button);
edit_button->hide();
- edit_button->connect("pressed", this,"_edit_oneshot_start");
+ edit_button->connect("pressed", this, "_edit_oneshot_start");
- edit_check = memnew( CheckButton );
- edit_check->set_anchor( MARGIN_RIGHT, ANCHOR_END );
+ edit_check = memnew(CheckButton);
+ edit_check->set_anchor(MARGIN_RIGHT, ANCHOR_END);
edit_check->set_margin(MARGIN_RIGHT, 10);
edit_dialog->add_child(edit_check);
edit_check->hide();
- edit_check->connect("pressed", this,"_edit_dialog_changed");
+ edit_check->connect("pressed", this, "_edit_dialog_changed");
- file_dialog = memnew( EditorFileDialog );
+ file_dialog = memnew(EditorFileDialog);
file_dialog->set_enable_multiple_selection(true);
file_dialog->set_current_dir(GlobalConfig::get_singleton()->get_resource_path());
add_child(file_dialog);
- file_dialog->connect("file_selected", this, "_file_dialog_selected");
+ file_dialog->connect("file_selected", this, "_file_dialog_selected");
- filter_dialog = memnew( AcceptDialog );
+ filter_dialog = memnew(AcceptDialog);
filter_dialog->set_title(TTR("Edit Node Filters"));
add_child(filter_dialog);
- filter = memnew( Tree );
+ filter = memnew(Tree);
filter_dialog->add_child(filter);
//filter_dialog->set_child_rect(filter);
- filter->connect("item_edited",this,"_filter_edited");
+ filter->connect("item_edited", this, "_filter_edited");
- filter_button = memnew( Button );
- filter_button->set_anchor( MARGIN_RIGHT, ANCHOR_END );
+ filter_button = memnew(Button);
+ filter_button->set_anchor(MARGIN_RIGHT, ANCHOR_END);
filter_button->set_margin(MARGIN_RIGHT, 10);
edit_dialog->add_child(filter_button);
filter_button->hide();
filter_button->set_text(TTR("Filters.."));
- filter_button->connect("pressed", this,"_edit_filters");
+ filter_button->connect("pressed", this, "_edit_filters");
set_clip_contents(true);
}
-
void AnimationTreeEditorPlugin::edit(Object *p_object) {
anim_tree_editor->edit(p_object->cast_to<AnimationTreePlayer>());
-
}
bool AnimationTreeEditorPlugin::handles(Object *p_object) const {
@@ -1518,19 +1460,13 @@ void AnimationTreeEditorPlugin::make_visible(bool p_visible) {
AnimationTreeEditorPlugin::AnimationTreeEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- anim_tree_editor = memnew( AnimationTreeEditor );
- anim_tree_editor->set_custom_minimum_size(Size2(0,300));
+ editor = p_node;
+ anim_tree_editor = memnew(AnimationTreeEditor);
+ anim_tree_editor->set_custom_minimum_size(Size2(0, 300));
- button=editor->add_bottom_panel_item("AnimationTree",anim_tree_editor);
+ button = editor->add_bottom_panel_item("AnimationTree", anim_tree_editor);
button->hide();
-
-
-
}
-
-AnimationTreeEditorPlugin::~AnimationTreeEditorPlugin()
-{
+AnimationTreeEditorPlugin::~AnimationTreeEditorPlugin() {
}
-
diff --git a/editor/plugins/animation_tree_editor_plugin.h b/editor/plugins/animation_tree_editor_plugin.h
index 4e5fb871f1..d998cb99ae 100644
--- a/editor/plugins/animation_tree_editor_plugin.h
+++ b/editor/plugins/animation_tree_editor_plugin.h
@@ -29,22 +29,22 @@
#ifndef ANIMATION_TREE_EDITOR_PLUGIN_H
#define ANIMATION_TREE_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
+#include "editor/property_editor.h"
#include "scene/animation/animation_tree_player.h"
-#include "scene/gui/tree.h"
#include "scene/gui/button.h"
#include "scene/gui/popup.h"
-#include "editor/property_editor.h"
+#include "scene/gui/tree.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class AnimationTreeEditor : public Control {
- GDCLASS(AnimationTreeEditor, Control );
+ GDCLASS(AnimationTreeEditor, Control);
- static const char* _node_type_names[];
+ static const char *_node_type_names[];
enum ClickType {
CLICK_NONE,
@@ -57,8 +57,8 @@ class AnimationTreeEditor : public Control {
enum {
- MENU_GRAPH_CLEAR=100,
- MENU_IMPORT_ANIMATIONS=101,
+ MENU_GRAPH_CLEAR = 100,
+ MENU_IMPORT_ANIMATIONS = 101,
NODE_DISCONNECT,
NODE_RENAME,
NODE_ERASE,
@@ -79,27 +79,26 @@ class AnimationTreeEditor : public Control {
Button *edit_button;
Button *filter_button;
CheckButton *edit_check;
- EditorFileDialog* file_dialog;
+ EditorFileDialog *file_dialog;
int file_op;
void _popup_edit_dialog();
-
- void _setup_edit_dialog(const StringName& p_node);
+ void _setup_edit_dialog(const StringName &p_node);
PopupMenu *master_anim_popup;
PopupMenu *node_popup;
PopupMenu *add_popup;
HScrollBar *h_scroll;
VScrollBar *v_scroll;
- MenuButton* add_menu;
+ MenuButton *add_menu;
CustomPropertyEditor *property_editor;
- AnimationTreePlayer* anim_tree;
+ AnimationTreePlayer *anim_tree;
List<StringName> order;
Set<StringName> active_nodes;
- int last_x,last_y;
+ int last_x, last_y;
Point2 offset;
ClickType click_type;
@@ -115,18 +114,16 @@ class AnimationTreeEditor : public Control {
Size2 _get_maximum_size();
Size2 get_node_size(const StringName &p_node) const;
- void _draw_node(const StringName& p_node);
+ void _draw_node(const StringName &p_node);
AcceptDialog *filter_dialog;
Tree *filter;
-
-
- 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 _update_scrollbars();
void _scroll_moved(float);
void _play_toggled();
-/*
+ /*
void _node_param_changed();
void _node_add_callback();
void _node_add(VisualServer::AnimationTreeNodeType p_type);
@@ -137,12 +134,10 @@ class AnimationTreeEditor : public Control {
void _node_menu_item(int p_item);
void _add_menu_item(int p_item);
-
void _filter_edited();
- void _find_paths_for_filter(const StringName& p_node,Set<String>& paths);
+ void _find_paths_for_filter(const StringName &p_node, Set<String> &paths);
void _edit_filters();
-
void _edit_oneshot_start();
void _edit_dialog_animation_changed();
void _edit_dialog_edit_animation();
@@ -151,20 +146,18 @@ class AnimationTreeEditor : public Control {
void _edit_dialog_changedf(float);
void _edit_dialog_changed();
void _dialog_changed() const;
- ClickType _locate_click(const Point2& p_click,StringName *p_node_id,int *p_slot_index) const;
- Point2 _get_slot_pos(const StringName& p_node_id,bool p_input,int p_slot);
+ ClickType _locate_click(const Point2 &p_click, StringName *p_node_id, int *p_slot_index) const;
+ Point2 _get_slot_pos(const StringName &p_node_id, bool p_input, int p_slot);
StringName _add_node(int p_item);
void _file_dialog_selected(String p_path);
-
protected:
void _notification(int p_what);
void _gui_input(InputEvent p_event);
static void _bind_methods();
-public:
-
+public:
virtual Size2 get_minimum_size() const;
void edit(AnimationTreePlayer *p_player);
AnimationTreeEditor();
@@ -172,14 +165,13 @@ public:
class AnimationTreeEditorPlugin : public EditorPlugin {
- GDCLASS( AnimationTreeEditorPlugin, EditorPlugin );
+ GDCLASS(AnimationTreeEditorPlugin, EditorPlugin);
AnimationTreeEditor *anim_tree_editor;
EditorNode *editor;
Button *button;
public:
-
virtual String get_name() const { return "AnimTree"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -188,7 +180,6 @@ public:
AnimationTreeEditorPlugin(EditorNode *p_node);
~AnimationTreeEditorPlugin();
-
};
#endif // ANIMATION_TREE_EDITOR_PLUGIN_H
diff --git a/editor/plugins/baked_light_baker.cpp b/editor/plugins/baked_light_baker.cpp
index e491fe012e..de2b78b8dd 100644
--- a/editor/plugins/baked_light_baker.cpp
+++ b/editor/plugins/baked_light_baker.cpp
@@ -28,11 +28,11 @@
/*************************************************************************/
#include "baked_light_baker.h"
-#include <stdlib.h>
-#include <cmath>
-#include "io/marshalls.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
+#include "io/marshalls.h"
+#include <stdlib.h>
+#include <cmath>
#if 0
void baked_light_baker_add_64f(double *dst,double value);
diff --git a/editor/plugins/baked_light_baker.h b/editor/plugins/baked_light_baker.h
index 89788338d9..f328062b1e 100644
--- a/editor/plugins/baked_light_baker.h
+++ b/editor/plugins/baked_light_baker.h
@@ -29,10 +29,10 @@
#ifndef BAKED_LIGHT_BAKER_H
#define BAKED_LIGHT_BAKER_H
+#include "os/thread.h"
#include "scene/3d/baked_light_instance.h"
#include "scene/3d/light.h"
#include "scene/3d/mesh_instance.h"
-#include "os/thread.h"
#if 0
diff --git a/editor/plugins/baked_light_baker_cmpxchg.cpp b/editor/plugins/baked_light_baker_cmpxchg.cpp
index 5e9228b7de..f84c001f78 100644
--- a/editor/plugins/baked_light_baker_cmpxchg.cpp
+++ b/editor/plugins/baked_light_baker_cmpxchg.cpp
@@ -28,85 +28,77 @@
/*************************************************************************/
#include "typedefs.h"
-
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
-void baked_light_baker_add_64f(double *dst,double value) {
-
+void baked_light_baker_add_64f(double *dst, double value) {
union {
int64_t i;
double f;
} swapy;
-
- while(true) {
- swapy.f=*dst;
+ while (true) {
+ swapy.f = *dst;
int64_t from = swapy.i;
- swapy.f+=value;
- int64_t to=swapy.i;
- if (__sync_bool_compare_and_swap((int64_t*)dst,from,to))
+ swapy.f += value;
+ int64_t to = swapy.i;
+ if (__sync_bool_compare_and_swap((int64_t *)dst, from, to))
break;
}
}
-void baked_light_baker_add_64i(int64_t *dst,int64_t value) {
-
- while(!__sync_bool_compare_and_swap(dst,*dst,(*dst)+value)) {}
+void baked_light_baker_add_64i(int64_t *dst, int64_t value) {
+ while (!__sync_bool_compare_and_swap(dst, *dst, (*dst) + value)) {
+ }
}
#elif defined(WINDOWS_ENABLED)
#include "windows.h"
-void baked_light_baker_add_64f(double *dst,double value) {
+void baked_light_baker_add_64f(double *dst, double value) {
union {
int64_t i;
double f;
} swapy;
-
- while(true) {
- swapy.f=*dst;
+ while (true) {
+ swapy.f = *dst;
int64_t from = swapy.i;
- swapy.f+=value;
- int64_t to=swapy.i;
- int64_t result = InterlockedCompareExchange64((int64_t*)dst,to,from);
- if (result==from)
+ swapy.f += value;
+ int64_t to = swapy.i;
+ int64_t result = InterlockedCompareExchange64((int64_t *)dst, to, from);
+ if (result == from)
break;
}
-
}
-void baked_light_baker_add_64i(int64_t *dst,int64_t value) {
+void baked_light_baker_add_64i(int64_t *dst, int64_t value) {
- while(true) {
+ while (true) {
int64_t from = *dst;
- int64_t to = from+value;
- int64_t result = InterlockedCompareExchange64(dst,to,from);
- if (result==from)
+ int64_t to = from + value;
+ int64_t result = InterlockedCompareExchange64(dst, to, from);
+ if (result == from)
break;
}
}
-
#else
//in goder (the god of programmers) we trust
#warning seems this platform or compiler does not support safe cmpxchg, your baked lighting may be funny
-void baked_light_baker_add_64f(double *dst,double value) {
-
- *dst+=value;
+void baked_light_baker_add_64f(double *dst, double value) {
+ *dst += value;
}
-void baked_light_baker_add_64i(int64_t *dst,int64_t value) {
-
- *dst+=value;
+void baked_light_baker_add_64i(int64_t *dst, int64_t value) {
+ *dst += value;
}
#endif
diff --git a/editor/plugins/baked_light_editor_plugin.cpp b/editor/plugins/baked_light_editor_plugin.cpp
index 6a7e708b85..5ac4b54600 100644
--- a/editor/plugins/baked_light_editor_plugin.cpp
+++ b/editor/plugins/baked_light_editor_plugin.cpp
@@ -28,11 +28,10 @@
/*************************************************************************/
#include "baked_light_editor_plugin.h"
-#include "scene/gui/box_container.h"
-#include "scene/3d/mesh_instance.h"
#include "io/marshalls.h"
#include "io/resource_saver.h"
-
+#include "scene/3d/mesh_instance.h"
+#include "scene/gui/box_container.h"
#if 0
@@ -153,7 +152,6 @@ void BakedLightEditor::_notification(int p_option) {
it->create_from_image(img);
ResourceSaver::save("baked_octree.png",it);
-
#endif
@@ -375,5 +373,4 @@ BakedLightEditorPlugin::~BakedLightEditorPlugin()
{
}
-
#endif
diff --git a/editor/plugins/baked_light_editor_plugin.h b/editor/plugins/baked_light_editor_plugin.h
index a71de12bcc..036407a574 100644
--- a/editor/plugins/baked_light_editor_plugin.h
+++ b/editor/plugins/baked_light_editor_plugin.h
@@ -29,13 +29,11 @@
#ifndef BAKED_LIGHT_EDITOR_PLUGIN_H
#define BAKED_LIGHT_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "editor/plugins/baked_light_baker.h"
#include "scene/gui/spin_box.h"
-
-
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -117,4 +115,3 @@ public:
#endif // MULTIMESH_EDITOR_PLUGIN_H
#endif
-
diff --git a/editor/plugins/camera_editor_plugin.cpp b/editor/plugins/camera_editor_plugin.cpp
index 7073acd2c0..96b6da51fd 100644
--- a/editor/plugins/camera_editor_plugin.cpp
+++ b/editor/plugins/camera_editor_plugin.cpp
@@ -30,45 +30,41 @@
#include "spatial_editor_plugin.h"
-
void CameraEditor::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
-/* case NOTIFICATION_PROCESS: {
+ /* case NOTIFICATION_PROCESS: {
if (preview->is_pressed() && node)
node->call("make_current");
} break;*/
}
-
}
void CameraEditor::_node_removed(Node *p_node) {
- if(p_node==node) {
- node=NULL;
+ if (p_node == node) {
+ node = NULL;
SpatialEditor::get_singleton()->set_custom_camera(NULL);
hide();
}
-
}
void CameraEditor::_pressed() {
- Node *sn = (node && preview->is_pressed())?node:NULL;
+ Node *sn = (node && preview->is_pressed()) ? node : NULL;
SpatialEditor::get_singleton()->set_custom_camera(sn);
}
void CameraEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_pressed"),&CameraEditor::_pressed);
-
+ ClassDB::bind_method(D_METHOD("_pressed"), &CameraEditor::_pressed);
}
void CameraEditor::edit(Node *p_camera) {
- node=p_camera;
+ node = p_camera;
if (!node) {
preview->set_pressed(false);
@@ -82,25 +78,22 @@ void CameraEditor::edit(Node *p_camera) {
}
}
-
CameraEditor::CameraEditor() {
- preview = memnew( Button );
+ preview = memnew(Button);
add_child(preview);
preview->set_text(TTR("Preview"));
preview->set_toggle_mode(true);
- preview->set_anchor(MARGIN_LEFT,Control::ANCHOR_END);
- preview->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END);
- preview->set_margin(MARGIN_LEFT,60);
- preview->set_margin(MARGIN_RIGHT,0);
- preview->set_margin(MARGIN_TOP,0);
- preview->set_margin(MARGIN_BOTTOM,10);
- preview->connect("pressed",this,"_pressed");
-
+ preview->set_anchor(MARGIN_LEFT, Control::ANCHOR_END);
+ preview->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END);
+ preview->set_margin(MARGIN_LEFT, 60);
+ preview->set_margin(MARGIN_RIGHT, 0);
+ preview->set_margin(MARGIN_TOP, 0);
+ preview->set_margin(MARGIN_BOTTOM, 10);
+ preview->connect("pressed", this, "_pressed");
}
-
void CameraEditorPlugin::edit(Object *p_object) {
SpatialEditor::get_singleton()->set_can_preview(p_object->cast_to<Camera>());
@@ -119,13 +112,12 @@ void CameraEditorPlugin::make_visible(bool p_visible) {
} else {
SpatialEditor::get_singleton()->set_can_preview(NULL);
}
-
}
CameraEditorPlugin::CameraEditorPlugin(EditorNode *p_node) {
- editor=p_node;
-/* camera_editor = memnew( CameraEditor );
+ editor = p_node;
+ /* camera_editor = memnew( CameraEditor );
editor->get_viewport()->add_child(camera_editor);
camera_editor->set_anchor(MARGIN_LEFT,Control::ANCHOR_END);
@@ -138,13 +130,7 @@ CameraEditorPlugin::CameraEditorPlugin(EditorNode *p_node) {
camera_editor->hide();
*/
-
-
}
-
-CameraEditorPlugin::~CameraEditorPlugin()
-{
+CameraEditorPlugin::~CameraEditorPlugin() {
}
-
-
diff --git a/editor/plugins/camera_editor_plugin.h b/editor/plugins/camera_editor_plugin.h
index b5817b9960..f23b0d5cc8 100644
--- a/editor/plugins/camera_editor_plugin.h
+++ b/editor/plugins/camera_editor_plugin.h
@@ -29,8 +29,8 @@
#ifndef CAMERA_EDITOR_PLUGIN_H
#define CAMERA_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/3d/camera.h"
/**
@@ -39,32 +39,32 @@
class CameraEditor : public Control {
- GDCLASS(CameraEditor, Control );
+ GDCLASS(CameraEditor, Control);
Panel *panel;
- Button * preview;
+ Button *preview;
Node *node;
void _pressed();
+
protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
-public:
+public:
void edit(Node *p_camera);
CameraEditor();
};
class CameraEditorPlugin : public EditorPlugin {
- GDCLASS( CameraEditorPlugin, EditorPlugin );
+ GDCLASS(CameraEditorPlugin, EditorPlugin);
//CameraEditor *camera_editor;
EditorNode *editor;
public:
-
virtual String get_name() const { return "Camera"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -73,7 +73,6 @@ public:
CameraEditorPlugin(EditorNode *p_node);
~CameraEditorPlugin();
-
};
#endif // CAMERA_EDITOR_PLUGIN_H
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 1a0791d864..ebf2fa5a3a 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -28,37 +28,35 @@
/*************************************************************************/
#include "canvas_item_editor_plugin.h"
-#include "print_string.h"
+#include "editor/animation_editor.h"
#include "editor/editor_node.h"
+#include "editor/editor_settings.h"
+#include "editor/plugins/animation_player_editor_plugin.h"
+#include "editor/plugins/script_editor_plugin.h"
+#include "editor/script_editor_debugger.h"
+#include "global_config.h"
+#include "os/input.h"
#include "os/keyboard.h"
-#include "scene/main/viewport.h"
-#include "scene/main/canvas_layer.h"
-#include "scene/2d/sprite.h"
+#include "print_string.h"
#include "scene/2d/light_2d.h"
#include "scene/2d/particles_2d.h"
#include "scene/2d/polygon_2d.h"
#include "scene/2d/screen_button.h"
-#include "global_config.h"
-#include "os/input.h"
-#include "editor/editor_settings.h"
+#include "scene/2d/sprite.h"
#include "scene/gui/grid_container.h"
#include "scene/gui/patch_9_rect.h"
-#include "editor/animation_editor.h"
-#include "editor/plugins/animation_player_editor_plugin.h"
-#include "editor/script_editor_debugger.h"
-#include "editor/plugins/script_editor_plugin.h"
+#include "scene/main/canvas_layer.h"
+#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
-
#define MIN_ZOOM 0.01
#define MAX_ZOOM 100
-
class SnapDialog : public ConfirmationDialog {
- GDCLASS(SnapDialog,ConfirmationDialog);
+ GDCLASS(SnapDialog, ConfirmationDialog);
-friend class CanvasItemEditor;
+ friend class CanvasItemEditor;
SpinBox *grid_offset_x;
SpinBox *grid_offset_y;
@@ -68,7 +66,8 @@ friend class CanvasItemEditor;
SpinBox *rotation_step;
public:
- SnapDialog() : ConfirmationDialog() {
+ SnapDialog()
+ : ConfirmationDialog() {
const int SPIN_BOX_GRID_RANGE = 256;
const int SPIN_BOX_ROTATION_RANGE = 360;
Label *label;
@@ -78,71 +77,71 @@ public:
set_title(TTR("Configure Snap"));
get_ok()->set_text(TTR("Close"));
- container = memnew( VBoxContainer );
+ container = memnew(VBoxContainer);
add_child(container);
//set_child_rect(container);
- child_container = memnew( GridContainer );
+ child_container = memnew(GridContainer);
child_container->set_columns(3);
container->add_child(child_container);
- label = memnew( Label );
+ label = memnew(Label);
label->set_text(TTR("Grid Offset:"));
child_container->add_child(label);
label->set_h_size_flags(SIZE_EXPAND_FILL);
- grid_offset_x = memnew( SpinBox );
+ grid_offset_x = memnew(SpinBox);
grid_offset_x->set_min(-SPIN_BOX_GRID_RANGE);
grid_offset_x->set_max(SPIN_BOX_GRID_RANGE);
grid_offset_x->set_suffix("px");
child_container->add_child(grid_offset_x);
- grid_offset_y = memnew( SpinBox );
+ grid_offset_y = memnew(SpinBox);
grid_offset_y->set_min(-SPIN_BOX_GRID_RANGE);
grid_offset_y->set_max(SPIN_BOX_GRID_RANGE);
grid_offset_y->set_suffix("px");
child_container->add_child(grid_offset_y);
- label = memnew( Label );
+ label = memnew(Label);
label->set_text(TTR("Grid Step:"));
child_container->add_child(label);
label->set_h_size_flags(SIZE_EXPAND_FILL);
- grid_step_x = memnew( SpinBox );
+ grid_step_x = memnew(SpinBox);
grid_step_x->set_min(-SPIN_BOX_GRID_RANGE);
grid_step_x->set_max(SPIN_BOX_GRID_RANGE);
grid_step_x->set_suffix("px");
child_container->add_child(grid_step_x);
- grid_step_y = memnew( SpinBox );
+ grid_step_y = memnew(SpinBox);
grid_step_y->set_min(-SPIN_BOX_GRID_RANGE);
grid_step_y->set_max(SPIN_BOX_GRID_RANGE);
grid_step_y->set_suffix("px");
child_container->add_child(grid_step_y);
- container->add_child( memnew( HSeparator ) );
+ container->add_child(memnew(HSeparator));
- child_container = memnew( GridContainer );
+ child_container = memnew(GridContainer);
child_container->set_columns(2);
container->add_child(child_container);
- label = memnew( Label );
+ label = memnew(Label);
label->set_text(TTR("Rotation Offset:"));
child_container->add_child(label);
label->set_h_size_flags(SIZE_EXPAND_FILL);
- rotation_offset = memnew( SpinBox );
+ rotation_offset = memnew(SpinBox);
rotation_offset->set_min(-SPIN_BOX_ROTATION_RANGE);
rotation_offset->set_max(SPIN_BOX_ROTATION_RANGE);
rotation_offset->set_suffix("deg");
child_container->add_child(rotation_offset);
- label = memnew( Label );
+ label = memnew(Label);
label->set_text(TTR("Rotation Step:"));
child_container->add_child(label);
label->set_h_size_flags(SIZE_EXPAND_FILL);
- rotation_step = memnew( SpinBox );
+ rotation_step = memnew(SpinBox);
rotation_step->set_min(-SPIN_BOX_ROTATION_RANGE);
rotation_step->set_max(SPIN_BOX_ROTATION_RANGE);
rotation_step->set_suffix("deg");
@@ -168,12 +167,12 @@ public:
}
};
-void CanvasItemEditor::_edit_set_pivot(const Vector2& mouse_pos) {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) {
+ List<Node *> &selection = editor_selection->get_selected_node_list();
undo_redo->create_action(TTR("Move Pivot"));
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Node2D *n2d = E->get()->cast_to<Node2D>();
@@ -184,31 +183,27 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2& mouse_pos) {
Vector2 local_mouse_pos = n2d->get_canvas_transform().affine_inverse().xform(mouse_pos);
- Vector2 motion_ofs = gpos-local_mouse_pos;
+ Vector2 motion_ofs = gpos - local_mouse_pos;
- undo_redo->add_do_method(n2d,"set_global_pos",local_mouse_pos);
- undo_redo->add_do_method(n2d,"edit_set_pivot",offset+n2d->get_global_transform().affine_inverse().basis_xform(motion_ofs));
- undo_redo->add_undo_method(n2d,"set_global_pos",gpos);
- undo_redo->add_undo_method(n2d,"edit_set_pivot",offset);
- for(int i=0;i<n2d->get_child_count();i++) {
+ undo_redo->add_do_method(n2d, "set_global_pos", local_mouse_pos);
+ undo_redo->add_do_method(n2d, "edit_set_pivot", offset + n2d->get_global_transform().affine_inverse().basis_xform(motion_ofs));
+ undo_redo->add_undo_method(n2d, "set_global_pos", gpos);
+ undo_redo->add_undo_method(n2d, "edit_set_pivot", offset);
+ for (int i = 0; i < n2d->get_child_count(); i++) {
Node2D *n2dc = n2d->get_child(i)->cast_to<Node2D>();
if (!n2dc)
continue;
- undo_redo->add_do_method(n2dc,"set_global_pos",n2dc->get_global_position());
- undo_redo->add_undo_method(n2dc,"set_global_pos",n2dc->get_global_position());
-
+ undo_redo->add_do_method(n2dc, "set_global_pos", n2dc->get_global_position());
+ undo_redo->add_undo_method(n2dc, "set_global_pos", n2dc->get_global_position());
}
-
}
-
}
undo_redo->commit_action();
-
}
-void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) {
+void CanvasItemEditor::_unhandled_key_input(const InputEvent &p_ev) {
if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack())
return;
@@ -216,42 +211,37 @@ void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) {
if (p_ev.key.mod.control)
return;
- if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_V && drag==DRAG_NONE && can_move_pivot) {
+ if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode == KEY_V && drag == DRAG_NONE && can_move_pivot) {
if (p_ev.key.mod.shift) {
//move drag pivot
- drag=DRAG_PIVOT;
+ drag = DRAG_PIVOT;
} else if (!Input::get_singleton()->is_mouse_button_pressed(0)) {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
Vector2 mouse_pos = viewport->get_local_mouse_pos();
if (selection.size() && viewport->get_rect().has_point(mouse_pos)) {
//just in case, make it work if over viewport
- mouse_pos=transform.affine_inverse().xform(mouse_pos);
- mouse_pos=snap_point(mouse_pos);
+ mouse_pos = transform.affine_inverse().xform(mouse_pos);
+ mouse_pos = snap_point(mouse_pos);
_edit_set_pivot(mouse_pos);
}
-
}
}
-
}
void CanvasItemEditor::_tool_select(int p_index) {
+ ToolButton *tb[TOOL_MAX] = { select_button, list_select_button, move_button, rotate_button, pivot_button, pan_button };
+ for (int i = 0; i < TOOL_MAX; i++) {
- ToolButton *tb[TOOL_MAX]={select_button,list_select_button,move_button,rotate_button,pivot_button,pan_button};
- for(int i=0;i<TOOL_MAX;i++) {
-
- tb[i]->set_pressed(i==p_index);
+ tb[i]->set_pressed(i == p_index);
}
-
viewport->update();
- tool=(Tool)p_index;
-
+ tool = (Tool)p_index;
}
Object *CanvasItemEditor::_get_editor_data(Object *p_what) {
@@ -260,7 +250,7 @@ Object *CanvasItemEditor::_get_editor_data(Object *p_what) {
if (!ci)
return NULL;
- return memnew( CanvasItemEditorSelectedItem );
+ return memnew(CanvasItemEditorSelectedItem);
}
inline float _snap_scalar(float p_offset, float p_step, bool p_snap_relative, float p_target, float p_start) {
@@ -286,89 +276,88 @@ float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
Dictionary CanvasItemEditor::get_state() const {
Dictionary state;
- state["zoom"]=zoom;
- state["ofs"]=Point2(h_scroll->get_value(),v_scroll->get_value());
+ state["zoom"] = zoom;
+ state["ofs"] = Point2(h_scroll->get_value(), v_scroll->get_value());
//state["ofs"]=-transform.get_origin();
- state["snap_offset"]=snap_offset;
- state["snap_step"]=snap_step;
- state["snap_rotation_offset"]=snap_rotation_offset;
- state["snap_rotation_step"]=snap_rotation_step;
- state["snap_grid"]=snap_grid;
- state["snap_show_grid"]=snap_show_grid;
- state["snap_rotation"]=snap_rotation;
- state["snap_relative"]=snap_relative;
- state["snap_pixel"]=snap_pixel;
- state["skeleton_show_bones"]=skeleton_show_bones;
+ state["snap_offset"] = snap_offset;
+ state["snap_step"] = snap_step;
+ state["snap_rotation_offset"] = snap_rotation_offset;
+ state["snap_rotation_step"] = snap_rotation_step;
+ state["snap_grid"] = snap_grid;
+ state["snap_show_grid"] = snap_show_grid;
+ state["snap_rotation"] = snap_rotation;
+ state["snap_relative"] = snap_relative;
+ state["snap_pixel"] = snap_pixel;
+ state["skeleton_show_bones"] = skeleton_show_bones;
return state;
}
-void CanvasItemEditor::set_state(const Dictionary& p_state){
+void CanvasItemEditor::set_state(const Dictionary &p_state) {
- Dictionary state=p_state;
+ Dictionary state = p_state;
if (state.has("zoom")) {
- zoom=p_state["zoom"];
+ zoom = p_state["zoom"];
}
if (state.has("ofs")) {
_update_scrollbars(); // i wonder how safe is calling this here..
- Point2 ofs=p_state["ofs"];
+ Point2 ofs = p_state["ofs"];
h_scroll->set_value(ofs.x);
v_scroll->set_value(ofs.y);
}
if (state.has("snap_step")) {
- snap_step=state["snap_step"];
+ snap_step = state["snap_step"];
}
if (state.has("snap_offset")) {
- snap_offset=state["snap_offset"];
+ snap_offset = state["snap_offset"];
}
if (state.has("snap_rotation_step")) {
- snap_rotation_step=state["snap_rotation_step"];
+ snap_rotation_step = state["snap_rotation_step"];
}
if (state.has("snap_rotation_offset")) {
- snap_rotation_offset=state["snap_rotation_offset"];
+ snap_rotation_offset = state["snap_rotation_offset"];
}
if (state.has("snap_grid")) {
- snap_grid=state["snap_grid"];
+ snap_grid = state["snap_grid"];
int idx = edit_menu->get_popup()->get_item_index(SNAP_USE);
- edit_menu->get_popup()->set_item_checked(idx,snap_grid);
+ edit_menu->get_popup()->set_item_checked(idx, snap_grid);
}
if (state.has("snap_show_grid")) {
- snap_show_grid=state["snap_show_grid"];
+ snap_show_grid = state["snap_show_grid"];
int idx = edit_menu->get_popup()->get_item_index(SNAP_SHOW_GRID);
- edit_menu->get_popup()->set_item_checked(idx,snap_show_grid);
+ edit_menu->get_popup()->set_item_checked(idx, snap_show_grid);
}
if (state.has("snap_rotation")) {
- snap_rotation=state["snap_rotation"];
+ snap_rotation = state["snap_rotation"];
int idx = edit_menu->get_popup()->get_item_index(SNAP_USE_ROTATION);
- edit_menu->get_popup()->set_item_checked(idx,snap_rotation);
+ edit_menu->get_popup()->set_item_checked(idx, snap_rotation);
}
if (state.has("snap_relative")) {
- snap_relative=state["snap_relative"];
+ snap_relative = state["snap_relative"];
int idx = edit_menu->get_popup()->get_item_index(SNAP_RELATIVE);
- edit_menu->get_popup()->set_item_checked(idx,snap_relative);
+ edit_menu->get_popup()->set_item_checked(idx, snap_relative);
}
if (state.has("snap_pixel")) {
- snap_pixel=state["snap_pixel"];
+ snap_pixel = state["snap_pixel"];
int idx = edit_menu->get_popup()->get_item_index(SNAP_USE_PIXEL);
- edit_menu->get_popup()->set_item_checked(idx,snap_pixel);
+ edit_menu->get_popup()->set_item_checked(idx, snap_pixel);
}
if (state.has("skeleton_show_bones")) {
- skeleton_show_bones=state["skeleton_show_bones"];
+ skeleton_show_bones = state["skeleton_show_bones"];
int idx = skeleton_menu->get_item_index(SKELETON_SHOW_BONES);
- skeleton_menu->set_item_checked(idx,skeleton_show_bones);
+ skeleton_menu->set_item_checked(idx, skeleton_show_bones);
}
}
-
void CanvasItemEditor::_add_canvas_item(CanvasItem *p_canvas_item) {
editor_selection->add_node(p_canvas_item);
@@ -388,7 +377,6 @@ void CanvasItemEditor::_remove_canvas_item(CanvasItem *p_canvas_item) {
p_canvas_item->disconnect("hide",this,"_visibility_changed");
canvas_items.erase(p_canvas_item);
#endif
-
}
void CanvasItemEditor::_clear_canvas_items() {
@@ -413,7 +401,6 @@ void CanvasItemEditor::_visibility_changed(ObjectID p_canvas_item) {
#endif
}
-
void CanvasItemEditor::_node_removed(Node *p_node) {
#if 0
CanvasItem *canvas_item = (CanvasItem*)p_node; //not a good cast, but safe
@@ -434,32 +421,31 @@ void CanvasItemEditor::_keying_changed() {
bool CanvasItemEditor::_is_part_of_subscene(CanvasItem *p_item) {
- Node* scene_node = get_tree()->get_edited_scene_root();
- Node* item_owner = p_item->get_owner();
+ Node *scene_node = get_tree()->get_edited_scene_root();
+ Node *item_owner = p_item->get_owner();
- return item_owner && item_owner!=scene_node && p_item!=scene_node && item_owner->get_filename()!="";
+ return item_owner && item_owner != scene_node && p_item != scene_node && item_owner->get_filename() != "";
}
// slow but modern computers should have no problem
-CanvasItem* CanvasItemEditor::_select_canvas_item_at_pos(const Point2& p_pos,Node* p_node,const Transform2D& p_parent_xform,const Transform2D& p_canvas_xform) {
+CanvasItem *CanvasItemEditor::_select_canvas_item_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform) {
if (!p_node)
return NULL;
if (p_node->cast_to<Viewport>())
return NULL;
- CanvasItem *c=p_node->cast_to<CanvasItem>();
-
+ CanvasItem *c = p_node->cast_to<CanvasItem>();
- for (int i=p_node->get_child_count()-1;i>=0;i--) {
+ for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
- CanvasItem *r=NULL;
+ CanvasItem *r = NULL;
if (c && !c->is_set_as_toplevel())
- r=_select_canvas_item_at_pos(p_pos,p_node->get_child(i),p_parent_xform * c->get_transform(),p_canvas_xform);
+ r = _select_canvas_item_at_pos(p_pos, p_node->get_child(i), p_parent_xform * c->get_transform(), p_canvas_xform);
else {
CanvasLayer *cl = p_node->cast_to<CanvasLayer>();
- r=_select_canvas_item_at_pos(p_pos,p_node->get_child(i),transform ,cl ? cl->get_transform() : p_canvas_xform); //use base transform
+ r = _select_canvas_item_at_pos(p_pos, p_node->get_child(i), transform, cl ? cl->get_transform() : p_canvas_xform); //use base transform
}
if (r)
@@ -471,79 +457,73 @@ CanvasItem* CanvasItemEditor::_select_canvas_item_at_pos(const Point2& p_pos,Nod
Rect2 rect = c->get_item_rect();
Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos);
-
if (rect.has_point(local_pos))
return c;
-
}
return NULL;
}
-void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos,Node* p_node,const Transform2D& p_parent_xform,const Transform2D& p_canvas_xform, Vector<_SelectResult> &r_items) {
+void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items) {
if (!p_node)
return;
if (p_node->cast_to<Viewport>())
return;
- CanvasItem *c=p_node->cast_to<CanvasItem>();
+ CanvasItem *c = p_node->cast_to<CanvasItem>();
- 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 (c && !c->is_set_as_toplevel())
- _find_canvas_items_at_pos(p_pos,p_node->get_child(i),p_parent_xform * c->get_transform(),p_canvas_xform, r_items);
+ _find_canvas_items_at_pos(p_pos, p_node->get_child(i), p_parent_xform * c->get_transform(), p_canvas_xform, r_items);
else {
CanvasLayer *cl = p_node->cast_to<CanvasLayer>();
- _find_canvas_items_at_pos(p_pos,p_node->get_child(i),transform ,cl ? cl->get_transform() : p_canvas_xform, r_items); //use base transform
+ _find_canvas_items_at_pos(p_pos, p_node->get_child(i), transform, cl ? cl->get_transform() : p_canvas_xform, r_items); //use base transform
}
}
-
if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) {
Rect2 rect = c->get_item_rect();
Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos);
-
if (rect.has_point(local_pos)) {
- Node2D *node=c->cast_to<Node2D>();
+ Node2D *node = c->cast_to<Node2D>();
_SelectResult res;
- res.item=c;
- res.z=node?node->get_z():0;
- res.has_z=node;
+ res.item = c;
+ res.z = node ? node->get_z() : 0;
+ res.has_z = node;
r_items.push_back(res);
}
-
}
return;
}
-void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2& p_rect,Node* p_node,const Transform2D& p_parent_xform,const Transform2D& p_canvas_xform,List<CanvasItem*> *r_items) {
+void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, List<CanvasItem *> *r_items) {
if (!p_node)
return;
if (p_node->cast_to<Viewport>())
return;
- CanvasItem *c=p_node->cast_to<CanvasItem>();
-
+ CanvasItem *c = p_node->cast_to<CanvasItem>();
- bool inherited=p_node!=get_tree()->get_edited_scene_root() && p_node->get_filename()!="";
- bool editable=false;
- if (inherited){
- editable=EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node);
+ bool inherited = p_node != get_tree()->get_edited_scene_root() && p_node->get_filename() != "";
+ bool editable = false;
+ if (inherited) {
+ editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node);
}
- bool lock_children=p_node->has_meta("_edit_group_") && p_node->get_meta("_edit_group_");
+ bool lock_children = p_node->has_meta("_edit_group_") && p_node->get_meta("_edit_group_");
if (!lock_children && (!inherited || editable)) {
- 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 (c && !c->is_set_as_toplevel())
- _find_canvas_items_at_rect(p_rect,p_node->get_child(i),p_parent_xform * c->get_transform(),p_canvas_xform,r_items);
+ _find_canvas_items_at_rect(p_rect, p_node->get_child(i), p_parent_xform * c->get_transform(), p_canvas_xform, r_items);
else {
CanvasLayer *cl = p_node->cast_to<CanvasLayer>();
- _find_canvas_items_at_rect(p_rect,p_node->get_child(i),transform,cl?cl->get_transform():p_canvas_xform,r_items);
+ _find_canvas_items_at_rect(p_rect, p_node->get_child(i), transform, cl ? cl->get_transform() : p_canvas_xform, r_items);
}
}
}
@@ -553,17 +533,14 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2& p_rect,Node* p_no
Rect2 rect = c->get_item_rect();
Transform2D xform = p_parent_xform * p_canvas_xform * c->get_transform();
- if ( p_rect.has_point( xform.xform( rect.pos ) ) &&
- p_rect.has_point( xform.xform( rect.pos+Vector2(rect.size.x,0) ) ) &&
- p_rect.has_point( xform.xform( rect.pos+Vector2(rect.size.x,rect.size.y) ) ) &&
- p_rect.has_point( xform.xform( rect.pos+Vector2(0,rect.size.y) ) ) ) {
+ if (p_rect.has_point(xform.xform(rect.pos)) &&
+ p_rect.has_point(xform.xform(rect.pos + Vector2(rect.size.x, 0))) &&
+ p_rect.has_point(xform.xform(rect.pos + Vector2(rect.size.x, rect.size.y))) &&
+ p_rect.has_point(xform.xform(rect.pos + Vector2(0, rect.size.y)))) {
r_items->push_back(c);
-
}
}
-
-
}
bool CanvasItemEditor::_select(CanvasItem *item, Point2 p_click_pos, bool p_append, bool p_drag) {
@@ -574,10 +551,10 @@ bool CanvasItemEditor::_select(CanvasItem *item, Point2 p_click_pos, bool p_appe
if (!item) {
if (p_drag) {
- drag_from=transform.affine_inverse().xform(p_click_pos);
+ drag_from = transform.affine_inverse().xform(p_click_pos);
- box_selecting=true;
- box_selecting_to=drag_from;
+ box_selecting = true;
+ box_selecting_to = drag_from;
}
return false; //nothing to add
@@ -590,7 +567,6 @@ bool CanvasItemEditor::_select(CanvasItem *item, Point2 p_click_pos, bool p_appe
viewport->update();
return false;
-
}
_append_canvas_item(item);
viewport->update();
@@ -605,10 +581,10 @@ bool CanvasItemEditor::_select(CanvasItem *item, Point2 p_click_pos, bool p_appe
editor_selection->clear();
if (p_drag) {
- drag_from=transform.affine_inverse().xform(p_click_pos);
+ drag_from = transform.affine_inverse().xform(p_click_pos);
- box_selecting=true;
- box_selecting_to=drag_from;
+ box_selecting = true;
+ box_selecting_to = drag_from;
}
viewport->update();
@@ -621,88 +597,83 @@ bool CanvasItemEditor::_select(CanvasItem *item, Point2 p_click_pos, bool p_appe
editor_selection->add_node(item);
//reselect
if (get_tree()->is_editor_hint()) {
- editor->call("edit_node",item);
+ editor->call("edit_node", item);
}
-
}
if (p_drag) {
//prepare to move!
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
- se->undo_state=canvas_item->edit_get_state();
+ se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>())
- se->undo_pivot=canvas_item->cast_to<Node2D>()->edit_get_pivot();
-
+ se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
}
- drag=DRAG_ALL;
- drag_from=transform.affine_inverse().xform(p_click_pos);
- drag_point_from=_find_topleftmost_point();
+ drag = DRAG_ALL;
+ drag_from = transform.affine_inverse().xform(p_click_pos);
+ drag_point_from = _find_topleftmost_point();
}
viewport->update();
return true;
-
}
}
-void CanvasItemEditor::_key_move(const Vector2& p_dir, bool p_snap, KeyMoveMODE p_move_mode) {
-
+void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE p_move_mode) {
- if (drag!=DRAG_NONE)
+ if (drag != DRAG_NONE)
return;
if (editor_selection->get_selected_node_list().empty())
return;
- undo_redo->create_action(TTR("Move Action"),UndoRedo::MERGE_ENDS);
+ undo_redo->create_action(TTR("Move Action"), UndoRedo::MERGE_ENDS);
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
if (canvas_item->has_meta("_edit_lock_"))
continue;
-
Vector2 drag = p_dir;
if (p_snap)
- drag*=snap_step;
+ drag *= snap_step;
- undo_redo->add_undo_method(canvas_item,"edit_set_state",canvas_item->edit_get_state());
+ undo_redo->add_undo_method(canvas_item, "edit_set_state", canvas_item->edit_get_state());
- if (p_move_mode == MOVE_VIEW_BASE) {
+ if (p_move_mode == MOVE_VIEW_BASE) {
// drag = transform.affine_inverse().basis_xform(p_dir); // zoom sensitive
drag = canvas_item->get_global_transform_with_canvas().affine_inverse().basis_xform(drag);
Rect2 local_rect = canvas_item->get_item_rect();
- local_rect.pos+=drag;
- undo_redo->add_do_method(canvas_item,"edit_set_rect",local_rect);
+ local_rect.pos += drag;
+ undo_redo->add_do_method(canvas_item, "edit_set_rect", local_rect);
} else { // p_move_mode==MOVE_LOCAL_BASE || p_move_mode==MOVE_LOCAL_WITH_ROT
@@ -710,14 +681,14 @@ void CanvasItemEditor::_key_move(const Vector2& p_dir, bool p_snap, KeyMoveMODE
if (p_move_mode == MOVE_LOCAL_WITH_ROT) {
Transform2D m;
- m.rotate( node_2d->get_rotation() );
+ m.rotate(node_2d->get_rotation());
drag = m.xform(drag);
}
node_2d->set_position(node_2d->get_position() + drag);
} else if (Control *control = canvas_item->cast_to<Control>()) {
- control->set_pos(control->get_pos()+drag);
+ control->set_pos(control->get_pos() + drag);
}
}
}
@@ -727,53 +698,44 @@ void CanvasItemEditor::_key_move(const Vector2& p_dir, bool p_snap, KeyMoveMODE
Point2 CanvasItemEditor::_find_topleftmost_point() {
-
-
- Vector2 tl=Point2(1e10,1e10);
+ Vector2 tl = Point2(1e10, 1e10);
Rect2 r2;
- r2.pos=tl;
-
+ r2.pos = tl;
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
-
-
-
- Rect2 rect=canvas_item->get_item_rect();
- Transform2D xform=canvas_item->get_global_transform_with_canvas();
+ Rect2 rect = canvas_item->get_item_rect();
+ Transform2D xform = canvas_item->get_global_transform_with_canvas();
r2.expand_to(xform.xform(rect.pos));
- r2.expand_to(xform.xform(rect.pos+Vector2(rect.size.x,0)));
- r2.expand_to(xform.xform(rect.pos+rect.size));
- r2.expand_to(xform.xform(rect.pos+Vector2(0,rect.size.y)));
-
+ r2.expand_to(xform.xform(rect.pos + Vector2(rect.size.x, 0)));
+ r2.expand_to(xform.xform(rect.pos + rect.size));
+ r2.expand_to(xform.xform(rect.pos + Vector2(0, rect.size.y)));
}
return r2.pos;
}
-
-
int CanvasItemEditor::get_item_count() {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- int ic=0;
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ int ic = 0;
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
ic++;
@@ -784,55 +746,54 @@ int CanvasItemEditor::get_item_count() {
CanvasItem *CanvasItemEditor::get_single_item() {
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
- Map<Node*,Object*> &selection = editor_selection->get_selection();
-
- CanvasItem *single_item=NULL;
+ CanvasItem *single_item = NULL;
- for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
if (single_item)
return NULL; //morethan one
- single_item=canvas_item;
+ single_item = canvas_item;
};
return single_item;
}
-CanvasItemEditor::DragType CanvasItemEditor::_find_drag_type(const Transform2D& p_xform, const Rect2& p_local_rect, const Point2& p_click, Vector2& r_point) {
+CanvasItemEditor::DragType CanvasItemEditor::_find_drag_type(const Transform2D &p_xform, const Rect2 &p_local_rect, const Point2 &p_click, Vector2 &r_point) {
CanvasItem *canvas_item = get_single_item();
- ERR_FAIL_COND_V(!canvas_item,DRAG_NONE);
+ ERR_FAIL_COND_V(!canvas_item, DRAG_NONE);
- Rect2 rect=canvas_item->get_item_rect();
- Transform2D xforml=canvas_item->get_global_transform_with_canvas();
- Transform2D xform=transform * xforml;
+ Rect2 rect = canvas_item->get_item_rect();
+ Transform2D xforml = canvas_item->get_global_transform_with_canvas();
+ Transform2D xform = transform * xforml;
- Vector2 endpoints[4]={
+ Vector2 endpoints[4] = {
xform.xform(rect.pos),
- xform.xform(rect.pos+Vector2(rect.size.x,0)),
- xform.xform(rect.pos+rect.size),
- xform.xform(rect.pos+Vector2(0,rect.size.y))
+ xform.xform(rect.pos + Vector2(rect.size.x, 0)),
+ xform.xform(rect.pos + rect.size),
+ xform.xform(rect.pos + Vector2(0, rect.size.y))
};
- Vector2 endpointsl[4]={
+ Vector2 endpointsl[4] = {
xforml.xform(rect.pos),
- xforml.xform(rect.pos+Vector2(rect.size.x,0)),
- xforml.xform(rect.pos+rect.size),
- xforml.xform(rect.pos+Vector2(0,rect.size.y))
+ xforml.xform(rect.pos + Vector2(rect.size.x, 0)),
+ xforml.xform(rect.pos + rect.size),
+ xforml.xform(rect.pos + Vector2(0, rect.size.y))
};
- DragType dragger[]={
+ DragType dragger[] = {
DRAG_TOP_LEFT,
DRAG_TOP,
DRAG_TOP_RIGHT,
@@ -843,34 +804,32 @@ CanvasItemEditor::DragType CanvasItemEditor::_find_drag_type(const Transform2D&
DRAG_LEFT
};
- float radius = (select_handle->get_size().width/2)*1.5;
+ float radius = (select_handle->get_size().width / 2) * 1.5;
//try draggers
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- int prev = (i+3)%4;
- int next = (i+1)%4;
+ int prev = (i + 3) % 4;
+ int next = (i + 1) % 4;
- r_point=endpointsl[i];
+ r_point = endpointsl[i];
Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized();
- ofs*=1.4144*(select_handle->get_size().width/2);
+ ofs *= 1.4144 * (select_handle->get_size().width / 2);
- ofs+=endpoints[i];
+ ofs += endpoints[i];
- if (ofs.distance_to(p_click)<radius)
- return dragger[i*2];
+ if (ofs.distance_to(p_click) < radius)
+ return dragger[i * 2];
- ofs = (endpoints[i]+endpoints[next])/2;
- ofs += (endpoints[next]-endpoints[i]).tangent().normalized()*(select_handle->get_size().width/2);
+ ofs = (endpoints[i] + endpoints[next]) / 2;
+ ofs += (endpoints[next] - endpoints[i]).tangent().normalized() * (select_handle->get_size().width / 2);
- r_point=(endpointsl[i]+endpointsl[next])/2;
-
-
- if (ofs.distance_to(p_click)<radius)
- return dragger[i*2+1];
+ r_point = (endpointsl[i] + endpointsl[next]) / 2;
+ if (ofs.distance_to(p_click) < radius)
+ return dragger[i * 2 + 1];
}
/*
@@ -884,70 +843,66 @@ CanvasItemEditor::DragType CanvasItemEditor::_find_drag_type(const Transform2D&
return DRAG_NONE;
}
-void CanvasItemEditor::incbeg(float& beg,float &end, float inc, float minsize,bool p_symmetric) {
+void CanvasItemEditor::incbeg(float &beg, float &end, float inc, float minsize, bool p_symmetric) {
- if (minsize<0) {
+ if (minsize < 0) {
- beg+=inc;
+ beg += inc;
if (p_symmetric)
- end-=inc;
+ end -= inc;
} else {
if (p_symmetric) {
- beg+=inc;
- end-=inc;
- if (end-beg < minsize) {
- float center = (beg+end)/2.0;
- beg=center-minsize/2.0;
- end=center+minsize/2.0;
+ beg += inc;
+ end -= inc;
+ if (end - beg < minsize) {
+ float center = (beg + end) / 2.0;
+ beg = center - minsize / 2.0;
+ end = center + minsize / 2.0;
}
} else {
- if (end-(beg+inc) < minsize)
- beg=end-minsize;
+ if (end - (beg + inc) < minsize)
+ beg = end - minsize;
else
- beg+=inc;
+ beg += inc;
}
-
}
}
-void CanvasItemEditor::incend(float &beg,float& end, float inc, float minsize,bool p_symmetric) {
+void CanvasItemEditor::incend(float &beg, float &end, float inc, float minsize, bool p_symmetric) {
- if (minsize<0) {
+ if (minsize < 0) {
- end+=inc;
+ end += inc;
if (p_symmetric)
- beg-=inc;
+ beg -= inc;
} else {
if (p_symmetric) {
- end+=inc;
- beg-=inc;
- if (end-beg < minsize) {
- float center = (beg+end)/2.0;
- beg=center-minsize/2.0;
- end=center+minsize/2.0;
+ end += inc;
+ beg -= inc;
+ if (end - beg < minsize) {
+ float center = (beg + end) / 2.0;
+ beg = center - minsize / 2.0;
+ end = center + minsize / 2.0;
}
} else {
- if ((end+inc)-beg < minsize)
- end=beg+minsize;
+ if ((end + inc) - beg < minsize)
+ end = beg + minsize;
else
- end+=inc;
+ end += inc;
}
-
}
}
void CanvasItemEditor::_append_canvas_item(CanvasItem *c) {
editor_selection->add_node(c);
-
}
-
void CanvasItemEditor::_snap_changed() {
((SnapDialog *)snap_dialog)->get_fields(snap_offset, snap_step, snap_rotation_offset, snap_rotation_step);
viewport->update();
@@ -958,16 +913,16 @@ void CanvasItemEditor::_dialog_value_changed(double) {
if (updating_value_dialog)
return;
- switch(last_option) {
+ switch (last_option) {
case ZOOM_SET: {
- zoom=dialog_val->get_value()/100.0;
+ zoom = dialog_val->get_value() / 100.0;
_update_scroll(0);
viewport->update();
} break;
- default:{}
+ default: {}
}
}
@@ -976,7 +931,7 @@ void CanvasItemEditor::_selection_result_pressed(int p_result) {
if (selection_results.size() <= p_result)
return;
- CanvasItem *item=selection_results[p_result].item;
+ CanvasItem *item = selection_results[p_result].item;
if (item)
_select(item, Point2(), additive_selection, false);
@@ -989,31 +944,28 @@ void CanvasItemEditor::_selection_menu_hide() {
selection_menu->set_size(Vector2(0, 0));
}
-bool CanvasItemEditor::get_remove_list(List<Node*> *p_list) {
+bool CanvasItemEditor::get_remove_list(List<Node *> *p_list) {
-
- return false;//!p_list->empty();
+ return false; //!p_list->empty();
}
+void CanvasItemEditor::_list_select(const InputEventMouseButton &b) {
-void CanvasItemEditor::_list_select(const InputEventMouseButton& b) {
-
- Point2 click=Point2(b.x,b.y);
+ Point2 click = Point2(b.x, b.y);
- Node* scene = editor->get_edited_scene();
+ Node *scene = editor->get_edited_scene();
if (!scene)
return;
- _find_canvas_items_at_pos(click, scene,transform,Transform2D(), selection_results);
+ _find_canvas_items_at_pos(click, scene, transform, Transform2D(), selection_results);
- for(int i=0;i<selection_results.size();i++) {
- CanvasItem *item=selection_results[i].item;
- if (item!=scene && item->get_owner()!=scene && !scene->is_editable_instance(item->get_owner())) {
+ for (int i = 0; i < selection_results.size(); i++) {
+ CanvasItem *item = selection_results[i].item;
+ if (item != scene && item->get_owner() != scene && !scene->is_editable_instance(item->get_owner())) {
//invalid result
selection_results.remove(i);
i--;
}
-
}
if (selection_results.size() == 1) {
@@ -1021,7 +973,7 @@ void CanvasItemEditor::_list_select(const InputEventMouseButton& b) {
CanvasItem *item = selection_results[0].item;
selection_results.clear();
- additive_selection=b.mod.shift;
+ additive_selection = b.mod.shift;
if (!_select(item, click, additive_selection, false))
return;
@@ -1030,50 +982,47 @@ void CanvasItemEditor::_list_select(const InputEventMouseButton& b) {
selection_results.sort();
NodePath root_path = get_tree()->get_edited_scene_root()->get_path();
- StringName root_name = root_path.get_name(root_path.get_name_count()-1);
+ StringName root_name = root_path.get_name(root_path.get_name_count() - 1);
for (int i = 0; i < selection_results.size(); i++) {
- CanvasItem *item=selection_results[i].item;
-
+ CanvasItem *item = selection_results[i].item;
Ref<Texture> icon;
if (item->has_meta("_editor_icon"))
- icon=item->get_meta("_editor_icon");
+ icon = item->get_meta("_editor_icon");
else
- icon=get_icon( has_icon(item->get_class(),"EditorIcons")?item->get_class():String("Object"),"EditorIcons");
+ icon = get_icon(has_icon(item->get_class(), "EditorIcons") ? item->get_class() : String("Object"), "EditorIcons");
- String node_path="/"+root_name+"/"+root_path.rel_path_to(item->get_path());
+ String node_path = "/" + root_name + "/" + root_path.rel_path_to(item->get_path());
selection_menu->add_item(item->get_name());
- selection_menu->set_item_icon(i, icon );
+ selection_menu->set_item_icon(i, icon);
selection_menu->set_item_metadata(i, node_path);
- selection_menu->set_item_tooltip(i,String(item->get_name())+
- "\nType: "+item->get_class()+"\nPath: "+node_path);
+ selection_menu->set_item_tooltip(i, String(item->get_name()) +
+ "\nType: " + item->get_class() + "\nPath: " + node_path);
}
- additive_selection=b.mod.shift;
+ additive_selection = b.mod.shift;
- selection_menu->set_global_pos(Vector2( b.global_x, b.global_y ));
+ selection_menu->set_global_pos(Vector2(b.global_x, b.global_y));
selection_menu->popup();
selection_menu->call_deferred("grab_click_focus");
selection_menu->set_invalidate_click_until_motion();
-
return;
}
-
}
-void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
+void CanvasItemEditor::_viewport_gui_input(const InputEvent &p_event) {
- {
+ {
EditorNode *en = editor;
EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
if (!over_plugin_list->empty()) {
- bool discard = over_plugin_list->forward_gui_input(transform,p_event);
+ bool discard = over_plugin_list->forward_gui_input(transform, p_event);
if (discard) {
accept_event();
return;
@@ -1081,42 +1030,40 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
}
}
+ if (p_event.type == InputEvent::MOUSE_BUTTON) {
- if (p_event.type==InputEvent::MOUSE_BUTTON) {
-
- const InputEventMouseButton &b=p_event.mouse_button;
+ const InputEventMouseButton &b = p_event.mouse_button;
+ if (b.button_index == BUTTON_WHEEL_DOWN) {
- if (b.button_index==BUTTON_WHEEL_DOWN) {
-
- if (zoom<MIN_ZOOM)
+ if (zoom < MIN_ZOOM)
return;
- float prev_zoom=zoom;
- zoom=zoom*0.95;
+ float prev_zoom = zoom;
+ zoom = zoom * 0.95;
{
- Point2 ofs(b.x,b.y);
- ofs = ofs/prev_zoom - ofs/zoom;
- h_scroll->set_value( h_scroll->get_value() + ofs.x );
- v_scroll->set_value( v_scroll->get_value() + ofs.y );
+ Point2 ofs(b.x, b.y);
+ ofs = ofs / prev_zoom - ofs / zoom;
+ h_scroll->set_value(h_scroll->get_value() + ofs.x);
+ v_scroll->set_value(v_scroll->get_value() + ofs.y);
}
_update_scroll(0);
viewport->update();
return;
}
- if (b.button_index==BUTTON_WHEEL_UP) {
+ if (b.button_index == BUTTON_WHEEL_UP) {
- if (zoom>MAX_ZOOM)
+ if (zoom > MAX_ZOOM)
return;
- float prev_zoom=zoom;
- zoom=zoom*(1.0/0.95);
+ float prev_zoom = zoom;
+ zoom = zoom * (1.0 / 0.95);
{
- Point2 ofs(b.x,b.y);
- ofs = ofs/prev_zoom - ofs/zoom;
- h_scroll->set_value( h_scroll->get_value() + ofs.x );
- v_scroll->set_value( v_scroll->get_value() + ofs.y );
+ Point2 ofs(b.x, b.y);
+ ofs = ofs / prev_zoom - ofs / zoom;
+ h_scroll->set_value(h_scroll->get_value() + ofs.x);
+ v_scroll->set_value(v_scroll->get_value() + ofs.y);
}
_update_scroll(0);
@@ -1124,21 +1071,20 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
return;
}
- if (b.button_index==BUTTON_RIGHT) {
-
+ if (b.button_index == BUTTON_RIGHT) {
- if (b.pressed && (tool==TOOL_SELECT && b.mod.alt)) {
+ if (b.pressed && (tool == TOOL_SELECT && b.mod.alt)) {
_list_select(b);
return;
}
- if (get_item_count() > 0 && drag!=DRAG_NONE) {
+ if (get_item_count() > 0 && drag != DRAG_NONE) {
//cancel drag
if (bone_ik_list.size()) {
- for(List<BoneIK>::Element *E=bone_ik_list.back();E;E=E->prev()) {
+ for (List<BoneIK>::Element *E = bone_ik_list.back(); E; E = E->prev()) {
E->get().node->edit_set_state(E->get().orig_state);
}
@@ -1147,35 +1093,32 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
} else {
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- List<Node*> &selection = editor_selection->get_selected_node_list();
-
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
-
- CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
canvas_item->edit_set_state(se->undo_state);
if (canvas_item->cast_to<Node2D>())
canvas_item->cast_to<Node2D>()->edit_set_pivot(se->undo_pivot);
-
}
}
- drag=DRAG_NONE;
+ drag = DRAG_NONE;
viewport->update();
- can_move_pivot=false;
+ can_move_pivot = false;
} else if (box_selecting) {
- box_selecting=false;
+ box_selecting = false;
viewport->update();
} else if (b.pressed) {
#if 0
@@ -1193,49 +1136,44 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
return;
*/
- if (b.button_index==BUTTON_LEFT && tool==TOOL_LIST_SELECT) {
+ if (b.button_index == BUTTON_LEFT && tool == TOOL_LIST_SELECT) {
if (b.pressed)
_list_select(b);
return;
}
-
- if (b.button_index==BUTTON_LEFT && tool==TOOL_EDIT_PIVOT) {
+ if (b.button_index == BUTTON_LEFT && tool == TOOL_EDIT_PIVOT) {
if (b.pressed) {
- Point2 mouse_pos(b.x,b.y);
- mouse_pos=transform.affine_inverse().xform(mouse_pos);
- mouse_pos=snap_point(mouse_pos);
+ Point2 mouse_pos(b.x, b.y);
+ mouse_pos = transform.affine_inverse().xform(mouse_pos);
+ mouse_pos = snap_point(mouse_pos);
_edit_set_pivot(mouse_pos);
}
return;
}
-
-
- if (tool==TOOL_PAN || b.button_index!=BUTTON_LEFT || Input::get_singleton()->is_key_pressed(KEY_SPACE))
+ if (tool == TOOL_PAN || b.button_index != BUTTON_LEFT || Input::get_singleton()->is_key_pressed(KEY_SPACE))
return;
if (!b.pressed) {
- if (drag!=DRAG_NONE) {
+ if (drag != DRAG_NONE) {
if (undo_redo) {
-
if (bone_ik_list.size()) {
-
undo_redo->create_action(TTR("Edit IK Chain"));
- for(List<BoneIK>::Element *E=bone_ik_list.back();E;E=E->prev()) {
+ for (List<BoneIK>::Element *E = bone_ik_list.back(); E; E = E->prev()) {
- undo_redo->add_do_method(E->get().node,"edit_set_state",E->get().node->edit_get_state());
- undo_redo->add_undo_method(E->get().node,"edit_set_state",E->get().orig_state);
+ undo_redo->add_do_method(E->get().node, "edit_set_state", E->get().node->edit_get_state());
+ undo_redo->add_undo_method(E->get().node, "edit_set_state", E->get().orig_state);
}
- undo_redo->add_do_method(viewport,"update");
- undo_redo->add_undo_method(viewport,"update");
+ undo_redo->add_do_method(viewport, "update");
+ undo_redo->add_undo_method(viewport, "update");
bone_ik_list.clear();
@@ -1244,29 +1182,28 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
undo_redo->create_action(TTR("Edit CanvasItem"));
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- List<Node*> &selection = editor_selection->get_selected_node_list();
-
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
- Variant state=canvas_item->edit_get_state();
- undo_redo->add_do_method(canvas_item,"edit_set_state",state);
- undo_redo->add_undo_method(canvas_item,"edit_set_state",se->undo_state);
+ Variant state = canvas_item->edit_get_state();
+ undo_redo->add_do_method(canvas_item, "edit_set_state", state);
+ undo_redo->add_undo_method(canvas_item, "edit_set_state", se->undo_state);
if (canvas_item->cast_to<Node2D>()) {
Node2D *pvt = canvas_item->cast_to<Node2D>();
if (pvt->edit_has_pivot()) {
- undo_redo->add_do_method(canvas_item,"edit_set_pivot",pvt->edit_get_pivot());
- undo_redo->add_undo_method(canvas_item,"edit_set_pivot",se->undo_pivot);
+ undo_redo->add_do_method(canvas_item, "edit_set_pivot", pvt->edit_get_pivot());
+ undo_redo->add_undo_method(canvas_item, "edit_set_pivot", se->undo_pivot);
}
}
}
@@ -1274,10 +1211,9 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
}
}
- drag=DRAG_NONE;
+ drag = DRAG_NONE;
viewport->update();
- can_move_pivot=false;
-
+ can_move_pivot = false;
}
if (box_selecting) {
@@ -1286,110 +1222,102 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
if ( box_selection_end() ) return;
#endif
- Node* scene = editor->get_edited_scene();
+ Node *scene = editor->get_edited_scene();
if (scene) {
- List<CanvasItem*> selitems;
+ List<CanvasItem *> selitems;
Point2 bsfrom = transform.xform(drag_from);
- Point2 bsto= transform.xform(box_selecting_to);
- if (bsfrom.x>bsto.x)
- SWAP(bsfrom.x,bsto.x);
- if (bsfrom.y>bsto.y)
- SWAP(bsfrom.y,bsto.y);
+ Point2 bsto = transform.xform(box_selecting_to);
+ if (bsfrom.x > bsto.x)
+ SWAP(bsfrom.x, bsto.x);
+ if (bsfrom.y > bsto.y)
+ SWAP(bsfrom.y, bsto.y);
- _find_canvas_items_at_rect(Rect2(bsfrom,bsto-bsfrom),scene,transform,Transform2D(),&selitems);
+ _find_canvas_items_at_rect(Rect2(bsfrom, bsto - bsfrom), scene, transform, Transform2D(), &selitems);
- for(List<CanvasItem*>::Element *E=selitems.front();E;E=E->next()) {
+ for (List<CanvasItem *>::Element *E = selitems.front(); E; E = E->next()) {
_append_canvas_item(E->get());
}
-
}
- box_selecting=false;
+ box_selecting = false;
viewport->update();
-
}
return;
}
-
- Map<ObjectID,BoneList>::Element *Cbone=NULL; //closest
+ Map<ObjectID, BoneList>::Element *Cbone = NULL; //closest
{
bone_ik_list.clear();
- float closest_dist=1e20;
+ float closest_dist = 1e20;
int bone_width = EditorSettings::get_singleton()->get("editors/2d/bone_width");
- for(Map<ObjectID,BoneList>::Element *E=bone_list.front();E;E=E->next()) {
+ for (Map<ObjectID, BoneList>::Element *E = bone_list.front(); E; E = E->next()) {
if (E->get().from == E->get().to)
continue;
- Vector2 s[2]={
+ Vector2 s[2] = {
E->get().from,
E->get().to
};
- Vector2 p = Geometry::get_closest_point_to_segment_2d(Vector2(b.x,b.y),s);
- float d = p.distance_to(Vector2(b.x,b.y));
- if (d<bone_width && d<closest_dist) {
- Cbone=E;
- closest_dist=d;
+ Vector2 p = Geometry::get_closest_point_to_segment_2d(Vector2(b.x, b.y), s);
+ float d = p.distance_to(Vector2(b.x, b.y));
+ if (d < bone_width && d < closest_dist) {
+ Cbone = E;
+ closest_dist = d;
}
}
if (Cbone) {
- Node2D *b=NULL;
- Object* obj=ObjectDB::get_instance(Cbone->get().bone);
+ Node2D *b = NULL;
+ Object *obj = ObjectDB::get_instance(Cbone->get().bone);
if (obj)
- b=obj->cast_to<Node2D>();
+ b = obj->cast_to<Node2D>();
if (b) {
+ bool ik_found = false;
+ bool first = true;
- bool ik_found=false;
- bool first=true;
-
-
+ while (b) {
- while(b) {
-
- CanvasItem *pi=b->get_parent_item();
+ CanvasItem *pi = b->get_parent_item();
if (!pi)
break;
- float len=pi->get_global_transform().get_origin().distance_to(b->get_global_position());
- b=pi->cast_to<Node2D>();
+ float len = pi->get_global_transform().get_origin().distance_to(b->get_global_position());
+ b = pi->cast_to<Node2D>();
if (!b)
break;
if (first) {
- bone_orig_xform=b->get_global_transform();
- first=false;
+ bone_orig_xform = b->get_global_transform();
+ first = false;
}
BoneIK bik;
- bik.node=b;
- bik.len=len;
- bik.orig_state=b->edit_get_state();
+ bik.node = b;
+ bik.len = len;
+ bik.orig_state = b->edit_get_state();
bone_ik_list.push_back(bik);
if (b->has_meta("_edit_ik_")) {
- ik_found=bone_ik_list.size()>1;
+ ik_found = bone_ik_list.size() > 1;
break;
}
if (!pi->has_meta("_edit_bone_"))
break;
-
}
if (!ik_found)
bone_ik_list.clear();
-
}
}
}
@@ -1400,92 +1328,86 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
//try single canvas_item edit
CanvasItem *canvas_item = single_item;
- CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
ERR_FAIL_COND(!se);
+ Point2 click(b.x, b.y);
- Point2 click(b.x,b.y);
-
- if ((b.mod.control && tool==TOOL_SELECT) || tool==TOOL_ROTATE) {
+ if ((b.mod.control && tool == TOOL_SELECT) || tool == TOOL_ROTATE) {
- drag=DRAG_ROTATE;
- drag_from=transform.affine_inverse().xform(click);
- se->undo_state=canvas_item->edit_get_state();
+ drag = DRAG_ROTATE;
+ drag_from = transform.affine_inverse().xform(click);
+ se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>())
- se->undo_pivot=canvas_item->cast_to<Node2D>()->edit_get_pivot();
+ se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
if (canvas_item->cast_to<Control>())
- se->undo_pivot=Vector2();
+ se->undo_pivot = Vector2();
return;
}
Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
- Rect2 rect=canvas_item->get_item_rect();
+ Rect2 rect = canvas_item->get_item_rect();
//float handle_radius = handle_len * 1.4144; //magic number, guess what it means!
- if (tool==TOOL_SELECT) {
- drag = _find_drag_type(xform,rect,click,drag_point_from);
+ if (tool == TOOL_SELECT) {
+ drag = _find_drag_type(xform, rect, click, drag_point_from);
if (b.doubleclick) {
- if (canvas_item->get_filename()!="" && canvas_item!=editor->get_edited_scene()) {
+ if (canvas_item->get_filename() != "" && canvas_item != editor->get_edited_scene()) {
editor->open_request(canvas_item->get_filename());
return;
}
}
- if (drag!=DRAG_NONE && (!Cbone || drag!=DRAG_ALL)) {
- drag_from=transform.affine_inverse().xform(click);
- se->undo_state=canvas_item->edit_get_state();
+ if (drag != DRAG_NONE && (!Cbone || drag != DRAG_ALL)) {
+ drag_from = transform.affine_inverse().xform(click);
+ se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>())
- se->undo_pivot=canvas_item->cast_to<Node2D>()->edit_get_pivot();
+ se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
return;
}
} else {
- drag=DRAG_NONE;
+ drag = DRAG_NONE;
}
}
//multi canvas_item edit
+ Point2 click = Point2(b.x, b.y);
- Point2 click=Point2(b.x,b.y);
+ if ((b.mod.alt || tool == TOOL_MOVE) && get_item_count()) {
- if ((b.mod.alt || tool==TOOL_MOVE) && get_item_count()) {
+ List<Node *> &selection = editor_selection->get_selected_node_list();
-
- List<Node*> &selection = editor_selection->get_selected_node_list();
-
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
- se->undo_state=canvas_item->edit_get_state();
+ se->undo_state = canvas_item->edit_get_state();
if (canvas_item->cast_to<Node2D>())
- se->undo_pivot=canvas_item->cast_to<Node2D>()->edit_get_pivot();
-
+ se->undo_pivot = canvas_item->cast_to<Node2D>()->edit_get_pivot();
}
-
- drag=DRAG_ALL;
- drag_from=transform.affine_inverse().xform(click);
- drag_point_from=_find_topleftmost_point();
+ drag = DRAG_ALL;
+ drag_from = transform.affine_inverse().xform(click);
+ drag_point_from = _find_topleftmost_point();
viewport->update();
return;
-
}
- Node* scene = editor->get_edited_scene();
+ Node *scene = editor->get_edited_scene();
if (!scene)
return;
@@ -1494,33 +1416,30 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
//no window.... ?
click-=current_window->get_scroll();
}*/
- CanvasItem *c=NULL;
+ CanvasItem *c = NULL;
if (Cbone) {
- Object* obj=ObjectDB::get_instance(Cbone->get().bone);
+ Object *obj = ObjectDB::get_instance(Cbone->get().bone);
if (obj)
- c=obj->cast_to<CanvasItem>();
+ c = obj->cast_to<CanvasItem>();
if (c)
- c=c->get_parent_item();
-
-
+ c = c->get_parent_item();
}
if (!c) {
- c =_select_canvas_item_at_pos(click, scene,transform,Transform2D());
-
+ c = _select_canvas_item_at_pos(click, scene, transform, Transform2D());
- CanvasItem* cn = c;
+ CanvasItem *cn = c;
- while(cn) {
+ while (cn) {
if (cn->has_meta("_edit_group_")) {
- c=cn;
+ c = cn;
}
- cn=cn->get_parent_item();
+ cn = cn->get_parent_item();
}
}
- Node* n = c;
+ Node *n = c;
while ((n && n != scene && n->get_owner() != scene) || (n && !n->is_class("CanvasItem"))) {
n = n->get_parent();
@@ -1530,57 +1449,50 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
if ( b.pressed ) box_selection_start( click );
#endif
- additive_selection=b.mod.shift;
+ additive_selection = b.mod.shift;
if (!_select(c, click, additive_selection))
return;
-
}
- if (p_event.type==InputEvent::MOUSE_MOTION) {
+ if (p_event.type == InputEvent::MOUSE_MOTION) {
if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
viewport->call_deferred("grab_focus");
- const InputEventMouseMotion &m=p_event.mouse_motion;
+ const InputEventMouseMotion &m = p_event.mouse_motion;
if (box_selecting) {
- box_selecting_to=transform.affine_inverse().xform(Point2(m.x,m.y));
+ box_selecting_to = transform.affine_inverse().xform(Point2(m.x, m.y));
viewport->update();
return;
-
}
+ if (drag == DRAG_NONE) {
- if (drag==DRAG_NONE) {
-
-
- if ( (m.button_mask&BUTTON_MASK_LEFT && tool == TOOL_PAN) || m.button_mask&BUTTON_MASK_MIDDLE || (m.button_mask&BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
- h_scroll->set_value( h_scroll->get_value() - m.relative_x/zoom);
- v_scroll->set_value( v_scroll->get_value() - m.relative_y/zoom);
+ if ((m.button_mask & BUTTON_MASK_LEFT && tool == TOOL_PAN) || m.button_mask & BUTTON_MASK_MIDDLE || (m.button_mask & BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
+ h_scroll->set_value(h_scroll->get_value() - m.relative_x / zoom);
+ v_scroll->set_value(v_scroll->get_value() - m.relative_y / zoom);
}
return;
-
}
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
-
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
- bool dragging_bone = drag==DRAG_ALL && selection.size()==1 && bone_ik_list.size();
-
+ bool dragging_bone = drag == DRAG_ALL && selection.size() == 1 && bone_ik_list.size();
if (!dragging_bone) {
canvas_item->edit_set_state(se->undo_state); //reset state and reapply
@@ -1588,23 +1500,20 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
canvas_item->cast_to<Node2D>()->edit_set_pivot(se->undo_pivot);
}
-
Vector2 dfrom = drag_from;
- Vector2 dto = transform.affine_inverse().xform(Point2(m.x,m.y));
+ Vector2 dto = transform.affine_inverse().xform(Point2(m.x, m.y));
if (canvas_item->has_meta("_edit_lock_"))
continue;
-
- if (drag==DRAG_ROTATE) {
+ if (drag == DRAG_ROTATE) {
Vector2 center = canvas_item->get_global_transform_with_canvas().get_origin();
{
Node2D *node = canvas_item->cast_to<Node2D>();
-
if (node) {
real_t angle = node->get_rotation();
- node->set_rotation(snap_angle( angle + (dfrom - center).angle_to(dto-center), angle ));
+ node->set_rotation(snap_angle(angle + (dfrom - center).angle_to(dto - center), angle));
display_rotate_to = dto;
display_rotate_from = center;
viewport->update();
@@ -1614,10 +1523,9 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
{
Control *node = canvas_item->cast_to<Control>();
-
if (node) {
real_t angle = node->get_rotation();
- node->set_rotation(snap_angle( angle + (dfrom - center).angle_to(dto-center), angle ));
+ node->set_rotation(snap_angle(angle + (dfrom - center).angle_to(dto - center), angle));
display_rotate_to = dto;
display_rotate_from = center;
viewport->update();
@@ -1627,14 +1535,13 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
continue;
}
-
bool uniform = m.mod.shift;
- bool symmetric=m.mod.alt;
+ bool symmetric = m.mod.alt;
dto = dto - (drag == DRAG_ALL ? drag_from - drag_point_from : Vector2(0, 0));
- if(uniform && drag == DRAG_ALL) {
- if(ABS(dto.x - drag_point_from.x) > ABS(dto.y - drag_point_from.y)) {
+ if (uniform && drag == DRAG_ALL) {
+ if (ABS(dto.x - drag_point_from.x) > ABS(dto.y - drag_point_from.y)) {
dto.y = drag_point_from.y;
} else {
dto.x = drag_point_from.x;
@@ -1649,128 +1556,118 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
canvas_item->get_global_transform_with_canvas().affine_inverse().xform(dfrom);
Rect2 local_rect = canvas_item->get_item_rect();
- Vector2 begin=local_rect.pos;
- Vector2 end=local_rect.pos+local_rect.size;
+ Vector2 begin = local_rect.pos;
+ Vector2 end = local_rect.pos + local_rect.size;
Vector2 minsize = canvas_item->edit_get_minimum_size();
if (uniform) {
float aspect = local_rect.size.aspect();
- switch(drag) {
+ switch (drag) {
case DRAG_BOTTOM_LEFT:
case DRAG_TOP_RIGHT: {
if (aspect > 1.0) { // width > height, take x as reference
- drag_vector.y = -drag_vector.x/aspect;
+ drag_vector.y = -drag_vector.x / aspect;
} else { // height > width, take y as reference
- drag_vector.x = -drag_vector.y*aspect;
+ drag_vector.x = -drag_vector.y * aspect;
}
} break;
case DRAG_BOTTOM_RIGHT:
case DRAG_TOP_LEFT: {
if (aspect > 1.0) { // width > height, take x as reference
- drag_vector.y = drag_vector.x/aspect;
+ drag_vector.y = drag_vector.x / aspect;
} else { // height > width, take y as reference
- drag_vector.x = drag_vector.y*aspect;
+ drag_vector.x = drag_vector.y * aspect;
}
} break;
default: {}
}
}
- switch(drag) {
+ switch (drag) {
case DRAG_ALL: {
- begin+=drag_vector;
- end+=drag_vector;
+ begin += drag_vector;
+ end += drag_vector;
} break;
case DRAG_RIGHT: {
- incend(begin.x,end.x,drag_vector.x,minsize.x,symmetric);
+ incend(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
} break;
case DRAG_BOTTOM: {
- incend(begin.y,end.y,drag_vector.y,minsize.y,symmetric);
+ incend(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
} break;
case DRAG_BOTTOM_RIGHT: {
- incend(begin.x,end.x,drag_vector.x,minsize.x,symmetric);
- incend(begin.y,end.y,drag_vector.y,minsize.y,symmetric);
+ incend(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
+ incend(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
} break;
case DRAG_TOP_LEFT: {
- incbeg(begin.x,end.x,drag_vector.x,minsize.x,symmetric);
- incbeg(begin.y,end.y,drag_vector.y,minsize.y,symmetric);
+ incbeg(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
+ incbeg(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
} break;
case DRAG_TOP: {
- incbeg(begin.y,end.y,drag_vector.y,minsize.y,symmetric);
+ incbeg(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
} break;
case DRAG_LEFT: {
- incbeg(begin.x,end.x,drag_vector.x,minsize.x,symmetric);
+ incbeg(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
} break;
case DRAG_TOP_RIGHT: {
- incbeg(begin.y,end.y,drag_vector.y,minsize.y,symmetric);
- incend(begin.x,end.x,drag_vector.x,minsize.x,symmetric);
+ incbeg(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
+ incend(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
} break;
case DRAG_BOTTOM_LEFT: {
- incbeg(begin.x,end.x,drag_vector.x,minsize.x,symmetric);
- incend(begin.y,end.y,drag_vector.y,minsize.y,symmetric);
+ incbeg(begin.x, end.x, drag_vector.x, minsize.x, symmetric);
+ incend(begin.y, end.y, drag_vector.y, minsize.y, symmetric);
} break;
case DRAG_PIVOT: {
if (canvas_item->cast_to<Node2D>()) {
- Node2D *n2d =canvas_item->cast_to<Node2D>();
- n2d->edit_set_pivot(se->undo_pivot+drag_vector);
-
+ Node2D *n2d = canvas_item->cast_to<Node2D>();
+ n2d->edit_set_pivot(se->undo_pivot + drag_vector);
}
continue;
} break;
- default:{}
+ default: {}
}
-
-
if (!dragging_bone) {
- local_rect.pos=begin;
- local_rect.size=end-begin;
+ local_rect.pos = begin;
+ local_rect.size = end - begin;
canvas_item->edit_set_rect(local_rect);
} else {
//ok, all that had to be done was done, now solve IK
-
-
-
Node2D *n2d = canvas_item->cast_to<Node2D>();
Transform2D final_xform = bone_orig_xform;
-
-
if (n2d) {
float total_len = 0;
- for (List<BoneIK>::Element *E=bone_ik_list.front();E;E=E->next()) {
+ for (List<BoneIK>::Element *E = bone_ik_list.front(); E; E = E->next()) {
if (E->prev())
- total_len+=E->get().len;
+ total_len += E->get().len;
E->get().pos = E->get().node->get_global_transform().get_origin();
}
{
- final_xform.elements[2]+=dto-dfrom;//final_xform.affine_inverse().basis_xform_inv(drag_vector);
+ final_xform.elements[2] += dto - dfrom; //final_xform.affine_inverse().basis_xform_inv(drag_vector);
//n2d->set_global_transform(final_xform);
-
}
-
CanvasItem *last = bone_ik_list.back()->get().node;
if (!last)
break;
@@ -1783,70 +1680,64 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
//print_line("TOO FAR!");
Vector2 rel = leaf_pos - root_pos;
rel = rel.normalized() * total_len;
- leaf_pos=root_pos+rel;
-
+ leaf_pos = root_pos + rel;
}
- bone_ik_list.front()->get().pos=leaf_pos;
+ bone_ik_list.front()->get().pos = leaf_pos;
//print_line("BONE IK LIST "+itos(bone_ik_list.size()));
+ if (bone_ik_list.size() > 2) {
+ int solver_iterations = 64;
+ float solver_k = 0.3;
- if (bone_ik_list.size()>2) {
- int solver_iterations=64;
- float solver_k=0.3;
-
- for(int i=0;i<solver_iterations;i++) {
-
- for (List<BoneIK>::Element *E=bone_ik_list.front();E;E=E->next()) {
-
+ for (int i = 0; i < solver_iterations; i++) {
+ for (List<BoneIK>::Element *E = bone_ik_list.front(); E; E = E->next()) {
- if (E==bone_ik_list.back()) {
+ if (E == bone_ik_list.back()) {
break;
}
float len = E->next()->get().len;
- if (E->next()==bone_ik_list.back()) {
+ if (E->next() == bone_ik_list.back()) {
//print_line("back");
Vector2 rel = E->get().pos - E->next()->get().pos;
//print_line("PREV "+E->get().pos);
- Vector2 desired = E->next()->get().pos+rel.normalized()*len;
+ Vector2 desired = E->next()->get().pos + rel.normalized() * len;
//print_line("DESIRED "+desired);
- E->get().pos=E->get().pos.linear_interpolate(desired,solver_k);
+ E->get().pos = E->get().pos.linear_interpolate(desired, solver_k);
//print_line("POST "+E->get().pos);
-
- } else if (E==bone_ik_list.front()) {
+ } else if (E == bone_ik_list.front()) {
//only adjust parent
//print_line("front");
Vector2 rel = E->next()->get().pos - E->get().pos;
//print_line("PREV "+E->next()->get().pos);
- Vector2 desired = E->get().pos+rel.normalized()*len;
+ Vector2 desired = E->get().pos + rel.normalized() * len;
//print_line("DESIRED "+desired);
- E->next()->get().pos=E->next()->get().pos.linear_interpolate(desired,solver_k);
+ E->next()->get().pos = E->next()->get().pos.linear_interpolate(desired, solver_k);
//print_line("POST "+E->next()->get().pos);
} else {
Vector2 rel = E->next()->get().pos - E->get().pos;
- Vector2 cen = (E->next()->get().pos + E->get().pos)*0.5;
- rel=rel.linear_interpolate(rel.normalized()*len,solver_k);
- rel*=0.5;
- E->next()->get().pos=cen+rel;
- E->get().pos=cen-rel;
+ Vector2 cen = (E->next()->get().pos + E->get().pos) * 0.5;
+ rel = rel.linear_interpolate(rel.normalized() * len, solver_k);
+ rel *= 0.5;
+ E->next()->get().pos = cen + rel;
+ E->get().pos = cen - rel;
//print_line("mid");
-
}
}
}
}
}
- for (List<BoneIK>::Element *E=bone_ik_list.back();E;E=E->prev()) {
+ for (List<BoneIK>::Element *E = bone_ik_list.back(); E; E = E->prev()) {
Node2D *n = E->get().node;
@@ -1859,90 +1750,81 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
Vector2 rel = (E->prev()->get().node->get_global_position() - n->get_global_position()).normalized();
Vector2 rel2 = (E->prev()->get().pos - E->get().pos).normalized();
float rot = rel.angle_to(rel2);
- if (n->get_global_transform().basis_determinant()<0) {
+ if (n->get_global_transform().basis_determinant() < 0) {
//mirrored, rotate the other way
- rot=-rot;
+ rot = -rot;
}
n->rotate(rot);
}
-
}
-
-
break;
}
}
}
- if (p_event.type==InputEvent::KEY) {
+ if (p_event.type == InputEvent::KEY) {
- const InputEventKey &k=p_event.key;
+ const InputEventKey &k = p_event.key;
- if (k.pressed && drag==DRAG_NONE) {
+ if (k.pressed && drag == DRAG_NONE) {
KeyMoveMODE move_mode = MOVE_VIEW_BASE;
if (k.mod.alt) move_mode = MOVE_LOCAL_BASE;
if (k.mod.control || k.mod.meta) move_mode = MOVE_LOCAL_WITH_ROT;
- if (k.scancode==KEY_UP)
- _key_move( Vector2(0,-1), k.mod.shift, move_mode );
- else if (k.scancode==KEY_DOWN)
- _key_move( Vector2(0,1), k.mod.shift, move_mode );
- else if (k.scancode==KEY_LEFT)
- _key_move( Vector2(-1,0), k.mod.shift, move_mode );
- else if (k.scancode==KEY_RIGHT)
- _key_move( Vector2(1,0), k.mod.shift, move_mode );
- else if (k.scancode==KEY_ESCAPE) {
+ if (k.scancode == KEY_UP)
+ _key_move(Vector2(0, -1), k.mod.shift, move_mode);
+ else if (k.scancode == KEY_DOWN)
+ _key_move(Vector2(0, 1), k.mod.shift, move_mode);
+ else if (k.scancode == KEY_LEFT)
+ _key_move(Vector2(-1, 0), k.mod.shift, move_mode);
+ else if (k.scancode == KEY_RIGHT)
+ _key_move(Vector2(1, 0), k.mod.shift, move_mode);
+ else if (k.scancode == KEY_ESCAPE) {
editor_selection->clear();
viewport->update();
- }
- else
+ } else
return;
accept_event();
}
-
}
-
-
-
-
}
void CanvasItemEditor::_viewport_draw() {
// TODO fetch the viewport?
- Ref<Texture> pivot = get_icon("EditorPivot","EditorIcons");
+ Ref<Texture> pivot = get_icon("EditorPivot", "EditorIcons");
_update_scrollbars();
- RID ci=viewport->get_canvas_item();
+ RID ci = viewport->get_canvas_item();
if (snap_show_grid) {
Size2 s = viewport->get_size();
int last_cell;
Transform2D xform = transform.affine_inverse();
- if (snap_step.x!=0) {
- for(int i=0;i<s.width;i++) {
- int cell = Math::fast_ftoi(Math::floor((xform.xform(Vector2(i,0)).x-snap_offset.x)/snap_step.x));
- if (i==0)
- last_cell=cell;
- if (last_cell!=cell)
- viewport->draw_line(Point2(i,0),Point2(i,s.height),Color(0.3,0.7,1,0.3));
- last_cell=cell;
+ if (snap_step.x != 0) {
+ for (int i = 0; i < s.width; i++) {
+ int cell = Math::fast_ftoi(Math::floor((xform.xform(Vector2(i, 0)).x - snap_offset.x) / snap_step.x));
+ if (i == 0)
+ last_cell = cell;
+ if (last_cell != cell)
+ viewport->draw_line(Point2(i, 0), Point2(i, s.height), Color(0.3, 0.7, 1, 0.3));
+ last_cell = cell;
}
}
- if (snap_step.y!=0) {
- for(int i=0;i<s.height;i++) {
- int cell = Math::fast_ftoi(Math::floor((xform.xform(Vector2(0,i)).y-snap_offset.y)/snap_step.y));
- if (i==0)
- last_cell=cell;
- if (last_cell!=cell)
- viewport->draw_line(Point2(0,i),Point2(s.width,i),Color(0.3,0.7,1,0.3));
- last_cell=cell;
+ if (snap_step.y != 0) {
+ for (int i = 0; i < s.height; i++) {
+ int cell = Math::fast_ftoi(Math::floor((xform.xform(Vector2(0, i)).y - snap_offset.y) / snap_step.y));
+ if (i == 0)
+ last_cell = cell;
+ if (last_cell != cell)
+ viewport->draw_line(Point2(0, i), Point2(s.width, i), Color(0.3, 0.7, 1, 0.3));
+ last_cell = cell;
}
}
}
@@ -1950,168 +1832,150 @@ void CanvasItemEditor::_viewport_draw() {
if (viewport->has_focus()) {
Size2 size = viewport->get_size();
if (v_scroll->is_visible_in_tree())
- size.width-=v_scroll->get_size().width;
+ size.width -= v_scroll->get_size().width;
if (h_scroll->is_visible_in_tree())
- size.height-=h_scroll->get_size().height;
+ size.height -= h_scroll->get_size().height;
- get_stylebox("EditorFocus","EditorStyles")->draw(ci,Rect2(Point2(),size));
+ get_stylebox("EditorFocus", "EditorStyles")->draw(ci, Rect2(Point2(), size));
}
- Ref<Texture> lock = get_icon("Lock","EditorIcons");
- Ref<Texture> group = get_icon("Group","EditorIcons");
+ Ref<Texture> lock = get_icon("Lock", "EditorIcons");
+ Ref<Texture> group = get_icon("Group", "EditorIcons");
+ bool single = get_single_item() != NULL;
- bool single = get_single_item()!=NULL;
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
- Map<Node*,Object*> &selection = editor_selection->get_selection();
-
- bool pivot_found=false;
-
- for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ bool pivot_found = false;
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
+ Rect2 rect = canvas_item->get_item_rect();
- Rect2 rect=canvas_item->get_item_rect();
+ Transform2D xform = transform * canvas_item->get_global_transform_with_canvas();
+ VisualServer::get_singleton()->canvas_item_add_set_transform(ci, xform);
- Transform2D xform=transform * canvas_item->get_global_transform_with_canvas();
- VisualServer::get_singleton()->canvas_item_add_set_transform(ci,xform);
-
- Vector2 endpoints[4]={
+ Vector2 endpoints[4] = {
xform.xform(rect.pos),
- xform.xform(rect.pos+Vector2(rect.size.x,0)),
- xform.xform(rect.pos+rect.size),
- xform.xform(rect.pos+Vector2(0,rect.size.y))
+ xform.xform(rect.pos + Vector2(rect.size.x, 0)),
+ xform.xform(rect.pos + rect.size),
+ xform.xform(rect.pos + Vector2(0, rect.size.y))
};
- Color c = Color(1,0.6,0.4,0.7);
+ Color c = Color(1, 0.6, 0.4, 0.7);
- VisualServer::get_singleton()->canvas_item_add_set_transform(ci,Transform2D());
+ VisualServer::get_singleton()->canvas_item_add_set_transform(ci, Transform2D());
- for(int i=0;i<4;i++) {
- viewport->draw_line(endpoints[i],endpoints[(i+1)%4],c,2);
+ for (int i = 0; i < 4; i++) {
+ viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, 2);
}
- if (single && (tool==TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_ROTATE || tool==TOOL_EDIT_PIVOT)) { //kind of sucks
+ if (single && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks
if (canvas_item->cast_to<Node2D>()) {
-
if (canvas_item->cast_to<Node2D>()->edit_has_pivot()) {
- viewport->draw_texture(pivot,xform.get_origin()+(-pivot->get_size()/2).floor());
- can_move_pivot=true;
- pivot_found=true;
+ viewport->draw_texture(pivot, xform.get_origin() + (-pivot->get_size() / 2).floor());
+ can_move_pivot = true;
+ pivot_found = true;
}
-
}
+ if (tool == TOOL_SELECT) {
- if (tool==TOOL_SELECT) {
-
+ for (int i = 0; i < 4; i++) {
- for(int i=0;i<4;i++) {
-
- int prev = (i+3)%4;
- int next = (i+1)%4;
+ int prev = (i + 3) % 4;
+ int next = (i + 1) % 4;
Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized();
- ofs*=1.4144*(select_handle->get_size().width/2);
-
- select_handle->draw(ci,(endpoints[i]+ofs-(select_handle->get_size()/2)).floor());
+ ofs *= 1.4144 * (select_handle->get_size().width / 2);
- ofs = (endpoints[i]+endpoints[next])/2;
- ofs += (endpoints[next]-endpoints[i]).tangent().normalized()*(select_handle->get_size().width/2);
+ select_handle->draw(ci, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor());
- select_handle->draw(ci,(ofs-(select_handle->get_size()/2)).floor());
+ ofs = (endpoints[i] + endpoints[next]) / 2;
+ ofs += (endpoints[next] - endpoints[i]).tangent().normalized() * (select_handle->get_size().width / 2);
+ select_handle->draw(ci, (ofs - (select_handle->get_size() / 2)).floor());
}
-
}
}
-
-
//DRAW_EMPTY_RECT( Rect2( current_window->get_scroll()-Point2(1,1), get_size()+Size2(2,2)), Color(0.8,0.8,1.0,0.8) );
//E->get().last_rect = rect;
}
pivot_button->set_disabled(!pivot_found);
- VisualServer::get_singleton()->canvas_item_add_set_transform(ci,Transform2D());
+ VisualServer::get_singleton()->canvas_item_add_set_transform(ci, Transform2D());
+ Color x_axis_color(1.0, 0.4, 0.4, 0.6);
+ Color y_axis_color(0.4, 1.0, 0.4, 0.6);
+ Color area_axis_color(0.4, 0.4, 1.0, 0.4);
+ Color rotate_color(0.4, 0.7, 1.0, 0.8);
-
- Color x_axis_color(1.0,0.4,0.4,0.6);
- Color y_axis_color(0.4,1.0,0.4,0.6);
- Color area_axis_color(0.4,0.4,1.0,0.4);
- Color rotate_color(0.4,0.7,1.0,0.8);
-
- VisualServer::get_singleton()->canvas_item_add_line(ci,Point2(h_scroll->get_min(),0)+transform.get_origin(),Point2(h_scroll->get_max(),0)+transform.get_origin(),x_axis_color);
- VisualServer::get_singleton()->canvas_item_add_line(ci,Point2(0,v_scroll->get_min())+transform.get_origin(),Point2(0,v_scroll->get_max())+transform.get_origin(),y_axis_color);
-
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(h_scroll->get_min(), 0) + transform.get_origin(), Point2(h_scroll->get_max(), 0) + transform.get_origin(), x_axis_color);
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(0, v_scroll->get_min()) + transform.get_origin(), Point2(0, v_scroll->get_max()) + transform.get_origin(), y_axis_color);
if (box_selecting) {
Point2 bsfrom = transform.xform(drag_from);
- Point2 bsto= transform.xform(box_selecting_to);
+ Point2 bsto = transform.xform(box_selecting_to);
-
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(bsfrom,bsto-bsfrom),Color(0.7,0.7,1.0,0.3));
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(bsfrom, bsto - bsfrom), Color(0.7, 0.7, 1.0, 0.3));
}
- if (drag==DRAG_ROTATE) {
- VisualServer::get_singleton()->canvas_item_add_line(ci,transform.xform(display_rotate_from), transform.xform(display_rotate_to),rotate_color);
+ if (drag == DRAG_ROTATE) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci, transform.xform(display_rotate_from), transform.xform(display_rotate_to), rotate_color);
}
- Size2 screen_size = Size2( GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height") );
+ Size2 screen_size = Size2(GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height"));
- Vector2 screen_endpoints[4]= {
- transform.xform(Vector2(0,0)),
- transform.xform(Vector2(screen_size.width,0)),
- transform.xform(Vector2(screen_size.width,screen_size.height)),
- transform.xform(Vector2(0,screen_size.height))
+ Vector2 screen_endpoints[4] = {
+ transform.xform(Vector2(0, 0)),
+ transform.xform(Vector2(screen_size.width, 0)),
+ transform.xform(Vector2(screen_size.width, screen_size.height)),
+ transform.xform(Vector2(0, screen_size.height))
};
- for(int i=0;i<4;i++) {
-
- VisualServer::get_singleton()->canvas_item_add_line(ci,screen_endpoints[i], screen_endpoints[(i+1)%4],area_axis_color);
+ for (int i = 0; i < 4; i++) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci, screen_endpoints[i], screen_endpoints[(i + 1) % 4], area_axis_color);
}
- for(List<LockList>::Element*E=lock_list.front();E;E=E->next()) {
+ for (List<LockList>::Element *E = lock_list.front(); E; E = E->next()) {
Vector2 ofs = transform.xform(E->get().pos);
if (E->get().lock) {
- lock->draw(ci,ofs);
- ofs.x+=lock->get_width();
+ lock->draw(ci, ofs);
+ ofs.x += lock->get_width();
}
if (E->get().group) {
- group->draw(ci,ofs);
+ group->draw(ci, ofs);
}
-
}
{
- EditorNode *en = editor;
- EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
-
- if (!over_plugin_list->empty()) {
+ EditorNode *en = editor;
+ EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
- over_plugin_list->forward_draw_over_canvas(transform,viewport);
+ if (!over_plugin_list->empty()) {
- }
- }
+ over_plugin_list->forward_draw_over_canvas(transform, viewport);
+ }
+ }
if (skeleton_show_bones) {
int bone_width = EditorSettings::get_singleton()->get("editors/2d/bone_width");
@@ -2120,16 +1984,16 @@ void CanvasItemEditor::_viewport_draw() {
Color bone_ik_color = EditorSettings::get_singleton()->get("editors/2d/bone_ik_color");
Color bone_selected_color = EditorSettings::get_singleton()->get("editors/2d/bone_selected_color");
- for(Map<ObjectID,BoneList>::Element*E=bone_list.front();E;E=E->next()) {
+ for (Map<ObjectID, BoneList>::Element *E = bone_list.front(); E; E = E->next()) {
- E->get().from=Vector2();
- E->get().to=Vector2();
+ E->get().from = Vector2();
+ E->get().to = Vector2();
Object *obj = ObjectDB::get_instance(E->get().bone);
if (!obj)
continue;
- Node2D* n2d = obj->cast_to<Node2D>();
+ Node2D *n2d = obj->cast_to<Node2D>();
if (!n2d)
continue;
@@ -2138,8 +2002,7 @@ void CanvasItemEditor::_viewport_draw() {
CanvasItem *pi = n2d->get_parent_item();
-
- Node2D* pn2d=n2d->get_parent()->cast_to<Node2D>();
+ Node2D *pn2d = n2d->get_parent()->cast_to<Node2D>();
if (!pn2d)
continue;
@@ -2147,19 +2010,17 @@ void CanvasItemEditor::_viewport_draw() {
Vector2 from = transform.xform(pn2d->get_global_position());
Vector2 to = transform.xform(n2d->get_global_position());
- E->get().from=from;
- E->get().to=to;
-
- Vector2 rel = to-from;
- Vector2 relt = rel.tangent().normalized()*bone_width;
-
+ E->get().from = from;
+ E->get().to = to;
+ Vector2 rel = to - from;
+ Vector2 relt = rel.tangent().normalized() * bone_width;
Vector<Vector2> bone_shape;
bone_shape.push_back(from);
- bone_shape.push_back(from+rel*0.2+relt);
+ bone_shape.push_back(from + rel * 0.2 + relt);
bone_shape.push_back(to);
- bone_shape.push_back(from+rel*0.2-relt);
+ bone_shape.push_back(from + rel * 0.2 - relt);
Vector<Color> colors;
if (pi->has_meta("_edit_ik_")) {
@@ -2174,57 +2035,54 @@ void CanvasItemEditor::_viewport_draw() {
colors.push_back(bone_color2);
}
-
- VisualServer::get_singleton()->canvas_item_add_primitive(ci,bone_shape,colors,Vector<Vector2>(),RID());
+ VisualServer::get_singleton()->canvas_item_add_primitive(ci, bone_shape, colors, Vector<Vector2>(), RID());
if (editor_selection->is_selected(pi)) {
- for(int i=0;i<bone_shape.size();i++) {
+ for (int i = 0; i < bone_shape.size(); i++) {
- VisualServer::get_singleton()->canvas_item_add_line(ci,bone_shape[i],bone_shape[(i+1)%bone_shape.size()],bone_selected_color,2);
+ VisualServer::get_singleton()->canvas_item_add_line(ci, bone_shape[i], bone_shape[(i + 1) % bone_shape.size()], bone_selected_color, 2);
}
}
-
}
}
}
void CanvasItemEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_FIXED_PROCESS) {
+ if (p_what == NOTIFICATION_FIXED_PROCESS) {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- bool all_control=true;
- bool has_control=false;
+ bool all_control = true;
+ bool has_control = false;
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
if (canvas_item->cast_to<Control>())
- has_control=true;
+ has_control = true;
else
- all_control=false;
+ all_control = false;
- CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
+ CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
if (!se)
continue;
- Rect2 r=canvas_item->get_item_rect();
+ Rect2 r = canvas_item->get_item_rect();
Transform2D xform = canvas_item->get_transform();
- if (r != se->prev_rect || xform!=se->prev_xform) {
+ if (r != se->prev_rect || xform != se->prev_xform) {
viewport->update();
- se->prev_rect=r;
- se->prev_xform=xform;
+ se->prev_rect = r;
+ se->prev_xform = xform;
}
-
}
bool show_anchor = all_control && has_control;
@@ -2235,7 +2093,7 @@ void CanvasItemEditor::_notification(int p_what) {
anchor_menu->hide();
}
- for(Map<ObjectID,BoneList>::Element *E=bone_list.front();E;E=E->next()) {
+ for (Map<ObjectID, BoneList>::Element *E = bone_list.front(); E; E = E->next()) {
Object *b = ObjectDB::get_instance(E->get().bone);
if (!b) {
@@ -2249,123 +2107,110 @@ void CanvasItemEditor::_notification(int p_what) {
continue;
}
- if (b2->get_global_transform()!=E->get().xform) {
+ if (b2->get_global_transform() != E->get().xform) {
- E->get().xform=b2->get_global_transform();
+ E->get().xform = b2->get_global_transform();
viewport->update();
}
}
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- select_sb->set_texture( get_icon("EditorRect2D","EditorIcons") );
- for(int i=0;i<4;i++) {
- select_sb->set_margin_size(Margin(i),4);
- select_sb->set_default_margin(Margin(i),4);
+ select_sb->set_texture(get_icon("EditorRect2D", "EditorIcons"));
+ for (int i = 0; i < 4; i++) {
+ select_sb->set_margin_size(Margin(i), 4);
+ select_sb->set_default_margin(Margin(i), 4);
}
- select_button->set_icon( get_icon("ToolSelect","EditorIcons"));
- list_select_button->set_icon( get_icon("ListSelect","EditorIcons"));
- move_button->set_icon( get_icon("ToolMove","EditorIcons"));
- rotate_button->set_icon( get_icon("ToolRotate","EditorIcons"));
- pan_button->set_icon( get_icon("ToolPan", "EditorIcons"));
- pivot_button->set_icon( get_icon("EditPivot", "EditorIcons"));
- select_handle=get_icon("EditorHandle","EditorIcons");
- lock_button->set_icon(get_icon("Lock","EditorIcons"));
- unlock_button->set_icon(get_icon("Unlock","EditorIcons"));
- group_button->set_icon(get_icon("Group","EditorIcons"));
- ungroup_button->set_icon(get_icon("Ungroup","EditorIcons"));
- key_insert_button->set_icon(get_icon("Key","EditorIcons"));
-
+ select_button->set_icon(get_icon("ToolSelect", "EditorIcons"));
+ list_select_button->set_icon(get_icon("ListSelect", "EditorIcons"));
+ move_button->set_icon(get_icon("ToolMove", "EditorIcons"));
+ rotate_button->set_icon(get_icon("ToolRotate", "EditorIcons"));
+ pan_button->set_icon(get_icon("ToolPan", "EditorIcons"));
+ pivot_button->set_icon(get_icon("EditPivot", "EditorIcons"));
+ select_handle = get_icon("EditorHandle", "EditorIcons");
+ lock_button->set_icon(get_icon("Lock", "EditorIcons"));
+ unlock_button->set_icon(get_icon("Unlock", "EditorIcons"));
+ group_button->set_icon(get_icon("Group", "EditorIcons"));
+ ungroup_button->set_icon(get_icon("Ungroup", "EditorIcons"));
+ key_insert_button->set_icon(get_icon("Key", "EditorIcons"));
//anchor_menu->add_icon_override("Align Top Left");
- anchor_menu->set_icon(get_icon("Anchor","EditorIcons"));
- PopupMenu *p=anchor_menu->get_popup();
+ anchor_menu->set_icon(get_icon("Anchor", "EditorIcons"));
+ PopupMenu *p = anchor_menu->get_popup();
- p->add_icon_item(get_icon("ControlAlignTopLeft","EditorIcons"),"Top Left",ANCHOR_ALIGN_TOP_LEFT);
- p->add_icon_item(get_icon("ControlAlignTopRight","EditorIcons"),"Top Right",ANCHOR_ALIGN_TOP_RIGHT);
- p->add_icon_item(get_icon("ControlAlignBottomRight","EditorIcons"),"Bottom Right",ANCHOR_ALIGN_BOTTOM_RIGHT);
- p->add_icon_item(get_icon("ControlAlignBottomLeft","EditorIcons"),"Bottom Left",ANCHOR_ALIGN_BOTTOM_LEFT);
+ p->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), "Top Left", ANCHOR_ALIGN_TOP_LEFT);
+ p->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), "Top Right", ANCHOR_ALIGN_TOP_RIGHT);
+ p->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), "Bottom Right", ANCHOR_ALIGN_BOTTOM_RIGHT);
+ p->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), "Bottom Left", ANCHOR_ALIGN_BOTTOM_LEFT);
p->add_separator();
- p->add_icon_item(get_icon("ControlAlignLeftCenter","EditorIcons"),"Center Left",ANCHOR_ALIGN_CENTER_LEFT);
- p->add_icon_item(get_icon("ControlAlignTopCenter","EditorIcons"),"Center Top",ANCHOR_ALIGN_CENTER_TOP);
- p->add_icon_item(get_icon("ControlAlignRightCenter","EditorIcons"),"Center Right",ANCHOR_ALIGN_CENTER_RIGHT);
- p->add_icon_item(get_icon("ControlAlignBottomCenter","EditorIcons"),"Center Bottom",ANCHOR_ALIGN_CENTER_BOTTOM);
- p->add_icon_item(get_icon("ControlAlignCenter","EditorIcons"),"Center",ANCHOR_ALIGN_CENTER);
+ p->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), "Center Left", ANCHOR_ALIGN_CENTER_LEFT);
+ p->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), "Center Top", ANCHOR_ALIGN_CENTER_TOP);
+ p->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), "Center Right", ANCHOR_ALIGN_CENTER_RIGHT);
+ p->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), "Center Bottom", ANCHOR_ALIGN_CENTER_BOTTOM);
+ p->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), "Center", ANCHOR_ALIGN_CENTER);
p->add_separator();
- p->add_icon_item(get_icon("ControlAlignLeftWide","EditorIcons"),"Left Wide",ANCHOR_ALIGN_LEFT_WIDE);
- p->add_icon_item(get_icon("ControlAlignTopWide","EditorIcons"),"Top Wide",ANCHOR_ALIGN_TOP_WIDE);
- p->add_icon_item(get_icon("ControlAlignRightWide","EditorIcons"),"Right Wide",ANCHOR_ALIGN_RIGHT_WIDE);
- p->add_icon_item(get_icon("ControlAlignBottomWide","EditorIcons"),"Bottom Wide",ANCHOR_ALIGN_BOTTOM_WIDE);
- p->add_icon_item(get_icon("ControlVcenterWide","EditorIcons"),"VCenter Wide ",ANCHOR_ALIGN_VCENTER_WIDE);
- p->add_icon_item(get_icon("ControlHcenterWide","EditorIcons"),"HCenter Wide ",ANCHOR_ALIGN_HCENTER_WIDE);
+ p->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), "Left Wide", ANCHOR_ALIGN_LEFT_WIDE);
+ p->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), "Top Wide", ANCHOR_ALIGN_TOP_WIDE);
+ p->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), "Right Wide", ANCHOR_ALIGN_RIGHT_WIDE);
+ p->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), "Bottom Wide", ANCHOR_ALIGN_BOTTOM_WIDE);
+ p->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), "VCenter Wide ", ANCHOR_ALIGN_VCENTER_WIDE);
+ p->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), "HCenter Wide ", ANCHOR_ALIGN_HCENTER_WIDE);
p->add_separator();
- p->add_icon_item(get_icon("ControlAlignWide","EditorIcons"),"Full Rect",ANCHOR_ALIGN_WIDE);
+ p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), "Full Rect", ANCHOR_ALIGN_WIDE);
-
- AnimationPlayerEditor::singleton->get_key_editor()->connect("visibility_changed",this,"_keying_changed");
+ AnimationPlayerEditor::singleton->get_key_editor()->connect("visibility_changed", this, "_keying_changed");
_keying_changed();
}
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
- get_tree()->connect("node_removed",this,"_node_removed");
+ get_tree()->connect("node_removed", this, "_node_removed");
}
- if (p_what==NOTIFICATION_DRAW) {
-
-
-
+ if (p_what == NOTIFICATION_DRAW) {
}
}
void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
- drag=DRAG_NONE;
+ drag = DRAG_NONE;
- editor_selection->clear();//_clear_canvas_items();
+ editor_selection->clear(); //_clear_canvas_items();
editor_selection->add_node(p_canvas_item);
//_add_canvas_item(p_canvas_item);
viewport->update();
-
}
-
-void CanvasItemEditor::_find_canvas_items_span(Node *p_node, Rect2& r_rect, const Transform2D& p_xform) {
-
-
+void CanvasItemEditor::_find_canvas_items_span(Node *p_node, Rect2 &r_rect, const Transform2D &p_xform) {
if (!p_node)
return;
- CanvasItem *c=p_node->cast_to<CanvasItem>();
-
+ CanvasItem *c = p_node->cast_to<CanvasItem>();
- for (int i=p_node->get_child_count()-1;i>=0;i--) {
+ for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
//CanvasItem *r=NULL;
if (c && !c->is_set_as_toplevel())
- _find_canvas_items_span(p_node->get_child(i),r_rect,p_xform * c->get_transform());
+ _find_canvas_items_span(p_node->get_child(i), r_rect, p_xform * c->get_transform());
else
- _find_canvas_items_span(p_node->get_child(i),r_rect,Transform2D());
+ _find_canvas_items_span(p_node->get_child(i), r_rect, Transform2D());
}
-
-
if (c && c->is_visible_in_tree()) {
Rect2 rect = c->get_item_rect();
Transform2D xform = p_xform * c->get_transform();
-
LockList lock;
- lock.lock=c->has_meta("_edit_lock_");
- lock.group=c->has_meta("_edit_group_");
+ lock.lock = c->has_meta("_edit_lock_");
+ lock.group = c->has_meta("_edit_group_");
if (lock.group || lock.lock) {
- lock.pos=xform.xform(rect.pos);
+ lock.pos = xform.xform(rect.pos);
lock_list.push_back(lock);
}
@@ -2374,221 +2219,205 @@ void CanvasItemEditor::_find_canvas_items_span(Node *p_node, Rect2& r_rect, cons
ObjectID id = c->get_instance_ID();
if (!bone_list.has(id)) {
BoneList bone;
- bone.bone=id;
- bone_list[id]=bone;
+ bone.bone = id;
+ bone_list[id] = bone;
}
- bone_list[id].last_pass=bone_last_frame;
+ bone_list[id].last_pass = bone_last_frame;
}
- r_rect.expand_to( xform.xform(rect.pos) );
- r_rect.expand_to( xform.xform(rect.pos+Point2(rect.size.x,0)) );
- r_rect.expand_to( xform.xform(rect.pos+Point2(0,rect.size.y)) );
- r_rect.expand_to( xform.xform(rect.pos+rect.size) );
-
+ r_rect.expand_to(xform.xform(rect.pos));
+ r_rect.expand_to(xform.xform(rect.pos + Point2(rect.size.x, 0)));
+ r_rect.expand_to(xform.xform(rect.pos + Point2(0, rect.size.y)));
+ r_rect.expand_to(xform.xform(rect.pos + rect.size));
}
-
}
void CanvasItemEditor::_update_scrollbars() {
-
- updating_scroll=true;
+ updating_scroll = true;
Size2 size = viewport->get_size();
Size2 hmin = h_scroll->get_minimum_size();
Size2 vmin = v_scroll->get_minimum_size();
- v_scroll->set_begin( Point2(size.width - vmin.width, 0) );
- v_scroll->set_end( Point2(size.width, size.height) );
-
- 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, 0));
+ v_scroll->set_end(Point2(size.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 screen_rect = Size2( GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height") );
+ Size2 screen_rect = Size2(GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height"));
+ Rect2 local_rect = Rect2(Point2(), viewport->get_size() - Size2(vmin.width, hmin.height));
- Rect2 local_rect = Rect2(Point2(),viewport->get_size()-Size2(vmin.width,hmin.height));
-
- Rect2 canvas_item_rect=Rect2(Point2(),screen_rect);
+ Rect2 canvas_item_rect = Rect2(Point2(), screen_rect);
lock_list.clear();
bone_last_frame++;
-
-
if (editor->get_edited_scene())
- _find_canvas_items_span(editor->get_edited_scene(),canvas_item_rect,Transform2D());
+ _find_canvas_items_span(editor->get_edited_scene(), canvas_item_rect, Transform2D());
- List<Map<ObjectID,BoneList>::Element*> bone_to_erase;
+ List<Map<ObjectID, BoneList>::Element *> bone_to_erase;
- for(Map<ObjectID,BoneList>::Element*E=bone_list.front();E;E=E->next()) {
+ for (Map<ObjectID, BoneList>::Element *E = bone_list.front(); E; E = E->next()) {
- if (E->get().last_pass!=bone_last_frame) {
+ if (E->get().last_pass != bone_last_frame) {
bone_to_erase.push_back(E);
}
}
- while(bone_to_erase.size()) {
+ while (bone_to_erase.size()) {
bone_list.erase(bone_to_erase.front()->get());
bone_to_erase.pop_front();
}
//expand area so it's easier to do animations and stuff at 0,0
- canvas_item_rect.size+=screen_rect*2;
- canvas_item_rect.pos-=screen_rect;
+ canvas_item_rect.size += screen_rect * 2;
+ canvas_item_rect.pos -= screen_rect;
Point2 ofs;
-
- if (canvas_item_rect.size.height <= (local_rect.size.y/zoom)) {
+ if (canvas_item_rect.size.height <= (local_rect.size.y / zoom)) {
v_scroll->hide();
- ofs.y=canvas_item_rect.pos.y;
+ ofs.y = canvas_item_rect.pos.y;
} else {
v_scroll->show();
v_scroll->set_min(canvas_item_rect.pos.y);
- v_scroll->set_max(canvas_item_rect.pos.y+canvas_item_rect.size.y);
- v_scroll->set_page(local_rect.size.y/zoom);
+ v_scroll->set_max(canvas_item_rect.pos.y + canvas_item_rect.size.y);
+ v_scroll->set_page(local_rect.size.y / zoom);
if (first_update) {
//so 0,0 is visible
v_scroll->set_value(-10);
h_scroll->set_value(-10);
- first_update=false;
-
+ first_update = false;
}
- ofs.y=v_scroll->get_value();
+ ofs.y = v_scroll->get_value();
}
- if (canvas_item_rect.size.width <= (local_rect.size.x/zoom)) {
+ if (canvas_item_rect.size.width <= (local_rect.size.x / zoom)) {
h_scroll->hide();
- ofs.x=canvas_item_rect.pos.x;
+ ofs.x = canvas_item_rect.pos.x;
} else {
h_scroll->show();
h_scroll->set_min(canvas_item_rect.pos.x);
- h_scroll->set_max(canvas_item_rect.pos.x+canvas_item_rect.size.x);
- h_scroll->set_page(local_rect.size.x/zoom);
- ofs.x=h_scroll->get_value();
+ h_scroll->set_max(canvas_item_rect.pos.x + canvas_item_rect.size.x);
+ h_scroll->set_page(local_rect.size.x / zoom);
+ ofs.x = h_scroll->get_value();
}
//transform=Matrix32();
- transform.elements[2]=-ofs*zoom;
+ transform.elements[2] = -ofs * zoom;
editor->get_scene_root()->set_global_canvas_transform(transform);
-
- updating_scroll=false;
+ updating_scroll = false;
//transform.scale_basis(Vector2(zoom,zoom));
-
-
}
void CanvasItemEditor::_update_scroll(float) {
-
if (updating_scroll)
return;
Point2 ofs;
- ofs.x=h_scroll->get_value();
- ofs.y=v_scroll->get_value();
+ ofs.x = h_scroll->get_value();
+ ofs.y = v_scroll->get_value();
//current_window->set_scroll(-ofs);
- transform=Transform2D();
+ transform = Transform2D();
- transform.scale_basis(Size2(zoom,zoom));
- transform.elements[2]=-ofs;
+ transform.scale_basis(Size2(zoom, zoom));
+ transform.elements[2] = -ofs;
editor->get_scene_root()->set_global_canvas_transform(transform);
-
viewport->update();
-
}
-void CanvasItemEditor::_set_anchor(Control::AnchorType p_left,Control::AnchorType p_top,Control::AnchorType p_right,Control::AnchorType p_bottom) {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+void CanvasItemEditor::_set_anchor(Control::AnchorType p_left, Control::AnchorType p_top, Control::AnchorType p_right, Control::AnchorType p_bottom) {
+ List<Node *> &selection = editor_selection->get_selected_node_list();
undo_redo->create_action(TTR("Change Anchors"));
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Control *c = E->get()->cast_to<Control>();
- undo_redo->add_do_method(c,"set_anchor",MARGIN_LEFT,p_left);
- undo_redo->add_do_method(c,"set_anchor",MARGIN_TOP,p_top);
- undo_redo->add_do_method(c,"set_anchor",MARGIN_RIGHT,p_right);
- undo_redo->add_do_method(c,"set_anchor",MARGIN_BOTTOM,p_bottom);
- undo_redo->add_undo_method(c,"set_anchor",MARGIN_LEFT,c->get_anchor(MARGIN_LEFT));
- undo_redo->add_undo_method(c,"set_anchor",MARGIN_TOP,c->get_anchor(MARGIN_TOP));
- undo_redo->add_undo_method(c,"set_anchor",MARGIN_RIGHT,c->get_anchor(MARGIN_RIGHT));
- undo_redo->add_undo_method(c,"set_anchor",MARGIN_BOTTOM,c->get_anchor(MARGIN_BOTTOM));
+ undo_redo->add_do_method(c, "set_anchor", MARGIN_LEFT, p_left);
+ undo_redo->add_do_method(c, "set_anchor", MARGIN_TOP, p_top);
+ undo_redo->add_do_method(c, "set_anchor", MARGIN_RIGHT, p_right);
+ undo_redo->add_do_method(c, "set_anchor", MARGIN_BOTTOM, p_bottom);
+ undo_redo->add_undo_method(c, "set_anchor", MARGIN_LEFT, c->get_anchor(MARGIN_LEFT));
+ undo_redo->add_undo_method(c, "set_anchor", MARGIN_TOP, c->get_anchor(MARGIN_TOP));
+ undo_redo->add_undo_method(c, "set_anchor", MARGIN_RIGHT, c->get_anchor(MARGIN_RIGHT));
+ undo_redo->add_undo_method(c, "set_anchor", MARGIN_BOTTOM, c->get_anchor(MARGIN_BOTTOM));
}
undo_redo->commit_action();
-
}
void CanvasItemEditor::_popup_callback(int p_op) {
- last_option=MenuOption(p_op);
- switch(p_op) {
+ last_option = MenuOption(p_op);
+ switch (p_op) {
case SNAP_USE: {
snap_grid = !snap_grid;
int idx = edit_menu->get_popup()->get_item_index(SNAP_USE);
- edit_menu->get_popup()->set_item_checked(idx,snap_grid);
+ edit_menu->get_popup()->set_item_checked(idx, snap_grid);
} break;
case SNAP_SHOW_GRID: {
snap_show_grid = !snap_show_grid;
int idx = edit_menu->get_popup()->get_item_index(SNAP_SHOW_GRID);
- edit_menu->get_popup()->set_item_checked(idx,snap_show_grid);
+ edit_menu->get_popup()->set_item_checked(idx, snap_show_grid);
viewport->update();
} break;
case SNAP_USE_ROTATION: {
snap_rotation = !snap_rotation;
int idx = edit_menu->get_popup()->get_item_index(SNAP_USE_ROTATION);
- edit_menu->get_popup()->set_item_checked(idx,snap_rotation);
+ edit_menu->get_popup()->set_item_checked(idx, snap_rotation);
} break;
case SNAP_RELATIVE: {
snap_relative = !snap_relative;
int idx = edit_menu->get_popup()->get_item_index(SNAP_RELATIVE);
- edit_menu->get_popup()->set_item_checked(idx,snap_relative);
+ edit_menu->get_popup()->set_item_checked(idx, snap_relative);
} break;
case SNAP_USE_PIXEL: {
snap_pixel = !snap_pixel;
int idx = edit_menu->get_popup()->get_item_index(SNAP_USE_PIXEL);
- edit_menu->get_popup()->set_item_checked(idx,snap_pixel);
+ edit_menu->get_popup()->set_item_checked(idx, snap_pixel);
} break;
case SNAP_CONFIGURE: {
((SnapDialog *)snap_dialog)->set_fields(snap_offset, snap_step, snap_rotation_offset, snap_rotation_step);
- snap_dialog->popup_centered(Size2(220,160));
+ snap_dialog->popup_centered(Size2(220, 160));
} break;
case SKELETON_SHOW_BONES: {
skeleton_show_bones = !skeleton_show_bones;
int idx = skeleton_menu->get_item_index(SKELETON_SHOW_BONES);
- skeleton_menu->set_item_checked(idx,skeleton_show_bones);
+ skeleton_menu->set_item_checked(idx, skeleton_show_bones);
viewport->update();
} break;
case ZOOM_IN: {
- if (zoom>MAX_ZOOM)
+ if (zoom > MAX_ZOOM)
return;
- zoom=zoom*(1.0/0.5);
+ zoom = zoom * (1.0 / 0.5);
_update_scroll(0);
viewport->update();
return;
} break;
case ZOOM_OUT: {
- if (zoom<MIN_ZOOM)
+ if (zoom < MIN_ZOOM)
return;
- zoom=zoom*0.5;
+ zoom = zoom * 0.5;
_update_scroll(0);
viewport->update();
return;
@@ -2596,7 +2425,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case ZOOM_RESET: {
- zoom=1;
+ zoom = 1;
_update_scroll(0);
viewport->update();
return;
@@ -2604,51 +2433,49 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case ZOOM_SET: {
- updating_value_dialog=true;
+ updating_value_dialog = true;
dialog_label->set_text(TTR("Zoom (%):"));
dialog_val->set_min(0.1);
dialog_val->set_step(0.1);
dialog_val->set_max(800);
- dialog_val->set_value(zoom*100);
- value_dialog->popup_centered(Size2(200,85));
- updating_value_dialog=false;
-
+ dialog_val->set_value(zoom * 100);
+ value_dialog->popup_centered(Size2(200, 85));
+ updating_value_dialog = false;
} break;
case LOCK_SELECTED: {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- canvas_item->set_meta("_edit_lock_",true);
+ canvas_item->set_meta("_edit_lock_", true);
emit_signal("item_lock_status_changed");
}
viewport->update();
} break;
case UNLOCK_SELECTED: {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
-
- canvas_item->set_meta("_edit_lock_",Variant());
+ canvas_item->set_meta("_edit_lock_", Variant());
emit_signal("item_lock_status_changed");
}
@@ -2657,36 +2484,36 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case GROUP_SELECTED: {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- canvas_item->set_meta("_edit_group_",true);
+ canvas_item->set_meta("_edit_group_", true);
emit_signal("item_group_status_changed");
}
viewport->update();
} break;
case UNGROUP_SELECTED: {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- canvas_item->set_meta("_edit_group_",Variant());
+ canvas_item->set_meta("_edit_group_", Variant());
emit_signal("item_group_status_changed");
}
@@ -2696,23 +2523,21 @@ void CanvasItemEditor::_popup_callback(int p_op) {
case EXPAND_TO_PARENT: {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
-
Control *c = canvas_item->cast_to<Control>();
if (!c)
continue;
c->set_area_as_parent_rect();
-
}
viewport->update();
@@ -2763,114 +2588,111 @@ void CanvasItemEditor::_popup_callback(int p_op) {
//space_selected_items< proj_vector2_y, compare_items_y >();
} break;
case ANCHOR_ALIGN_TOP_LEFT: {
- _set_anchor(ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_BEGIN);
+ _set_anchor(ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN);
} break;
case ANCHOR_ALIGN_TOP_RIGHT: {
- _set_anchor(ANCHOR_END,ANCHOR_BEGIN,ANCHOR_END,ANCHOR_BEGIN);
+ _set_anchor(ANCHOR_END, ANCHOR_BEGIN, ANCHOR_END, ANCHOR_BEGIN);
} break;
case ANCHOR_ALIGN_BOTTOM_LEFT: {
- _set_anchor(ANCHOR_BEGIN,ANCHOR_END,ANCHOR_BEGIN,ANCHOR_END);
+ _set_anchor(ANCHOR_BEGIN, ANCHOR_END, ANCHOR_BEGIN, ANCHOR_END);
} break;
case ANCHOR_ALIGN_BOTTOM_RIGHT: {
- _set_anchor(ANCHOR_END,ANCHOR_END,ANCHOR_END,ANCHOR_END);
+ _set_anchor(ANCHOR_END, ANCHOR_END, ANCHOR_END, ANCHOR_END);
} break;
case ANCHOR_ALIGN_CENTER_LEFT: {
- _set_anchor(ANCHOR_BEGIN,ANCHOR_CENTER,ANCHOR_BEGIN,ANCHOR_CENTER);
+ _set_anchor(ANCHOR_BEGIN, ANCHOR_CENTER, ANCHOR_BEGIN, ANCHOR_CENTER);
} break;
case ANCHOR_ALIGN_CENTER_RIGHT: {
- _set_anchor(ANCHOR_END,ANCHOR_CENTER,ANCHOR_END,ANCHOR_CENTER);
+ _set_anchor(ANCHOR_END, ANCHOR_CENTER, ANCHOR_END, ANCHOR_CENTER);
} break;
case ANCHOR_ALIGN_CENTER_TOP: {
- _set_anchor(ANCHOR_CENTER,ANCHOR_BEGIN,ANCHOR_CENTER,ANCHOR_BEGIN);
+ _set_anchor(ANCHOR_CENTER, ANCHOR_BEGIN, ANCHOR_CENTER, ANCHOR_BEGIN);
} break;
case ANCHOR_ALIGN_CENTER_BOTTOM: {
- _set_anchor(ANCHOR_CENTER,ANCHOR_END,ANCHOR_CENTER,ANCHOR_END);
+ _set_anchor(ANCHOR_CENTER, ANCHOR_END, ANCHOR_CENTER, ANCHOR_END);
} break;
case ANCHOR_ALIGN_CENTER: {
- _set_anchor(ANCHOR_CENTER,ANCHOR_CENTER,ANCHOR_CENTER,ANCHOR_CENTER);
+ _set_anchor(ANCHOR_CENTER, ANCHOR_CENTER, ANCHOR_CENTER, ANCHOR_CENTER);
} break;
case ANCHOR_ALIGN_TOP_WIDE: {
- _set_anchor(ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_END,ANCHOR_BEGIN);
+ _set_anchor(ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_END, ANCHOR_BEGIN);
} break;
case ANCHOR_ALIGN_LEFT_WIDE: {
- _set_anchor(ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_END);
+ _set_anchor(ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_END);
} break;
case ANCHOR_ALIGN_RIGHT_WIDE: {
- _set_anchor(ANCHOR_END,ANCHOR_BEGIN,ANCHOR_END,ANCHOR_END);
+ _set_anchor(ANCHOR_END, ANCHOR_BEGIN, ANCHOR_END, ANCHOR_END);
} break;
case ANCHOR_ALIGN_BOTTOM_WIDE: {
- _set_anchor(ANCHOR_BEGIN,ANCHOR_END,ANCHOR_END,ANCHOR_END);
+ _set_anchor(ANCHOR_BEGIN, ANCHOR_END, ANCHOR_END, ANCHOR_END);
} break;
case ANCHOR_ALIGN_VCENTER_WIDE: {
- _set_anchor(ANCHOR_CENTER,ANCHOR_BEGIN,ANCHOR_CENTER,ANCHOR_END);
+ _set_anchor(ANCHOR_CENTER, ANCHOR_BEGIN, ANCHOR_CENTER, ANCHOR_END);
} break;
case ANCHOR_ALIGN_HCENTER_WIDE: {
- _set_anchor(ANCHOR_BEGIN,ANCHOR_CENTER,ANCHOR_END,ANCHOR_CENTER);
+ _set_anchor(ANCHOR_BEGIN, ANCHOR_CENTER, ANCHOR_END, ANCHOR_CENTER);
} break;
case ANCHOR_ALIGN_WIDE: {
- _set_anchor(ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_END,ANCHOR_END);
+ _set_anchor(ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_END, ANCHOR_END);
} break;
case ANIM_INSERT_KEY:
case ANIM_INSERT_KEY_EXISTING: {
- bool existing = p_op==ANIM_INSERT_KEY_EXISTING;
+ bool existing = p_op == ANIM_INSERT_KEY_EXISTING;
- Map<Node*,Object*> &selection = editor_selection->get_selection();
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
- for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
if (canvas_item->cast_to<Node2D>()) {
Node2D *n2d = canvas_item->cast_to<Node2D>();
if (key_pos)
- AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d,"transform/pos",n2d->get_position(),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "transform/pos", n2d->get_position(), existing);
if (key_rot)
- AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d,"transform/rot",Math::rad2deg(n2d->get_rotation()),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "transform/rot", Math::rad2deg(n2d->get_rotation()), existing);
if (key_scale)
- AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d,"transform/scale",n2d->get_scale(),existing);
-
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "transform/scale", n2d->get_scale(), existing);
if (n2d->has_meta("_edit_bone_") && n2d->get_parent_item()) {
//look for an IK chain
- List<Node2D*> ik_chain;
+ List<Node2D *> ik_chain;
Node2D *n = n2d->get_parent_item()->cast_to<Node2D>();
- bool has_chain=false;
+ bool has_chain = false;
- while(n) {
+ while (n) {
ik_chain.push_back(n);
if (n->has_meta("_edit_ik_")) {
- has_chain=true;
+ has_chain = true;
break;
}
if (!n->get_parent_item())
break;
- n=n->get_parent_item()->cast_to<Node2D>();
+ n = n->get_parent_item()->cast_to<Node2D>();
}
if (has_chain && ik_chain.size()) {
- for(List<Node2D*>::Element *F=ik_chain.front();F;F=F->next()) {
+ for (List<Node2D *>::Element *F = ik_chain.front(); F; F = F->next()) {
if (key_pos)
- AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(),"transform/pos",F->get()->get_position(),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "transform/pos", F->get()->get_position(), existing);
if (key_rot)
- AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(),"transform/rot",Math::rad2deg(F->get()->get_rotation()),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "transform/rot", Math::rad2deg(F->get()->get_rotation()), existing);
if (key_scale)
- AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(),"transform/scale",F->get()->get_scale(),existing);
-
-
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "transform/scale", F->get()->get_scale(), existing);
}
}
}
@@ -2880,11 +2702,10 @@ void CanvasItemEditor::_popup_callback(int p_op) {
Control *ctrl = canvas_item->cast_to<Control>();
if (key_pos)
- AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl,"rect/pos",ctrl->get_pos(),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect/pos", ctrl->get_pos(), existing);
if (key_scale)
- AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size(),existing);
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect/size", ctrl->get_size(), existing);
}
-
}
} break;
@@ -2900,7 +2721,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
key_scale = key_scale_button->is_pressed();
} break;
- /*
+ /*
case ANIM_INSERT_POS_ROT
case ANIM_INSERT_POS_SCALE:
case ANIM_INSERT_ROT_SCALE:
@@ -2929,32 +2750,29 @@ void CanvasItemEditor::_popup_callback(int p_op) {
pose_clipboard.clear();
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
- Map<Node*,Object*> &selection = editor_selection->get_selection();
-
- for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
-
if (canvas_item->cast_to<Node2D>()) {
Node2D *n2d = canvas_item->cast_to<Node2D>();
PoseClipboard pc;
- pc.pos=n2d->get_position();
- pc.rot=n2d->get_rotation();
- pc.scale=n2d->get_scale();
- pc.id=n2d->get_instance_ID();
+ pc.pos = n2d->get_position();
+ pc.rot = n2d->get_rotation();
+ pc.scale = n2d->get_scale();
+ pc.id = n2d->get_instance_ID();
pose_clipboard.push_back(pc);
}
}
-
} break;
case ANIM_PASTE_POSE: {
@@ -2962,7 +2780,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
break;
undo_redo->create_action(TTR("Paste Pose"));
- for (List<PoseClipboard>::Element *E=pose_clipboard.front();E;E=E->next()) {
+ for (List<PoseClipboard>::Element *E = pose_clipboard.front(); E; E = E->next()) {
Object *o = ObjectDB::get_instance(E->get().id);
if (!o)
@@ -2970,27 +2788,27 @@ void CanvasItemEditor::_popup_callback(int p_op) {
Node2D *n2d = o->cast_to<Node2D>();
if (!n2d)
continue;
- undo_redo->add_do_method(n2d,"set_pos",E->get().pos);
- undo_redo->add_do_method(n2d,"set_rot",E->get().rot);
- undo_redo->add_do_method(n2d,"set_scale",E->get().scale);
- undo_redo->add_undo_method(n2d,"set_pos",n2d->get_position());
- undo_redo->add_undo_method(n2d,"set_rot",n2d->get_rotation());
- undo_redo->add_undo_method(n2d,"set_scale",n2d->get_scale());
+ undo_redo->add_do_method(n2d, "set_pos", E->get().pos);
+ undo_redo->add_do_method(n2d, "set_rot", E->get().rot);
+ undo_redo->add_do_method(n2d, "set_scale", E->get().scale);
+ undo_redo->add_undo_method(n2d, "set_pos", n2d->get_position());
+ undo_redo->add_undo_method(n2d, "set_rot", n2d->get_rotation());
+ undo_redo->add_undo_method(n2d, "set_scale", n2d->get_scale());
}
undo_redo->commit_action();
} break;
case ANIM_CLEAR_POSE: {
- Map<Node*,Object*> &selection = editor_selection->get_selection();
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
- for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
if (canvas_item->cast_to<Node2D>()) {
@@ -3001,7 +2819,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (key_rot)
n2d->set_rotation(0);
if (key_scale)
- n2d->set_scale(Vector2(1,1));
+ n2d->set_scale(Vector2(1, 1));
} else if (canvas_item->cast_to<Control>()) {
Control *ctrl = canvas_item->cast_to<Control>();
@@ -3013,10 +2831,8 @@ void CanvasItemEditor::_popup_callback(int p_op) {
AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size());
*/
}
-
}
-
} break;
case VIEW_CENTER_TO_SELECTION:
case VIEW_FRAME_TO_SELECTION: {
@@ -3026,11 +2842,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case SKELETON_MAKE_BONES: {
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
-
- Map<Node*,Object*> &selection = editor_selection->get_selection();
-
- for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
Node2D *n2d = E->key()->cast_to<Node2D>();
if (!n2d)
@@ -3040,19 +2854,18 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!n2d->get_parent_item())
continue;
- n2d->set_meta("_edit_bone_",true);
+ n2d->set_meta("_edit_bone_", true);
if (!skeleton_show_bones)
skeleton_menu->activate_item(skeleton_menu->get_item_index(SKELETON_SHOW_BONES));
-
}
viewport->update();
} break;
case SKELETON_CLEAR_BONES: {
- Map<Node*,Object*> &selection = editor_selection->get_selection();
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
- for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
Node2D *n2d = E->key()->cast_to<Node2D>();
if (!n2d)
@@ -3060,31 +2873,29 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!n2d->is_visible_in_tree())
continue;
- n2d->set_meta("_edit_bone_",Variant());
+ n2d->set_meta("_edit_bone_", Variant());
if (!skeleton_show_bones)
skeleton_menu->activate_item(skeleton_menu->get_item_index(SKELETON_SHOW_BONES));
-
}
viewport->update();
} break;
case SKELETON_SET_IK_CHAIN: {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
- canvas_item->set_meta("_edit_ik_",true);
+ canvas_item->set_meta("_edit_ik_", true);
if (!skeleton_show_bones)
skeleton_menu->activate_item(skeleton_menu->get_item_index(SKELETON_SHOW_BONES));
-
}
viewport->update();
@@ -3092,9 +2903,9 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case SKELETON_CLEAR_IK_CHAIN: {
- Map<Node*,Object*> &selection = editor_selection->get_selection();
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
- for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *n2d = E->key()->cast_to<CanvasItem>();
if (!n2d)
@@ -3102,15 +2913,13 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (!n2d->is_visible_in_tree())
continue;
- n2d->set_meta("_edit_ik_",Variant());
+ n2d->set_meta("_edit_ik_", Variant());
if (!skeleton_show_bones)
skeleton_menu->activate_item(skeleton_menu->get_item_index(SKELETON_SHOW_BONES));
-
}
viewport->update();
} break;
-
}
}
#if 0
@@ -3142,20 +2951,18 @@ template< class P, class C > void CanvasItemEditor::space_selected_items() {
}
#endif
-
void CanvasItemEditor::_focus_selection(int p_op) {
Vector2 center(0.f, 0.f);
Rect2 rect;
int count = 0;
- Map<Node*,Object*> &selection = editor_selection->get_selection();
- for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
if (!canvas_item) continue;
- if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
+ if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root())
continue;
-
// counting invisible items, for now
//if (!canvas_item->is_visible_in_tree()) continue;
++count;
@@ -3166,30 +2973,30 @@ void CanvasItemEditor::_focus_selection(int p_op) {
Vector2 scale = canvas_item->get_global_transform().get_scale();
real_t angle = canvas_item->get_global_transform().get_rotation();
- Transform2D t(angle, Vector2(0.f,0.f));
+ Transform2D t(angle, Vector2(0.f, 0.f));
item_rect = t.xform(item_rect);
- Rect2 canvas_item_rect(pos + scale*item_rect.pos, scale*item_rect.size);
+ Rect2 canvas_item_rect(pos + scale * item_rect.pos, scale * item_rect.size);
if (count == 1) {
rect = canvas_item_rect;
} else {
rect = rect.merge(canvas_item_rect);
}
};
- if (count==0) return;
+ if (count == 0) return;
if (p_op == VIEW_CENTER_TO_SELECTION) {
- center = rect.pos + rect.size/2;
- Vector2 offset = viewport->get_size()/2 - editor->get_scene_root()->get_global_canvas_transform().xform(center);
- h_scroll->set_value(h_scroll->get_value() - offset.x/zoom);
- v_scroll->set_value(v_scroll->get_value() - offset.y/zoom);
+ center = rect.pos + rect.size / 2;
+ Vector2 offset = viewport->get_size() / 2 - editor->get_scene_root()->get_global_canvas_transform().xform(center);
+ h_scroll->set_value(h_scroll->get_value() - offset.x / zoom);
+ v_scroll->set_value(v_scroll->get_value() - offset.y / zoom);
} else { // VIEW_FRAME_TO_SELECTION
if (rect.size.x > CMP_EPSILON && rect.size.y > CMP_EPSILON) {
- float scale_x = viewport->get_size().x/rect.size.x;
- float scale_y = viewport->get_size().y/rect.size.y;
- zoom = scale_x < scale_y? scale_x:scale_y;
+ float scale_x = viewport->get_size().x / rect.size.x;
+ float scale_y = viewport->get_size().y / rect.size.y;
+ zoom = scale_x < scale_y ? scale_x : scale_y;
zoom *= 0.90;
_update_scroll(0);
call_deferred("_popup_callback", VIEW_CENTER_TO_SELECTION);
@@ -3197,27 +3004,25 @@ void CanvasItemEditor::_focus_selection(int p_op) {
}
}
-
void CanvasItemEditor::_bind_methods() {
- ClassDB::bind_method("_node_removed",&CanvasItemEditor::_node_removed);
- ClassDB::bind_method("_update_scroll",&CanvasItemEditor::_update_scroll);
- ClassDB::bind_method("_popup_callback",&CanvasItemEditor::_popup_callback);
- ClassDB::bind_method("_visibility_changed",&CanvasItemEditor::_visibility_changed);
- ClassDB::bind_method("_dialog_value_changed",&CanvasItemEditor::_dialog_value_changed);
- ClassDB::bind_method("_get_editor_data",&CanvasItemEditor::_get_editor_data);
- ClassDB::bind_method("_tool_select",&CanvasItemEditor::_tool_select);
- ClassDB::bind_method("_keying_changed",&CanvasItemEditor::_keying_changed);
- ClassDB::bind_method("_unhandled_key_input",&CanvasItemEditor::_unhandled_key_input);
- ClassDB::bind_method("_viewport_draw",&CanvasItemEditor::_viewport_draw);
- ClassDB::bind_method("_viewport_gui_input",&CanvasItemEditor::_viewport_gui_input);
- ClassDB::bind_method("_snap_changed",&CanvasItemEditor::_snap_changed);
- ClassDB::bind_method(D_METHOD("_selection_result_pressed"),&CanvasItemEditor::_selection_result_pressed);
- ClassDB::bind_method(D_METHOD("_selection_menu_hide"),&CanvasItemEditor::_selection_menu_hide);
-
- ADD_SIGNAL( MethodInfo("item_lock_status_changed") );
- ADD_SIGNAL( MethodInfo("item_group_status_changed") );
-
+ ClassDB::bind_method("_node_removed", &CanvasItemEditor::_node_removed);
+ ClassDB::bind_method("_update_scroll", &CanvasItemEditor::_update_scroll);
+ ClassDB::bind_method("_popup_callback", &CanvasItemEditor::_popup_callback);
+ ClassDB::bind_method("_visibility_changed", &CanvasItemEditor::_visibility_changed);
+ ClassDB::bind_method("_dialog_value_changed", &CanvasItemEditor::_dialog_value_changed);
+ ClassDB::bind_method("_get_editor_data", &CanvasItemEditor::_get_editor_data);
+ ClassDB::bind_method("_tool_select", &CanvasItemEditor::_tool_select);
+ ClassDB::bind_method("_keying_changed", &CanvasItemEditor::_keying_changed);
+ ClassDB::bind_method("_unhandled_key_input", &CanvasItemEditor::_unhandled_key_input);
+ ClassDB::bind_method("_viewport_draw", &CanvasItemEditor::_viewport_draw);
+ ClassDB::bind_method("_viewport_gui_input", &CanvasItemEditor::_viewport_gui_input);
+ ClassDB::bind_method("_snap_changed", &CanvasItemEditor::_snap_changed);
+ ClassDB::bind_method(D_METHOD("_selection_result_pressed"), &CanvasItemEditor::_selection_result_pressed);
+ ClassDB::bind_method(D_METHOD("_selection_menu_hide"), &CanvasItemEditor::_selection_menu_hide);
+
+ ADD_SIGNAL(MethodInfo("item_lock_status_changed"));
+ ADD_SIGNAL(MethodInfo("item_group_status_changed"));
}
#if 0
@@ -3303,142 +3108,135 @@ VSplitContainer *CanvasItemEditor::get_bottom_split() {
return bottom_split;
}
-
void CanvasItemEditor::focus_selection() {
_focus_selection(VIEW_CENTER_TO_SELECTION);
}
-
CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
tool = TOOL_SELECT;
- undo_redo=p_editor->get_undo_redo();
- editor=p_editor;
- editor_selection=p_editor->get_editor_selection();
+ undo_redo = p_editor->get_undo_redo();
+ editor = p_editor;
+ editor_selection = p_editor->get_editor_selection();
editor_selection->add_editor_plugin(this);
- editor_selection->connect("selection_changed",this,"update");
+ editor_selection->connect("selection_changed", this, "update");
-
- hb = memnew( HBoxContainer );
- add_child( hb );
+ hb = memnew(HBoxContainer);
+ add_child(hb);
hb->set_area_as_parent_rect();
- bottom_split = memnew( VSplitContainer );
+ bottom_split = memnew(VSplitContainer);
bottom_split->set_v_size_flags(SIZE_EXPAND_FILL);
add_child(bottom_split);
- palette_split = memnew( HSplitContainer);
+ palette_split = memnew(HSplitContainer);
palette_split->set_v_size_flags(SIZE_EXPAND_FILL);
bottom_split->add_child(palette_split);
- Control *vp_base = memnew (Control);
+ Control *vp_base = memnew(Control);
vp_base->set_v_size_flags(SIZE_EXPAND_FILL);
palette_split->add_child(vp_base);
- ViewportContainer *vp = memnew (ViewportContainer);
+ ViewportContainer *vp = memnew(ViewportContainer);
vp->set_stretch(true);
vp_base->add_child(vp);
vp->set_area_as_parent_rect();
vp->add_child(p_editor->get_scene_root());
-
- viewport = memnew( CanvasItemEditorViewport(p_editor, this) );
+ viewport = memnew(CanvasItemEditorViewport(p_editor, this));
vp_base->add_child(viewport);
viewport->set_area_as_parent_rect();
viewport->set_clip_contents(true);
- h_scroll = memnew( HScrollBar );
- v_scroll = memnew( VScrollBar );
+ h_scroll = memnew(HScrollBar);
+ v_scroll = memnew(VScrollBar);
viewport->add_child(h_scroll);
viewport->add_child(v_scroll);
- viewport->connect("draw",this,"_viewport_draw");
- viewport->connect("gui_input",this,"_viewport_gui_input");
+ viewport->connect("draw", this, "_viewport_draw");
+ viewport->connect("gui_input", this, "_viewport_gui_input");
-
- h_scroll->connect("value_changed", this,"_update_scroll",Vector<Variant>(),Object::CONNECT_DEFERRED);
- v_scroll->connect("value_changed", this,"_update_scroll",Vector<Variant>(),Object::CONNECT_DEFERRED);
+ h_scroll->connect("value_changed", this, "_update_scroll", Vector<Variant>(), Object::CONNECT_DEFERRED);
+ v_scroll->connect("value_changed", this, "_update_scroll", Vector<Variant>(), Object::CONNECT_DEFERRED);
h_scroll->hide();
v_scroll->hide();
- updating_scroll=false;
+ updating_scroll = false;
viewport->set_focus_mode(FOCUS_ALL);
- handle_len=10;
- first_update=true;
-
+ handle_len = 10;
+ first_update = true;
- select_button = memnew( ToolButton );
+ select_button = memnew(ToolButton);
select_button->set_toggle_mode(true);
hb->add_child(select_button);
- select_button->connect("pressed",this,"_tool_select",make_binds(TOOL_SELECT));
+ select_button->connect("pressed", this, "_tool_select", make_binds(TOOL_SELECT));
select_button->set_pressed(true);
- select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode",TTR("Select Mode"),KEY_Q));
- select_button->set_tooltip(TTR("Select Mode")+" $sc\n"+keycode_get_string(KEY_MASK_CMD)+TTR("Drag: Rotate")+"\n"+TTR("Alt+Drag: Move")+"\n"+TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).")+"\n"+TTR("Alt+RMB: Depth list selection"));
+ select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTR("Select Mode"), KEY_Q));
+ select_button->set_tooltip(TTR("Select Mode") + " $sc\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate") + "\n" + TTR("Alt+Drag: Move") + "\n" + TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).") + "\n" + TTR("Alt+RMB: Depth list selection"));
-
- move_button = memnew( ToolButton );
+ move_button = memnew(ToolButton);
move_button->set_toggle_mode(true);
hb->add_child(move_button);
- move_button->connect("pressed",this,"_tool_select",make_binds(TOOL_MOVE));
- move_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/move_mode",TTR("Move Mode"),KEY_W));
+ move_button->connect("pressed", this, "_tool_select", make_binds(TOOL_MOVE));
+ move_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/move_mode", TTR("Move Mode"), KEY_W));
move_button->set_tooltip(TTR("Move Mode"));
- rotate_button = memnew( ToolButton );
+ rotate_button = memnew(ToolButton);
rotate_button->set_toggle_mode(true);
hb->add_child(rotate_button);
- rotate_button->connect("pressed",this,"_tool_select",make_binds(TOOL_ROTATE));
- rotate_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/rotate_mode",TTR("Rotate Mode"),KEY_E));
+ rotate_button->connect("pressed", this, "_tool_select", make_binds(TOOL_ROTATE));
+ rotate_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/rotate_mode", TTR("Rotate Mode"), KEY_E));
rotate_button->set_tooltip(TTR("Rotate Mode"));
hb->add_child(memnew(VSeparator));
- list_select_button = memnew( ToolButton );
+ list_select_button = memnew(ToolButton);
list_select_button->set_toggle_mode(true);
hb->add_child(list_select_button);
- list_select_button->connect("pressed",this,"_tool_select",make_binds(TOOL_LIST_SELECT));
+ list_select_button->connect("pressed", this, "_tool_select", make_binds(TOOL_LIST_SELECT));
list_select_button->set_tooltip(TTR("Show a list of all objects at the position clicked\n(same as Alt+RMB in select mode)."));
- pivot_button = memnew( ToolButton );
+ pivot_button = memnew(ToolButton);
pivot_button->set_toggle_mode(true);
hb->add_child(pivot_button);
- pivot_button->connect("pressed",this,"_tool_select",make_binds(TOOL_EDIT_PIVOT));
+ pivot_button->connect("pressed", this, "_tool_select", make_binds(TOOL_EDIT_PIVOT));
pivot_button->set_tooltip(TTR("Click to change object's rotation pivot."));
- pan_button = memnew( ToolButton );
+ pan_button = memnew(ToolButton);
pan_button->set_toggle_mode(true);
hb->add_child(pan_button);
- pan_button->connect("pressed",this,"_tool_select",make_binds(TOOL_PAN));
+ pan_button->connect("pressed", this, "_tool_select", make_binds(TOOL_PAN));
pan_button->set_tooltip(TTR("Pan Mode"));
hb->add_child(memnew(VSeparator));
- lock_button = memnew( ToolButton );
+ lock_button = memnew(ToolButton);
hb->add_child(lock_button);
- lock_button->connect("pressed",this,"_popup_callback",varray(LOCK_SELECTED));
+ lock_button->connect("pressed", this, "_popup_callback", varray(LOCK_SELECTED));
lock_button->set_tooltip(TTR("Lock the selected object in place (can't be moved)."));
- unlock_button = memnew( ToolButton );
+ unlock_button = memnew(ToolButton);
hb->add_child(unlock_button);
- unlock_button->connect("pressed",this,"_popup_callback",varray(UNLOCK_SELECTED));
+ unlock_button->connect("pressed", this, "_popup_callback", varray(UNLOCK_SELECTED));
unlock_button->set_tooltip(TTR("Unlock the selected object (can be moved)."));
- group_button = memnew( ToolButton );
+ group_button = memnew(ToolButton);
hb->add_child(group_button);
- group_button->connect("pressed",this,"_popup_callback",varray(GROUP_SELECTED));
+ group_button->connect("pressed", this, "_popup_callback", varray(GROUP_SELECTED));
group_button->set_tooltip(TTR("Makes sure the object's children are not selectable."));
- ungroup_button = memnew( ToolButton );
+ ungroup_button = memnew(ToolButton);
hb->add_child(ungroup_button);
- ungroup_button->connect("pressed",this,"_popup_callback",varray(UNGROUP_SELECTED));
+ ungroup_button->connect("pressed", this, "_popup_callback", varray(UNGROUP_SELECTED));
ungroup_button->set_tooltip(TTR("Restores the object's children's ability to be selected."));
hb->add_child(memnew(VSeparator));
- edit_menu = memnew( MenuButton );
+ edit_menu = memnew(MenuButton);
edit_menu->set_text(TTR("Edit"));
hb->add_child(edit_menu);
- edit_menu->get_popup()->connect("id_pressed", this,"_popup_callback");
+ edit_menu->get_popup()->connect("id_pressed", this, "_popup_callback");
PopupMenu *p;
p = edit_menu->get_popup();
@@ -3452,19 +3250,18 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/expand_to_parent", TTR("Expand to Parent"), KEY_MASK_CMD | KEY_P), EXPAND_TO_PARENT);
p->add_separator();
- p->add_submenu_item(TTR("Skeleton.."),"skeleton");
+ p->add_submenu_item(TTR("Skeleton.."), "skeleton");
skeleton_menu = memnew(PopupMenu);
p->add_child(skeleton_menu);
skeleton_menu->set_name("skeleton");
- skeleton_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_make_bones", TTR("Make Bones"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B ),SKELETON_MAKE_BONES);
+ skeleton_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_make_bones", TTR("Make Bones"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B), SKELETON_MAKE_BONES);
skeleton_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_bones", TTR("Clear Bones")), SKELETON_CLEAR_BONES);
skeleton_menu->add_separator();
skeleton_menu->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_show_bones", TTR("Show Bones")), SKELETON_SHOW_BONES);
skeleton_menu->add_separator();
skeleton_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_set_ik_chain", TTR("Make IK Chain")), SKELETON_SET_IK_CHAIN);
skeleton_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_ik_chain", TTR("Clear IK Chain")), SKELETON_CLEAR_IK_CHAIN);
- skeleton_menu->connect("id_pressed", this,"_popup_callback");
-
+ skeleton_menu->connect("id_pressed", this, "_popup_callback");
/*
p->add_item("Align Horizontal",ALIGN_HORIZONTAL);
@@ -3472,10 +3269,10 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p->add_item("Space Horizontal",SPACE_HORIZONTAL);
p->add_item("Space Vertical",SPACE_VERTICAL);*/
- view_menu = memnew( MenuButton );
+ view_menu = memnew(MenuButton);
view_menu->set_text(TTR("View"));
hb->add_child(view_menu);
- view_menu->get_popup()->connect("id_pressed", this,"_popup_callback");
+ view_menu->get_popup()->connect("id_pressed", this, "_popup_callback");
p = view_menu->get_popup();
@@ -3487,123 +3284,121 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/center_selection", TTR("Center Selection"), KEY_F), VIEW_CENTER_TO_SELECTION);
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/frame_selection", TTR("Frame Selection"), KEY_MASK_SHIFT | KEY_F), VIEW_FRAME_TO_SELECTION);
- anchor_menu = memnew( MenuButton );
+ anchor_menu = memnew(MenuButton);
anchor_menu->set_text(TTR("Anchor"));
hb->add_child(anchor_menu);
- anchor_menu->get_popup()->connect("id_pressed", this,"_popup_callback");
+ anchor_menu->get_popup()->connect("id_pressed", this, "_popup_callback");
anchor_menu->hide();
//p = anchor_menu->get_popup();
-
-
- animation_hb = memnew( HBoxContainer );
+ animation_hb = memnew(HBoxContainer);
hb->add_child(animation_hb);
- animation_hb->add_child( memnew( VSeparator ));
+ animation_hb->add_child(memnew(VSeparator));
animation_hb->hide();
- key_loc_button = memnew( Button("loc"));
+ key_loc_button = memnew(Button("loc"));
key_loc_button->set_toggle_mode(true);
key_loc_button->set_pressed(true);
key_loc_button->set_focus_mode(FOCUS_NONE);
- key_loc_button->add_color_override("font_color",Color(1,0.6,0.6));
- key_loc_button->add_color_override("font_color_pressed",Color(0.6,1,0.6));
- key_loc_button->connect("pressed",this,"_popup_callback",varray(ANIM_INSERT_POS));
+ key_loc_button->add_color_override("font_color", Color(1, 0.6, 0.6));
+ key_loc_button->add_color_override("font_color_pressed", Color(0.6, 1, 0.6));
+ key_loc_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_POS));
animation_hb->add_child(key_loc_button);
- key_rot_button = memnew( Button("rot"));
+ key_rot_button = memnew(Button("rot"));
key_rot_button->set_toggle_mode(true);
key_rot_button->set_pressed(true);
key_rot_button->set_focus_mode(FOCUS_NONE);
- key_rot_button->add_color_override("font_color",Color(1,0.6,0.6));
- key_rot_button->add_color_override("font_color_pressed",Color(0.6,1,0.6));
- key_rot_button->connect("pressed",this,"_popup_callback",varray(ANIM_INSERT_ROT));
+ key_rot_button->add_color_override("font_color", Color(1, 0.6, 0.6));
+ key_rot_button->add_color_override("font_color_pressed", Color(0.6, 1, 0.6));
+ key_rot_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_ROT));
animation_hb->add_child(key_rot_button);
- key_scale_button = memnew( Button("scl"));
+ key_scale_button = memnew(Button("scl"));
key_scale_button->set_toggle_mode(true);
key_scale_button->set_focus_mode(FOCUS_NONE);
- key_scale_button->add_color_override("font_color",Color(1,0.6,0.6));
- key_scale_button->add_color_override("font_color_pressed",Color(0.6,1,0.6));
- key_scale_button->connect("pressed",this,"_popup_callback",varray(ANIM_INSERT_SCALE));
+ key_scale_button->add_color_override("font_color", Color(1, 0.6, 0.6));
+ key_scale_button->add_color_override("font_color_pressed", Color(0.6, 1, 0.6));
+ key_scale_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_SCALE));
animation_hb->add_child(key_scale_button);
- key_insert_button = memnew( Button );
+ key_insert_button = memnew(Button);
key_insert_button->set_focus_mode(FOCUS_NONE);
- key_insert_button->connect("pressed",this,"_popup_callback",varray(ANIM_INSERT_KEY));
+ key_insert_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_KEY));
key_insert_button->set_tooltip(TTR("Insert Keys"));
key_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key", TTR("Insert Key"), KEY_INSERT));
animation_hb->add_child(key_insert_button);
- animation_menu = memnew( MenuButton );
+ animation_menu = memnew(MenuButton);
animation_menu->set_text(TTR("Animation"));
animation_hb->add_child(animation_menu);
- animation_menu->get_popup()->connect("id_pressed", this,"_popup_callback");
+ animation_menu->get_popup()->connect("id_pressed", this, "_popup_callback");
p = animation_menu->get_popup();
p->add_shortcut(ED_GET_SHORTCUT("canvas_item_editor/anim_insert_key"), ANIM_INSERT_KEY);
- p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key_existing_tracks", TTR("Insert Key (Existing Tracks)"), KEY_MASK_CMD+KEY_INSERT), ANIM_INSERT_KEY_EXISTING);
+ p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key_existing_tracks", TTR("Insert Key (Existing Tracks)"), KEY_MASK_CMD + KEY_INSERT), ANIM_INSERT_KEY_EXISTING);
p->add_separator();
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_copy_pose", TTR("Copy Pose")), ANIM_COPY_POSE);
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_paste_pose", TTR("Paste Pose")), ANIM_PASTE_POSE);
p->add_shortcut(ED_SHORTCUT("canvas_item_editor/anim_clear_pose", TTR("Clear Pose"), KEY_MASK_SHIFT | KEY_K), ANIM_CLEAR_POSE);
- snap_dialog = memnew( SnapDialog );
- snap_dialog->connect("confirmed",this,"_snap_changed");
+ snap_dialog = memnew(SnapDialog);
+ snap_dialog->connect("confirmed", this, "_snap_changed");
add_child(snap_dialog);
- value_dialog = memnew( AcceptDialog );
+ value_dialog = memnew(AcceptDialog);
value_dialog->set_title(TTR("Set a Value"));
value_dialog->get_ok()->set_text(TTR("Close"));
add_child(value_dialog);
Label *l = memnew(Label);
l->set_text(TTR("Snap (Pixels):"));
- l->set_pos(Point2(5,5));
+ l->set_pos(Point2(5, 5));
value_dialog->add_child(l);
- dialog_label=l;
+ dialog_label = l;
- dialog_val=memnew(SpinBox);
- dialog_val->set_anchor(MARGIN_RIGHT,ANCHOR_END);
- dialog_val->set_begin(Point2(15,25));
- dialog_val->set_end(Point2(10,25));
+ dialog_val = memnew(SpinBox);
+ dialog_val->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ dialog_val->set_begin(Point2(15, 25));
+ dialog_val->set_end(Point2(10, 25));
value_dialog->add_child(dialog_val);
- dialog_val->connect("value_changed",this,"_dialog_value_changed");
- select_sb = Ref<StyleBoxTexture>( memnew( StyleBoxTexture) );
+ dialog_val->connect("value_changed", this, "_dialog_value_changed");
+ select_sb = Ref<StyleBoxTexture>(memnew(StyleBoxTexture));
- selection_menu = memnew( PopupMenu );
+ selection_menu = memnew(PopupMenu);
add_child(selection_menu);
selection_menu->set_custom_minimum_size(Vector2(100, 0));
selection_menu->connect("id_pressed", this, "_selection_result_pressed");
selection_menu->connect("popup_hide", this, "_selection_menu_hide");
- key_pos=true;
- key_rot=true;
- key_scale=false;
-
- zoom=1;
- snap_offset=Vector2(0, 0);
- snap_step=Vector2(10, 10);
- snap_rotation_offset=0;
- snap_rotation_step=15 / (180 / Math_PI);
- snap_grid=false;
- snap_show_grid=false;
- snap_rotation=false;
- snap_pixel=false;
- skeleton_show_bones=true;
- skeleton_menu->set_item_checked(skeleton_menu->get_item_index(SKELETON_SHOW_BONES),true);
- updating_value_dialog=false;
- box_selecting=false;
+ key_pos = true;
+ key_rot = true;
+ key_scale = false;
+
+ zoom = 1;
+ snap_offset = Vector2(0, 0);
+ snap_step = Vector2(10, 10);
+ snap_rotation_offset = 0;
+ snap_rotation_step = 15 / (180 / Math_PI);
+ snap_grid = false;
+ snap_show_grid = false;
+ snap_rotation = false;
+ snap_pixel = false;
+ skeleton_show_bones = true;
+ skeleton_menu->set_item_checked(skeleton_menu->get_item_index(SKELETON_SHOW_BONES), true);
+ updating_value_dialog = false;
+ box_selecting = false;
//zoom=0.5;
- singleton=this;
+ singleton = this;
set_process_unhandled_key_input(true);
- can_move_pivot=false;
- drag=DRAG_NONE;
- bone_last_frame=0;
- additive_selection=false;
+ can_move_pivot = false;
+ drag = DRAG_NONE;
+ bone_last_frame = 0;
+ additive_selection = false;
}
-CanvasItemEditor *CanvasItemEditor::singleton=NULL;
+CanvasItemEditor *CanvasItemEditor::singleton = NULL;
void CanvasItemEditorPlugin::edit(Object *p_object) {
@@ -3621,88 +3416,83 @@ void CanvasItemEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
canvas_item_editor->show();
canvas_item_editor->set_fixed_process(true);
- VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(),false);
+ VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), false);
canvas_item_editor->viewport->grab_focus();
} else {
canvas_item_editor->hide();
canvas_item_editor->set_fixed_process(false);
- VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(),true);
+ VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), true);
}
-
}
Dictionary CanvasItemEditorPlugin::get_state() const {
return canvas_item_editor->get_state();
}
-void CanvasItemEditorPlugin::set_state(const Dictionary& p_state) {
+void CanvasItemEditorPlugin::set_state(const Dictionary &p_state) {
canvas_item_editor->set_state(p_state);
}
CanvasItemEditorPlugin::CanvasItemEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- canvas_item_editor = memnew( CanvasItemEditor(editor) );
+ editor = p_node;
+ canvas_item_editor = memnew(CanvasItemEditor(editor));
canvas_item_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
editor->get_viewport()->add_child(canvas_item_editor);
canvas_item_editor->set_area_as_parent_rect();
canvas_item_editor->hide();
-
}
-
-CanvasItemEditorPlugin::~CanvasItemEditorPlugin()
-{
+CanvasItemEditorPlugin::~CanvasItemEditorPlugin() {
}
-
void CanvasItemEditorViewport::_on_mouse_exit() {
- if (!selector->is_visible()){
+ if (!selector->is_visible()) {
_remove_preview();
}
}
-void CanvasItemEditorViewport::_on_select_type(Object* selected) {
- CheckBox* check = selected->cast_to<CheckBox>();
+void CanvasItemEditorViewport::_on_select_type(Object *selected) {
+ CheckBox *check = selected->cast_to<CheckBox>();
String type = check->get_text();
- selector_label->set_text(vformat(TTR("Add %s"),type));
- label->set_text(vformat(TTR("Adding %s..."),type));
+ selector_label->set_text(vformat(TTR("Add %s"), type));
+ label->set_text(vformat(TTR("Adding %s..."), type));
}
void CanvasItemEditorViewport::_on_change_type() {
if (!button_group->get_pressed_button())
return;
- CheckBox* check=button_group->get_pressed_button()->cast_to<CheckBox>();
- default_type=check->get_text();
+ CheckBox *check = button_group->get_pressed_button()->cast_to<CheckBox>();
+ default_type = check->get_text();
_perform_drop_data();
selector->hide();
}
-void CanvasItemEditorViewport::_create_preview(const Vector<String>& files) const {
- label->set_pos(get_global_pos()+Point2(14,14));
- label_desc->set_pos(label->get_pos()+Point2(0,label->get_size().height));
- for (int i=0;i<files.size();i++) {
- String path=files[i];
- RES res=ResourceLoader::load(path);
- String type=res->get_class();
- if (type=="ImageTexture" || type=="PackedScene") {
- if (type=="ImageTexture") {
- Ref<ImageTexture> texture=Ref<ImageTexture> ( ResourceCache::get(path)->cast_to<ImageTexture>() );
- Sprite* sprite=memnew(Sprite);
+void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const {
+ label->set_pos(get_global_pos() + Point2(14, 14));
+ label_desc->set_pos(label->get_pos() + Point2(0, label->get_size().height));
+ for (int i = 0; i < files.size(); i++) {
+ String path = files[i];
+ RES res = ResourceLoader::load(path);
+ String type = res->get_class();
+ if (type == "ImageTexture" || type == "PackedScene") {
+ if (type == "ImageTexture") {
+ Ref<ImageTexture> texture = Ref<ImageTexture>(ResourceCache::get(path)->cast_to<ImageTexture>());
+ Sprite *sprite = memnew(Sprite);
sprite->set_texture(texture);
- sprite->set_modulate(Color(1,1,1,0.7f));
+ sprite->set_modulate(Color(1, 1, 1, 0.7f));
preview->add_child(sprite);
label->show();
label_desc->show();
- } else if (type=="PackedScene") {
- Ref<PackedScene> scn=ResourceLoader::load(path);
- if (scn.is_valid()){
- Node* instance=scn->instance();
- if (instance){
+ } else if (type == "PackedScene") {
+ Ref<PackedScene> scn = ResourceLoader::load(path);
+ if (scn.is_valid()) {
+ Node *instance = scn->instance();
+ if (instance) {
preview->add_child(instance);
}
}
@@ -3713,10 +3503,10 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String>& files) cons
}
void CanvasItemEditorViewport::_remove_preview() {
- if (preview->get_parent()){
+ if (preview->get_parent()) {
editor->get_scene_root()->remove_child(preview);
- for (int i=preview->get_child_count()-1;i>=0;i--){
- Node* node=preview->get_child(i);
+ for (int i = preview->get_child_count() - 1; i >= 0; i--) {
+ Node *node = preview->get_child(i);
memdelete(node);
}
label->hide();
@@ -3724,152 +3514,159 @@ void CanvasItemEditorViewport::_remove_preview() {
}
}
-bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String& p_target_scene_path, Node* p_desired_node) {
- if (p_desired_node->get_filename()==p_target_scene_path) {
+bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
+ if (p_desired_node->get_filename() == p_target_scene_path) {
return true;
}
- int childCount=p_desired_node->get_child_count();
- for (int i=0;i<childCount;i++) {
- Node* child=p_desired_node->get_child(i);
- if(_cyclical_dependency_exists(p_target_scene_path,child)) {
+ int childCount = p_desired_node->get_child_count();
+ for (int i = 0; i < childCount; i++) {
+ Node *child = p_desired_node->get_child(i);
+ if (_cyclical_dependency_exists(p_target_scene_path, child)) {
return true;
}
}
return false;
}
-void CanvasItemEditorViewport::_create_nodes(Node* parent, Node* child, String& path, const Point2& p_point) {
+void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) {
child->set_name(path.get_file().get_basename());
- Ref<ImageTexture> texture=Ref<ImageTexture> ( ResourceCache::get(path)->cast_to<ImageTexture>() );
+ Ref<ImageTexture> texture = Ref<ImageTexture>(ResourceCache::get(path)->cast_to<ImageTexture>());
Size2 texture_size = texture->get_size();
- editor_data->get_undo_redo().add_do_method(parent,"add_child",child);
- editor_data->get_undo_redo().add_do_method(child,"set_owner",editor->get_edited_scene());
+ editor_data->get_undo_redo().add_do_method(parent, "add_child", child);
+ editor_data->get_undo_redo().add_do_method(child, "set_owner", editor->get_edited_scene());
editor_data->get_undo_redo().add_do_reference(child);
- editor_data->get_undo_redo().add_undo_method(parent,"remove_child",child);
+ editor_data->get_undo_redo().add_undo_method(parent, "remove_child", child);
- String new_name=parent->validate_child_name(child);
- ScriptEditorDebugger *sed=ScriptEditor::get_singleton()->get_debugger();
- editor_data->get_undo_redo().add_do_method(sed,"live_debug_create_node",editor->get_edited_scene()->get_path_to(parent),child->get_class(),new_name);
- editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(editor->get_edited_scene()->get_path_to(parent))+"/"+new_name));
+ String new_name = parent->validate_child_name(child);
+ ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
+ editor_data->get_undo_redo().add_do_method(sed, "live_debug_create_node", editor->get_edited_scene()->get_path_to(parent), child->get_class(), new_name);
+ editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
// handle with different property for texture
String property = "texture";
List<PropertyInfo> props;
child->get_property_list(&props);
- for(const List<PropertyInfo>::Element *E=props.front();E;E=E->next() ) {
- if (E->get().name=="config/texture") { // Particles2D
- property="config/texture";
+ for (const List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+ if (E->get().name == "config/texture") { // Particles2D
+ property = "config/texture";
break;
- } else if (E->get().name=="texture/texture") { // Polygon2D
- property="texture/texture";
+ } else if (E->get().name == "texture/texture") { // Polygon2D
+ property = "texture/texture";
break;
- } else if (E->get().name=="normal") { // TouchScreenButton
- property="normal";
+ } else if (E->get().name == "normal") { // TouchScreenButton
+ property = "normal";
break;
}
}
- editor_data->get_undo_redo().add_do_property(child,property,texture);
+ editor_data->get_undo_redo().add_do_property(child, property, texture);
// make visible for certain node type
- if (default_type=="Patch9Rect") {
- editor_data->get_undo_redo().add_do_property(child,"rect/size",texture_size);
- } else if (default_type=="Polygon2D") {
+ if (default_type == "Patch9Rect") {
+ editor_data->get_undo_redo().add_do_property(child, "rect/size", texture_size);
+ } else if (default_type == "Polygon2D") {
PoolVector<Vector2> list;
- list.push_back(Vector2(0,0));
- list.push_back(Vector2(texture_size.width,0));
- list.push_back(Vector2(texture_size.width,texture_size.height));
- list.push_back(Vector2(0,texture_size.height));
- editor_data->get_undo_redo().add_do_property(child,"polygon",list);
+ list.push_back(Vector2(0, 0));
+ list.push_back(Vector2(texture_size.width, 0));
+ list.push_back(Vector2(texture_size.width, texture_size.height));
+ list.push_back(Vector2(0, texture_size.height));
+ editor_data->get_undo_redo().add_do_property(child, "polygon", list);
}
// locate at preview position
Point2 pos;
if (parent->has_method("get_global_pos")) {
- pos=parent->call("get_global_pos");
+ pos = parent->call("get_global_pos");
}
- Transform2D trans=canvas->get_canvas_transform();
- Point2 target_pos = (p_point-trans.get_origin())/trans.get_scale().x-pos;
- if (default_type=="Polygon2D" || default_type=="TouchScreenButton" || default_type=="TextureRect" || default_type=="Patch9Rect") {
- target_pos -= texture_size/2;
+ Transform2D trans = canvas->get_canvas_transform();
+ Point2 target_pos = (p_point - trans.get_origin()) / trans.get_scale().x - pos;
+ if (default_type == "Polygon2D" || default_type == "TouchScreenButton" || default_type == "TextureRect" || default_type == "Patch9Rect") {
+ target_pos -= texture_size / 2;
}
- editor_data->get_undo_redo().add_do_method(child,"set_pos",target_pos);
+ editor_data->get_undo_redo().add_do_method(child, "set_pos", target_pos);
}
-bool CanvasItemEditorViewport::_create_instance(Node* parent, String& path, const Point2& p_point) {
- Ref<PackedScene> sdata=ResourceLoader::load(path);
+bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, const Point2 &p_point) {
+ Ref<PackedScene> sdata = ResourceLoader::load(path);
if (!sdata.is_valid()) { // invalid scene
return false;
}
- Node* instanced_scene=sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!instanced_scene) { // error on instancing
return false;
}
- if (editor->get_edited_scene()->get_filename()!="") { // cyclical instancing
+ if (editor->get_edited_scene()->get_filename() != "") { // cyclical instancing
if (_cyclical_dependency_exists(editor->get_edited_scene()->get_filename(), instanced_scene)) {
memdelete(instanced_scene);
return false;
}
}
- instanced_scene->set_filename( GlobalConfig::get_singleton()->localize_path(path) );
+ instanced_scene->set_filename(GlobalConfig::get_singleton()->localize_path(path));
- editor_data->get_undo_redo().add_do_method(parent,"add_child",instanced_scene);
- editor_data->get_undo_redo().add_do_method(instanced_scene,"set_owner",editor->get_edited_scene());
+ editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene);
+ editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", editor->get_edited_scene());
editor_data->get_undo_redo().add_do_reference(instanced_scene);
- editor_data->get_undo_redo().add_undo_method(parent,"remove_child",instanced_scene);
+ editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instanced_scene);
- String new_name=parent->validate_child_name(instanced_scene);
- ScriptEditorDebugger *sed=ScriptEditor::get_singleton()->get_debugger();
- editor_data->get_undo_redo().add_do_method(sed,"live_debug_instance_node",editor->get_edited_scene()->get_path_to(parent),path,new_name);
- editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(editor->get_edited_scene()->get_path_to(parent))+"/"+new_name));
+ String new_name = parent->validate_child_name(instanced_scene);
+ ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
+ editor_data->get_undo_redo().add_do_method(sed, "live_debug_instance_node", editor->get_edited_scene()->get_path_to(parent), path, new_name);
+ editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
Point2 pos;
- Node2D* parent_node2d=parent->cast_to<Node2D>();
+ Node2D *parent_node2d = parent->cast_to<Node2D>();
if (parent_node2d) {
- pos=parent_node2d->get_global_position();
+ pos = parent_node2d->get_global_position();
} else {
- Control* parent_control=parent->cast_to<Control>();
+ Control *parent_control = parent->cast_to<Control>();
if (parent_control) {
- pos=parent_control->get_global_pos();
+ pos = parent_control->get_global_pos();
}
}
- Transform2D trans=canvas->get_canvas_transform();
- editor_data->get_undo_redo().add_do_method(instanced_scene,"set_pos",(p_point-trans.get_origin())/trans.get_scale().x-pos);
+ Transform2D trans = canvas->get_canvas_transform();
+ editor_data->get_undo_redo().add_do_method(instanced_scene, "set_pos", (p_point - trans.get_origin()) / trans.get_scale().x - pos);
return true;
}
-void CanvasItemEditorViewport::_perform_drop_data(){
+void CanvasItemEditorViewport::_perform_drop_data() {
_remove_preview();
Vector<String> error_files;
editor_data->get_undo_redo().create_action(TTR("Create Node"));
- for (int i=0;i<selected_files.size();i++) {
- String path=selected_files[i];
- RES res=ResourceLoader::load(path);
+ for (int i = 0; i < selected_files.size(); i++) {
+ String path = selected_files[i];
+ RES res = ResourceLoader::load(path);
if (res.is_null()) {
continue;
}
- String type=res->get_class();
- if (type=="ImageTexture") {
- Node* child;
- if (default_type=="Light2D") child=memnew(Light2D);
- else if (default_type=="Particles2D") child=memnew(Particles2D);
- else if (default_type=="Polygon2D") child=memnew(Polygon2D);
- else if (default_type=="TouchScreenButton") child=memnew(TouchScreenButton);
- else if (default_type=="TextureRect") child=memnew(TextureRect);
- else if (default_type=="Patch9Rect") child=memnew(NinePatchRect);
- else child=memnew(Sprite); // default
+ String type = res->get_class();
+ if (type == "ImageTexture") {
+ Node *child;
+ if (default_type == "Light2D")
+ child = memnew(Light2D);
+ else if (default_type == "Particles2D")
+ child = memnew(Particles2D);
+ else if (default_type == "Polygon2D")
+ child = memnew(Polygon2D);
+ else if (default_type == "TouchScreenButton")
+ child = memnew(TouchScreenButton);
+ else if (default_type == "TextureRect")
+ child = memnew(TextureRect);
+ else if (default_type == "Patch9Rect")
+ child = memnew(NinePatchRect);
+ else
+ child = memnew(Sprite); // default
_create_nodes(target_node, child, path, drop_pos);
- } else if (type=="PackedScene") {
- bool success=_create_instance(target_node, path, drop_pos);
+ } else if (type == "PackedScene") {
+ bool success = _create_instance(target_node, path, drop_pos);
if (!success) {
error_files.push_back(path);
}
@@ -3878,48 +3675,48 @@ void CanvasItemEditorViewport::_perform_drop_data(){
editor_data->get_undo_redo().commit_action();
- if (error_files.size()>0) {
+ if (error_files.size() > 0) {
String files_str;
- for (int i=0;i<error_files.size();i++) {
+ for (int i = 0; i < error_files.size(); i++) {
files_str += error_files[i].get_file().get_basename() + ",";
}
- files_str=files_str.substr(0,files_str.length()-1);
+ files_str = files_str.substr(0, files_str.length() - 1);
accept->get_ok()->set_text(TTR("Ugh"));
- accept->set_text(vformat(TTR("Error instancing scene from %s"),files_str.c_str()));
+ accept->set_text(vformat(TTR("Error instancing scene from %s"), files_str.c_str()));
accept->popup_centered_minsize();
}
}
-bool CanvasItemEditorViewport::can_drop_data(const Point2& p_point,const Variant& p_data) const {
- Dictionary d=p_data;
+bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
+ Dictionary d = p_data;
if (d.has("type")) {
- if (String(d["type"])=="files") {
- Vector<String> files=d["files"];
- bool can_instance=false;
- for (int i=0;i<files.size();i++) { // check if dragged files contain resource or scene can be created at least one
- RES res=ResourceLoader::load(files[i]);
+ if (String(d["type"]) == "files") {
+ Vector<String> files = d["files"];
+ bool can_instance = false;
+ for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least one
+ RES res = ResourceLoader::load(files[i]);
if (res.is_null()) {
continue;
}
- String type=res->get_class();
- if (type=="PackedScene") {
- Ref<PackedScene> sdata=ResourceLoader::load(files[i]);
- Node* instanced_scene=sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ String type = res->get_class();
+ if (type == "PackedScene") {
+ Ref<PackedScene> sdata = ResourceLoader::load(files[i]);
+ Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!instanced_scene) {
continue;
}
memdelete(instanced_scene);
}
- can_instance=true;
+ can_instance = true;
break;
}
if (can_instance) {
- if (!preview->get_parent()){ // create preview only once
+ if (!preview->get_parent()) { // create preview only once
_create_preview(files);
}
- Transform2D trans=canvas->get_canvas_transform();
- preview->set_position((p_point-trans.get_origin())/trans.get_scale().x);
- label->set_text(vformat(TTR("Adding %s..."),default_type));
+ Transform2D trans = canvas->get_canvas_transform();
+ preview->set_position((p_point - trans.get_origin()) / trans.get_scale().x);
+ label->set_text(vformat(TTR("Adding %s..."), default_type));
}
return can_instance;
}
@@ -3928,25 +3725,25 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2& p_point,const Variant
return false;
}
-void CanvasItemEditorViewport::drop_data(const Point2& p_point,const Variant& p_data) {
- bool is_shift=Input::get_singleton()->is_key_pressed(KEY_SHIFT);
- bool is_alt=Input::get_singleton()->is_key_pressed(KEY_ALT);
+void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) {
+ bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
+ bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT);
selected_files.clear();
- Dictionary d=p_data;
- if (d.has("type") && String(d["type"])=="files"){
- selected_files=d["files"];
+ Dictionary d = p_data;
+ if (d.has("type") && String(d["type"]) == "files") {
+ selected_files = d["files"];
}
- List<Node*> list=editor->get_editor_selection()->get_selected_node_list();
- if (list.size()==0) {
+ List<Node *> list = editor->get_editor_selection()->get_selected_node_list();
+ if (list.size() == 0) {
accept->get_ok()->set_text(TTR("OK :("));
accept->set_text(TTR("No parent to instance a child at."));
accept->popup_centered_minsize();
_remove_preview();
return;
}
- if (list.size()!=1) {
+ if (list.size() != 1) {
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation requires a single selected node."));
accept->popup_centered_minsize();
@@ -3954,21 +3751,21 @@ void CanvasItemEditorViewport::drop_data(const Point2& p_point,const Variant& p_
return;
}
- target_node=list[0];
- if (is_shift && target_node!=editor->get_edited_scene()) {
- target_node=target_node->get_parent();
+ target_node = list[0];
+ if (is_shift && target_node != editor->get_edited_scene()) {
+ target_node = target_node->get_parent();
}
- drop_pos=p_point;
+ drop_pos = p_point;
if (is_alt) {
- List<BaseButton*> btn_list;
+ List<BaseButton *> btn_list;
button_group->get_buttons(&btn_list);
- for (int i=0;i<btn_list.size();i++) {
- CheckBox* check=btn_list[i]->cast_to<CheckBox>();
- check->set_pressed(check->get_text()==default_type);
+ for (int i = 0; i < btn_list.size(); i++) {
+ CheckBox *check = btn_list[i]->cast_to<CheckBox>();
+ check->set_pressed(check->get_text() == default_type);
}
- selector_label->set_text(vformat(TTR("Add %s"),default_type));
+ selector_label->set_text(vformat(TTR("Add %s"), default_type));
selector->popup_centered_minsize();
} else {
_perform_drop_data();
@@ -3976,21 +3773,21 @@ void CanvasItemEditorViewport::drop_data(const Point2& p_point,const Variant& p_
}
void CanvasItemEditorViewport::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
- connect("mouse_exited",this,"_on_mouse_exit");
- } else if (p_what==NOTIFICATION_EXIT_TREE) {
- disconnect("mouse_exited",this,"_on_mouse_exit");
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ connect("mouse_exited", this, "_on_mouse_exit");
+ } else if (p_what == NOTIFICATION_EXIT_TREE) {
+ disconnect("mouse_exited", this, "_on_mouse_exit");
}
}
void CanvasItemEditorViewport::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_on_select_type"),&CanvasItemEditorViewport::_on_select_type);
- ClassDB::bind_method(D_METHOD("_on_change_type"),&CanvasItemEditorViewport::_on_change_type);
- ClassDB::bind_method(D_METHOD("_on_mouse_exit"),&CanvasItemEditorViewport::_on_mouse_exit);
+ ClassDB::bind_method(D_METHOD("_on_select_type"), &CanvasItemEditorViewport::_on_select_type);
+ ClassDB::bind_method(D_METHOD("_on_change_type"), &CanvasItemEditorViewport::_on_change_type);
+ ClassDB::bind_method(D_METHOD("_on_mouse_exit"), &CanvasItemEditorViewport::_on_mouse_exit);
}
-CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor* p_canvas) {
- default_type="Sprite";
+CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor *p_canvas) {
+ default_type = "Sprite";
// Node2D
types.push_back("Sprite");
types.push_back("Light2D");
@@ -4001,42 +3798,42 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
types.push_back("TextureRect");
types.push_back("Patch9Rect");
- target_node=NULL;
- editor=p_node;
- editor_data=editor->get_scene_tree_dock()->get_editor_data();
- canvas=p_canvas;
- preview=memnew( Node2D );
- accept=memnew( AcceptDialog );
+ target_node = NULL;
+ editor = p_node;
+ editor_data = editor->get_scene_tree_dock()->get_editor_data();
+ canvas = p_canvas;
+ preview = memnew(Node2D);
+ accept = memnew(AcceptDialog);
editor->get_gui_base()->add_child(accept);
- selector=memnew( WindowDialog );
+ selector = memnew(WindowDialog);
selector->set_title(TTR("Change default type"));
- VBoxContainer* vbc=memnew(VBoxContainer);
- vbc->add_constant_override("separation",10*EDSCALE);
- vbc->set_custom_minimum_size(Size2(200,260)*EDSCALE);
+ VBoxContainer *vbc = memnew(VBoxContainer);
+ vbc->add_constant_override("separation", 10 * EDSCALE);
+ vbc->set_custom_minimum_size(Size2(200, 260) * EDSCALE);
- selector_label=memnew(Label);
+ selector_label = memnew(Label);
selector_label->set_align(Label::ALIGN_CENTER);
selector_label->set_valign(Label::VALIGN_BOTTOM);
- selector_label->set_custom_minimum_size(Size2(0,30)*EDSCALE);
+ selector_label->set_custom_minimum_size(Size2(0, 30) * EDSCALE);
vbc->add_child(selector_label);
button_group.instance();
- btn_group=memnew( VBoxContainer );
+ btn_group = memnew(VBoxContainer);
btn_group->set_h_size_flags(0);
btn_group->connect("button_selected", this, "_on_select_type");
- for (int i=0;i<types.size();i++) {
- CheckBox* check=memnew(CheckBox);
+ for (int i = 0; i < types.size(); i++) {
+ CheckBox *check = memnew(CheckBox);
check->set_text(types[i]);
btn_group->add_child(check);
check->set_button_group(button_group);
}
vbc->add_child(btn_group);
- Button* ok=memnew(Button);
+ Button *ok = memnew(Button);
ok->set_text(TTR("OK"));
ok->set_h_size_flags(0);
vbc->add_child(ok);
@@ -4045,18 +3842,18 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
selector->add_child(vbc);
editor->get_gui_base()->add_child(selector);
- label=memnew(Label);
- label->add_color_override("font_color", Color(1,1,0,1));
- label->add_color_override("font_color_shadow", Color(0,0,0,1));
- label->add_constant_override("shadow_as_outline", 1*EDSCALE);
+ label = memnew(Label);
+ label->add_color_override("font_color", Color(1, 1, 0, 1));
+ label->add_color_override("font_color_shadow", Color(0, 0, 0, 1));
+ label->add_constant_override("shadow_as_outline", 1 * EDSCALE);
label->hide();
editor->get_gui_base()->add_child(label);
- label_desc=memnew(Label);
+ label_desc = memnew(Label);
label_desc->set_text(TTR("Drag & drop + Shift : Add node as sibling\nDrag & drop + Alt : Change node type"));
- label_desc->add_color_override("font_color", Color(0.6,0.6,0.6,1));
- label_desc->add_color_override("font_color_shadow", Color(0.2,0.2,0.2,1));
- label_desc->add_constant_override("shadow_as_outline", 1*EDSCALE);
+ label_desc->add_color_override("font_color", Color(0.6, 0.6, 0.6, 1));
+ label_desc->add_color_override("font_color_shadow", Color(0.2, 0.2, 0.2, 1));
+ label_desc->add_constant_override("shadow_as_outline", 1 * EDSCALE);
label_desc->add_constant_override("line_spacing", 0);
label_desc->hide();
editor->get_gui_base()->add_child(label_desc);
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 0c2dcdff3d..5f22437d39 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -29,15 +29,15 @@
#ifndef CONTROL_EDITOR_PLUGIN_H
#define CONTROL_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
+#include "scene/2d/canvas_item.h"
+#include "scene/gui/box_container.h"
#include "scene/gui/button_group.h"
#include "scene/gui/check_box.h"
#include "scene/gui/label.h"
-#include "scene/gui/spin_box.h"
#include "scene/gui/panel_container.h"
-#include "scene/gui/box_container.h"
-#include "scene/2d/canvas_item.h"
+#include "scene/gui/spin_box.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -46,7 +46,8 @@ class CanvasItemEditorViewport;
class CanvasItemEditorSelectedItem : public Object {
- GDCLASS(CanvasItemEditorSelectedItem,Object);
+ GDCLASS(CanvasItemEditorSelectedItem, Object);
+
public:
Variant undo_state;
Vector2 undo_pivot;
@@ -55,16 +56,15 @@ public:
float prev_rot;
Rect2 prev_rect;
- CanvasItemEditorSelectedItem() { prev_rot=0; }
+ CanvasItemEditorSelectedItem() { prev_rot = 0; }
};
class CanvasItemEditor : public VBoxContainer {
- GDCLASS(CanvasItemEditor, VBoxContainer );
+ GDCLASS(CanvasItemEditor, VBoxContainer);
EditorNode *editor;
-
enum Tool {
TOOL_SELECT,
@@ -186,15 +186,14 @@ class CanvasItemEditor : public VBoxContainer {
void _tool_select(int p_index);
-
MenuOption last_option;
struct _SelectResult {
- CanvasItem* item;
+ CanvasItem *item;
float z;
bool has_z;
- _FORCE_INLINE_ bool operator<(const _SelectResult& p_rr) const {
+ _FORCE_INLINE_ bool operator<(const _SelectResult &p_rr) const {
return has_z && p_rr.has_z ? p_rr.z < z : p_rr.has_z;
}
};
@@ -205,7 +204,10 @@ class CanvasItemEditor : public VBoxContainer {
Point2 pos;
bool lock;
bool group;
- LockList() { lock=false; group=false; }
+ LockList() {
+ lock = false;
+ group = false;
+ }
};
List<LockList> lock_list;
@@ -220,7 +222,7 @@ class CanvasItemEditor : public VBoxContainer {
};
uint64_t bone_last_frame;
- Map<ObjectID,BoneList> bone_list;
+ Map<ObjectID, BoneList> bone_list;
Transform2D bone_orig_xform;
@@ -272,7 +274,6 @@ class CanvasItemEditor : public VBoxContainer {
PopupMenu *selection_menu;
-
//PopupMenu *popup;
DragType drag;
Point2 drag_from;
@@ -297,14 +298,13 @@ class CanvasItemEditor : public VBoxContainer {
Ref<StyleBoxTexture> select_sb;
Ref<Texture> select_handle;
-
int handle_len;
bool _is_part_of_subscene(CanvasItem *p_item);
- CanvasItem* _select_canvas_item_at_pos(const Point2 &p_pos,Node* p_node,const Transform2D& p_parent_xform,const Transform2D& p_canvas_xform);
- void _find_canvas_items_at_pos(const Point2 &p_pos,Node* p_node,const Transform2D& p_parent_xform,const Transform2D& p_canvas_xform, Vector<_SelectResult> &r_items);
- void _find_canvas_items_at_rect(const Rect2& p_rect,Node* p_node,const Transform2D& p_parent_xform,const Transform2D& p_canvas_xform,List<CanvasItem*> *r_items);
+ CanvasItem *_select_canvas_item_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform);
+ void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items);
+ void _find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, List<CanvasItem *> *r_items);
- bool _select(CanvasItem *item, Point2 p_click_pos, bool p_append, bool p_drag=true);
+ bool _select(CanvasItem *item, Point2 p_click_pos, bool p_append, bool p_drag = true);
ConfirmationDialog *snap_dialog;
@@ -314,22 +314,22 @@ class CanvasItemEditor : public VBoxContainer {
CanvasItem *ref_item;
- void _edit_set_pivot(const Vector2& mouse_pos);
+ void _edit_set_pivot(const Vector2 &mouse_pos);
void _add_canvas_item(CanvasItem *p_canvas_item);
void _remove_canvas_item(CanvasItem *p_canvas_item);
void _clear_canvas_items();
void _visibility_changed(ObjectID p_canvas_item);
- void _key_move(const Vector2& p_dir, bool p_snap, KeyMoveMODE p_move_mode);
- void _list_select(const InputEventMouseButton& b);
+ void _key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE p_move_mode);
+ void _list_select(const InputEventMouseButton &b);
- DragType _find_drag_type(const Transform2D& p_xform, const Rect2& p_local_rect, const Point2& p_click, Vector2& r_point);
+ DragType _find_drag_type(const Transform2D &p_xform, const Rect2 &p_local_rect, const Point2 &p_click, Vector2 &r_point);
void _popup_callback(int p_op);
bool updating_scroll;
void _update_scroll(float);
void _update_scrollbars();
- void incbeg(float& beg,float& end, float inc, float minsize,bool p_symmetric);
- void incend(float& beg,float& end, float inc, float minsize,bool p_symmetric);
+ void incbeg(float &beg, float &end, float inc, float minsize, bool p_symmetric);
+ void incend(float &beg, float &end, float inc, float minsize, bool p_symmetric);
void _append_canvas_item(CanvasItem *p_item);
void _dialog_value_changed(double);
@@ -341,9 +341,7 @@ class CanvasItemEditor : public VBoxContainer {
Point2 _find_topleftmost_point();
-
- void _find_canvas_items_span(Node *p_node, Rect2& r_rect, const Transform2D& p_xform);
-
+ void _find_canvas_items_span(Node *p_node, Rect2 &r_rect, const Transform2D &p_xform);
Object *_get_editor_data(Object *p_what);
@@ -351,59 +349,59 @@ class CanvasItemEditor : public VBoxContainer {
int get_item_count();
void _keying_changed();
- void _unhandled_key_input(const InputEvent& p_ev);
+ void _unhandled_key_input(const InputEvent &p_ev);
- void _viewport_gui_input(const InputEvent& p_event);
+ void _viewport_gui_input(const InputEvent &p_event);
void _viewport_draw();
void _focus_selection(int p_op);
- void _set_anchor(Control::AnchorType p_left,Control::AnchorType p_top,Control::AnchorType p_right,Control::AnchorType p_bottom);
+ void _set_anchor(Control::AnchorType p_left, Control::AnchorType p_top, Control::AnchorType p_right, Control::AnchorType p_bottom);
HSplitContainer *palette_split;
VSplitContainer *bottom_split;
-friend class CanvasItemEditorPlugin;
-protected:
-
+ friend class CanvasItemEditorPlugin;
+protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
void end_drag();
- void box_selection_start( Point2 &click );
+ void box_selection_start(Point2 &click);
bool box_selection_end();
HBoxContainer *get_panel_hb() { return hb; }
struct compare_items_x {
- bool operator()( const CanvasItem *a, const CanvasItem *b ) const {
+ bool operator()(const CanvasItem *a, const CanvasItem *b) const {
return a->get_global_transform().elements[2].x < b->get_global_transform().elements[2].x;
}
};
struct compare_items_y {
- bool operator()( const CanvasItem *a, const CanvasItem *b ) const {
+ bool operator()(const CanvasItem *a, const CanvasItem *b) const {
return a->get_global_transform().elements[2].y < b->get_global_transform().elements[2].y;
}
};
struct proj_vector2_x {
- float get( const Vector2 &v ) { return v.x; }
- void set( Vector2 &v, float f ) { v.x = f; }
+ float get(const Vector2 &v) { return v.x; }
+ void set(Vector2 &v, float f) { v.x = f; }
};
struct proj_vector2_y {
- float get( const Vector2 &v ) { return v.y; }
- void set( Vector2 &v, float f ) { v.y = f; }
+ float get(const Vector2 &v) { return v.y; }
+ void set(Vector2 &v, float f) { v.y = f; }
};
- template< class P, class C > void space_selected_items();
+ template <class P, class C>
+ void space_selected_items();
static CanvasItemEditor *singleton;
-public:
+public:
Vector2 snap_point(Vector2 p_target, Vector2 p_start = Vector2(0, 0)) const;
float snap_angle(float p_target, float p_start = 0) const;
@@ -411,7 +409,7 @@ public:
static CanvasItemEditor *get_singleton() { return singleton; }
Dictionary get_state() const;
- void set_state(const Dictionary& p_state);
+ void set_state(const Dictionary &p_state);
void add_control_to_menu_panel(Control *p_control);
@@ -420,8 +418,8 @@ public:
Control *get_viewport_control() { return viewport; }
- bool get_remove_list(List<Node*> *p_list);
- void set_undo_redo(UndoRedo *p_undo_redo) {undo_redo=p_undo_redo; }
+ bool get_remove_list(List<Node *> *p_list);
+ void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
void edit(CanvasItem *p_canvas_item);
void focus_selection();
@@ -431,61 +429,59 @@ public:
class CanvasItemEditorPlugin : public EditorPlugin {
- GDCLASS( CanvasItemEditorPlugin, EditorPlugin );
+ GDCLASS(CanvasItemEditorPlugin, EditorPlugin);
CanvasItemEditor *canvas_item_editor;
EditorNode *editor;
public:
-
virtual String get_name() const { return "2D"; }
bool has_main_screen() const { return true; }
virtual void edit(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
- virtual bool get_remove_list(List<Node*> *p_list) { return canvas_item_editor->get_remove_list(p_list); }
+ virtual bool get_remove_list(List<Node *> *p_list) { return canvas_item_editor->get_remove_list(p_list); }
virtual Dictionary get_state() const;
- virtual void set_state(const Dictionary& p_state);
+ virtual void set_state(const Dictionary &p_state);
CanvasItemEditor *get_canvas_item_editor() { return canvas_item_editor; }
CanvasItemEditorPlugin(EditorNode *p_node);
~CanvasItemEditorPlugin();
-
};
class CanvasItemEditorViewport : public Control {
- GDCLASS( CanvasItemEditorViewport, Control );
+ GDCLASS(CanvasItemEditorViewport, Control);
String default_type;
Vector<String> types;
Vector<String> selected_files;
- Node* target_node;
+ Node *target_node;
Point2 drop_pos;
- EditorNode* editor;
- EditorData* editor_data;
- CanvasItemEditor* canvas;
- Node2D* preview;
- AcceptDialog* accept;
- WindowDialog* selector;
- Label* selector_label;
- Label* label;
- Label* label_desc;
- VBoxContainer* btn_group;
+ EditorNode *editor;
+ EditorData *editor_data;
+ CanvasItemEditor *canvas;
+ Node2D *preview;
+ AcceptDialog *accept;
+ WindowDialog *selector;
+ Label *selector_label;
+ Label *label;
+ Label *label_desc;
+ VBoxContainer *btn_group;
Ref<ButtonGroup> button_group;
void _on_mouse_exit();
- void _on_select_type(Object* selected);
+ void _on_select_type(Object *selected);
void _on_change_type();
- void _create_preview(const Vector<String>& files) const;
+ void _create_preview(const Vector<String> &files) const;
void _remove_preview();
- bool _cyclical_dependency_exists(const String& p_target_scene_path, Node* p_desired_node);
- void _create_nodes(Node* parent, Node* child, String& path, const Point2& p_point);
- bool _create_instance(Node* parent, String& path, const Point2& p_point);
+ bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
+ void _create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point);
+ bool _create_instance(Node *parent, String &path, const Point2 &p_point);
void _perform_drop_data();
static void _bind_methods();
@@ -494,10 +490,10 @@ protected:
void _notification(int p_what);
public:
- 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 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);
- CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor* p_canvas);
+ CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor *p_canvas);
};
#endif
diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
index 5a45267c85..0f7e3a3990 100644
--- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
@@ -29,193 +29,177 @@
#include "collision_polygon_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
-#include "os/file_access.h"
#include "editor/editor_settings.h"
-
+#include "os/file_access.h"
void CollisionPolygon2DEditor::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
- button_create->set_icon( get_icon("Edit","EditorIcons"));
- button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
+ button_create->set_icon(get_icon("Edit", "EditorIcons"));
+ button_edit->set_icon(get_icon("MovePoint", "EditorIcons"));
button_edit->set_pressed(true);
- get_tree()->connect("node_removed",this,"_node_removed");
+ get_tree()->connect("node_removed", this, "_node_removed");
} break;
case NOTIFICATION_FIXED_PROCESS: {
-
} break;
}
-
}
void CollisionPolygon2DEditor::_node_removed(Node *p_node) {
- if(p_node==node) {
- node=NULL;
+ if (p_node == node) {
+ node = NULL;
hide();
canvas_item_editor->get_viewport_control()->update();
}
-
}
-
void CollisionPolygon2DEditor::_menu_option(int p_option) {
- switch(p_option) {
+ switch (p_option) {
case MODE_CREATE: {
- mode=MODE_CREATE;
+ mode = MODE_CREATE;
button_create->set_pressed(true);
button_edit->set_pressed(false);
} break;
case MODE_EDIT: {
- mode=MODE_EDIT;
+ mode = MODE_EDIT;
button_create->set_pressed(false);
button_edit->set_pressed(true);
} break;
-
}
}
void CollisionPolygon2DEditor::_wip_close() {
undo_redo->create_action(TTR("Create Poly"));
- undo_redo->add_undo_method(node,"set_polygon",node->get_polygon());
- undo_redo->add_do_method(node,"set_polygon",wip);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_undo_method(node, "set_polygon", node->get_polygon());
+ undo_redo->add_do_method(node, "set_polygon", wip);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
wip.clear();
- wip_active=false;
- mode=MODE_EDIT;
+ wip_active = false;
+ mode = MODE_EDIT;
button_edit->set_pressed(true);
button_create->set_pressed(false);
- edited_point=-1;
+ edited_point = -1;
}
-bool CollisionPolygon2DEditor::forward_gui_input(const InputEvent& p_event) {
-
+bool CollisionPolygon2DEditor::forward_gui_input(const InputEvent &p_event) {
if (!node)
return false;
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_event.mouse_button;
+ const InputEventMouseButton &mb = p_event.mouse_button;
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
-
- Vector2 gpoint = Point2(mb.x,mb.y);
+ Vector2 gpoint = Point2(mb.x, mb.y);
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
- cpoint=canvas_item_editor->snap_point(cpoint);
+ cpoint = canvas_item_editor->snap_point(cpoint);
cpoint = node->get_global_transform().affine_inverse().xform(cpoint);
Vector<Vector2> poly = node->get_polygon();
//first check if a point is to be added (segment split)
- real_t grab_treshold=EDITOR_DEF("editors/poly_editor/point_grab_radius",8);
-
- switch(mode) {
+ real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
+ switch (mode) {
case MODE_CREATE: {
- if (mb.button_index==BUTTON_LEFT && mb.pressed) {
-
+ if (mb.button_index == BUTTON_LEFT && mb.pressed) {
if (!wip_active) {
wip.clear();
- wip.push_back( cpoint );
- wip_active=true;
- edited_point_pos=cpoint;
+ wip.push_back(cpoint);
+ wip_active = true;
+ edited_point_pos = cpoint;
canvas_item_editor->get_viewport_control()->update();
- edited_point=1;
+ edited_point = 1;
return true;
} else {
-
- if (wip.size()>1 && xform.xform(wip[0]).distance_to(gpoint)<grab_treshold) {
+ if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_treshold) {
//wip closed
_wip_close();
return true;
} else {
- wip.push_back( cpoint );
- edited_point=wip.size();
+ wip.push_back(cpoint);
+ edited_point = wip.size();
canvas_item_editor->get_viewport_control()->update();
return true;
//add wip point
}
}
- } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && wip_active) {
+ } else if (mb.button_index == BUTTON_RIGHT && mb.pressed && wip_active) {
_wip_close();
}
-
-
} break;
case MODE_EDIT: {
- if (mb.button_index==BUTTON_LEFT) {
+ if (mb.button_index == BUTTON_LEFT) {
if (mb.pressed) {
if (mb.mod.control) {
-
if (poly.size() < 3) {
undo_redo->create_action(TTR("Edit Poly"));
- undo_redo->add_undo_method(node,"set_polygon",poly);
+ undo_redo->add_undo_method(node, "set_polygon", poly);
poly.push_back(cpoint);
- undo_redo->add_do_method(node,"set_polygon",poly);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node, "set_polygon", poly);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
return true;
}
//search edges
- int closest_idx=-1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 points[2] ={ xform.xform(poly[i]),
- xform.xform(poly[(i+1)%poly.size()]) };
+ Vector2 points[2] = { xform.xform(poly[i]),
+ xform.xform(poly[(i + 1) % poly.size()]) };
- Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint,points);
- if (cp.distance_squared_to(points[0])<CMP_EPSILON2 || cp.distance_squared_to(points[1])<CMP_EPSILON2)
+ Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint, points);
+ if (cp.distance_squared_to(points[0]) < CMP_EPSILON2 || cp.distance_squared_to(points[1]) < CMP_EPSILON2)
continue; //not valid to reuse point
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
}
-
-
}
- if (closest_idx>=0) {
+ if (closest_idx >= 0) {
- pre_move_edit=poly;
- poly.insert(closest_idx+1,xform.affine_inverse().xform(closest_pos));
- edited_point=closest_idx+1;
- edited_point_pos=xform.affine_inverse().xform(closest_pos);
+ pre_move_edit = poly;
+ poly.insert(closest_idx + 1, xform.affine_inverse().xform(closest_pos));
+ edited_point = closest_idx + 1;
+ edited_point_pos = xform.affine_inverse().xform(closest_pos);
node->set_polygon(poly);
canvas_item_editor->get_viewport_control()->update();
return true;
@@ -224,106 +208,95 @@ bool CollisionPolygon2DEditor::forward_gui_input(const InputEvent& p_event) {
//look for points to move
- int closest_idx=-1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 cp =xform.xform(poly[i]);
+ Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
}
-
}
- if (closest_idx>=0) {
+ if (closest_idx >= 0) {
- pre_move_edit=poly;
- edited_point=closest_idx;
- edited_point_pos=xform.affine_inverse().xform(closest_pos);
+ pre_move_edit = poly;
+ edited_point = closest_idx;
+ edited_point_pos = xform.affine_inverse().xform(closest_pos);
canvas_item_editor->get_viewport_control()->update();
return true;
}
}
} else {
- if (edited_point!=-1) {
+ if (edited_point != -1) {
//apply
- ERR_FAIL_INDEX_V(edited_point,poly.size(),false);
- poly[edited_point]=edited_point_pos;
+ ERR_FAIL_INDEX_V(edited_point, poly.size(), false);
+ poly[edited_point] = edited_point_pos;
undo_redo->create_action(TTR("Edit Poly"));
- undo_redo->add_do_method(node,"set_polygon",poly);
- undo_redo->add_undo_method(node,"set_polygon",pre_move_edit);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node, "set_polygon", poly);
+ undo_redo->add_undo_method(node, "set_polygon", pre_move_edit);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
- edited_point=-1;
+ edited_point = -1;
return true;
}
}
- } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
-
+ } else if (mb.button_index == BUTTON_RIGHT && mb.pressed && edited_point == -1) {
-
- int closest_idx=-1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 cp =xform.xform(poly[i]);
+ Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
}
-
}
- if (closest_idx>=0) {
-
+ if (closest_idx >= 0) {
undo_redo->create_action(TTR("Edit Poly (Remove Point)"));
- undo_redo->add_undo_method(node,"set_polygon",poly);
+ undo_redo->add_undo_method(node, "set_polygon", poly);
poly.remove(closest_idx);
- undo_redo->add_do_method(node,"set_polygon",poly);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node, "set_polygon", poly);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
return true;
}
-
}
-
-
} break;
}
-
-
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_event.mouse_motion;
+ const InputEventMouseMotion &mm = p_event.mouse_motion;
- if (edited_point!=-1 && (wip_active || mm.button_mask&BUTTON_MASK_LEFT)) {
+ if (edited_point != -1 && (wip_active || mm.button_mask & BUTTON_MASK_LEFT)) {
- Vector2 gpoint = Point2(mm.x,mm.y);
+ Vector2 gpoint = Point2(mm.x, mm.y);
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
- cpoint=canvas_item_editor->snap_point(cpoint);
+ cpoint = canvas_item_editor->snap_point(cpoint);
edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint);
canvas_item_editor->get_viewport_control()->update();
-
}
} break;
@@ -341,90 +314,83 @@ void CollisionPolygon2DEditor::_canvas_draw() {
Vector<Vector2> poly;
if (wip_active)
- poly=wip;
+ poly = wip;
else
- poly=node->get_polygon();
-
+ poly = node->get_polygon();
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- Ref<Texture> handle= get_icon("EditorHandle","EditorIcons");
-
- for(int i=0;i<poly.size();i++) {
+ Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons");
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 p,p2;
- p = i==edited_point ? edited_point_pos : poly[i];
- if ((wip_active && i==poly.size()-1) || (((i+1)%poly.size())==edited_point))
- p2=edited_point_pos;
+ Vector2 p, p2;
+ p = i == edited_point ? edited_point_pos : poly[i];
+ if ((wip_active && i == poly.size() - 1) || (((i + 1) % poly.size()) == edited_point))
+ p2 = edited_point_pos;
else
- p2 = poly[(i+1)%poly.size()];
+ p2 = poly[(i + 1) % poly.size()];
Vector2 point = xform.xform(p);
Vector2 next_point = xform.xform(p2);
- Color col=Color(1,0.3,0.1,0.8);
- vpc->draw_line(point,next_point,col,2);
- vpc->draw_texture(handle,point-handle->get_size()*0.5);
+ Color col = Color(1, 0.3, 0.1, 0.8);
+ vpc->draw_line(point, next_point, col, 2);
+ vpc->draw_texture(handle, point - handle->get_size() * 0.5);
}
}
-
-
void CollisionPolygon2DEditor::edit(Node *p_collision_polygon) {
if (!canvas_item_editor) {
- canvas_item_editor=CanvasItemEditor::get_singleton();
+ canvas_item_editor = CanvasItemEditor::get_singleton();
}
if (p_collision_polygon) {
- node=p_collision_polygon->cast_to<CollisionPolygon2D>();
- if (!canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->connect("draw",this,"_canvas_draw");
+ node = p_collision_polygon->cast_to<CollisionPolygon2D>();
+ if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
wip.clear();
- wip_active=false;
- edited_point=-1;
+ wip_active = false;
+ edited_point = -1;
canvas_item_editor->get_viewport_control()->update();
} else {
- node=NULL;
-
- if (canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->disconnect("draw",this,"_canvas_draw");
+ node = NULL;
+ if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw");
}
-
}
void CollisionPolygon2DEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_menu_option"),&CollisionPolygon2DEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_canvas_draw"),&CollisionPolygon2DEditor::_canvas_draw);
- ClassDB::bind_method(D_METHOD("_node_removed"),&CollisionPolygon2DEditor::_node_removed);
-
+ ClassDB::bind_method(D_METHOD("_menu_option"), &CollisionPolygon2DEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"), &CollisionPolygon2DEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_node_removed"), &CollisionPolygon2DEditor::_node_removed);
}
CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) {
- node=NULL;
- canvas_item_editor=NULL;
- editor=p_editor;
+ node = NULL;
+ canvas_item_editor = NULL;
+ editor = p_editor;
undo_redo = editor->get_undo_redo();
- add_child( memnew( VSeparator ));
- button_create = memnew( ToolButton );
+ add_child(memnew(VSeparator));
+ button_create = memnew(ToolButton);
add_child(button_create);
- button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE));
+ button_create->connect("pressed", this, "_menu_option", varray(MODE_CREATE));
button_create->set_toggle_mode(true);
button_create->set_tooltip(TTR("Create a new polygon from scratch."));
- button_edit = memnew( ToolButton );
+ button_edit = memnew(ToolButton);
add_child(button_edit);
- button_edit->connect("pressed",this,"_menu_option",varray(MODE_EDIT));
+ button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT));
button_edit->set_toggle_mode(true);
button_edit->set_tooltip("Edit existing polygon:\nLMB: Move Point.\nCtrl+LMB: Split Segment.\nRMB: Erase Point.");
- //add_constant_override("separation",0);
+//add_constant_override("separation",0);
#if 0
options = memnew( MenuButton );
@@ -436,11 +402,9 @@ CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) {
#endif
mode = MODE_EDIT;
- wip_active=false;
-
+ wip_active = false;
}
-
void CollisionPolygon2DEditorPlugin::edit(Object *p_object) {
collision_polygon_editor->edit(p_object->cast_to<Node>());
@@ -460,23 +424,16 @@ void CollisionPolygon2DEditorPlugin::make_visible(bool p_visible) {
collision_polygon_editor->hide();
collision_polygon_editor->edit(NULL);
}
-
}
CollisionPolygon2DEditorPlugin::CollisionPolygon2DEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- collision_polygon_editor = memnew( CollisionPolygon2DEditor(p_node) );
+ editor = p_node;
+ collision_polygon_editor = memnew(CollisionPolygon2DEditor(p_node));
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
collision_polygon_editor->hide();
-
-
-
}
-
-CollisionPolygon2DEditorPlugin::~CollisionPolygon2DEditorPlugin()
-{
+CollisionPolygon2DEditorPlugin::~CollisionPolygon2DEditorPlugin() {
}
-
diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.h b/editor/plugins/collision_polygon_2d_editor_plugin.h
index 796328753d..abd723cce9 100644
--- a/editor/plugins/collision_polygon_2d_editor_plugin.h
+++ b/editor/plugins/collision_polygon_2d_editor_plugin.h
@@ -29,12 +29,11 @@
#ifndef COLLISION_POLYGON_2D_EDITOR_PLUGIN_H
#define COLLISION_POLYGON_2D_EDITOR_PLUGIN_H
-
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/2d/collision_polygon_2d.h"
-#include "scene/gui/tool_button.h"
#include "scene/gui/button_group.h"
+#include "scene/gui/tool_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -43,7 +42,7 @@ class CanvasItemEditor;
class CollisionPolygon2DEditor : public HBoxContainer {
- GDCLASS(CollisionPolygon2DEditor, HBoxContainer );
+ GDCLASS(CollisionPolygon2DEditor, HBoxContainer);
UndoRedo *undo_redo;
enum Mode {
@@ -70,7 +69,6 @@ class CollisionPolygon2DEditor : public HBoxContainer {
Vector<Vector2> wip;
bool wip_active;
-
void _wip_close();
void _canvas_draw();
void _menu_option(int p_option);
@@ -79,23 +77,22 @@ protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
-public:
- bool forward_gui_input(const InputEvent& p_event);
+public:
+ bool forward_gui_input(const InputEvent &p_event);
void edit(Node *p_collision_polygon);
CollisionPolygon2DEditor(EditorNode *p_editor);
};
class CollisionPolygon2DEditorPlugin : public EditorPlugin {
- GDCLASS( CollisionPolygon2DEditorPlugin, EditorPlugin );
+ GDCLASS(CollisionPolygon2DEditorPlugin, EditorPlugin);
CollisionPolygon2DEditor *collision_polygon_editor;
EditorNode *editor;
public:
-
- virtual bool forward_canvas_gui_input(const Transform2D& p_canvas_xform,const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
+ virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
virtual String get_name() const { return "CollisionPolygon2D"; }
bool has_main_screen() const { return false; }
@@ -105,7 +102,6 @@ public:
CollisionPolygon2DEditorPlugin(EditorNode *p_node);
~CollisionPolygon2DEditorPlugin();
-
};
#endif // COLLISION_POLYGON_2D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp
index 3aad53b420..62426a7699 100644
--- a/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -28,11 +28,11 @@
/*************************************************************************/
#include "collision_polygon_editor_plugin.h"
-#include "spatial_editor_plugin.h"
-#include "os/file_access.h"
+#include "canvas_item_editor_plugin.h"
#include "editor/editor_settings.h"
+#include "os/file_access.h"
#include "scene/3d/camera.h"
-#include "canvas_item_editor_plugin.h"
+#include "spatial_editor_plugin.h"
#if 0
diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_editor_plugin.h
index aaad2174fe..ace8c3429f 100644
--- a/editor/plugins/collision_polygon_editor_plugin.h
+++ b/editor/plugins/collision_polygon_editor_plugin.h
@@ -29,13 +29,13 @@
#ifndef COLLISION_POLYGON_EDITOR_PLUGIN_H
#define COLLISION_POLYGON_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/3d/collision_polygon.h"
#include "scene/3d/immediate_geometry.h"
#include "scene/3d/mesh_instance.h"
-#include "scene/gui/tool_button.h"
#include "scene/gui/button_group.h"
+#include "scene/gui/tool_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp
index a05eeb7a27..3538878877 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -29,23 +29,23 @@
#include "collision_shape_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.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"
Variant CollisionShape2DEditor::get_handle_value(int idx) const {
- switch ( shape_type ) {
+ switch (shape_type) {
case CAPSULE_SHAPE: {
Ref<CapsuleShape2D> capsule = node->get_shape();
- if (idx==0) {
+ if (idx == 0) {
return capsule->get_radius();
- } else if (idx==1) {
+ } else if (idx == 1) {
return capsule->get_height();
}
@@ -54,7 +54,7 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
case CIRCLE_SHAPE: {
Ref<CircleShape2D> circle = node->get_shape();
- if (idx==0) {
+ if (idx == 0) {
return circle->get_radius();
}
@@ -71,7 +71,7 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
case LINE_SHAPE: {
Ref<LineShape2D> line = node->get_shape();
- if (idx==0) {
+ if (idx == 0) {
return line->get_d();
} else {
return line->get_normal();
@@ -82,7 +82,7 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
case RAY_SHAPE: {
Ref<RayShape2D> ray = node->get_shape();
- if (idx==0) {
+ if (idx == 0) {
return ray->get_length();
}
@@ -91,7 +91,7 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
case RECTANGLE_SHAPE: {
Ref<RectangleShape2D> rect = node->get_shape();
- if (idx<2) {
+ if (idx < 2) {
return rect->get_extents().abs();
}
@@ -100,9 +100,9 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
case SEGMENT_SHAPE: {
Ref<SegmentShape2D> seg = node->get_shape();
- if (idx==0) {
+ if (idx == 0) {
return seg->get_a();
- } else if (idx==1) {
+ } else if (idx == 1) {
return seg->get_b();
}
@@ -112,19 +112,19 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
return Variant();
}
-void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) {
+void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
- switch ( shape_type ) {
+ switch (shape_type) {
case CAPSULE_SHAPE: {
if (idx < 2) {
Ref<CapsuleShape2D> capsule = node->get_shape();
real_t parameter = Math::abs(p_point[idx]);
- if (idx==0) {
+ if (idx == 0) {
capsule->set_radius(parameter);
- } else if (idx==1){
- capsule->set_height(parameter*2 - capsule->get_radius()*2);
+ } else if (idx == 1) {
+ capsule->set_height(parameter * 2 - capsule->get_radius() * 2);
}
canvas_item_editor->get_viewport_control()->update();
@@ -149,19 +149,18 @@ void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) {
} break;
case LINE_SHAPE: {
- if (idx<2) {
+ if (idx < 2) {
Ref<LineShape2D> line = node->get_shape();
- if (idx==0){
+ if (idx == 0) {
line->set_d(p_point.length());
- }else{
+ } else {
line->set_normal(p_point.normalized());
}
canvas_item_editor->get_viewport_control()->update();
}
-
} break;
case RAY_SHAPE: {
@@ -174,7 +173,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) {
} break;
case RECTANGLE_SHAPE: {
- if (idx<2) {
+ if (idx < 2) {
Ref<RectangleShape2D> rect = node->get_shape();
Vector2 extents = rect->get_extents();
@@ -191,9 +190,9 @@ void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) {
if (edit_handle < 2) {
Ref<SegmentShape2D> seg = node->get_shape();
- if (idx==0) {
+ if (idx == 0) {
seg->set_a(p_point);
- } else if (idx==1) {
+ } else if (idx == 1) {
seg->set_b(p_point);
}
@@ -204,25 +203,25 @@ void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) {
}
}
-void CollisionShape2DEditor::commit_handle(int idx, Variant& p_org) {
+void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
- Control* c = canvas_item_editor->get_viewport_control();
+ Control *c = canvas_item_editor->get_viewport_control();
undo_redo->create_action(TTR("Set Handle"));
- switch ( shape_type ) {
+ switch (shape_type) {
case CAPSULE_SHAPE: {
Ref<CapsuleShape2D> capsule = node->get_shape();
- if (idx==0) {
- undo_redo->add_do_method(capsule.ptr(),"set_radius",capsule->get_radius());
- undo_redo->add_do_method(c,"update");
- undo_redo->add_undo_method(capsule.ptr(),"set_radius",p_org);
- undo_redo->add_do_method(c,"update");
- } else if (idx==1) {
- undo_redo->add_do_method(capsule.ptr(),"set_height",capsule->get_height());
- undo_redo->add_do_method(c,"update");
- undo_redo->add_undo_method(capsule.ptr(),"set_height",p_org);
- undo_redo->add_undo_method(c,"update");
+ if (idx == 0) {
+ undo_redo->add_do_method(capsule.ptr(), "set_radius", capsule->get_radius());
+ undo_redo->add_do_method(c, "update");
+ undo_redo->add_undo_method(capsule.ptr(), "set_radius", p_org);
+ undo_redo->add_do_method(c, "update");
+ } else if (idx == 1) {
+ undo_redo->add_do_method(capsule.ptr(), "set_height", capsule->get_height());
+ undo_redo->add_do_method(c, "update");
+ undo_redo->add_undo_method(capsule.ptr(), "set_height", p_org);
+ undo_redo->add_undo_method(c, "update");
}
} break;
@@ -230,10 +229,10 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant& p_org) {
case CIRCLE_SHAPE: {
Ref<CircleShape2D> circle = node->get_shape();
- undo_redo->add_do_method(circle.ptr(),"set_radius",circle->get_radius());
- undo_redo->add_do_method(c,"update");
- undo_redo->add_undo_method(circle.ptr(),"set_radius",p_org);
- undo_redo->add_undo_method(c,"update");
+ undo_redo->add_do_method(circle.ptr(), "set_radius", circle->get_radius());
+ undo_redo->add_do_method(c, "update");
+ undo_redo->add_undo_method(circle.ptr(), "set_radius", p_org);
+ undo_redo->add_undo_method(c, "update");
} break;
@@ -248,16 +247,16 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant& p_org) {
case LINE_SHAPE: {
Ref<LineShape2D> line = node->get_shape();
- if (idx==0) {
- undo_redo->add_do_method(line.ptr(),"set_d",line->get_d());
- undo_redo->add_do_method(c,"update");
- undo_redo->add_undo_method(line.ptr(),"set_d",p_org);
- undo_redo->add_undo_method(c,"update");
+ if (idx == 0) {
+ undo_redo->add_do_method(line.ptr(), "set_d", line->get_d());
+ undo_redo->add_do_method(c, "update");
+ undo_redo->add_undo_method(line.ptr(), "set_d", p_org);
+ undo_redo->add_undo_method(c, "update");
} else {
- undo_redo->add_do_method(line.ptr(),"set_normal",line->get_normal());
- undo_redo->add_do_method(c,"update");
- undo_redo->add_undo_method(line.ptr(),"set_normal",p_org);
- undo_redo->add_undo_method(c,"update");
+ undo_redo->add_do_method(line.ptr(), "set_normal", line->get_normal());
+ undo_redo->add_do_method(c, "update");
+ undo_redo->add_undo_method(line.ptr(), "set_normal", p_org);
+ undo_redo->add_undo_method(c, "update");
}
} break;
@@ -265,35 +264,35 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant& p_org) {
case RAY_SHAPE: {
Ref<RayShape2D> ray = node->get_shape();
- undo_redo->add_do_method(ray.ptr(),"set_length",ray->get_length());
- undo_redo->add_do_method(c,"update");
- undo_redo->add_undo_method(ray.ptr(),"set_length",p_org);
- undo_redo->add_undo_method(c,"update");
+ undo_redo->add_do_method(ray.ptr(), "set_length", ray->get_length());
+ undo_redo->add_do_method(c, "update");
+ undo_redo->add_undo_method(ray.ptr(), "set_length", p_org);
+ undo_redo->add_undo_method(c, "update");
} break;
case RECTANGLE_SHAPE: {
Ref<RectangleShape2D> rect = node->get_shape();
- undo_redo->add_do_method(rect.ptr(),"set_extents",rect->get_extents());
- undo_redo->add_do_method(c,"update");
- undo_redo->add_undo_method(rect.ptr(),"set_extents",p_org);
- undo_redo->add_undo_method(c,"update");
+ undo_redo->add_do_method(rect.ptr(), "set_extents", rect->get_extents());
+ undo_redo->add_do_method(c, "update");
+ undo_redo->add_undo_method(rect.ptr(), "set_extents", p_org);
+ undo_redo->add_undo_method(c, "update");
} break;
case SEGMENT_SHAPE: {
Ref<SegmentShape2D> seg = node->get_shape();
- if (idx==0) {
- undo_redo->add_do_method(seg.ptr(),"set_a",seg->get_a());
- undo_redo->add_do_method(c,"update");
- undo_redo->add_undo_method(seg.ptr(),"set_a",p_org);
- undo_redo->add_undo_method(c,"update");
- } else if (idx==1) {
- undo_redo->add_do_method(seg.ptr(),"set_b",seg->get_b());
- undo_redo->add_do_method(c,"update");
- undo_redo->add_undo_method(seg.ptr(),"set_b",p_org);
- undo_redo->add_undo_method(c,"update");
+ if (idx == 0) {
+ undo_redo->add_do_method(seg.ptr(), "set_a", seg->get_a());
+ undo_redo->add_do_method(c, "update");
+ undo_redo->add_undo_method(seg.ptr(), "set_a", p_org);
+ undo_redo->add_undo_method(c, "update");
+ } else if (idx == 1) {
+ undo_redo->add_do_method(seg.ptr(), "set_b", seg->get_b());
+ undo_redo->add_do_method(c, "update");
+ undo_redo->add_undo_method(seg.ptr(), "set_b", p_org);
+ undo_redo->add_undo_method(c, "update");
}
} break;
@@ -302,7 +301,7 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant& p_org) {
undo_redo->commit_action();
}
-bool CollisionShape2DEditor::forward_gui_input(const InputEvent& p_event) {
+bool CollisionShape2DEditor::forward_gui_input(const InputEvent &p_event) {
if (!node) {
return false;
@@ -316,13 +315,13 @@ bool CollisionShape2DEditor::forward_gui_input(const InputEvent& p_event) {
return false;
}
- switch( p_event.type ) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton& mb = p_event.mouse_button;
+ const InputEventMouseButton &mb = p_event.mouse_button;
Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- Point2 gpoint(mb.x,mb.y);
+ Point2 gpoint(mb.x, mb.y);
if (mb.button_index == BUTTON_LEFT) {
if (mb.pressed) {
@@ -334,7 +333,7 @@ bool CollisionShape2DEditor::forward_gui_input(const InputEvent& p_event) {
}
}
- if (edit_handle==-1) {
+ if (edit_handle == -1) {
pressed = false;
return false;
@@ -362,13 +361,13 @@ bool CollisionShape2DEditor::forward_gui_input(const InputEvent& p_event) {
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion& mm = p_event.mouse_motion;
+ const InputEventMouseMotion &mm = p_event.mouse_motion;
if (edit_handle == -1 || !pressed) {
return false;
}
- Point2 gpoint = Point2(mm.x,mm.y);
+ Point2 gpoint = Point2(mm.x, mm.y);
Point2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
cpoint = canvas_item_editor->snap_point(cpoint);
cpoint = node->get_global_transform().affine_inverse().xform(cpoint);
@@ -437,8 +436,8 @@ void CollisionShape2DEditor::_canvas_draw() {
Control *c = canvas_item_editor->get_viewport_control();
Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- Ref<Texture> h = get_icon("EditorHandle","EditorIcons");
- Vector2 size = h->get_size()*0.5;
+ Ref<Texture> h = get_icon("EditorHandle", "EditorIcons");
+ Vector2 size = h->get_size() * 0.5;
handles.clear();
@@ -448,13 +447,13 @@ void CollisionShape2DEditor::_canvas_draw() {
handles.resize(2);
float radius = shape->get_radius();
- float height = shape->get_height()/2;
+ float height = shape->get_height() / 2;
handles[0] = Point2(radius, -height);
- handles[1] = Point2(0,-(height + radius));
+ handles[1] = Point2(0, -(height + radius));
- c->draw_texture(h, gt.xform(handles[0])-size);
- c->draw_texture(h, gt.xform(handles[1])-size);
+ c->draw_texture(h, gt.xform(handles[0]) - size);
+ c->draw_texture(h, gt.xform(handles[1]) - size);
} break;
@@ -462,9 +461,9 @@ void CollisionShape2DEditor::_canvas_draw() {
Ref<CircleShape2D> shape = node->get_shape();
handles.resize(1);
- handles[0] = Point2(shape->get_radius(),0);
+ handles[0] = Point2(shape->get_radius(), 0);
- c->draw_texture(h, gt.xform(handles[0])-size);
+ c->draw_texture(h, gt.xform(handles[0]) - size);
} break;
@@ -483,8 +482,8 @@ void CollisionShape2DEditor::_canvas_draw() {
handles[0] = shape->get_normal() * shape->get_d();
handles[1] = shape->get_normal() * (shape->get_d() + 30.0);
- c->draw_texture(h,gt.xform(handles[0])-size);
- c->draw_texture(h,gt.xform(handles[1])-size);
+ c->draw_texture(h, gt.xform(handles[0]) - size);
+ c->draw_texture(h, gt.xform(handles[1]) - size);
} break;
@@ -492,9 +491,9 @@ void CollisionShape2DEditor::_canvas_draw() {
Ref<RayShape2D> shape = node->get_shape();
handles.resize(1);
- handles[0] = Point2(0,shape->get_length());
+ handles[0] = Point2(0, shape->get_length());
- c->draw_texture(h,gt.xform(handles[0])-size);
+ c->draw_texture(h, gt.xform(handles[0]) - size);
} break;
@@ -503,11 +502,11 @@ void CollisionShape2DEditor::_canvas_draw() {
handles.resize(2);
Vector2 ext = shape->get_extents();
- handles[0] = Point2(ext.x,0);
- handles[1] = Point2(0,-ext.y);
+ handles[0] = Point2(ext.x, 0);
+ handles[1] = Point2(0, -ext.y);
- c->draw_texture(h,gt.xform(handles[0])-size);
- c->draw_texture(h,gt.xform(handles[1])-size);
+ c->draw_texture(h, gt.xform(handles[0]) - size);
+ c->draw_texture(h, gt.xform(handles[1]) - size);
} break;
@@ -518,24 +517,24 @@ void CollisionShape2DEditor::_canvas_draw() {
handles[0] = shape->get_a();
handles[1] = shape->get_b();
- c->draw_texture(h, gt.xform(handles[0])-size);
- c->draw_texture(h, gt.xform(handles[1])-size);
+ c->draw_texture(h, gt.xform(handles[0]) - size);
+ c->draw_texture(h, gt.xform(handles[1]) - size);
} break;
}
}
-void CollisionShape2DEditor::edit(Node* p_node) {
+void CollisionShape2DEditor::edit(Node *p_node) {
if (!canvas_item_editor) {
- canvas_item_editor=CanvasItemEditor::get_singleton();
+ canvas_item_editor = CanvasItemEditor::get_singleton();
}
if (p_node) {
- node=p_node->cast_to<CollisionShape2D>();
+ node = p_node->cast_to<CollisionShape2D>();
- if (!canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->connect("draw",this,"_canvas_draw");
+ if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
_get_current_shape_type();
@@ -543,10 +542,10 @@ void CollisionShape2DEditor::edit(Node* p_node) {
edit_handle = -1;
shape_type = -1;
- if (canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->disconnect("draw",this,"_canvas_draw");
+ if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw");
- node=NULL;
+ node = NULL;
}
canvas_item_editor->get_viewport_control()->update();
@@ -554,11 +553,11 @@ void CollisionShape2DEditor::edit(Node* p_node) {
void CollisionShape2DEditor::_bind_methods() {
- ClassDB::bind_method("_canvas_draw",&CollisionShape2DEditor::_canvas_draw);
- ClassDB::bind_method("_get_current_shape_type",&CollisionShape2DEditor::_get_current_shape_type);
+ ClassDB::bind_method("_canvas_draw", &CollisionShape2DEditor::_canvas_draw);
+ ClassDB::bind_method("_get_current_shape_type", &CollisionShape2DEditor::_get_current_shape_type);
}
-CollisionShape2DEditor::CollisionShape2DEditor(EditorNode* p_editor) {
+CollisionShape2DEditor::CollisionShape2DEditor(EditorNode *p_editor) {
node = NULL;
canvas_item_editor = NULL;
@@ -570,12 +569,12 @@ CollisionShape2DEditor::CollisionShape2DEditor(EditorNode* p_editor) {
pressed = false;
}
-void CollisionShape2DEditorPlugin::edit(Object* p_obj) {
+void CollisionShape2DEditorPlugin::edit(Object *p_obj) {
collision_shape_2d_editor->edit(p_obj->cast_to<Node>());
}
-bool CollisionShape2DEditorPlugin::handles(Object* p_obj) const {
+bool CollisionShape2DEditorPlugin::handles(Object *p_obj) const {
return p_obj->is_class("CollisionShape2D");
}
@@ -587,14 +586,13 @@ void CollisionShape2DEditorPlugin::make_visible(bool visible) {
}
}
-CollisionShape2DEditorPlugin::CollisionShape2DEditorPlugin(EditorNode* p_node) {
+CollisionShape2DEditorPlugin::CollisionShape2DEditorPlugin(EditorNode *p_node) {
- editor=p_node;
+ editor = p_node;
- collision_shape_2d_editor = memnew( CollisionShape2DEditor(p_node) );
+ collision_shape_2d_editor = memnew(CollisionShape2DEditor(p_node));
p_node->get_gui_base()->add_child(collision_shape_2d_editor);
}
CollisionShape2DEditorPlugin::~CollisionShape2DEditorPlugin() {
-
}
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h
index f7e6da8b4e..75331a1d61 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.h
+++ b/editor/plugins/collision_shape_2d_editor_plugin.h
@@ -29,8 +29,8 @@
#ifndef COLLISION_SHAPE_2D_EDITOR_PLUGIN_H
#define COLLISION_SHAPE_2D_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/2d/collision_shape_2d.h"
@@ -50,10 +50,10 @@ class CollisionShape2DEditor : public Control {
SEGMENT_SHAPE
};
- EditorNode* editor;
- UndoRedo* undo_redo;
- CanvasItemEditor* canvas_item_editor;
- CollisionShape2D* node;
+ EditorNode *editor;
+ UndoRedo *undo_redo;
+ CanvasItemEditor *canvas_item_editor;
+ CollisionShape2D *node;
Vector<Point2> handles;
@@ -63,8 +63,8 @@ class CollisionShape2DEditor : public Control {
Variant original;
Variant get_handle_value(int idx) const;
- void set_handle(int idx, Point2& p_point);
- void commit_handle(int idx, Variant& p_org);
+ void set_handle(int idx, Point2 &p_point);
+ void commit_handle(int idx, Variant &p_org);
void _get_current_shape_type();
void _canvas_draw();
@@ -73,28 +73,28 @@ protected:
static void _bind_methods();
public:
- bool forward_gui_input(const InputEvent& p_event);
- void edit(Node* p_node);
+ bool forward_gui_input(const InputEvent &p_event);
+ void edit(Node *p_node);
- CollisionShape2DEditor(EditorNode* p_editor);
+ CollisionShape2DEditor(EditorNode *p_editor);
};
class CollisionShape2DEditorPlugin : public EditorPlugin {
GDCLASS(CollisionShape2DEditorPlugin, EditorPlugin);
- CollisionShape2DEditor* collision_shape_2d_editor;
- EditorNode* editor;
+ CollisionShape2DEditor *collision_shape_2d_editor;
+ EditorNode *editor;
public:
- virtual bool forward_canvas_gui_input(const Transform2D& p_canvas_xform,const InputEvent& p_event) { return collision_shape_2d_editor->forward_gui_input(p_event); }
+ virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event) { return collision_shape_2d_editor->forward_gui_input(p_event); }
virtual String get_name() const { return "CollisionShape2D"; }
bool has_main_screen() const { return false; }
- virtual void edit(Object* p_obj);
- virtual bool handles(Object* p_obj) const;
+ virtual void edit(Object *p_obj);
+ virtual bool handles(Object *p_obj) const;
virtual void make_visible(bool visible);
- CollisionShape2DEditorPlugin(EditorNode* p_editor);
+ CollisionShape2DEditorPlugin(EditorNode *p_editor);
~CollisionShape2DEditorPlugin();
};
diff --git a/editor/plugins/color_ramp_editor_plugin.cpp b/editor/plugins/color_ramp_editor_plugin.cpp
index 82674fabb8..1d1d654bd5 100644
--- a/editor/plugins/color_ramp_editor_plugin.cpp
+++ b/editor/plugins/color_ramp_editor_plugin.cpp
@@ -28,16 +28,15 @@
/*************************************************************************/
#include "color_ramp_editor_plugin.h"
-#include "spatial_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
+#include "spatial_editor_plugin.h"
ColorRampEditorPlugin::ColorRampEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- ramp_editor = memnew( ColorRampEdit );
-
+ editor = p_node;
+ ramp_editor = memnew(ColorRampEdit);
- add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM,ramp_editor);
+ add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, ramp_editor);
ramp_editor->set_custom_minimum_size(Size2(100, 48));
ramp_editor->hide();
@@ -46,7 +45,7 @@ ColorRampEditorPlugin::ColorRampEditorPlugin(EditorNode *p_node) {
void ColorRampEditorPlugin::edit(Object *p_object) {
- ColorRamp* color_ramp = p_object->cast_to<ColorRamp>();
+ ColorRamp *color_ramp = p_object->cast_to<ColorRamp>();
if (!color_ramp)
return;
color_ramp_ref = Ref<ColorRamp>(color_ramp);
@@ -56,7 +55,6 @@ void ColorRampEditorPlugin::edit(Object *p_object) {
bool ColorRampEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("ColorRamp");
-
}
void ColorRampEditorPlugin::make_visible(bool p_visible) {
@@ -66,36 +64,34 @@ void ColorRampEditorPlugin::make_visible(bool p_visible) {
} else {
ramp_editor->hide();
}
-
}
void ColorRampEditorPlugin::_ramp_changed() {
- if(color_ramp_ref.is_valid())
- {
+ if (color_ramp_ref.is_valid()) {
- UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
//Not sure if I should convert this data to PoolVector
- Vector<float> new_offsets=ramp_editor->get_offsets();
- Vector<Color> new_colors=ramp_editor->get_colors();
- Vector<float> old_offsets=color_ramp_ref->get_offsets();
- Vector<Color> old_colors=color_ramp_ref->get_colors();
+ Vector<float> new_offsets = ramp_editor->get_offsets();
+ Vector<Color> new_colors = ramp_editor->get_colors();
+ Vector<float> old_offsets = color_ramp_ref->get_offsets();
+ Vector<Color> old_colors = color_ramp_ref->get_colors();
- if (old_offsets.size()!=new_offsets.size())
+ if (old_offsets.size() != new_offsets.size())
ur->create_action(TTR("Add/Remove Color Ramp Point"));
else
- ur->create_action(TTR("Modify Color Ramp"),UndoRedo::MERGE_ENDS);
- ur->add_do_method(this,"undo_redo_color_ramp",new_offsets,new_colors);
- ur->add_undo_method(this,"undo_redo_color_ramp",old_offsets,old_colors);
+ ur->create_action(TTR("Modify Color Ramp"), UndoRedo::MERGE_ENDS);
+ ur->add_do_method(this, "undo_redo_color_ramp", new_offsets, new_colors);
+ ur->add_undo_method(this, "undo_redo_color_ramp", old_offsets, old_colors);
ur->commit_action();
//color_ramp_ref->set_points(ramp_editor->get_points());
}
}
-void ColorRampEditorPlugin::_undo_redo_color_ramp(const Vector<float>& offsets,
- const Vector<Color>& colors) {
+void ColorRampEditorPlugin::_undo_redo_color_ramp(const Vector<float> &offsets,
+ const Vector<Color> &colors) {
color_ramp_ref->set_offsets(offsets);
color_ramp_ref->set_colors(colors);
@@ -103,10 +99,10 @@ void ColorRampEditorPlugin::_undo_redo_color_ramp(const Vector<float>& offsets,
ramp_editor->update();
}
-ColorRampEditorPlugin::~ColorRampEditorPlugin(){
+ColorRampEditorPlugin::~ColorRampEditorPlugin() {
}
void ColorRampEditorPlugin::_bind_methods() {
- ClassDB::bind_method(D_METHOD("ramp_changed"),&ColorRampEditorPlugin::_ramp_changed);
- ClassDB::bind_method(D_METHOD("undo_redo_color_ramp","offsets","colors"),&ColorRampEditorPlugin::_undo_redo_color_ramp);
+ ClassDB::bind_method(D_METHOD("ramp_changed"), &ColorRampEditorPlugin::_ramp_changed);
+ ClassDB::bind_method(D_METHOD("undo_redo_color_ramp", "offsets", "colors"), &ColorRampEditorPlugin::_undo_redo_color_ramp);
}
diff --git a/editor/plugins/color_ramp_editor_plugin.h b/editor/plugins/color_ramp_editor_plugin.h
index 0323bd7a46..45ac53c669 100644
--- a/editor/plugins/color_ramp_editor_plugin.h
+++ b/editor/plugins/color_ramp_editor_plugin.h
@@ -29,13 +29,13 @@
#ifndef TOOLS_EDITOR_PLUGINS_COLOR_RAMP_EDITOR_PLUGIN_H_
#define TOOLS_EDITOR_PLUGINS_COLOR_RAMP_EDITOR_PLUGIN_H_
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/gui/color_ramp_edit.h"
class ColorRampEditorPlugin : public EditorPlugin {
- GDCLASS( ColorRampEditorPlugin, EditorPlugin );
+ GDCLASS(ColorRampEditorPlugin, EditorPlugin);
bool _2d;
Ref<ColorRamp> color_ramp_ref;
@@ -45,7 +45,7 @@ class ColorRampEditorPlugin : public EditorPlugin {
protected:
static void _bind_methods();
void _ramp_changed();
- void _undo_redo_color_ramp(const Vector<float>& offsets, const Vector<Color>& colors);
+ void _undo_redo_color_ramp(const Vector<float> &offsets, const Vector<Color> &colors);
public:
virtual String get_name() const { return "ColorRamp"; }
@@ -56,7 +56,6 @@ public:
ColorRampEditorPlugin(EditorNode *p_node);
~ColorRampEditorPlugin();
-
};
#endif /* TOOLS_EDITOR_PLUGINS_COLOR_RAMP_EDITOR_PLUGIN_H_ */
diff --git a/editor/plugins/cube_grid_theme_editor_plugin.cpp b/editor/plugins/cube_grid_theme_editor_plugin.cpp
index b8abd2e9cc..e73a9b31af 100644
--- a/editor/plugins/cube_grid_theme_editor_plugin.cpp
+++ b/editor/plugins/cube_grid_theme_editor_plugin.cpp
@@ -29,14 +29,14 @@
#include "cube_grid_theme_editor_plugin.h"
#if 0
+#include "editor/editor_node.h"
+#include "editor/editor_settings.h"
+#include "main/main.h"
#include "scene/3d/mesh_instance.h"
+#include "scene/3d/navigation_mesh.h"
#include "scene/3d/physics_body.h"
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
-#include "editor/editor_node.h"
-#include "main/main.h"
-#include "editor/editor_settings.h"
-#include "scene/3d/navigation_mesh.h"
void MeshLibraryEditor::edit(const Ref<MeshLibrary>& p_theme) {
diff --git a/editor/plugins/cube_grid_theme_editor_plugin.h b/editor/plugins/cube_grid_theme_editor_plugin.h
index 07e7c7cadd..af3929e616 100644
--- a/editor/plugins/cube_grid_theme_editor_plugin.h
+++ b/editor/plugins/cube_grid_theme_editor_plugin.h
@@ -29,8 +29,8 @@
#ifndef CUBE_GRID_THEME_EDITOR_PLUGIN_H
#define CUBE_GRID_THEME_EDITOR_PLUGIN_H
-#include "scene/resources/mesh_library.h"
#include "editor/editor_node.h"
+#include "scene/resources/mesh_library.h"
#if 0
class MeshLibraryEditor : public Control {
@@ -91,6 +91,5 @@ public:
};
-
#endif // CUBE_GRID_THEME_EDITOR_PLUGIN_H
#endif
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 3f31f1e0f1..eaadf3976b 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -28,15 +28,15 @@
/*************************************************************************/
#include "editor_preview_plugins.h"
-#include "io/resource_loader.h"
#include "editor/editor_settings.h"
#include "io/file_access_memory.h"
+#include "io/resource_loader.h"
#include "os/os.h"
#include "scene/resources/material.h"
//#include "scene/resources/sample.h"
-#include "scene/resources/mesh.h"
-#include "scene/resources/bit_mask.h"
#include "editor/editor_scale.h"
+#include "scene/resources/bit_mask.h"
+#include "scene/resources/mesh.h"
#if 0
bool EditorTexturePreviewPlugin::handles(const String& p_type) const {
@@ -345,21 +345,23 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
Vector3(x0 * zr0, z0, y0 *zr0)
};
-#define ADD_POINT(m_idx) \
- normals.push_back(v[m_idx]);\
- vertices.push_back(v[m_idx]*radius);\
- { Vector2 uv(Math::atan2(v[m_idx].x,v[m_idx].z),Math::atan2(-v[m_idx].y,v[m_idx].z));\
- uv/=Math_PI;\
- uv*=4.0;\
- uv=uv*0.5+Vector2(0.5,0.5);\
- uvs.push_back(uv);\
- }\
- { Vector3 t = tt.xform(v[m_idx]);\
- tangents.push_back(t.x);\
- tangents.push_back(t.y);\
- tangents.push_back(t.z);\
- tangents.push_back(1.0);\
- }
+#define ADD_POINT(m_idx) \
+ normals.push_back(v[m_idx]); \
+ vertices.push_back(v[m_idx] * radius); \
+ { \
+ Vector2 uv(Math::atan2(v[m_idx].x, v[m_idx].z), Math::atan2(-v[m_idx].y, v[m_idx].z)); \
+ uv /= Math_PI; \
+ uv *= 4.0; \
+ uv = uv * 0.5 + Vector2(0.5, 0.5); \
+ uvs.push_back(uv); \
+ } \
+ { \
+ Vector3 t = tt.xform(v[m_idx]); \
+ tangents.push_back(t.x); \
+ tangents.push_back(t.y); \
+ tangents.push_back(t.z); \
+ tangents.push_back(1.0); \
+ }
diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp
index 925ac8ef11..0930c91e94 100644
--- a/editor/plugins/gi_probe_editor_plugin.cpp
+++ b/editor/plugins/gi_probe_editor_plugin.cpp
@@ -28,7 +28,6 @@
/*************************************************************************/
#include "gi_probe_editor_plugin.h"
-
void GIProbeEditorPlugin::_bake() {
if (gi_probe) {
@@ -36,14 +35,13 @@ void GIProbeEditorPlugin::_bake() {
}
}
-
void GIProbeEditorPlugin::edit(Object *p_object) {
- GIProbe * s = p_object->cast_to<GIProbe>();
+ GIProbe *s = p_object->cast_to<GIProbe>();
if (!s)
return;
- gi_probe=s;
+ gi_probe = s;
}
bool GIProbeEditorPlugin::handles(Object *p_object) const {
@@ -59,25 +57,23 @@ void GIProbeEditorPlugin::make_visible(bool p_visible) {
bake->hide();
}
-
}
void GIProbeEditorPlugin::_bind_methods() {
- ClassDB::bind_method("_bake",&GIProbeEditorPlugin::_bake);
+ ClassDB::bind_method("_bake", &GIProbeEditorPlugin::_bake);
}
GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- bake = memnew( Button );
- bake->set_icon(editor->get_gui_base()->get_icon("BakedLight","EditorIcons"));
+ editor = p_node;
+ bake = memnew(Button);
+ bake->set_icon(editor->get_gui_base()->get_icon("BakedLight", "EditorIcons"));
bake->hide();
- bake->connect("pressed",this,"_bake");
- add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU,bake);
- gi_probe=NULL;
+ bake->connect("pressed", this, "_bake");
+ add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake);
+ gi_probe = NULL;
}
-
GIProbeEditorPlugin::~GIProbeEditorPlugin() {
}
diff --git a/editor/plugins/gi_probe_editor_plugin.h b/editor/plugins/gi_probe_editor_plugin.h
index 982a549368..14d831a01a 100644
--- a/editor/plugins/gi_probe_editor_plugin.h
+++ b/editor/plugins/gi_probe_editor_plugin.h
@@ -29,16 +29,14 @@
#ifndef GIPROBEEDITORPLUGIN_H
#define GIPROBEEDITORPLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
-#include "scene/resources/material.h"
+#include "editor/editor_plugin.h"
#include "scene/3d/gi_probe.h"
-
-
+#include "scene/resources/material.h"
class GIProbeEditorPlugin : public EditorPlugin {
- GDCLASS( GIProbeEditorPlugin, EditorPlugin );
+ GDCLASS(GIProbeEditorPlugin, EditorPlugin);
GIProbe *gi_probe;
@@ -46,11 +44,11 @@ class GIProbeEditorPlugin : public EditorPlugin {
EditorNode *editor;
void _bake();
-protected:
+protected:
static void _bind_methods();
-public:
+public:
virtual String get_name() const { return "GIProbe"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -59,7 +57,6 @@ public:
GIProbeEditorPlugin(EditorNode *p_node);
~GIProbeEditorPlugin();
-
};
#endif // GIPROBEEDITORPLUGIN_H
diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp
index f31074a9dc..fabbf07a15 100644
--- a/editor/plugins/item_list_editor_plugin.cpp
+++ b/editor/plugins/item_list_editor_plugin.cpp
@@ -30,81 +30,81 @@
#include "io/resource_loader.h"
-bool ItemListPlugin::_set(const StringName& p_name, const Variant& p_value) {
+bool ItemListPlugin::_set(const StringName &p_name, const Variant &p_value) {
String name = p_name;
- int idx = name.get_slice("/",0).to_int();
- String what=name.get_slice("/",1);
-
- if (what=="text")
- set_item_text(idx,p_value);
- else if (what=="icon")
- set_item_icon(idx,p_value);
- else if (what=="checkable")
- set_item_checkable(idx,p_value);
- else if (what=="checked")
- set_item_checked(idx,p_value);
- else if (what=="id")
- set_item_id(idx,p_value);
- else if (what=="enabled")
- set_item_enabled(idx,p_value);
- else if (what=="separator")
- set_item_separator(idx,p_value);
+ int idx = name.get_slice("/", 0).to_int();
+ String what = name.get_slice("/", 1);
+
+ if (what == "text")
+ set_item_text(idx, p_value);
+ else if (what == "icon")
+ set_item_icon(idx, p_value);
+ else if (what == "checkable")
+ set_item_checkable(idx, p_value);
+ else if (what == "checked")
+ set_item_checked(idx, p_value);
+ else if (what == "id")
+ set_item_id(idx, p_value);
+ else if (what == "enabled")
+ set_item_enabled(idx, p_value);
+ else if (what == "separator")
+ set_item_separator(idx, p_value);
else
return false;
return true;
}
-bool ItemListPlugin::_get(const StringName& p_name,Variant &r_ret) const {
+bool ItemListPlugin::_get(const StringName &p_name, Variant &r_ret) const {
String name = p_name;
- int idx = name.get_slice("/",0).to_int();
- String what=name.get_slice("/",1);
-
- if (what=="text")
- r_ret=get_item_text(idx);
- else if (what=="icon")
- r_ret=get_item_icon(idx);
- else if (what=="checkable")
- r_ret=is_item_checkable(idx);
- else if (what=="checked")
- r_ret=is_item_checked(idx);
- else if (what=="id")
- r_ret=get_item_id(idx);
- else if (what=="enabled")
- r_ret=is_item_enabled(idx);
- else if (what=="separator")
- r_ret=is_item_separator(idx);
+ int idx = name.get_slice("/", 0).to_int();
+ String what = name.get_slice("/", 1);
+
+ if (what == "text")
+ r_ret = get_item_text(idx);
+ else if (what == "icon")
+ r_ret = get_item_icon(idx);
+ else if (what == "checkable")
+ r_ret = is_item_checkable(idx);
+ else if (what == "checked")
+ r_ret = is_item_checked(idx);
+ else if (what == "id")
+ r_ret = get_item_id(idx);
+ else if (what == "enabled")
+ r_ret = is_item_enabled(idx);
+ else if (what == "separator")
+ r_ret = is_item_separator(idx);
else
return false;
return true;
}
-void ItemListPlugin::_get_property_list( List<PropertyInfo> *p_list) const {
+void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const {
- for(int i=0;i<get_item_count();i++) {
+ for (int i = 0; i < get_item_count(); i++) {
- String base=itos(i)+"/";
+ String base = itos(i) + "/";
- p_list->push_back( PropertyInfo(Variant::STRING,base+"text") );
- p_list->push_back( PropertyInfo(Variant::OBJECT,base+"icon",PROPERTY_HINT_RESOURCE_TYPE,"Texture") );
+ p_list->push_back(PropertyInfo(Variant::STRING, base + "text"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, base + "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"));
int flags = get_flags();
- if (flags&FLAG_CHECKABLE) {
- p_list->push_back( PropertyInfo(Variant::BOOL,base+"checkable") );
- p_list->push_back( PropertyInfo(Variant::BOOL,base+"checked") );
+ if (flags & FLAG_CHECKABLE) {
+ p_list->push_back(PropertyInfo(Variant::BOOL, base + "checkable"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, base + "checked"));
}
- if (flags&FLAG_ID)
- p_list->push_back( PropertyInfo(Variant::INT,base+"id",PROPERTY_HINT_RANGE,"-1,4096") );
+ if (flags & FLAG_ID)
+ p_list->push_back(PropertyInfo(Variant::INT, base + "id", PROPERTY_HINT_RANGE, "-1,4096"));
- if (flags&FLAG_ENABLE)
- p_list->push_back( PropertyInfo(Variant::BOOL,base+"enabled") );
+ if (flags & FLAG_ENABLE)
+ p_list->push_back(PropertyInfo(Variant::BOOL, base + "enabled"));
- if (flags&FLAG_SEPARATOR)
- p_list->push_back( PropertyInfo(Variant::BOOL,base+"separator") );
+ if (flags & FLAG_SEPARATOR)
+ p_list->push_back(PropertyInfo(Variant::BOOL, base + "separator"));
}
}
@@ -124,12 +124,12 @@ bool ItemListOptionButtonPlugin::handles(Object *p_object) const {
int ItemListOptionButtonPlugin::get_flags() const {
- return FLAG_ICON|FLAG_ID|FLAG_ENABLE;
+ return FLAG_ICON | FLAG_ID | FLAG_ENABLE;
}
void ItemListOptionButtonPlugin::add_item() {
- ob->add_item( vformat(TTR("Item %d"),ob->get_item_count()));
+ ob->add_item(vformat(TTR("Item %d"), ob->get_item_count()));
_change_notify();
}
@@ -146,7 +146,7 @@ void ItemListOptionButtonPlugin::erase(int p_idx) {
ItemListOptionButtonPlugin::ItemListOptionButtonPlugin() {
- ob=NULL;
+ ob = NULL;
}
///////////////////////////////////////////////////////////////
@@ -166,12 +166,12 @@ bool ItemListPopupMenuPlugin::handles(Object *p_object) const {
int ItemListPopupMenuPlugin::get_flags() const {
- return FLAG_ICON|FLAG_CHECKABLE|FLAG_ID|FLAG_ENABLE|FLAG_SEPARATOR;
+ return FLAG_ICON | FLAG_CHECKABLE | FLAG_ID | FLAG_ENABLE | FLAG_SEPARATOR;
}
void ItemListPopupMenuPlugin::add_item() {
- pp->add_item( vformat(TTR("Item %d"),pp->get_item_count()));
+ pp->add_item(vformat(TTR("Item %d"), pp->get_item_count()));
_change_notify();
}
@@ -188,7 +188,7 @@ void ItemListPopupMenuPlugin::erase(int p_idx) {
ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() {
- pp=NULL;
+ pp = NULL;
}
///////////////////////////////////////////////////////////////
@@ -197,8 +197,8 @@ ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() {
void ItemListEditor::_node_removed(Node *p_node) {
- if(p_node==item_list) {
- item_list=NULL;
+ if (p_node == item_list) {
+ item_list = NULL;
hide();
dialog->hide();
}
@@ -206,16 +206,16 @@ void ItemListEditor::_node_removed(Node *p_node) {
void ItemListEditor::_notification(int p_notification) {
- if (p_notification==NOTIFICATION_ENTER_TREE) {
+ if (p_notification == NOTIFICATION_ENTER_TREE) {
- add_button->set_icon(get_icon("Add","EditorIcons"));
- del_button->set_icon(get_icon("Remove","EditorIcons"));
+ add_button->set_icon(get_icon("Add", "EditorIcons"));
+ del_button->set_icon(get_icon("Remove", "EditorIcons"));
}
}
void ItemListEditor::_add_pressed() {
- if (selected_idx==-1)
+ if (selected_idx == -1)
return;
item_plugins[selected_idx]->add_item();
@@ -228,12 +228,12 @@ void ItemListEditor::_delete_pressed() {
if (!ti)
return;
- if (ti->get_parent()!=tree->get_root())
+ if (ti->get_parent() != tree->get_root())
return;
int idx = ti->get_text(0).to_int();
- if (selected_idx==-1)
+ if (selected_idx == -1)
return;
item_plugins[selected_idx]->erase(idx);
@@ -246,15 +246,15 @@ void ItemListEditor::_edit_items() {
void ItemListEditor::edit(Node *p_item_list) {
- item_list=p_item_list;
+ item_list = p_item_list;
if (!item_list) {
- selected_idx=-1;
+ selected_idx = -1;
property_editor->edit(NULL);
return;
}
- for(int i=0;i<item_plugins.size();i++) {
+ for (int i = 0; i < item_plugins.size(); i++) {
if (item_plugins[i]->handles(p_item_list)) {
item_plugins[i]->set_object(p_item_list);
@@ -265,18 +265,18 @@ void ItemListEditor::edit(Node *p_item_list) {
else
toolbar_button->set_icon(Ref<Texture>());
- selected_idx=i;
+ selected_idx = i;
return;
}
}
- selected_idx=-1;
+ selected_idx = -1;
property_editor->edit(NULL);
}
bool ItemListEditor::handles(Object *p_object) const {
- for(int i=0;i<item_plugins.size();i++) {
+ for (int i = 0; i < item_plugins.size(); i++) {
if (item_plugins[i]->handles(p_object)) {
return true;
}
@@ -287,47 +287,47 @@ bool ItemListEditor::handles(Object *p_object) const {
void ItemListEditor::_bind_methods() {
- ClassDB::bind_method("_edit_items",&ItemListEditor::_edit_items);
- ClassDB::bind_method("_add_button",&ItemListEditor::_add_pressed);
- ClassDB::bind_method("_delete_button",&ItemListEditor::_delete_pressed);
+ ClassDB::bind_method("_edit_items", &ItemListEditor::_edit_items);
+ ClassDB::bind_method("_add_button", &ItemListEditor::_add_pressed);
+ ClassDB::bind_method("_delete_button", &ItemListEditor::_delete_pressed);
}
ItemListEditor::ItemListEditor() {
- selected_idx=-1;
+ selected_idx = -1;
- add_child( memnew( VSeparator ) );
+ add_child(memnew(VSeparator));
- toolbar_button = memnew( ToolButton );
+ toolbar_button = memnew(ToolButton);
toolbar_button->set_text(TTR("Items"));
add_child(toolbar_button);
- toolbar_button->connect("pressed",this,"_edit_items");
+ toolbar_button->connect("pressed", this, "_edit_items");
- dialog = memnew( AcceptDialog );
+ dialog = memnew(AcceptDialog);
dialog->set_title(TTR("Item List Editor"));
- add_child( dialog );
+ add_child(dialog);
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
dialog->add_child(vbc);
//dialog->set_child_rect(vbc);
- HBoxContainer *hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
hbc->set_h_size_flags(SIZE_EXPAND_FILL);
vbc->add_child(hbc);
- add_button = memnew( Button );
+ add_button = memnew(Button);
add_button->set_text(TTR("Add"));
hbc->add_child(add_button);
- add_button->connect("pressed",this,"_add_button");
+ add_button->connect("pressed", this, "_add_button");
hbc->add_spacer();
- del_button = memnew( Button );
+ del_button = memnew(Button);
del_button->set_text(TTR("Delete"));
hbc->add_child(del_button);
- del_button->connect("pressed",this,"_delete_button");
+ del_button->connect("pressed", this, "_delete_button");
- property_editor = memnew( PropertyEditor );
+ property_editor = memnew(PropertyEditor);
property_editor->hide_top_label();
property_editor->set_subsection_selectable(true);
vbc->add_child(property_editor);
@@ -338,8 +338,8 @@ ItemListEditor::ItemListEditor() {
ItemListEditor::~ItemListEditor() {
- for(int i=0;i<item_plugins.size();i++)
- memdelete( item_plugins[i] );
+ for (int i = 0; i < item_plugins.size(); i++)
+ memdelete(item_plugins[i]);
}
void ItemListEditorPlugin::edit(Object *p_object) {
@@ -365,17 +365,14 @@ void ItemListEditorPlugin::make_visible(bool p_visible) {
ItemListEditorPlugin::ItemListEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- item_list_editor = memnew( ItemListEditor );
+ editor = p_node;
+ item_list_editor = memnew(ItemListEditor);
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(item_list_editor);
item_list_editor->hide();
- item_list_editor->add_plugin( memnew( ItemListOptionButtonPlugin ) );
- item_list_editor->add_plugin( memnew( ItemListPopupMenuPlugin ) );
+ item_list_editor->add_plugin(memnew(ItemListOptionButtonPlugin));
+ item_list_editor->add_plugin(memnew(ItemListPopupMenuPlugin));
}
-ItemListEditorPlugin::~ItemListEditorPlugin()
-{
+ItemListEditorPlugin::~ItemListEditorPlugin() {
}
-
-
diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h
index 25d6ed6757..064c43bda5 100644
--- a/editor/plugins/item_list_editor_plugin.h
+++ b/editor/plugins/item_list_editor_plugin.h
@@ -29,69 +29,66 @@
#ifndef ITEM_LIST_EDITOR_PLUGIN_H
#define ITEM_LIST_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
-#include "editor/editor_node.h"
#include "canvas_item_editor_plugin.h"
+#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
-#include "scene/gui/option_button.h"
#include "scene/gui/menu_button.h"
+#include "scene/gui/option_button.h"
#include "scene/gui/popup_menu.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
class ItemListPlugin : public Object {
- GDCLASS(ItemListPlugin,Object);
+ GDCLASS(ItemListPlugin, Object);
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;
public:
-
enum Flags {
- FLAG_ICON=1,
- FLAG_CHECKABLE=2,
- FLAG_ID=4,
- FLAG_ENABLE=8,
- FLAG_SEPARATOR=16
+ FLAG_ICON = 1,
+ FLAG_CHECKABLE = 2,
+ FLAG_ID = 4,
+ FLAG_ENABLE = 8,
+ FLAG_SEPARATOR = 16
};
- virtual void set_object(Object *p_object)=0;
- virtual bool handles(Object *p_object) const=0;
+ virtual void set_object(Object *p_object) = 0;
+ virtual bool handles(Object *p_object) const = 0;
- virtual int get_flags() const=0;
+ virtual int get_flags() const = 0;
- virtual void set_item_text(int p_idx, const String& p_text) {}
- virtual String get_item_text(int p_idx) const{ return ""; };
+ virtual void set_item_text(int p_idx, const String &p_text) {}
+ virtual String get_item_text(int p_idx) const { return ""; };
- virtual void set_item_icon(int p_idx, const Ref<Texture>& p_tex) {}
- virtual Ref<Texture> get_item_icon(int p_idx) const{ return Ref<Texture>(); };
+ virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) {}
+ virtual Ref<Texture> get_item_icon(int p_idx) const { return Ref<Texture>(); };
virtual void set_item_checkable(int p_idx, bool p_check) {}
- virtual bool is_item_checkable(int p_idx) const{ return false; };
+ virtual bool is_item_checkable(int p_idx) const { return false; };
virtual void set_item_checked(int p_idx, bool p_checked) {}
- virtual bool is_item_checked(int p_idx) const{ return false; };
+ virtual bool is_item_checked(int p_idx) const { return false; };
virtual void set_item_enabled(int p_idx, int p_enabled) {}
- virtual bool is_item_enabled(int p_idx) const{ return false; };
+ virtual bool is_item_enabled(int p_idx) const { return false; };
virtual void set_item_id(int p_idx, int p_id) {}
- virtual int get_item_id(int p_idx) const{ return -1; };
+ virtual int get_item_id(int p_idx) const { return -1; };
virtual void set_item_separator(int p_idx, bool p_separator) {}
virtual bool is_item_separator(int p_idx) const { return false; };
- virtual void add_item()=0;
- virtual int get_item_count() const=0;
- virtual void erase(int p_idx)=0;
+ virtual void add_item() = 0;
+ virtual int get_item_count() const = 0;
+ virtual void erase(int p_idx) = 0;
ItemListPlugin() {}
};
@@ -100,25 +97,25 @@ public:
class ItemListOptionButtonPlugin : public ItemListPlugin {
- GDCLASS(ItemListOptionButtonPlugin,ItemListPlugin);
+ GDCLASS(ItemListOptionButtonPlugin, ItemListPlugin);
OptionButton *ob;
-public:
+public:
virtual void set_object(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual int get_flags() const;
- virtual void set_item_text(int p_idx, const String& p_text) { ob->set_item_text(p_idx,p_text); }
+ virtual void set_item_text(int p_idx, const String &p_text) { ob->set_item_text(p_idx, p_text); }
virtual String get_item_text(int p_idx) const { return ob->get_item_text(p_idx); }
- virtual void set_item_icon(int p_idx, const Ref<Texture>& p_tex) { ob->set_item_icon(p_idx, p_tex); }
+ virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { ob->set_item_icon(p_idx, p_tex); }
virtual Ref<Texture> get_item_icon(int p_idx) const { return ob->get_item_icon(p_idx); }
virtual void set_item_enabled(int p_idx, int p_enabled) { ob->set_item_disabled(p_idx, !p_enabled); }
virtual bool is_item_enabled(int p_idx) const { return !ob->is_item_disabled(p_idx); }
- virtual void set_item_id(int p_idx, int p_id) { ob->set_item_ID(p_idx,p_id); }
+ virtual void set_item_id(int p_idx, int p_id) { ob->set_item_ID(p_idx, p_id); }
virtual int get_item_id(int p_idx) const { return ob->get_item_ID(p_idx); }
virtual void add_item();
@@ -130,34 +127,34 @@ public:
class ItemListPopupMenuPlugin : public ItemListPlugin {
- GDCLASS(ItemListPopupMenuPlugin,ItemListPlugin);
+ GDCLASS(ItemListPopupMenuPlugin, ItemListPlugin);
PopupMenu *pp;
-public:
+public:
virtual void set_object(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual int get_flags() const;
- virtual void set_item_text(int p_idx, const String& p_text) { pp->set_item_text(p_idx,p_text); }
+ virtual void set_item_text(int p_idx, const String &p_text) { pp->set_item_text(p_idx, p_text); }
virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); }
- virtual void set_item_icon(int p_idx, const Ref<Texture>& p_tex) { pp->set_item_icon(p_idx,p_tex); }
+ virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { pp->set_item_icon(p_idx, p_tex); }
virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
- virtual void set_item_checkable(int p_idx, bool p_check) { pp->set_item_as_checkable(p_idx,p_check); }
+ virtual void set_item_checkable(int p_idx, bool p_check) { pp->set_item_as_checkable(p_idx, p_check); }
virtual bool is_item_checkable(int p_idx) const { return pp->is_item_checkable(p_idx); }
- virtual void set_item_checked(int p_idx, bool p_checked) { pp->set_item_checked(p_idx,p_checked); }
+ virtual void set_item_checked(int p_idx, bool p_checked) { pp->set_item_checked(p_idx, p_checked); }
virtual bool is_item_checked(int p_idx) const { return pp->is_item_checked(p_idx); }
- virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx,!p_enabled); }
+ virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx, !p_enabled); }
virtual bool is_item_enabled(int p_idx) const { return !pp->is_item_disabled(p_idx); }
- virtual void set_item_id(int p_idx, int p_id) { pp->set_item_ID(p_idx,p_idx); }
+ virtual void set_item_id(int p_idx, int p_id) { pp->set_item_ID(p_idx, p_idx); }
virtual int get_item_id(int p_idx) const { return pp->get_item_ID(p_idx); }
- virtual void set_item_separator(int p_idx, bool p_separator) { pp->set_item_as_separator(p_idx,p_separator); }
+ virtual void set_item_separator(int p_idx, bool p_separator) { pp->set_item_as_separator(p_idx, p_separator); }
virtual bool is_item_separator(int p_idx) const { return pp->is_item_separator(p_idx); }
virtual void add_item();
@@ -171,7 +168,7 @@ public:
class ItemListEditor : public HBoxContainer {
- GDCLASS(ItemListEditor,HBoxContainer);
+ GDCLASS(ItemListEditor, HBoxContainer);
Node *item_list;
@@ -185,7 +182,7 @@ class ItemListEditor : public HBoxContainer {
int selected_idx;
- Vector<ItemListPlugin*> item_plugins;
+ Vector<ItemListPlugin *> item_plugins;
void _edit_items();
@@ -195,27 +192,25 @@ class ItemListEditor : public HBoxContainer {
void _node_removed(Node *p_node);
protected:
-
void _notification(int p_notification);
static void _bind_methods();
-public:
+public:
void edit(Node *p_item_list);
bool handles(Object *p_object) const;
- void add_plugin(ItemListPlugin* p_plugin) { item_plugins.push_back(p_plugin); }
+ void add_plugin(ItemListPlugin *p_plugin) { item_plugins.push_back(p_plugin); }
ItemListEditor();
~ItemListEditor();
};
class ItemListEditorPlugin : public EditorPlugin {
- GDCLASS(ItemListEditorPlugin,EditorPlugin);
+ GDCLASS(ItemListEditorPlugin, EditorPlugin);
ItemListEditor *item_list_editor;
EditorNode *editor;
public:
-
virtual String get_name() const { return "ItemList"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -224,7 +219,6 @@ public:
ItemListEditorPlugin(EditorNode *p_node);
~ItemListEditorPlugin();
-
};
#endif // ITEM_LIST_EDITOR_PLUGIN_H
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp
index be9e52e241..6db25e8455 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -29,208 +29,193 @@
#include "light_occluder_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
-#include "os/file_access.h"
#include "editor/editor_settings.h"
+#include "os/file_access.h"
void LightOccluder2DEditor::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
- button_create->set_icon( get_icon("Edit","EditorIcons"));
- button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
+ button_create->set_icon(get_icon("Edit", "EditorIcons"));
+ button_edit->set_icon(get_icon("MovePoint", "EditorIcons"));
button_edit->set_pressed(true);
- get_tree()->connect("node_removed",this,"_node_removed");
- create_poly->connect("confirmed",this,"_create_poly");
+ get_tree()->connect("node_removed", this, "_node_removed");
+ create_poly->connect("confirmed", this, "_create_poly");
} break;
case NOTIFICATION_FIXED_PROCESS: {
-
} break;
}
-
}
void LightOccluder2DEditor::_node_removed(Node *p_node) {
- if(p_node==node) {
- node=NULL;
+ if (p_node == node) {
+ node = NULL;
hide();
canvas_item_editor->get_viewport_control()->update();
}
-
}
-
void LightOccluder2DEditor::_menu_option(int p_option) {
- switch(p_option) {
+ switch (p_option) {
case MODE_CREATE: {
- mode=MODE_CREATE;
+ mode = MODE_CREATE;
button_create->set_pressed(true);
button_edit->set_pressed(false);
} break;
case MODE_EDIT: {
- mode=MODE_EDIT;
+ mode = MODE_EDIT;
button_create->set_pressed(false);
button_edit->set_pressed(true);
} break;
-
}
}
void LightOccluder2DEditor::_wip_close(bool p_closed) {
undo_redo->create_action(TTR("Create Poly"));
- undo_redo->add_undo_method(node->get_occluder_polygon().ptr(),"set_polygon",node->get_occluder_polygon()->get_polygon());
- undo_redo->add_do_method(node->get_occluder_polygon().ptr(),"set_polygon",wip);
- undo_redo->add_undo_method(node->get_occluder_polygon().ptr(),"set_closed",node->get_occluder_polygon()->is_closed());
- undo_redo->add_do_method(node->get_occluder_polygon().ptr(),"set_closed",p_closed);
+ undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", node->get_occluder_polygon()->get_polygon());
+ undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", wip);
+ undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_closed", node->get_occluder_polygon()->is_closed());
+ undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_closed", p_closed);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
wip.clear();
- wip_active=false;
- mode=MODE_EDIT;
+ wip_active = false;
+ mode = MODE_EDIT;
button_edit->set_pressed(true);
button_create->set_pressed(false);
- edited_point=-1;
+ edited_point = -1;
}
-bool LightOccluder2DEditor::forward_gui_input(const InputEvent& p_event) {
-
+bool LightOccluder2DEditor::forward_gui_input(const InputEvent &p_event) {
if (!node)
return false;
if (node->get_occluder_polygon().is_null()) {
- 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) {
create_poly->set_text("No OccluderPolygon2D resource on this node.\nCreate and assign one?");
create_poly->popup_centered_minsize();
}
- return (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1);
+ return (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == 1);
}
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_event.mouse_button;
+ const InputEventMouseButton &mb = p_event.mouse_button;
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
-
- Vector2 gpoint = Point2(mb.x,mb.y);
+ Vector2 gpoint = Point2(mb.x, mb.y);
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
- cpoint=canvas_item_editor->snap_point(cpoint);
+ cpoint = canvas_item_editor->snap_point(cpoint);
cpoint = node->get_global_transform().affine_inverse().xform(cpoint);
Vector<Vector2> poly = Variant(node->get_occluder_polygon()->get_polygon());
//first check if a point is to be added (segment split)
- real_t grab_treshold=EDITOR_DEF("editors/poly_editor/point_grab_radius",8);
-
- switch(mode) {
+ real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
+ switch (mode) {
case MODE_CREATE: {
- if (mb.button_index==BUTTON_LEFT && mb.pressed) {
-
+ if (mb.button_index == BUTTON_LEFT && mb.pressed) {
if (!wip_active) {
wip.clear();
- wip.push_back( cpoint );
- wip_active=true;
- edited_point_pos=cpoint;
+ wip.push_back(cpoint);
+ wip_active = true;
+ edited_point_pos = cpoint;
canvas_item_editor->get_viewport_control()->update();
- edited_point=1;
+ edited_point = 1;
return true;
} else {
-
- if (wip.size()>1 && xform.xform(wip[0]).distance_to(gpoint)<grab_treshold) {
+ if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_treshold) {
//wip closed
_wip_close(true);
return true;
- } else if (wip.size()>1 && xform.xform(wip[wip.size()-1]).distance_to(gpoint)<grab_treshold) {
- //wip closed
- _wip_close(false);
- return true;
+ } else if (wip.size() > 1 && xform.xform(wip[wip.size() - 1]).distance_to(gpoint) < grab_treshold) {
+ //wip closed
+ _wip_close(false);
+ return true;
} else {
- wip.push_back( cpoint );
- edited_point=wip.size();
+ wip.push_back(cpoint);
+ edited_point = wip.size();
canvas_item_editor->get_viewport_control()->update();
return true;
//add wip point
}
}
- } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && wip_active) {
+ } else if (mb.button_index == BUTTON_RIGHT && mb.pressed && wip_active) {
_wip_close(true);
}
-
-
} break;
case MODE_EDIT: {
- if (mb.button_index==BUTTON_LEFT) {
+ if (mb.button_index == BUTTON_LEFT) {
if (mb.pressed) {
if (mb.mod.control) {
-
if (poly.size() < 3) {
undo_redo->create_action(TTR("Edit Poly"));
- undo_redo->add_undo_method(node->get_occluder_polygon().ptr(),"set_polygon",poly);
+ undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", poly);
poly.push_back(cpoint);
- undo_redo->add_do_method(node->get_occluder_polygon().ptr(),"set_polygon",poly);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
return true;
}
//search edges
- int closest_idx=-1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 points[2] ={ xform.xform(poly[i]),
- xform.xform(poly[(i+1)%poly.size()]) };
+ Vector2 points[2] = { xform.xform(poly[i]),
+ xform.xform(poly[(i + 1) % poly.size()]) };
- Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint,points);
- if (cp.distance_squared_to(points[0])<CMP_EPSILON2 || cp.distance_squared_to(points[1])<CMP_EPSILON2)
+ Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint, points);
+ if (cp.distance_squared_to(points[0]) < CMP_EPSILON2 || cp.distance_squared_to(points[1]) < CMP_EPSILON2)
continue; //not valid to reuse point
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
}
-
-
}
- if (closest_idx>=0) {
+ if (closest_idx >= 0) {
- pre_move_edit=poly;
- poly.insert(closest_idx+1,xform.affine_inverse().xform(closest_pos));
- edited_point=closest_idx+1;
- edited_point_pos=xform.affine_inverse().xform(closest_pos);
+ pre_move_edit = poly;
+ poly.insert(closest_idx + 1, xform.affine_inverse().xform(closest_pos));
+ edited_point = closest_idx + 1;
+ edited_point_pos = xform.affine_inverse().xform(closest_pos);
node->get_occluder_polygon()->set_polygon(Variant(poly));
canvas_item_editor->get_viewport_control()->update();
return true;
@@ -239,106 +224,95 @@ bool LightOccluder2DEditor::forward_gui_input(const InputEvent& p_event) {
//look for points to move
- int closest_idx=-1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 cp =xform.xform(poly[i]);
+ Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
}
-
}
- if (closest_idx>=0) {
+ if (closest_idx >= 0) {
- pre_move_edit=poly;
- edited_point=closest_idx;
- edited_point_pos=xform.affine_inverse().xform(closest_pos);
+ pre_move_edit = poly;
+ edited_point = closest_idx;
+ edited_point_pos = xform.affine_inverse().xform(closest_pos);
canvas_item_editor->get_viewport_control()->update();
return true;
}
}
} else {
- if (edited_point!=-1) {
+ if (edited_point != -1) {
//apply
- ERR_FAIL_INDEX_V(edited_point,poly.size(),false);
- poly[edited_point]=edited_point_pos;
+ ERR_FAIL_INDEX_V(edited_point, poly.size(), false);
+ poly[edited_point] = edited_point_pos;
undo_redo->create_action(TTR("Edit Poly"));
- undo_redo->add_do_method(node->get_occluder_polygon().ptr(),"set_polygon",poly);
- undo_redo->add_undo_method(node->get_occluder_polygon().ptr(),"set_polygon",pre_move_edit);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly);
+ undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", pre_move_edit);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
- edited_point=-1;
+ edited_point = -1;
return true;
}
}
- } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
+ } else if (mb.button_index == BUTTON_RIGHT && mb.pressed && edited_point == -1) {
-
-
- int closest_idx=-1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 cp =xform.xform(poly[i]);
+ Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
}
-
}
- if (closest_idx>=0) {
-
+ if (closest_idx >= 0) {
undo_redo->create_action(TTR("Edit Poly (Remove Point)"));
- undo_redo->add_undo_method(node->get_occluder_polygon().ptr(),"set_polygon",poly);
+ undo_redo->add_undo_method(node->get_occluder_polygon().ptr(), "set_polygon", poly);
poly.remove(closest_idx);
- undo_redo->add_do_method(node->get_occluder_polygon().ptr(),"set_polygon",poly);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node->get_occluder_polygon().ptr(), "set_polygon", poly);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
return true;
}
-
}
-
-
} break;
}
-
-
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_event.mouse_motion;
+ const InputEventMouseMotion &mm = p_event.mouse_motion;
- if (edited_point!=-1 && (wip_active || mm.button_mask&BUTTON_MASK_LEFT)) {
+ if (edited_point != -1 && (wip_active || mm.button_mask & BUTTON_MASK_LEFT)) {
- Vector2 gpoint = Point2(mm.x,mm.y);
+ Vector2 gpoint = Point2(mm.x, mm.y);
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
- cpoint=canvas_item_editor->snap_point(cpoint);
+ cpoint = canvas_item_editor->snap_point(cpoint);
edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint);
canvas_item_editor->get_viewport_control()->update();
-
}
} break;
@@ -356,111 +330,102 @@ void LightOccluder2DEditor::_canvas_draw() {
Vector<Vector2> poly;
if (wip_active)
- poly=wip;
+ poly = wip;
else
- poly=Variant(node->get_occluder_polygon()->get_polygon());
-
+ poly = Variant(node->get_occluder_polygon()->get_polygon());
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- Ref<Texture> handle= get_icon("EditorHandle","EditorIcons");
-
- for(int i=0;i<poly.size();i++) {
+ Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons");
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 p,p2;
- p = i==edited_point ? edited_point_pos : poly[i];
- if ((wip_active && i==poly.size()-1) || (((i+1)%poly.size())==edited_point))
- p2=edited_point_pos;
+ Vector2 p, p2;
+ p = i == edited_point ? edited_point_pos : poly[i];
+ if ((wip_active && i == poly.size() - 1) || (((i + 1) % poly.size()) == edited_point))
+ p2 = edited_point_pos;
else
- p2 = poly[(i+1)%poly.size()];
+ p2 = poly[(i + 1) % poly.size()];
Vector2 point = xform.xform(p);
Vector2 next_point = xform.xform(p2);
- Color col=Color(1,0.3,0.1,0.8);
+ Color col = Color(1, 0.3, 0.1, 0.8);
- if (i==poly.size()-1 && (!node->get_occluder_polygon()->is_closed() || wip_active)) {
+ if (i == poly.size() - 1 && (!node->get_occluder_polygon()->is_closed() || wip_active)) {
} else {
- vpc->draw_line(point,next_point,col,2);
+ vpc->draw_line(point, next_point, col, 2);
}
- vpc->draw_texture(handle,point-handle->get_size()*0.5);
+ vpc->draw_texture(handle, point - handle->get_size() * 0.5);
}
}
-
-
void LightOccluder2DEditor::edit(Node *p_collision_polygon) {
if (!canvas_item_editor) {
- canvas_item_editor=CanvasItemEditor::get_singleton();
+ canvas_item_editor = CanvasItemEditor::get_singleton();
}
if (p_collision_polygon) {
- node=p_collision_polygon->cast_to<LightOccluder2D>();
- if (!canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->connect("draw",this,"_canvas_draw");
+ node = p_collision_polygon->cast_to<LightOccluder2D>();
+ if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
wip.clear();
- wip_active=false;
- edited_point=-1;
+ wip_active = false;
+ edited_point = -1;
canvas_item_editor->get_viewport_control()->update();
} else {
- node=NULL;
-
- if (canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->disconnect("draw",this,"_canvas_draw");
+ node = NULL;
+ if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw");
}
-
}
-void LightOccluder2DEditor::_create_poly() {
+void LightOccluder2DEditor::_create_poly() {
if (!node)
return;
undo_redo->create_action(TTR("Create Occluder Polygon"));
- undo_redo->add_do_method(node,"set_occluder_polygon",Ref<OccluderPolygon2D>(memnew( OccluderPolygon2D)));
- undo_redo->add_undo_method(node,"set_occluder_polygon",Variant(REF()));
+ undo_redo->add_do_method(node, "set_occluder_polygon", Ref<OccluderPolygon2D>(memnew(OccluderPolygon2D)));
+ undo_redo->add_undo_method(node, "set_occluder_polygon", Variant(REF()));
undo_redo->commit_action();
}
void LightOccluder2DEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_menu_option"),&LightOccluder2DEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_canvas_draw"),&LightOccluder2DEditor::_canvas_draw);
- ClassDB::bind_method(D_METHOD("_node_removed"),&LightOccluder2DEditor::_node_removed);
- ClassDB::bind_method(D_METHOD("_create_poly"),&LightOccluder2DEditor::_create_poly);
-
+ ClassDB::bind_method(D_METHOD("_menu_option"), &LightOccluder2DEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"), &LightOccluder2DEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_node_removed"), &LightOccluder2DEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_create_poly"), &LightOccluder2DEditor::_create_poly);
}
-
LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) {
- node=NULL;
- canvas_item_editor=NULL;
- editor=p_editor;
+ node = NULL;
+ canvas_item_editor = NULL;
+ editor = p_editor;
undo_redo = editor->get_undo_redo();
- add_child( memnew( VSeparator ));
- button_create = memnew( ToolButton );
+ add_child(memnew(VSeparator));
+ button_create = memnew(ToolButton);
add_child(button_create);
- button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE));
+ button_create->connect("pressed", this, "_menu_option", varray(MODE_CREATE));
button_create->set_toggle_mode(true);
button_create->set_tooltip(TTR("Create a new polygon from scratch."));
- button_edit = memnew( ToolButton );
+ button_edit = memnew(ToolButton);
add_child(button_edit);
- button_edit->connect("pressed",this,"_menu_option",varray(MODE_EDIT));
+ button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT));
button_edit->set_toggle_mode(true);
- button_edit->set_tooltip(TTR("Edit existing polygon:")+"\n"+TTR("LMB: Move Point.")+"\n"+TTR("Ctrl+LMB: Split Segment.")+"\n"+TTR("RMB: Erase Point."));
+ button_edit->set_tooltip(TTR("Edit existing polygon:") + "\n" + TTR("LMB: Move Point.") + "\n" + TTR("Ctrl+LMB: Split Segment.") + "\n" + TTR("RMB: Erase Point."));
- create_poly = memnew( ConfirmationDialog );
+ create_poly = memnew(ConfirmationDialog);
add_child(create_poly);
create_poly->get_ok()->set_text(TTR("Create"));
-
- //add_constant_override("separation",0);
+//add_constant_override("separation",0);
#if 0
options = memnew( MenuButton );
@@ -472,11 +437,9 @@ LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) {
#endif
mode = MODE_EDIT;
- wip_active=false;
-
+ wip_active = false;
}
-
void LightOccluder2DEditorPlugin::edit(Object *p_object) {
collision_polygon_editor->edit(p_object->cast_to<Node>());
@@ -496,23 +459,16 @@ void LightOccluder2DEditorPlugin::make_visible(bool p_visible) {
collision_polygon_editor->hide();
collision_polygon_editor->edit(NULL);
}
-
}
LightOccluder2DEditorPlugin::LightOccluder2DEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- collision_polygon_editor = memnew( LightOccluder2DEditor(p_node) );
+ editor = p_node;
+ collision_polygon_editor = memnew(LightOccluder2DEditor(p_node));
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
collision_polygon_editor->hide();
-
-
-
}
-
-LightOccluder2DEditorPlugin::~LightOccluder2DEditorPlugin()
-{
+LightOccluder2DEditorPlugin::~LightOccluder2DEditorPlugin() {
}
-
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.h b/editor/plugins/light_occluder_2d_editor_plugin.h
index 1f1c6e86eb..68e5e3f729 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.h
+++ b/editor/plugins/light_occluder_2d_editor_plugin.h
@@ -29,13 +29,11 @@
#ifndef LIGHT_OCCLUDER_2D_EDITOR_PLUGIN_H
#define LIGHT_OCCLUDER_2D_EDITOR_PLUGIN_H
-
-
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/2d/light_occluder_2d.h"
-#include "scene/gui/tool_button.h"
#include "scene/gui/button_group.h"
+#include "scene/gui/tool_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -44,7 +42,7 @@ class CanvasItemEditor;
class LightOccluder2DEditor : public HBoxContainer {
- GDCLASS(LightOccluder2DEditor, HBoxContainer );
+ GDCLASS(LightOccluder2DEditor, HBoxContainer);
UndoRedo *undo_redo;
enum Mode {
@@ -82,24 +80,23 @@ protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
-public:
- Vector2 snap_point(const Vector2& p_point) const;
- bool forward_gui_input(const InputEvent& p_event);
+public:
+ Vector2 snap_point(const Vector2 &p_point) const;
+ bool forward_gui_input(const InputEvent &p_event);
void edit(Node *p_collision_polygon);
LightOccluder2DEditor(EditorNode *p_editor);
};
class LightOccluder2DEditorPlugin : public EditorPlugin {
- GDCLASS( LightOccluder2DEditorPlugin, EditorPlugin );
+ GDCLASS(LightOccluder2DEditorPlugin, EditorPlugin);
LightOccluder2DEditor *collision_polygon_editor;
EditorNode *editor;
public:
-
- virtual bool forward_canvas_gui_input(const Transform2D& p_canvas_xform,const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
+ virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
virtual String get_name() const { return "LightOccluder2D"; }
bool has_main_screen() const { return false; }
@@ -109,7 +106,6 @@ public:
LightOccluder2DEditorPlugin(EditorNode *p_node);
~LightOccluder2DEditorPlugin();
-
};
#endif // LIGHT_OCCLUDER_2D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp
index 4a0f90a2b4..b3afe0bb93 100644
--- a/editor/plugins/line_2d_editor_plugin.cpp
+++ b/editor/plugins/line_2d_editor_plugin.cpp
@@ -29,37 +29,33 @@
#include "line_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
-#include "os/file_access.h"
#include "editor/editor_settings.h"
+#include "os/file_access.h"
#include "os/keyboard.h"
-
//----------------------------------------------------------------------------
// Line2DEditor
//----------------------------------------------------------------------------
void Line2DEditor::_node_removed(Node *p_node) {
- if(p_node == node) {
- node=NULL;
+ if (p_node == node) {
+ node = NULL;
hide();
}
}
void Line2DEditor::_notification(int p_what) {
- switch(p_what) {
- case NOTIFICATION_VISIBILITY_CHANGED:
- // This widget is not a child but should have the same visibility state
- base_hb->set_visible(is_visible());
- break;
+ switch (p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED:
+ // This widget is not a child but should have the same visibility state
+ base_hb->set_visible(is_visible());
+ break;
}
}
Vector2 Line2DEditor::mouse_to_local_pos(Vector2 gpoint, bool alt) {
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- return !alt? canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint))
- : node->get_global_transform().affine_inverse().xform(
- canvas_item_editor->snap_point(
- canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)) );
+ return !alt ? canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint)) : node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)));
}
int Line2DEditor::get_point_index_at(Vector2 gpos) {
@@ -68,9 +64,9 @@ int Line2DEditor::get_point_index_at(Vector2 gpos) {
real_t grab_treshold = EDITOR_DEF("poly_editor/point_grab_radius", 8);
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- for(int i = 0; i < node->get_point_count(); ++i) {
- Point2 p = xform.xform( node->get_point_pos(i) );
- if(gpos.distance_to(p) < grab_treshold) {
+ for (int i = 0; i < node->get_point_count(); ++i) {
+ Point2 p = xform.xform(node->get_point_pos(i));
+ if (gpos.distance_to(p) < grab_treshold) {
return i;
}
}
@@ -78,7 +74,7 @@ int Line2DEditor::get_point_index_at(Vector2 gpos) {
return -1;
}
-bool Line2DEditor::forward_gui_input(const InputEvent& p_event) {
+bool Line2DEditor::forward_gui_input(const InputEvent &p_event) {
if (!node)
return false;
@@ -86,25 +82,24 @@ bool Line2DEditor::forward_gui_input(const InputEvent& p_event) {
if (!node->is_visible())
return false;
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
const InputEventMouseButton &mb = p_event.mouse_button;
- Vector2 gpoint = Point2(mb.x,mb.y);
+ Vector2 gpoint = Point2(mb.x, mb.y);
Vector2 cpoint = mouse_to_local_pos(gpoint, mb.mod.alt);
- if(mb.pressed && _dragging == false) {
+ if (mb.pressed && _dragging == false) {
int i = get_point_index_at(gpoint);
- if(i != -1) {
+ if (i != -1) {
if (mb.button_index == BUTTON_LEFT && !mb.mod.shift && mode == MODE_EDIT) {
_dragging = true;
action_point = i;
moving_from = node->get_point_pos(i);
moving_screen_from = gpoint;
- }
- else if((mb.button_index == BUTTON_RIGHT && mode == MODE_EDIT) || (mb.button_index == BUTTON_LEFT && mode == MODE_DELETE)) {
+ } else if ((mb.button_index == BUTTON_RIGHT && mode == MODE_EDIT) || (mb.button_index == BUTTON_LEFT && mode == MODE_DELETE)) {
undo_redo->create_action(TTR("Remove Point from Line2D"));
undo_redo->add_do_method(node, "remove_point", i);
undo_redo->add_undo_method(node, "add_point", node->get_point_pos(i), i);
@@ -116,7 +111,7 @@ bool Line2DEditor::forward_gui_input(const InputEvent& p_event) {
}
}
- if(mb.pressed && mb.button_index == BUTTON_LEFT && ((mb.mod.command && mode == MODE_EDIT) || mode == MODE_CREATE)) {
+ if (mb.pressed && mb.button_index == BUTTON_LEFT && ((mb.mod.command && mode == MODE_EDIT) || mode == MODE_CREATE)) {
undo_redo->create_action(TTR("Add Point to Line2D"));
undo_redo->add_do_method(node, "add_point", cpoint);
@@ -126,7 +121,7 @@ bool Line2DEditor::forward_gui_input(const InputEvent& p_event) {
undo_redo->commit_action();
_dragging = true;
- action_point = node->get_point_count()-1;
+ action_point = node->get_point_count() - 1;
moving_from = node->get_point_pos(action_point);
moving_screen_from = gpoint;
@@ -135,7 +130,7 @@ bool Line2DEditor::forward_gui_input(const InputEvent& p_event) {
return true;
}
- if(!mb.pressed && mb.button_index == BUTTON_LEFT && _dragging) {
+ if (!mb.pressed && mb.button_index == BUTTON_LEFT && _dragging) {
undo_redo->create_action(TTR("Move Point in Line2D"));
undo_redo->add_do_method(node, "set_point_pos", action_point, cpoint);
undo_redo->add_undo_method(node, "set_point_pos", action_point, moving_from);
@@ -145,19 +140,17 @@ bool Line2DEditor::forward_gui_input(const InputEvent& p_event) {
_dragging = false;
return true;
}
- }
- break;
+ } break;
case InputEvent::MOUSE_MOTION: {
if (_dragging) {
const InputEventMouseMotion &mm = p_event.mouse_motion;
Vector2 cpoint = mouse_to_local_pos(Vector2(mm.x, mm.y), mm.mod.alt);
- node->set_point_pos(action_point,cpoint);
+ node->set_point_pos(action_point, cpoint);
canvas_item_editor->get_viewport_control()->update();
return true;
}
- }
- break;
+ } break;
}
return false;
@@ -178,7 +171,7 @@ void Line2DEditor::_canvas_draw() {
int len = node->get_point_count();
Control *vpc = canvas_item_editor->get_viewport_control();
- for(int i=0; i < len; ++i) {
+ for (int i = 0; i < len; ++i) {
Vector2 point = xform.xform(node->get_point_pos(i));
vpc->draw_texture_rect(handle, Rect2(point - handle_size * 0.5, handle_size), false);
}
@@ -201,8 +194,7 @@ void Line2DEditor::edit(Node *p_line2d) {
canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
if (!node->is_connected("visibility_changed", this, "_node_visibility_changed"))
node->connect("visibility_changed", this, "_node_visibility_changed");
- }
- else {
+ } else {
if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw");
// node may have been deleted at this point
@@ -219,7 +211,7 @@ void Line2DEditor::_bind_methods() {
}
void Line2DEditor::_mode_selected(int p_mode) {
- for(unsigned int i = 0; i < _MODE_COUNT; ++i) {
+ for (unsigned int i = 0; i < _MODE_COUNT; ++i) {
toolbar_buttons[i]->set_pressed(i == p_mode);
}
mode = Mode(p_mode);
@@ -233,41 +225,37 @@ Line2DEditor::Line2DEditor(EditorNode *p_editor) {
_dragging = false;
- base_hb = memnew( HBoxContainer );
+ base_hb = memnew(HBoxContainer);
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(base_hb);
- sep = memnew( VSeparator);
+ sep = memnew(VSeparator);
base_hb->add_child(sep);
{
- ToolButton * b = memnew(ToolButton);
+ ToolButton *b = memnew(ToolButton);
b->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons"));
b->set_toggle_mode(true);
b->set_focus_mode(Control::FOCUS_NONE);
b->set_tooltip(
- TTR("Select Points")+"\n"
- + TTR("Shift+Drag: Select Control Points")+"\n"
- + keycode_get_string(KEY_MASK_CMD)
- + TTR("Click: Add Point")+"\n"
- + TTR("Right Click: Delete Point"));
+ TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Right Click: Delete Point"));
b->connect("pressed", this, "_mode_selected", varray(MODE_EDIT));
toolbar_buttons[MODE_EDIT] = b;
base_hb->add_child(b);
}
{
- ToolButton * b = memnew(ToolButton);
+ ToolButton *b = memnew(ToolButton);
b->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons"));
b->set_toggle_mode(true);
b->set_focus_mode(Control::FOCUS_NONE);
- b->set_tooltip(TTR("Add Point (in empty space)")+"\n"+TTR("Split Segment (in line)"));
+ b->set_tooltip(TTR("Add Point (in empty space)") + "\n" + TTR("Split Segment (in line)"));
b->connect("pressed", this, "_mode_selected", varray(MODE_CREATE));
toolbar_buttons[MODE_CREATE] = b;
base_hb->add_child(b);
}
{
- ToolButton * b = memnew( ToolButton );
+ ToolButton *b = memnew(ToolButton);
b->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons"));
b->set_toggle_mode(true);
b->set_focus_mode(Control::FOCUS_NONE);
@@ -297,15 +285,13 @@ bool Line2DEditorPlugin::handles(Object *p_object) const {
void Line2DEditorPlugin::make_visible(bool p_visible) {
line2d_editor->set_visible(p_visible);
- if(p_visible == false)
+ if (p_visible == false)
line2d_editor->edit(NULL);
}
Line2DEditorPlugin::Line2DEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- line2d_editor = memnew( Line2DEditor(p_node) );
+ editor = p_node;
+ line2d_editor = memnew(Line2DEditor(p_node));
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(line2d_editor);
line2d_editor->hide();
}
-
-
diff --git a/editor/plugins/line_2d_editor_plugin.h b/editor/plugins/line_2d_editor_plugin.h
index 6e0da7df38..6bade92da4 100644
--- a/editor/plugins/line_2d_editor_plugin.h
+++ b/editor/plugins/line_2d_editor_plugin.h
@@ -29,13 +29,12 @@
#ifndef LINE_2D_EDITOR_PLUGIN_H
#define LINE_2D_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
+#include "scene/2d/line_2d.h"
#include "scene/2d/path_2d.h"
-#include "scene/gui/tool_button.h"
#include "scene/gui/button_group.h"
-#include "scene/2d/line_2d.h"
-
+#include "scene/gui/tool_button.h"
class CanvasItemEditor;
@@ -43,7 +42,7 @@ class Line2DEditor : public HBoxContainer {
GDCLASS(Line2DEditor, HBoxContainer)
public:
- bool forward_gui_input(const InputEvent& p_event);
+ bool forward_gui_input(const InputEvent &p_event);
void edit(Node *p_line2d);
Line2DEditor(EditorNode *p_editor);
@@ -81,7 +80,7 @@ private:
};
Mode mode;
- ToolButton* toolbar_buttons[_MODE_COUNT];
+ ToolButton *toolbar_buttons[_MODE_COUNT];
bool _dragging;
int action_point;
@@ -90,13 +89,12 @@ private:
};
class Line2DEditorPlugin : public EditorPlugin {
- GDCLASS( Line2DEditorPlugin, EditorPlugin )
+ GDCLASS(Line2DEditorPlugin, EditorPlugin)
public:
virtual bool forward_canvas_gui_input(
- const Transform2D& p_canvas_xform,
- const InputEvent& p_event)
- {
+ const Transform2D &p_canvas_xform,
+ const InputEvent &p_event) {
return line2d_editor->forward_gui_input(p_event);
}
@@ -111,8 +109,6 @@ public:
private:
Line2DEditor *line2d_editor;
EditorNode *editor;
-
};
#endif // LINE_2D_EDITOR_PLUGIN_H
-
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index cdf7c70d39..8716349cb4 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -205,21 +205,23 @@ MaterialEditor::MaterialEditor() {
Vector3(x0 * zr0, z0, y0 *zr0)
};
- #define ADD_POINT(m_idx) \
- normals.push_back(v[m_idx]);\
- vertices.push_back(v[m_idx]*radius);\
- { Vector2 uv(Math::atan2(v[m_idx].x,v[m_idx].z),Math::atan2(-v[m_idx].y,v[m_idx].z));\
- uv/=Math_PI;\
- uv*=4.0;\
- uv=uv*0.5+Vector2(0.5,0.5);\
- uvs.push_back(uv);\
- }\
- { Vector3 t = tt.xform(v[m_idx]);\
- tangents.push_back(t.x);\
- tangents.push_back(t.y);\
- tangents.push_back(t.z);\
- tangents.push_back(1.0);\
- }
+#define ADD_POINT(m_idx) \
+ normals.push_back(v[m_idx]); \
+ vertices.push_back(v[m_idx] * radius); \
+ { \
+ Vector2 uv(Math::atan2(v[m_idx].x, v[m_idx].z), Math::atan2(-v[m_idx].y, v[m_idx].z)); \
+ uv /= Math_PI; \
+ uv *= 4.0; \
+ uv = uv * 0.5 + Vector2(0.5, 0.5); \
+ uvs.push_back(uv); \
+ } \
+ { \
+ Vector3 t = tt.xform(v[m_idx]); \
+ tangents.push_back(t.x); \
+ tangents.push_back(t.y); \
+ tangents.push_back(t.z); \
+ tangents.push_back(1.0); \
+ }
@@ -256,15 +258,16 @@ MaterialEditor::MaterialEditor() {
PoolVector<Vector3> uvs;
int vtx_idx=0;
- #define ADD_VTX(m_idx);\
- vertices.push_back( face_points[m_idx] );\
- normals.push_back( normal_points[m_idx] );\
- tangents.push_back( normal_points[m_idx][1] );\
- tangents.push_back( normal_points[m_idx][2] );\
- tangents.push_back( normal_points[m_idx][0] );\
- tangents.push_back( 1.0 );\
- uvs.push_back( Vector3(uv_points[m_idx*2+0],uv_points[m_idx*2+1],0) );\
- vtx_idx++;\
+#define ADD_VTX(m_idx) \
+ ; \
+ vertices.push_back(face_points[m_idx]); \
+ normals.push_back(normal_points[m_idx]); \
+ tangents.push_back(normal_points[m_idx][1]); \
+ tangents.push_back(normal_points[m_idx][2]); \
+ tangents.push_back(normal_points[m_idx][0]); \
+ tangents.push_back(1.0); \
+ uvs.push_back(Vector3(uv_points[m_idx * 2 + 0], uv_points[m_idx * 2 + 1], 0)); \
+ vtx_idx++;\
for (int i=0;i<6;i++) {
@@ -409,5 +412,4 @@ MaterialEditorPlugin::~MaterialEditorPlugin()
{
}
-
#endif
diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h
index 604e7e61bd..30bed67a5e 100644
--- a/editor/plugins/material_editor_plugin.h
+++ b/editor/plugins/material_editor_plugin.h
@@ -29,12 +29,12 @@
#ifndef MATERIAL_EDITOR_PLUGIN_H
#define MATERIAL_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
-#include "scene/resources/material.h"
+#include "editor/editor_plugin.h"
+#include "scene/3d/camera.h"
#include "scene/3d/light.h"
#include "scene/3d/mesh_instance.h"
-#include "scene/3d/camera.h"
+#include "scene/resources/material.h"
#if 0
class MaterialEditor : public Control {
diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h
index 80504ae445..ec6d67e2f7 100644
--- a/editor/plugins/mesh_editor_plugin.h
+++ b/editor/plugins/mesh_editor_plugin.h
@@ -31,12 +31,12 @@
#if 0
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
-#include "scene/resources/material.h"
+#include "editor/editor_plugin.h"
+#include "scene/3d/camera.h"
#include "scene/3d/light.h"
#include "scene/3d/mesh_instance.h"
-#include "scene/3d/camera.h"
+#include "scene/resources/material.h"
class MeshEditor : public Control {
diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp
index 322e212534..972e92e51e 100644
--- a/editor/plugins/mesh_instance_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_editor_plugin.cpp
@@ -28,27 +28,23 @@
/*************************************************************************/
#include "mesh_instance_editor_plugin.h"
-#include "scene/3d/physics_body.h"
#include "scene/3d/body_shape.h"
-#include "scene/gui/box_container.h"
#include "scene/3d/navigation_mesh.h"
+#include "scene/3d/physics_body.h"
+#include "scene/gui/box_container.h"
#include "spatial_editor_plugin.h"
void MeshInstanceEditor::_node_removed(Node *p_node) {
- if(p_node==node) {
- node=NULL;
+ if (p_node == node) {
+ node = NULL;
options->hide();
}
-
}
-
-
void MeshInstanceEditor::edit(MeshInstance *p_mesh) {
- node=p_mesh;
-
+ node = p_mesh;
}
void MeshInstanceEditor::_menu_option(int p_option) {
@@ -60,39 +56,39 @@ void MeshInstanceEditor::_menu_option(int p_option) {
return;
}
- switch(p_option) {
+ switch (p_option) {
case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY:
case MENU_OPTION_CREATE_STATIC_CONVEX_BODY: {
- bool trimesh_shape = (p_option==MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
+ bool trimesh_shape = (p_option == MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection();
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- List<Node*> selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.empty()) {
Ref<Shape> shape = trimesh_shape ? mesh->create_trimesh_shape() : mesh->create_convex_shape();
if (shape.is_null())
return;
- CollisionShape *cshape = memnew( CollisionShape );
+ CollisionShape *cshape = memnew(CollisionShape);
cshape->set_shape(shape);
- StaticBody *body = memnew( StaticBody );
+ StaticBody *body = memnew(StaticBody);
body->add_child(cshape);
- Node *owner = node==get_tree()->get_edited_scene_root() ? node : node->get_owner();
+ Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner();
if (trimesh_shape)
ur->create_action(TTR("Create Static Trimesh Body"));
else
ur->create_action(TTR("Create Static Convex Body"));
- ur->add_do_method(node,"add_child",body);
- ur->add_do_method(body,"set_owner",owner);
- ur->add_do_method(cshape,"set_owner",owner);
+ ur->add_do_method(node, "add_child", body);
+ ur->add_do_method(body, "set_owner", owner);
+ ur->add_do_method(cshape, "set_owner", owner);
ur->add_do_reference(body);
- ur->add_undo_method(node,"remove_child",body);
+ ur->add_undo_method(node, "remove_child", body);
ur->commit_action();
return;
}
@@ -102,7 +98,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
else
ur->create_action(TTR("Create Static Convex Body"));
- for (List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
MeshInstance *instance = E->get()->cast_to<MeshInstance>();
if (!instance)
@@ -116,18 +112,18 @@ void MeshInstanceEditor::_menu_option(int p_option) {
if (shape.is_null())
continue;
- CollisionShape *cshape = memnew( CollisionShape );
+ CollisionShape *cshape = memnew(CollisionShape);
cshape->set_shape(shape);
- StaticBody *body = memnew( StaticBody );
+ StaticBody *body = memnew(StaticBody);
body->add_child(cshape);
- Node *owner = instance==get_tree()->get_edited_scene_root() ? instance : instance->get_owner();
+ Node *owner = instance == get_tree()->get_edited_scene_root() ? instance : instance->get_owner();
- ur->add_do_method(instance,"add_child",body);
- ur->add_do_method(body,"set_owner",owner);
- ur->add_do_method(cshape,"set_owner",owner);
+ ur->add_do_method(instance, "add_child", body);
+ ur->add_do_method(body, "set_owner", owner);
+ ur->add_do_method(cshape, "set_owner", owner);
ur->add_do_reference(body);
- ur->add_undo_method(instance,"remove_child",body);
+ ur->add_undo_method(instance, "remove_child", body);
}
ur->commit_action();
@@ -137,22 +133,22 @@ void MeshInstanceEditor::_menu_option(int p_option) {
case MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE:
case MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE: {
- if (node==get_tree()->get_edited_scene_root()) {
+ if (node == get_tree()->get_edited_scene_root()) {
err_dialog->set_text(TTR("This doesn't work on scene root!"));
err_dialog->popup_centered_minsize();
return;
}
- bool trimesh_shape = (p_option==MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE);
+ bool trimesh_shape = (p_option == MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE);
Ref<Shape> shape = trimesh_shape ? mesh->create_trimesh_shape() : mesh->create_convex_shape();
if (shape.is_null())
return;
- CollisionShape *cshape = memnew( CollisionShape );
+ CollisionShape *cshape = memnew(CollisionShape);
cshape->set_shape(shape);
- Node *owner = node->get_owner();
+ Node *owner = node->get_owner();
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
@@ -161,36 +157,36 @@ void MeshInstanceEditor::_menu_option(int p_option) {
else
ur->create_action(TTR("Create Convex Shape"));
- ur->add_do_method(node->get_parent(),"add_child",cshape);
- ur->add_do_method(node->get_parent(),"move_child",cshape,node->get_index()+1);
- ur->add_do_method(cshape,"set_owner",owner);
+ ur->add_do_method(node->get_parent(), "add_child", cshape);
+ ur->add_do_method(node->get_parent(), "move_child", cshape, node->get_index() + 1);
+ ur->add_do_method(cshape, "set_owner", owner);
ur->add_do_reference(cshape);
- ur->add_undo_method(node->get_parent(),"remove_child",cshape);
+ ur->add_undo_method(node->get_parent(), "remove_child", cshape);
ur->commit_action();
} break;
case MENU_OPTION_CREATE_NAVMESH: {
- Ref<NavigationMesh> nmesh = memnew( NavigationMesh );
+ Ref<NavigationMesh> nmesh = memnew(NavigationMesh);
if (nmesh.is_null())
return;
nmesh->create_from_mesh(mesh);
- NavigationMeshInstance *nmi = memnew( NavigationMeshInstance );
+ NavigationMeshInstance *nmi = memnew(NavigationMeshInstance);
nmi->set_navigation_mesh(nmesh);
- Node *owner = node==get_tree()->get_edited_scene_root() ? node : node->get_owner();
+ Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner();
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action(TTR("Create Navigation Mesh"));
- ur->add_do_method(node,"add_child",nmi);
- ur->add_do_method(nmi,"set_owner",owner);
+ ur->add_do_method(node, "add_child", nmi);
+ ur->add_do_method(nmi, "set_owner", owner);
ur->add_do_reference(nmi);
- ur->add_undo_method(node,"remove_child",nmi);
+ ur->add_undo_method(node, "remove_child", nmi);
ur->commit_action();
} break;
@@ -199,7 +195,6 @@ void MeshInstanceEditor::_menu_option(int p_option) {
outline_dialog->popup_centered(Vector2(200, 90));
} break;
}
-
}
void MeshInstanceEditor::_create_outline_mesh() {
@@ -225,76 +220,73 @@ void MeshInstanceEditor::_create_outline_mesh() {
return;
}
- MeshInstance *mi = memnew( MeshInstance );
+ MeshInstance *mi = memnew(MeshInstance);
mi->set_mesh(mesho);
- Node *owner=node->get_owner();
- if (get_tree()->get_edited_scene_root()==node) {
- owner=node;
+ Node *owner = node->get_owner();
+ if (get_tree()->get_edited_scene_root() == node) {
+ owner = node;
}
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action(TTR("Create Outline"));
- ur->add_do_method(node,"add_child",mi);
- ur->add_do_method(mi,"set_owner",owner);
+ ur->add_do_method(node, "add_child", mi);
+ ur->add_do_method(mi, "set_owner", owner);
ur->add_do_reference(mi);
- ur->add_undo_method(node,"remove_child",mi);
+ ur->add_undo_method(node, "remove_child", mi);
ur->commit_action();
}
void MeshInstanceEditor::_bind_methods() {
- ClassDB::bind_method("_menu_option",&MeshInstanceEditor::_menu_option);
- ClassDB::bind_method("_create_outline_mesh",&MeshInstanceEditor::_create_outline_mesh);
+ ClassDB::bind_method("_menu_option", &MeshInstanceEditor::_menu_option);
+ ClassDB::bind_method("_create_outline_mesh", &MeshInstanceEditor::_create_outline_mesh);
}
MeshInstanceEditor::MeshInstanceEditor() {
-
- options = memnew( MenuButton );
+ options = memnew(MenuButton);
SpatialEditor::get_singleton()->add_control_to_menu_panel(options);
options->set_text(TTR("Mesh"));
- options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshInstance","EditorIcons"));
+ options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshInstance", "EditorIcons"));
- options->get_popup()->add_item(TTR("Create Trimesh Static Body"),MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
- options->get_popup()->add_item(TTR("Create Convex Static Body"),MENU_OPTION_CREATE_STATIC_CONVEX_BODY);
+ options->get_popup()->add_item(TTR("Create Trimesh Static Body"), MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
+ options->get_popup()->add_item(TTR("Create Convex Static Body"), MENU_OPTION_CREATE_STATIC_CONVEX_BODY);
options->get_popup()->add_separator();
- options->get_popup()->add_item(TTR("Create Trimesh Collision Sibling"),MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE);
- options->get_popup()->add_item(TTR("Create Convex Collision Sibling"),MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE);
+ options->get_popup()->add_item(TTR("Create Trimesh Collision Sibling"), MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE);
+ options->get_popup()->add_item(TTR("Create Convex Collision Sibling"), MENU_OPTION_CREATE_CONVEX_COLLISION_SHAPE);
options->get_popup()->add_separator();
- options->get_popup()->add_item(TTR("Create Navigation Mesh"),MENU_OPTION_CREATE_NAVMESH);
+ options->get_popup()->add_item(TTR("Create Navigation Mesh"), MENU_OPTION_CREATE_NAVMESH);
options->get_popup()->add_separator();
- options->get_popup()->add_item(TTR("Create Outline Mesh.."),MENU_OPTION_CREATE_OUTLINE_MESH);
+ options->get_popup()->add_item(TTR("Create Outline Mesh.."), MENU_OPTION_CREATE_OUTLINE_MESH);
- options->get_popup()->connect("id_pressed", this,"_menu_option");
+ options->get_popup()->connect("id_pressed", this, "_menu_option");
- outline_dialog = memnew( ConfirmationDialog );
+ outline_dialog = memnew(ConfirmationDialog);
outline_dialog->set_title(TTR("Create Outline Mesh"));
outline_dialog->get_ok()->set_text(TTR("Create"));
- VBoxContainer *outline_dialog_vbc = memnew( VBoxContainer );
+ VBoxContainer *outline_dialog_vbc = memnew(VBoxContainer);
outline_dialog->add_child(outline_dialog_vbc);
//outline_dialog->set_child_rect(outline_dialog_vbc);
- outline_size = memnew( SpinBox );
+ outline_size = memnew(SpinBox);
outline_size->set_min(0.001);
outline_size->set_max(1024);
outline_size->set_step(0.001);
outline_size->set_value(0.05);
- outline_dialog_vbc->add_margin_child(TTR("Outline Size:"),outline_size);
+ outline_dialog_vbc->add_margin_child(TTR("Outline Size:"), outline_size);
add_child(outline_dialog);
- outline_dialog->connect("confirmed",this,"_create_outline_mesh");
+ outline_dialog->connect("confirmed", this, "_create_outline_mesh");
- err_dialog = memnew( AcceptDialog );
+ err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
-
}
-
void MeshInstanceEditorPlugin::edit(Object *p_object) {
mesh_editor->edit(p_object->cast_to<MeshInstance>());
@@ -314,21 +306,16 @@ void MeshInstanceEditorPlugin::make_visible(bool p_visible) {
mesh_editor->options->hide();
mesh_editor->edit(NULL);
}
-
}
MeshInstanceEditorPlugin::MeshInstanceEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- mesh_editor = memnew( MeshInstanceEditor );
+ editor = p_node;
+ mesh_editor = memnew(MeshInstanceEditor);
editor->get_viewport()->add_child(mesh_editor);
mesh_editor->options->hide();
}
-
-MeshInstanceEditorPlugin::~MeshInstanceEditorPlugin()
-{
+MeshInstanceEditorPlugin::~MeshInstanceEditorPlugin() {
}
-
-
diff --git a/editor/plugins/mesh_instance_editor_plugin.h b/editor/plugins/mesh_instance_editor_plugin.h
index de5be2fbbb..54d42d1a01 100644
--- a/editor/plugins/mesh_instance_editor_plugin.h
+++ b/editor/plugins/mesh_instance_editor_plugin.h
@@ -29,17 +29,14 @@
#ifndef MESH_INSTANCE_EDITOR_PLUGIN_H
#define MESH_INSTANCE_EDITOR_PLUGIN_H
-
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/3d/mesh_instance.h"
#include "scene/gui/spin_box.h"
-
class MeshInstanceEditor : public Node {
- GDCLASS(MeshInstanceEditor, Node );
-
+ GDCLASS(MeshInstanceEditor, Node);
enum Menu {
@@ -63,26 +60,25 @@ class MeshInstanceEditor : public Node {
void _menu_option(int p_option);
void _create_outline_mesh();
-friend class MeshInstanceEditorPlugin;
+ friend class MeshInstanceEditorPlugin;
protected:
void _node_removed(Node *p_node);
static void _bind_methods();
-public:
+public:
void edit(MeshInstance *p_mesh);
MeshInstanceEditor();
};
class MeshInstanceEditorPlugin : public EditorPlugin {
- GDCLASS( MeshInstanceEditorPlugin, EditorPlugin );
+ GDCLASS(MeshInstanceEditorPlugin, EditorPlugin);
MeshInstanceEditor *mesh_editor;
EditorNode *editor;
public:
-
virtual String get_name() const { return "MeshInstance"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -91,7 +87,6 @@ public:
MeshInstanceEditorPlugin(EditorNode *p_node);
~MeshInstanceEditorPlugin();
-
};
#endif // MESH_EDITOR_PLUGIN_H
diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp
index 6259ddf473..126927480a 100644
--- a/editor/plugins/multimesh_editor_plugin.cpp
+++ b/editor/plugins/multimesh_editor_plugin.cpp
@@ -28,29 +28,26 @@
/*************************************************************************/
#include "multimesh_editor_plugin.h"
-#include "scene/gui/box_container.h"
#include "scene/3d/mesh_instance.h"
+#include "scene/gui/box_container.h"
#include "spatial_editor_plugin.h"
void MultiMeshEditor::_node_removed(Node *p_node) {
- if(p_node==node) {
- node=NULL;
+ if (p_node == node) {
+ node = NULL;
hide();
}
-
}
-
void MultiMeshEditor::_populate() {
- if(!node)
+ if (!node)
return;
-
Ref<Mesh> mesh;
- if (mesh_source->get_text()=="") {
+ if (mesh_source->get_text() == "") {
Ref<MultiMesh> multimesh;
multimesh = node->get_multimesh();
@@ -88,7 +85,7 @@ void MultiMeshEditor::_populate() {
return;
}
- mesh=ms_instance->get_mesh();
+ mesh = ms_instance->get_mesh();
if (mesh.is_null()) {
@@ -96,10 +93,9 @@ void MultiMeshEditor::_populate() {
err_dialog->popup_centered_minsize();
return;
}
-
}
- if (surface_source->get_text()=="") {
+ if (surface_source->get_text() == "") {
err_dialog->set_text(TTR("No surface source specified."));
err_dialog->popup_centered_minsize();
@@ -128,7 +124,7 @@ void MultiMeshEditor::_populate() {
PoolVector<Face3> geometry = ss_instance->get_faces(VisualInstance::FACES_SOLID);
- if (geometry.size()==0) {
+ if (geometry.size() == 0) {
err_dialog->set_text(TTR("Surface source is invalid (no faces)."));
err_dialog->popup_centered_minsize();
@@ -140,14 +136,12 @@ void MultiMeshEditor::_populate() {
int gc = geometry.size();
PoolVector<Face3>::Write w = geometry.write();
- for(int i=0;i<gc;i++) {
- for(int j=0;j<3;j++) {
- w[i].vertex[j] = geom_xform.xform( w[i].vertex[j] );
+ for (int i = 0; i < gc; i++) {
+ for (int j = 0; j < 3; j++) {
+ w[i].vertex[j] = geom_xform.xform(w[i].vertex[j]);
}
}
-
-
w = PoolVector<Face3>::Write();
#if 0
node->get_multimesh()->set_instance_count(populate_amount->get_val());
@@ -167,34 +161,31 @@ void MultiMeshEditor::_populate() {
#endif
PoolVector<Face3> faces = geometry;
ERR_EXPLAIN(TTR("Parent has no solid faces to populate."));
- int facecount=faces.size();
+ int facecount = faces.size();
ERR_FAIL_COND(!facecount);
PoolVector<Face3>::Read r = faces.read();
-
-
- float area_accum=0;
- Map<float,int> triangle_area_map;
- for(int i=0;i<facecount;i++) {
+ float area_accum = 0;
+ Map<float, int> triangle_area_map;
+ for (int i = 0; i < facecount; i++) {
float area = r[i].get_area();
- if (area<CMP_EPSILON)
+ if (area < CMP_EPSILON)
continue;
- triangle_area_map[area_accum]=i;
- area_accum+=area;
+ triangle_area_map[area_accum] = i;
+ area_accum += area;
}
ERR_EXPLAIN(TTR("Couldn't map area."));
- ERR_FAIL_COND(triangle_area_map.size()==0);
+ ERR_FAIL_COND(triangle_area_map.size() == 0);
ERR_EXPLAIN(TTR("Couldn't map area."));
- ERR_FAIL_COND(area_accum==0);
-
+ ERR_FAIL_COND(area_accum == 0);
- Ref<MultiMesh> multimesh = memnew( MultiMesh );
+ Ref<MultiMesh> multimesh = memnew(MultiMesh);
multimesh->set_mesh(mesh);
- int instance_count=populate_amount->get_value();
+ int instance_count = populate_amount->get_value();
multimesh->set_transform_format(MultiMesh::TRANSFORM_3D);
multimesh->set_color_format(MultiMesh::COLOR_NONE);
@@ -207,21 +198,21 @@ void MultiMeshEditor::_populate() {
int axis = populate_axis->get_selected();
Transform axis_xform;
- if (axis==Vector3::AXIS_Z) {
- axis_xform.rotate(Vector3(1,0,0),-Math_PI*0.5);
+ if (axis == Vector3::AXIS_Z) {
+ axis_xform.rotate(Vector3(1, 0, 0), -Math_PI * 0.5);
}
- if (axis==Vector3::AXIS_X) {
- axis_xform.rotate(Vector3(0,0,1),-Math_PI*0.5);
+ if (axis == Vector3::AXIS_X) {
+ axis_xform.rotate(Vector3(0, 0, 1), -Math_PI * 0.5);
}
- for(int i=0;i<instance_count;i++) {
+ for (int i = 0; i < instance_count; i++) {
- float areapos = Math::random(0.0f,area_accum);
+ float areapos = Math::random(0.0f, area_accum);
- Map<float,int>::Element *E = triangle_area_map.find_closest(areapos);
+ Map<float, int>::Element *E = triangle_area_map.find_closest(areapos);
ERR_FAIL_COND(!E)
int index = E->get();
- ERR_FAIL_INDEX(index,facecount);
+ ERR_FAIL_INDEX(index, facecount);
// ok FINALLY get face
Face3 face = r[index];
@@ -229,41 +220,33 @@ void MultiMeshEditor::_populate() {
Vector3 pos = face.get_random_point_inside();
Vector3 normal = face.get_plane().normal;
- Vector3 op_axis = (face.vertex[0]-face.vertex[1]).normalized();
+ Vector3 op_axis = (face.vertex[0] - face.vertex[1]).normalized();
Transform xform;
- xform.set_look_at(pos, pos+op_axis,normal);
+ xform.set_look_at(pos, pos + op_axis, normal);
xform = xform * axis_xform;
-
Basis post_xform;
- post_xform.rotate(xform.basis.get_axis(1),-Math::random(-_rotate_random,_rotate_random)*Math_PI);
- post_xform.rotate(xform.basis.get_axis(2),-Math::random(-_tilt_random,_tilt_random)*Math_PI);
- post_xform.rotate(xform.basis.get_axis(0),-Math::random(-_tilt_random,_tilt_random)*Math_PI);
+ post_xform.rotate(xform.basis.get_axis(1), -Math::random(-_rotate_random, _rotate_random) * Math_PI);
+ post_xform.rotate(xform.basis.get_axis(2), -Math::random(-_tilt_random, _tilt_random) * Math_PI);
+ post_xform.rotate(xform.basis.get_axis(0), -Math::random(-_tilt_random, _tilt_random) * Math_PI);
xform.basis = post_xform * xform.basis;
//xform.basis.orthonormalize();
+ xform.basis.scale(Vector3(1, 1, 1) * (_scale + Math::random(-_scale_random, _scale_random)));
- xform.basis.scale(Vector3(1,1,1)*(_scale+Math::random(-_scale_random,_scale_random)));
-
-
- multimesh->set_instance_transform(i,xform);
-
+ multimesh->set_instance_transform(i, xform);
}
-
-
node->set_multimesh(multimesh);
-
}
-void MultiMeshEditor::_browsed(const NodePath& p_path) {
-
+void MultiMeshEditor::_browsed(const NodePath &p_path) {
- NodePath path = node->get_path_to( get_node(p_path) );
+ NodePath path = node->get_path_to(get_node(p_path));
if (browsing_source)
mesh_source->set_text(path);
@@ -273,14 +256,11 @@ void MultiMeshEditor::_browsed(const NodePath& p_path) {
void MultiMeshEditor::_menu_option(int p_option) {
-
- switch(p_option) {
-
+ switch (p_option) {
case MENU_OPTION_POPULATE: {
- if (_last_pp_node!=node) {
-
+ if (_last_pp_node != node) {
surface_source->set_text("..");
mesh_source->set_text("..");
@@ -291,25 +271,23 @@ void MultiMeshEditor::_menu_option(int p_option) {
populate_scale->set_value(1);
populate_amount->set_value(128);
- _last_pp_node=node;
+ _last_pp_node = node;
}
- populate_dialog->popup_centered(Size2(250,380));
+ populate_dialog->popup_centered(Size2(250, 380));
} break;
}
}
-
void MultiMeshEditor::edit(MultiMeshInstance *p_multimesh) {
- node=p_multimesh;
-
+ node = p_multimesh;
}
void MultiMeshEditor::_browse(bool p_source) {
- browsing_source=p_source;
- std->get_scene_tree()->set_marked(node,false);
+ browsing_source = p_source;
+ std->get_scene_tree()->set_marked(node, false);
std->popup_centered_ratio();
if (p_source)
std->set_title(TTR("Select a Source Mesh:"));
@@ -319,113 +297,108 @@ void MultiMeshEditor::_browse(bool p_source) {
void MultiMeshEditor::_bind_methods() {
- ClassDB::bind_method("_menu_option",&MultiMeshEditor::_menu_option);
- ClassDB::bind_method("_populate",&MultiMeshEditor::_populate);
- ClassDB::bind_method("_browsed",&MultiMeshEditor::_browsed);
- ClassDB::bind_method("_browse",&MultiMeshEditor::_browse);
+ ClassDB::bind_method("_menu_option", &MultiMeshEditor::_menu_option);
+ ClassDB::bind_method("_populate", &MultiMeshEditor::_populate);
+ ClassDB::bind_method("_browsed", &MultiMeshEditor::_browsed);
+ ClassDB::bind_method("_browse", &MultiMeshEditor::_browse);
}
MultiMeshEditor::MultiMeshEditor() {
-
- options = memnew( MenuButton );
+ options = memnew(MenuButton);
SpatialEditor::get_singleton()->add_control_to_menu_panel(options);
options->set_text("MultiMesh");
- options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MultiMeshInstance","EditorIcons"));
+ options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MultiMeshInstance", "EditorIcons"));
options->get_popup()->add_item(TTR("Populate Surface"));
- options->get_popup()->connect("id_pressed", this,"_menu_option");
+ options->get_popup()->connect("id_pressed", this, "_menu_option");
- populate_dialog = memnew( ConfirmationDialog );
+ populate_dialog = memnew(ConfirmationDialog);
populate_dialog->set_title(TTR("Populate MultiMesh"));
add_child(populate_dialog);
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
populate_dialog->add_child(vbc);
//populate_dialog->set_child_rect(vbc);
- HBoxContainer *hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
- surface_source = memnew( LineEdit );
+ surface_source = memnew(LineEdit);
hbc->add_child(surface_source);
surface_source->set_h_size_flags(SIZE_EXPAND_FILL);
- Button *b = memnew( Button );
+ Button *b = memnew(Button);
hbc->add_child(b);
b->set_text("..");
- b->connect("pressed",this,"_browse",make_binds(false));
+ b->connect("pressed", this, "_browse", make_binds(false));
- vbc->add_margin_child(TTR("Target Surface:"),hbc);
+ vbc->add_margin_child(TTR("Target Surface:"), hbc);
- hbc = memnew( HBoxContainer );
- mesh_source = memnew( LineEdit );
+ hbc = memnew(HBoxContainer);
+ mesh_source = memnew(LineEdit);
hbc->add_child(mesh_source);
mesh_source->set_h_size_flags(SIZE_EXPAND_FILL);
- b = memnew( Button );
+ b = memnew(Button);
hbc->add_child(b);
b->set_text("..");
- vbc->add_margin_child(TTR("Source Mesh:"),hbc);
- b->connect("pressed",this,"_browse",make_binds(true));
+ vbc->add_margin_child(TTR("Source Mesh:"), hbc);
+ b->connect("pressed", this, "_browse", make_binds(true));
-
- populate_axis = memnew( OptionButton );
+ populate_axis = memnew(OptionButton);
populate_axis->add_item(TTR("X-Axis"));
populate_axis->add_item(TTR("Y-Axis"));
populate_axis->add_item(TTR("Z-Axis"));
populate_axis->select(2);
- vbc->add_margin_child(TTR("Mesh Up Axis:"),populate_axis);
+ vbc->add_margin_child(TTR("Mesh Up Axis:"), populate_axis);
- populate_rotate_random = memnew( HSlider );
+ populate_rotate_random = memnew(HSlider);
populate_rotate_random->set_max(1);
populate_rotate_random->set_step(0.01);
- vbc->add_margin_child(TTR("Random Rotation:"),populate_rotate_random);
+ vbc->add_margin_child(TTR("Random Rotation:"), populate_rotate_random);
- populate_tilt_random = memnew( HSlider );
+ populate_tilt_random = memnew(HSlider);
populate_tilt_random->set_max(1);
populate_tilt_random->set_step(0.01);
- vbc->add_margin_child(TTR("Random Tilt:"),populate_tilt_random);
-
+ vbc->add_margin_child(TTR("Random Tilt:"), populate_tilt_random);
- populate_scale_random = memnew( SpinBox );
+ populate_scale_random = memnew(SpinBox);
populate_scale_random->set_min(0);
populate_scale_random->set_max(1);
populate_scale_random->set_value(0);
populate_scale_random->set_step(0.01);
- vbc->add_margin_child(TTR("Random Scale:"),populate_scale_random);
+ vbc->add_margin_child(TTR("Random Scale:"), populate_scale_random);
- populate_scale = memnew( SpinBox );
+ populate_scale = memnew(SpinBox);
populate_scale->set_min(0.001);
populate_scale->set_max(4096);
populate_scale->set_value(1);
populate_scale->set_step(0.01);
- vbc->add_margin_child(TTR("Scale:"),populate_scale);
+ vbc->add_margin_child(TTR("Scale:"), populate_scale);
-
- populate_amount = memnew( SpinBox );
- populate_amount->set_anchor(MARGIN_RIGHT,ANCHOR_END);
- populate_amount->set_begin( Point2(20,232));
- populate_amount->set_end( Point2(5,237));
+ populate_amount = memnew(SpinBox);
+ populate_amount->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ populate_amount->set_begin(Point2(20, 232));
+ populate_amount->set_end(Point2(5, 237));
populate_amount->set_min(1);
populate_amount->set_max(65536);
populate_amount->set_value(128);
- vbc->add_margin_child(TTR("Amount:"),populate_amount);
+ vbc->add_margin_child(TTR("Amount:"), populate_amount);
populate_dialog->get_ok()->set_text(TTR("Populate"));
- populate_dialog->get_ok()->connect("pressed", this,"_populate");
- std = memnew( SceneTreeDialog );
+ populate_dialog->get_ok()->connect("pressed", this, "_populate");
+ std = memnew(SceneTreeDialog);
populate_dialog->add_child(std);
- std->connect("selected",this,"_browsed");
+ std->connect("selected", this, "_browsed");
- _last_pp_node=NULL;
+ _last_pp_node = NULL;
- err_dialog = memnew( AcceptDialog );
+ err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
}
-
void MultiMeshEditorPlugin::edit(Object *p_object) {
multimesh_editor->edit(p_object->cast_to<MultiMeshInstance>());
@@ -445,21 +418,16 @@ void MultiMeshEditorPlugin::make_visible(bool p_visible) {
multimesh_editor->options->hide();
multimesh_editor->edit(NULL);
}
-
}
MultiMeshEditorPlugin::MultiMeshEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- multimesh_editor = memnew( MultiMeshEditor );
+ editor = p_node;
+ multimesh_editor = memnew(MultiMeshEditor);
editor->get_viewport()->add_child(multimesh_editor);
multimesh_editor->options->hide();
}
-
-MultiMeshEditorPlugin::~MultiMeshEditorPlugin()
-{
+MultiMeshEditorPlugin::~MultiMeshEditorPlugin() {
}
-
-
diff --git a/editor/plugins/multimesh_editor_plugin.h b/editor/plugins/multimesh_editor_plugin.h
index a97b3758a1..eb46733082 100644
--- a/editor/plugins/multimesh_editor_plugin.h
+++ b/editor/plugins/multimesh_editor_plugin.h
@@ -29,8 +29,8 @@
#ifndef MULTIMESH_EDITOR_PLUGIN_H
#define MULTIMESH_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/3d/multimesh_instance.h"
#include "scene/gui/spin_box.h"
@@ -40,12 +40,12 @@
class MultiMeshEditor : public Control {
- GDCLASS(MultiMeshEditor, Control );
+ GDCLASS(MultiMeshEditor, Control);
-friend class MultiMeshEditorPlugin;
+ friend class MultiMeshEditorPlugin;
AcceptDialog *err_dialog;
- MenuButton * options;
+ MenuButton *options;
MultiMeshInstance *_last_pp_node;
bool browsing_source;
@@ -70,7 +70,7 @@ friend class MultiMeshEditorPlugin;
MENU_OPTION_POPULATE
};
- void _browsed(const NodePath& p_path);
+ void _browsed(const NodePath &p_path);
void _menu_option(int);
void _populate();
void _browse(bool p_source);
@@ -78,21 +78,20 @@ friend class MultiMeshEditorPlugin;
protected:
void _node_removed(Node *p_node);
static void _bind_methods();
-public:
+public:
void edit(MultiMeshInstance *p_multimesh);
MultiMeshEditor();
};
class MultiMeshEditorPlugin : public EditorPlugin {
- GDCLASS( MultiMeshEditorPlugin, EditorPlugin );
+ GDCLASS(MultiMeshEditorPlugin, EditorPlugin);
MultiMeshEditor *multimesh_editor;
EditorNode *editor;
public:
-
virtual String get_name() const { return "MultiMesh"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -101,7 +100,6 @@ public:
MultiMeshEditorPlugin(EditorNode *p_node);
~MultiMeshEditorPlugin();
-
};
#endif // MULTIMESH_EDITOR_PLUGIN_H
diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp
index 654afb754e..e5b2594872 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -29,372 +29,342 @@
#include "navigation_polygon_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
-#include "os/file_access.h"
#include "editor/editor_settings.h"
+#include "os/file_access.h"
void NavigationPolygonEditor::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
- button_create->set_icon( get_icon("Edit","EditorIcons"));
- button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
+ button_create->set_icon(get_icon("Edit", "EditorIcons"));
+ button_edit->set_icon(get_icon("MovePoint", "EditorIcons"));
button_edit->set_pressed(true);
- get_tree()->connect("node_removed",this,"_node_removed");
- create_nav->connect("confirmed",this,"_create_nav");
+ get_tree()->connect("node_removed", this, "_node_removed");
+ create_nav->connect("confirmed", this, "_create_nav");
} break;
case NOTIFICATION_FIXED_PROCESS: {
-
} break;
}
-
}
void NavigationPolygonEditor::_node_removed(Node *p_node) {
- if(p_node==node) {
- node=NULL;
+ if (p_node == node) {
+ node = NULL;
hide();
canvas_item_editor->get_viewport_control()->update();
}
-
}
-void NavigationPolygonEditor::_create_nav() {
+void NavigationPolygonEditor::_create_nav() {
if (!node)
return;
undo_redo->create_action(TTR("Create Navigation Polygon"));
- undo_redo->add_do_method(node,"set_navigation_polygon",Ref<NavigationPolygon>(memnew( NavigationPolygon)));
- undo_redo->add_undo_method(node,"set_navigation_polygon",Variant(REF()));
+ undo_redo->add_do_method(node, "set_navigation_polygon", Ref<NavigationPolygon>(memnew(NavigationPolygon)));
+ undo_redo->add_undo_method(node, "set_navigation_polygon", Variant(REF()));
undo_redo->commit_action();
}
void NavigationPolygonEditor::_menu_option(int p_option) {
- switch(p_option) {
+ switch (p_option) {
case MODE_CREATE: {
- mode=MODE_CREATE;
+ mode = MODE_CREATE;
button_create->set_pressed(true);
button_edit->set_pressed(false);
} break;
case MODE_EDIT: {
- mode=MODE_EDIT;
+ mode = MODE_EDIT;
button_create->set_pressed(false);
button_edit->set_pressed(true);
} break;
-
}
}
void NavigationPolygonEditor::_wip_close() {
-
- if (wip.size()>=3) {
+ if (wip.size() >= 3) {
undo_redo->create_action(TTR("Create Poly"));
- undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"remove_outline",node->get_navigation_polygon()->get_outline_count());
- undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"add_outline",wip);
- undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
- undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_undo_method(node->get_navigation_polygon().ptr(), "remove_outline", node->get_navigation_polygon()->get_outline_count());
+ undo_redo->add_do_method(node->get_navigation_polygon().ptr(), "add_outline", wip);
+ undo_redo->add_do_method(node->get_navigation_polygon().ptr(), "make_polygons_from_outlines");
+ undo_redo->add_undo_method(node->get_navigation_polygon().ptr(), "make_polygons_from_outlines");
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
- mode=MODE_EDIT;
+ mode = MODE_EDIT;
button_edit->set_pressed(true);
button_create->set_pressed(false);
}
wip.clear();
- wip_active=false;
- edited_point=-1;
+ wip_active = false;
+ edited_point = -1;
}
-bool NavigationPolygonEditor::forward_gui_input(const InputEvent& p_event) {
-
+bool NavigationPolygonEditor::forward_gui_input(const InputEvent &p_event) {
if (!node)
return false;
if (node->get_navigation_polygon().is_null()) {
- 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) {
create_nav->set_text("No NavigationPolygon resource on this node.\nCreate and assign one?");
create_nav->popup_centered_minsize();
}
- return (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1);
+ return (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == 1);
}
-
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_event.mouse_button;
+ const InputEventMouseButton &mb = p_event.mouse_button;
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
-
- Vector2 gpoint = Point2(mb.x,mb.y);
+ Vector2 gpoint = Point2(mb.x, mb.y);
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
- cpoint=canvas_item_editor->snap_point(cpoint);
+ cpoint = canvas_item_editor->snap_point(cpoint);
cpoint = node->get_global_transform().affine_inverse().xform(cpoint);
-
-
//first check if a point is to be added (segment split)
- real_t grab_treshold=EDITOR_DEF("editors/poly_editor/point_grab_radius",8);
-
- switch(mode) {
+ real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
+ switch (mode) {
case MODE_CREATE: {
- if (mb.button_index==BUTTON_LEFT && mb.pressed) {
-
+ if (mb.button_index == BUTTON_LEFT && mb.pressed) {
if (!wip_active) {
wip.clear();
- wip.push_back( cpoint );
- wip_active=true;
- edited_point_pos=cpoint;
- edited_outline=-1;
+ wip.push_back(cpoint);
+ wip_active = true;
+ edited_point_pos = cpoint;
+ edited_outline = -1;
canvas_item_editor->get_viewport_control()->update();
- edited_point=1;
+ edited_point = 1;
return true;
} else {
-
- if (wip.size()>1 && xform.xform(wip[0]).distance_to(gpoint)<grab_treshold) {
+ if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_treshold) {
//wip closed
_wip_close();
return true;
} else {
- wip.push_back( cpoint );
- edited_point=wip.size();
+ wip.push_back(cpoint);
+ edited_point = wip.size();
canvas_item_editor->get_viewport_control()->update();
return true;
//add wip point
}
}
- } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && wip_active) {
+ } else if (mb.button_index == BUTTON_RIGHT && mb.pressed && wip_active) {
_wip_close();
}
-
-
} break;
case MODE_EDIT: {
- if (mb.button_index==BUTTON_LEFT) {
+ if (mb.button_index == BUTTON_LEFT) {
if (mb.pressed) {
if (mb.mod.control) {
-
//search edges
- int closest_outline=-1;
- int closest_idx=-1;
+ int closest_outline = -1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
-
- for(int j=0;j<node->get_navigation_polygon()->get_outline_count();j++) {
+ real_t closest_dist = 1e10;
+ for (int j = 0; j < node->get_navigation_polygon()->get_outline_count(); j++) {
- PoolVector<Vector2> points=node->get_navigation_polygon()->get_outline(j);
+ PoolVector<Vector2> points = node->get_navigation_polygon()->get_outline(j);
- int pc=points.size();
- PoolVector<Vector2>::Read poly=points.read();
+ int pc = points.size();
+ PoolVector<Vector2>::Read poly = points.read();
- for(int i=0;i<pc;i++) {
+ for (int i = 0; i < pc; i++) {
- Vector2 points[2] ={ xform.xform(poly[i]),
- xform.xform(poly[(i+1)%pc]) };
+ Vector2 points[2] = { xform.xform(poly[i]),
+ xform.xform(poly[(i + 1) % pc]) };
- Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint,points);
- if (cp.distance_squared_to(points[0])<CMP_EPSILON2 || cp.distance_squared_to(points[1])<CMP_EPSILON2)
+ Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint, points);
+ if (cp.distance_squared_to(points[0]) < CMP_EPSILON2 || cp.distance_squared_to(points[1]) < CMP_EPSILON2)
continue; //not valid to reuse point
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_outline=j;
- closest_pos=cp;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_outline = j;
+ closest_pos = cp;
+ closest_idx = i;
}
-
-
}
}
- if (closest_idx>=0) {
+ if (closest_idx >= 0) {
- pre_move_edit=node->get_navigation_polygon()->get_outline(closest_outline);
+ pre_move_edit = node->get_navigation_polygon()->get_outline(closest_outline);
PoolVector<Point2> poly = pre_move_edit;
- poly.insert(closest_idx+1,xform.affine_inverse().xform(closest_pos));
- edited_point=closest_idx+1;
- edited_outline=closest_outline;
- edited_point_pos=xform.affine_inverse().xform(closest_pos);
- node->get_navigation_polygon()->set_outline(closest_outline,poly);
+ poly.insert(closest_idx + 1, xform.affine_inverse().xform(closest_pos));
+ edited_point = closest_idx + 1;
+ edited_outline = closest_outline;
+ edited_point_pos = xform.affine_inverse().xform(closest_pos);
+ node->get_navigation_polygon()->set_outline(closest_outline, poly);
canvas_item_editor->get_viewport_control()->update();
return true;
}
} else {
//look for points to move
- int closest_outline=-1;
- int closest_idx=-1;
+ int closest_outline = -1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
-
- for(int j=0;j<node->get_navigation_polygon()->get_outline_count();j++) {
+ real_t closest_dist = 1e10;
+ for (int j = 0; j < node->get_navigation_polygon()->get_outline_count(); j++) {
- PoolVector<Vector2> points=node->get_navigation_polygon()->get_outline(j);
+ PoolVector<Vector2> points = node->get_navigation_polygon()->get_outline(j);
- int pc=points.size();
- PoolVector<Vector2>::Read poly=points.read();
+ int pc = points.size();
+ PoolVector<Vector2>::Read poly = points.read();
- for(int i=0;i<pc;i++) {
+ for (int i = 0; i < pc; i++) {
-
- Vector2 cp =xform.xform(poly[i]);
+ Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_outline=j;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_outline = j;
+ closest_idx = i;
}
}
}
- if (closest_idx>=0) {
+ if (closest_idx >= 0) {
- pre_move_edit=node->get_navigation_polygon()->get_outline(closest_outline);
- edited_point=closest_idx;
- edited_outline=closest_outline;
- edited_point_pos=xform.affine_inverse().xform(closest_pos);
+ pre_move_edit = node->get_navigation_polygon()->get_outline(closest_outline);
+ edited_point = closest_idx;
+ edited_outline = closest_outline;
+ edited_point_pos = xform.affine_inverse().xform(closest_pos);
canvas_item_editor->get_viewport_control()->update();
return true;
}
}
} else {
- if (edited_point!=-1) {
+ if (edited_point != -1) {
//apply
PoolVector<Vector2> poly = node->get_navigation_polygon()->get_outline(edited_outline);
- ERR_FAIL_INDEX_V(edited_point,poly.size(),false);
- poly.set(edited_point,edited_point_pos);
+ ERR_FAIL_INDEX_V(edited_point, poly.size(), false);
+ poly.set(edited_point, edited_point_pos);
undo_redo->create_action(TTR("Edit Poly"));
- undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"set_outline",edited_outline,poly);
- undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"set_outline",edited_outline,pre_move_edit);
- undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
- undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node->get_navigation_polygon().ptr(), "set_outline", edited_outline, poly);
+ undo_redo->add_undo_method(node->get_navigation_polygon().ptr(), "set_outline", edited_outline, pre_move_edit);
+ undo_redo->add_do_method(node->get_navigation_polygon().ptr(), "make_polygons_from_outlines");
+ undo_redo->add_undo_method(node->get_navigation_polygon().ptr(), "make_polygons_from_outlines");
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
- edited_point=-1;
+ edited_point = -1;
return true;
}
}
- } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
+ } else if (mb.button_index == BUTTON_RIGHT && mb.pressed && edited_point == -1) {
- int closest_outline=-1;
- int closest_idx=-1;
+ int closest_outline = -1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
-
- for(int j=0;j<node->get_navigation_polygon()->get_outline_count();j++) {
-
+ real_t closest_dist = 1e10;
- PoolVector<Vector2> points=node->get_navigation_polygon()->get_outline(j);
+ for (int j = 0; j < node->get_navigation_polygon()->get_outline_count(); j++) {
- int pc=points.size();
- PoolVector<Vector2>::Read poly=points.read();
+ PoolVector<Vector2> points = node->get_navigation_polygon()->get_outline(j);
- for(int i=0;i<pc;i++) {
+ int pc = points.size();
+ PoolVector<Vector2>::Read poly = points.read();
+ for (int i = 0; i < pc; i++) {
- Vector2 cp =xform.xform(poly[i]);
+ Vector2 cp = xform.xform(poly[i]);
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_outline=j;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_outline = j;
+ closest_idx = i;
}
}
}
- if (closest_idx>=0) {
-
+ if (closest_idx >= 0) {
PoolVector<Vector2> poly = node->get_navigation_polygon()->get_outline(closest_outline);
- if (poly.size()>3) {
+ if (poly.size() > 3) {
undo_redo->create_action(TTR("Edit Poly (Remove Point)"));
- undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"set_outline",closest_outline,poly);
+ undo_redo->add_undo_method(node->get_navigation_polygon().ptr(), "set_outline", closest_outline, poly);
poly.remove(closest_idx);
- undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"set_outline",closest_outline,poly);
- undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
- undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node->get_navigation_polygon().ptr(), "set_outline", closest_outline, poly);
+ undo_redo->add_do_method(node->get_navigation_polygon().ptr(), "make_polygons_from_outlines");
+ undo_redo->add_undo_method(node->get_navigation_polygon().ptr(), "make_polygons_from_outlines");
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
} else {
undo_redo->create_action(TTR("Remove Poly And Point"));
- undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"add_outline_at_index",poly,closest_outline);
+ undo_redo->add_undo_method(node->get_navigation_polygon().ptr(), "add_outline_at_index", poly, closest_outline);
poly.remove(closest_idx);
- undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"remove_outline",closest_outline);
- undo_redo->add_do_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
- undo_redo->add_undo_method(node->get_navigation_polygon().ptr(),"make_polygons_from_outlines");
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node->get_navigation_polygon().ptr(), "remove_outline", closest_outline);
+ undo_redo->add_do_method(node->get_navigation_polygon().ptr(), "make_polygons_from_outlines");
+ undo_redo->add_undo_method(node->get_navigation_polygon().ptr(), "make_polygons_from_outlines");
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
-
}
return true;
}
}
-
-
} break;
}
-
-
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_event.mouse_motion;
+ const InputEventMouseMotion &mm = p_event.mouse_motion;
- if (edited_point!=-1 && (wip_active || mm.button_mask&BUTTON_MASK_LEFT)) {
+ if (edited_point != -1 && (wip_active || mm.button_mask & BUTTON_MASK_LEFT)) {
- Vector2 gpoint = Point2(mm.x,mm.y);
+ Vector2 gpoint = Point2(mm.x, mm.y);
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
- cpoint=canvas_item_editor->snap_point(cpoint);
+ cpoint = canvas_item_editor->snap_point(cpoint);
edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint);
canvas_item_editor->get_viewport_control()->update();
-
}
} break;
@@ -409,105 +379,96 @@ void NavigationPolygonEditor::_canvas_draw() {
Control *vpc = canvas_item_editor->get_viewport_control();
if (node->get_navigation_polygon().is_null())
- return;
+ return;
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- Ref<Texture> handle= get_icon("EditorHandle","EditorIcons");
-
-
+ Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons");
- for(int j=-1;j<node->get_navigation_polygon()->get_outline_count();j++) {
+ for (int j = -1; j < node->get_navigation_polygon()->get_outline_count(); j++) {
Vector<Vector2> poly;
- if (wip_active && j==edited_outline) {
- poly=wip;
+ if (wip_active && j == edited_outline) {
+ poly = wip;
} else {
- if (j==-1)
+ if (j == -1)
continue;
poly = Variant(node->get_navigation_polygon()->get_outline(j));
}
- for(int i=0;i<poly.size();i++) {
+ for (int i = 0; i < poly.size(); i++) {
-
- Vector2 p,p2;
- p = (j==edited_outline && i==edited_point) ? edited_point_pos : poly[i];
- if (j==edited_outline && ((wip_active && i==poly.size()-1) || (((i+1)%poly.size())==edited_point)))
- p2=edited_point_pos;
+ Vector2 p, p2;
+ p = (j == edited_outline && i == edited_point) ? edited_point_pos : poly[i];
+ if (j == edited_outline && ((wip_active && i == poly.size() - 1) || (((i + 1) % poly.size()) == edited_point)))
+ p2 = edited_point_pos;
else
- p2 = poly[(i+1)%poly.size()];
+ p2 = poly[(i + 1) % poly.size()];
Vector2 point = xform.xform(p);
Vector2 next_point = xform.xform(p2);
- Color col=Color(1,0.3,0.1,0.8);
- vpc->draw_line(point,next_point,col,2);
- vpc->draw_texture(handle,point-handle->get_size()*0.5);
+ Color col = Color(1, 0.3, 0.1, 0.8);
+ vpc->draw_line(point, next_point, col, 2);
+ vpc->draw_texture(handle, point - handle->get_size() * 0.5);
}
}
}
-
-
void NavigationPolygonEditor::edit(Node *p_collision_polygon) {
if (!canvas_item_editor) {
- canvas_item_editor=CanvasItemEditor::get_singleton();
+ canvas_item_editor = CanvasItemEditor::get_singleton();
}
if (p_collision_polygon) {
- node=p_collision_polygon->cast_to<NavigationPolygonInstance>();
- if (!canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->connect("draw",this,"_canvas_draw");
+ node = p_collision_polygon->cast_to<NavigationPolygonInstance>();
+ if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
wip.clear();
- wip_active=false;
- edited_point=-1;
+ wip_active = false;
+ edited_point = -1;
canvas_item_editor->get_viewport_control()->update();
} else {
- node=NULL;
-
- if (canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->disconnect("draw",this,"_canvas_draw");
+ node = NULL;
+ if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw");
}
-
}
void NavigationPolygonEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_menu_option"),&NavigationPolygonEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_canvas_draw"),&NavigationPolygonEditor::_canvas_draw);
- ClassDB::bind_method(D_METHOD("_node_removed"),&NavigationPolygonEditor::_node_removed);
- ClassDB::bind_method(D_METHOD("_create_nav"),&NavigationPolygonEditor::_create_nav);
-
+ ClassDB::bind_method(D_METHOD("_menu_option"), &NavigationPolygonEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"), &NavigationPolygonEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_node_removed"), &NavigationPolygonEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_create_nav"), &NavigationPolygonEditor::_create_nav);
}
NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) {
- node=NULL;
- canvas_item_editor=NULL;
- editor=p_editor;
+ node = NULL;
+ canvas_item_editor = NULL;
+ editor = p_editor;
undo_redo = editor->get_undo_redo();
- add_child( memnew( VSeparator ));
- button_create = memnew( ToolButton );
+ add_child(memnew(VSeparator));
+ button_create = memnew(ToolButton);
add_child(button_create);
- button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE));
+ button_create->connect("pressed", this, "_menu_option", varray(MODE_CREATE));
button_create->set_toggle_mode(true);
button_create->set_tooltip(TTR("Create a new polygon from scratch."));
- button_edit = memnew( ToolButton );
+ button_edit = memnew(ToolButton);
add_child(button_edit);
- button_edit->connect("pressed",this,"_menu_option",varray(MODE_EDIT));
+ button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT));
button_edit->set_toggle_mode(true);
- button_edit->set_tooltip(TTR("Edit existing polygon:")+"\n"+TTR("LMB: Move Point.")+"\n"+TTR("Ctrl+LMB: Split Segment.")+"\n"+TTR("RMB: Erase Point."));
- create_nav = memnew( ConfirmationDialog );
+ button_edit->set_tooltip(TTR("Edit existing polygon:") + "\n" + TTR("LMB: Move Point.") + "\n" + TTR("Ctrl+LMB: Split Segment.") + "\n" + TTR("RMB: Erase Point."));
+ create_nav = memnew(ConfirmationDialog);
add_child(create_nav);
create_nav->get_ok()->set_text(TTR("Create"));
-
- //add_constant_override("separation",0);
+//add_constant_override("separation",0);
#if 0
options = memnew( MenuButton );
@@ -519,12 +480,10 @@ NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) {
#endif
mode = MODE_EDIT;
- wip_active=false;
- edited_outline=-1;
-
+ wip_active = false;
+ edited_outline = -1;
}
-
void NavigationPolygonEditorPlugin::edit(Object *p_object) {
collision_polygon_editor->edit(p_object->cast_to<Node>());
@@ -544,23 +503,16 @@ void NavigationPolygonEditorPlugin::make_visible(bool p_visible) {
collision_polygon_editor->hide();
collision_polygon_editor->edit(NULL);
}
-
}
NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- collision_polygon_editor = memnew( NavigationPolygonEditor(p_node) );
+ editor = p_node;
+ collision_polygon_editor = memnew(NavigationPolygonEditor(p_node));
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
collision_polygon_editor->hide();
-
-
-
}
-
-NavigationPolygonEditorPlugin::~NavigationPolygonEditorPlugin()
-{
+NavigationPolygonEditorPlugin::~NavigationPolygonEditorPlugin() {
}
-
diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h
index 0d5e67e352..ba18756869 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.h
+++ b/editor/plugins/navigation_polygon_editor_plugin.h
@@ -29,13 +29,11 @@
#ifndef NAVIGATIONPOLYGONEDITORPLUGIN_H
#define NAVIGATIONPOLYGONEDITORPLUGIN_H
-
-
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/2d/navigation_polygon.h"
-#include "scene/gui/tool_button.h"
#include "scene/gui/button_group.h"
+#include "scene/gui/tool_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -44,7 +42,7 @@ class CanvasItemEditor;
class NavigationPolygonEditor : public HBoxContainer {
- GDCLASS(NavigationPolygonEditor, HBoxContainer );
+ GDCLASS(NavigationPolygonEditor, HBoxContainer);
UndoRedo *undo_redo;
enum Mode {
@@ -74,7 +72,6 @@ class NavigationPolygonEditor : public HBoxContainer {
Vector<Vector2> wip;
bool wip_active;
-
void _wip_close();
void _canvas_draw();
void _create_nav();
@@ -85,23 +82,22 @@ protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
-public:
- bool forward_gui_input(const InputEvent& p_event);
+public:
+ bool forward_gui_input(const InputEvent &p_event);
void edit(Node *p_collision_polygon);
NavigationPolygonEditor(EditorNode *p_editor);
};
class NavigationPolygonEditorPlugin : public EditorPlugin {
- GDCLASS( NavigationPolygonEditorPlugin, EditorPlugin );
+ GDCLASS(NavigationPolygonEditorPlugin, EditorPlugin);
NavigationPolygonEditor *collision_polygon_editor;
EditorNode *editor;
public:
-
- virtual bool forward_canvas_gui_input(const Transform2D& p_canvas_xform,const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
+ virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
virtual String get_name() const { return "NavigationPolygonInstance"; }
bool has_main_screen() const { return false; }
@@ -111,8 +107,6 @@ public:
NavigationPolygonEditorPlugin(EditorNode *p_node);
~NavigationPolygonEditorPlugin();
-
};
-
#endif // NAVIGATIONPOLYGONEDITORPLUGIN_H
diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp
index 1efdbe9e68..94644cd410 100644
--- a/editor/plugins/particles_2d_editor_plugin.cpp
+++ b/editor/plugins/particles_2d_editor_plugin.cpp
@@ -35,9 +35,9 @@
void Particles2DEditorPlugin::edit(Object *p_object) {
if (p_object) {
- particles=p_object->cast_to<Particles2D>();
+ particles = p_object->cast_to<Particles2D>();
} else {
- particles=NULL;
+ particles = NULL;
}
}
@@ -55,145 +55,135 @@ void Particles2DEditorPlugin::make_visible(bool p_visible) {
toolbar->hide();
}
-
}
-void Particles2DEditorPlugin::_file_selected(const String& p_file) {
+void Particles2DEditorPlugin::_file_selected(const String &p_file) {
- print_line("file: "+p_file);
+ print_line("file: " + p_file);
- int epc=epoints->get_value();
+ int epc = epoints->get_value();
Image img;
- Error err = ImageLoader::load_image(p_file,&img);
- ERR_EXPLAIN(TTR("Error loading image:")+" "+p_file);
- ERR_FAIL_COND(err!=OK);
+ Error err = ImageLoader::load_image(p_file, &img);
+ ERR_EXPLAIN(TTR("Error loading image:") + " " + p_file);
+ ERR_FAIL_COND(err != OK);
img.convert(Image::FORMAT_LA8);
- ERR_FAIL_COND(img.get_format()!=Image::FORMAT_LA8);
- Size2i s = Size2(img.get_width(),img.get_height());
- ERR_FAIL_COND(s.width==0 || s.height==0);
+ ERR_FAIL_COND(img.get_format() != Image::FORMAT_LA8);
+ Size2i s = Size2(img.get_width(), img.get_height());
+ ERR_FAIL_COND(s.width == 0 || s.height == 0);
PoolVector<uint8_t> data = img.get_data();
PoolVector<uint8_t>::Read r = data.read();
Vector<Point2i> valid_positions;
- valid_positions.resize(s.width*s.height);
- int vpc=0;
-
+ valid_positions.resize(s.width * s.height);
+ int vpc = 0;
- for(int i=0;i<s.width*s.height;i++) {
+ for (int i = 0; i < s.width * s.height; i++) {
- uint8_t a = r[i*2+1];
- if (a>128) {
- valid_positions[vpc++]=Point2i(i%s.width,i/s.width);
+ uint8_t a = r[i * 2 + 1];
+ if (a > 128) {
+ valid_positions[vpc++] = Point2i(i % s.width, i / s.width);
}
}
valid_positions.resize(vpc);
ERR_EXPLAIN(TTR("No pixels with transparency > 128 in image.."));
- ERR_FAIL_COND(valid_positions.size()==0);
+ ERR_FAIL_COND(valid_positions.size() == 0);
PoolVector<Point2> epoints;
epoints.resize(epc);
PoolVector<Point2>::Write w = epoints.write();
- Size2 extents = Size2(img.get_width()*0.5,img.get_height()*0.5);
+ Size2 extents = Size2(img.get_width() * 0.5, img.get_height() * 0.5);
- for(int i=0;i<epc;i++) {
+ for (int i = 0; i < epc; i++) {
- Point2 p = valid_positions[Math::rand()%vpc];
- p-=s/2;
- w[i]=p/extents;
+ Point2 p = valid_positions[Math::rand() % vpc];
+ p -= s / 2;
+ w[i] = p / extents;
}
w = PoolVector<Point2>::Write();
undo_redo->create_action(TTR("Set Emission Mask"));
- undo_redo->add_do_method(particles,"set_emission_points",epoints);
- undo_redo->add_do_method(particles,"set_emission_half_extents",extents);
- undo_redo->add_undo_method(particles,"set_emission_points",particles->get_emission_points());
- undo_redo->add_undo_method(particles,"set_emission_half_extents",particles->get_emission_half_extents());
+ undo_redo->add_do_method(particles, "set_emission_points", epoints);
+ undo_redo->add_do_method(particles, "set_emission_half_extents", extents);
+ undo_redo->add_undo_method(particles, "set_emission_points", particles->get_emission_points());
+ undo_redo->add_undo_method(particles, "set_emission_half_extents", particles->get_emission_half_extents());
undo_redo->commit_action();
-
}
void Particles2DEditorPlugin::_menu_callback(int p_idx) {
- switch(p_idx) {
+ switch (p_idx) {
case MENU_LOAD_EMISSION_MASK: {
-
file->popup_centered_ratio();
} break;
case MENU_CLEAR_EMISSION_MASK: {
undo_redo->create_action(TTR("Clear Emission Mask"));
- undo_redo->add_do_method(particles,"set_emission_points",PoolVector<Vector2>());
- undo_redo->add_undo_method(particles,"set_emission_points",particles->get_emission_points());
+ undo_redo->add_do_method(particles, "set_emission_points", PoolVector<Vector2>());
+ undo_redo->add_undo_method(particles, "set_emission_points", particles->get_emission_points());
undo_redo->commit_action();
} break;
}
-
}
-
void Particles2DEditorPlugin::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- menu->get_popup()->connect("id_pressed",this,"_menu_callback");
- menu->set_icon(menu->get_popup()->get_icon("Particles2D","EditorIcons"));
- file->connect("file_selected",this,"_file_selected");
+ menu->get_popup()->connect("id_pressed", this, "_menu_callback");
+ menu->set_icon(menu->get_popup()->get_icon("Particles2D", "EditorIcons"));
+ file->connect("file_selected", this, "_file_selected");
}
}
void Particles2DEditorPlugin::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_menu_callback"),&Particles2DEditorPlugin::_menu_callback);
- ClassDB::bind_method(D_METHOD("_file_selected"),&Particles2DEditorPlugin::_file_selected);
+ ClassDB::bind_method(D_METHOD("_menu_callback"), &Particles2DEditorPlugin::_menu_callback);
+ ClassDB::bind_method(D_METHOD("_file_selected"), &Particles2DEditorPlugin::_file_selected);
}
-
-
Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
- particles=NULL;
- editor=p_node;
- undo_redo=editor->get_undo_redo();
+ particles = NULL;
+ editor = p_node;
+ undo_redo = editor->get_undo_redo();
- toolbar = memnew( HBoxContainer );
+ toolbar = memnew(HBoxContainer);
add_control_to_container(CONTAINER_CANVAS_EDITOR_MENU, toolbar);
toolbar->hide();
- toolbar->add_child( memnew( VSeparator ) );
+ toolbar->add_child(memnew(VSeparator));
- menu = memnew( MenuButton );
- menu->get_popup()->add_item(TTR("Load Emission Mask"),MENU_LOAD_EMISSION_MASK);
- menu->get_popup()->add_item(TTR("Clear Emission Mask"),MENU_CLEAR_EMISSION_MASK);
+ menu = memnew(MenuButton);
+ menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK);
+ menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK);
menu->set_text("Particles");
toolbar->add_child(menu);
- file = memnew( EditorFileDialog );
+ file = memnew(EditorFileDialog);
List<String> ext;
ImageLoader::get_recognized_extensions(&ext);
- for(List<String>::Element *E=ext.front();E;E=E->next()) {
- file->add_filter("*."+E->get()+"; "+E->get().to_upper());
+ for (List<String>::Element *E = ext.front(); E; E = E->next()) {
+ file->add_filter("*." + E->get() + "; " + E->get().to_upper());
}
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
toolbar->add_child(file);
- epoints = memnew( SpinBox );
+ epoints = memnew(SpinBox);
epoints->set_min(1);
epoints->set_max(8192);
epoints->set_step(1);
epoints->set_value(512);
- file->get_vbox()->add_margin_child(TTR("Generated Point Count:"),epoints);
+ file->get_vbox()->add_margin_child(TTR("Generated Point Count:"), epoints);
}
-Particles2DEditorPlugin::~Particles2DEditorPlugin()
-{
+Particles2DEditorPlugin::~Particles2DEditorPlugin() {
}
-
diff --git a/editor/plugins/particles_2d_editor_plugin.h b/editor/plugins/particles_2d_editor_plugin.h
index ea71c739f3..56122c4354 100644
--- a/editor/plugins/particles_2d_editor_plugin.h
+++ b/editor/plugins/particles_2d_editor_plugin.h
@@ -29,17 +29,17 @@
#ifndef PARTICLES_2D_EDITOR_PLUGIN_H
#define PARTICLES_2D_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/2d/collision_polygon_2d.h"
+#include "scene/2d/particles_2d.h"
#include "scene/gui/box_container.h"
#include "scene/gui/file_dialog.h"
-#include "scene/2d/particles_2d.h"
class Particles2DEditorPlugin : public EditorPlugin {
- GDCLASS( Particles2DEditorPlugin, EditorPlugin );
+ GDCLASS(Particles2DEditorPlugin, EditorPlugin);
enum {
@@ -58,15 +58,14 @@ class Particles2DEditorPlugin : public EditorPlugin {
SpinBox *epoints;
UndoRedo *undo_redo;
- void _file_selected(const String& p_file);
+ void _file_selected(const String &p_file);
void _menu_callback(int p_idx);
+
protected:
void _notification(int p_what);
static void _bind_methods();
public:
-
-
virtual String get_name() const { return "Particles2D"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -75,8 +74,6 @@ public:
Particles2DEditorPlugin(EditorNode *p_node);
~Particles2DEditorPlugin();
-
};
-
#endif // PARTICLES_2D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp
index 4ce1f5eb54..fd26674a0e 100644
--- a/editor/plugins/particles_editor_plugin.cpp
+++ b/editor/plugins/particles_editor_plugin.cpp
@@ -29,9 +29,9 @@
#if 0
#include "particles_editor_plugin.h"
+#include "editor/plugins/spatial_editor_plugin.h"
#include "io/resource_loader.h"
#include "servers/visual/particle_system_sw.h"
-#include "editor/plugins/spatial_editor_plugin.h"
void ParticlesEditor::_node_removed(Node *p_node) {
@@ -457,5 +457,4 @@ ParticlesEditorPlugin::~ParticlesEditorPlugin()
{
}
-
#endif
diff --git a/editor/plugins/particles_editor_plugin.h b/editor/plugins/particles_editor_plugin.h
index 06134ddef2..420e20d641 100644
--- a/editor/plugins/particles_editor_plugin.h
+++ b/editor/plugins/particles_editor_plugin.h
@@ -29,8 +29,8 @@
#ifndef PARTICLES_EDITOR_PLUGIN_H
#define PARTICLES_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/3d/particles.h"
#include "scene/gui/spin_box.h"
diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp
index 00b026e25b..36605c118f 100644
--- a/editor/plugins/path_2d_editor_plugin.cpp
+++ b/editor/plugins/path_2d_editor_plugin.cpp
@@ -29,12 +29,12 @@
#include "path_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
-#include "os/file_access.h"
#include "editor/editor_settings.h"
+#include "os/file_access.h"
#include "os/keyboard.h"
void Path2DEditor::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
@@ -43,26 +43,21 @@ void Path2DEditor::_notification(int p_what) {
//set_pressed_button(button_edit);
//button_edit->set_pressed(true);
-
} break;
case NOTIFICATION_FIXED_PROCESS: {
-
} break;
}
-
}
void Path2DEditor::_node_removed(Node *p_node) {
- if(p_node==node) {
- node=NULL;
+ if (p_node == node) {
+ node = NULL;
hide();
}
-
}
-
-bool Path2DEditor::forward_gui_input(const InputEvent& p_event) {
+bool Path2DEditor::forward_gui_input(const InputEvent &p_event) {
if (!node)
return false;
@@ -73,160 +68,151 @@ bool Path2DEditor::forward_gui_input(const InputEvent& p_event) {
if (!node->get_curve().is_valid())
return false;
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_event.mouse_button;
+ const InputEventMouseButton &mb = p_event.mouse_button;
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- Vector2 gpoint = Point2(mb.x,mb.y);
- Vector2 cpoint = !mb.mod.alt? canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint))
- : node->get_global_transform().affine_inverse().xform( canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)) );
+ Vector2 gpoint = Point2(mb.x, mb.y);
+ Vector2 cpoint = !mb.mod.alt ? canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint)) : node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)));
//first check if a point is to be added (segment split)
- real_t grab_treshold=EDITOR_DEF("editors/poly_editor/point_grab_radius",8);
-
-
+ real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
// Test move point!!
- if ( mb.pressed && action==ACTION_NONE ) {
+ if (mb.pressed && action == ACTION_NONE) {
Ref<Curve2D> curve = node->get_curve();
- for(int i=0;i<curve->get_point_count();i++) {
+ for (int i = 0; i < curve->get_point_count(); i++) {
- bool pointunder=false;
+ bool pointunder = false;
{
- Point2 p = xform.xform( curve->get_point_pos(i) );
- if (gpoint.distance_to(p) < grab_treshold ) {
+ Point2 p = xform.xform(curve->get_point_pos(i));
+ if (gpoint.distance_to(p) < grab_treshold) {
- if (mb.button_index==BUTTON_LEFT && !mb.mod.shift && mode==MODE_EDIT) {
+ if (mb.button_index == BUTTON_LEFT && !mb.mod.shift && mode == MODE_EDIT) {
- action=ACTION_MOVING_POINT;
- action_point=i;
- moving_from=curve->get_point_pos(i);
- moving_screen_from=gpoint;
+ action = ACTION_MOVING_POINT;
+ action_point = i;
+ moving_from = curve->get_point_pos(i);
+ moving_screen_from = gpoint;
return true;
- } else if ((mb.button_index==BUTTON_RIGHT && mode==MODE_EDIT) || (mb.button_index==BUTTON_LEFT && mode==MODE_DELETE)) {
+ } else if ((mb.button_index == BUTTON_RIGHT && mode == MODE_EDIT) || (mb.button_index == BUTTON_LEFT && mode == MODE_DELETE)) {
undo_redo->create_action(TTR("Remove Point from Curve"));
- undo_redo->add_do_method(curve.ptr(),"remove_point",i);
- undo_redo->add_undo_method(curve.ptr(),"add_point",curve->get_point_pos(i),curve->get_point_in(i),curve->get_point_out(i),i);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(curve.ptr(), "remove_point", i);
+ undo_redo->add_undo_method(curve.ptr(), "add_point", curve->get_point_pos(i), curve->get_point_in(i), curve->get_point_out(i), i);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
return true;
} else
- pointunder=true;
+ pointunder = true;
}
}
- if (mb.button_index==BUTTON_LEFT && i<(curve->get_point_count()-1)) {
- Point2 p = xform.xform( curve->get_point_pos(i)+curve->get_point_out(i) );
- if (gpoint.distance_to(p) < grab_treshold && (mode == MODE_EDIT || mode==MODE_EDIT_CURVE) ) {
+ if (mb.button_index == BUTTON_LEFT && i < (curve->get_point_count() - 1)) {
+ Point2 p = xform.xform(curve->get_point_pos(i) + curve->get_point_out(i));
+ if (gpoint.distance_to(p) < grab_treshold && (mode == MODE_EDIT || mode == MODE_EDIT_CURVE)) {
- action=ACTION_MOVING_OUT;
- action_point=i;
- moving_from=curve->get_point_out(i);
- moving_screen_from=gpoint;
+ action = ACTION_MOVING_OUT;
+ action_point = i;
+ moving_from = curve->get_point_out(i);
+ moving_screen_from = gpoint;
return true;
}
}
- if (mb.button_index==BUTTON_LEFT && i>0) {
- Point2 p = xform.xform( curve->get_point_pos(i)+curve->get_point_in(i) );
- if (gpoint.distance_to(p) < grab_treshold && (mode == MODE_EDIT || mode==MODE_EDIT_CURVE)) {
+ if (mb.button_index == BUTTON_LEFT && i > 0) {
+ Point2 p = xform.xform(curve->get_point_pos(i) + curve->get_point_in(i));
+ if (gpoint.distance_to(p) < grab_treshold && (mode == MODE_EDIT || mode == MODE_EDIT_CURVE)) {
- action=ACTION_MOVING_IN;
- action_point=i;
- moving_from=curve->get_point_in(i);
- moving_screen_from=gpoint;
+ action = ACTION_MOVING_IN;
+ action_point = i;
+ moving_from = curve->get_point_in(i);
+ moving_screen_from = gpoint;
return true;
}
}
if (pointunder)
return true;
-
}
-
}
// Test add point in empty space!
- if ( mb.pressed && mb.button_index==BUTTON_LEFT && ((mb.mod.command && mode == MODE_EDIT) || mode == MODE_CREATE)) {
+ if (mb.pressed && mb.button_index == BUTTON_LEFT && ((mb.mod.command && mode == MODE_EDIT) || mode == MODE_CREATE)) {
Ref<Curve2D> curve = node->get_curve();
undo_redo->create_action(TTR("Add Point to Curve"));
- undo_redo->add_do_method(curve.ptr(),"add_point",cpoint);
- undo_redo->add_undo_method(curve.ptr(),"remove_point",curve->get_point_count());
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(curve.ptr(), "add_point", cpoint);
+ undo_redo->add_undo_method(curve.ptr(), "remove_point", curve->get_point_count());
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
- action=ACTION_MOVING_POINT;
- action_point=curve->get_point_count()-1;
- moving_from=curve->get_point_pos(action_point);
- moving_screen_from=gpoint;
+ action = ACTION_MOVING_POINT;
+ action_point = curve->get_point_count() - 1;
+ moving_from = curve->get_point_pos(action_point);
+ moving_screen_from = gpoint;
canvas_item_editor->get_viewport_control()->update();
return true;
}
- if ( !mb.pressed && mb.button_index==BUTTON_LEFT && action!=ACTION_NONE) {
-
+ if (!mb.pressed && mb.button_index == BUTTON_LEFT && action != ACTION_NONE) {
Ref<Curve2D> curve = node->get_curve();
Vector2 new_pos = moving_from + xform.affine_inverse().basis_xform(gpoint - moving_screen_from);
- switch(action) {
+ switch (action) {
case ACTION_MOVING_POINT: {
-
undo_redo->create_action(TTR("Move Point in Curve"));
- undo_redo->add_do_method(curve.ptr(),"set_point_pos",action_point,cpoint);
- undo_redo->add_undo_method(curve.ptr(),"set_point_pos",action_point,moving_from);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(curve.ptr(), "set_point_pos", action_point, cpoint);
+ undo_redo->add_undo_method(curve.ptr(), "set_point_pos", action_point, moving_from);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
} break;
case ACTION_MOVING_IN: {
undo_redo->create_action(TTR("Move In-Control in Curve"));
- undo_redo->add_do_method(curve.ptr(),"set_point_in",action_point,new_pos);
- undo_redo->add_undo_method(curve.ptr(),"set_point_in",action_point,moving_from);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, new_pos);
+ undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, moving_from);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
} break;
case ACTION_MOVING_OUT: {
undo_redo->create_action(TTR("Move Out-Control in Curve"));
- undo_redo->add_do_method(curve.ptr(),"set_point_out",action_point,new_pos);
- undo_redo->add_undo_method(curve.ptr(),"set_point_out",action_point,moving_from);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, new_pos);
+ undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, moving_from);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
} break;
-
}
- action=ACTION_NONE;
+ action = ACTION_NONE;
return true;
}
-
#if 0
switch(mode) {
@@ -411,44 +397,40 @@ bool Path2DEditor::forward_gui_input(const InputEvent& p_event) {
} break;
}
-
#endif
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_event.mouse_motion;
-
+ const InputEventMouseMotion &mm = p_event.mouse_motion;
- if ( action!=ACTION_NONE) {
+ if (action != ACTION_NONE) {
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- Vector2 gpoint = Point2(mm.x,mm.y);
- Vector2 cpoint = !mm.mod.alt? canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint))
- : node->get_global_transform().affine_inverse().xform( canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)) );
+ Vector2 gpoint = Point2(mm.x, mm.y);
+ Vector2 cpoint = !mm.mod.alt ? canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint)) : node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)));
Ref<Curve2D> curve = node->get_curve();
Vector2 new_pos = moving_from + xform.affine_inverse().basis_xform(gpoint - moving_screen_from);
- switch(action) {
+ switch (action) {
case ACTION_MOVING_POINT: {
- curve->set_point_pos(action_point,cpoint);
+ curve->set_point_pos(action_point, cpoint);
} break;
case ACTION_MOVING_IN: {
- curve->set_point_in(action_point,new_pos);
+ curve->set_point_in(action_point, new_pos);
} break;
case ACTION_MOVING_OUT: {
- curve->set_point_out(action_point,new_pos);
+ curve->set_point_out(action_point, new_pos);
} break;
}
-
canvas_item_editor->get_viewport_control()->update();
return true;
}
@@ -473,16 +455,16 @@ bool Path2DEditor::forward_gui_input(const InputEvent& p_event) {
void Path2DEditor::_canvas_draw() {
if (!node)
- return ;
+ return;
if (!node->is_visible_in_tree())
return;
if (!node->get_curve().is_valid())
- return ;
+ return;
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- Ref<Texture> handle= get_icon("EditorHandle","EditorIcons");
+ Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons");
Size2 handle_size = handle->get_size();
Ref<Curve2D> curve = node->get_curve();
@@ -490,27 +472,23 @@ void Path2DEditor::_canvas_draw() {
int len = curve->get_point_count();
Control *vpc = canvas_item_editor->get_viewport_control();
-
- for(int i=0;i<len;i++) {
-
+ for (int i = 0; i < len; i++) {
Vector2 point = xform.xform(curve->get_point_pos(i));
- vpc->draw_texture_rect(handle,Rect2(point-handle_size*0.5,handle_size),false,Color(1,1,1,1));
+ vpc->draw_texture_rect(handle, Rect2(point - handle_size * 0.5, handle_size), false, Color(1, 1, 1, 1));
- if (i<len-1) {
- Vector2 pointout = xform.xform(curve->get_point_pos(i)+curve->get_point_out(i));
- vpc->draw_line(point,pointout,Color(0.5,0.5,1.0,0.8),1.0);
- vpc->draw_texture_rect(handle, Rect2(pointout-handle_size*0.5,handle_size),false,Color(1,0.5,1,0.3));
+ if (i < len - 1) {
+ Vector2 pointout = xform.xform(curve->get_point_pos(i) + curve->get_point_out(i));
+ vpc->draw_line(point, pointout, Color(0.5, 0.5, 1.0, 0.8), 1.0);
+ vpc->draw_texture_rect(handle, Rect2(pointout - handle_size * 0.5, handle_size), false, Color(1, 0.5, 1, 0.3));
}
- if (i>0) {
- Vector2 pointin = xform.xform(curve->get_point_pos(i)+curve->get_point_in(i));
- vpc->draw_line(point,pointin,Color(0.5,0.5,1.0,0.8),1.0);
- vpc->draw_texture_rect(handle, Rect2(pointin-handle_size*0.5,handle_size),false,Color(1,0.5,1,0.3));
+ if (i > 0) {
+ Vector2 pointin = xform.xform(curve->get_point_pos(i) + curve->get_point_in(i));
+ vpc->draw_line(point, pointin, Color(0.5, 0.5, 1.0, 0.8), 1.0);
+ vpc->draw_texture_rect(handle, Rect2(pointin - handle_size * 0.5, handle_size), false, Color(1, 0.5, 1, 0.3));
}
-
}
-
}
void Path2DEditor::_node_visibility_changed() {
@@ -523,101 +501,98 @@ void Path2DEditor::_node_visibility_changed() {
void Path2DEditor::edit(Node *p_path2d) {
if (!canvas_item_editor) {
- canvas_item_editor=CanvasItemEditor::get_singleton();
+ canvas_item_editor = CanvasItemEditor::get_singleton();
}
if (p_path2d) {
- node=p_path2d->cast_to<Path2D>();
- if (!canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->connect("draw",this,"_canvas_draw");
+ node = p_path2d->cast_to<Path2D>();
+ if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
if (!node->is_connected("visibility_changed", this, "_node_visibility_changed"))
node->connect("visibility_changed", this, "_node_visibility_changed");
-
} else {
- if (canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->disconnect("draw",this,"_canvas_draw");
+ if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw");
// node may have been deleted at this point
if (node && node->is_connected("visibility_changed", this, "_node_visibility_changed"))
node->disconnect("visibility_changed", this, "_node_visibility_changed");
- node=NULL;
+ node = NULL;
}
-
}
void Path2DEditor::_bind_methods() {
//ClassDB::bind_method(D_METHOD("_menu_option"),&Path2DEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_canvas_draw"),&Path2DEditor::_canvas_draw);
- ClassDB::bind_method(D_METHOD("_node_visibility_changed"),&Path2DEditor::_node_visibility_changed);
- ClassDB::bind_method(D_METHOD("_mode_selected"),&Path2DEditor::_mode_selected);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"), &Path2DEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_node_visibility_changed"), &Path2DEditor::_node_visibility_changed);
+ ClassDB::bind_method(D_METHOD("_mode_selected"), &Path2DEditor::_mode_selected);
}
void Path2DEditor::_mode_selected(int p_mode) {
- if (p_mode==MODE_CREATE) {
+ if (p_mode == MODE_CREATE) {
curve_create->set_pressed(true);
curve_edit->set_pressed(false);
curve_edit_curve->set_pressed(false);
curve_del->set_pressed(false);
- } else if (p_mode==MODE_EDIT) {
+ } else if (p_mode == MODE_EDIT) {
curve_create->set_pressed(false);
curve_edit->set_pressed(true);
curve_edit_curve->set_pressed(false);
curve_del->set_pressed(false);
- } else if (p_mode==MODE_EDIT_CURVE) {
+ } else if (p_mode == MODE_EDIT_CURVE) {
curve_create->set_pressed(false);
curve_edit->set_pressed(false);
curve_edit_curve->set_pressed(true);
curve_del->set_pressed(false);
- } else if (p_mode==MODE_DELETE) {
+ } else if (p_mode == MODE_DELETE) {
curve_create->set_pressed(false);
curve_edit->set_pressed(false);
curve_edit_curve->set_pressed(false);
curve_del->set_pressed(true);
- } else if (p_mode==ACTION_CLOSE) {
+ } else if (p_mode == ACTION_CLOSE) {
//?
if (!node->get_curve().is_valid())
- return ;
- if (node->get_curve()->get_point_count()<3)
+ return;
+ if (node->get_curve()->get_point_count() < 3)
return;
Vector2 begin = node->get_curve()->get_point_pos(0);
- Vector2 end = node->get_curve()->get_point_pos( node->get_curve()->get_point_count() -1 );
- if (begin.distance_to(end)<CMP_EPSILON)
+ Vector2 end = node->get_curve()->get_point_pos(node->get_curve()->get_point_count() - 1);
+ if (begin.distance_to(end) < CMP_EPSILON)
return;
undo_redo->create_action(TTR("Remove Point from Curve"));
- undo_redo->add_do_method(node->get_curve().ptr(),"add_point",begin);
- undo_redo->add_undo_method(node->get_curve().ptr(),"remove_point",node->get_curve()->get_point_count());
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node->get_curve().ptr(), "add_point", begin);
+ undo_redo->add_undo_method(node->get_curve().ptr(), "remove_point", node->get_curve()->get_point_count());
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
return;
}
- mode=Mode(p_mode);
-
+ mode = Mode(p_mode);
}
Path2DEditor::Path2DEditor(EditorNode *p_editor) {
- canvas_item_editor=NULL;
- editor=p_editor;
+ canvas_item_editor = NULL;
+ editor = p_editor;
undo_redo = editor->get_undo_redo();
- mode=MODE_EDIT;
+ mode = MODE_EDIT;
- action=ACTION_NONE;
+ action = ACTION_NONE;
#if 0
options = memnew( MenuButton );
add_child(options);
@@ -627,55 +602,50 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) {
options->get_popup()->connect("id_pressed", this,"_menu_option");
#endif
- base_hb = memnew( HBoxContainer );
+ base_hb = memnew(HBoxContainer);
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(base_hb);
- sep = memnew( VSeparator);
+ sep = memnew(VSeparator);
base_hb->add_child(sep);
- curve_edit = memnew( ToolButton );
- curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit","EditorIcons"));
+ curve_edit = memnew(ToolButton);
+ curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons"));
curve_edit->set_toggle_mode(true);
curve_edit->set_focus_mode(Control::FOCUS_NONE);
- curve_edit->set_tooltip(TTR("Select Points")+"\n"+TTR("Shift+Drag: Select Control Points")+"\n"+keycode_get_string(KEY_MASK_CMD)+TTR("Click: Add Point")+"\n"+TTR("Right Click: Delete Point"));
- curve_edit->connect("pressed",this,"_mode_selected",varray(MODE_EDIT));
+ curve_edit->set_tooltip(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Right Click: Delete Point"));
+ curve_edit->connect("pressed", this, "_mode_selected", varray(MODE_EDIT));
base_hb->add_child(curve_edit);
- curve_edit_curve = memnew( ToolButton );
- curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCurve","EditorIcons"));
+ curve_edit_curve = memnew(ToolButton);
+ curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCurve", "EditorIcons"));
curve_edit_curve->set_toggle_mode(true);
curve_edit_curve->set_focus_mode(Control::FOCUS_NONE);
curve_edit_curve->set_tooltip(TTR("Select Control Points (Shift+Drag)"));
- curve_edit_curve->connect("pressed",this,"_mode_selected",varray(MODE_EDIT_CURVE));
+ curve_edit_curve->connect("pressed", this, "_mode_selected", varray(MODE_EDIT_CURVE));
base_hb->add_child(curve_edit_curve);
- curve_create = memnew( ToolButton );
- curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate","EditorIcons"));
+ curve_create = memnew(ToolButton);
+ curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons"));
curve_create->set_toggle_mode(true);
curve_create->set_focus_mode(Control::FOCUS_NONE);
- curve_create->set_tooltip(TTR("Add Point (in empty space)")+"\n"+TTR("Split Segment (in curve)"));
- curve_create->connect("pressed",this,"_mode_selected",varray(MODE_CREATE));
+ curve_create->set_tooltip(TTR("Add Point (in empty space)") + "\n" + TTR("Split Segment (in curve)"));
+ curve_create->connect("pressed", this, "_mode_selected", varray(MODE_CREATE));
base_hb->add_child(curve_create);
- curve_del = memnew( ToolButton );
- curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete","EditorIcons"));
+ curve_del = memnew(ToolButton);
+ curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons"));
curve_del->set_toggle_mode(true);
curve_del->set_focus_mode(Control::FOCUS_NONE);
curve_del->set_tooltip(TTR("Delete Point"));
- curve_del->connect("pressed",this,"_mode_selected",varray(MODE_DELETE));
+ curve_del->connect("pressed", this, "_mode_selected", varray(MODE_DELETE));
base_hb->add_child(curve_del);
- curve_close = memnew( ToolButton );
- curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveClose","EditorIcons"));
+ curve_close = memnew(ToolButton);
+ curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveClose", "EditorIcons"));
curve_close->set_focus_mode(Control::FOCUS_NONE);
curve_close->set_tooltip(TTR("Close Curve"));
- curve_close->connect("pressed",this,"_mode_selected",varray(ACTION_CLOSE));
+ curve_close->connect("pressed", this, "_mode_selected", varray(ACTION_CLOSE));
base_hb->add_child(curve_close);
base_hb->hide();
-
-
curve_edit->set_pressed(true);
-
-
}
-
void Path2DEditorPlugin::edit(Object *p_object) {
path2d_editor->edit(p_object->cast_to<Node>());
@@ -698,21 +668,15 @@ void Path2DEditorPlugin::make_visible(bool p_visible) {
path2d_editor->base_hb->hide();
path2d_editor->edit(NULL);
}
-
}
Path2DEditorPlugin::Path2DEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- path2d_editor = memnew( Path2DEditor(p_node) );
+ editor = p_node;
+ path2d_editor = memnew(Path2DEditor(p_node));
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(path2d_editor);
path2d_editor->hide();
-
-
}
-
-Path2DEditorPlugin::~Path2DEditorPlugin()
-{
+Path2DEditorPlugin::~Path2DEditorPlugin() {
}
-
diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h
index 89f42d94cc..32dd6868bb 100644
--- a/editor/plugins/path_2d_editor_plugin.h
+++ b/editor/plugins/path_2d_editor_plugin.h
@@ -29,11 +29,11 @@
#ifndef PATH_2D_EDITOR_PLUGIN_H
#define PATH_2D_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/2d/path_2d.h"
-#include "scene/gui/tool_button.h"
#include "scene/gui/button_group.h"
+#include "scene/gui/tool_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -77,7 +77,6 @@ class Path2DEditor : public HBoxContainer {
ACTION_MOVING_OUT,
};
-
Action action;
int action_point;
Point2 moving_from;
@@ -87,28 +86,28 @@ class Path2DEditor : public HBoxContainer {
void _canvas_draw();
void _node_visibility_changed();
-friend class Path2DEditorPlugin;
+ friend class Path2DEditorPlugin;
+
protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
-public:
- bool forward_gui_input(const InputEvent& p_event);
+public:
+ bool forward_gui_input(const InputEvent &p_event);
void edit(Node *p_path2d);
Path2DEditor(EditorNode *p_editor);
};
class Path2DEditorPlugin : public EditorPlugin {
- GDCLASS( Path2DEditorPlugin, EditorPlugin );
+ GDCLASS(Path2DEditorPlugin, EditorPlugin);
Path2DEditor *path2d_editor;
EditorNode *editor;
public:
-
- virtual bool forward_canvas_gui_input(const Transform2D& p_canvas_xform,const InputEvent& p_event) { return path2d_editor->forward_gui_input(p_event); }
+ virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event) { return path2d_editor->forward_gui_input(p_event); }
virtual String get_name() const { return "Path2D"; }
bool has_main_screen() const { return false; }
@@ -118,9 +117,6 @@ public:
Path2DEditorPlugin(EditorNode *p_node);
~Path2DEditorPlugin();
-
};
-
-
#endif // PATH_2D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp
index a3df39fdaa..0b3587bc5e 100644
--- a/editor/plugins/path_editor_plugin.cpp
+++ b/editor/plugins/path_editor_plugin.cpp
@@ -28,9 +28,9 @@
/*************************************************************************/
#include "path_editor_plugin.h"
-#include "spatial_editor_plugin.h"
-#include "scene/resources/curve.h"
#include "os/keyboard.h"
+#include "scene/resources/curve.h"
+#include "spatial_editor_plugin.h"
#if 0
String PathSpatialGizmo::get_handle_name(int p_idx) const {
diff --git a/editor/plugins/path_editor_plugin.h b/editor/plugins/path_editor_plugin.h
index fe1c5ad159..9d0f6eb9f2 100644
--- a/editor/plugins/path_editor_plugin.h
+++ b/editor/plugins/path_editor_plugin.h
@@ -29,10 +29,9 @@
#ifndef PATH_EDITOR_PLUGIN_H
#define PATH_EDITOR_PLUGIN_H
-
#include "editor/spatial_editor_gizmos.h"
#include "scene/3d/path.h"
-# if 0
+#if 0
class PathSpatialGizmo : public EditorSpatialGizmo {
GDCLASS(PathSpatialGizmo,EditorSpatialGizmo);
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index 3a41b2cb6b..8d208f9cee 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -29,66 +29,62 @@
#include "polygon_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
-#include "os/file_access.h"
#include "editor/editor_settings.h"
-#include "os/keyboard.h"
+#include "os/file_access.h"
#include "os/input.h"
+#include "os/keyboard.h"
void Polygon2DEditor::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
- button_create->set_icon( get_icon("Edit","EditorIcons"));
- button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
+ button_create->set_icon(get_icon("Edit", "EditorIcons"));
+ button_edit->set_icon(get_icon("MovePoint", "EditorIcons"));
button_edit->set_pressed(true);
- button_uv->set_icon( get_icon("Uv","EditorIcons"));
+ button_uv->set_icon(get_icon("Uv", "EditorIcons"));
- uv_button[UV_MODE_EDIT_POINT]->set_icon(get_icon("ToolSelect","EditorIcons"));
- uv_button[UV_MODE_MOVE]->set_icon(get_icon("ToolMove","EditorIcons"));
- uv_button[UV_MODE_ROTATE]->set_icon(get_icon("ToolRotate","EditorIcons"));
- uv_button[UV_MODE_SCALE]->set_icon(get_icon("ToolScale","EditorIcons"));
+ uv_button[UV_MODE_EDIT_POINT]->set_icon(get_icon("ToolSelect", "EditorIcons"));
+ uv_button[UV_MODE_MOVE]->set_icon(get_icon("ToolMove", "EditorIcons"));
+ uv_button[UV_MODE_ROTATE]->set_icon(get_icon("ToolRotate", "EditorIcons"));
+ uv_button[UV_MODE_SCALE]->set_icon(get_icon("ToolScale", "EditorIcons"));
- b_snap_grid->set_icon( get_icon("Grid", "EditorIcons"));
- b_snap_enable->set_icon( get_icon("Snap", "EditorIcons"));
- uv_icon_zoom->set_texture( get_icon("Zoom", "EditorIcons"));
+ b_snap_grid->set_icon(get_icon("Grid", "EditorIcons"));
+ b_snap_enable->set_icon(get_icon("Snap", "EditorIcons"));
+ uv_icon_zoom->set_texture(get_icon("Zoom", "EditorIcons"));
get_tree()->connect("node_removed", this, "_node_removed");
} break;
case NOTIFICATION_FIXED_PROCESS: {
-
} break;
}
-
}
void Polygon2DEditor::_node_removed(Node *p_node) {
- if(p_node==node) {
+ if (p_node == node) {
edit(NULL);
hide();
canvas_item_editor->get_viewport_control()->update();
}
-
}
-
void Polygon2DEditor::_menu_option(int p_option) {
- switch(p_option) {
+ switch (p_option) {
case MODE_CREATE: {
- mode=MODE_CREATE;
+ mode = MODE_CREATE;
button_create->set_pressed(true);
button_edit->set_pressed(false);
} break;
case MODE_EDIT: {
- mode=MODE_EDIT;
+ mode = MODE_EDIT;
button_create->set_pressed(false);
button_edit->set_pressed(true);
} break;
@@ -101,238 +97,216 @@ void Polygon2DEditor::_menu_option(int p_option) {
return;
}
-
PoolVector<Vector2> points = node->get_polygon();
PoolVector<Vector2> uvs = node->get_uv();
- if (uvs.size()!=points.size()) {
+ if (uvs.size() != points.size()) {
undo_redo->create_action(TTR("Create UV Map"));
- undo_redo->add_do_method(node,"set_uv",points);
- undo_redo->add_undo_method(node,"set_uv",uvs);
- undo_redo->add_do_method(uv_edit_draw,"update");
- undo_redo->add_undo_method(uv_edit_draw,"update");
+ undo_redo->add_do_method(node, "set_uv", points);
+ undo_redo->add_undo_method(node, "set_uv", uvs);
+ undo_redo->add_do_method(uv_edit_draw, "update");
+ undo_redo->add_undo_method(uv_edit_draw, "update");
undo_redo->commit_action();
-
}
-
uv_edit->popup_centered_ratio(0.85);
} break;
case UVEDIT_POLYGON_TO_UV: {
PoolVector<Vector2> points = node->get_polygon();
- if (points.size()==0)
+ if (points.size() == 0)
break;
PoolVector<Vector2> uvs = node->get_uv();
undo_redo->create_action(TTR("Create UV Map"));
- undo_redo->add_do_method(node,"set_uv",points);
- undo_redo->add_undo_method(node,"set_uv",uvs);
- undo_redo->add_do_method(uv_edit_draw,"update");
- undo_redo->add_undo_method(uv_edit_draw,"update");
+ undo_redo->add_do_method(node, "set_uv", points);
+ undo_redo->add_undo_method(node, "set_uv", uvs);
+ undo_redo->add_do_method(uv_edit_draw, "update");
+ undo_redo->add_undo_method(uv_edit_draw, "update");
undo_redo->commit_action();
-
} break;
case UVEDIT_UV_TO_POLYGON: {
PoolVector<Vector2> points = node->get_polygon();
PoolVector<Vector2> uvs = node->get_uv();
- if (uvs.size()==0)
+ if (uvs.size() == 0)
break;
undo_redo->create_action(TTR("Create UV Map"));
- undo_redo->add_do_method(node,"set_polygon",uvs);
- undo_redo->add_undo_method(node,"set_polygon",points);
- undo_redo->add_do_method(uv_edit_draw,"update");
- undo_redo->add_undo_method(uv_edit_draw,"update");
+ undo_redo->add_do_method(node, "set_polygon", uvs);
+ undo_redo->add_undo_method(node, "set_polygon", points);
+ undo_redo->add_do_method(uv_edit_draw, "update");
+ undo_redo->add_undo_method(uv_edit_draw, "update");
undo_redo->commit_action();
} break;
case UVEDIT_UV_CLEAR: {
PoolVector<Vector2> uvs = node->get_uv();
- if (uvs.size()==0)
+ if (uvs.size() == 0)
break;
undo_redo->create_action(TTR("Create UV Map"));
- undo_redo->add_do_method(node,"set_uv",PoolVector<Vector2>());
- undo_redo->add_undo_method(node,"set_uv",uvs);
- undo_redo->add_do_method(uv_edit_draw,"update");
- undo_redo->add_undo_method(uv_edit_draw,"update");
+ undo_redo->add_do_method(node, "set_uv", PoolVector<Vector2>());
+ undo_redo->add_undo_method(node, "set_uv", uvs);
+ undo_redo->add_do_method(uv_edit_draw, "update");
+ undo_redo->add_undo_method(uv_edit_draw, "update");
undo_redo->commit_action();
} break;
-
-
}
}
-void Polygon2DEditor::_set_use_snap(bool p_use)
-{
- use_snap=p_use;
+void Polygon2DEditor::_set_use_snap(bool p_use) {
+ use_snap = p_use;
}
-void Polygon2DEditor::_set_show_grid(bool p_show)
-{
- snap_show_grid=p_show;
+void Polygon2DEditor::_set_show_grid(bool p_show) {
+ snap_show_grid = p_show;
uv_edit_draw->update();
}
-void Polygon2DEditor::_set_snap_off_x(float p_val)
-{
- snap_offset.x=p_val;
+void Polygon2DEditor::_set_snap_off_x(float p_val) {
+ snap_offset.x = p_val;
uv_edit_draw->update();
}
-void Polygon2DEditor::_set_snap_off_y(float p_val)
-{
- snap_offset.y=p_val;
+void Polygon2DEditor::_set_snap_off_y(float p_val) {
+ snap_offset.y = p_val;
uv_edit_draw->update();
}
-void Polygon2DEditor::_set_snap_step_x(float p_val)
-{
- snap_step.x=p_val;
+void Polygon2DEditor::_set_snap_step_x(float p_val) {
+ snap_step.x = p_val;
uv_edit_draw->update();
}
-void Polygon2DEditor::_set_snap_step_y(float p_val)
-{
- snap_step.y=p_val;
+void Polygon2DEditor::_set_snap_step_y(float p_val) {
+ snap_step.y = p_val;
uv_edit_draw->update();
}
void Polygon2DEditor::_wip_close() {
undo_redo->create_action(TTR("Create Poly"));
- undo_redo->add_undo_method(node,"set_polygon",node->get_polygon());
- undo_redo->add_do_method(node,"set_polygon",wip);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_undo_method(node, "set_polygon", node->get_polygon());
+ undo_redo->add_do_method(node, "set_polygon", wip);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
wip.clear();
- wip_active=false;
- mode=MODE_EDIT;
+ wip_active = false;
+ mode = MODE_EDIT;
button_edit->set_pressed(true);
button_create->set_pressed(false);
- edited_point=-1;
+ edited_point = -1;
}
-bool Polygon2DEditor::forward_gui_input(const InputEvent& p_event) {
+bool Polygon2DEditor::forward_gui_input(const InputEvent &p_event) {
- if (node==NULL)
+ if (node == NULL)
return false;
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_event.mouse_button;
+ const InputEventMouseButton &mb = p_event.mouse_button;
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
-
- Vector2 gpoint = Point2(mb.x,mb.y);
+ Vector2 gpoint = Point2(mb.x, mb.y);
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
- cpoint=canvas_item_editor->snap_point(cpoint);
+ cpoint = canvas_item_editor->snap_point(cpoint);
cpoint = node->get_global_transform().affine_inverse().xform(cpoint);
-
Vector<Vector2> poly = Variant(node->get_polygon());
//first check if a point is to be added (segment split)
- real_t grab_treshold=EDITOR_DEF("editors/poly_editor/point_grab_radius",8);
-
- switch(mode) {
+ real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);
+ switch (mode) {
case MODE_CREATE: {
- if (mb.button_index==BUTTON_LEFT && mb.pressed) {
-
+ if (mb.button_index == BUTTON_LEFT && mb.pressed) {
if (!wip_active) {
wip.clear();
- wip.push_back( cpoint-node->get_offset() );
- wip_active=true;
- edited_point_pos=cpoint;
+ wip.push_back(cpoint - node->get_offset());
+ wip_active = true;
+ edited_point_pos = cpoint;
canvas_item_editor->get_viewport_control()->update();
- edited_point=1;
+ edited_point = 1;
return true;
} else {
-
- if (wip.size()>1 && xform.xform(wip[0]+node->get_offset()).distance_to(gpoint)<grab_treshold) {
+ if (wip.size() > 1 && xform.xform(wip[0] + node->get_offset()).distance_to(gpoint) < grab_treshold) {
//wip closed
_wip_close();
return true;
} else {
- wip.push_back( cpoint-node->get_offset() );
- edited_point=wip.size();
+ wip.push_back(cpoint - node->get_offset());
+ edited_point = wip.size();
canvas_item_editor->get_viewport_control()->update();
return true;
//add wip point
}
}
- } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && wip_active) {
+ } else if (mb.button_index == BUTTON_RIGHT && mb.pressed && wip_active) {
_wip_close();
}
-
-
} break;
case MODE_EDIT: {
- if (mb.button_index==BUTTON_LEFT) {
+ if (mb.button_index == BUTTON_LEFT) {
if (mb.pressed) {
if (mb.mod.control) {
-
if (poly.size() < 3) {
undo_redo->create_action(TTR("Edit Poly"));
- undo_redo->add_undo_method(node,"set_polygon",poly);
+ undo_redo->add_undo_method(node, "set_polygon", poly);
poly.push_back(cpoint);
- undo_redo->add_do_method(node,"set_polygon",poly);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node, "set_polygon", poly);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
return true;
}
//search edges
- int closest_idx=-1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 points[2] ={ xform.xform(poly[i]+node->get_offset()),
- xform.xform(poly[(i+1)%poly.size()]+node->get_offset()) };
+ Vector2 points[2] = { xform.xform(poly[i] + node->get_offset()),
+ xform.xform(poly[(i + 1) % poly.size()] + node->get_offset()) };
- Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint,points);
- if (cp.distance_squared_to(points[0])<CMP_EPSILON2 || cp.distance_squared_to(points[1])<CMP_EPSILON2)
+ Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint, points);
+ if (cp.distance_squared_to(points[0]) < CMP_EPSILON2 || cp.distance_squared_to(points[1]) < CMP_EPSILON2)
continue; //not valid to reuse point
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
}
-
-
}
- if (closest_idx>=0) {
+ if (closest_idx >= 0) {
- pre_move_edit=poly;
- poly.insert(closest_idx+1,xform.affine_inverse().xform(closest_pos)-node->get_offset());
- edited_point=closest_idx+1;
- edited_point_pos=xform.affine_inverse().xform(closest_pos);
+ pre_move_edit = poly;
+ poly.insert(closest_idx + 1, xform.affine_inverse().xform(closest_pos) - node->get_offset());
+ edited_point = closest_idx + 1;
+ edited_point_pos = xform.affine_inverse().xform(closest_pos);
node->set_polygon(Variant(poly));
canvas_item_editor->get_viewport_control()->update();
return true;
@@ -341,106 +315,95 @@ bool Polygon2DEditor::forward_gui_input(const InputEvent& p_event) {
//look for points to move
- int closest_idx=-1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 cp =xform.xform(poly[i]+node->get_offset());
+ Vector2 cp = xform.xform(poly[i] + node->get_offset());
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
}
-
}
- if (closest_idx>=0) {
+ if (closest_idx >= 0) {
- pre_move_edit=poly;
- edited_point=closest_idx;
- edited_point_pos=xform.affine_inverse().xform(closest_pos);
+ pre_move_edit = poly;
+ edited_point = closest_idx;
+ edited_point_pos = xform.affine_inverse().xform(closest_pos);
canvas_item_editor->get_viewport_control()->update();
return true;
}
}
} else {
- if (edited_point!=-1) {
+ if (edited_point != -1) {
//apply
- ERR_FAIL_INDEX_V(edited_point,poly.size(),false);
- poly[edited_point]=edited_point_pos-node->get_offset();
+ ERR_FAIL_INDEX_V(edited_point, poly.size(), false);
+ poly[edited_point] = edited_point_pos - node->get_offset();
undo_redo->create_action(TTR("Edit Poly"));
- undo_redo->add_do_method(node,"set_polygon",poly);
- undo_redo->add_undo_method(node,"set_polygon",pre_move_edit);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node, "set_polygon", poly);
+ undo_redo->add_undo_method(node, "set_polygon", pre_move_edit);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
- edited_point=-1;
+ edited_point = -1;
return true;
}
}
- } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
+ } else if (mb.button_index == BUTTON_RIGHT && mb.pressed && edited_point == -1) {
-
-
- int closest_idx=-1;
+ int closest_idx = -1;
Vector2 closest_pos;
- real_t closest_dist=1e10;
- for(int i=0;i<poly.size();i++) {
+ real_t closest_dist = 1e10;
+ for (int i = 0; i < poly.size(); i++) {
- Vector2 cp =xform.xform(poly[i]+node->get_offset());
+ Vector2 cp = xform.xform(poly[i] + node->get_offset());
real_t d = cp.distance_to(gpoint);
- if (d<closest_dist && d<grab_treshold) {
- closest_dist=d;
- closest_pos=cp;
- closest_idx=i;
+ if (d < closest_dist && d < grab_treshold) {
+ closest_dist = d;
+ closest_pos = cp;
+ closest_idx = i;
}
-
}
- if (closest_idx>=0) {
-
+ if (closest_idx >= 0) {
undo_redo->create_action(TTR("Edit Poly (Remove Point)"));
- undo_redo->add_undo_method(node,"set_polygon",poly);
+ undo_redo->add_undo_method(node, "set_polygon", poly);
poly.remove(closest_idx);
- undo_redo->add_do_method(node,"set_polygon",poly);
- undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
- undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
+ undo_redo->add_do_method(node, "set_polygon", poly);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
undo_redo->commit_action();
return true;
}
-
}
-
-
} break;
}
-
-
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_event.mouse_motion;
+ const InputEventMouseMotion &mm = p_event.mouse_motion;
- if (edited_point!=-1 && (wip_active || mm.button_mask&BUTTON_MASK_LEFT)) {
+ if (edited_point != -1 && (wip_active || mm.button_mask & BUTTON_MASK_LEFT)) {
- Vector2 gpoint = Point2(mm.x,mm.y);
+ Vector2 gpoint = Point2(mm.x, mm.y);
Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
- cpoint=canvas_item_editor->snap_point(cpoint);
+ cpoint = canvas_item_editor->snap_point(cpoint);
edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint);
canvas_item_editor->get_viewport_control()->update();
-
}
} break;
@@ -458,170 +421,159 @@ void Polygon2DEditor::_canvas_draw() {
Vector<Vector2> poly;
if (wip_active)
- poly=wip;
+ poly = wip;
else
- poly=Variant(node->get_polygon());
-
+ poly = Variant(node->get_polygon());
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
- Ref<Texture> handle= get_icon("EditorHandle","EditorIcons");
+ Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons");
- for(int i=0;i<poly.size();i++) {
+ for (int i = 0; i < poly.size(); i++) {
-
- Vector2 p,p2;
- p = i==edited_point ? edited_point_pos : (poly[i]+node->get_offset());
- if ((wip_active && i==poly.size()-1) || (((i+1)%poly.size())==edited_point))
- p2=edited_point_pos;
+ Vector2 p, p2;
+ p = i == edited_point ? edited_point_pos : (poly[i] + node->get_offset());
+ if ((wip_active && i == poly.size() - 1) || (((i + 1) % poly.size()) == edited_point))
+ p2 = edited_point_pos;
else
- p2 = poly[(i+1)%poly.size()]+node->get_offset();
+ p2 = poly[(i + 1) % poly.size()] + node->get_offset();
Vector2 point = xform.xform(p);
Vector2 next_point = xform.xform(p2);
- Color col=Color(1,0.3,0.1,0.8);
- vpc->draw_line(point,next_point,col,2);
- vpc->draw_texture(handle,point-handle->get_size()*0.5);
+ Color col = Color(1, 0.3, 0.1, 0.8);
+ vpc->draw_line(point, next_point, col, 2);
+ vpc->draw_texture(handle, point - handle->get_size() * 0.5);
}
}
-
void Polygon2DEditor::_uv_mode(int p_mode) {
-
- uv_mode=UVMode(p_mode);
- for(int i=0;i<UV_MODE_MAX;i++) {
- uv_button[i]->set_pressed(p_mode==i);
+ uv_mode = UVMode(p_mode);
+ for (int i = 0; i < UV_MODE_MAX; i++) {
+ uv_button[i]->set_pressed(p_mode == i);
}
}
-
-void Polygon2DEditor::_uv_input(const InputEvent& p_input) {
-
+void Polygon2DEditor::_uv_input(const InputEvent &p_input) {
Transform2D mtx;
- mtx.elements[2]=-uv_draw_ofs;
- mtx.scale_basis(Vector2(uv_draw_zoom,uv_draw_zoom));
-
- if (p_input.type==InputEvent::MOUSE_BUTTON) {
+ mtx.elements[2] = -uv_draw_ofs;
+ mtx.scale_basis(Vector2(uv_draw_zoom, uv_draw_zoom));
+ if (p_input.type == InputEvent::MOUSE_BUTTON) {
- const InputEventMouseButton &mb=p_input.mouse_button;
-
- if (mb.button_index==BUTTON_LEFT) {
+ const InputEventMouseButton &mb = p_input.mouse_button;
+ if (mb.button_index == BUTTON_LEFT) {
if (mb.pressed) {
- uv_drag_from=Vector2(mb.x,mb.y);
- uv_drag=true;
- uv_prev=node->get_uv();
- uv_move_current=uv_mode;
- if (uv_move_current==UV_MODE_EDIT_POINT) {
+ uv_drag_from = Vector2(mb.x, mb.y);
+ uv_drag = true;
+ uv_prev = node->get_uv();
+ uv_move_current = uv_mode;
+ if (uv_move_current == UV_MODE_EDIT_POINT) {
if (mb.mod.shift && mb.mod.command)
- uv_move_current=UV_MODE_SCALE;
+ uv_move_current = UV_MODE_SCALE;
else if (mb.mod.shift)
- uv_move_current=UV_MODE_MOVE;
+ uv_move_current = UV_MODE_MOVE;
else if (mb.mod.command)
- uv_move_current=UV_MODE_ROTATE;
+ uv_move_current = UV_MODE_ROTATE;
}
- if (uv_move_current==UV_MODE_EDIT_POINT) {
+ if (uv_move_current == UV_MODE_EDIT_POINT) {
- uv_drag_index=-1;
- for(int i=0;i<uv_prev.size();i++) {
+ uv_drag_index = -1;
+ for (int i = 0; i < uv_prev.size(); i++) {
- Vector2 tuv=mtx.xform(uv_prev[i]);
- if (tuv.distance_to(Vector2(mb.x,mb.y))<8) {
- uv_drag_from=tuv;
- uv_drag_index=i;
+ Vector2 tuv = mtx.xform(uv_prev[i]);
+ if (tuv.distance_to(Vector2(mb.x, mb.y)) < 8) {
+ uv_drag_from = tuv;
+ uv_drag_index = i;
}
}
- if (uv_drag_index==-1) {
- uv_drag=false;
+ if (uv_drag_index == -1) {
+ uv_drag = false;
}
-
}
} else if (uv_drag) {
undo_redo->create_action(TTR("Transform UV Map"));
- undo_redo->add_do_method(node,"set_uv",node->get_uv());
- undo_redo->add_undo_method(node,"set_uv",uv_prev);
- undo_redo->add_do_method(uv_edit_draw,"update");
- undo_redo->add_undo_method(uv_edit_draw,"update");
+ undo_redo->add_do_method(node, "set_uv", node->get_uv());
+ undo_redo->add_undo_method(node, "set_uv", uv_prev);
+ undo_redo->add_do_method(uv_edit_draw, "update");
+ undo_redo->add_undo_method(uv_edit_draw, "update");
undo_redo->commit_action();
- uv_drag=false;
+ uv_drag = false;
}
- } else if (mb.button_index==BUTTON_RIGHT && mb.pressed) {
+ } else if (mb.button_index == BUTTON_RIGHT && mb.pressed) {
if (uv_drag) {
- uv_drag=false;
+ uv_drag = false;
node->set_uv(uv_prev);
uv_edit_draw->update();
}
- } else if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) {
+ } else if (mb.button_index == BUTTON_WHEEL_UP && mb.pressed) {
- uv_zoom->set_value( uv_zoom->get_value()/0.9 );
- } else if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) {
+ uv_zoom->set_value(uv_zoom->get_value() / 0.9);
+ } else if (mb.button_index == BUTTON_WHEEL_DOWN && mb.pressed) {
- uv_zoom->set_value( uv_zoom->get_value()*0.9);
+ uv_zoom->set_value(uv_zoom->get_value() * 0.9);
}
- } else if (p_input.type==InputEvent::MOUSE_MOTION) {
+ } else if (p_input.type == InputEvent::MOUSE_MOTION) {
- const InputEventMouseMotion &mm=p_input.mouse_motion;
+ const InputEventMouseMotion &mm = p_input.mouse_motion;
- if (mm.button_mask&BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
+ if (mm.button_mask & BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
- Vector2 drag(mm.relative_x,mm.relative_y);
- uv_hscroll->set_value( uv_hscroll->get_value()-drag.x );
- uv_vscroll->set_value( uv_vscroll->get_value()-drag.y );
+ Vector2 drag(mm.relative_x, mm.relative_y);
+ uv_hscroll->set_value(uv_hscroll->get_value() - drag.x);
+ uv_vscroll->set_value(uv_vscroll->get_value() - drag.y);
} else if (uv_drag) {
- Vector2 uv_drag_to=snap_point(Vector2(mm.x,mm.y));
+ Vector2 uv_drag_to = snap_point(Vector2(mm.x, mm.y));
Vector2 drag = mtx.affine_inverse().xform(uv_drag_to) - mtx.affine_inverse().xform(uv_drag_from);
-
- switch(uv_move_current) {
+ switch (uv_move_current) {
case UV_MODE_EDIT_POINT: {
- PoolVector<Vector2> uv_new=uv_prev;
- uv_new.set( uv_drag_index, uv_new[uv_drag_index]+drag );
+ PoolVector<Vector2> uv_new = uv_prev;
+ uv_new.set(uv_drag_index, uv_new[uv_drag_index] + drag);
node->set_uv(uv_new);
} break;
case UV_MODE_MOVE: {
- PoolVector<Vector2> uv_new=uv_prev;
- for(int i=0;i<uv_new.size();i++)
- uv_new.set( i, uv_new[i]+drag );
+ PoolVector<Vector2> uv_new = uv_prev;
+ for (int i = 0; i < uv_new.size(); i++)
+ uv_new.set(i, uv_new[i] + drag);
node->set_uv(uv_new);
-
} break;
case UV_MODE_ROTATE: {
Vector2 center;
- PoolVector<Vector2> uv_new=uv_prev;
+ PoolVector<Vector2> uv_new = uv_prev;
- for(int i=0;i<uv_new.size();i++)
- center+=uv_prev[i];
- center/=uv_new.size();
+ for (int i = 0; i < uv_new.size(); i++)
+ center += uv_prev[i];
+ center /= uv_new.size();
- float angle = (uv_drag_from - mtx.xform(center)).normalized().angle_to( (uv_drag_to - mtx.xform(center)).normalized() );
+ float angle = (uv_drag_from - mtx.xform(center)).normalized().angle_to((uv_drag_to - mtx.xform(center)).normalized());
- for(int i=0;i<uv_new.size();i++) {
+ for (int i = 0; i < uv_new.size(); i++) {
Vector2 rel = uv_prev[i] - center;
- rel=rel.rotated(angle);
- uv_new.set(i,center+rel);
+ rel = rel.rotated(angle);
+ uv_new.set(i, center + rel);
}
node->set_uv(uv_new);
@@ -630,47 +582,41 @@ void Polygon2DEditor::_uv_input(const InputEvent& p_input) {
case UV_MODE_SCALE: {
Vector2 center;
- PoolVector<Vector2> uv_new=uv_prev;
+ PoolVector<Vector2> uv_new = uv_prev;
- for(int i=0;i<uv_new.size();i++)
- center+=uv_prev[i];
- center/=uv_new.size();
+ for (int i = 0; i < uv_new.size(); i++)
+ center += uv_prev[i];
+ center /= uv_new.size();
float from_dist = uv_drag_from.distance_to(mtx.xform(center));
float to_dist = uv_drag_to.distance_to(mtx.xform(center));
- if (from_dist<2)
+ if (from_dist < 2)
break;
- float scale = to_dist/from_dist;
+ float scale = to_dist / from_dist;
-
- for(int i=0;i<uv_new.size();i++) {
+ for (int i = 0; i < uv_new.size(); i++) {
Vector2 rel = uv_prev[i] - center;
- rel=rel*scale;
- uv_new.set(i,center+rel);
+ rel = rel * scale;
+ uv_new.set(i, center + rel);
}
node->set_uv(uv_new);
} break;
-
-
}
uv_edit_draw->update();
}
-
}
-
}
-
void Polygon2DEditor::_uv_scroll_changed(float) {
if (updating_uv_scroll)
return;
- uv_draw_ofs.x=uv_hscroll->get_value();
- uv_draw_ofs.y=uv_vscroll->get_value();
- uv_draw_zoom=uv_zoom->get_value();
+ uv_draw_ofs.x = uv_hscroll->get_value();
+ uv_draw_ofs.y = uv_vscroll->get_value();
+ uv_draw_zoom = uv_zoom->get_value();
uv_edit_draw->update();
}
@@ -681,115 +627,110 @@ void Polygon2DEditor::_uv_draw() {
return;
Transform2D mtx;
- mtx.elements[2]=-uv_draw_ofs;
- mtx.scale_basis(Vector2(uv_draw_zoom,uv_draw_zoom));
+ mtx.elements[2] = -uv_draw_ofs;
+ mtx.scale_basis(Vector2(uv_draw_zoom, uv_draw_zoom));
- VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(),mtx);
- uv_edit_draw->draw_texture(base_tex,Point2());
- VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(),Transform2D());
+ VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), mtx);
+ uv_edit_draw->draw_texture(base_tex, Point2());
+ VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), Transform2D());
if (snap_show_grid) {
Size2 s = uv_edit_draw->get_size();
int last_cell;
- if (snap_step.x!=0) {
- for(int i=0;i<s.width;i++) {
- int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i,0)).x-snap_offset.x)/snap_step.x));
- if (i==0)
- last_cell=cell;
- if (last_cell!=cell)
- uv_edit_draw->draw_line(Point2(i,0),Point2(i,s.height),Color(0.3,0.7,1,0.3));
- last_cell=cell;
+ if (snap_step.x != 0) {
+ for (int i = 0; i < s.width; i++) {
+ int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i, 0)).x - snap_offset.x) / snap_step.x));
+ if (i == 0)
+ last_cell = cell;
+ if (last_cell != cell)
+ uv_edit_draw->draw_line(Point2(i, 0), Point2(i, s.height), Color(0.3, 0.7, 1, 0.3));
+ last_cell = cell;
}
}
- if (snap_step.y!=0) {
- for(int i=0;i<s.height;i++) {
- int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0,i)).y-snap_offset.y)/snap_step.y));
- if (i==0)
- last_cell=cell;
- if (last_cell!=cell)
- uv_edit_draw->draw_line(Point2(0,i),Point2(s.width,i),Color(0.3,0.7,1,0.3));
- last_cell=cell;
+ if (snap_step.y != 0) {
+ for (int i = 0; i < s.height; i++) {
+ int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0, i)).y - snap_offset.y) / snap_step.y));
+ if (i == 0)
+ last_cell = cell;
+ if (last_cell != cell)
+ uv_edit_draw->draw_line(Point2(0, i), Point2(s.width, i), Color(0.3, 0.7, 1, 0.3));
+ last_cell = cell;
}
}
}
PoolVector<Vector2> uvs = node->get_uv();
- Ref<Texture> handle = get_icon("EditorHandle","EditorIcons");
+ Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons");
- Rect2 rect(Point2(),mtx.basis_xform(base_tex->get_size()));
+ Rect2 rect(Point2(), mtx.basis_xform(base_tex->get_size()));
rect.expand_to(mtx.basis_xform(uv_edit_draw->get_size()));
- for(int i=0;i<uvs.size();i++) {
+ for (int i = 0; i < uvs.size(); i++) {
- int next = (i+1)%uvs.size();
- uv_edit_draw->draw_line(mtx.xform(uvs[i]),mtx.xform(uvs[next]),Color(0.9,0.5,0.5),2);
- uv_edit_draw->draw_texture(handle,mtx.xform(uvs[i])-handle->get_size()*0.5);
+ int next = (i + 1) % uvs.size();
+ uv_edit_draw->draw_line(mtx.xform(uvs[i]), mtx.xform(uvs[next]), Color(0.9, 0.5, 0.5), 2);
+ uv_edit_draw->draw_texture(handle, mtx.xform(uvs[i]) - handle->get_size() * 0.5);
rect.expand_to(mtx.basis_xform(uvs[i]));
}
- rect=rect.grow(200);
- updating_uv_scroll=true;
+ rect = rect.grow(200);
+ updating_uv_scroll = true;
uv_hscroll->set_min(rect.pos.x);
- uv_hscroll->set_max(rect.pos.x+rect.size.x);
+ uv_hscroll->set_max(rect.pos.x + rect.size.x);
uv_hscroll->set_page(uv_edit_draw->get_size().x);
uv_hscroll->set_value(uv_draw_ofs.x);
uv_hscroll->set_step(0.001);
uv_vscroll->set_min(rect.pos.y);
- uv_vscroll->set_max(rect.pos.y+rect.size.y);
+ uv_vscroll->set_max(rect.pos.y + rect.size.y);
uv_vscroll->set_page(uv_edit_draw->get_size().y);
uv_vscroll->set_value(uv_draw_ofs.y);
uv_vscroll->set_step(0.001);
- updating_uv_scroll=false;
-
+ updating_uv_scroll = false;
}
void Polygon2DEditor::edit(Node *p_collision_polygon) {
if (!canvas_item_editor) {
- canvas_item_editor=CanvasItemEditor::get_singleton();
+ canvas_item_editor = CanvasItemEditor::get_singleton();
}
if (p_collision_polygon) {
- node=p_collision_polygon->cast_to<Polygon2D>();
- if (!canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->connect("draw",this,"_canvas_draw");
+ node = p_collision_polygon->cast_to<Polygon2D>();
+ if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
wip.clear();
- wip_active=false;
- edited_point=-1;
+ wip_active = false;
+ edited_point = -1;
} else {
- node=NULL;
-
- if (canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->get_viewport_control()->disconnect("draw",this,"_canvas_draw");
+ node = NULL;
+ if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw");
}
-
}
void Polygon2DEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_menu_option"),&Polygon2DEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_canvas_draw"),&Polygon2DEditor::_canvas_draw);
- ClassDB::bind_method(D_METHOD("_uv_mode"),&Polygon2DEditor::_uv_mode);
- ClassDB::bind_method(D_METHOD("_uv_draw"),&Polygon2DEditor::_uv_draw);
- ClassDB::bind_method(D_METHOD("_uv_input"),&Polygon2DEditor::_uv_input);
- ClassDB::bind_method(D_METHOD("_uv_scroll_changed"),&Polygon2DEditor::_uv_scroll_changed);
- ClassDB::bind_method(D_METHOD("_node_removed"),&Polygon2DEditor::_node_removed);
- ClassDB::bind_method(D_METHOD("_set_use_snap"),&Polygon2DEditor::_set_use_snap);
- ClassDB::bind_method(D_METHOD("_set_show_grid"),&Polygon2DEditor::_set_show_grid);
- ClassDB::bind_method(D_METHOD("_set_snap_off_x"),&Polygon2DEditor::_set_snap_off_x);
- ClassDB::bind_method(D_METHOD("_set_snap_off_y"),&Polygon2DEditor::_set_snap_off_y);
- ClassDB::bind_method(D_METHOD("_set_snap_step_x"),&Polygon2DEditor::_set_snap_step_x);
- ClassDB::bind_method(D_METHOD("_set_snap_step_y"),&Polygon2DEditor::_set_snap_step_y);
-
-
+ ClassDB::bind_method(D_METHOD("_menu_option"), &Polygon2DEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"), &Polygon2DEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_uv_mode"), &Polygon2DEditor::_uv_mode);
+ ClassDB::bind_method(D_METHOD("_uv_draw"), &Polygon2DEditor::_uv_draw);
+ ClassDB::bind_method(D_METHOD("_uv_input"), &Polygon2DEditor::_uv_input);
+ ClassDB::bind_method(D_METHOD("_uv_scroll_changed"), &Polygon2DEditor::_uv_scroll_changed);
+ ClassDB::bind_method(D_METHOD("_node_removed"), &Polygon2DEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_set_use_snap"), &Polygon2DEditor::_set_use_snap);
+ ClassDB::bind_method(D_METHOD("_set_show_grid"), &Polygon2DEditor::_set_show_grid);
+ ClassDB::bind_method(D_METHOD("_set_snap_off_x"), &Polygon2DEditor::_set_snap_off_x);
+ ClassDB::bind_method(D_METHOD("_set_snap_off_y"), &Polygon2DEditor::_set_snap_off_y);
+ ClassDB::bind_method(D_METHOD("_set_snap_step_x"), &Polygon2DEditor::_set_snap_step_x);
+ ClassDB::bind_method(D_METHOD("_set_snap_step_y"), &Polygon2DEditor::_set_snap_step_y);
}
inline float _snap_scalar(float p_offset, float p_step, float p_target) {
@@ -798,8 +739,8 @@ inline float _snap_scalar(float p_offset, float p_step, float p_target) {
Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const {
if (use_snap) {
- p_target.x = _snap_scalar(snap_offset.x*uv_draw_zoom-uv_draw_ofs.x, snap_step.x*uv_draw_zoom, p_target.x);
- p_target.y = _snap_scalar(snap_offset.y*uv_draw_zoom-uv_draw_ofs.y, snap_step.y*uv_draw_zoom, p_target.y);
+ p_target.x = _snap_scalar(snap_offset.x * uv_draw_zoom - uv_draw_ofs.x, snap_step.x * uv_draw_zoom, p_target.x);
+ p_target.y = _snap_scalar(snap_offset.y * uv_draw_zoom - uv_draw_ofs.y, snap_step.y * uv_draw_zoom, p_target.y);
}
return p_target;
@@ -807,31 +748,31 @@ Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const {
Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) {
- node=NULL;
- canvas_item_editor=NULL;
- editor=p_editor;
+ node = NULL;
+ canvas_item_editor = NULL;
+ editor = p_editor;
undo_redo = editor->get_undo_redo();
- snap_step=Vector2(10,10);
- use_snap=false;
- snap_show_grid=false;
+ snap_step = Vector2(10, 10);
+ use_snap = false;
+ snap_show_grid = false;
- add_child( memnew( VSeparator ));
- button_create = memnew( ToolButton );
+ add_child(memnew(VSeparator));
+ button_create = memnew(ToolButton);
add_child(button_create);
- button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE));
+ button_create->connect("pressed", this, "_menu_option", varray(MODE_CREATE));
button_create->set_toggle_mode(true);
- button_edit = memnew( ToolButton );
+ button_edit = memnew(ToolButton);
add_child(button_edit);
- button_edit->connect("pressed",this,"_menu_option",varray(MODE_EDIT));
+ button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT));
button_edit->set_toggle_mode(true);
- button_uv = memnew( ToolButton );
+ button_uv = memnew(ToolButton);
add_child(button_uv);
- button_uv->connect("pressed",this,"_menu_option",varray(MODE_EDIT_UV));
+ button_uv->connect("pressed", this, "_menu_option", varray(MODE_EDIT_UV));
- //add_constant_override("separation",0);
+//add_constant_override("separation",0);
#if 0
options = memnew( MenuButton );
@@ -843,73 +784,73 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) {
#endif
mode = MODE_EDIT;
- wip_active=false;
+ wip_active = false;
- uv_mode=UV_MODE_EDIT_POINT;
- uv_edit = memnew( AcceptDialog );
+ uv_mode = UV_MODE_EDIT_POINT;
+ uv_edit = memnew(AcceptDialog);
add_child(uv_edit);
uv_edit->set_title(TTR("Polygon 2D UV Editor"));
- uv_edit->set_self_modulate(Color(1,1,1,0.9));
+ uv_edit->set_self_modulate(Color(1, 1, 1, 0.9));
- VBoxContainer *uv_main_vb = memnew( VBoxContainer );
+ VBoxContainer *uv_main_vb = memnew(VBoxContainer);
uv_edit->add_child(uv_main_vb);
//uv_edit->set_child_rect(uv_main_vb);
- HBoxContainer *uv_mode_hb = memnew( HBoxContainer );
+ HBoxContainer *uv_mode_hb = memnew(HBoxContainer);
uv_main_vb->add_child(uv_mode_hb);
- for(int i=0;i<UV_MODE_MAX;i++) {
+ for (int i = 0; i < UV_MODE_MAX; i++) {
- uv_button[i]=memnew( ToolButton );
+ uv_button[i] = memnew(ToolButton);
uv_button[i]->set_toggle_mode(true);
uv_mode_hb->add_child(uv_button[i]);
- uv_button[i]->connect("pressed",this,"_uv_mode",varray(i));
+ uv_button[i]->connect("pressed", this, "_uv_mode", varray(i));
uv_button[i]->set_focus_mode(FOCUS_NONE);
}
- uv_button[0]->set_tooltip(TTR("Move Point")+"\n"+TTR("Ctrl: Rotate")+"\n"+TTR("Shift: Move All")+"\n"+TTR("Shift+Ctrl: Scale"));
+ uv_button[0]->set_tooltip(TTR("Move Point") + "\n" + TTR("Ctrl: Rotate") + "\n" + TTR("Shift: Move All") + "\n" + TTR("Shift+Ctrl: Scale"));
uv_button[1]->set_tooltip(TTR("Move Polygon"));
uv_button[2]->set_tooltip(TTR("Rotate Polygon"));
uv_button[3]->set_tooltip(TTR("Scale Polygon"));
uv_button[0]->set_pressed(true);
- HBoxContainer *uv_main_hb = memnew( HBoxContainer );
+ HBoxContainer *uv_main_hb = memnew(HBoxContainer);
uv_main_vb->add_child(uv_main_hb);
- uv_edit_draw = memnew( Control );
+ uv_edit_draw = memnew(Control);
uv_main_hb->add_child(uv_edit_draw);
uv_main_hb->set_v_size_flags(SIZE_EXPAND_FILL);
uv_edit_draw->set_h_size_flags(SIZE_EXPAND_FILL);
- uv_menu = memnew( MenuButton );
+ uv_menu = memnew(MenuButton);
uv_mode_hb->add_child(uv_menu);
uv_menu->set_text(TTR("Edit"));
- uv_menu->get_popup()->add_item(TTR("Polygon->UV"),UVEDIT_POLYGON_TO_UV);
- uv_menu->get_popup()->add_item(TTR("UV->Polygon"),UVEDIT_UV_TO_POLYGON);
+ uv_menu->get_popup()->add_item(TTR("Polygon->UV"), UVEDIT_POLYGON_TO_UV);
+ uv_menu->get_popup()->add_item(TTR("UV->Polygon"), UVEDIT_UV_TO_POLYGON);
uv_menu->get_popup()->add_separator();
- uv_menu->get_popup()->add_item(TTR("Clear UV"),UVEDIT_UV_CLEAR);
- uv_menu->get_popup()->connect("id_pressed",this,"_menu_option");
+ uv_menu->get_popup()->add_item(TTR("Clear UV"), UVEDIT_UV_CLEAR);
+ uv_menu->get_popup()->connect("id_pressed", this, "_menu_option");
- uv_mode_hb->add_child( memnew( VSeparator ));
+ uv_mode_hb->add_child(memnew(VSeparator));
- b_snap_enable = memnew( ToolButton );
+ b_snap_enable = memnew(ToolButton);
uv_mode_hb->add_child(b_snap_enable);
b_snap_enable->set_text(TTR("Snap"));
b_snap_enable->set_focus_mode(FOCUS_NONE);
b_snap_enable->set_toggle_mode(true);
b_snap_enable->set_pressed(use_snap);
b_snap_enable->set_tooltip(TTR("Enable Snap"));
- b_snap_enable->connect("toggled",this,"_set_use_snap");
+ b_snap_enable->connect("toggled", this, "_set_use_snap");
- b_snap_grid = memnew( ToolButton );
+ b_snap_grid = memnew(ToolButton);
uv_mode_hb->add_child(b_snap_grid);
b_snap_grid->set_text(TTR("Grid"));
b_snap_grid->set_focus_mode(FOCUS_NONE);
b_snap_grid->set_toggle_mode(true);
b_snap_grid->set_pressed(snap_show_grid);
b_snap_grid->set_tooltip(TTR("Show Grid"));
- b_snap_grid->connect("toggled",this,"_set_show_grid");
+ b_snap_grid->connect("toggled", this, "_set_show_grid");
- uv_mode_hb->add_child( memnew( VSeparator ));
- uv_mode_hb->add_child( memnew( Label(TTR("Grid Offset:")) ) );
+ uv_mode_hb->add_child(memnew(VSeparator));
+ uv_mode_hb->add_child(memnew(Label(TTR("Grid Offset:"))));
- SpinBox *sb_off_x = memnew( SpinBox );
+ SpinBox *sb_off_x = memnew(SpinBox);
sb_off_x->set_min(-256);
sb_off_x->set_max(256);
sb_off_x->set_step(1);
@@ -918,7 +859,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) {
sb_off_x->connect("value_changed", this, "_set_snap_off_x");
uv_mode_hb->add_child(sb_off_x);
- SpinBox *sb_off_y = memnew( SpinBox );
+ SpinBox *sb_off_y = memnew(SpinBox);
sb_off_y->set_min(-256);
sb_off_y->set_max(256);
sb_off_y->set_step(1);
@@ -927,10 +868,10 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) {
sb_off_y->connect("value_changed", this, "_set_snap_off_y");
uv_mode_hb->add_child(sb_off_y);
- uv_mode_hb->add_child( memnew( VSeparator ));
- uv_mode_hb->add_child( memnew( Label(TTR("Grid Step:")) ) );
+ uv_mode_hb->add_child(memnew(VSeparator));
+ uv_mode_hb->add_child(memnew(Label(TTR("Grid Step:"))));
- SpinBox *sb_step_x = memnew( SpinBox );
+ SpinBox *sb_step_x = memnew(SpinBox);
sb_step_x->set_min(-256);
sb_step_x->set_max(256);
sb_step_x->set_step(1);
@@ -939,7 +880,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) {
sb_step_x->connect("value_changed", this, "_set_snap_step_x");
uv_mode_hb->add_child(sb_step_x);
- SpinBox *sb_step_y = memnew( SpinBox );
+ SpinBox *sb_step_y = memnew(SpinBox);
sb_step_y->set_min(-256);
sb_step_y->set_max(256);
sb_step_y->set_step(1);
@@ -948,49 +889,44 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) {
sb_step_y->connect("value_changed", this, "_set_snap_step_y");
uv_mode_hb->add_child(sb_step_y);
- uv_mode_hb->add_child( memnew( VSeparator ));
- uv_icon_zoom = memnew( TextureRect );
- uv_mode_hb->add_child( uv_icon_zoom );
- uv_zoom = memnew( HSlider );
+ uv_mode_hb->add_child(memnew(VSeparator));
+ uv_icon_zoom = memnew(TextureRect);
+ uv_mode_hb->add_child(uv_icon_zoom);
+ uv_zoom = memnew(HSlider);
uv_zoom->set_min(0.01);
uv_zoom->set_max(4);
uv_zoom->set_value(1);
uv_zoom->set_step(0.01);
uv_mode_hb->add_child(uv_zoom);
- uv_zoom->set_custom_minimum_size(Size2(200,0));
- uv_zoom_value = memnew( SpinBox );
+ uv_zoom->set_custom_minimum_size(Size2(200, 0));
+ uv_zoom_value = memnew(SpinBox);
uv_zoom->share(uv_zoom_value);
- uv_zoom_value->set_custom_minimum_size(Size2(50,0));
+ uv_zoom_value->set_custom_minimum_size(Size2(50, 0));
uv_mode_hb->add_child(uv_zoom_value);
- uv_zoom->connect("value_changed",this,"_uv_scroll_changed");
-
+ uv_zoom->connect("value_changed", this, "_uv_scroll_changed");
-
- uv_vscroll = memnew( VScrollBar);
+ uv_vscroll = memnew(VScrollBar);
uv_main_hb->add_child(uv_vscroll);
- uv_vscroll->connect("value_changed",this,"_uv_scroll_changed");
- uv_hscroll = memnew( HScrollBar );
+ uv_vscroll->connect("value_changed", this, "_uv_scroll_changed");
+ uv_hscroll = memnew(HScrollBar);
uv_main_vb->add_child(uv_hscroll);
- uv_hscroll->connect("value_changed",this,"_uv_scroll_changed");
+ uv_hscroll->connect("value_changed", this, "_uv_scroll_changed");
- uv_edit_draw->connect("draw",this,"_uv_draw");
- uv_edit_draw->connect("gui_input",this,"_uv_input");
- uv_draw_zoom=1.0;
- uv_drag_index=-1;
- uv_drag=false;
- updating_uv_scroll=false;
+ uv_edit_draw->connect("draw", this, "_uv_draw");
+ uv_edit_draw->connect("gui_input", this, "_uv_input");
+ uv_draw_zoom = 1.0;
+ uv_drag_index = -1;
+ uv_drag = false;
+ updating_uv_scroll = false;
- error = memnew( AcceptDialog);
+ error = memnew(AcceptDialog);
add_child(error);
uv_edit_draw->set_clip_contents(true);
-
}
-
void Polygon2DEditorPlugin::edit(Object *p_object) {
-
collision_polygon_editor->edit(p_object->cast_to<Node>());
}
@@ -1008,21 +944,16 @@ void Polygon2DEditorPlugin::make_visible(bool p_visible) {
collision_polygon_editor->hide();
collision_polygon_editor->edit(NULL);
}
-
}
Polygon2DEditorPlugin::Polygon2DEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- collision_polygon_editor = memnew( Polygon2DEditor(p_node) );
+ editor = p_node;
+ collision_polygon_editor = memnew(Polygon2DEditor(p_node));
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
collision_polygon_editor->hide();
-
}
-
-Polygon2DEditorPlugin::~Polygon2DEditorPlugin()
-{
+Polygon2DEditorPlugin::~Polygon2DEditorPlugin() {
}
-
diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h
index c994867705..94eb3f49e8 100644
--- a/editor/plugins/polygon_2d_editor_plugin.h
+++ b/editor/plugins/polygon_2d_editor_plugin.h
@@ -29,11 +29,11 @@
#ifndef POLYGON_2D_EDITOR_PLUGIN_H
#define POLYGON_2D_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/2d/polygon_2d.h"
-#include "scene/gui/tool_button.h"
#include "scene/gui/button_group.h"
+#include "scene/gui/tool_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -42,7 +42,7 @@ class CanvasItemEditor;
class Polygon2DEditor : public HBoxContainer {
- GDCLASS(Polygon2DEditor, HBoxContainer );
+ GDCLASS(Polygon2DEditor, HBoxContainer);
UndoRedo *undo_redo;
enum Mode {
@@ -88,8 +88,6 @@ class Polygon2DEditor : public HBoxContainer {
Vector2 uv_drag_from;
bool updating_uv_scroll;
-
-
AcceptDialog *error;
ToolButton *button_create;
@@ -114,7 +112,7 @@ class Polygon2DEditor : public HBoxContainer {
Vector2 snap_step;
void _uv_scroll_changed(float);
- void _uv_input(const InputEvent& p_input);
+ void _uv_input(const InputEvent &p_input);
void _uv_draw();
void _uv_mode(int p_mode);
void _wip_close();
@@ -136,22 +134,20 @@ protected:
Vector2 snap_point(Vector2 p_target) const;
public:
-
- bool forward_gui_input(const InputEvent& p_event);
+ bool forward_gui_input(const InputEvent &p_event);
void edit(Node *p_collision_polygon);
Polygon2DEditor(EditorNode *p_editor);
};
class Polygon2DEditorPlugin : public EditorPlugin {
- GDCLASS( Polygon2DEditorPlugin, EditorPlugin );
+ GDCLASS(Polygon2DEditorPlugin, EditorPlugin);
Polygon2DEditor *collision_polygon_editor;
EditorNode *editor;
public:
-
- virtual bool forward_canvas_gui_input(const Transform2D& p_canvas_xform,const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
+ virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
virtual String get_name() const { return "Polygon2D"; }
bool has_main_screen() const { return false; }
@@ -161,7 +157,6 @@ public:
Polygon2DEditorPlugin(EditorNode *p_node);
~Polygon2DEditorPlugin();
-
};
#endif // POLYGON_2D_EDITOR_PLUGIN_H
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index e876fa55c6..2cdbff8d97 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -28,40 +28,35 @@
/*************************************************************************/
#include "resource_preloader_editor_plugin.h"
-#include "io/resource_loader.h"
-#include "global_config.h"
#include "editor/editor_settings.h"
-
+#include "global_config.h"
+#include "io/resource_loader.h"
void ResourcePreloaderEditor::_gui_input(InputEvent p_event) {
-
-
}
void ResourcePreloaderEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_FIXED_PROCESS) {
-
+ if (p_what == NOTIFICATION_FIXED_PROCESS) {
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
- load->set_icon( get_icon("Folder","EditorIcons") );
- _delete->set_icon( get_icon("Del","EditorIcons") );
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ load->set_icon(get_icon("Folder", "EditorIcons"));
+ _delete->set_icon(get_icon("Del", "EditorIcons"));
}
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
//NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
}
- if (p_what==NOTIFICATION_DRAW) {
-
+ if (p_what == NOTIFICATION_DRAW) {
}
}
-void ResourcePreloaderEditor::_files_load_request(const Vector<String>& p_paths) {
+void ResourcePreloaderEditor::_files_load_request(const Vector<String> &p_paths) {
- for(int i=0;i<p_paths.size();i++) {
+ for (int i = 0; i < p_paths.size(); i++) {
String path = p_paths[i];
@@ -77,41 +72,38 @@ void ResourcePreloaderEditor::_files_load_request(const Vector<String>& p_paths)
return; ///beh should show an error i guess
}
-
String basename = path.get_file().get_basename();
- String name=basename;
- int counter=1;
- while(preloader->has_resource(name)) {
+ String name = basename;
+ int counter = 1;
+ while (preloader->has_resource(name)) {
counter++;
- name=basename+" "+itos(counter);
+ name = basename + " " + itos(counter);
}
undo_redo->create_action(TTR("Add Resource"));
- undo_redo->add_do_method(preloader,"add_resource",name,resource);
- undo_redo->add_undo_method(preloader,"remove_resource",name);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(preloader, "add_resource", name, resource);
+ undo_redo->add_undo_method(preloader, "remove_resource", name);
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
}
}
void ResourcePreloaderEditor::_load_pressed() {
- loading_scene=false;
+ loading_scene = false;
file->clear_filters();
List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("",&extensions);
- for(int i=0;i<extensions.size();i++)
- file->add_filter("*."+extensions[i]);
+ ResourceLoader::get_recognized_extensions_for_type("", &extensions);
+ for (int i = 0; i < extensions.size(); i++)
+ file->add_filter("*." + extensions[i]);
file->set_mode(EditorFileDialog::MODE_OPEN_FILES);
file->popup_centered_ratio();
-
}
-
void ResourcePreloaderEditor::_item_edited() {
if (!tree->get_selected())
@@ -119,32 +111,29 @@ void ResourcePreloaderEditor::_item_edited() {
TreeItem *s = tree->get_selected();
- if (tree->get_selected_column()==0) {
+ if (tree->get_selected_column() == 0) {
// renamed
- String old_name=s->get_metadata(0);
- String new_name=s->get_text(0);
- if (old_name==new_name)
+ String old_name = s->get_metadata(0);
+ String new_name = s->get_text(0);
+ if (old_name == new_name)
return;
- if (new_name=="" || new_name.find("\\")!=-1 || new_name.find("/")!=-1 || preloader->has_resource(new_name)) {
+ if (new_name == "" || new_name.find("\\") != -1 || new_name.find("/") != -1 || preloader->has_resource(new_name)) {
- s->set_text(0,old_name);
+ s->set_text(0, old_name);
return;
}
RES samp = preloader->get_resource(old_name);
undo_redo->create_action(TTR("Rename Resource"));
- undo_redo->add_do_method(preloader,"remove_resource",old_name);
- undo_redo->add_do_method(preloader,"add_resource",new_name,samp);
- undo_redo->add_undo_method(preloader,"remove_resource",new_name);
- undo_redo->add_undo_method(preloader,"add_resource",old_name,samp);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(preloader, "remove_resource", old_name);
+ undo_redo->add_do_method(preloader, "add_resource", new_name, samp);
+ undo_redo->add_undo_method(preloader, "remove_resource", new_name);
+ undo_redo->add_undo_method(preloader, "add_resource", old_name, samp);
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
-
}
-
-
}
void ResourcePreloaderEditor::_delete_confirm_pressed() {
@@ -154,17 +143,16 @@ void ResourcePreloaderEditor::_delete_confirm_pressed() {
String to_remove = tree->get_selected()->get_text(0);
undo_redo->create_action(TTR("Delete Resource"));
- undo_redo->add_do_method(preloader,"remove_resource",to_remove);
- undo_redo->add_undo_method(preloader,"add_resource",to_remove,preloader->get_resource(to_remove));
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(preloader, "remove_resource", to_remove);
+ undo_redo->add_undo_method(preloader, "add_resource", to_remove, preloader->get_resource(to_remove));
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
}
-
void ResourcePreloaderEditor::_paste_pressed() {
- RES r=EditorSettings::get_singleton()->get_resource_clipboard();
+ RES r = EditorSettings::get_singleton()->get_resource_clipboard();
if (!r.is_valid()) {
dialog->set_text(TTR("Resource clipboard is empty!"));
dialog->set_title(TTR("Error!"));
@@ -175,31 +163,28 @@ void ResourcePreloaderEditor::_paste_pressed() {
}
String name = r->get_name();
- if (name=="")
- name=r->get_path().get_file();
- if (name=="")
- name=r->get_class();
+ if (name == "")
+ name = r->get_path().get_file();
+ if (name == "")
+ name = r->get_class();
String basename = name;
- int counter=1;
- while(preloader->has_resource(name)) {
+ int counter = 1;
+ while (preloader->has_resource(name)) {
counter++;
- name=basename+" "+itos(counter);
+ name = basename + " " + itos(counter);
}
undo_redo->create_action(TTR("Paste Resource"));
- undo_redo->add_do_method(preloader,"add_resource",name,r);
- undo_redo->add_undo_method(preloader,"remove_resource",name);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(preloader, "add_resource", name, r);
+ undo_redo->add_undo_method(preloader, "remove_resource", name);
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
-
}
-
void ResourcePreloaderEditor::_delete_pressed() {
-
if (!tree->get_selected())
return;
@@ -211,10 +196,8 @@ void ResourcePreloaderEditor::_delete_pressed() {
//dialog->get_ok()->show();
dialog->get_ok()->set_text("Remove");
dialog->popup_centered(Size2(300,60));*/
-
}
-
void ResourcePreloaderEditor::_update_library() {
tree->clear();
@@ -225,46 +208,40 @@ void ResourcePreloaderEditor::_update_library() {
preloader->get_resource_list(&rnames);
List<String> names;
- for(List<StringName>::Element *E=rnames.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = rnames.front(); E; E = E->next()) {
names.push_back(E->get());
}
names.sort();
- for(List<String>::Element *E=names.front();E;E=E->next()) {
+ for (List<String>::Element *E = names.front(); E; E = E->next()) {
TreeItem *ti = tree->create_item(root);
- ti->set_cell_mode(0,TreeItem::CELL_MODE_STRING);
- ti->set_editable(0,true);
- ti->set_selectable(0,true);
- ti->set_text(0,E->get());
- ti->set_metadata(0,E->get());
-
-
+ ti->set_cell_mode(0, TreeItem::CELL_MODE_STRING);
+ ti->set_editable(0, true);
+ ti->set_selectable(0, true);
+ ti->set_text(0, E->get());
+ ti->set_metadata(0, E->get());
RES r = preloader->get_resource(E->get());
ERR_CONTINUE(r.is_null());
- ti->set_tooltip(0,r->get_path());
+ ti->set_tooltip(0, r->get_path());
String type = r->get_class();
- ti->set_text(1,type);
- ti->set_selectable(1,false);
-
- if (has_icon(type,"EditorIcons"))
- ti->set_icon( 1, get_icon(type,"EditorIcons") );
+ ti->set_text(1, type);
+ ti->set_selectable(1, false);
+ if (has_icon(type, "EditorIcons"))
+ ti->set_icon(1, get_icon(type, "EditorIcons"));
}
//player->add_resource("default",resource);
}
+void ResourcePreloaderEditor::edit(ResourcePreloader *p_preloader) {
-
-void ResourcePreloaderEditor::edit(ResourcePreloader* p_preloader) {
-
- preloader=p_preloader;
-
+ preloader = p_preloader;
if (p_preloader) {
_update_library();
@@ -273,14 +250,11 @@ void ResourcePreloaderEditor::edit(ResourcePreloader* p_preloader) {
hide();
set_fixed_process(false);
}
-
}
+Variant ResourcePreloaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
-Variant ResourcePreloaderEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) {
-
- TreeItem*ti =tree->get_item_at_pos(p_point);
+ TreeItem *ti = tree->get_item_at_pos(p_point);
if (!ti)
return Variant();
@@ -290,45 +264,40 @@ Variant ResourcePreloaderEditor::get_drag_data_fw(const Point2& p_point,Control*
if (!res.is_valid())
return Variant();
- return EditorNode::get_singleton()->drag_resource(res,p_from);
-
+ return EditorNode::get_singleton()->drag_resource(res, p_from);
}
-bool ResourcePreloaderEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const {
-
-
+bool ResourcePreloaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
Dictionary d = p_data;
if (!d.has("type"))
return false;
- if (d.has("from") && (Object*)(d["from"])==tree)
+ if (d.has("from") && (Object *)(d["from"]) == tree)
return false;
- if (String(d["type"])=="resource" && d.has("resource")) {
- RES r=d["resource"];
+ if (String(d["type"]) == "resource" && d.has("resource")) {
+ RES r = d["resource"];
return r.is_valid();
}
-
- if (String(d["type"])=="files") {
+ if (String(d["type"]) == "files") {
Vector<String> files = d["files"];
- if (files.size()==0)
+ if (files.size() == 0)
return false;
return true;
-
}
return false;
}
-void ResourcePreloaderEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) {
+void ResourcePreloaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
- if (!can_drop_data_fw(p_point,p_data,p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from))
return;
Dictionary d = p_data;
@@ -336,39 +305,37 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2& p_point,const Variant&
if (!d.has("type"))
return;
-
- if (String(d["type"])=="resource" && d.has("resource")) {
- RES r=d["resource"];
+ if (String(d["type"]) == "resource" && d.has("resource")) {
+ RES r = d["resource"];
if (r.is_valid()) {
String basename;
- if (r->get_name()!="") {
- basename=r->get_name();
+ if (r->get_name() != "") {
+ basename = r->get_name();
} else if (r->get_path().is_resource_file()) {
basename = r->get_path().get_basename();
} else {
- basename="Resource";
+ basename = "Resource";
}
- String name=basename;
- int counter=0;
- while(preloader->has_resource(name)) {
+ String name = basename;
+ int counter = 0;
+ while (preloader->has_resource(name)) {
counter++;
- name=basename+"_"+itos(counter);
+ name = basename + "_" + itos(counter);
}
undo_redo->create_action(TTR("Add Resource"));
- undo_redo->add_do_method(preloader,"add_resource",name,r);
- undo_redo->add_undo_method(preloader,"remove_resource",name);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(preloader, "add_resource", name, r);
+ undo_redo->add_undo_method(preloader, "remove_resource", name);
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
}
}
-
- if (String(d["type"])=="files") {
+ if (String(d["type"]) == "files") {
Vector<String> files = d["files"];
@@ -376,83 +343,73 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2& p_point,const Variant&
}
}
-
-
void ResourcePreloaderEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_gui_input"),&ResourcePreloaderEditor::_gui_input);
- ClassDB::bind_method(D_METHOD("_load_pressed"),&ResourcePreloaderEditor::_load_pressed);
- ClassDB::bind_method(D_METHOD("_item_edited"),&ResourcePreloaderEditor::_item_edited);
- ClassDB::bind_method(D_METHOD("_delete_pressed"),&ResourcePreloaderEditor::_delete_pressed);
- ClassDB::bind_method(D_METHOD("_paste_pressed"),&ResourcePreloaderEditor::_paste_pressed);
- ClassDB::bind_method(D_METHOD("_delete_confirm_pressed"),&ResourcePreloaderEditor::_delete_confirm_pressed);
- ClassDB::bind_method(D_METHOD("_files_load_request"),&ResourcePreloaderEditor::_files_load_request);
- ClassDB::bind_method(D_METHOD("_update_library"),&ResourcePreloaderEditor::_update_library);
-
+ ClassDB::bind_method(D_METHOD("_gui_input"), &ResourcePreloaderEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_load_pressed"), &ResourcePreloaderEditor::_load_pressed);
+ ClassDB::bind_method(D_METHOD("_item_edited"), &ResourcePreloaderEditor::_item_edited);
+ ClassDB::bind_method(D_METHOD("_delete_pressed"), &ResourcePreloaderEditor::_delete_pressed);
+ ClassDB::bind_method(D_METHOD("_paste_pressed"), &ResourcePreloaderEditor::_paste_pressed);
+ ClassDB::bind_method(D_METHOD("_delete_confirm_pressed"), &ResourcePreloaderEditor::_delete_confirm_pressed);
+ ClassDB::bind_method(D_METHOD("_files_load_request"), &ResourcePreloaderEditor::_files_load_request);
+ ClassDB::bind_method(D_METHOD("_update_library"), &ResourcePreloaderEditor::_update_library);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &ResourcePreloaderEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &ResourcePreloaderEditor::can_drop_data_fw);
ClassDB::bind_method(D_METHOD("drop_data_fw"), &ResourcePreloaderEditor::drop_data_fw);
-
-
}
ResourcePreloaderEditor::ResourcePreloaderEditor() {
//add_style_override("panel", get_stylebox("panel","Panel"));
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
- HBoxContainer *hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
vbc->add_child(hbc);
- load = memnew( Button );
+ load = memnew(Button);
load->set_tooltip(TTR("Load Resource"));
hbc->add_child(load);
-
-
- _delete = memnew( Button );
+ _delete = memnew(Button);
hbc->add_child(_delete);
- paste = memnew( Button );
+ paste = memnew(Button);
paste->set_text(TTR("Paste"));
hbc->add_child(paste);
- file = memnew( EditorFileDialog );
+ file = memnew(EditorFileDialog);
add_child(file);
-
- tree = memnew( Tree );
+ tree = memnew(Tree);
tree->set_columns(2);
- tree->set_column_min_width(0,3);
- tree->set_column_min_width(1,1);
- tree->set_column_expand(0,true);
- tree->set_column_expand(1,true);
+ tree->set_column_min_width(0, 3);
+ tree->set_column_min_width(1, 1);
+ tree->set_column_expand(0, true);
+ tree->set_column_expand(1, true);
tree->set_v_size_flags(SIZE_EXPAND_FILL);
tree->set_drag_forwarding(this);
vbc->add_child(tree);
- dialog = memnew( AcceptDialog );
- add_child( dialog );
+ dialog = memnew(AcceptDialog);
+ add_child(dialog);
- load->connect("pressed", this,"_load_pressed");
- _delete->connect("pressed", this,"_delete_pressed");
- paste->connect("pressed", this,"_paste_pressed");
- file->connect("files_selected", this,"_files_load_request");
+ load->connect("pressed", this, "_load_pressed");
+ _delete->connect("pressed", this, "_delete_pressed");
+ paste->connect("pressed", this, "_paste_pressed");
+ file->connect("files_selected", this, "_files_load_request");
//dialog->connect("confirmed", this,"_delete_confirm_pressed");
- tree->connect("item_edited", this,"_item_edited");
- loading_scene=false;
-
+ tree->connect("item_edited", this, "_item_edited");
+ loading_scene = false;
}
-
void ResourcePreloaderEditorPlugin::edit(Object *p_object) {
preloader_editor->set_undo_redo(&get_undo_redo());
- ResourcePreloader * s = p_object->cast_to<ResourcePreloader>();
+ ResourcePreloader *s = p_object->cast_to<ResourcePreloader>();
if (!s)
return;
@@ -479,29 +436,20 @@ void ResourcePreloaderEditorPlugin::make_visible(bool p_visible) {
//preloader_editor->hide();
//preloader_editor->set_process(false);
}
-
}
ResourcePreloaderEditorPlugin::ResourcePreloaderEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- preloader_editor = memnew( ResourcePreloaderEditor );
- preloader_editor->set_custom_minimum_size(Size2(0,250));
+ editor = p_node;
+ preloader_editor = memnew(ResourcePreloaderEditor);
+ preloader_editor->set_custom_minimum_size(Size2(0, 250));
- button=editor->add_bottom_panel_item("ResourcePreloader",preloader_editor);
+ button = editor->add_bottom_panel_item("ResourcePreloader", preloader_editor);
button->hide();
//preloader_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END);
//preloader_editor->set_margin( MARGIN_TOP, 120 );
-
-
-
-
}
-
-ResourcePreloaderEditorPlugin::~ResourcePreloaderEditorPlugin()
-{
+ResourcePreloaderEditorPlugin::~ResourcePreloaderEditorPlugin() {
}
-
-
diff --git a/editor/plugins/resource_preloader_editor_plugin.h b/editor/plugins/resource_preloader_editor_plugin.h
index 54ccad4341..946a3887ef 100644
--- a/editor/plugins/resource_preloader_editor_plugin.h
+++ b/editor/plugins/resource_preloader_editor_plugin.h
@@ -29,18 +29,16 @@
#ifndef RESOURCE_PRELOADER_EDITOR_PLUGIN_H
#define RESOURCE_PRELOADER_EDITOR_PLUGIN_H
-
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/file_dialog.h"
#include "scene/gui/tree.h"
#include "scene/main/resource_preloader.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/dialogs.h"
-
class ResourcePreloaderEditor : public PanelContainer {
- GDCLASS(ResourcePreloaderEditor, PanelContainer );
+ GDCLASS(ResourcePreloaderEditor, PanelContainer);
Button *load;
Button *_delete;
@@ -48,17 +46,15 @@ class ResourcePreloaderEditor : public PanelContainer {
Tree *tree;
bool loading_scene;
-
EditorFileDialog *file;
AcceptDialog *dialog;
ResourcePreloader *preloader;
-
void _load_pressed();
void _load_scene_pressed();
- void _files_load_request(const Vector<String>& p_paths);
+ void _files_load_request(const Vector<String> &p_paths);
void _paste_pressed();
void _delete_pressed();
void _delete_confirm_pressed();
@@ -67,33 +63,31 @@ class ResourcePreloaderEditor : public PanelContainer {
UndoRedo *undo_redo;
- Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
- bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
- void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
-
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
protected:
void _notification(int p_what);
void _gui_input(InputEvent p_event);
static void _bind_methods();
-public:
- void set_undo_redo(UndoRedo *p_undo_redo) {undo_redo=p_undo_redo; }
+public:
+ void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
- void edit(ResourcePreloader* p_preloader);
+ void edit(ResourcePreloader *p_preloader);
ResourcePreloaderEditor();
};
class ResourcePreloaderEditorPlugin : public EditorPlugin {
- GDCLASS( ResourcePreloaderEditorPlugin, EditorPlugin );
+ GDCLASS(ResourcePreloaderEditorPlugin, EditorPlugin);
ResourcePreloaderEditor *preloader_editor;
EditorNode *editor;
Button *button;
public:
-
virtual String get_name() const { return "ResourcePreloader"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -102,7 +96,6 @@ public:
ResourcePreloaderEditorPlugin(EditorNode *p_node);
~ResourcePreloaderEditorPlugin();
-
};
#endif // RESOURCE_PRELOADER_EDITOR_PLUGIN_H
diff --git a/editor/plugins/rich_text_editor_plugin.cpp b/editor/plugins/rich_text_editor_plugin.cpp
index 797ee8e8ea..72a9278e62 100644
--- a/editor/plugins/rich_text_editor_plugin.cpp
+++ b/editor/plugins/rich_text_editor_plugin.cpp
@@ -28,39 +28,35 @@
/*************************************************************************/
#include "rich_text_editor_plugin.h"
-#include "os/file_access.h"
#include "canvas_item_editor_plugin.h"
+#include "os/file_access.h"
void RichTextEditor::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_FIXED_PROCESS: {
-
} break;
}
-
}
void RichTextEditor::_node_removed(Node *p_node) {
- if(p_node==node) {
- node=NULL;
+ if (p_node == node) {
+ node = NULL;
hide();
}
-
}
-
-void RichTextEditor::_file_selected(const String& p_path) {
+void RichTextEditor::_file_selected(const String &p_path) {
CharString cs;
- FileAccess *fa = FileAccess::open(p_path,FileAccess::READ);
+ FileAccess *fa = FileAccess::open(p_path, FileAccess::READ);
if (!fa) {
ERR_FAIL();
}
- while(!fa->eof_reached())
+ while (!fa->eof_reached())
cs.push_back(fa->get_8());
cs.push_back(0);
memdelete(fa);
@@ -68,12 +64,11 @@ void RichTextEditor::_file_selected(const String& p_path) {
String bbcode;
bbcode.parse_utf8(&cs[0]);
node->parse_bbcode(bbcode);
-
}
void RichTextEditor::_menu_option(int p_option) {
- switch(p_option) {
+ switch (p_option) {
case PARSE_BBCODE: {
@@ -84,42 +79,38 @@ void RichTextEditor::_menu_option(int p_option) {
node->clear();
} break;
-
}
}
void RichTextEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_menu_option"),&RichTextEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_file_selected"),&RichTextEditor::_file_selected);
-
+ ClassDB::bind_method(D_METHOD("_menu_option"), &RichTextEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_file_selected"), &RichTextEditor::_file_selected);
}
void RichTextEditor::edit(Node *p_rich_text) {
- node=p_rich_text->cast_to<RichTextLabel>();
-
+ node = p_rich_text->cast_to<RichTextLabel>();
}
RichTextEditor::RichTextEditor() {
- options = memnew( MenuButton );
+ options = memnew(MenuButton);
//add_child(options);
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options);
options->set_area_as_parent_rect();
options->set_text("RichText");
- options->get_popup()->add_item(TTR("Parse BBCode"),PARSE_BBCODE);
- options->get_popup()->add_item(TTR("Clear"),CLEAR);
+ options->get_popup()->add_item(TTR("Parse BBCode"), PARSE_BBCODE);
+ options->get_popup()->add_item(TTR("Clear"), CLEAR);
- options->get_popup()->connect("id_pressed", this,"_menu_option");
- file_dialog = memnew( EditorFileDialog );
+ options->get_popup()->connect("id_pressed", this, "_menu_option");
+ file_dialog = memnew(EditorFileDialog);
add_child(file_dialog);
file_dialog->add_filter("*.txt");
file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- file_dialog->connect("file_selected",this,"_file_selected");
+ file_dialog->connect("file_selected", this, "_file_selected");
}
-
void RichTextEditorPlugin::edit(Object *p_object) {
rich_text_editor->edit(p_object->cast_to<Node>());
@@ -139,26 +130,21 @@ void RichTextEditorPlugin::make_visible(bool p_visible) {
rich_text_editor->options->hide();
rich_text_editor->edit(NULL);
}
-
}
RichTextEditorPlugin::RichTextEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- rich_text_editor = memnew( RichTextEditor );
+ editor = p_node;
+ rich_text_editor = memnew(RichTextEditor);
editor->get_viewport()->add_child(rich_text_editor);
- rich_text_editor->set_margin(MARGIN_LEFT,184);
- rich_text_editor->set_margin(MARGIN_RIGHT,230);
- rich_text_editor->set_margin(MARGIN_TOP,0);
- rich_text_editor->set_margin(MARGIN_BOTTOM,10);
+ rich_text_editor->set_margin(MARGIN_LEFT, 184);
+ rich_text_editor->set_margin(MARGIN_RIGHT, 230);
+ rich_text_editor->set_margin(MARGIN_TOP, 0);
+ rich_text_editor->set_margin(MARGIN_BOTTOM, 10);
rich_text_editor->options->hide();
-
}
-
-RichTextEditorPlugin::~RichTextEditorPlugin()
-{
+RichTextEditorPlugin::~RichTextEditorPlugin() {
}
-
diff --git a/editor/plugins/rich_text_editor_plugin.h b/editor/plugins/rich_text_editor_plugin.h
index c7f95fb479..ab3c252fcf 100644
--- a/editor/plugins/rich_text_editor_plugin.h
+++ b/editor/plugins/rich_text_editor_plugin.h
@@ -29,10 +29,10 @@
#ifndef RICH_TEXT_EDITOR_PLUGIN_H
#define RICH_TEXT_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
-#include "scene/gui/rich_text_label.h"
+#include "editor/editor_plugin.h"
#include "scene/gui/file_dialog.h"
+#include "scene/gui/rich_text_label.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -40,9 +40,9 @@
class RichTextEditor : public Control {
- GDCLASS(RichTextEditor, Control );
+ GDCLASS(RichTextEditor, Control);
- friend class RichTextEditorPlugin;
+ friend class RichTextEditorPlugin;
enum {
@@ -51,32 +51,31 @@ class RichTextEditor : public Control {
};
Panel *panel;
- MenuButton *options;
+ MenuButton *options;
RichTextLabel *node;
EditorFileDialog *file_dialog;
- void _file_selected(const String& p_path);
+ void _file_selected(const String &p_path);
void _menu_option(int p_option);
protected:
void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods();
-public:
+public:
void edit(Node *p_rich_text);
RichTextEditor();
};
class RichTextEditorPlugin : public EditorPlugin {
- GDCLASS( RichTextEditorPlugin, EditorPlugin );
+ GDCLASS(RichTextEditorPlugin, EditorPlugin);
RichTextEditor *rich_text_editor;
EditorNode *editor;
public:
-
virtual String get_name() const { return "RichText"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -85,7 +84,6 @@ public:
RichTextEditorPlugin(EditorNode *p_node);
~RichTextEditorPlugin();
-
};
#endif // RICH_TEXT_EDITOR_PLUGIN_H
diff --git a/editor/plugins/sample_editor_plugin.cpp b/editor/plugins/sample_editor_plugin.cpp
index b6b96c946e..4d685f4289 100644
--- a/editor/plugins/sample_editor_plugin.cpp
+++ b/editor/plugins/sample_editor_plugin.cpp
@@ -29,9 +29,9 @@
#include "sample_editor_plugin.h"
#if 0
-#include "io/resource_loader.h"
-#include "global_config.h"
#include "editor/editor_settings.h"
+#include "global_config.h"
+#include "io/resource_loader.h"
diff --git a/editor/plugins/sample_editor_plugin.h b/editor/plugins/sample_editor_plugin.h
index dae9cef9f4..0e7bccffa7 100644
--- a/editor/plugins/sample_editor_plugin.h
+++ b/editor/plugins/sample_editor_plugin.h
@@ -30,8 +30,8 @@
#define SAMPLE_EDITOR_PLUGIN_H
#if 0
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/audio/sample_player.h"
#include "scene/resources/sample.h"
#include "scene/resources/sample_library.h"
diff --git a/editor/plugins/sample_library_editor_plugin.cpp b/editor/plugins/sample_library_editor_plugin.cpp
index 4ead1d2709..c164428553 100644
--- a/editor/plugins/sample_library_editor_plugin.cpp
+++ b/editor/plugins/sample_library_editor_plugin.cpp
@@ -30,11 +30,11 @@
#if 0
#include "sample_library_editor_plugin.h"
-#include "io/resource_loader.h"
-#include "global_config.h"
#include "editor/editor_settings.h"
-#include "scene/main/viewport.h"
+#include "global_config.h"
+#include "io/resource_loader.h"
#include "sample_editor_plugin.h"
+#include "scene/main/viewport.h"
void SampleLibraryEditor::_gui_input(InputEvent p_event) {
diff --git a/editor/plugins/sample_library_editor_plugin.h b/editor/plugins/sample_library_editor_plugin.h
index 4bbc29b147..a41e1538b4 100644
--- a/editor/plugins/sample_library_editor_plugin.h
+++ b/editor/plugins/sample_library_editor_plugin.h
@@ -29,15 +29,14 @@
#ifndef SAMPLE_LIBRARY_EDITOR_PLUGIN_H
#define SAMPLE_LIBRARY_EDITOR_PLUGIN_H
-
#if 0
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/audio/sample_player.h"
-#include "scene/resources/sample.h"
-#include "scene/gui/tree.h"
-#include "scene/gui/file_dialog.h"
#include "scene/gui/dialogs.h"
+#include "scene/gui/file_dialog.h"
+#include "scene/gui/tree.h"
+#include "scene/resources/sample.h"
class SampleLibraryEditor : public Panel {
diff --git a/editor/plugins/sample_player_editor_plugin.cpp b/editor/plugins/sample_player_editor_plugin.cpp
index 7e2683dedf..a550d96d5c 100644
--- a/editor/plugins/sample_player_editor_plugin.cpp
+++ b/editor/plugins/sample_player_editor_plugin.cpp
@@ -30,7 +30,6 @@
#if 0
#include "sample_player_editor_plugin.h"
-
#include "scene/resources/sample_library.h"
@@ -199,5 +198,4 @@ SamplePlayerEditorPlugin::~SamplePlayerEditorPlugin()
{
}
-
#endif
diff --git a/editor/plugins/sample_player_editor_plugin.h b/editor/plugins/sample_player_editor_plugin.h
index c1d599540a..10a08b8a17 100644
--- a/editor/plugins/sample_player_editor_plugin.h
+++ b/editor/plugins/sample_player_editor_plugin.h
@@ -31,11 +31,11 @@
#if 0
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/3d/spatial_sample_player.h"
-#include "scene/gui/option_button.h"
#include "scene/audio/sample_player.h"
+#include "scene/gui/option_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 3631d39f9a..4e7a0709fa 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -28,44 +28,41 @@
/*************************************************************************/
#include "script_editor_plugin.h"
+#include "editor/editor_node.h"
#include "editor/editor_settings.h"
+#include "editor/script_editor_debugger.h"
+#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
+#include "os/file_access.h"
+#include "os/input.h"
+#include "os/keyboard.h"
#include "os/keyboard.h"
#include "os/os.h"
-#include "editor/editor_node.h"
-#include "editor/script_editor_debugger.h"
-#include "global_config.h"
-#include "os/file_access.h"
#include "scene/main/viewport.h"
-#include "os/keyboard.h"
-#include "os/input.h"
/*** SCRIPT EDITOR ****/
-
-
void ScriptEditorBase::_bind_methods() {
ADD_SIGNAL(MethodInfo("name_changed"));
- ADD_SIGNAL(MethodInfo("request_help_search",PropertyInfo(Variant::STRING,"topic")));
- ADD_SIGNAL(MethodInfo("request_open_script_at_line",PropertyInfo(Variant::OBJECT,"script"),PropertyInfo(Variant::INT,"line")));
+ ADD_SIGNAL(MethodInfo("request_help_search", PropertyInfo(Variant::STRING, "topic")));
+ ADD_SIGNAL(MethodInfo("request_open_script_at_line", PropertyInfo(Variant::OBJECT, "script"), PropertyInfo(Variant::INT, "line")));
ADD_SIGNAL(MethodInfo("request_save_history"));
- ADD_SIGNAL(MethodInfo("go_to_help",PropertyInfo(Variant::STRING,"what")));
-
+ ADD_SIGNAL(MethodInfo("go_to_help", PropertyInfo(Variant::STRING, "what")));
}
-static bool _can_open_in_editor(Script* p_script) {
+static bool _can_open_in_editor(Script *p_script) {
String path = p_script->get_path();
- if (path.find("::")!=-1) {
+ if (path.find("::") != -1) {
//refuse handling this if it can't be edited
- bool valid=false;
- for(int i=0;i<EditorNode::get_singleton()->get_editor_data().get_edited_scene_count();i++) {
+ bool valid = false;
+ for (int i = 0; i < EditorNode::get_singleton()->get_editor_data().get_edited_scene_count(); i++) {
if (path.begins_with(EditorNode::get_singleton()->get_editor_data().get_scene_path(i))) {
- valid=true;
+ valid = true;
break;
}
}
@@ -76,68 +73,63 @@ static bool _can_open_in_editor(Script* p_script) {
return true;
}
-
class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache {
-
struct Cache {
uint64_t time_loaded;
RES cache;
};
- Map<String,Cache> cached;
-
+ Map<String, Cache> cached;
public:
-
uint64_t max_time_cache;
int max_cache_size;
void cleanup() {
- List< Map<String,Cache>::Element * > to_clean;
+ List<Map<String, Cache>::Element *> to_clean;
-
- Map<String,Cache>::Element *I=cached.front();
- while(I) {
- if ((OS::get_singleton()->get_ticks_msec()-I->get().time_loaded)>max_time_cache) {
+ Map<String, Cache>::Element *I = cached.front();
+ while (I) {
+ if ((OS::get_singleton()->get_ticks_msec() - I->get().time_loaded) > max_time_cache) {
to_clean.push_back(I);
}
- I=I->next();
+ I = I->next();
}
- while(to_clean.front()) {
+ while (to_clean.front()) {
cached.erase(to_clean.front()->get());
to_clean.pop_front();
}
}
- RES get_cached_resource(const String& p_path) {
+ RES get_cached_resource(const String &p_path) {
- Map<String,Cache>::Element *E=cached.find(p_path);
+ Map<String, Cache>::Element *E = cached.find(p_path);
if (!E) {
Cache c;
- c.cache=ResourceLoader::load(p_path);
- E=cached.insert(p_path,c);
+ c.cache = ResourceLoader::load(p_path);
+ E = cached.insert(p_path, c);
}
- E->get().time_loaded=OS::get_singleton()->get_ticks_msec();
+ E->get().time_loaded = OS::get_singleton()->get_ticks_msec();
- if (cached.size()>max_cache_size) {
+ if (cached.size() > max_cache_size) {
uint64_t older;
- Map<String,Cache>::Element *O=cached.front();
- older=O->get().time_loaded;
- Map<String,Cache>::Element *I=O;
- while(I) {
- if (I->get().time_loaded<older) {
+ Map<String, Cache>::Element *O = cached.front();
+ older = O->get().time_loaded;
+ Map<String, Cache>::Element *I = O;
+ while (I) {
+ if (I->get().time_loaded < older) {
older = I->get().time_loaded;
- O=I;
+ O = I;
}
- I=I->next();
+ I = I->next();
}
- if (O!=E) {//should never heppane..
+ if (O != E) { //should never heppane..
cached.erase(O);
}
}
@@ -145,18 +137,16 @@ public:
return E->get().cache;
}
-
EditorScriptCodeCompletionCache() {
- max_cache_size=128;
- max_time_cache=5*60*1000; //minutes, five
+ max_cache_size = 128;
+ max_time_cache = 5 * 60 * 1000; //minutes, five
}
-
};
#define SORT_SCRIPT_LIST
-void ScriptEditorQuickOpen::popup(const Vector<String>& p_functions, bool p_dontclear) {
+void ScriptEditorQuickOpen::popup(const Vector<String> &p_functions, bool p_dontclear) {
popup_centered_ratio(0.6);
if (p_dontclear)
@@ -164,55 +154,45 @@ void ScriptEditorQuickOpen::popup(const Vector<String>& p_functions, bool p_dont
else
search_box->clear();
search_box->grab_focus();
- functions=p_functions;
+ functions = p_functions;
_update_search();
-
-
}
-
-void ScriptEditorQuickOpen::_text_changed(const String& p_newtext) {
+void ScriptEditorQuickOpen::_text_changed(const String &p_newtext) {
_update_search();
}
-void ScriptEditorQuickOpen::_sbox_input(const InputEvent& p_ie) {
+void ScriptEditorQuickOpen::_sbox_input(const InputEvent &p_ie) {
- if (p_ie.type==InputEvent::KEY && (
- p_ie.key.scancode == KEY_UP ||
- p_ie.key.scancode == KEY_DOWN ||
- p_ie.key.scancode == KEY_PAGEUP ||
- p_ie.key.scancode == KEY_PAGEDOWN ) ) {
+ if (p_ie.type == InputEvent::KEY && (p_ie.key.scancode == KEY_UP ||
+ p_ie.key.scancode == KEY_DOWN ||
+ p_ie.key.scancode == KEY_PAGEUP ||
+ p_ie.key.scancode == KEY_PAGEDOWN)) {
- search_options->call("_gui_input",p_ie);
+ search_options->call("_gui_input", p_ie);
search_box->accept_event();
}
-
}
-
-
void ScriptEditorQuickOpen::_update_search() {
-
search_options->clear();
TreeItem *root = search_options->create_item();
- for(int i=0;i<functions.size();i++) {
+ for (int i = 0; i < functions.size(); i++) {
String file = functions[i];
- if ((search_box->get_text()=="" || file.findn(search_box->get_text())!=-1)) {
+ if ((search_box->get_text() == "" || file.findn(search_box->get_text()) != -1)) {
TreeItem *ti = search_options->create_item(root);
- ti->set_text(0,file);
- if (root->get_children()==ti)
+ ti->set_text(0, file);
+ if (root->get_children() == ti)
ti->select(0);
-
}
}
- get_ok()->set_disabled(root->get_children()==NULL);
-
+ get_ok()->set_disabled(root->get_children() == NULL);
}
void ScriptEditorQuickOpen::_confirmed() {
@@ -220,88 +200,79 @@ void ScriptEditorQuickOpen::_confirmed() {
TreeItem *ti = search_options->get_selected();
if (!ti)
return;
- int line = ti->get_text(0).get_slice(":",1).to_int();
+ int line = ti->get_text(0).get_slice(":", 1).to_int();
- emit_signal("goto_line",line-1);
+ emit_signal("goto_line", line - 1);
hide();
}
void ScriptEditorQuickOpen::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
-
- connect("confirmed",this,"_confirmed");
-
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ connect("confirmed", this, "_confirmed");
}
}
-
-
-
void ScriptEditorQuickOpen::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_text_changed"),&ScriptEditorQuickOpen::_text_changed);
- ClassDB::bind_method(D_METHOD("_confirmed"),&ScriptEditorQuickOpen::_confirmed);
- ClassDB::bind_method(D_METHOD("_sbox_input"),&ScriptEditorQuickOpen::_sbox_input);
-
- ADD_SIGNAL(MethodInfo("goto_line",PropertyInfo(Variant::INT,"line")));
+ ClassDB::bind_method(D_METHOD("_text_changed"), &ScriptEditorQuickOpen::_text_changed);
+ ClassDB::bind_method(D_METHOD("_confirmed"), &ScriptEditorQuickOpen::_confirmed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"), &ScriptEditorQuickOpen::_sbox_input);
+ ADD_SIGNAL(MethodInfo("goto_line", PropertyInfo(Variant::INT, "line")));
}
-
ScriptEditorQuickOpen::ScriptEditorQuickOpen() {
-
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
//set_child_rect(vbc);
- search_box = memnew( LineEdit );
- vbc->add_margin_child(TTR("Search:"),search_box);
- search_box->connect("text_changed",this,"_text_changed");
- search_box->connect("gui_input",this,"_sbox_input");
- search_options = memnew( Tree );
- vbc->add_margin_child(TTR("Matches:"),search_options,true);
+ search_box = memnew(LineEdit);
+ vbc->add_margin_child(TTR("Search:"), search_box);
+ search_box->connect("text_changed", this, "_text_changed");
+ search_box->connect("gui_input", this, "_sbox_input");
+ search_options = memnew(Tree);
+ vbc->add_margin_child(TTR("Matches:"), search_options, true);
get_ok()->set_text(TTR("Open"));
get_ok()->set_disabled(true);
register_text_enter(search_box);
set_hide_on_ok(false);
- search_options->connect("item_activated",this,"_confirmed");
+ search_options->connect("item_activated", this, "_confirmed");
search_options->set_hide_root(true);
}
-
/////////////////////////////////
-ScriptEditor *ScriptEditor::script_editor=NULL;
+ScriptEditor *ScriptEditor::script_editor = NULL;
/*** SCRIPT EDITOR ******/
-String ScriptEditor::_get_debug_tooltip(const String&p_text,Node *_se) {
+String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) {
//ScriptEditorBase *se=_se->cast_to<ScriptEditorBase>();
String val = debugger->get_var_value(p_text);
- if (val!=String()) {
- return p_text+": "+val;
+ if (val != String()) {
+ return p_text + ": " + val;
} else {
return String();
}
}
-void ScriptEditor::_breaked(bool p_breaked,bool p_can_debug) {
+void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) {
if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
return;
}
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_NEXT), !(p_breaked && p_can_debug));
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_STEP), !(p_breaked && p_can_debug) );
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_BREAK), p_breaked );
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), !p_breaked );
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_NEXT), !(p_breaked && p_can_debug));
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_STEP), !(p_breaked && p_can_debug));
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), p_breaked);
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), !p_breaked);
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (!se) {
@@ -311,7 +282,6 @@ void ScriptEditor::_breaked(bool p_breaked,bool p_can_debug) {
se->set_debugger_active(p_breaked);
}
-
}
void ScriptEditor::_show_debugger(bool p_show) {
@@ -323,11 +293,10 @@ void ScriptEditor::_script_created(Ref<Script> p_script) {
editor->push_item(p_script.operator->());
}
-
void ScriptEditor::_goto_script_line2(int p_line) {
int selected = tab_container->get_current_tab();
- if (selected<0 || selected>=tab_container->get_child_count())
+ if (selected < 0 || selected >= tab_container->get_child_count())
return;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
@@ -335,54 +304,49 @@ void ScriptEditor::_goto_script_line2(int p_line) {
return;
current->goto_line(p_line);
-
}
-void ScriptEditor::_goto_script_line(REF p_script,int p_line) {
-
+void ScriptEditor::_goto_script_line(REF p_script, int p_line) {
editor->push_item(p_script.ptr());
int selected = tab_container->get_current_tab();
- if (selected<0 || selected>=tab_container->get_child_count())
+ if (selected < 0 || selected >= tab_container->get_child_count())
return;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
if (!current)
return;
- current->goto_line(p_line,true);
-
+ current->goto_line(p_line, true);
}
-
void ScriptEditor::_update_history_arrows() {
- script_back->set_disabled( history_pos<=0 );
- script_forward->set_disabled( history_pos>=history.size()-1 );
+ script_back->set_disabled(history_pos <= 0);
+ script_forward->set_disabled(history_pos >= history.size() - 1);
}
void ScriptEditor::_save_history() {
-
- if (history_pos>=0 && history_pos<history.size() && history[history_pos].control==tab_container->get_current_tab_control()) {
+ if (history_pos >= 0 && history_pos < history.size() && history[history_pos].control == tab_container->get_current_tab_control()) {
Node *n = tab_container->get_current_tab_control();
if (n->cast_to<ScriptEditorBase>()) {
- history[history_pos].state=n->cast_to<ScriptEditorBase>()->get_edit_state();
+ history[history_pos].state = n->cast_to<ScriptEditorBase>()->get_edit_state();
}
if (n->cast_to<EditorHelp>()) {
- history[history_pos].state=n->cast_to<EditorHelp>()->get_scroll();
+ history[history_pos].state = n->cast_to<EditorHelp>()->get_scroll();
}
}
- history.resize(history_pos+1);
+ history.resize(history_pos + 1);
ScriptHistory sh;
- sh.control=tab_container->get_current_tab_control();
- sh.state=Variant();
+ sh.control = tab_container->get_current_tab_control();
+ sh.state = Variant();
history.push_back(sh);
history_pos++;
@@ -390,7 +354,6 @@ void ScriptEditor::_save_history() {
_update_history_arrows();
}
-
void ScriptEditor::_go_to_tab(int p_idx) {
Node *cn = tab_container->get_child(p_idx);
@@ -400,29 +363,28 @@ void ScriptEditor::_go_to_tab(int p_idx) {
if (!c)
return;
- if (history_pos>=0 && history_pos<history.size() && history[history_pos].control==tab_container->get_current_tab_control()) {
+ if (history_pos >= 0 && history_pos < history.size() && history[history_pos].control == tab_container->get_current_tab_control()) {
Node *n = tab_container->get_current_tab_control();
if (n->cast_to<ScriptEditorBase>()) {
- history[history_pos].state=n->cast_to<ScriptEditorBase>()->get_edit_state();
+ history[history_pos].state = n->cast_to<ScriptEditorBase>()->get_edit_state();
}
if (n->cast_to<EditorHelp>()) {
- history[history_pos].state=n->cast_to<EditorHelp>()->get_scroll();
+ history[history_pos].state = n->cast_to<EditorHelp>()->get_scroll();
}
}
- history.resize(history_pos+1);
+ history.resize(history_pos + 1);
ScriptHistory sh;
- sh.control=c;
- sh.state=Variant();
+ sh.control = c;
+ sh.state = Variant();
history.push_back(sh);
history_pos++;
-
tab_container->set_current_tab(p_idx);
c = tab_container->get_current_tab_control();
@@ -437,23 +399,21 @@ void ScriptEditor::_go_to_tab(int p_idx) {
if (c->cast_to<EditorHelp>()) {
script_name_label->set_text(c->cast_to<EditorHelp>()->get_class());
- script_icon->set_texture(get_icon("Help","EditorIcons"));
+ script_icon->set_texture(get_icon("Help", "EditorIcons"));
if (is_visible_in_tree())
c->cast_to<EditorHelp>()->set_focused();
}
-
-
- c->set_meta("__editor_pass",++edit_pass);
+ c->set_meta("__editor_pass", ++edit_pass);
_update_history_arrows();
- _update_script_colors();
+ _update_script_colors();
_update_selected_editor_menu();
}
void ScriptEditor::_close_tab(int p_idx, bool p_save) {
int selected = p_idx;
- if (selected<0 || selected>=tab_container->get_child_count())
+ if (selected < 0 || selected >= tab_container->get_child_count())
return;
Node *tselected = tab_container->get_child(selected);
@@ -468,27 +428,27 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
}
//remove from history
- history.resize(history_pos+1);
+ history.resize(history_pos + 1);
- for(int i=0;i<history.size();i++) {
- if (history[i].control==tselected) {
+ for (int i = 0; i < history.size(); i++) {
+ if (history[i].control == tselected) {
history.remove(i);
i--;
history_pos--;
}
}
- if (history_pos>=history.size()) {
- history_pos=history.size()-1;
+ if (history_pos >= history.size()) {
+ history_pos = history.size() - 1;
}
int idx = tab_container->get_current_tab();
memdelete(tselected);
- if (idx>=tab_container->get_child_count())
- idx=tab_container->get_child_count()-1;
- if (idx>=0) {
+ if (idx >= tab_container->get_child_count())
+ idx = tab_container->get_child_count() - 1;
+ if (idx >= 0) {
- if (history_pos>=0) {
+ if (history_pos >= 0) {
idx = history[history_pos].control->get_index();
}
tab_container->set_current_tab(idx);
@@ -496,11 +456,8 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
//script_list->select(idx);
}
-
_update_history_arrows();
-
-
_update_script_names();
_save_layout();
}
@@ -508,10 +465,9 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
void ScriptEditor::_close_current_tab() {
_close_tab(tab_container->get_current_tab());
-
}
-void ScriptEditor::_close_discard_current_tab(const String& p_str) {
+void ScriptEditor::_close_discard_current_tab(const String &p_str) {
_close_tab(tab_container->get_current_tab(), false);
erase_tab_confirm->hide();
}
@@ -519,22 +475,20 @@ void ScriptEditor::_close_discard_current_tab(const String& p_str) {
void ScriptEditor::_close_docs_tab() {
int child_count = tab_container->get_child_count();
- for (int i = child_count-1; i>=0; i--) {
+ for (int i = child_count - 1; i >= 0; i--) {
EditorHelp *se = tab_container->get_child(i)->cast_to<EditorHelp>();
if (se) {
_close_tab(i);
}
-
}
-
}
void ScriptEditor::_close_all_tabs() {
int child_count = tab_container->get_child_count();
- for (int i = child_count-1; i>=0; i--) {
+ for (int i = child_count - 1; i >= 0; i--) {
tab_container->set_current_tab(i);
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
@@ -546,34 +500,30 @@ void ScriptEditor::_close_all_tabs() {
_ask_close_current_unsaved_tab(se);
continue;
}
-
}
_close_current_tab();
}
-
}
void ScriptEditor::_ask_close_current_unsaved_tab(ScriptEditorBase *current) {
- erase_tab_confirm->set_text("Close and save changes?\n\""+current->get_name()+"\"");
+ erase_tab_confirm->set_text("Close and save changes?\n\"" + current->get_name() + "\"");
erase_tab_confirm->popup_centered_minsize();
}
-
-void ScriptEditor::_resave_scripts(const String& p_str) {
+void ScriptEditor::_resave_scripts(const String &p_str) {
apply_scripts();
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (!se)
continue;
-
Ref<Script> script = se->get_edited_script();
- if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1)
+ if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1)
continue; //internal script, who cares
if (trim_trailing_whitespace_on_save) {
@@ -584,14 +534,11 @@ void ScriptEditor::_resave_scripts(const String& p_str) {
}
disk_changed->hide();
-
}
-void ScriptEditor::_reload_scripts(){
-
+void ScriptEditor::_reload_scripts() {
-
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (!se) {
@@ -599,46 +546,36 @@ void ScriptEditor::_reload_scripts(){
continue;
}
-
Ref<Script> script = se->get_edited_script();
- if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) {
+ if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) {
continue; //internal script, who cares
}
-
uint64_t last_date = script->get_last_modified_time();
uint64_t date = FileAccess::get_modified_time(script->get_path());
//printf("last date: %lli vs date: %lli\n",last_date,date);
- if (last_date==date) {
+ if (last_date == date) {
continue;
}
-
- Ref<Script> rel_script = ResourceLoader::load(script->get_path(),script->get_class(),true);
+ Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), true);
ERR_CONTINUE(!rel_script.is_valid());
- script->set_source_code( rel_script->get_source_code() );
- script->set_last_modified_time( rel_script->get_last_modified_time() );
+ script->set_source_code(rel_script->get_source_code());
+ script->set_last_modified_time(rel_script->get_last_modified_time());
script->reload();
se->reload_text();
-
-
}
disk_changed->hide();
_update_script_names();
-
}
+void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) {
-
-void ScriptEditor::_res_saved_callback(const Ref<Resource>& p_res) {
-
-
-
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (!se) {
@@ -646,105 +583,94 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource>& p_res) {
continue;
}
-
Ref<Script> script = se->get_edited_script();
- if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) {
+ if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) {
continue; //internal script, who cares
}
- if (script==p_res) {
+ if (script == p_res) {
se->tag_saved_version();
}
-
}
_update_script_names();
-
if (!pending_auto_reload && auto_reload_running_scripts) {
call_deferred("_live_auto_reload_running_scripts");
- pending_auto_reload=true;
+ pending_auto_reload = true;
}
}
void ScriptEditor::_live_auto_reload_running_scripts() {
- pending_auto_reload=false;
+ pending_auto_reload = false;
debugger->reload_scripts();
}
-
bool ScriptEditor::_test_script_times_on_disk(Ref<Script> p_for_script) {
-
disk_changed_list->clear();
TreeItem *r = disk_changed_list->create_item();
disk_changed_list->set_hide_root(true);
- bool need_ask=false;
- bool need_reload=false;
- bool use_autoreload=bool(EDITOR_DEF("text_editor/files/auto_reload_scripts_on_external_change",false));
-
+ bool need_ask = false;
+ bool need_reload = false;
+ bool use_autoreload = bool(EDITOR_DEF("text_editor/files/auto_reload_scripts_on_external_change", false));
-
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (se) {
Ref<Script> script = se->get_edited_script();
- if (p_for_script.is_valid() && p_for_script!=script)
+ if (p_for_script.is_valid() && p_for_script != script)
continue;
- if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1)
+ if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1)
continue; //internal script, who cares
-
uint64_t last_date = script->get_last_modified_time();
uint64_t date = FileAccess::get_modified_time(script->get_path());
//printf("last date: %lli vs date: %lli\n",last_date,date);
- if (last_date!=date) {
+ if (last_date != date) {
TreeItem *ti = disk_changed_list->create_item(r);
- ti->set_text(0,script->get_path().get_file());
+ ti->set_text(0, script->get_path().get_file());
if (!use_autoreload || se->is_unsaved()) {
- need_ask=true;
+ need_ask = true;
}
- need_reload=true;
+ need_reload = true;
//r->set_metadata(0,);
}
}
}
-
-
if (need_reload) {
if (!need_ask) {
script_editor->_reload_scripts();
- need_reload=false;
+ need_reload = false;
} else {
- disk_changed->call_deferred("popup_centered_ratio",0.5);
+ disk_changed->call_deferred("popup_centered_ratio", 0.5);
}
}
return need_reload;
}
-
void ScriptEditor::_file_dialog_action(String p_file) {
switch (file_dialog_option) {
case FILE_SAVE_THEME_AS: {
- if(!EditorSettings::get_singleton()->save_text_editor_theme_as(p_file)) {
+ if (!EditorSettings::get_singleton()->save_text_editor_theme_as(p_file)) {
editor->show_warning(TTR("Error while saving theme"), TTR("Error saving"));
}
} break;
case FILE_IMPORT_THEME: {
- if(!EditorSettings::get_singleton()->import_text_editor_theme(p_file)) {
+ if (!EditorSettings::get_singleton()->import_text_editor_theme(p_file)) {
editor->show_warning(TTR("Error importing theme"), TTR("Error importing"));
}
} break;
@@ -754,11 +680,10 @@ void ScriptEditor::_file_dialog_action(String p_file) {
void ScriptEditor::_menu_option(int p_option) {
-
- switch(p_option) {
+ switch (p_option) {
case FILE_NEW: {
script_create_dialog->config("Node", ".gd");
- script_create_dialog->popup_centered(Size2(300, 300)*EDSCALE);
+ script_create_dialog->popup_centered(Size2(300, 300) * EDSCALE);
} break;
case FILE_OPEN: {
@@ -785,7 +710,7 @@ void ScriptEditor::_menu_option(int p_option) {
EditorSettings::get_singleton()->load_text_editor_theme();
} break;
case FILE_SAVE_THEME: {
- if(!EditorSettings::get_singleton()->save_text_editor_theme()) {
+ if (!EditorSettings::get_singleton()->save_text_editor_theme()) {
editor->show_warning(TTR("Error while saving theme"), TTR("Error saving"));
}
} break;
@@ -807,17 +732,17 @@ void ScriptEditor::_menu_option(int p_option) {
String current;
- if (tab_container->get_tab_count()>0) {
- EditorHelp *eh = tab_container->get_child( tab_container->get_current_tab() )->cast_to<EditorHelp>();
+ if (tab_container->get_tab_count() > 0) {
+ EditorHelp *eh = tab_container->get_child(tab_container->get_current_tab())->cast_to<EditorHelp>();
if (eh) {
- current=eh->get_class();
+ current = eh->get_class();
}
}
help_index->popup();
- if (current!="") {
- help_index->call_deferred("select_class",current);
+ if (current != "") {
+ help_index->call_deferred("select_class", current);
}
} break;
case SEARCH_WEBSITE: {
@@ -834,8 +759,8 @@ void ScriptEditor::_menu_option(int p_option) {
} break;
case DEBUG_SHOW: {
if (debugger) {
- bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW) );
- debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), !visible);
+ bool visible = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_SHOW));
+ debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_SHOW), !visible);
if (visible)
debugger->hide();
else
@@ -843,25 +768,24 @@ void ScriptEditor::_menu_option(int p_option) {
}
} break;
case DEBUG_SHOW_KEEP_OPEN: {
- bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN) );
+ bool visible = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN));
if (debugger)
debugger->set_hide_on_stop(visible);
- debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN), !visible);
+ debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN), !visible);
} break;
}
-
int selected = tab_container->get_current_tab();
- if (selected<0 || selected>=tab_container->get_child_count())
+ if (selected < 0 || selected >= tab_container->get_child_count())
return;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
if (current) {
- switch(p_option) {
+ switch (p_option) {
case FILE_NEW: {
script_create_dialog->config("Node", ".gd");
- script_create_dialog->popup_centered(Size2(300, 300)*EDSCALE);
+ script_create_dialog->popup_centered(Size2(300, 300) * EDSCALE);
} break;
case FILE_SAVE: {
@@ -870,21 +794,21 @@ void ScriptEditor::_menu_option(int p_option) {
if (trim_trailing_whitespace_on_save)
current->trim_trailing_whitespace();
- editor->save_resource( current->get_edited_script() );
+ editor->save_resource(current->get_edited_script());
} break;
case FILE_SAVE_AS: {
current->trim_trailing_whitespace();
editor->push_item(current->get_edited_script()->cast_to<Object>());
- editor->save_resource_as( current->get_edited_script() );
+ editor->save_resource_as(current->get_edited_script());
} break;
case FILE_TOOL_RELOAD:
case FILE_TOOL_RELOAD_SOFT: {
- current->reload(p_option==FILE_TOOL_RELOAD_SOFT);
+ current->reload(p_option == FILE_TOOL_RELOAD_SOFT);
} break;
@@ -926,32 +850,30 @@ void ScriptEditor::_menu_option(int p_option) {
} break;
case WINDOW_MOVE_LEFT: {
- if (tab_container->get_current_tab()>0) {
- tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()-1);
- script_list->call_deferred("select",tab_container->get_current_tab()-1);
- tab_container->move_child(current,tab_container->get_current_tab()-1);
+ if (tab_container->get_current_tab() > 0) {
+ tab_container->call_deferred("set_current_tab", tab_container->get_current_tab() - 1);
+ script_list->call_deferred("select", tab_container->get_current_tab() - 1);
+ tab_container->move_child(current, tab_container->get_current_tab() - 1);
_update_script_names();
}
} break;
case WINDOW_MOVE_RIGHT: {
- if (tab_container->get_current_tab()<tab_container->get_child_count()-1) {
- tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()+1);
- script_list->call_deferred("select",tab_container->get_current_tab()+1);
- tab_container->move_child(current,tab_container->get_current_tab()+1);
+ if (tab_container->get_current_tab() < tab_container->get_child_count() - 1) {
+ tab_container->call_deferred("set_current_tab", tab_container->get_current_tab() + 1);
+ script_list->call_deferred("select", tab_container->get_current_tab() + 1);
+ tab_container->move_child(current, tab_container->get_current_tab() + 1);
_update_script_names();
}
-
} break;
default: {
- if (p_option>=WINDOW_SELECT_BASE) {
-
- tab_container->set_current_tab(p_option-WINDOW_SELECT_BASE);
- script_list->select(p_option-WINDOW_SELECT_BASE);
+ if (p_option >= WINDOW_SELECT_BASE) {
+ tab_container->set_current_tab(p_option - WINDOW_SELECT_BASE);
+ script_list->select(p_option - WINDOW_SELECT_BASE);
}
}
}
@@ -960,7 +882,7 @@ void ScriptEditor::_menu_option(int p_option) {
EditorHelp *help = tab_container->get_current_tab_control()->cast_to<EditorHelp>();
if (help) {
- switch(p_option) {
+ switch (p_option) {
case HELP_SEARCH_FIND: {
help->popup_search();
@@ -977,12 +899,8 @@ void ScriptEditor::_menu_option(int p_option) {
case CLOSE_ALL: {
_close_all_tabs();
} break;
-
-
}
}
-
-
}
void ScriptEditor::_tab_changed(int p_which) {
@@ -992,19 +910,19 @@ void ScriptEditor::_tab_changed(int p_which) {
void ScriptEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- editor->connect("play_pressed",this,"_editor_play");
- editor->connect("pause_pressed",this,"_editor_pause");
- editor->connect("stop_pressed",this,"_editor_stop");
- editor->connect("script_add_function_request",this,"_add_callback");
- editor->connect("resource_saved",this,"_res_saved_callback");
- script_list->connect("item_selected",this,"_script_selected");
- script_split->connect("dragged",this,"_script_split_dragged");
- autosave_timer->connect("timeout",this,"_autosave_scripts");
+ editor->connect("play_pressed", this, "_editor_play");
+ editor->connect("pause_pressed", this, "_editor_pause");
+ editor->connect("stop_pressed", this, "_editor_stop");
+ editor->connect("script_add_function_request", this, "_add_callback");
+ editor->connect("resource_saved", this, "_res_saved_callback");
+ script_list->connect("item_selected", this, "_script_selected");
+ script_split->connect("dragged", this, "_script_split_dragged");
+ autosave_timer->connect("timeout", this, "_autosave_scripts");
{
float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs");
- if (autosave_time>0) {
+ if (autosave_time > 0) {
autosave_timer->set_wait_time(autosave_time);
autosave_timer->start();
} else {
@@ -1012,65 +930,54 @@ void ScriptEditor::_notification(int p_what) {
}
}
- EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");
- help_search->set_icon(get_icon("Help","EditorIcons"));
- site_search->set_icon(get_icon("Godot","EditorIcons"));
- class_search->set_icon(get_icon("ClassList","EditorIcons"));
-
- script_forward->set_icon(get_icon("Forward","EditorIcons"));
- script_back->set_icon(get_icon("Back","EditorIcons"));
-
-
-
+ EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
+ help_search->set_icon(get_icon("Help", "EditorIcons"));
+ site_search->set_icon(get_icon("Godot", "EditorIcons"));
+ class_search->set_icon(get_icon("ClassList", "EditorIcons"));
+ script_forward->set_icon(get_icon("Forward", "EditorIcons"));
+ script_back->set_icon(get_icon("Back", "EditorIcons"));
}
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
- get_tree()->connect("tree_changed",this,"_tree_changed");
- editor->connect("request_help",this,"_request_help");
+ get_tree()->connect("tree_changed", this, "_tree_changed");
+ editor->connect("request_help", this, "_request_help");
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
-
- editor->disconnect("play_pressed",this,"_editor_play");
- editor->disconnect("pause_pressed",this,"_editor_pause");
- editor->disconnect("stop_pressed",this,"_editor_stop");
+ if (p_what == NOTIFICATION_EXIT_TREE) {
+ editor->disconnect("play_pressed", this, "_editor_play");
+ editor->disconnect("pause_pressed", this, "_editor_pause");
+ editor->disconnect("stop_pressed", this, "_editor_stop");
}
- if (p_what==MainLoop::NOTIFICATION_WM_FOCUS_IN) {
+ if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
_test_script_times_on_disk();
_update_modified_scripts_for_external_editor();
}
- if (p_what==NOTIFICATION_PROCESS) {
-
+ if (p_what == NOTIFICATION_PROCESS) {
}
-
}
bool ScriptEditor::can_take_away_focus() const {
int selected = tab_container->get_current_tab();
- if (selected<0 || selected>=tab_container->get_child_count())
+ if (selected < 0 || selected >= tab_container->get_child_count())
return true;
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
if (!current)
return true;
-
return current->can_lose_focus_on_node_selection();
-
}
-void ScriptEditor::close_builtin_scripts_from_scene(const String& p_scene) {
-
+void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
-
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
@@ -1080,32 +987,27 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String& p_scene) {
if (!script.is_valid())
continue;
- if (script->get_path().find("::")!=-1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
+ if (script->get_path().find("::") != -1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
_close_tab(i);
i--;
-
}
}
-
}
-
-
}
void ScriptEditor::edited_scene_changed() {
_update_modified_scripts_for_external_editor();
-
}
-static const Node * _find_node_with_script(const Node* p_node, const RefPtr & p_script) {
+static const Node *_find_node_with_script(const Node *p_node, const RefPtr &p_script) {
- if (p_node->get_script()==p_script)
+ if (p_node->get_script() == p_script)
return p_node;
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- const Node *result = _find_node_with_script(p_node->get_child(i),p_script);
+ const Node *result = _find_node_with_script(p_node->get_child(i), p_script);
if (result)
return result;
}
@@ -1115,7 +1017,6 @@ static const Node * _find_node_with_script(const Node* p_node, const RefPtr & p_
Dictionary ScriptEditor::get_state() const {
-
//apply_scripts();
Dictionary state;
@@ -1155,7 +1056,7 @@ Dictionary ScriptEditor::get_state() const {
#endif
return state;
}
-void ScriptEditor::set_state(const Dictionary& p_state) {
+void ScriptEditor::set_state(const Dictionary &p_state) {
#if 0
print_line("attempt set state: "+String(Variant(p_state)));
@@ -1195,7 +1096,6 @@ void ScriptEditor::set_state(const Dictionary& p_state) {
tab_container->set_current_tab(p_state["current"]);
}
#endif
-
}
void ScriptEditor::clear() {
#if 0
@@ -1224,15 +1124,11 @@ void ScriptEditor::clear() {
}
#endif
-
-
}
-
void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
-
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (!se)
@@ -1242,27 +1138,23 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
se->get_breakpoints(&bpoints);
Ref<Script> script = se->get_edited_script();
String base = script->get_path();
- ERR_CONTINUE( base.begins_with("local://") || base=="" );
+ ERR_CONTINUE(base.begins_with("local://") || base == "");
- for(List<int>::Element *E=bpoints.front();E;E=E->next()) {
+ for (List<int>::Element *E = bpoints.front(); E; E = E->next()) {
- p_breakpoints->push_back(base+":"+itos(E->get()+1));
+ p_breakpoints->push_back(base + ":" + itos(E->get() + 1));
}
}
-
}
-
-
-
-
void ScriptEditor::ensure_focus_current() {
if (!is_inside_tree())
return;
int cidx = tab_container->get_current_tab();
- if (cidx<0 || cidx>=tab_container->get_tab_count());
+ if (cidx < 0 || cidx >= tab_container->get_tab_count())
+ ;
Control *c = tab_container->get_child(cidx)->cast_to<Control>();
if (!c)
return;
@@ -1277,17 +1169,15 @@ void ScriptEditor::_script_selected(int p_idx) {
grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing
_go_to_tab(script_list->get_item_metadata(p_idx));
- grab_focus_block=false;
+ grab_focus_block = false;
}
void ScriptEditor::ensure_select_current() {
-
- if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) {
+ if (tab_container->get_child_count() && tab_container->get_current_tab() >= 0) {
Node *current = tab_container->get_child(tab_container->get_current_tab());
-
ScriptEditorBase *se = current->cast_to<ScriptEditorBase>();
if (se) {
@@ -1296,11 +1186,8 @@ void ScriptEditor::ensure_select_current() {
if (!grab_focus_block && is_visible_in_tree())
se->ensure_focus();
-
//edit_menu->show();
//search_menu->show();
-
-
}
EditorHelp *eh = current->cast_to<EditorHelp>();
@@ -1309,18 +1196,14 @@ void ScriptEditor::ensure_select_current() {
//edit_menu->hide();
//search_menu->hide();
//script_search_menu->show();
-
}
}
_update_selected_editor_menu();
-
-
-
}
-void ScriptEditor::_find_scripts(Node* p_base, Node* p_current, Set<Ref<Script> > &used) {
- if (p_current!=p_base && p_current->get_owner()!=p_base)
+void ScriptEditor::_find_scripts(Node *p_base, Node *p_current, Set<Ref<Script> > &used) {
+ if (p_current != p_base && p_current->get_owner() != p_base)
return;
if (p_current->get_script_instance()) {
@@ -1329,10 +1212,9 @@ void ScriptEditor::_find_scripts(Node* p_base, Node* p_current, Set<Ref<Script>
used.insert(scr);
}
- for(int i=0;i<p_current->get_child_count();i++) {
- _find_scripts(p_base,p_current->get_child(i),used);
+ for (int i = 0; i < p_current->get_child_count(); i++) {
+ _find_scripts(p_base, p_current->get_child(i), used);
}
-
}
struct _ScriptEditorItemData {
@@ -1345,32 +1227,29 @@ struct _ScriptEditorItemData {
bool used;
int category;
+ bool operator<(const _ScriptEditorItemData &id) const {
- bool operator<(const _ScriptEditorItemData& id) const {
-
- return category==id.category?sort_key<id.sort_key:category<id.category;
+ return category == id.category ? sort_key < id.sort_key : category < id.category;
}
-
};
-
void ScriptEditor::_update_script_colors() {
bool script_temperature_enabled = EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_enabled");
bool highlight_current = EditorSettings::get_singleton()->get("text_editor/open_scripts/highlight_current_script");
int hist_size = EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_history_size");
- Color hot_color=EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_hot_color");
- Color cold_color=EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_cold_color");
+ Color hot_color = EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_hot_color");
+ Color cold_color = EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_cold_color");
- for(int i=0;i<script_list->get_item_count();i++) {
+ for (int i = 0; i < script_list->get_item_count(); i++) {
int c = script_list->get_item_metadata(i);
Node *n = tab_container->get_child(c);
if (!n)
continue;
- script_list->set_item_custom_bg_color(i,Color(0,0,0,0));
+ script_list->set_item_custom_bg_color(i, Color(0, 0, 0, 0));
bool current = tab_container->get_current_tab() == c;
if (current && highlight_current) {
@@ -1382,15 +1261,15 @@ void ScriptEditor::_update_script_colors() {
continue;
}
- int pass=n->get_meta("__editor_pass");
+ int pass = n->get_meta("__editor_pass");
int h = edit_pass - pass;
- if (h>hist_size) {
+ if (h > hist_size) {
continue;
}
- int non_zero_hist_size = ( hist_size == 0 ) ? 1 : hist_size;
- float v = Math::ease((edit_pass-pass)/float(non_zero_hist_size),0.4);
+ int non_zero_hist_size = (hist_size == 0) ? 1 : hist_size;
+ float v = Math::ease((edit_pass - pass) / float(non_zero_hist_size), 0.4);
- script_list->set_item_custom_bg_color(i,hot_color.linear_interpolate(cold_color,v));
+ script_list->set_item_custom_bg_color(i, hot_color.linear_interpolate(cold_color, v));
}
}
}
@@ -1400,22 +1279,21 @@ void ScriptEditor::_update_script_names() {
if (restoring_layout)
return;
- waiting_update_names=false;
+ waiting_update_names = false;
Set<Ref<Script> > used;
- Node* edited = EditorNode::get_singleton()->get_edited_scene();
+ Node *edited = EditorNode::get_singleton()->get_edited_scene();
if (edited) {
- _find_scripts(edited,edited,used);
+ _find_scripts(edited, edited, used);
}
script_list->clear();
bool split_script_help = EditorSettings::get_singleton()->get("text_editor/open_scripts/group_help_pages");
- ScriptSortBy sort_by = (ScriptSortBy) (int) EditorSettings::get_singleton()->get("text_editor/open_scripts/sort_scripts_by");
- ScriptListName display_as = (ScriptListName) (int) EditorSettings::get_singleton()->get("text_editor/open_scripts/list_script_names_as");
+ ScriptSortBy sort_by = (ScriptSortBy)(int)EditorSettings::get_singleton()->get("text_editor/open_scripts/sort_scripts_by");
+ ScriptListName display_as = (ScriptListName)(int)EditorSettings::get_singleton()->get("text_editor/open_scripts/list_script_names_as");
Vector<_ScriptEditorItemData> sedata;
- for(int i=0;i<tab_container->get_child_count();i++) {
-
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (se) {
@@ -1425,39 +1303,38 @@ void ScriptEditor::_update_script_names() {
String path = se->get_edited_script()->get_path();
_ScriptEditorItemData sd;
- sd.icon=icon;
- sd.name=name;
- sd.tooltip=path;
- sd.index=i;
- sd.used=used.has(se->get_edited_script());
- sd.category=0;
-
+ sd.icon = icon;
+ sd.name = name;
+ sd.tooltip = path;
+ sd.index = i;
+ sd.used = used.has(se->get_edited_script());
+ sd.category = 0;
+
switch (sort_by) {
case SORT_BY_NAME: {
- sd.sort_key=name.to_lower();
+ sd.sort_key = name.to_lower();
} break;
case SORT_BY_PATH: {
- sd.sort_key=path;
+ sd.sort_key = path;
} break;
}
-
+
switch (display_as) {
case DISPLAY_NAME: {
- sd.name=name;
+ sd.name = name;
} break;
case DISPLAY_DIR_AND_NAME: {
if (!path.get_base_dir().get_file().empty()) {
- sd.name=path.get_base_dir().get_file() + "/" + name;
+ sd.name = path.get_base_dir().get_file() + "/" + name;
} else {
- sd.name=name;
+ sd.name = name;
}
} break;
case DISPLAY_FULL_PATH: {
- sd.name=path;
+ sd.name = path;
} break;
}
-
sedata.push_back(sd);
}
@@ -1465,62 +1342,50 @@ void ScriptEditor::_update_script_names() {
if (eh) {
String name = eh->get_class();
- Ref<Texture> icon = get_icon("Help","EditorIcons");
- String tooltip = name+" Class Reference";
+ Ref<Texture> icon = get_icon("Help", "EditorIcons");
+ String tooltip = name + " Class Reference";
_ScriptEditorItemData sd;
- sd.icon=icon;
- sd.name=name;
- sd.sort_key=name;
- sd.tooltip=tooltip;
- sd.index=i;
- sd.used=false;
- sd.category=split_script_help?1:0;
+ sd.icon = icon;
+ sd.name = name;
+ sd.sort_key = name;
+ sd.tooltip = tooltip;
+ sd.index = i;
+ sd.used = false;
+ sd.category = split_script_help ? 1 : 0;
sedata.push_back(sd);
-
}
-
}
sedata.sort();
- for(int i=0;i<sedata.size();i++) {
+ for (int i = 0; i < sedata.size(); i++) {
- script_list->add_item(sedata[i].name,sedata[i].icon);
- int index = script_list->get_item_count()-1;
- script_list->set_item_tooltip(index,sedata[i].tooltip);
- script_list->set_item_metadata(index,sedata[i].index);
+ script_list->add_item(sedata[i].name, sedata[i].icon);
+ int index = script_list->get_item_count() - 1;
+ script_list->set_item_tooltip(index, sedata[i].tooltip);
+ script_list->set_item_metadata(index, sedata[i].index);
if (sedata[i].used) {
- script_list->set_item_custom_bg_color(index,Color(88/255.0,88/255.0,60/255.0));
+ script_list->set_item_custom_bg_color(index, Color(88 / 255.0, 88 / 255.0, 60 / 255.0));
}
- if (tab_container->get_current_tab()==sedata[i].index) {
+ if (tab_container->get_current_tab() == sedata[i].index) {
script_list->select(index);
script_name_label->set_text(sedata[i].name);
script_icon->set_texture(sedata[i].icon);
-
}
}
_update_script_colors();
-
-
-
-
}
-
-
-void ScriptEditor::edit(const Ref<Script>& p_script, bool p_grab_focus) {
+void ScriptEditor::edit(const Ref<Script> &p_script, bool p_grab_focus) {
if (p_script.is_null())
return;
// refuse to open built-in if scene is not loaded
-
-
-
// see if already has it
bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
@@ -1530,33 +1395,32 @@ void ScriptEditor::edit(const Ref<Script>& p_script, bool p_grab_focus) {
String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path");
String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags");
List<String> args;
- flags=flags.strip_edges();
- if (flags!=String()) {
- Vector<String> flagss = flags.split(" ",false);
- for(int i=0;i<flagss.size();i++)
+ flags = flags.strip_edges();
+ if (flags != String()) {
+ Vector<String> flagss = flags.split(" ", false);
+ for (int i = 0; i < flagss.size(); i++)
args.push_back(flagss[i]);
}
args.push_back(GlobalConfig::get_singleton()->globalize_path(p_script->get_path()));
- Error err = OS::get_singleton()->execute(path,args,false);
- if (err==OK)
+ Error err = OS::get_singleton()->execute(path, args, false);
+ if (err == OK)
return;
WARN_PRINT("Couldn't open external text editor, using internal");
}
-
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (!se)
continue;
- if (se->get_edited_script()==p_script) {
+ if (se->get_edited_script() == p_script) {
if (open_dominant || !EditorNode::get_singleton()->is_changing_scene()) {
- if (tab_container->get_current_tab()!=i) {
+ if (tab_container->get_current_tab() != i) {
_go_to_tab(i);
- script_list->select( script_list->find_metadata(i) );
+ script_list->select(script_list->find_metadata(i));
}
if (is_visible_in_tree())
se->ensure_focus();
@@ -1569,7 +1433,7 @@ void ScriptEditor::edit(const Ref<Script>& p_script, bool p_grab_focus) {
ScriptEditorBase *se;
- for(int i=script_editor_func_count-1;i>=0;i--) {
+ for (int i = script_editor_func_count - 1; i >= 0; i--) {
se = script_editor_funcs[i](p_script);
if (se)
break;
@@ -1578,50 +1442,39 @@ void ScriptEditor::edit(const Ref<Script>& p_script, bool p_grab_focus) {
tab_container->add_child(se);
se->set_edited_script(p_script);
- se->set_tooltip_request_func("_get_debug_tooltip",this);
+ se->set_tooltip_request_func("_get_debug_tooltip", this);
if (se->get_edit_menu()) {
se->get_edit_menu()->hide();
menu_hb->add_child(se->get_edit_menu());
- menu_hb->move_child(se->get_edit_menu(),1);
+ menu_hb->move_child(se->get_edit_menu(), 1);
}
-
if (p_grab_focus) {
- _go_to_tab(tab_container->get_tab_count()-1);
+ _go_to_tab(tab_container->get_tab_count() - 1);
}
-
-
-
-
_update_script_names();
_save_layout();
- se->connect("name_changed",this,"_update_script_names");
- se->connect("request_help_search",this,"_help_search");
- se->connect("request_open_script_at_line",this,"_goto_script_line");
- se->connect("go_to_help",this,"_help_class_goto");
- se->connect("request_save_history",this,"_save_history");
-
-
-
+ se->connect("name_changed", this, "_update_script_names");
+ se->connect("request_help_search", this, "_help_search");
+ se->connect("request_open_script_at_line", this, "_goto_script_line");
+ se->connect("go_to_help", this, "_help_class_goto");
+ se->connect("request_save_history", this, "_save_history");
//test for modification, maybe the script was not edited but was loaded
_test_script_times_on_disk(p_script);
_update_modified_scripts_for_external_editor(p_script);
-
}
void ScriptEditor::save_all_scripts() {
-
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (!se)
continue;
-
if (!se->is_unsaved())
continue;
@@ -1633,57 +1486,51 @@ void ScriptEditor::save_all_scripts() {
if (script.is_valid())
se->apply_code();
- if (script->get_path()!="" && script->get_path().find("local://")==-1 &&script->get_path().find("::")==-1) {
+ if (script->get_path() != "" && script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) {
//external script, save it
editor->save_resource(script);
//ResourceSaver::save(script->get_path(),script);
-
}
-
}
_update_script_names();
-
}
void ScriptEditor::apply_scripts() const {
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (!se)
continue;
se->apply_code();
}
-
}
void ScriptEditor::_editor_play() {
debugger->start();
debug_menu->get_popup()->grab_focus();
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true );
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_STEP), true );
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_BREAK), false );
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true );
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true);
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_STEP), true);
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), false);
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true);
- //debugger_gui->start_listening(Globals::get_singleton()->get("debug/debug_port"));
+ //debugger_gui->start_listening(Globals::get_singleton()->get("debug/debug_port"));
}
void ScriptEditor::_editor_pause() {
-
-
}
void ScriptEditor::_editor_stop() {
debugger->stop();
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true );
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_STEP), true );
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_BREAK), true );
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true );
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true);
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_STEP), true);
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), true);
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true);
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (!se) {
@@ -1695,34 +1542,31 @@ void ScriptEditor::_editor_stop() {
}
}
-
-void ScriptEditor::_add_callback(Object *p_obj, const String& p_function, const PoolStringArray& p_args) {
+void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const PoolStringArray &p_args) {
//print_line("add callback! hohoho"); kinda sad to remove this
ERR_FAIL_COND(!p_obj);
Ref<Script> script = p_obj->get_script();
- ERR_FAIL_COND( !script.is_valid() );
+ ERR_FAIL_COND(!script.is_valid());
editor->push_item(script.ptr());
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (!se)
continue;
- if (se->get_edited_script()!=script)
+ if (se->get_edited_script() != script)
continue;
- se->add_callback(p_function,p_args);
+ se->add_callback(p_function, p_args);
_go_to_tab(i);
- script_list->select( script_list->find_metadata(i) );
+ script_list->select(script_list->find_metadata(i));
break;
-
}
-
}
void ScriptEditor::_save_layout() {
@@ -1738,7 +1582,7 @@ void ScriptEditor::_editor_settings_changed() {
trim_trailing_whitespace_on_save = EditorSettings::get_singleton()->get("text_editor/files/trim_trailing_whitespace_on_save");
float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs");
- if (autosave_time>0) {
+ if (autosave_time > 0) {
autosave_timer->set_wait_time(autosave_time);
autosave_timer->start();
} else {
@@ -1752,7 +1596,7 @@ void ScriptEditor::_editor_settings_changed() {
EditorSettings::get_singleton()->load_text_editor_theme();
}
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (!se)
@@ -1763,8 +1607,7 @@ void ScriptEditor::_editor_settings_changed() {
_update_script_colors();
_update_script_names();
- ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/files/auto_reload_and_parse_scripts_on_save",true));
-
+ ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/files/auto_reload_and_parse_scripts_on_save", true));
}
void ScriptEditor::_autosave_scripts() {
@@ -1777,7 +1620,7 @@ void ScriptEditor::_tree_changed() {
if (waiting_update_names)
return;
- waiting_update_names=true;
+ waiting_update_names = true;
call_deferred("_update_script_names");
}
@@ -1786,7 +1629,7 @@ void ScriptEditor::_script_split_dragged(float) {
_save_layout();
}
-void ScriptEditor::_unhandled_input(const InputEvent& p_event) {
+void ScriptEditor::_unhandled_input(const InputEvent &p_event) {
if (p_event.key.pressed || !is_visible_in_tree()) return;
if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) {
int next_tab = script_list->get_current() + 1;
@@ -1804,21 +1647,21 @@ void ScriptEditor::_unhandled_input(const InputEvent& p_event) {
void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
- if (!bool(EDITOR_DEF("text_editor/files/restore_scripts_on_load",true))) {
+ if (!bool(EDITOR_DEF("text_editor/files/restore_scripts_on_load", true))) {
return;
}
- if (!p_layout->has_section_key("ScriptEditor","open_scripts") && !p_layout->has_section_key("ScriptEditor","open_help"))
+ if (!p_layout->has_section_key("ScriptEditor", "open_scripts") && !p_layout->has_section_key("ScriptEditor", "open_help"))
return;
- Array scripts = p_layout->get_value("ScriptEditor","open_scripts");
+ Array scripts = p_layout->get_value("ScriptEditor", "open_scripts");
Array helps;
- if (p_layout->has_section_key("ScriptEditor","open_help"))
- helps=p_layout->get_value("ScriptEditor","open_help");
+ if (p_layout->has_section_key("ScriptEditor", "open_help"))
+ helps = p_layout->get_value("ScriptEditor", "open_help");
- restoring_layout=true;
+ restoring_layout = true;
- for(int i=0;i<scripts.size();i++) {
+ for (int i = 0; i < scripts.size(); i++) {
String path = scripts[i];
if (!FileAccess::exists(path))
@@ -1829,22 +1672,21 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
}
}
- for(int i=0;i<helps.size();i++) {
+ for (int i = 0; i < helps.size(); i++) {
String path = helps[i];
_help_class_open(path);
}
- for(int i=0;i<tab_container->get_child_count();i++) {
- tab_container->get_child(i)->set_meta("__editor_pass",Variant());
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
+ tab_container->get_child(i)->set_meta("__editor_pass", Variant());
}
-
- if (p_layout->has_section_key("ScriptEditor","split_offset")) {
- script_split->set_split_offset(p_layout->get_value("ScriptEditor","split_offset"));
+ if (p_layout->has_section_key("ScriptEditor", "split_offset")) {
+ script_split->set_split_offset(p_layout->get_value("ScriptEditor", "split_offset"));
}
- restoring_layout=false;
+ restoring_layout = false;
_update_script_names();
}
@@ -1854,7 +1696,7 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
Array scripts;
Array helps;
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
if (se) {
@@ -1872,26 +1714,23 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
helps.push_back(eh->get_class());
}
-
-
}
- p_layout->set_value("ScriptEditor","open_scripts",scripts);
- p_layout->set_value("ScriptEditor","open_help",helps);
- p_layout->set_value("ScriptEditor","split_offset",script_split->get_split_offset());
+ p_layout->set_value("ScriptEditor", "open_scripts", scripts);
+ p_layout->set_value("ScriptEditor", "open_help", helps);
+ p_layout->set_value("ScriptEditor", "split_offset", script_split->get_split_offset());
}
+void ScriptEditor::_help_class_open(const String &p_class) {
-void ScriptEditor::_help_class_open(const String& p_class) {
-
- if (p_class=="")
+ if (p_class == "")
return;
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>();
- if (eh && eh->get_class()==p_class) {
+ if (eh && eh->get_class() == p_class) {
_go_to_tab(i);
_update_script_names();
@@ -1899,27 +1738,26 @@ void ScriptEditor::_help_class_open(const String& p_class) {
}
}
- EditorHelp * eh = memnew( EditorHelp );
-
+ EditorHelp *eh = memnew(EditorHelp);
eh->set_name(p_class);
tab_container->add_child(eh);
- _go_to_tab(tab_container->get_tab_count()-1);
- eh->go_to_class(p_class,0);
- eh->connect("go_to_help",this,"_help_class_goto");
+ _go_to_tab(tab_container->get_tab_count() - 1);
+ eh->go_to_class(p_class, 0);
+ eh->connect("go_to_help", this, "_help_class_goto");
_update_script_names();
_save_layout();
}
-void ScriptEditor::_help_class_goto(const String& p_desc) {
+void ScriptEditor::_help_class_goto(const String &p_desc) {
- String cname=p_desc.get_slice(":",1);
+ String cname = p_desc.get_slice(":", 1);
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>();
- if (eh && eh->get_class()==cname) {
+ if (eh && eh->get_class() == cname) {
_go_to_tab(i);
eh->go_to_help(p_desc);
@@ -1928,20 +1766,20 @@ void ScriptEditor::_help_class_goto(const String& p_desc) {
}
}
- EditorHelp * eh = memnew( EditorHelp );
+ EditorHelp *eh = memnew(EditorHelp);
eh->set_name(cname);
tab_container->add_child(eh);
- _go_to_tab(tab_container->get_tab_count()-1);
+ _go_to_tab(tab_container->get_tab_count() - 1);
eh->go_to_help(p_desc);
- eh->connect("go_to_help",this,"_help_class_goto");
+ eh->connect("go_to_help", this, "_help_class_goto");
_update_script_names();
_save_layout();
}
void ScriptEditor::_update_selected_editor_menu() {
- for(int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
bool current = tab_container->get_current_tab() == i;
@@ -1953,10 +1791,9 @@ void ScriptEditor::_update_selected_editor_menu() {
else
se->get_edit_menu()->hide();
}
-
}
- EditorHelp *eh=tab_container->get_current_tab_control()->cast_to<EditorHelp>();
+ EditorHelp *eh = tab_container->get_current_tab_control()->cast_to<EditorHelp>();
if (eh) {
script_search_menu->show();
} else {
@@ -1970,14 +1807,14 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
if (n->cast_to<ScriptEditorBase>()) {
- history[history_pos].state=n->cast_to<ScriptEditorBase>()->get_edit_state();
+ history[history_pos].state = n->cast_to<ScriptEditorBase>()->get_edit_state();
}
if (n->cast_to<EditorHelp>()) {
- history[history_pos].state=n->cast_to<EditorHelp>()->get_scroll();
+ history[history_pos].state = n->cast_to<EditorHelp>()->get_scroll();
}
- history_pos=p_new_pos;
+ history_pos = p_new_pos;
tab_container->set_current_tab(history[history_pos].control->get_index());
n = history[history_pos].control;
@@ -1994,28 +1831,26 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
n->cast_to<EditorHelp>()->set_focused();
}
- n->set_meta("__editor_pass",++edit_pass);
+ n->set_meta("__editor_pass", ++edit_pass);
_update_script_names();
_update_history_arrows();
_update_selected_editor_menu();
-
}
void ScriptEditor::_history_forward() {
- if (history_pos<history.size()-1) {
- _update_history_pos(history_pos+1);
+ if (history_pos < history.size() - 1) {
+ _update_history_pos(history_pos + 1);
}
}
-void ScriptEditor::_history_back(){
+void ScriptEditor::_history_back() {
- if (history_pos>0) {
- _update_history_pos(history_pos-1);
+ if (history_pos > 0) {
+ _update_history_pos(history_pos - 1);
}
-
}
-void ScriptEditor::set_scene_root_script( Ref<Script> p_script ) {
+void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
@@ -2027,13 +1862,12 @@ void ScriptEditor::set_scene_root_script( Ref<Script> p_script ) {
}
}
-bool ScriptEditor::script_go_to_method(Ref<Script> p_script, const String& p_method) {
+bool ScriptEditor::script_go_to_method(Ref<Script> p_script, const String &p_method) {
-
- for (int i=0;i<tab_container->get_child_count();i++) {
+ for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *current = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
- if (current && current->get_edited_script()==p_script) {
+ if (current && current->get_edited_script() == p_script) {
if (current->goto_method(p_method)) {
edit(p_script);
return true;
@@ -2046,123 +1880,118 @@ bool ScriptEditor::script_go_to_method(Ref<Script> p_script, const String& p_met
void ScriptEditor::set_live_auto_reload_running_scripts(bool p_enabled) {
- auto_reload_running_scripts=p_enabled;
+ auto_reload_running_scripts = p_enabled;
}
void ScriptEditor::_help_search(String p_text) {
help_search_dialog->popup(p_text);
}
-void ScriptEditor::_open_script_request(const String& p_path) {
+void ScriptEditor::_open_script_request(const String &p_path) {
Ref<Script> script = ResourceLoader::load(p_path);
if (script.is_valid()) {
- script_editor->edit(script,false);
+ script_editor->edit(script, false);
}
}
-int ScriptEditor::script_editor_func_count=0;
+int ScriptEditor::script_editor_func_count = 0;
CreateScriptEditorFunc ScriptEditor::script_editor_funcs[ScriptEditor::SCRIPT_EDITOR_FUNC_MAX];
void ScriptEditor::register_create_script_editor_function(CreateScriptEditorFunc p_func) {
- ERR_FAIL_COND(script_editor_func_count==SCRIPT_EDITOR_FUNC_MAX);
- script_editor_funcs[script_editor_func_count++]=p_func;
+ ERR_FAIL_COND(script_editor_func_count == SCRIPT_EDITOR_FUNC_MAX);
+ script_editor_funcs[script_editor_func_count++] = p_func;
}
void ScriptEditor::_bind_methods() {
- ClassDB::bind_method("_file_dialog_action",&ScriptEditor::_file_dialog_action);
- ClassDB::bind_method("_tab_changed",&ScriptEditor::_tab_changed);
- ClassDB::bind_method("_menu_option",&ScriptEditor::_menu_option);
- ClassDB::bind_method("_close_current_tab",&ScriptEditor::_close_current_tab);
+ ClassDB::bind_method("_file_dialog_action", &ScriptEditor::_file_dialog_action);
+ ClassDB::bind_method("_tab_changed", &ScriptEditor::_tab_changed);
+ ClassDB::bind_method("_menu_option", &ScriptEditor::_menu_option);
+ ClassDB::bind_method("_close_current_tab", &ScriptEditor::_close_current_tab);
ClassDB::bind_method("_close_discard_current_tab", &ScriptEditor::_close_discard_current_tab);
ClassDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab);
ClassDB::bind_method("_close_all_tabs", &ScriptEditor::_close_all_tabs);
- ClassDB::bind_method("_editor_play",&ScriptEditor::_editor_play);
- ClassDB::bind_method("_editor_pause",&ScriptEditor::_editor_pause);
- ClassDB::bind_method("_editor_stop",&ScriptEditor::_editor_stop);
- ClassDB::bind_method("_add_callback",&ScriptEditor::_add_callback);
- ClassDB::bind_method("_reload_scripts",&ScriptEditor::_reload_scripts);
- ClassDB::bind_method("_resave_scripts",&ScriptEditor::_resave_scripts);
- ClassDB::bind_method("_res_saved_callback",&ScriptEditor::_res_saved_callback);
- ClassDB::bind_method("_goto_script_line",&ScriptEditor::_goto_script_line);
- ClassDB::bind_method("_goto_script_line2",&ScriptEditor::_goto_script_line2);
- ClassDB::bind_method("_help_search",&ScriptEditor::_help_search);
- ClassDB::bind_method("_save_history",&ScriptEditor::_save_history);
-
-
-
- ClassDB::bind_method("_breaked",&ScriptEditor::_breaked);
- ClassDB::bind_method("_show_debugger",&ScriptEditor::_show_debugger);
- ClassDB::bind_method("_get_debug_tooltip",&ScriptEditor::_get_debug_tooltip);
- ClassDB::bind_method("_autosave_scripts",&ScriptEditor::_autosave_scripts);
- ClassDB::bind_method("_editor_settings_changed",&ScriptEditor::_editor_settings_changed);
- ClassDB::bind_method("_update_script_names",&ScriptEditor::_update_script_names);
- ClassDB::bind_method("_tree_changed",&ScriptEditor::_tree_changed);
- ClassDB::bind_method("_script_selected",&ScriptEditor::_script_selected);
- ClassDB::bind_method("_script_created",&ScriptEditor::_script_created);
- ClassDB::bind_method("_script_split_dragged",&ScriptEditor::_script_split_dragged);
- ClassDB::bind_method("_help_class_open",&ScriptEditor::_help_class_open);
- ClassDB::bind_method("_help_class_goto",&ScriptEditor::_help_class_goto);
- ClassDB::bind_method("_request_help",&ScriptEditor::_help_class_open);
- ClassDB::bind_method("_history_forward",&ScriptEditor::_history_forward);
- ClassDB::bind_method("_history_back",&ScriptEditor::_history_back);
- ClassDB::bind_method("_live_auto_reload_running_scripts",&ScriptEditor::_live_auto_reload_running_scripts);
- ClassDB::bind_method("_unhandled_input",&ScriptEditor::_unhandled_input);
-
+ ClassDB::bind_method("_editor_play", &ScriptEditor::_editor_play);
+ ClassDB::bind_method("_editor_pause", &ScriptEditor::_editor_pause);
+ ClassDB::bind_method("_editor_stop", &ScriptEditor::_editor_stop);
+ ClassDB::bind_method("_add_callback", &ScriptEditor::_add_callback);
+ ClassDB::bind_method("_reload_scripts", &ScriptEditor::_reload_scripts);
+ ClassDB::bind_method("_resave_scripts", &ScriptEditor::_resave_scripts);
+ ClassDB::bind_method("_res_saved_callback", &ScriptEditor::_res_saved_callback);
+ ClassDB::bind_method("_goto_script_line", &ScriptEditor::_goto_script_line);
+ ClassDB::bind_method("_goto_script_line2", &ScriptEditor::_goto_script_line2);
+ ClassDB::bind_method("_help_search", &ScriptEditor::_help_search);
+ ClassDB::bind_method("_save_history", &ScriptEditor::_save_history);
+
+ ClassDB::bind_method("_breaked", &ScriptEditor::_breaked);
+ ClassDB::bind_method("_show_debugger", &ScriptEditor::_show_debugger);
+ ClassDB::bind_method("_get_debug_tooltip", &ScriptEditor::_get_debug_tooltip);
+ ClassDB::bind_method("_autosave_scripts", &ScriptEditor::_autosave_scripts);
+ ClassDB::bind_method("_editor_settings_changed", &ScriptEditor::_editor_settings_changed);
+ ClassDB::bind_method("_update_script_names", &ScriptEditor::_update_script_names);
+ ClassDB::bind_method("_tree_changed", &ScriptEditor::_tree_changed);
+ ClassDB::bind_method("_script_selected", &ScriptEditor::_script_selected);
+ ClassDB::bind_method("_script_created", &ScriptEditor::_script_created);
+ ClassDB::bind_method("_script_split_dragged", &ScriptEditor::_script_split_dragged);
+ ClassDB::bind_method("_help_class_open", &ScriptEditor::_help_class_open);
+ ClassDB::bind_method("_help_class_goto", &ScriptEditor::_help_class_goto);
+ ClassDB::bind_method("_request_help", &ScriptEditor::_help_class_open);
+ ClassDB::bind_method("_history_forward", &ScriptEditor::_history_forward);
+ ClassDB::bind_method("_history_back", &ScriptEditor::_history_back);
+ ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts);
+ ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input);
}
ScriptEditor::ScriptEditor(EditorNode *p_editor) {
current_theme = "";
- completion_cache = memnew( EditorScriptCodeCompletionCache );
- restoring_layout=false;
- waiting_update_names=false;
- pending_auto_reload=false;
- auto_reload_running_scripts=false;
- editor=p_editor;
+ completion_cache = memnew(EditorScriptCodeCompletionCache);
+ restoring_layout = false;
+ waiting_update_names = false;
+ pending_auto_reload = false;
+ auto_reload_running_scripts = false;
+ editor = p_editor;
- menu_hb = memnew( HBoxContainer );
+ menu_hb = memnew(HBoxContainer);
add_child(menu_hb);
-
- script_split = memnew( HSplitContainer );
+ script_split = memnew(HSplitContainer);
add_child(script_split);
script_split->set_v_size_flags(SIZE_EXPAND_FILL);
- script_list = memnew( ItemList );
+ script_list = memnew(ItemList);
script_split->add_child(script_list);
- script_list->set_custom_minimum_size(Size2(0,0));
+ script_list->set_custom_minimum_size(Size2(0, 0));
script_split->set_split_offset(140);
- tab_container = memnew( TabContainer );
+ tab_container = memnew(TabContainer);
tab_container->set_tabs_visible(false);
script_split->add_child(tab_container);
-
tab_container->set_h_size_flags(SIZE_EXPAND_FILL);
ED_SHORTCUT("script_editor/next_script", TTR("Next script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_GREATER);
ED_SHORTCUT("script_editor/prev_script", TTR("Previous script"), KEY_MASK_CMD | KEY_LESS);
set_process_unhandled_input(true);
- file_menu = memnew( MenuButton );
+ file_menu = memnew(MenuButton);
menu_hb->add_child(file_menu);
file_menu->set_text(TTR("File"));
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new", TTR("New")), FILE_NEW);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/open", TTR("Open")), FILE_OPEN);
file_menu->get_popup()->add_separator();
- file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save", TTR("Save"), KEY_MASK_ALT|KEY_MASK_CMD|KEY_S), FILE_SAVE);
+ file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save", TTR("Save"), KEY_MASK_ALT | KEY_MASK_CMD | KEY_S), FILE_SAVE);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_as", TTR("Save As..")), FILE_SAVE_AS);
- file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_all", TTR("Save All"), KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_MASK_ALT|KEY_S), FILE_SAVE_ALL);
+ file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_all", TTR("Save All"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_S), FILE_SAVE_ALL);
file_menu->get_popup()->add_separator();
- file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/reload_script_soft", TTR("Soft Reload Script"), KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_R), FILE_TOOL_RELOAD_SOFT);
+ file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/reload_script_soft", TTR("Soft Reload Script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_R), FILE_TOOL_RELOAD_SOFT);
file_menu->get_popup()->add_separator();
- file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_previous", TTR("History Prev"), KEY_MASK_ALT|KEY_LEFT), WINDOW_PREV);
- file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_next", TTR("History Next"), KEY_MASK_ALT|KEY_RIGHT), WINDOW_NEXT);
+ file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_previous", TTR("History Prev"), KEY_MASK_ALT | KEY_LEFT), WINDOW_PREV);
+ file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_next", TTR("History Next"), KEY_MASK_ALT | KEY_RIGHT), WINDOW_NEXT);
file_menu->get_popup()->add_separator();
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/import_theme", TTR("Import Theme")), FILE_IMPORT_THEME);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/reload_theme", TTR("Reload Theme")), FILE_RELOAD_THEME);
@@ -2172,20 +2001,17 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_docs", TTR("Close Docs")), CLOSE_DOCS);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_all", TTR("Close All")), CLOSE_ALL);
- file_menu->get_popup()->connect("id_pressed", this,"_menu_option");
-
+ file_menu->get_popup()->connect("id_pressed", this, "_menu_option");
-
- script_search_menu = memnew( MenuButton );
+ script_search_menu = memnew(MenuButton);
menu_hb->add_child(script_search_menu);
script_search_menu->set_text(TTR("Search"));
- script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find.."), KEY_MASK_CMD|KEY_F), HELP_SEARCH_FIND);
+ script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find.."), KEY_MASK_CMD | KEY_F), HELP_SEARCH_FIND);
script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_next", TTR("Find Next"), KEY_F3), HELP_SEARCH_FIND_NEXT);
- script_search_menu->get_popup()->connect("id_pressed", this,"_menu_option");
+ script_search_menu->get_popup()->connect("id_pressed", this, "_menu_option");
script_search_menu->hide();
-
- debug_menu = memnew( MenuButton );
+ debug_menu = memnew(MenuButton);
menu_hb->add_child(debug_menu);
debug_menu->set_text(TTR("Debug"));
debug_menu->get_popup()->add_separator();
@@ -2197,13 +2023,12 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
debug_menu->get_popup()->add_separator();
//debug_menu->get_popup()->add_check_item("Show Debugger",DEBUG_SHOW);
debug_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("debugger/keep_debugger_open", TTR("Keep Debugger Open")), DEBUG_SHOW_KEEP_OPEN);
- debug_menu->get_popup()->connect("id_pressed", this,"_menu_option");
-
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true);
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_STEP), true );
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_BREAK), true );
- debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true );
+ debug_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true);
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_STEP), true);
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), true);
+ debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true);
#if 0
window_menu = memnew( MenuButton );
@@ -2218,13 +2043,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
#endif
-
menu_hb->add_spacer();
-
- script_icon = memnew( TextureRect );
+ script_icon = memnew(TextureRect);
menu_hb->add_child(script_icon);
- script_name_label = memnew( Label );
+ script_name_label = memnew(Label);
menu_hb->add_child(script_name_label);
script_icon->hide();
@@ -2232,46 +2055,44 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
menu_hb->add_spacer();
- site_search = memnew( ToolButton );
+ site_search = memnew(ToolButton);
site_search->set_text(TTR("Tutorials"));
- site_search->connect("pressed",this,"_menu_option",varray(SEARCH_WEBSITE));
+ site_search->connect("pressed", this, "_menu_option", varray(SEARCH_WEBSITE));
menu_hb->add_child(site_search);
site_search->set_tooltip(TTR("Open https://godotengine.org at tutorials section."));
- class_search = memnew( ToolButton );
+ class_search = memnew(ToolButton);
class_search->set_text(TTR("Classes"));
- class_search->connect("pressed",this,"_menu_option",varray(SEARCH_CLASSES));
+ class_search->connect("pressed", this, "_menu_option", varray(SEARCH_CLASSES));
menu_hb->add_child(class_search);
class_search->set_tooltip(TTR("Search the class hierarchy."));
- help_search = memnew( ToolButton );
+ help_search = memnew(ToolButton);
help_search->set_text(TTR("Search Help"));
- help_search->connect("pressed",this,"_menu_option",varray(SEARCH_HELP));
+ help_search->connect("pressed", this, "_menu_option", varray(SEARCH_HELP));
menu_hb->add_child(help_search);
help_search->set_tooltip(TTR("Search the reference documentation."));
- menu_hb->add_child( memnew( VSeparator) );
+ menu_hb->add_child(memnew(VSeparator));
- script_back = memnew( ToolButton );
- script_back->connect("pressed",this,"_history_back");
+ script_back = memnew(ToolButton);
+ script_back->connect("pressed", this, "_history_back");
menu_hb->add_child(script_back);
script_back->set_disabled(true);
script_back->set_tooltip(TTR("Go to previous edited document."));
- script_forward = memnew( ToolButton );
- script_forward->connect("pressed",this,"_history_forward");
+ script_forward = memnew(ToolButton);
+ script_forward->connect("pressed", this, "_history_forward");
menu_hb->add_child(script_forward);
script_forward->set_disabled(true);
script_forward->set_tooltip(TTR("Go to next edited document."));
+ tab_container->connect("tab_changed", this, "_tab_changed");
-
- tab_container->connect("tab_changed", this,"_tab_changed");
-
- erase_tab_confirm = memnew( ConfirmationDialog );
+ erase_tab_confirm = memnew(ConfirmationDialog);
erase_tab_confirm->get_ok()->set_text(TTR("Save"));
erase_tab_confirm->add_button(TTR("Discard"), OS::get_singleton()->get_swap_ok_cancel(), "discard");
- erase_tab_confirm->connect("confirmed", this,"_close_current_tab");
+ erase_tab_confirm->connect("confirmed", this, "_close_current_tab");
erase_tab_confirm->connect("custom_action", this, "_close_discard_current_tab");
add_child(erase_tab_confirm);
@@ -2281,74 +2102,67 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
script_create_dialog->connect("script_created", this, "_script_created");
file_dialog_option = -1;
- file_dialog = memnew( EditorFileDialog );
+ file_dialog = memnew(EditorFileDialog);
add_child(file_dialog);
- file_dialog->connect("file_selected", this,"_file_dialog_action");
-
+ file_dialog->connect("file_selected", this, "_file_dialog_action");
- debugger = memnew( ScriptEditorDebugger(editor) );
- debugger->connect("goto_script_line",this,"_goto_script_line");
- debugger->connect("show_debugger",this,"_show_debugger");
+ debugger = memnew(ScriptEditorDebugger(editor));
+ debugger->connect("goto_script_line", this, "_goto_script_line");
+ debugger->connect("show_debugger", this, "_show_debugger");
- disk_changed = memnew( ConfirmationDialog );
+ disk_changed = memnew(ConfirmationDialog);
{
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
disk_changed->add_child(vbc);
//disk_changed->set_child_rect(vbc);
- Label *dl = memnew( Label );
+ Label *dl = memnew(Label);
dl->set_text(TTR("The following files are newer on disk.\nWhat action should be taken?:"));
vbc->add_child(dl);
- disk_changed_list = memnew( Tree );
+ disk_changed_list = memnew(Tree);
vbc->add_child(disk_changed_list);
disk_changed_list->set_v_size_flags(SIZE_EXPAND_FILL);
- disk_changed->connect("confirmed",this,"_reload_scripts");
+ disk_changed->connect("confirmed", this, "_reload_scripts");
disk_changed->get_ok()->set_text(TTR("Reload"));
- disk_changed->add_button(TTR("Resave"),!OS::get_singleton()->get_swap_ok_cancel(),"resave");
- disk_changed->connect("custom_action",this,"_resave_scripts");
-
-
+ disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave");
+ disk_changed->connect("custom_action", this, "_resave_scripts");
}
add_child(disk_changed);
- script_editor=this;
+ script_editor = this;
-
- Button *db = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Debugger"),debugger);
+ Button *db = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Debugger"), debugger);
debugger->set_tool_button(db);
+ debugger->connect("breaked", this, "_breaked");
- debugger->connect("breaked",this,"_breaked");
-
- autosave_timer = memnew( Timer );
+ autosave_timer = memnew(Timer);
autosave_timer->set_one_shot(false);
add_child(autosave_timer);
- grab_focus_block=false;
+ grab_focus_block = false;
- help_search_dialog = memnew( EditorHelpSearch );
+ help_search_dialog = memnew(EditorHelpSearch);
add_child(help_search_dialog);
- help_search_dialog->connect("go_to_help",this,"_help_class_goto");
-
+ help_search_dialog->connect("go_to_help", this, "_help_class_goto");
- help_index = memnew( EditorHelpIndex );
+ help_index = memnew(EditorHelpIndex);
add_child(help_index);
- help_index->connect("open_class",this,"_help_class_open");
+ help_index->connect("open_class", this, "_help_class_open");
- history_pos=-1;
+ history_pos = -1;
//debugger_gui->hide();
- edit_pass=0;
+ edit_pass = 0;
trim_trailing_whitespace_on_save = false;
- ScriptServer::edit_request_func=_open_script_request;
+ ScriptServer::edit_request_func = _open_script_request;
}
-
ScriptEditor::~ScriptEditor() {
memdelete(completion_cache);
@@ -2360,7 +2174,6 @@ void ScriptEditorPlugin::edit(Object *p_object) {
return;
script_editor->edit(p_object->cast_to<Script>());
-
}
bool ScriptEditorPlugin::handles(Object *p_object) const {
@@ -2389,7 +2202,6 @@ void ScriptEditorPlugin::make_visible(bool p_visible) {
script_editor->hide();
script_editor->set_process(false);
}
-
}
void ScriptEditorPlugin::selected_notify() {
@@ -2402,7 +2214,7 @@ Dictionary ScriptEditorPlugin::get_state() const {
return script_editor->get_state();
}
-void ScriptEditorPlugin::set_state(const Dictionary& p_state) {
+void ScriptEditorPlugin::set_state(const Dictionary &p_state) {
script_editor->set_state(p_state);
}
@@ -2422,12 +2234,9 @@ void ScriptEditorPlugin::apply_changes() {
}
void ScriptEditorPlugin::restore_global_state() {
-
-
}
void ScriptEditorPlugin::save_global_state() {
-
}
void ScriptEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
@@ -2435,15 +2244,13 @@ void ScriptEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
script_editor->set_window_layout(p_layout);
}
-void ScriptEditorPlugin::get_window_layout(Ref<ConfigFile> p_layout){
+void ScriptEditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
script_editor->get_window_layout(p_layout);
}
-
void ScriptEditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
-
return script_editor->get_breakpoints(p_breakpoints);
}
@@ -2452,40 +2259,34 @@ void ScriptEditorPlugin::edited_scene_changed() {
script_editor->edited_scene_changed();
}
-
-
ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- script_editor = memnew( ScriptEditor(p_node) );
+ editor = p_node;
+ script_editor = memnew(ScriptEditor(p_node));
editor->get_viewport()->add_child(script_editor);
script_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
script_editor->hide();
- EDITOR_DEF("text_editor/files/auto_reload_scripts_on_external_change",true);
- ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/files/auto_reload_and_parse_scripts_on_save",true));
- EDITOR_DEF("text_editor/files/open_dominant_script_on_scene_change",true);
- EDITOR_DEF("text_editor/external/use_external_editor",false);
- EDITOR_DEF("text_editor/external/exec_path","");
- EDITOR_DEF("text_editor/open_scripts/script_temperature_enabled",true);
+ EDITOR_DEF("text_editor/files/auto_reload_scripts_on_external_change", true);
+ ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/files/auto_reload_and_parse_scripts_on_save", true));
+ EDITOR_DEF("text_editor/files/open_dominant_script_on_scene_change", true);
+ EDITOR_DEF("text_editor/external/use_external_editor", false);
+ EDITOR_DEF("text_editor/external/exec_path", "");
+ EDITOR_DEF("text_editor/open_scripts/script_temperature_enabled", true);
EDITOR_DEF("text_editor/open_scripts/highlight_current_script", true);
- EDITOR_DEF("text_editor/open_scripts/script_temperature_history_size",15);
- EDITOR_DEF("text_editor/open_scripts/script_temperature_hot_color",Color(1,0,0,0.3));
- EDITOR_DEF("text_editor/open_scripts/script_temperature_cold_color",Color(0,0,1,0.3));
- EDITOR_DEF("text_editor/open_scripts/current_script_background_color",Color(0.81,0.81,0.14,0.63));
- EDITOR_DEF("text_editor/open_scripts/group_help_pages",true);
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT,"text_editor/open_scripts/sort_scripts_by",PROPERTY_HINT_ENUM,"Name,Path"));
- EDITOR_DEF("text_editor/open_scripts/sort_scripts_by",0);
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT,"text_editor/open_scripts/list_script_names_as",PROPERTY_HINT_ENUM,"Name,Parent Directory And Name,Full Path"));
- EDITOR_DEF("text_editor/open_scripts/list_script_names_as",0);
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"text_editor/external/exec_path",PROPERTY_HINT_GLOBAL_FILE));
- EDITOR_DEF("text_editor/external/exec_flags","");
-
-
-}
-
-
-ScriptEditorPlugin::~ScriptEditorPlugin()
-{
+ EDITOR_DEF("text_editor/open_scripts/script_temperature_history_size", 15);
+ EDITOR_DEF("text_editor/open_scripts/script_temperature_hot_color", Color(1, 0, 0, 0.3));
+ EDITOR_DEF("text_editor/open_scripts/script_temperature_cold_color", Color(0, 0, 1, 0.3));
+ EDITOR_DEF("text_editor/open_scripts/current_script_background_color", Color(0.81, 0.81, 0.14, 0.63));
+ EDITOR_DEF("text_editor/open_scripts/group_help_pages", true);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/open_scripts/sort_scripts_by", PROPERTY_HINT_ENUM, "Name,Path"));
+ EDITOR_DEF("text_editor/open_scripts/sort_scripts_by", 0);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/open_scripts/list_script_names_as", PROPERTY_HINT_ENUM, "Name,Parent Directory And Name,Full Path"));
+ EDITOR_DEF("text_editor/open_scripts/list_script_names_as", 0);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "text_editor/external/exec_path", PROPERTY_HINT_GLOBAL_FILE));
+ EDITOR_DEF("text_editor/external/exec_flags", "");
+}
+
+ScriptEditorPlugin::~ScriptEditorPlugin() {
}
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index bf5316363c..a73e14423d 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -29,23 +29,23 @@
#ifndef SCRIPT_EDITOR_PLUGIN_H
#define SCRIPT_EDITOR_PLUGIN_H
+#include "editor/code_editor.h"
+#include "editor/editor_help.h"
#include "editor/editor_plugin.h"
#include "editor/script_create_dialog.h"
+#include "scene/gui/item_list.h"
+#include "scene/gui/menu_button.h"
+#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/text_edit.h"
-#include "scene/gui/menu_button.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
#include "scene/main/timer.h"
#include "script_language.h"
-#include "editor/code_editor.h"
-#include "scene/gui/split_container.h"
-#include "scene/gui/item_list.h"
-#include "editor/editor_help.h"
class ScriptEditorQuickOpen : public ConfirmationDialog {
- GDCLASS(ScriptEditorQuickOpen,ConfirmationDialog )
+ GDCLASS(ScriptEditorQuickOpen, ConfirmationDialog)
LineEdit *search_box;
Tree *search_options;
@@ -53,73 +53,66 @@ class ScriptEditorQuickOpen : public ConfirmationDialog {
void _update_search();
- void _sbox_input(const InputEvent& p_ie);
+ void _sbox_input(const InputEvent &p_ie);
Vector<String> functions;
-
void _confirmed();
- void _text_changed(const String& p_newtext);
+ void _text_changed(const String &p_newtext);
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
- void popup(const Vector<String>& p_base,bool p_dontclear=false);
+public:
+ void popup(const Vector<String> &p_base, bool p_dontclear = false);
ScriptEditorQuickOpen();
};
-
class ScriptEditorDebugger;
-
-
class ScriptEditorBase : public Control {
- GDCLASS( ScriptEditorBase, Control );
+ GDCLASS(ScriptEditorBase, Control);
+
protected:
static void _bind_methods();
-public:
- virtual void apply_code()=0;
- virtual Ref<Script> get_edited_script() const=0;
- virtual Vector<String> get_functions()=0;
- virtual void set_edited_script(const Ref<Script>& p_script)=0;
- virtual void reload_text()=0;
- virtual String get_name()=0;
- virtual Ref<Texture> get_icon()=0;
- virtual bool is_unsaved()=0;
- virtual Variant get_edit_state()=0;
- virtual void set_edit_state(const Variant& p_state)=0;
- virtual void goto_line(int p_line,bool p_with_error=false)=0;
- virtual void trim_trailing_whitespace()=0;
- virtual void ensure_focus()=0;
- virtual void tag_saved_version()=0;
- virtual void reload(bool p_soft)=0;
- virtual void get_breakpoints(List<int> *p_breakpoints)=0;
- virtual bool goto_method(const String& p_method)=0;
- virtual void add_callback(const String& p_function,PoolStringArray p_args)=0;
- virtual void update_settings()=0;
- virtual void set_debugger_active(bool p_active)=0;
+public:
+ virtual void apply_code() = 0;
+ virtual Ref<Script> get_edited_script() const = 0;
+ virtual Vector<String> get_functions() = 0;
+ virtual void set_edited_script(const Ref<Script> &p_script) = 0;
+ virtual void reload_text() = 0;
+ virtual String get_name() = 0;
+ virtual Ref<Texture> get_icon() = 0;
+ virtual bool is_unsaved() = 0;
+ virtual Variant get_edit_state() = 0;
+ virtual void set_edit_state(const Variant &p_state) = 0;
+ virtual void goto_line(int p_line, bool p_with_error = false) = 0;
+ virtual void trim_trailing_whitespace() = 0;
+ virtual void ensure_focus() = 0;
+ virtual void tag_saved_version() = 0;
+ virtual void reload(bool p_soft) = 0;
+ virtual void get_breakpoints(List<int> *p_breakpoints) = 0;
+ virtual bool goto_method(const String &p_method) = 0;
+ virtual void add_callback(const String &p_function, PoolStringArray p_args) = 0;
+ virtual void update_settings() = 0;
+ virtual void set_debugger_active(bool p_active) = 0;
virtual bool can_lose_focus_on_node_selection() { return true; }
- virtual void set_tooltip_request_func(String p_method,Object* p_obj)=0;
- virtual Control *get_edit_menu()=0;
+ virtual void set_tooltip_request_func(String p_method, Object *p_obj) = 0;
+ virtual Control *get_edit_menu() = 0;
ScriptEditorBase() {}
};
-
-typedef ScriptEditorBase* (*CreateScriptEditorFunc)(const Ref<Script>& p_script);
-
+typedef ScriptEditorBase *(*CreateScriptEditorFunc)(const Ref<Script> &p_script);
class EditorScriptCodeCompletionCache;
class ScriptEditor : public VBoxContainer {
- GDCLASS(ScriptEditor, VBoxContainer );
-
+ GDCLASS(ScriptEditor, VBoxContainer);
EditorNode *editor;
enum {
@@ -152,14 +145,14 @@ class ScriptEditor : public VBoxContainer {
WINDOW_MOVE_RIGHT,
WINDOW_NEXT,
WINDOW_PREV,
- WINDOW_SELECT_BASE=100
+ WINDOW_SELECT_BASE = 100
};
-
+
enum ScriptSortBy {
SORT_BY_NAME,
SORT_BY_PATH,
};
-
+
enum ScriptListName {
DISPLAY_NAME,
DISPLAY_DIR_AND_NAME,
@@ -185,7 +178,7 @@ class ScriptEditor : public VBoxContainer {
EditorFileDialog *file_dialog;
ConfirmationDialog *erase_tab_confirm;
ScriptCreateDialog *script_create_dialog;
- ScriptEditorDebugger* debugger;
+ ScriptEditorDebugger *debugger;
ToolButton *scripts_visible;
String current_theme;
@@ -197,7 +190,7 @@ class ScriptEditor : public VBoxContainer {
ToolButton *script_forward;
enum {
- SCRIPT_EDITOR_FUNC_MAX=32
+ SCRIPT_EDITOR_FUNC_MAX = 32
};
static int script_editor_func_count;
@@ -212,7 +205,6 @@ class ScriptEditor : public VBoxContainer {
Vector<ScriptHistory> history;
int history_pos;
-
EditorHelpIndex *help_index;
void _tab_changed(int p_which);
@@ -223,17 +215,17 @@ class ScriptEditor : public VBoxContainer {
bool restoring_layout;
- String _get_debug_tooltip(const String&p_text,Node *_ste);
+ String _get_debug_tooltip(const String &p_text, Node *_ste);
- void _resave_scripts(const String& p_str);
+ void _resave_scripts(const String &p_str);
void _reload_scripts();
- bool _test_script_times_on_disk(Ref<Script> p_for_script=Ref<Script>());
+ bool _test_script_times_on_disk(Ref<Script> p_for_script = Ref<Script>());
- void _close_tab(int p_idx, bool p_save=true);
+ void _close_tab(int p_idx, bool p_save = true);
void _close_current_tab();
- void _close_discard_current_tab(const String& p_str);
+ void _close_discard_current_tab(const String &p_str);
void _close_docs_tab();
void _close_all_tabs();
@@ -255,16 +247,16 @@ class ScriptEditor : public VBoxContainer {
int edit_pass;
- void _add_callback(Object *p_obj, const String& p_function, const PoolStringArray& p_args);
- void _res_saved_callback(const Ref<Resource>& p_res);
+ void _add_callback(Object *p_obj, const String &p_function, const PoolStringArray &p_args);
+ void _res_saved_callback(const Ref<Resource> &p_res);
bool trim_trailing_whitespace_on_save;
void _trim_trailing_whitespace(TextEdit *tx);
void _goto_script_line2(int p_line);
- void _goto_script_line(REF p_script,int p_line);
- void _breaked(bool p_breaked,bool p_can_debug);
+ void _goto_script_line(REF p_script, int p_line);
+ void _breaked(bool p_breaked, bool p_can_debug);
void _show_debugger(bool p_show);
void _update_window_menu();
void _script_created(Ref<Script> p_script);
@@ -277,13 +269,13 @@ class ScriptEditor : public VBoxContainer {
void _script_selected(int p_idx);
- void _find_scripts(Node* p_base, Node* p_current,Set<Ref<Script> >& used);
+ void _find_scripts(Node *p_base, Node *p_current, Set<Ref<Script> > &used);
void _tree_changed();
void _script_split_dragged(float);
- void _unhandled_input(const InputEvent& p_event);
+ void _unhandled_input(const InputEvent &p_event);
void _help_search(String p_text);
@@ -292,36 +284,37 @@ class ScriptEditor : public VBoxContainer {
bool waiting_update_names;
- void _help_class_open(const String& p_class);
- void _help_class_goto(const String& p_desc);
+ void _help_class_open(const String &p_class);
+ void _help_class_goto(const String &p_desc);
void _update_history_arrows();
void _save_history();
void _go_to_tab(int p_idx);
void _update_history_pos(int p_new_pos);
void _update_script_colors();
- void _update_modified_scripts_for_external_editor(Ref<Script> p_for_script=Ref<Script>());
+ void _update_modified_scripts_for_external_editor(Ref<Script> p_for_script = Ref<Script>());
int file_dialog_option;
void _file_dialog_action(String p_file);
- static void _open_script_request(const String& p_path);
+ static void _open_script_request(const String &p_path);
static ScriptEditor *script_editor;
+
protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
static ScriptEditor *get_singleton() { return script_editor; }
void ensure_focus_current();
void apply_scripts() const;
void ensure_select_current();
- void edit(const Ref<Script>& p_script,bool p_grab_focus=true);
+ void edit(const Ref<Script> &p_script, bool p_grab_focus = true);
Dictionary get_state() const;
- void set_state(const Dictionary& p_state);
+ void set_state(const Dictionary &p_state);
void clear();
void get_breakpoints(List<String> *p_breakpoints);
@@ -333,15 +326,15 @@ public:
void set_window_layout(Ref<ConfigFile> p_layout);
void get_window_layout(Ref<ConfigFile> p_layout);
- void set_scene_root_script( Ref<Script> p_script );
+ void set_scene_root_script(Ref<Script> p_script);
- bool script_go_to_method(Ref<Script> p_script, const String& p_method);
+ bool script_go_to_method(Ref<Script> p_script, const String &p_method);
virtual void edited_scene_changed();
- void close_builtin_scripts_from_scene(const String& p_scene);
+ void close_builtin_scripts_from_scene(const String &p_scene);
- void goto_help(const String& p_desc) { _help_class_goto(p_desc); }
+ void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
bool can_take_away_focus() const;
@@ -355,12 +348,12 @@ public:
class ScriptEditorPlugin : public EditorPlugin {
- GDCLASS( ScriptEditorPlugin, EditorPlugin );
+ GDCLASS(ScriptEditorPlugin, EditorPlugin);
ScriptEditor *script_editor;
EditorNode *editor;
-public:
+public:
virtual String get_name() const { return "Script"; }
bool has_main_screen() const { return true; }
virtual void edit(Object *p_node);
@@ -369,7 +362,7 @@ public:
virtual void selected_notify();
Dictionary get_state() const;
- virtual void set_state(const Dictionary& p_state);
+ virtual void set_state(const Dictionary &p_state);
virtual void clear();
virtual void save_external_data();
@@ -383,12 +376,10 @@ public:
virtual void get_breakpoints(List<String> *p_breakpoints);
-
virtual void edited_scene_changed();
ScriptEditorPlugin(EditorNode *p_node);
~ScriptEditorPlugin();
-
};
#endif // SCRIPT_EDITOR_PLUGIN_H
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 8723a863f0..7496ad8cca 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -28,30 +28,27 @@
/*************************************************************************/
#include "script_text_editor.h"
+#include "editor/editor_node.h"
#include "editor/editor_settings.h"
-#include "os/keyboard.h"
#include "editor/script_editor_debugger.h"
-#include "editor/editor_node.h"
-
-Vector<String> ScriptTextEditor::get_functions() {
+#include "os/keyboard.h"
+Vector<String> ScriptTextEditor::get_functions() {
String errortxt;
- int line=-1,col;
- TextEdit *te=code_editor->get_text_edit();
+ int line = -1, col;
+ TextEdit *te = code_editor->get_text_edit();
String text = te->get_text();
List<String> fnc;
- if (script->get_language()->validate(text,line,col,errortxt,script->get_path(),&fnc)) {
+ if (script->get_language()->validate(text, line, col, errortxt, script->get_path(), &fnc)) {
//if valid rewrite functions to latest
functions.clear();
- for (List<String>::Element *E=fnc.front();E;E=E->next()) {
+ for (List<String>::Element *E = fnc.front(); E; E = E->next()) {
functions.push_back(E->get());
}
-
-
}
return functions;
@@ -71,20 +68,19 @@ Ref<Script> ScriptTextEditor::get_edited_script() const {
return script;
}
-bool ScriptTextEditor::goto_method(const String& p_method) {
-
+bool ScriptTextEditor::goto_method(const String &p_method) {
Vector<String> functions = get_functions();
String method_search = p_method + ":";
- for (int i=0;i<functions.size();i++) {
- String function=functions[i];
+ for (int i = 0; i < functions.size(); i++) {
+ String function = functions[i];
if (function.begins_with(method_search)) {
- int line=function.get_slice(":",1).to_int();
- goto_line(line-1);
+ int line = function.get_slice(":", 1).to_int();
+ goto_line(line - 1);
return true;
}
}
@@ -100,105 +96,103 @@ void ScriptTextEditor::_load_theme_settings() {
/* keyword color */
-
- text_edit->add_color_override("background_color", EDITOR_DEF("text_editor/highlighting/background_color",Color(0,0,0,0)));
- text_edit->add_color_override("completion_background_color", EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0,0,0,0)));
+ text_edit->add_color_override("background_color", EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0)));
+ text_edit->add_color_override("completion_background_color", EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0)));
text_edit->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244")));
text_edit->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf")));
text_edit->add_color_override("completion_scroll_color", EDITOR_DEF("text_editor/highlighting/completion_scroll_color", Color::html("ffffff")));
text_edit->add_color_override("completion_font_color", EDITOR_DEF("text_editor/highlighting/completion_font_color", Color::html("aaaaaa")));
- text_edit->add_color_override("font_color",EDITOR_DEF("text_editor/highlighting/text_color",Color(0,0,0)));
- text_edit->add_color_override("line_number_color",EDITOR_DEF("text_editor/highlighting/line_number_color",Color(0,0,0)));
- text_edit->add_color_override("caret_color",EDITOR_DEF("text_editor/highlighting/caret_color",Color(0,0,0)));
- text_edit->add_color_override("caret_background_color",EDITOR_DEF("text_editor/highlighting/caret_background_color",Color(0,0,0)));
- text_edit->add_color_override("font_selected_color",EDITOR_DEF("text_editor/highlighting/text_selected_color",Color(1,1,1)));
- text_edit->add_color_override("selection_color",EDITOR_DEF("text_editor/highlighting/selection_color",Color(0.2,0.2,1)));
- text_edit->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/highlighting/brace_mismatch_color",Color(1,0.2,0.2)));
- text_edit->add_color_override("current_line_color",EDITOR_DEF("text_editor/highlighting/current_line_color",Color(0.3,0.5,0.8,0.15)));
- text_edit->add_color_override("line_length_guideline_color", EDITOR_DEF("text_editor/highlighting/line_length_guideline_color", Color(0,0,0)));
- text_edit->add_color_override("word_highlighted_color",EDITOR_DEF("text_editor/highlighting/word_highlighted_color",Color(0.8,0.9,0.9,0.15)));
- text_edit->add_color_override("number_color",EDITOR_DEF("text_editor/highlighting/number_color",Color(0.9,0.6,0.0,2)));
- text_edit->add_color_override("function_color",EDITOR_DEF("text_editor/highlighting/function_color",Color(0.4,0.6,0.8)));
- text_edit->add_color_override("member_variable_color",EDITOR_DEF("text_editor/highlighting/member_variable_color",Color(0.9,0.3,0.3)));
- text_edit->add_color_override("mark_color", EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0,0.4,0.4,0.4)));
- text_edit->add_color_override("breakpoint_color", EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8,0.8,0.4,0.2)));
- text_edit->add_color_override("search_result_color",EDITOR_DEF("text_editor/highlighting/search_result_color",Color(0.05,0.25,0.05,1)));
- text_edit->add_color_override("search_result_border_color",EDITOR_DEF("text_editor/highlighting/search_result_border_color",Color(0.1,0.45,0.1,1)));
- text_edit->add_color_override("symbol_color",EDITOR_DEF("text_editor/highlighting/symbol_color",Color::hex(0x005291ff)));
- text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing",4));
-
- Color keyword_color= EDITOR_DEF("text_editor/highlighting/keyword_color",Color(0.5,0.0,0.2));
+ text_edit->add_color_override("font_color", EDITOR_DEF("text_editor/highlighting/text_color", Color(0, 0, 0)));
+ text_edit->add_color_override("line_number_color", EDITOR_DEF("text_editor/highlighting/line_number_color", Color(0, 0, 0)));
+ text_edit->add_color_override("caret_color", EDITOR_DEF("text_editor/highlighting/caret_color", Color(0, 0, 0)));
+ text_edit->add_color_override("caret_background_color", EDITOR_DEF("text_editor/highlighting/caret_background_color", Color(0, 0, 0)));
+ text_edit->add_color_override("font_selected_color", EDITOR_DEF("text_editor/highlighting/text_selected_color", Color(1, 1, 1)));
+ text_edit->add_color_override("selection_color", EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1)));
+ text_edit->add_color_override("brace_mismatch_color", EDITOR_DEF("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2)));
+ text_edit->add_color_override("current_line_color", EDITOR_DEF("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15)));
+ text_edit->add_color_override("line_length_guideline_color", EDITOR_DEF("text_editor/highlighting/line_length_guideline_color", Color(0, 0, 0)));
+ text_edit->add_color_override("word_highlighted_color", EDITOR_DEF("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15)));
+ text_edit->add_color_override("number_color", EDITOR_DEF("text_editor/highlighting/number_color", Color(0.9, 0.6, 0.0, 2)));
+ text_edit->add_color_override("function_color", EDITOR_DEF("text_editor/highlighting/function_color", Color(0.4, 0.6, 0.8)));
+ text_edit->add_color_override("member_variable_color", EDITOR_DEF("text_editor/highlighting/member_variable_color", Color(0.9, 0.3, 0.3)));
+ text_edit->add_color_override("mark_color", EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4)));
+ text_edit->add_color_override("breakpoint_color", EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2)));
+ text_edit->add_color_override("search_result_color", EDITOR_DEF("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1)));
+ text_edit->add_color_override("search_result_border_color", EDITOR_DEF("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1)));
+ text_edit->add_color_override("symbol_color", EDITOR_DEF("text_editor/highlighting/symbol_color", Color::hex(0x005291ff)));
+ text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 4));
+
+ Color keyword_color = EDITOR_DEF("text_editor/highlighting/keyword_color", Color(0.5, 0.0, 0.2));
List<String> keywords;
script->get_language()->get_reserved_words(&keywords);
- for(List<String>::Element *E=keywords.front();E;E=E->next()) {
+ for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
- text_edit->add_keyword_color(E->get(),keyword_color);
+ text_edit->add_keyword_color(E->get(), keyword_color);
}
//colorize core types
- Color basetype_color= EDITOR_DEF("text_editor/highlighting/base_type_color",Color(0.3,0.3,0.0));
-
- text_edit->add_keyword_color("Vector2",basetype_color);
- text_edit->add_keyword_color("Vector3",basetype_color);
- text_edit->add_keyword_color("Plane",basetype_color);
- text_edit->add_keyword_color("Quat",basetype_color);
- text_edit->add_keyword_color("AABB",basetype_color);
- text_edit->add_keyword_color("Matrix3",basetype_color);
- text_edit->add_keyword_color("Transform",basetype_color);
- text_edit->add_keyword_color("Color",basetype_color);
- text_edit->add_keyword_color("Image",basetype_color);
- text_edit->add_keyword_color("InputEvent",basetype_color);
- text_edit->add_keyword_color("Rect2",basetype_color);
- text_edit->add_keyword_color("NodePath",basetype_color);
+ Color basetype_color = EDITOR_DEF("text_editor/highlighting/base_type_color", Color(0.3, 0.3, 0.0));
+
+ text_edit->add_keyword_color("Vector2", basetype_color);
+ text_edit->add_keyword_color("Vector3", basetype_color);
+ text_edit->add_keyword_color("Plane", basetype_color);
+ text_edit->add_keyword_color("Quat", basetype_color);
+ text_edit->add_keyword_color("AABB", basetype_color);
+ text_edit->add_keyword_color("Matrix3", basetype_color);
+ text_edit->add_keyword_color("Transform", basetype_color);
+ text_edit->add_keyword_color("Color", basetype_color);
+ text_edit->add_keyword_color("Image", basetype_color);
+ text_edit->add_keyword_color("InputEvent", basetype_color);
+ text_edit->add_keyword_color("Rect2", basetype_color);
+ text_edit->add_keyword_color("NodePath", basetype_color);
//colorize engine types
- Color type_color= EDITOR_DEF("text_editor/highlighting/engine_type_color",Color(0.0,0.2,0.4));
+ Color type_color = EDITOR_DEF("text_editor/highlighting/engine_type_color", Color(0.0, 0.2, 0.4));
List<StringName> types;
ClassDB::get_class_list(&types);
- for(List<StringName>::Element *E=types.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = types.front(); E; E = E->next()) {
String n = E->get();
if (n.begins_with("_"))
n = n.substr(1, n.length());
- text_edit->add_keyword_color(n,type_color);
+ text_edit->add_keyword_color(n, type_color);
}
//colorize comments
- Color comment_color = EDITOR_DEF("text_editor/highlighting/comment_color",Color::hex(0x797e7eff));
+ Color comment_color = EDITOR_DEF("text_editor/highlighting/comment_color", Color::hex(0x797e7eff));
List<String> comments;
script->get_language()->get_comment_delimiters(&comments);
- for(List<String>::Element *E=comments.front();E;E=E->next()) {
+ for (List<String>::Element *E = comments.front(); E; E = E->next()) {
String comment = E->get();
- String beg = comment.get_slice(" ",0);
- String end = comment.get_slice_count(" ")>1?comment.get_slice(" ",1):String();
+ String beg = comment.get_slice(" ", 0);
+ String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
- text_edit->add_color_region(beg,end,comment_color,end=="");
+ text_edit->add_color_region(beg, end, comment_color, end == "");
}
//colorize strings
- Color string_color = EDITOR_DEF("text_editor/highlighting/string_color",Color::hex(0x6b6f00ff));
+ Color string_color = EDITOR_DEF("text_editor/highlighting/string_color", Color::hex(0x6b6f00ff));
List<String> strings;
script->get_language()->get_string_delimiters(&strings);
- for (List<String>::Element *E=strings.front();E;E=E->next()) {
+ for (List<String>::Element *E = strings.front(); E; E = E->next()) {
String string = E->get();
- String beg = string.get_slice(" ",0);
- String end = string.get_slice_count(" ")>1?string.get_slice(" ",1):String();
- text_edit->add_color_region(beg,end,string_color,end=="");
+ String beg = string.get_slice(" ", 0);
+ String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String();
+ text_edit->add_color_region(beg, end, string_color, end == "");
}
}
-
void ScriptTextEditor::reload_text() {
- ERR_FAIL_COND(script.is_null()) ;
+ ERR_FAIL_COND(script.is_null());
TextEdit *te = code_editor->get_text_edit();
int column = te->cursor_get_column();
@@ -216,30 +210,29 @@ void ScriptTextEditor::reload_text() {
te->tag_saved_version();
code_editor->update_line_and_column();
-
}
void ScriptTextEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
//emit_signal("name_changed");
}
}
-void ScriptTextEditor::add_callback(const String& p_function,PoolStringArray p_args) {
+void ScriptTextEditor::add_callback(const String &p_function, PoolStringArray p_args) {
String code = code_editor->get_text_edit()->get_text();
- int pos = script->get_language()->find_function(p_function,code);
- if (pos==-1) {
+ int pos = script->get_language()->find_function(p_function, code);
+ if (pos == -1) {
//does not exist
code_editor->get_text_edit()->deselect();
- pos=code_editor->get_text_edit()->get_line_count()+2;
- String func = script->get_language()->make_function("",p_function,p_args);
+ pos = code_editor->get_text_edit()->get_line_count() + 2;
+ String func = script->get_language()->make_function("", p_function, p_args);
//code=code+func;
- code_editor->get_text_edit()->cursor_set_line(pos+1);
+ code_editor->get_text_edit()->cursor_set_line(pos + 1);
code_editor->get_text_edit()->cursor_set_column(1000000); //none shall be that big
- code_editor->get_text_edit()->insert_text_at_cursor("\n\n"+func);
+ code_editor->get_text_edit()->insert_text_at_cursor("\n\n" + func);
}
code_editor->get_text_edit()->cursor_set_line(pos);
code_editor->get_text_edit()->cursor_set_column(1);
@@ -250,18 +243,18 @@ void ScriptTextEditor::update_settings() {
code_editor->update_editor_settings();
}
-bool ScriptTextEditor::is_unsaved() {
+bool ScriptTextEditor::is_unsaved() {
- return code_editor->get_text_edit()->get_version()!=code_editor->get_text_edit()->get_saved_version();
+ return code_editor->get_text_edit()->get_version() != code_editor->get_text_edit()->get_saved_version();
}
Variant ScriptTextEditor::get_edit_state() {
Dictionary state;
- state["scroll_pos"]=code_editor->get_text_edit()->get_v_scroll();
- state["column"]=code_editor->get_text_edit()->cursor_get_column();
- state["row"]=code_editor->get_text_edit()->cursor_get_line();
+ state["scroll_pos"] = code_editor->get_text_edit()->get_v_scroll();
+ state["column"] = code_editor->get_text_edit()->cursor_get_column();
+ state["row"] = code_editor->get_text_edit()->cursor_get_line();
return state;
}
@@ -283,7 +276,7 @@ void ScriptTextEditor::trim_trailing_whitespace() {
int end = 0;
for (int j = line.length() - 1; j > -1; j--) {
if (line[j] != ' ' && line[j] != '\t') {
- end = j+1;
+ end = j + 1;
break;
}
}
@@ -310,12 +303,12 @@ void ScriptTextEditor::ensure_focus() {
code_editor->get_text_edit()->grab_focus();
}
-void ScriptTextEditor::set_edit_state(const Variant& p_state) {
+void ScriptTextEditor::set_edit_state(const Variant &p_state) {
- Dictionary state=p_state;
+ Dictionary state = p_state;
code_editor->get_text_edit()->set_v_scroll(state["scroll_pos"]);
- code_editor->get_text_edit()->cursor_set_column( state["column"]);
- code_editor->get_text_edit()->cursor_set_line( state["row"] );
+ code_editor->get_text_edit()->cursor_set_column(state["column"]);
+ code_editor->get_text_edit()->cursor_set_line(state["row"]);
code_editor->get_text_edit()->grab_focus();
//int scroll_pos;
@@ -323,40 +316,36 @@ void ScriptTextEditor::set_edit_state(const Variant& p_state) {
//int cursor_row;
}
-String ScriptTextEditor::get_name() {
+String ScriptTextEditor::get_name() {
String name;
- if (script->get_path().find("local://")==-1 && script->get_path().find("::")==-1) {
- name=script->get_path().get_file();
+ if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) {
+ name = script->get_path().get_file();
if (is_unsaved()) {
- name+="(*)";
+ name += "(*)";
}
- } else if (script->get_name()!="")
- name=script->get_name();
+ } else if (script->get_name() != "")
+ name = script->get_name();
else
- name=script->get_class()+"("+itos(script->get_instance_ID())+")";
+ name = script->get_class() + "(" + itos(script->get_instance_ID()) + ")";
return name;
-
}
Ref<Texture> ScriptTextEditor::get_icon() {
- if (get_parent_control() && get_parent_control()->has_icon(script->get_class(),"EditorIcons")) {
- return get_parent_control()->get_icon(script->get_class(),"EditorIcons");
+ if (get_parent_control() && get_parent_control()->has_icon(script->get_class(), "EditorIcons")) {
+ return get_parent_control()->get_icon(script->get_class(), "EditorIcons");
}
return Ref<Texture>();
}
-
-
-void ScriptTextEditor::set_edited_script(const Ref<Script>& p_script) {
+void ScriptTextEditor::set_edited_script(const Ref<Script> &p_script) {
ERR_FAIL_COND(!script.is_null());
- script=p_script;
-
+ script = p_script;
_load_theme_settings();
@@ -368,22 +357,21 @@ void ScriptTextEditor::set_edited_script(const Ref<Script>& p_script) {
code_editor->update_line_and_column();
}
-
void ScriptTextEditor::_validate_script() {
String errortxt;
- int line=-1,col;
- TextEdit *te=code_editor->get_text_edit();
+ int line = -1, col;
+ TextEdit *te = code_editor->get_text_edit();
String text = te->get_text();
List<String> fnc;
- if (!script->get_language()->validate(text,line,col,errortxt,script->get_path(),&fnc)) {
- String error_text="error("+itos(line)+","+itos(col)+"): "+errortxt;
+ if (!script->get_language()->validate(text, line, col, errortxt, script->get_path(), &fnc)) {
+ String error_text = "error(" + itos(line) + "," + itos(col) + "): " + errortxt;
code_editor->set_error(error_text);
} else {
code_editor->set_error("");
- line=-1;
+ line = -1;
if (!script->is_tool()) {
script->set_source_code(text);
script->update_exports();
@@ -391,31 +379,29 @@ void ScriptTextEditor::_validate_script() {
}
functions.clear();
- for (List<String>::Element *E=fnc.front();E;E=E->next()) {
+ for (List<String>::Element *E = fnc.front(); E; E = E->next()) {
functions.push_back(E->get());
}
-
}
line--;
- for(int i=0;i<te->get_line_count();i++) {
- te->set_line_as_marked(i,line==i);
+ for (int i = 0; i < te->get_line_count(); i++) {
+ te->set_line_as_marked(i, line == i);
}
emit_signal("name_changed");
}
+static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Script> &p_script) {
-static Node* _find_node_for_script(Node* p_base, Node*p_current, const Ref<Script>& p_script) {
-
- if (p_current->get_owner()!=p_base && p_base!=p_current)
+ if (p_current->get_owner() != p_base && p_base != p_current)
return NULL;
Ref<Script> c = p_current->get_script();
- if (c==p_script)
+ if (c == p_script)
return p_current;
- for(int i=0;i<p_current->get_child_count();i++) {
- Node *found = _find_node_for_script(p_base,p_current->get_child(i),p_script);
+ for (int i = 0; i < p_current->get_child_count(); i++) {
+ Node *found = _find_node_for_script(p_base, p_current->get_child(i), p_script);
if (found)
return found;
}
@@ -423,19 +409,18 @@ static Node* _find_node_for_script(Node* p_base, Node*p_current, const Ref<Scrip
return NULL;
}
-static void _find_changed_scripts_for_external_editor(Node* p_base, Node*p_current, Set<Ref<Script> > &r_scripts) {
+static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, Set<Ref<Script> > &r_scripts) {
- if (p_current->get_owner()!=p_base && p_base!=p_current)
+ if (p_current->get_owner() != p_base && p_base != p_current)
return;
Ref<Script> c = p_current->get_script();
if (c.is_valid())
r_scripts.insert(c);
- for(int i=0;i<p_current->get_child_count();i++) {
- _find_changed_scripts_for_external_editor(p_base,p_current->get_child(i),r_scripts);
+ for (int i = 0; i < p_current->get_child_count(); i++) {
+ _find_changed_scripts_for_external_editor(p_base, p_current->get_child(i), r_scripts);
}
-
}
void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_for_script) {
@@ -447,17 +432,17 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
Node *base = get_tree()->get_edited_scene_root();
if (base) {
- _find_changed_scripts_for_external_editor(base,base,scripts);
+ _find_changed_scripts_for_external_editor(base, base, scripts);
}
- for (Set<Ref<Script> >::Element *E=scripts.front();E;E=E->next()) {
+ for (Set<Ref<Script> >::Element *E = scripts.front(); E; E = E->next()) {
Ref<Script> script = E->get();
- if (p_for_script.is_valid() && p_for_script!=script)
+ if (p_for_script.is_valid() && p_for_script != script)
continue;
- if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) {
+ if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) {
continue; //internal script, who cares, though weird
}
@@ -465,128 +450,120 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
uint64_t last_date = script->get_last_modified_time();
uint64_t date = FileAccess::get_modified_time(script->get_path());
- if (last_date!=date) {
+ if (last_date != date) {
- Ref<Script> rel_script = ResourceLoader::load(script->get_path(),script->get_class(),true);
+ Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), true);
ERR_CONTINUE(!rel_script.is_valid());
- script->set_source_code( rel_script->get_source_code() );
- script->set_last_modified_time( rel_script->get_last_modified_time() );
+ script->set_source_code(rel_script->get_source_code());
+ script->set_last_modified_time(rel_script->get_last_modified_time());
script->update_exports();
}
-
}
}
-
-void ScriptTextEditor::_code_complete_scripts(void* p_ud,const String& p_code, List<String>* r_options) {
+void ScriptTextEditor::_code_complete_scripts(void *p_ud, const String &p_code, List<String> *r_options) {
ScriptTextEditor *ste = (ScriptTextEditor *)p_ud;
- ste->_code_complete_script(p_code,r_options);
+ ste->_code_complete_script(p_code, r_options);
}
-void ScriptTextEditor::_code_complete_script(const String& p_code, List<String>* r_options) {
+void ScriptTextEditor::_code_complete_script(const String &p_code, List<String> *r_options) {
if (color_panel->is_visible_in_tree()) return;
Node *base = get_tree()->get_edited_scene_root();
if (base) {
- base = _find_node_for_script(base,base,script);
+ base = _find_node_for_script(base, base, script);
}
String hint;
- Error err = script->get_language()->complete_code(p_code,script->get_path().get_base_dir(),base,r_options,hint);
- if (hint!="") {
+ Error err = script->get_language()->complete_code(p_code, script->get_path().get_base_dir(), base, r_options, hint);
+ if (hint != "") {
code_editor->get_text_edit()->set_code_hint(hint);
}
-
}
void ScriptTextEditor::_breakpoint_toggled(int p_row) {
- ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(script->get_path(),p_row+1,code_editor->get_text_edit()->is_line_set_as_breakpoint(p_row));
-
+ ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(script->get_path(), p_row + 1, code_editor->get_text_edit()->is_line_set_as_breakpoint(p_row));
}
-static void swap_lines(TextEdit *tx, int line1, int line2)
-{
- String tmp = tx->get_line(line1);
- String tmp2 = tx->get_line(line2);
- tx->set_line(line2, tmp);
- tx->set_line(line1, tmp2);
+static void swap_lines(TextEdit *tx, int line1, int line2) {
+ String tmp = tx->get_line(line1);
+ String tmp2 = tx->get_line(line2);
+ tx->set_line(line2, tmp);
+ tx->set_line(line1, tmp2);
- tx->cursor_set_line(line2);
+ tx->cursor_set_line(line2);
}
-void ScriptTextEditor::_lookup_symbol(const String& p_symbol,int p_row, int p_column) {
+void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_column) {
Node *base = get_tree()->get_edited_scene_root();
if (base) {
- base = _find_node_for_script(base,base,script);
+ base = _find_node_for_script(base, base, script);
}
-
ScriptLanguage::LookupResult result;
- if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(),p_symbol,script->get_path().get_base_dir(),base,result)==OK) {
+ if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path().get_base_dir(), base, result) == OK) {
_goto_line(p_row);
- switch(result.type) {
+ switch (result.type) {
case ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION: {
if (result.script.is_valid()) {
- emit_signal("request_open_script_at_line",result.script,result.location-1);
+ emit_signal("request_open_script_at_line", result.script, result.location - 1);
} else {
emit_signal("request_save_history");
- _goto_line(result.location-1);
+ _goto_line(result.location - 1);
}
} break;
case ScriptLanguage::LookupResult::RESULT_CLASS: {
- emit_signal("go_to_help","class_name:"+result.class_name);
+ emit_signal("go_to_help", "class_name:" + result.class_name);
} break;
case ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT: {
StringName cname = result.class_name;
bool success;
- while(true) {
- ClassDB::get_integer_constant(cname,result.class_member,&success);
+ while (true) {
+ ClassDB::get_integer_constant(cname, result.class_member, &success);
if (success) {
- result.class_name=cname;
- cname=ClassDB::get_parent_class(cname);
+ result.class_name = cname;
+ cname = ClassDB::get_parent_class(cname);
} else {
break;
}
}
-
- emit_signal("go_to_help","class_constant:"+result.class_name+":"+result.class_member);
+ emit_signal("go_to_help", "class_constant:" + result.class_name + ":" + result.class_member);
} break;
case ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY: {
- emit_signal("go_to_help","class_property:"+result.class_name+":"+result.class_member);
+ emit_signal("go_to_help", "class_property:" + result.class_name + ":" + result.class_member);
} break;
case ScriptLanguage::LookupResult::RESULT_CLASS_METHOD: {
StringName cname = result.class_name;
- while(true) {
- if (ClassDB::has_method(cname,result.class_member)) {
- result.class_name=cname;
- cname=ClassDB::get_parent_class(cname);
+ while (true) {
+ if (ClassDB::has_method(cname, result.class_member)) {
+ result.class_name = cname;
+ cname = ClassDB::get_parent_class(cname);
} else {
break;
}
}
- emit_signal("go_to_help","class_method:"+result.class_name+":"+result.class_member);
+ emit_signal("go_to_help", "class_method:" + result.class_name + ":" + result.class_member);
} break;
}
-
}
}
void ScriptTextEditor::_edit_option(int p_op) {
- switch(p_op) {
+ switch (p_op) {
case EDIT_UNDO: {
code_editor->get_text_edit()->undo();
code_editor->get_text_edit()->call_deferred("grab_focus");
@@ -624,15 +601,13 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
tx->begin_complex_operation();
- if (tx->is_selection_active())
- {
+ if (tx->is_selection_active()) {
int from_line = tx->get_selection_from_line();
- int from_col = tx->get_selection_from_column();
- int to_line = tx->get_selection_to_line();
+ int from_col = tx->get_selection_from_column();
+ int to_line = tx->get_selection_to_line();
int to_column = tx->get_selection_to_column();
- for (int i = from_line; i <= to_line; i++)
- {
+ for (int i = from_line; i <= to_line; i++) {
int line_id = i;
int next_id = i - 1;
@@ -641,12 +616,10 @@ void ScriptTextEditor::_edit_option(int p_op) {
swap_lines(tx, line_id, next_id);
}
- int from_line_up = from_line > 0 ? from_line-1 : from_line;
- int to_line_up = to_line > 0 ? to_line-1 : to_line;
+ int from_line_up = from_line > 0 ? from_line - 1 : from_line;
+ int to_line_up = to_line > 0 ? to_line - 1 : to_line;
tx->select(from_line_up, from_col, to_line_up, to_column);
- }
- else
- {
+ } else {
int line_id = tx->cursor_get_line();
int next_id = line_id - 1;
@@ -667,33 +640,29 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
tx->begin_complex_operation();
- if (tx->is_selection_active())
- {
+ if (tx->is_selection_active()) {
int from_line = tx->get_selection_from_line();
- int from_col = tx->get_selection_from_column();
- int to_line = tx->get_selection_to_line();
+ int from_col = tx->get_selection_from_column();
+ int to_line = tx->get_selection_to_line();
int to_column = tx->get_selection_to_column();
- for (int i = to_line; i >= from_line; i--)
- {
+ for (int i = to_line; i >= from_line; i--) {
int line_id = i;
int next_id = i + 1;
- if (line_id == tx->get_line_count()-1 || next_id > tx->get_line_count())
+ if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count())
return;
swap_lines(tx, line_id, next_id);
}
- int from_line_down = from_line < tx->get_line_count() ? from_line+1 : from_line;
- int to_line_down = to_line < tx->get_line_count() ? to_line+1 : to_line;
+ int from_line_down = from_line < tx->get_line_count() ? from_line + 1 : from_line;
+ int to_line_down = to_line < tx->get_line_count() ? to_line + 1 : to_line;
tx->select(from_line_down, from_col, to_line_down, to_column);
- }
- else
- {
+ } else {
int line_id = tx->cursor_get_line();
int next_id = line_id + 1;
- if (line_id == tx->get_line_count()-1 || next_id > tx->get_line_count())
+ if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count())
return;
swap_lines(tx, line_id, next_id);
@@ -710,23 +679,18 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
tx->begin_complex_operation();
- if (tx->is_selection_active())
- {
+ if (tx->is_selection_active()) {
tx->indent_selection_left();
- }
- else
- {
+ } else {
int begin = tx->cursor_get_line();
String line_text = tx->get_line(begin);
// begins with tab
- if (line_text.begins_with("\t"))
- {
+ if (line_text.begins_with("\t")) {
line_text = line_text.substr(1, line_text.length());
tx->set_line(begin, line_text);
}
// begins with 4 spaces
- else if (line_text.begins_with(" "))
- {
+ else if (line_text.begins_with(" ")) {
line_text = line_text.substr(4, line_text.length());
tx->set_line(begin, line_text);
}
@@ -744,12 +708,9 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
tx->begin_complex_operation();
- if (tx->is_selection_active())
- {
+ if (tx->is_selection_active()) {
tx->indent_selection_right();
- }
- else
- {
+ } else {
int begin = tx->cursor_get_line();
String line_text = tx->get_line(begin);
line_text = '\t' + line_text;
@@ -782,7 +743,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
for (int i = from_line; i <= to_line; i++) {
if (i >= tx->get_line_count() - 1) {
- tx->set_line(i, tx->get_line(i) + "\n");
+ tx->set_line(i, tx->get_line(i) + "\n");
}
String line_clone = tx->get_line(i);
tx->insert_at(line_clone, next_line);
@@ -805,19 +766,16 @@ void ScriptTextEditor::_edit_option(int p_op) {
if (scr.is_null())
return;
-
tx->begin_complex_operation();
- if (tx->is_selection_active())
- {
+ if (tx->is_selection_active()) {
int begin = tx->get_selection_from_line();
int end = tx->get_selection_to_line();
// End of selection ends on the first column of the last line, ignore it.
- if(tx->get_selection_to_column() == 0)
+ if (tx->get_selection_to_column() == 0)
end -= 1;
- for (int i = begin; i <= end; i++)
- {
+ for (int i = begin; i <= end; i++) {
String line_text = tx->get_line(i);
if (line_text.begins_with("#"))
@@ -826,9 +784,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
line_text = "#" + line_text;
tx->set_line(i, line_text);
}
- }
- else
- {
+ } else {
int begin = tx->cursor_get_line();
String line_text = tx->get_line(begin);
@@ -855,18 +811,17 @@ void ScriptTextEditor::_edit_option(int p_op) {
Ref<Script> scr = get_edited_script();
if (scr.is_null())
return;
- int begin,end;
+ int begin, end;
if (te->is_selection_active()) {
- begin=te->get_selection_from_line();
- end=te->get_selection_to_line();
+ begin = te->get_selection_from_line();
+ end = te->get_selection_to_line();
} else {
- begin=0;
- end=te->get_line_count()-1;
+ begin = 0;
+ end = te->get_line_count() - 1;
}
- scr->get_language()->auto_indent_code(text,begin,end);
+ scr->get_language()->auto_indent_code(text, begin, end);
te->set_text(text);
-
} break;
case EDIT_TRIM_TRAILING_WHITESAPCE: {
trim_trailing_whitespace();
@@ -875,7 +830,6 @@ void ScriptTextEditor::_edit_option(int p_op) {
color_panel->popup();
} break;
-
case SEARCH_FIND: {
code_editor->get_find_replace_bar()->popup_search();
@@ -901,20 +855,20 @@ void ScriptTextEditor::_edit_option(int p_op) {
goto_line_dialog->popup_find_line(code_editor->get_text_edit());
} break;
case DEBUG_TOGGLE_BREAKPOINT: {
- int line=code_editor->get_text_edit()->cursor_get_line();
+ int line = code_editor->get_text_edit()->cursor_get_line();
bool dobreak = !code_editor->get_text_edit()->is_line_set_as_breakpoint(line);
- code_editor->get_text_edit()->set_line_as_breakpoint(line,dobreak);
- ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(get_edited_script()->get_path(),line+1,dobreak);
+ code_editor->get_text_edit()->set_line_as_breakpoint(line, dobreak);
+ ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(get_edited_script()->get_path(), line + 1, dobreak);
} break;
case DEBUG_REMOVE_ALL_BREAKPOINTS: {
List<int> bpoints;
code_editor->get_text_edit()->get_breakpoints(&bpoints);
- for(List<int>::Element *E=bpoints.front();E;E=E->next()) {
+ for (List<int>::Element *E = bpoints.front(); E; E = E->next()) {
int line = E->get();
bool dobreak = !code_editor->get_text_edit()->is_line_set_as_breakpoint(line);
- code_editor->get_text_edit()->set_line_as_breakpoint(line,dobreak);
- ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(get_edited_script()->get_path(),line+1,dobreak);
+ code_editor->get_text_edit()->set_line_as_breakpoint(line, dobreak);
+ ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(get_edited_script()->get_path(), line + 1, dobreak);
}
}
case DEBUG_GOTO_NEXT_BREAKPOINT: {
@@ -924,12 +878,12 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
}
- int line=code_editor->get_text_edit()->cursor_get_line();
+ int line = code_editor->get_text_edit()->cursor_get_line();
// wrap around
if (line >= bpoints[bpoints.size() - 1]) {
code_editor->get_text_edit()->cursor_set_line(bpoints[0]);
} else {
- for(List<int>::Element *E=bpoints.front();E;E=E->next()) {
+ for (List<int>::Element *E = bpoints.front(); E; E = E->next()) {
int bline = E->get();
if (bline > line) {
code_editor->get_text_edit()->cursor_set_line(bline);
@@ -946,12 +900,12 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
}
- int line=code_editor->get_text_edit()->cursor_get_line();
+ int line = code_editor->get_text_edit()->cursor_get_line();
// wrap around
if (line <= bpoints[0]) {
code_editor->get_text_edit()->cursor_set_line(bpoints[bpoints.size() - 1]);
} else {
- for(List<int>::Element *E=bpoints.back();E;E=E->prev()) {
+ for (List<int>::Element *E = bpoints.back(); E; E = E->prev()) {
int bline = E->get();
if (bline < line) {
code_editor->get_text_edit()->cursor_set_line(bline);
@@ -967,7 +921,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
if (text == "")
text = code_editor->get_text_edit()->get_word_under_cursor();
if (text != "") {
- emit_signal("request_help_search",text);
+ emit_signal("request_help_search", text);
}
} break;
}
@@ -975,20 +929,18 @@ void ScriptTextEditor::_edit_option(int p_op) {
void ScriptTextEditor::_bind_methods() {
- ClassDB::bind_method("_validate_script",&ScriptTextEditor::_validate_script);
- ClassDB::bind_method("_load_theme_settings",&ScriptTextEditor::_load_theme_settings);
- ClassDB::bind_method("_breakpoint_toggled",&ScriptTextEditor::_breakpoint_toggled);
- ClassDB::bind_method("_edit_option",&ScriptTextEditor::_edit_option);
- ClassDB::bind_method("_goto_line",&ScriptTextEditor::_goto_line);
- ClassDB::bind_method("_lookup_symbol",&ScriptTextEditor::_lookup_symbol);
+ ClassDB::bind_method("_validate_script", &ScriptTextEditor::_validate_script);
+ ClassDB::bind_method("_load_theme_settings", &ScriptTextEditor::_load_theme_settings);
+ ClassDB::bind_method("_breakpoint_toggled", &ScriptTextEditor::_breakpoint_toggled);
+ ClassDB::bind_method("_edit_option", &ScriptTextEditor::_edit_option);
+ ClassDB::bind_method("_goto_line", &ScriptTextEditor::_goto_line);
+ ClassDB::bind_method("_lookup_symbol", &ScriptTextEditor::_lookup_symbol);
ClassDB::bind_method("_text_edit_gui_input", &ScriptTextEditor::_text_edit_gui_input);
ClassDB::bind_method("_color_changed", &ScriptTextEditor::_color_changed);
-
- ClassDB::bind_method("get_drag_data_fw",&ScriptTextEditor::get_drag_data_fw);
- ClassDB::bind_method("can_drop_data_fw",&ScriptTextEditor::can_drop_data_fw);
- ClassDB::bind_method("drop_data_fw",&ScriptTextEditor::drop_data_fw);
-
+ ClassDB::bind_method("get_drag_data_fw", &ScriptTextEditor::get_drag_data_fw);
+ ClassDB::bind_method("can_drop_data_fw", &ScriptTextEditor::can_drop_data_fw);
+ ClassDB::bind_method("drop_data_fw", &ScriptTextEditor::drop_data_fw);
}
Control *ScriptTextEditor::get_edit_menu() {
@@ -1003,67 +955,59 @@ void ScriptTextEditor::reload(bool p_soft) {
if (scr.is_null())
return;
scr->set_source_code(te->get_text());
- bool soft = p_soft || scr->get_instance_base_type()=="EditorPlugin"; //always soft-reload editor plugins
+ bool soft = p_soft || scr->get_instance_base_type() == "EditorPlugin"; //always soft-reload editor plugins
- scr->get_language()->reload_tool_script(scr,soft);
+ scr->get_language()->reload_tool_script(scr, soft);
}
void ScriptTextEditor::get_breakpoints(List<int> *p_breakpoints) {
code_editor->get_text_edit()->get_breakpoints(p_breakpoints);
-
}
-void ScriptTextEditor::set_tooltip_request_func(String p_method,Object* p_obj) {
+void ScriptTextEditor::set_tooltip_request_func(String p_method, Object *p_obj) {
- code_editor->get_text_edit()->set_tooltip_request_func(p_obj,p_method,this);
+ code_editor->get_text_edit()->set_tooltip_request_func(p_obj, p_method, this);
}
void ScriptTextEditor::set_debugger_active(bool p_active) {
-
-
}
-
-Variant ScriptTextEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) {
+Variant ScriptTextEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
return Variant();
}
-bool ScriptTextEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{
+bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
Dictionary d = p_data;
if (d.has("type") &&
(
- String(d["type"])=="resource" ||
- String(d["type"])=="files" ||
- String(d["type"])=="nodes"
- ) ) {
+ String(d["type"]) == "resource" ||
+ String(d["type"]) == "files" ||
+ String(d["type"]) == "nodes")) {
-
- return true;
+ return true;
}
-
return false;
-
}
#ifdef TOOLS_ENABLED
-static Node* _find_script_node(Node* p_edited_scene,Node* p_current_node,const Ref<Script> &script) {
+static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
- if (p_edited_scene!=p_current_node && p_current_node->get_owner()!=p_edited_scene)
+ if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
return NULL;
Ref<Script> scr = p_current_node->get_script();
- if (scr.is_valid() && scr==script)
+ if (scr.is_valid() && scr == script)
return p_current_node;
- for(int i=0;i<p_current_node->get_child_count();i++) {
- Node *n = _find_script_node(p_edited_scene,p_current_node->get_child(i),script);
+ for (int i = 0; i < p_current_node->get_child_count(); i++) {
+ Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script);
if (n)
return n;
}
@@ -1073,20 +1017,17 @@ static Node* _find_script_node(Node* p_edited_scene,Node* p_current_node,const R
#else
-static Node* _find_script_node(Node* p_edited_scene,Node* p_current_node,const Ref<Script> &script) {
+static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
return NULL;
}
#endif
-
-
-
-void ScriptTextEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){
+void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
Dictionary d = p_data;
- if (d.has("type") && String(d["type"])=="resource") {
+ if (d.has("type") && String(d["type"]) == "resource") {
Ref<Resource> res = d["resource"];
if (!res.is_valid()) {
@@ -1099,44 +1040,38 @@ void ScriptTextEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,
}
code_editor->get_text_edit()->insert_text_at_cursor(res->get_path());
-
}
- if (d.has("type") && String(d["type"])=="files") {
-
+ if (d.has("type") && String(d["type"]) == "files") {
Array files = d["files"];
String text_to_drop;
- for(int i=0;i<files.size();i++) {
-
- if (i>0)
- text_to_drop+=",";
- text_to_drop+="\""+String(files[i]).c_escape()+"\"";
+ for (int i = 0; i < files.size(); i++) {
+ if (i > 0)
+ text_to_drop += ",";
+ text_to_drop += "\"" + String(files[i]).c_escape() + "\"";
}
code_editor->get_text_edit()->insert_text_at_cursor(text_to_drop);
-
}
- if (d.has("type") && String(d["type"])=="nodes") {
-
- Node* sn = _find_script_node(get_tree()->get_edited_scene_root(),get_tree()->get_edited_scene_root(),script);
+ if (d.has("type") && String(d["type"]) == "nodes") {
+ Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
if (!sn) {
- EditorNode::get_singleton()->show_warning("Can't drop nodes because script '"+get_name()+"' is not used in this scene.");
+ EditorNode::get_singleton()->show_warning("Can't drop nodes because script '" + get_name() + "' is not used in this scene.");
return;
}
-
Array nodes = d["nodes"];
String text_to_drop;
- for(int i=0;i<nodes.size();i++) {
+ for (int i = 0; i < nodes.size(); i++) {
- if (i>0)
- text_to_drop+=",";
+ if (i > 0)
+ text_to_drop += ",";
NodePath np = nodes[i];
Node *node = get_node(np);
@@ -1144,32 +1079,23 @@ void ScriptTextEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,
continue;
}
-
-
String path = sn->get_path_to(node);
- text_to_drop+="\""+path.c_escape()+"\"";
-
-
+ text_to_drop += "\"" + path.c_escape() + "\"";
}
code_editor->get_text_edit()->insert_text_at_cursor(text_to_drop);
-
-
}
-
-
-
}
-void ScriptTextEditor::_text_edit_gui_input(const InputEvent& ev) {
+void ScriptTextEditor::_text_edit_gui_input(const InputEvent &ev) {
if (ev.type == InputEvent::MOUSE_BUTTON) {
InputEventMouseButton mb = ev.mouse_button;
if (mb.button_index == BUTTON_RIGHT && !mb.pressed) {
int col, row;
- TextEdit* tx = code_editor->get_text_edit();
- tx->_get_mouse_pos(Point2i(mb.global_x, mb.global_y)-tx->get_global_pos(), row, col);
- Vector2 mpos = Vector2(mb.global_x, mb.global_y)-tx->get_global_pos();
+ TextEdit *tx = code_editor->get_text_edit();
+ tx->_get_mouse_pos(Point2i(mb.global_x, mb.global_y) - tx->get_global_pos(), row, col);
+ Vector2 mpos = Vector2(mb.global_x, mb.global_y) - tx->get_global_pos();
bool have_selection = (tx->get_selection_text().length() > 0);
bool have_color = (tx->get_word_at_pos(mpos) == "Color");
if (have_color) {
@@ -1177,21 +1103,20 @@ void ScriptTextEditor::_text_edit_gui_input(const InputEvent& ev) {
String line = tx->get_line(row);
color_line = row;
int begin = 0;
- int end = 0;
+ int end = 0;
bool valid = false;
for (int i = col; i < line.length(); i++) {
if (line[i] == '(') {
begin = i;
continue;
- }
- else if (line[i] == ')') {
- end = i+1;
+ } else if (line[i] == ')') {
+ end = i + 1;
valid = true;
break;
}
}
if (valid) {
- color_args = line.substr(begin, end-begin);
+ color_args = line.substr(begin, end - begin);
String stripped = color_args.replace(" ", "").replace("(", "").replace(")", "");
Vector<float> color = stripped.split_floats(",");
if (color.size() > 2) {
@@ -1199,7 +1124,7 @@ void ScriptTextEditor::_text_edit_gui_input(const InputEvent& ev) {
color_picker->set_pick_color(Color(color[0], color[1], color[2], alpha));
}
color_panel->set_pos(get_global_transform().xform(get_local_mouse_pos()));
- Size2 ms = Size2(300, color_picker->get_combined_minimum_size().height+10);
+ Size2 ms = Size2(300, color_picker->get_combined_minimum_size().height + 10);
color_panel->set_size(ms);
} else {
have_color = false;
@@ -1210,12 +1135,12 @@ void ScriptTextEditor::_text_edit_gui_input(const InputEvent& ev) {
}
}
-void ScriptTextEditor::_color_changed(const Color& p_color) {
+void ScriptTextEditor::_color_changed(const Color &p_color) {
String new_args;
if (p_color.a == 1.0f) {
- new_args = String("("+rtos(p_color.r)+", "+rtos(p_color.g)+", "+rtos(p_color.b)+")");
+ new_args = String("(" + rtos(p_color.r) + ", " + rtos(p_color.g) + ", " + rtos(p_color.b) + ")");
} else {
- new_args = String("("+rtos(p_color.r)+", "+rtos(p_color.g)+", "+rtos(p_color.b)+", "+rtos(p_color.a)+")");
+ new_args = String("(" + rtos(p_color.r) + ", " + rtos(p_color.g) + ", " + rtos(p_color.b) + ", " + rtos(p_color.a) + ")");
}
String line = code_editor->get_text_edit()->get_line(color_line);
@@ -1255,20 +1180,20 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) {
ScriptTextEditor::ScriptTextEditor() {
- code_editor = memnew( CodeTextEditor );
+ code_editor = memnew(CodeTextEditor);
add_child(code_editor);
code_editor->set_area_as_parent_rect();
- code_editor->connect("validate_script",this,"_validate_script");
- code_editor->connect("load_theme_settings",this,"_load_theme_settings");
- code_editor->set_code_complete_func(_code_complete_scripts,this);
+ code_editor->connect("validate_script", this, "_validate_script");
+ code_editor->connect("load_theme_settings", this, "_load_theme_settings");
+ code_editor->set_code_complete_func(_code_complete_scripts, this);
code_editor->get_text_edit()->connect("breakpoint_toggled", this, "_breakpoint_toggled");
code_editor->get_text_edit()->connect("symbol_lookup", this, "_lookup_symbol");
update_settings();
code_editor->get_text_edit()->set_callhint_settings(
- EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"),
- EditorSettings::get_singleton()->get("text_editor/completion/callhint_tooltip_offset"));
+ EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"),
+ EditorSettings::get_singleton()->get("text_editor/completion/callhint_tooltip_offset"));
code_editor->get_text_edit()->set_select_identifiers_on_hover(true);
code_editor->get_text_edit()->set_context_menu_enabled(false);
@@ -1285,9 +1210,9 @@ ScriptTextEditor::ScriptTextEditor() {
color_panel->set_child_rect(color_picker); //NOT
color_picker->connect("color_changed", this, "_color_changed");
- edit_hb = memnew (HBoxContainer);
+ edit_hb = memnew(HBoxContainer);
- edit_menu = memnew( MenuButton );
+ edit_menu = memnew(MenuButton);
edit_menu->set_text(TTR("Edit"));
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO);
@@ -1312,14 +1237,14 @@ ScriptTextEditor::ScriptTextEditor() {
#endif
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/auto_indent"), EDIT_AUTO_INDENT);
- edit_menu->get_popup()->connect("id_pressed", this,"_edit_option");
+ edit_menu->get_popup()->connect("id_pressed", this, "_edit_option");
edit_menu->get_popup()->add_separator();
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_breakpoint"), DEBUG_TOGGLE_BREAKPOINT);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/remove_all_breakpoints"), DEBUG_REMOVE_ALL_BREAKPOINTS);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_breakpoint"), DEBUG_GOTO_NEXT_BREAKPOINT);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_breakpoint"), DEBUG_GOTO_PREV_BREAKPOINT);
- search_menu = memnew( MenuButton );
+ search_menu = memnew(MenuButton);
edit_hb->add_child(search_menu);
search_menu->set_text(TTR("Search"));
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND);
@@ -1332,25 +1257,24 @@ ScriptTextEditor::ScriptTextEditor() {
search_menu->get_popup()->add_separator();
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/contextual_help"), HELP_CONTEXTUAL);
- search_menu->get_popup()->connect("id_pressed", this,"_edit_option");
+ search_menu->get_popup()->connect("id_pressed", this, "_edit_option");
edit_hb->add_child(edit_menu);
- quick_open = memnew( ScriptEditorQuickOpen );
+ quick_open = memnew(ScriptEditorQuickOpen);
add_child(quick_open);
- quick_open->connect("goto_line",this,"_goto_line");
+ quick_open->connect("goto_line", this, "_goto_line");
goto_line_dialog = memnew(GotoLineDialog);
add_child(goto_line_dialog);
-
code_editor->get_text_edit()->set_drag_forwarding(this);
}
-static ScriptEditorBase * create_editor(const Ref<Script>& p_script) {
+static ScriptEditorBase *create_editor(const Ref<Script> &p_script) {
if (p_script->has_source_code()) {
- return memnew( ScriptTextEditor );
+ return memnew(ScriptTextEditor);
}
return NULL;
@@ -1358,44 +1282,44 @@ static ScriptEditorBase * create_editor(const Ref<Script>& p_script) {
void ScriptTextEditor::register_editor() {
- ED_SHORTCUT("script_text_editor/undo", TTR("Undo"), KEY_MASK_CMD|KEY_Z);
- ED_SHORTCUT("script_text_editor/redo", TTR("Redo"), KEY_MASK_CMD|KEY_Y);
- ED_SHORTCUT("script_text_editor/cut", TTR("Cut"), KEY_MASK_CMD|KEY_X);
- ED_SHORTCUT("script_text_editor/copy", TTR("Copy"), KEY_MASK_CMD|KEY_C);
- ED_SHORTCUT("script_text_editor/paste", TTR("Paste"), KEY_MASK_CMD|KEY_V);
- ED_SHORTCUT("script_text_editor/select_all", TTR("Select All"), KEY_MASK_CMD|KEY_A);
- ED_SHORTCUT("script_text_editor/move_up", TTR("Move Up"), KEY_MASK_ALT|KEY_UP);
- ED_SHORTCUT("script_text_editor/move_down", TTR("Move Down"), KEY_MASK_ALT|KEY_DOWN);
+ ED_SHORTCUT("script_text_editor/undo", TTR("Undo"), KEY_MASK_CMD | KEY_Z);
+ ED_SHORTCUT("script_text_editor/redo", TTR("Redo"), KEY_MASK_CMD | KEY_Y);
+ ED_SHORTCUT("script_text_editor/cut", TTR("Cut"), KEY_MASK_CMD | KEY_X);
+ ED_SHORTCUT("script_text_editor/copy", TTR("Copy"), KEY_MASK_CMD | KEY_C);
+ ED_SHORTCUT("script_text_editor/paste", TTR("Paste"), KEY_MASK_CMD | KEY_V);
+ ED_SHORTCUT("script_text_editor/select_all", TTR("Select All"), KEY_MASK_CMD | KEY_A);
+ ED_SHORTCUT("script_text_editor/move_up", TTR("Move Up"), KEY_MASK_ALT | KEY_UP);
+ ED_SHORTCUT("script_text_editor/move_down", TTR("Move Down"), KEY_MASK_ALT | KEY_DOWN);
//leave these at zero, same can be accomplished with tab/shift-tab, including selection
//the next/previous in history shortcut in this case makes a lot more sene.
ED_SHORTCUT("script_text_editor/indent_left", TTR("Indent Left"), 0);
ED_SHORTCUT("script_text_editor/indent_right", TTR("Indent Right"), 0);
- ED_SHORTCUT("script_text_editor/toggle_comment", TTR("Toggle Comment"), KEY_MASK_CMD|KEY_K);
- ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_CMD|KEY_B);
+ ED_SHORTCUT("script_text_editor/toggle_comment", TTR("Toggle Comment"), KEY_MASK_CMD | KEY_K);
+ ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_CMD | KEY_B);
#ifdef OSX_ENABLED
- ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CTRL|KEY_SPACE);
+ ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CTRL | KEY_SPACE);
#else
- ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CMD|KEY_SPACE);
+ ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CMD | KEY_SPACE);
#endif
- ED_SHORTCUT("script_text_editor/trim_trailing_whitespace", TTR("Trim Trailing Whitespace"), KEY_MASK_CTRL|KEY_MASK_ALT|KEY_T);
- ED_SHORTCUT("script_text_editor/auto_indent", TTR("Auto Indent"), KEY_MASK_CMD|KEY_I);
+ ED_SHORTCUT("script_text_editor/trim_trailing_whitespace", TTR("Trim Trailing Whitespace"), KEY_MASK_CTRL | KEY_MASK_ALT | KEY_T);
+ ED_SHORTCUT("script_text_editor/auto_indent", TTR("Auto Indent"), KEY_MASK_CMD | KEY_I);
ED_SHORTCUT("script_text_editor/toggle_breakpoint", TTR("Toggle Breakpoint"), KEY_F9);
- ED_SHORTCUT("script_text_editor/remove_all_breakpoints", TTR("Remove All Breakpoints"), KEY_MASK_CTRL|KEY_MASK_SHIFT|KEY_F9);
- ED_SHORTCUT("script_text_editor/goto_next_breakpoint", TTR("Goto Next Breakpoint"), KEY_MASK_CTRL|KEY_PERIOD);
- ED_SHORTCUT("script_text_editor/goto_previous_breakpoint", TTR("Goto Previous Breakpoint"), KEY_MASK_CTRL|KEY_COMMA);
+ ED_SHORTCUT("script_text_editor/remove_all_breakpoints", TTR("Remove All Breakpoints"), KEY_MASK_CTRL | KEY_MASK_SHIFT | KEY_F9);
+ ED_SHORTCUT("script_text_editor/goto_next_breakpoint", TTR("Goto Next Breakpoint"), KEY_MASK_CTRL | KEY_PERIOD);
+ ED_SHORTCUT("script_text_editor/goto_previous_breakpoint", TTR("Goto Previous Breakpoint"), KEY_MASK_CTRL | KEY_COMMA);
- ED_SHORTCUT("script_text_editor/find", TTR("Find.."), KEY_MASK_CMD|KEY_F);
+ ED_SHORTCUT("script_text_editor/find", TTR("Find.."), KEY_MASK_CMD | KEY_F);
ED_SHORTCUT("script_text_editor/find_next", TTR("Find Next"), KEY_F3);
- ED_SHORTCUT("script_text_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT|KEY_F3);
- ED_SHORTCUT("script_text_editor/replace", TTR("Replace.."), KEY_MASK_CMD|KEY_R);
+ ED_SHORTCUT("script_text_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT | KEY_F3);
+ ED_SHORTCUT("script_text_editor/replace", TTR("Replace.."), KEY_MASK_CMD | KEY_R);
- ED_SHORTCUT("script_text_editor/goto_function", TTR("Goto Function.."), KEY_MASK_SHIFT|KEY_MASK_CMD|KEY_F);
- ED_SHORTCUT("script_text_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD|KEY_L);
+ ED_SHORTCUT("script_text_editor/goto_function", TTR("Goto Function.."), KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_F);
+ ED_SHORTCUT("script_text_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD | KEY_L);
- ED_SHORTCUT("script_text_editor/contextual_help", TTR("Contextual Help"), KEY_MASK_SHIFT|KEY_F1);
+ ED_SHORTCUT("script_text_editor/contextual_help", TTR("Contextual Help"), KEY_MASK_SHIFT | KEY_F1);
ScriptEditor::register_create_script_editor_function(create_editor);
}
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index e30a78340e..c5f65fb1db 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -29,26 +29,24 @@
#ifndef SCRIPT_TEXT_EDITOR_H
#define SCRIPT_TEXT_EDITOR_H
-#include "script_editor_plugin.h"
#include "scene/gui/color_picker.h"
-
+#include "script_editor_plugin.h"
class ScriptTextEditor : public ScriptEditorBase {
- GDCLASS( ScriptTextEditor, ScriptEditorBase );
+ GDCLASS(ScriptTextEditor, ScriptEditorBase);
CodeTextEditor *code_editor;
Ref<Script> script;
-
Vector<String> functions;
HBoxContainer *edit_hb;
MenuButton *edit_menu;
MenuButton *search_menu;
- PopupMenu *context_menu;
+ PopupMenu *context_menu;
GotoLineDialog *goto_line_dialog;
ScriptEditorQuickOpen *quick_open;
@@ -88,16 +86,13 @@ class ScriptTextEditor : public ScriptEditorBase {
HELP_CONTEXTUAL,
};
-
protected:
-
-
- static void _code_complete_scripts(void* p_ud,const String& p_code, List<String>* r_options);
+ static void _code_complete_scripts(void *p_ud, const String &p_code, List<String> *r_options);
void _breakpoint_toggled(int p_row);
//no longer virtual
void _validate_script();
- void _code_complete_script(const String& p_code, List<String>* r_options);
+ void _code_complete_script(const String &p_code, List<String> *r_options);
void _load_theme_settings();
void _notification(int p_what);
@@ -105,43 +100,42 @@ protected:
void _edit_option(int p_op);
void _make_context_menu(bool p_selection, bool p_color);
- void _text_edit_gui_input(const InputEvent& ev);
- void _color_changed(const Color& p_color);
+ void _text_edit_gui_input(const InputEvent &ev);
+ void _color_changed(const Color &p_color);
void _goto_line(int p_line) { goto_line(p_line); }
- void _lookup_symbol(const String& p_symbol,int p_row, int p_column);
+ void _lookup_symbol(const String &p_symbol, int p_row, int p_column);
- Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
- bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
- void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
public:
-
virtual void apply_code();
virtual Ref<Script> get_edited_script() const;
- virtual Vector<String> get_functions() ;
- virtual void set_edited_script(const Ref<Script>& p_script);
+ virtual Vector<String> get_functions();
+ virtual void set_edited_script(const Ref<Script> &p_script);
virtual void reload_text();
- virtual String get_name() ;
- virtual Ref<Texture> get_icon() ;
+ virtual String get_name();
+ virtual Ref<Texture> get_icon();
virtual bool is_unsaved();
virtual Variant get_edit_state();
- virtual void set_edit_state(const Variant& p_state);
+ virtual void set_edit_state(const Variant &p_state);
virtual void ensure_focus();
virtual void trim_trailing_whitespace();
virtual void tag_saved_version();
- virtual void goto_line(int p_line,bool p_with_error=false);
+ virtual void goto_line(int p_line, bool p_with_error = false);
virtual void reload(bool p_soft);
virtual void get_breakpoints(List<int> *p_breakpoints);
- virtual void add_callback(const String& p_function,PoolStringArray p_args);
+ virtual void add_callback(const String &p_function, PoolStringArray p_args);
virtual void update_settings();
- virtual bool goto_method(const String& p_method);
+ virtual bool goto_method(const String &p_method);
- virtual void set_tooltip_request_func(String p_method,Object* p_obj);
+ virtual void set_tooltip_request_func(String p_method, Object *p_obj);
virtual void set_debugger_active(bool p_active);
@@ -150,10 +144,6 @@ public:
static void register_editor();
ScriptTextEditor();
-
};
-
-
-
#endif // SCRIPT_TEXT_EDITOR_H
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index c14d1650fd..c295a6679e 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -28,113 +28,99 @@
/*************************************************************************/
#include "shader_editor_plugin.h"
+#include "editor/editor_node.h"
#include "editor/editor_settings.h"
-#include "spatial_editor_plugin.h"
-#include "scene/resources/shader_graph.h"
+#include "editor/property_editor.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/keyboard.h"
-#include "editor/editor_node.h"
-#include "editor/property_editor.h"
#include "os/os.h"
+#include "scene/resources/shader_graph.h"
#include "servers/visual/shader_types.h"
+#include "spatial_editor_plugin.h"
/*** SETTINGS EDITOR ****/
-
-
-
/*** SCRIPT EDITOR ****/
-
Ref<Shader> ShaderTextEditor::get_edited_shader() const {
return shader;
}
-void ShaderTextEditor::set_edited_shader(const Ref<Shader>& p_shader) {
-
- shader=p_shader;
+void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) {
+ shader = p_shader;
_load_theme_settings();
get_text_edit()->set_text(p_shader->get_code());
_line_col_changed();
-
-
}
-
void ShaderTextEditor::_load_theme_settings() {
get_text_edit()->clear_colors();
/* keyword color */
- get_text_edit()->add_color_override("background_color", EDITOR_DEF("text_editor/highlighting/background_color",Color(0,0,0,0)));
- get_text_edit()->add_color_override("completion_background_color", EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0,0,0,0)));
+ get_text_edit()->add_color_override("background_color", EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0)));
+ get_text_edit()->add_color_override("completion_background_color", EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0)));
get_text_edit()->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244")));
get_text_edit()->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf")));
get_text_edit()->add_color_override("completion_scroll_color", EDITOR_DEF("text_editor/highlighting/completion_scroll_color", Color::html("ffffff")));
get_text_edit()->add_color_override("completion_font_color", EDITOR_DEF("text_editor/highlighting/completion_font_color", Color::html("aaaaaa")));
- get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/highlighting/text_color",Color(0,0,0)));
- get_text_edit()->add_color_override("line_number_color",EDITOR_DEF("text_editor/highlighting/line_number_color",Color(0,0,0)));
- get_text_edit()->add_color_override("caret_color",EDITOR_DEF("text_editor/highlighting/caret_color",Color(0,0,0)));
- get_text_edit()->add_color_override("caret_background_color",EDITOR_DEF("text_editor/highlighting/caret_background_color",Color(0,0,0)));
- get_text_edit()->add_color_override("font_selected_color",EDITOR_DEF("text_editor/highlighting/text_selected_color",Color(1,1,1)));
- get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/highlighting/selection_color",Color(0.2,0.2,1)));
- get_text_edit()->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/highlighting/brace_mismatch_color",Color(1,0.2,0.2)));
- get_text_edit()->add_color_override("current_line_color",EDITOR_DEF("text_editor/highlighting/current_line_color",Color(0.3,0.5,0.8,0.15)));
- get_text_edit()->add_color_override("word_highlighted_color",EDITOR_DEF("text_editor/highlighting/word_highlighted_color",Color(0.8,0.9,0.9,0.15)));
- get_text_edit()->add_color_override("number_color",EDITOR_DEF("text_editor/highlighting/number_color",Color(0.9,0.6,0.0,2)));
- get_text_edit()->add_color_override("function_color",EDITOR_DEF("text_editor/highlighting/function_color",Color(0.4,0.6,0.8)));
- get_text_edit()->add_color_override("member_variable_color",EDITOR_DEF("text_editor/highlighting/member_variable_color",Color(0.9,0.3,0.3)));
- get_text_edit()->add_color_override("mark_color", EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0,0.4,0.4,0.4)));
- get_text_edit()->add_color_override("breakpoint_color", EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8,0.8,0.4,0.2)));
- get_text_edit()->add_color_override("search_result_color",EDITOR_DEF("text_editor/highlighting/search_result_color",Color(0.05,0.25,0.05,1)));
- get_text_edit()->add_color_override("search_result_border_color",EDITOR_DEF("text_editor/highlighting/search_result_border_color",Color(0.1,0.45,0.1,1)));
- get_text_edit()->add_color_override("symbol_color",EDITOR_DEF("text_editor/highlighting/symbol_color",Color::hex(0x005291ff)));
-
- Color keyword_color= EDITOR_DEF("text_editor/highlighting/keyword_color",Color(0.5,0.0,0.2));
-
+ get_text_edit()->add_color_override("font_color", EDITOR_DEF("text_editor/highlighting/text_color", Color(0, 0, 0)));
+ get_text_edit()->add_color_override("line_number_color", EDITOR_DEF("text_editor/highlighting/line_number_color", Color(0, 0, 0)));
+ get_text_edit()->add_color_override("caret_color", EDITOR_DEF("text_editor/highlighting/caret_color", Color(0, 0, 0)));
+ get_text_edit()->add_color_override("caret_background_color", EDITOR_DEF("text_editor/highlighting/caret_background_color", Color(0, 0, 0)));
+ get_text_edit()->add_color_override("font_selected_color", EDITOR_DEF("text_editor/highlighting/text_selected_color", Color(1, 1, 1)));
+ get_text_edit()->add_color_override("selection_color", EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1)));
+ get_text_edit()->add_color_override("brace_mismatch_color", EDITOR_DEF("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2)));
+ get_text_edit()->add_color_override("current_line_color", EDITOR_DEF("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15)));
+ get_text_edit()->add_color_override("word_highlighted_color", EDITOR_DEF("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15)));
+ get_text_edit()->add_color_override("number_color", EDITOR_DEF("text_editor/highlighting/number_color", Color(0.9, 0.6, 0.0, 2)));
+ get_text_edit()->add_color_override("function_color", EDITOR_DEF("text_editor/highlighting/function_color", Color(0.4, 0.6, 0.8)));
+ get_text_edit()->add_color_override("member_variable_color", EDITOR_DEF("text_editor/highlighting/member_variable_color", Color(0.9, 0.3, 0.3)));
+ get_text_edit()->add_color_override("mark_color", EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4)));
+ get_text_edit()->add_color_override("breakpoint_color", EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2)));
+ get_text_edit()->add_color_override("search_result_color", EDITOR_DEF("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1)));
+ get_text_edit()->add_color_override("search_result_border_color", EDITOR_DEF("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1)));
+ get_text_edit()->add_color_override("symbol_color", EDITOR_DEF("text_editor/highlighting/symbol_color", Color::hex(0x005291ff)));
+
+ Color keyword_color = EDITOR_DEF("text_editor/highlighting/keyword_color", Color(0.5, 0.0, 0.2));
List<String> keywords;
ShaderLanguage::get_keyword_list(&keywords);
if (shader.is_valid()) {
+ for (const Map<StringName, Map<StringName, ShaderLanguage::DataType> >::Element *E = ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())).front(); E; E = E->next()) {
- for(const Map< StringName, Map<StringName,ShaderLanguage::DataType> >::Element *E=ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())).front();E;E=E->next()) {
-
- for (const Map<StringName,ShaderLanguage::DataType>::Element *F=E->get().front();F;F=F->next()) {
+ for (const Map<StringName, ShaderLanguage::DataType>::Element *F = E->get().front(); F; F = F->next()) {
keywords.push_back(F->key());
}
-
}
- for(const Set<String>::Element *E =ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())).front();E;E=E->next()) {
+ for (const Set<String>::Element *E = ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())).front(); E; E = E->next()) {
keywords.push_back(E->get());
-
}
}
+ for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
- for(List<String>::Element *E=keywords.front();E;E=E->next()) {
-
- get_text_edit()->add_keyword_color(E->get(),keyword_color);
+ get_text_edit()->add_keyword_color(E->get(), keyword_color);
}
//colorize core types
//Color basetype_color= EDITOR_DEF("text_editor/base_type_color",Color(0.3,0.3,0.0));
-
//colorize comments
- Color comment_color = EDITOR_DEF("text_editor/highlighting/comment_color",Color::hex(0x797e7eff));
+ Color comment_color = EDITOR_DEF("text_editor/highlighting/comment_color", Color::hex(0x797e7eff));
- get_text_edit()->add_color_region("/*","*/",comment_color,false);
- get_text_edit()->add_color_region("//","",comment_color,false);
+ get_text_edit()->add_color_region("/*", "*/", comment_color, false);
+ get_text_edit()->add_color_region("//", "", comment_color, false);
/*//colorize strings
Color string_color = EDITOR_DEF("text_editor/string_color",Color::hex(0x6b6f00ff));
@@ -151,38 +137,38 @@ void ShaderTextEditor::_load_theme_settings() {
}*/
}
-void ShaderTextEditor::_code_complete_script(const String& p_code, List<String>* r_options) {
+void ShaderTextEditor::_code_complete_script(const String &p_code, List<String> *r_options) {
print_line("code complete");
ShaderLanguage sl;
String calltip;
- Error err = sl.complete(p_code,ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())),ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())),r_options,calltip);
+ Error err = sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), r_options, calltip);
- if (calltip!="") {
+ if (calltip != "") {
get_text_edit()->set_code_hint(calltip);
}
}
void ShaderTextEditor::_validate_script() {
- String code=get_text_edit()->get_text();
+ String code = get_text_edit()->get_text();
//List<StringName> params;
//shader->get_param_list(&params);
ShaderLanguage sl;
- Error err = sl.compile(code,ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())),ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())));
+ Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())));
- if (err!=OK) {
- String error_text="error("+itos(sl.get_error_line())+"): "+sl.get_error_text();
+ if (err != OK) {
+ String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text();
set_error(error_text);
- get_text_edit()->set_line_as_marked(sl.get_error_line(),true);
+ get_text_edit()->set_line_as_marked(sl.get_error_line(), true);
} else {
- for(int i=0;i<get_text_edit()->get_line_count();i++)
- get_text_edit()->set_line_as_marked(i,false);
+ for (int i = 0; i < get_text_edit()->get_line_count(); i++)
+ get_text_edit()->set_line_as_marked(i, false);
set_error("");
}
@@ -191,29 +177,21 @@ void ShaderTextEditor::_validate_script() {
void ShaderTextEditor::_bind_methods() {
-
//ADD_SIGNAL( MethodInfo("script_changed") );
-
}
ShaderTextEditor::ShaderTextEditor() {
-
-
}
/*** SCRIPT EDITOR ******/
-
-
void ShaderEditor::_menu_option(int p_option) {
-
ShaderTextEditor *current = shader_editor;
- switch(p_option) {
+ switch (p_option) {
case EDIT_UNDO: {
-
current->get_text_edit()->undo();
} break;
case EDIT_REDO: {
@@ -260,29 +238,21 @@ void ShaderEditor::_menu_option(int p_option) {
goto_line_dialog->popup_find_line(current->get_text_edit());
} break;
-
}
}
-
void ShaderEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
-
-
+ if (p_what == NOTIFICATION_ENTER_TREE) {
}
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
- Ref<StyleBox> style = get_stylebox("panel","Panel");
- style->draw( ci, Rect2( Point2(), get_size() ) );
-
+ Ref<StyleBox> style = get_stylebox("panel", "Panel");
+ style->draw(ci, Rect2(Point2(), get_size()));
}
-
}
-
-
Dictionary ShaderEditor::get_state() const {
#if 0
apply_shaders();
@@ -326,7 +296,7 @@ Dictionary ShaderEditor::get_state() const {
#endif
return Dictionary();
}
-void ShaderEditor::set_state(const Dictionary& p_state) {
+void ShaderEditor::set_state(const Dictionary &p_state) {
#if 0
print_line("setting state..");
if (!p_state.has("sources"))
@@ -365,43 +335,41 @@ void ShaderEditor::set_state(const Dictionary& p_state) {
#endif
}
void ShaderEditor::clear() {
-
}
void ShaderEditor::_params_changed() {
-
shader_editor->_validate_script();
}
void ShaderEditor::_editor_settings_changed() {
- shader_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete"));
- shader_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
- shader_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/indent/tab_size"));
- shader_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs"));
- shader_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_numbers"));
- shader_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting"));
- shader_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
- shader_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
- shader_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
- shader_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/theme/line_spacing"));
- shader_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
+ shader_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete"));
+ shader_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
+ shader_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/indent/tab_size"));
+ shader_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs"));
+ shader_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_numbers"));
+ shader_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting"));
+ shader_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
+ shader_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
+ shader_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
+ shader_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/theme/line_spacing"));
+ shader_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
}
void ShaderEditor::_bind_methods() {
- ClassDB::bind_method("_editor_settings_changed",&ShaderEditor::_editor_settings_changed);
+ ClassDB::bind_method("_editor_settings_changed", &ShaderEditor::_editor_settings_changed);
- ClassDB::bind_method("_menu_option",&ShaderEditor::_menu_option);
- ClassDB::bind_method("_params_changed",&ShaderEditor::_params_changed);
- ClassDB::bind_method("apply_shaders",&ShaderEditor::apply_shaders);
+ ClassDB::bind_method("_menu_option", &ShaderEditor::_menu_option);
+ ClassDB::bind_method("_params_changed", &ShaderEditor::_params_changed);
+ ClassDB::bind_method("apply_shaders", &ShaderEditor::apply_shaders);
//ClassDB::bind_method("_close_current_tab",&ShaderEditor::_close_current_tab);
}
void ShaderEditor::ensure_select_current() {
-/*
+ /*
if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) {
ShaderTextEditor *ste = tab_container->get_child(tab_container->get_current_tab())->cast_to<ShaderTextEditor>();
@@ -412,20 +380,17 @@ void ShaderEditor::ensure_select_current() {
}*/
}
-void ShaderEditor::edit(const Ref<Shader>& p_shader) {
+void ShaderEditor::edit(const Ref<Shader> &p_shader) {
if (p_shader.is_null())
return;
-
- shader=p_shader;
+ shader = p_shader;
shader_editor->set_edited_shader(p_shader);
//vertex_editor->set_edited_shader(shader,ShaderLanguage::SHADER_MATERIAL_VERTEX);
// see if already has it
-
-
}
void ShaderEditor::save_external_data() {
@@ -434,14 +399,13 @@ void ShaderEditor::save_external_data() {
return;
apply_shaders();
- if (shader->get_path()!="" && shader->get_path().find("local://")==-1 &&shader->get_path().find("::")==-1) {
+ if (shader->get_path() != "" && shader->get_path().find("local://") == -1 && shader->get_path().find("::") == -1) {
//external shader, save it
- ResourceSaver::save(shader->get_path(),shader);
+ ResourceSaver::save(shader->get_path(), shader);
}
}
-void ShaderEditor::apply_shaders() {
-
+void ShaderEditor::apply_shaders() {
if (shader.is_valid()) {
shader->set_code(shader_editor->get_text_edit()->get_text());
@@ -449,75 +413,68 @@ void ShaderEditor::apply_shaders() {
}
}
-
ShaderEditor::ShaderEditor() {
-
- HBoxContainer *hbc = memnew( HBoxContainer);
+ HBoxContainer *hbc = memnew(HBoxContainer);
add_child(hbc);
- edit_menu = memnew( MenuButton );
+ edit_menu = memnew(MenuButton);
hbc->add_child(edit_menu);
- edit_menu->set_pos(Point2(5,-1));
+ edit_menu->set_pos(Point2(5, -1));
edit_menu->set_text(TTR("Edit"));
- edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/undo", TTR("Undo"), KEY_MASK_CMD|KEY_Z), EDIT_UNDO);
- edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/redo", TTR("Redo"), KEY_MASK_CMD|KEY_Y), EDIT_REDO);
+ edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/undo", TTR("Undo"), KEY_MASK_CMD | KEY_Z), EDIT_UNDO);
+ edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/redo", TTR("Redo"), KEY_MASK_CMD | KEY_Y), EDIT_REDO);
edit_menu->get_popup()->add_separator();
- edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/cut", TTR("Cut"), KEY_MASK_CMD|KEY_X), EDIT_CUT);
- edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/copy", TTR("Copy"), KEY_MASK_CMD|KEY_C), EDIT_COPY);
- edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/paste", TTR("Paste"), KEY_MASK_CMD|KEY_V), EDIT_PASTE);
+ edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/cut", TTR("Cut"), KEY_MASK_CMD | KEY_X), EDIT_CUT);
+ edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/copy", TTR("Copy"), KEY_MASK_CMD | KEY_C), EDIT_COPY);
+ edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/paste", TTR("Paste"), KEY_MASK_CMD | KEY_V), EDIT_PASTE);
edit_menu->get_popup()->add_separator();
- edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/select_all", TTR("Select All"), KEY_MASK_CMD|KEY_A), EDIT_SELECT_ALL);
- edit_menu->get_popup()->connect("id_pressed", this,"_menu_option");
+ edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/select_all", TTR("Select All"), KEY_MASK_CMD | KEY_A), EDIT_SELECT_ALL);
+ edit_menu->get_popup()->connect("id_pressed", this, "_menu_option");
-
- search_menu = memnew( MenuButton );
+ search_menu = memnew(MenuButton);
hbc->add_child(search_menu);
- search_menu->set_pos(Point2(38,-1));
+ search_menu->set_pos(Point2(38, -1));
search_menu->set_text(TTR("Search"));
- search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find.."), KEY_MASK_CMD|KEY_F), SEARCH_FIND);
+ search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find.."), KEY_MASK_CMD | KEY_F), SEARCH_FIND);
search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_next", TTR("Find Next"), KEY_F3), SEARCH_FIND_NEXT);
- search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT|KEY_F3), SEARCH_FIND_PREV);
- search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/replace", TTR("Replace.."), KEY_MASK_CMD|KEY_R), SEARCH_REPLACE);
+ search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT | KEY_F3), SEARCH_FIND_PREV);
+ search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/replace", TTR("Replace.."), KEY_MASK_CMD | KEY_R), SEARCH_REPLACE);
search_menu->get_popup()->add_separator();
//search_menu->get_popup()->add_item("Locate Symbol..",SEARCH_LOCATE_SYMBOL,KEY_MASK_CMD|KEY_K);
- search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD|KEY_L), SEARCH_GOTO_LINE);
- search_menu->get_popup()->connect("id_pressed", this,"_menu_option");
-
+ search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD | KEY_L), SEARCH_GOTO_LINE);
+ search_menu->get_popup()->connect("id_pressed", this, "_menu_option");
goto_line_dialog = memnew(GotoLineDialog);
add_child(goto_line_dialog);
- shader_editor = memnew( ShaderTextEditor );
+ shader_editor = memnew(ShaderTextEditor);
add_child(shader_editor);
shader_editor->set_v_size_flags(SIZE_EXPAND_FILL);
-
- shader_editor->connect("script_changed", this,"apply_shaders");
- EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");
+ shader_editor->connect("script_changed", this, "apply_shaders");
+ EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
_editor_settings_changed();
}
-
void ShaderEditorPlugin::edit(Object *p_object) {
- Shader* s = p_object->cast_to<Shader>();
+ Shader *s = p_object->cast_to<Shader>();
shader_editor->edit(s);
-
}
bool ShaderEditorPlugin::handles(Object *p_object) const {
bool handles = true;
- Shader *shader=p_object->cast_to<Shader>();
+ Shader *shader = p_object->cast_to<Shader>();
/*
if (!shader || shader->cast_to<ShaderGraph>()) // Dont handle ShaderGraph's
handles = false;
*/
- return shader!=NULL;
+ return shader != NULL;
}
void ShaderEditorPlugin::make_visible(bool p_visible) {
@@ -532,9 +489,7 @@ void ShaderEditorPlugin::make_visible(bool p_visible) {
if (shader_editor->is_visible_in_tree())
editor->hide_bottom_panel();
shader_editor->apply_shaders();
-
}
-
}
void ShaderEditorPlugin::selected_notify() {
@@ -547,7 +502,7 @@ Dictionary ShaderEditorPlugin::get_state() const {
return shader_editor->get_state();
}
-void ShaderEditorPlugin::set_state(const Dictionary& p_state) {
+void ShaderEditorPlugin::set_state(const Dictionary &p_state) {
shader_editor->set_state(p_state);
}
@@ -568,17 +523,12 @@ void ShaderEditorPlugin::apply_changes() {
ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node) {
+ editor = p_node;
+ shader_editor = memnew(ShaderEditor);
- editor=p_node;
- shader_editor = memnew( ShaderEditor );
-
- shader_editor->set_custom_minimum_size(Size2(0,300));
- button=editor->add_bottom_panel_item("Shader",shader_editor);
-
+ shader_editor->set_custom_minimum_size(Size2(0, 300));
+ button = editor->add_bottom_panel_item("Shader", shader_editor);
}
-
ShaderEditorPlugin::~ShaderEditorPlugin() {
}
-
-
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index 703913e431..4a56c14ecb 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -31,41 +31,36 @@
#include "editor/code_editor.h"
#include "editor/editor_plugin.h"
+#include "scene/gui/menu_button.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/text_edit.h"
-#include "scene/gui/menu_button.h"
#include "scene/main/timer.h"
#include "scene/resources/shader.h"
#include "servers/visual/shader_language.h"
class ShaderTextEditor : public CodeTextEditor {
- GDCLASS( ShaderTextEditor, CodeTextEditor );
+ GDCLASS(ShaderTextEditor, CodeTextEditor);
Ref<Shader> shader;
protected:
-
static void _bind_methods();
virtual void _load_theme_settings();
- virtual void _code_complete_script(const String& p_code, List<String>* r_options);
+ virtual void _code_complete_script(const String &p_code, List<String> *r_options);
public:
-
virtual void _validate_script();
-
Ref<Shader> get_edited_shader() const;
- void set_edited_shader(const Ref<Shader>& p_shader);
+ void set_edited_shader(const Ref<Shader> &p_shader);
ShaderTextEditor();
-
};
-
class ShaderEditor : public VBoxContainer {
- GDCLASS(ShaderEditor, VBoxContainer );
+ GDCLASS(ShaderEditor, VBoxContainer);
enum {
@@ -92,32 +87,29 @@ class ShaderEditor : public VBoxContainer {
GotoLineDialog *goto_line_dialog;
ConfirmationDialog *erase_tab_confirm;
-
ShaderTextEditor *shader_editor;
-
void _menu_option(int p_optin);
void _params_changed();
mutable Ref<Shader> shader;
-
void _editor_settings_changed();
protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void apply_shaders();
void ensure_select_current();
- void edit(const Ref<Shader>& p_shader);
+ void edit(const Ref<Shader> &p_shader);
Dictionary get_state() const;
- void set_state(const Dictionary& p_state);
+ void set_state(const Dictionary &p_state);
void clear();
- virtual Size2 get_minimum_size() const { return Size2(0,200); }
+ virtual Size2 get_minimum_size() const { return Size2(0, 200); }
void save_external_data();
ShaderEditor();
@@ -125,7 +117,7 @@ public:
class ShaderEditorPlugin : public EditorPlugin {
- GDCLASS( ShaderEditorPlugin, EditorPlugin );
+ GDCLASS(ShaderEditorPlugin, EditorPlugin);
bool _2d;
ShaderEditor *shader_editor;
@@ -133,7 +125,6 @@ class ShaderEditorPlugin : public EditorPlugin {
Button *button;
public:
-
virtual String get_name() const { return "Shader"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -142,7 +133,7 @@ public:
virtual void selected_notify();
Dictionary get_state() const;
- virtual void set_state(const Dictionary& p_state);
+ virtual void set_state(const Dictionary &p_state);
virtual void clear();
virtual void save_external_data();
@@ -150,7 +141,6 @@ public:
ShaderEditorPlugin(EditorNode *p_node);
~ShaderEditorPlugin();
-
};
#endif
diff --git a/editor/plugins/shader_graph_editor_plugin.cpp b/editor/plugins/shader_graph_editor_plugin.cpp
index dac63b4a9f..d55c133dc9 100644
--- a/editor/plugins/shader_graph_editor_plugin.cpp
+++ b/editor/plugins/shader_graph_editor_plugin.cpp
@@ -30,12 +30,12 @@
#if 0
+#include "canvas_item_editor_plugin.h"
+#include "os/keyboard.h"
#include "scene/gui/check_box.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/panel.h"
#include "spatial_editor_plugin.h"
-#include "os/keyboard.h"
-#include "canvas_item_editor_plugin.h"
void GraphColorRampEdit::_gui_input(const InputEvent& p_event) {
@@ -2943,6 +2943,4 @@ ShaderGraphEditorPlugin::~ShaderGraphEditorPlugin()
{
}
-
-
#endif
diff --git a/editor/plugins/shader_graph_editor_plugin.h b/editor/plugins/shader_graph_editor_plugin.h
index 5143722242..e5c59f82f4 100644
--- a/editor/plugins/shader_graph_editor_plugin.h
+++ b/editor/plugins/shader_graph_editor_plugin.h
@@ -29,15 +29,14 @@
#ifndef SHADER_GRAPH_EDITOR_PLUGIN_H
#define SHADER_GRAPH_EDITOR_PLUGIN_H
-
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
-#include "scene/resources/shader.h"
-#include "scene/gui/tree.h"
+#include "editor/editor_plugin.h"
+#include "editor/property_editor.h"
#include "scene/gui/button.h"
#include "scene/gui/graph_edit.h"
#include "scene/gui/popup.h"
-#include "editor/property_editor.h"
+#include "scene/gui/tree.h"
+#include "scene/resources/shader.h"
#include "scene/resources/shader_graph.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 8a7969c71b..fcfb20bd7d 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -28,35 +28,32 @@
/*************************************************************************/
#include "spatial_editor_plugin.h"
-#include "print_string.h"
-#include "os/keyboard.h"
-#include "scene/3d/visual_instance.h"
-#include "scene/3d/camera.h"
#include "camera_matrix.h"
-#include "sort.h"
+#include "editor/animation_editor.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
-#include "scene/resources/surface_tool.h"
+#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/spatial_editor_gizmos.h"
#include "global_config.h"
-#include "editor/plugins/animation_player_editor_plugin.h"
-#include "editor/animation_editor.h"
+#include "os/keyboard.h"
+#include "print_string.h"
+#include "scene/3d/camera.h"
+#include "scene/3d/visual_instance.h"
+#include "scene/resources/surface_tool.h"
+#include "sort.h"
#define DISTANCE_DEFAULT 4
-
#define GIZMO_ARROW_SIZE 0.3
#define GIZMO_RING_HALF_WIDTH 0.1
//#define GIZMO_SCALE_DEFAULT 0.28
#define GIZMO_SCALE_DEFAULT 0.15
-
void SpatialEditorViewport::_update_camera() {
if (orthogonal) {
//camera->set_orthogonal(size.width*cursor.distance,get_znear(),get_zfar());
camera->set_orthogonal(2 * cursor.distance, 0.1, 8192);
- }
- else
+ } else
camera->set_perspective(get_fov(), get_znear(), get_zfar());
Transform camera_transform;
@@ -83,7 +80,7 @@ String SpatialEditorGizmo::get_handle_name(int p_idx) const {
return "";
}
-Variant SpatialEditorGizmo::get_handle_value(int p_idx) const{
+Variant SpatialEditorGizmo::get_handle_value(int p_idx) const {
if (get_script_instance() && get_script_instance()->has_method("get_handle_value"))
return get_script_instance()->call("get_handle_value", p_idx);
@@ -91,49 +88,46 @@ Variant SpatialEditorGizmo::get_handle_value(int p_idx) const{
return Variant();
}
-void SpatialEditorGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point) {
+void SpatialEditorGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
if (get_script_instance() && get_script_instance()->has_method("set_handle"))
get_script_instance()->call("set_handle", p_idx, p_camera, p_point);
}
-void SpatialEditorGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
+void SpatialEditorGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
if (get_script_instance() && get_script_instance()->has_method("commit_handle"))
get_script_instance()->call("commit_handle", p_idx, p_restore, p_cancel);
}
-bool SpatialEditorGizmo::intersect_frustum(const Camera *p_camera,const Vector<Plane> &p_frustum) {
+bool SpatialEditorGizmo::intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum) {
return false;
}
-bool SpatialEditorGizmo::intersect_ray(const Camera *p_camera, const Point2 &p_point, Vector3& r_pos, Vector3& r_normal,int *r_gizmo_handle,bool p_sec_first) {
+bool SpatialEditorGizmo::intersect_ray(const Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle, bool p_sec_first) {
return false;
}
-SpatialEditorGizmo::SpatialEditorGizmo(){
+SpatialEditorGizmo::SpatialEditorGizmo() {
- selected=false;
+ selected = false;
}
-
-
int SpatialEditorViewport::get_selected_count() const {
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
- Map<Node*,Object*> &selection = editor_selection->get_selection();
-
- int count=0;
+ int count = 0;
- for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->key()->cast_to<Spatial>();
if (!sp)
continue;
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se)
continue;
@@ -143,36 +137,30 @@ int SpatialEditorViewport::get_selected_count() const {
return count;
}
-
-
float SpatialEditorViewport::get_znear() const {
float val = spatial_editor->get_znear();
- if (val<0.001)
- val=0.001;
+ if (val < 0.001)
+ val = 0.001;
return val;
}
-float SpatialEditorViewport::get_zfar() const{
+float SpatialEditorViewport::get_zfar() const {
float val = spatial_editor->get_zfar();
- if (val<0.001)
- val=0.001;
+ if (val < 0.001)
+ val = 0.001;
return val;
-
}
-float SpatialEditorViewport::get_fov() const{
+float SpatialEditorViewport::get_fov() const {
float val = spatial_editor->get_fov();
- if (val<0.001)
- val=0.001;
- if (val>89)
- val=89;
+ if (val < 0.001)
+ val = 0.001;
+ if (val > 89)
+ val = 89;
return val;
-
}
-
-
Transform SpatialEditorViewport::_get_camera_transform() const {
return camera->get_global_transform();
@@ -183,29 +171,24 @@ Vector3 SpatialEditorViewport::_get_camera_pos() const {
return _get_camera_transform().origin;
}
-Point2 SpatialEditorViewport::_point_to_screen(const Vector3& p_point) {
+Point2 SpatialEditorViewport::_point_to_screen(const Vector3 &p_point) {
return camera->unproject_position(p_point);
-
}
-Vector3 SpatialEditorViewport::_get_ray_pos(const Vector2& p_pos) const {
+Vector3 SpatialEditorViewport::_get_ray_pos(const Vector2 &p_pos) const {
return camera->project_ray_origin(p_pos);
}
-
Vector3 SpatialEditorViewport::_get_camera_normal() const {
return -_get_camera_transform().basis.get_axis(2);
}
-Vector3 SpatialEditorViewport::_get_ray(const Vector2& p_pos) {
-
+Vector3 SpatialEditorViewport::_get_ray(const Vector2 &p_pos) {
return camera->project_ray_normal(p_pos);
-
-
}
/*
void SpatialEditorViewport::_clear_id(Spatial *p_node) {
@@ -221,9 +204,7 @@ void SpatialEditorViewport::_clear_selected() {
editor_selection->clear();
}
-
-
-void SpatialEditorViewport::_select_clicked(bool p_append,bool p_single) {
+void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single) {
if (!clicked)
return;
@@ -232,18 +213,14 @@ void SpatialEditorViewport::_select_clicked(bool p_append,bool p_single) {
if (!obj)
return;
-
Spatial *sp = obj->cast_to<Spatial>();
if (!sp)
return;
- _select(sp, clicked_wants_append,true);
+ _select(sp, clicked_wants_append, true);
}
-
-
-void SpatialEditorViewport::_select(Spatial *p_node, bool p_append,bool p_single) {
-
+void SpatialEditorViewport::_select(Spatial *p_node, bool p_append, bool p_single) {
if (!p_append) {
@@ -261,34 +238,32 @@ void SpatialEditorViewport::_select(Spatial *p_node, bool p_append,bool p_single
editor_selection->add_node(p_node);
}
-
}
-
}
-ObjectID SpatialEditorViewport::_select_ray(const Point2& p_pos, bool p_append,bool &r_includes_current,int *r_gizmo_handle,bool p_alt_select) {
+ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle, bool p_alt_select) {
if (r_gizmo_handle)
- *r_gizmo_handle=-1;
+ *r_gizmo_handle = -1;
- Vector3 ray=_get_ray(p_pos);
- Vector3 pos=_get_ray_pos(p_pos);
+ Vector3 ray = _get_ray(p_pos);
+ Vector3 pos = _get_ray_pos(p_pos);
- Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_ray(pos,ray,get_tree()->get_root()->get_world()->get_scenario() );
+ Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario());
Set<Ref<SpatialEditorGizmo> > found_gizmos;
- ObjectID closest=0;
- Spatial *item=NULL;
- float closest_dist=1e20;
- int selected_handle=-1;
+ ObjectID closest = 0;
+ Spatial *item = NULL;
+ float closest_dist = 1e20;
+ int selected_handle = -1;
- for (int i=0;i<instances.size();i++) {
+ for (int i = 0; i < instances.size(); i++) {
- Object *obj=ObjectDB::get_instance(instances[i]);
+ Object *obj = ObjectDB::get_instance(instances[i]);
if (!obj)
continue;
- Spatial *spat=obj->cast_to<Spatial>();
+ Spatial *spat = obj->cast_to<Spatial>();
if (!spat)
continue;
@@ -305,62 +280,58 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2& p_pos, bool p_append,b
Vector3 point;
Vector3 normal;
- int handle=-1;
- bool inters = seg->intersect_ray(camera,p_pos,point,normal,NULL,p_alt_select);
+ int handle = -1;
+ bool inters = seg->intersect_ray(camera, p_pos, point, normal, NULL, p_alt_select);
if (!inters)
continue;
float dist = pos.distance_to(point);
- if (dist<0)
+ if (dist < 0)
continue;
if (dist < closest_dist) {
- closest=instances[i];
- closest_dist=dist;
- selected_handle=handle;
- item=spat;
+ closest = instances[i];
+ closest_dist = dist;
+ selected_handle = handle;
+ item = spat;
}
- // if (editor_selection->is_selected(spat))
- // r_includes_current=true;
-
+ // if (editor_selection->is_selected(spat))
+ // r_includes_current=true;
}
-
if (!item)
return 0;
- if (!editor_selection->is_selected(item) || (r_gizmo_handle && selected_handle>=0)) {
+ if (!editor_selection->is_selected(item) || (r_gizmo_handle && selected_handle >= 0)) {
if (r_gizmo_handle)
- *r_gizmo_handle=selected_handle;
-
+ *r_gizmo_handle = selected_handle;
}
return closest;
-
}
-void SpatialEditorViewport::_find_items_at_pos(const Point2& p_pos,bool &r_includes_current,Vector<_RayResult> &results,bool p_alt_select) {
+void SpatialEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select) {
- Vector3 ray=_get_ray(p_pos);
- Vector3 pos=_get_ray_pos(p_pos);
+ Vector3 ray = _get_ray(p_pos);
+ Vector3 pos = _get_ray_pos(p_pos);
- Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_ray(pos,ray,get_tree()->get_root()->get_world()->get_scenario() );
+ Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario());
Set<Ref<SpatialEditorGizmo> > found_gizmos;
- r_includes_current=false;
+ r_includes_current = false;
- for (int i=0;i<instances.size();i++) {
+ for (int i = 0; i < instances.size(); i++) {
- Object *obj=ObjectDB::get_instance(instances[i]);
+ Object *obj = ObjectDB::get_instance(instances[i]);
if (!obj)
continue;
- Spatial *spat=obj->cast_to<Spatial>();
+ Spatial *spat = obj->cast_to<Spatial>();
if (!spat)
continue;
@@ -377,112 +348,100 @@ void SpatialEditorViewport::_find_items_at_pos(const Point2& p_pos,bool &r_inclu
Vector3 point;
Vector3 normal;
- int handle=-1;
- bool inters = seg->intersect_ray(camera,p_pos,point,normal,NULL,p_alt_select);
+ int handle = -1;
+ bool inters = seg->intersect_ray(camera, p_pos, point, normal, NULL, p_alt_select);
if (!inters)
continue;
float dist = pos.distance_to(point);
- if (dist<0)
+ if (dist < 0)
continue;
-
-
if (editor_selection->is_selected(spat))
- r_includes_current=true;
+ r_includes_current = true;
_RayResult res;
- res.item=spat;
- res.depth=dist;
- res.handle=handle;
+ res.item = spat;
+ res.depth = dist;
+ res.handle = handle;
results.push_back(res);
}
-
if (results.empty())
return;
results.sort();
}
-
-Vector3 SpatialEditorViewport::_get_screen_to_space(const Vector3& p_pos) {
-
+Vector3 SpatialEditorViewport::_get_screen_to_space(const Vector3 &p_pos) {
CameraMatrix cm;
- cm.set_perspective(get_fov(),get_size().aspect(),get_znear(),get_zfar());
- float screen_w,screen_h;
- cm.get_viewport_size(screen_w,screen_h);
+ cm.set_perspective(get_fov(), get_size().aspect(), get_znear(), get_zfar());
+ float screen_w, screen_h;
+ cm.get_viewport_size(screen_w, screen_h);
Transform camera_transform;
- camera_transform.translate( cursor.pos );
- camera_transform.basis.rotate(Vector3(1,0,0),-cursor.x_rot);
- camera_transform.basis.rotate(Vector3(0,1,0),-cursor.y_rot);
- camera_transform.translate(0,0,cursor.distance);
-
- return camera_transform.xform(Vector3( ((p_pos.x/get_size().width)*2.0-1.0)*screen_w, ((1.0-(p_pos.y/get_size().height))*2.0-1.0)*screen_h,-get_znear()));
+ camera_transform.translate(cursor.pos);
+ camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot);
+ camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot);
+ camera_transform.translate(0, 0, cursor.distance);
+ return camera_transform.xform(Vector3(((p_pos.x / get_size().width) * 2.0 - 1.0) * screen_w, ((1.0 - (p_pos.y / get_size().height)) * 2.0 - 1.0) * screen_h, -get_znear()));
}
-
void SpatialEditorViewport::_select_region() {
- if (cursor.region_begin==cursor.region_end)
+ if (cursor.region_begin == cursor.region_end)
return; //nothing really
- Vector3 box[4]={
+ Vector3 box[4] = {
Vector3(
- MIN( cursor.region_begin.x, cursor.region_end.x),
- MIN( cursor.region_begin.y, cursor.region_end.y),
- 0
- ),
+ MIN(cursor.region_begin.x, cursor.region_end.x),
+ MIN(cursor.region_begin.y, cursor.region_end.y),
+ 0),
Vector3(
- MAX( cursor.region_begin.x, cursor.region_end.x),
- MIN( cursor.region_begin.y, cursor.region_end.y),
- 0
- ),
+ MAX(cursor.region_begin.x, cursor.region_end.x),
+ MIN(cursor.region_begin.y, cursor.region_end.y),
+ 0),
Vector3(
- MAX( cursor.region_begin.x, cursor.region_end.x),
- MAX( cursor.region_begin.y, cursor.region_end.y),
- 0
- ),
+ MAX(cursor.region_begin.x, cursor.region_end.x),
+ MAX(cursor.region_begin.y, cursor.region_end.y),
+ 0),
Vector3(
- MIN( cursor.region_begin.x, cursor.region_end.x),
- MAX( cursor.region_begin.y, cursor.region_end.y),
- 0
- )
+ MIN(cursor.region_begin.x, cursor.region_end.x),
+ MAX(cursor.region_begin.y, cursor.region_end.y),
+ 0)
};
Vector<Plane> frustum;
- Vector3 cam_pos=_get_camera_pos();
+ Vector3 cam_pos = _get_camera_pos();
Set<Ref<SpatialEditorGizmo> > found_gizmos;
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- Vector3 a=_get_screen_to_space(box[i]);
- Vector3 b=_get_screen_to_space(box[(i+1)%4]);
- frustum.push_back( Plane(a,b,cam_pos) );
+ Vector3 a = _get_screen_to_space(box[i]);
+ Vector3 b = _get_screen_to_space(box[(i + 1) % 4]);
+ frustum.push_back(Plane(a, b, cam_pos));
}
- Plane near( cam_pos, -_get_camera_normal() );
- near.d-=get_znear();
-
- frustum.push_back( near );
+ Plane near(cam_pos, -_get_camera_normal());
+ near.d -= get_znear();
- Plane far=-near;
- far.d+=500.0;
+ frustum.push_back(near);
- frustum.push_back( far );
+ Plane far = -near;
+ far.d += 500.0;
- Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_convex(frustum,get_tree()->get_root()->get_world()->get_scenario());
+ frustum.push_back(far);
+ Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world()->get_scenario());
- for (int i=0;i<instances.size();i++) {
+ for (int i = 0; i < instances.size(); i++) {
- Object *obj=ObjectDB::get_instance(instances[i]);
+ Object *obj = ObjectDB::get_instance(instances[i]);
if (!obj)
continue;
Spatial *sp = obj->cast_to<Spatial>();
@@ -497,46 +456,44 @@ void SpatialEditorViewport::_select_region() {
if (found_gizmos.has(seg))
continue;
- if (seg->intersect_frustum(camera,frustum))
- _select(sp,true,false);
+ if (seg->intersect_frustum(camera, frustum))
+ _select(sp, true, false);
}
-
}
void SpatialEditorViewport::_update_name() {
- String ortho = orthogonal?TTR("Orthogonal"):TTR("Perspective");
+ String ortho = orthogonal ? TTR("Orthogonal") : TTR("Perspective");
- if (name!="")
- view_menu->set_text("[ "+name+" "+ortho+" ]");
+ if (name != "")
+ view_menu->set_text("[ " + name + " " + ortho + " ]");
else
- view_menu->set_text("[ "+ortho+" ]");
+ view_menu->set_text("[ " + ortho + " ]");
}
+void SpatialEditorViewport::_compute_edit(const Point2 &p_point) {
-void SpatialEditorViewport::_compute_edit(const Point2& p_point) {
-
- _edit.click_ray=_get_ray( Vector2( p_point.x, p_point.y ) );
- _edit.click_ray_pos=_get_ray_pos( Vector2( p_point.x, p_point.y ) );
- _edit.plane=TRANSFORM_VIEW;
+ _edit.click_ray = _get_ray(Vector2(p_point.x, p_point.y));
+ _edit.click_ray_pos = _get_ray_pos(Vector2(p_point.x, p_point.y));
+ _edit.plane = TRANSFORM_VIEW;
spatial_editor->update_transform_gizmo();
- _edit.center=spatial_editor->get_gizmo_transform().origin;
+ _edit.center = spatial_editor->get_gizmo_transform().origin;
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
//Vector3 center;
//int nc=0;
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
if (!sp)
continue;
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se)
continue;
- se->original=se->sp->get_global_transform();
+ se->original = se->sp->get_global_transform();
//center+=se->original.origin;
//nc++;
}
@@ -547,9 +504,9 @@ void SpatialEditorViewport::_compute_edit(const Point2& p_point) {
*/
}
-static int _get_key_modifier(const String& p_property) {
+static int _get_key_modifier(const String &p_property) {
- switch(EditorSettings::get_singleton()->get(p_property).operator int()) {
+ switch (EditorSettings::get_singleton()->get(p_property).operator int()) {
case 0: return 0;
case 1: return KEY_SHIFT;
@@ -560,181 +517,164 @@ static int _get_key_modifier(const String& p_property) {
return 0;
}
-bool SpatialEditorViewport::_gizmo_select(const Vector2& p_screenpos,bool p_hilite_only) {
+bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hilite_only) {
if (!spatial_editor->is_gizmo_visible())
return false;
- if (get_selected_count()==0) {
+ if (get_selected_count() == 0) {
if (p_hilite_only)
spatial_editor->select_gizmo_hilight_axis(-1);
return false;
}
-
- Vector3 ray_pos=_get_ray_pos( Vector2( p_screenpos.x, p_screenpos.y ) );
- Vector3 ray=_get_ray( Vector2( p_screenpos.x, p_screenpos.y ) );
+ Vector3 ray_pos = _get_ray_pos(Vector2(p_screenpos.x, p_screenpos.y));
+ Vector3 ray = _get_ray(Vector2(p_screenpos.x, p_screenpos.y));
Transform gt = spatial_editor->get_gizmo_transform();
- float gs=gizmo_scale;
+ float gs = gizmo_scale;
- if (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_MOVE) {
+ if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE) {
- int col_axis=-1;
- float col_d=1e20;
+ int col_axis = -1;
+ float col_d = 1e20;
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
- Vector3 grabber_pos = gt.origin+gt.basis.get_axis(i)*gs;
- float grabber_radius = gs*GIZMO_ARROW_SIZE;
+ Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i) * gs;
+ float grabber_radius = gs * GIZMO_ARROW_SIZE;
Vector3 r;
- if (Geometry::segment_intersects_sphere(ray_pos,ray_pos+ray*10000.0,grabber_pos,grabber_radius,&r)) {
+ if (Geometry::segment_intersects_sphere(ray_pos, ray_pos + ray * 10000.0, grabber_pos, grabber_radius, &r)) {
float d = r.distance_to(ray_pos);
- if (d<col_d) {
- col_d=d;
- col_axis=i;
+ if (d < col_d) {
+ col_d = d;
+ col_axis = i;
}
}
}
- if (col_axis!=-1) {
-
+ if (col_axis != -1) {
if (p_hilite_only) {
spatial_editor->select_gizmo_hilight_axis(col_axis);
-
} else {
//handle rotate
- _edit.mode=TRANSFORM_TRANSLATE;
- _compute_edit(Point2(p_screenpos.x,p_screenpos.y));
- _edit.plane=TransformPlane(TRANSFORM_X_AXIS+col_axis);
+ _edit.mode = TRANSFORM_TRANSLATE;
+ _compute_edit(Point2(p_screenpos.x, p_screenpos.y));
+ _edit.plane = TransformPlane(TRANSFORM_X_AXIS + col_axis);
}
return true;
-
-
}
-
}
+ if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE) {
- if (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_ROTATE) {
+ int col_axis = -1;
+ float col_d = 1e20;
- int col_axis=-1;
- float col_d=1e20;
+ for (int i = 0; i < 3; i++) {
- for(int i=0;i<3;i++) {
-
- Plane plane(gt.origin,gt.basis.get_axis(i).normalized());
+ Plane plane(gt.origin, gt.basis.get_axis(i).normalized());
Vector3 r;
- if (!plane.intersects_ray(ray_pos,ray,&r))
+ if (!plane.intersects_ray(ray_pos, ray, &r))
continue;
float dist = r.distance_to(gt.origin);
-
-
- if (dist > gs*(1-GIZMO_RING_HALF_WIDTH) && dist < gs *(1+GIZMO_RING_HALF_WIDTH)) {
+ if (dist > gs * (1 - GIZMO_RING_HALF_WIDTH) && dist < gs * (1 + GIZMO_RING_HALF_WIDTH)) {
float d = ray_pos.distance_to(r);
- if (d<col_d) {
- col_d=d;
- col_axis=i;
+ if (d < col_d) {
+ col_d = d;
+ col_axis = i;
}
}
}
- if (col_axis!=-1) {
+ if (col_axis != -1) {
if (p_hilite_only) {
- spatial_editor->select_gizmo_hilight_axis(col_axis+3);
+ spatial_editor->select_gizmo_hilight_axis(col_axis + 3);
} else {
//handle rotate
- _edit.mode=TRANSFORM_ROTATE;
- _compute_edit(Point2(p_screenpos.x,p_screenpos.y));
- _edit.plane=TransformPlane(TRANSFORM_X_AXIS+col_axis);
+ _edit.mode = TRANSFORM_ROTATE;
+ _compute_edit(Point2(p_screenpos.x, p_screenpos.y));
+ _edit.plane = TransformPlane(TRANSFORM_X_AXIS + col_axis);
}
return true;
}
}
-
if (p_hilite_only)
spatial_editor->select_gizmo_hilight_axis(-1);
return false;
-
}
-
void SpatialEditorViewport::_smouseenter() {
- if (!surface->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
- surface->grab_focus();
+ if (!surface->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
+ surface->grab_focus();
}
void SpatialEditorViewport::_list_select(InputEventMouseButton b) {
- _find_items_at_pos(Vector2( b.x, b.y ),clicked_includes_current,selection_results,b.mod.shift);
+ _find_items_at_pos(Vector2(b.x, b.y), clicked_includes_current, selection_results, b.mod.shift);
- Node *scene=editor->get_edited_scene();
+ Node *scene = editor->get_edited_scene();
- for(int i=0;i<selection_results.size();i++) {
- Spatial *item=selection_results[i].item;
- if (item!=scene && item->get_owner()!=scene && !scene->is_editable_instance(item->get_owner())) {
+ for (int i = 0; i < selection_results.size(); i++) {
+ Spatial *item = selection_results[i].item;
+ if (item != scene && item->get_owner() != scene && !scene->is_editable_instance(item->get_owner())) {
//invalid result
selection_results.remove(i);
i--;
}
-
}
-
- clicked_wants_append=b.mod.shift;
+ clicked_wants_append = b.mod.shift;
if (selection_results.size() == 1) {
- clicked=selection_results[0].item->get_instance_ID();
+ clicked = selection_results[0].item->get_instance_ID();
selection_results.clear();
if (clicked) {
- _select_clicked(clicked_wants_append,true);
- clicked=0;
+ _select_clicked(clicked_wants_append, true);
+ clicked = 0;
}
} else if (!selection_results.empty()) {
NodePath root_path = get_tree()->get_edited_scene_root()->get_path();
- StringName root_name = root_path.get_name(root_path.get_name_count()-1);
+ StringName root_name = root_path.get_name(root_path.get_name_count() - 1);
for (int i = 0; i < selection_results.size(); i++) {
- Spatial *spat=selection_results[i].item;
+ Spatial *spat = selection_results[i].item;
Ref<Texture> icon;
if (spat->has_meta("_editor_icon"))
- icon=spat->get_meta("_editor_icon");
+ icon = spat->get_meta("_editor_icon");
else
- icon=get_icon( has_icon(spat->get_class(),"EditorIcons")?spat->get_class():String("Object"),"EditorIcons");
+ icon = get_icon(has_icon(spat->get_class(), "EditorIcons") ? spat->get_class() : String("Object"), "EditorIcons");
- String node_path="/"+root_name+"/"+root_path.rel_path_to(spat->get_path());
+ String node_path = "/" + root_name + "/" + root_path.rel_path_to(spat->get_path());
selection_menu->add_item(spat->get_name());
- selection_menu->set_item_icon(i, icon );
+ selection_menu->set_item_icon(i, icon);
selection_menu->set_item_metadata(i, node_path);
- selection_menu->set_item_tooltip(i,String(spat->get_name())+
- "\nType: "+spat->get_class()+"\nPath: "+node_path);
+ selection_menu->set_item_tooltip(i, String(spat->get_name()) +
+ "\nType: " + spat->get_class() + "\nPath: " + node_path);
}
- selection_menu->set_global_pos(Vector2( b.global_x, b.global_y ));
+ selection_menu->set_global_pos(Vector2(b.global_x, b.global_y));
selection_menu->popup();
selection_menu->call_deferred("grab_click_focus");
selection_menu->set_invalidate_click_until_motion();
-
-
-
}
}
void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
@@ -742,39 +682,37 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (previewing)
return; //do NONE
-
{
EditorNode *en = editor;
EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
if (!over_plugin_list->empty()) {
- bool discard = over_plugin_list->forward_spatial_gui_input(camera,p_event);
+ bool discard = over_plugin_list->forward_spatial_gui_input(camera, p_event);
if (discard)
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;
- switch(b.button_index) {
+ switch (b.button_index) {
case BUTTON_WHEEL_UP: {
-
- cursor.distance/=1.08;
- if (cursor.distance<0.001)
- cursor.distance=0.001;
+ cursor.distance /= 1.08;
+ if (cursor.distance < 0.001)
+ cursor.distance = 0.001;
} break;
case BUTTON_WHEEL_DOWN: {
- if (cursor.distance<0.001)
- cursor.distance=0.001;
- cursor.distance*=1.08;
+ if (cursor.distance < 0.001)
+ cursor.distance = 0.001;
+ cursor.distance *= 1.08;
} break;
case BUTTON_RIGHT: {
@@ -783,81 +721,76 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (b.pressed && _edit.gizmo.is_valid()) {
//restore
- _edit.gizmo->commit_handle(_edit.gizmo_handle,_edit.gizmo_initial_value,true);
- _edit.gizmo=Ref<SpatialEditorGizmo>();
+ _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_initial_value, true);
+ _edit.gizmo = Ref<SpatialEditorGizmo>();
}
- if (_edit.mode==TRANSFORM_NONE && b.pressed) {
-
- Plane cursor_plane(cursor.cursor_pos,_get_camera_normal());
+ if (_edit.mode == TRANSFORM_NONE && b.pressed) {
- Vector3 ray_origin = _get_ray_pos(Vector2(b.x,b.y));
- Vector3 ray_dir = _get_ray(Vector2(b.x,b.y));
+ Plane cursor_plane(cursor.cursor_pos, _get_camera_normal());
+ Vector3 ray_origin = _get_ray_pos(Vector2(b.x, b.y));
+ Vector3 ray_dir = _get_ray(Vector2(b.x, b.y));
//gizmo modify
if (b.mod.control) {
- Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_ray(ray_origin,ray_dir,get_tree()->get_root()->get_world()->get_scenario() );
-
- Plane p(ray_origin,_get_camera_normal());
+ Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(ray_origin, ray_dir, get_tree()->get_root()->get_world()->get_scenario());
- float min_d=1e10;
- bool found=false;
+ Plane p(ray_origin, _get_camera_normal());
- for (int i=0;i<instances.size();i++) {
+ float min_d = 1e10;
+ bool found = false;
+ for (int i = 0; i < instances.size(); i++) {
- Object *obj=ObjectDB::get_instance(instances[i]);
+ Object *obj = ObjectDB::get_instance(instances[i]);
if (!obj)
continue;
- VisualInstance *vi=obj->cast_to<VisualInstance>();
+ VisualInstance *vi = obj->cast_to<VisualInstance>();
if (!vi)
continue;
//optimize by checking AABB (although should pre sort by distance)
- Rect3 aabb = vi->get_global_transform().xform(vi->get_aabb());
- if (p.distance_to(aabb.get_support(-ray_dir))>min_d)
+ Rect3 aabb = vi->get_global_transform().xform(vi->get_aabb());
+ if (p.distance_to(aabb.get_support(-ray_dir)) > min_d)
continue;
PoolVector<Face3> faces = vi->get_faces(VisualInstance::FACES_SOLID);
int c = faces.size();
- if (c>0) {
+ if (c > 0) {
PoolVector<Face3>::Read r = faces.read();
- for(int j=0;j<c;j++) {
+ for (int j = 0; j < c; j++) {
Vector3 inters;
- if (r[j].intersects_ray(ray_origin,ray_dir,&inters)) {
+ if (r[j].intersects_ray(ray_origin, ray_dir, &inters)) {
float d = p.distance_to(inters);
- if (d<0)
+ if (d < 0)
continue;
- if (d<min_d) {
- min_d=d;
- found=true;
+ if (d < min_d) {
+ min_d = d;
+ found = true;
}
}
-
}
}
-
}
if (found) {
//cursor.cursor_pos=ray_origin+ray_dir*min_d;
//VisualServer::get_singleton()->instance_set_transform(cursor_instance,Transform(Matrix3(),cursor.cursor_pos));
-
}
} else {
Vector3 new_pos;
- if (cursor_plane.intersects_ray(ray_origin,ray_dir,&new_pos)) {
+ if (cursor_plane.intersects_ray(ray_origin, ray_dir, &new_pos)) {
//cursor.cursor_pos=new_pos;
//VisualServer::get_singleton()->instance_set_transform(cursor_instance,Transform(Matrix3(),cursor.cursor_pos));
@@ -871,68 +804,65 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
_list_select(b);
return;
-
}
}
- if (_edit.mode!=TRANSFORM_NONE && b.pressed) {
+ if (_edit.mode != TRANSFORM_NONE && b.pressed) {
//cancel motion
- _edit.mode=TRANSFORM_NONE;
+ _edit.mode = TRANSFORM_NONE;
//_validate_selection();
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
if (!sp)
continue;
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se)
continue;
- sp->set_global_transform( se->original );
-
+ sp->set_global_transform(se->original);
}
surface->update();
//VisualServer::get_singleton()->poly_clear(indicators);
- set_message(TTR("Transform Aborted."),3);
+ set_message(TTR("Transform Aborted."), 3);
}
} break;
case BUTTON_MIDDLE: {
- if (b.pressed && _edit.mode!=TRANSFORM_NONE) {
+ if (b.pressed && _edit.mode != TRANSFORM_NONE) {
- switch(_edit.plane ) {
+ switch (_edit.plane) {
case TRANSFORM_VIEW: {
- _edit.plane=TRANSFORM_X_AXIS;
- set_message(TTR("X-Axis Transform."),2);
- name="";
+ _edit.plane = TRANSFORM_X_AXIS;
+ set_message(TTR("X-Axis Transform."), 2);
+ name = "";
_update_name();
} break;
case TRANSFORM_X_AXIS: {
- _edit.plane=TRANSFORM_Y_AXIS;
- set_message(TTR("Y-Axis Transform."),2);
+ _edit.plane = TRANSFORM_Y_AXIS;
+ set_message(TTR("Y-Axis Transform."), 2);
} break;
case TRANSFORM_Y_AXIS: {
- _edit.plane=TRANSFORM_Z_AXIS;
- set_message(TTR("Z-Axis Transform."),2);
+ _edit.plane = TRANSFORM_Z_AXIS;
+ set_message(TTR("Z-Axis Transform."), 2);
} break;
case TRANSFORM_Z_AXIS: {
- _edit.plane=TRANSFORM_VIEW;
- set_message(TTR("View Plane Transform."),2);
+ _edit.plane = TRANSFORM_VIEW;
+ set_message(TTR("View Plane Transform."), 2);
} break;
}
-
}
} break;
case BUTTON_LEFT: {
@@ -940,108 +870,93 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (b.pressed) {
NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation_scheme").operator int();
- if ( (nav_scheme==NAVIGATION_MAYA || nav_scheme==NAVIGATION_MODO) && b.mod.alt) {
+ if ((nav_scheme == NAVIGATION_MAYA || nav_scheme == NAVIGATION_MODO) && b.mod.alt) {
break;
}
- if (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_LIST_SELECT) {
+ if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_LIST_SELECT) {
_list_select(b);
break;
}
- _edit.mouse_pos=Point2(b.x,b.y);
- _edit.snap=false;
- _edit.mode=TRANSFORM_NONE;
-
+ _edit.mouse_pos = Point2(b.x, b.y);
+ _edit.snap = false;
+ _edit.mode = TRANSFORM_NONE;
//gizmo has priority over everything
- bool can_select_gizmos=true;
+ bool can_select_gizmos = true;
{
int idx = view_menu->get_popup()->get_item_index(VIEW_GIZMOS);
- can_select_gizmos = view_menu->get_popup()->is_item_checked( idx );
+ can_select_gizmos = view_menu->get_popup()->is_item_checked(idx);
}
-
-
if (can_select_gizmos && spatial_editor->get_selected()) {
Ref<SpatialEditorGizmo> seg = spatial_editor->get_selected()->get_gizmo();
if (seg.is_valid()) {
- int handle=-1;
+ int handle = -1;
Vector3 point;
Vector3 normal;
- bool inters = seg->intersect_ray(camera,_edit.mouse_pos,point,normal,&handle,b.mod.shift);
- if (inters && handle!=-1) {
+ bool inters = seg->intersect_ray(camera, _edit.mouse_pos, point, normal, &handle, b.mod.shift);
+ if (inters && handle != -1) {
- _edit.gizmo=seg;
- _edit.gizmo_handle=handle;
+ _edit.gizmo = seg;
+ _edit.gizmo_handle = handle;
//_edit.gizmo_initial_pos=seg->get_handle_pos(gizmo_handle);
- _edit.gizmo_initial_value=seg->get_handle_value(handle);
+ _edit.gizmo_initial_value = seg->get_handle_value(handle);
break;
-
}
}
}
-
-
if (_gizmo_select(_edit.mouse_pos))
break;
- clicked=0;
- clicked_includes_current=false;
-
+ clicked = 0;
+ clicked_includes_current = false;
- if ((spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_SELECT && b.mod.control) || spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_ROTATE) {
+ if ((spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT && b.mod.control) || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE) {
/* HANDLE ROTATION */
- if (get_selected_count()==0)
+ if (get_selected_count() == 0)
break; //bye
//handle rotate
- _edit.mode=TRANSFORM_ROTATE;
- _compute_edit(Point2(b.x,b.y));
+ _edit.mode = TRANSFORM_ROTATE;
+ _compute_edit(Point2(b.x, b.y));
break;
-
}
- if (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_MOVE) {
+ if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE) {
- if (get_selected_count()==0)
+ if (get_selected_count() == 0)
break; //bye
//handle rotate
- _edit.mode=TRANSFORM_TRANSLATE;
- _compute_edit(Point2(b.x,b.y));
+ _edit.mode = TRANSFORM_TRANSLATE;
+ _compute_edit(Point2(b.x, b.y));
break;
-
-
}
+ if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE) {
- if (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_SCALE) {
-
- if (get_selected_count()==0)
+ if (get_selected_count() == 0)
break; //bye
//handle rotate
- _edit.mode=TRANSFORM_SCALE;
- _compute_edit(Point2(b.x,b.y));
+ _edit.mode = TRANSFORM_SCALE;
+ _compute_edit(Point2(b.x, b.y));
break;
-
-
}
-
-
// todo scale
- int gizmo_handle=-1;
+ int gizmo_handle = -1;
- clicked=_select_ray(Vector2( b.x, b.y ),b.mod.shift,clicked_includes_current,&gizmo_handle,b.mod.shift);
+ clicked = _select_ray(Vector2(b.x, b.y), b.mod.shift, clicked_includes_current, &gizmo_handle, b.mod.shift);
//clicking is always deferred to either move or release
- clicked_wants_append=b.mod.shift;
+ clicked_wants_append = b.mod.shift;
if (!clicked) {
@@ -1049,131 +964,118 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
_clear_selected();
//default to regionselect
- cursor.region_select=true;
- cursor.region_begin=Point2(b.x,b.y);
- cursor.region_end=Point2(b.x,b.y);
+ cursor.region_select = true;
+ cursor.region_begin = Point2(b.x, b.y);
+ cursor.region_end = Point2(b.x, b.y);
}
- if (clicked && gizmo_handle>=0) {
+ if (clicked && gizmo_handle >= 0) {
- Object *obj=ObjectDB::get_instance(clicked);
+ Object *obj = ObjectDB::get_instance(clicked);
if (obj) {
Spatial *spa = obj->cast_to<Spatial>();
if (spa) {
- Ref<SpatialEditorGizmo> seg=spa->get_gizmo();
+ Ref<SpatialEditorGizmo> seg = spa->get_gizmo();
if (seg.is_valid()) {
- _edit.gizmo=seg;
- _edit.gizmo_handle=gizmo_handle;
+ _edit.gizmo = seg;
+ _edit.gizmo_handle = gizmo_handle;
//_edit.gizmo_initial_pos=seg->get_handle_pos(gizmo_handle);
- _edit.gizmo_initial_value=seg->get_handle_value(gizmo_handle);
+ _edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle);
//print_line("GIZMO: "+itos(gizmo_handle)+" FROMPOS: "+_edit.orig_gizmo_pos);
break;
-
}
}
-
}
//_compute_edit(Point2(b.x,b.y)); //in case a motion happens..
}
-
-
surface->update();
} else {
-
if (_edit.gizmo.is_valid()) {
- _edit.gizmo->commit_handle(_edit.gizmo_handle,_edit.gizmo_initial_value,false);
- _edit.gizmo=Ref<SpatialEditorGizmo>();
+ _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_initial_value, false);
+ _edit.gizmo = Ref<SpatialEditorGizmo>();
break;
}
if (clicked) {
- _select_clicked(clicked_wants_append,true);
+ _select_clicked(clicked_wants_append, true);
//clickd processing was deferred
- clicked=0;
-
-
+ clicked = 0;
}
if (cursor.region_select) {
_select_region();
- cursor.region_select=false;
+ cursor.region_select = false;
surface->update();
}
+ if (_edit.mode != TRANSFORM_NONE) {
- if (_edit.mode!=TRANSFORM_NONE) {
-
-
- static const char* _transform_name[4]={"None","Rotate","Translate","Scale"};
+ static const char *_transform_name[4] = { "None", "Rotate", "Translate", "Scale" };
undo_redo->create_action(_transform_name[_edit.mode]);
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
if (!sp)
continue;
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se)
continue;
- undo_redo->add_do_method(sp,"set_global_transform",sp->get_global_transform());
- undo_redo->add_undo_method(sp,"set_global_transform",se->original);
+ undo_redo->add_do_method(sp, "set_global_transform", sp->get_global_transform());
+ undo_redo->add_undo_method(sp, "set_global_transform", se->original);
}
undo_redo->commit_action();
- _edit.mode=TRANSFORM_NONE;
+ _edit.mode = TRANSFORM_NONE;
//VisualServer::get_singleton()->poly_clear(indicators);
set_message("");
}
-
surface->update();
}
} break;
}
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &m=p_event.mouse_motion;
- _edit.mouse_pos=Point2(p_event.mouse_motion.x,p_event.mouse_motion.y);
+ const InputEventMouseMotion &m = p_event.mouse_motion;
+ _edit.mouse_pos = Point2(p_event.mouse_motion.x, p_event.mouse_motion.y);
if (spatial_editor->get_selected()) {
-
Ref<SpatialEditorGizmo> seg = spatial_editor->get_selected()->get_gizmo();
if (seg.is_valid()) {
- int selected_handle=-1;
+ int selected_handle = -1;
- int handle=-1;
+ int handle = -1;
Vector3 point;
Vector3 normal;
- bool inters = seg->intersect_ray(camera,_edit.mouse_pos,point,normal,&handle,false);
- if (inters && handle!=-1) {
-
- selected_handle=handle;
+ bool inters = seg->intersect_ray(camera, _edit.mouse_pos, point, normal, &handle, false);
+ if (inters && handle != -1) {
+ selected_handle = handle;
}
- if (selected_handle!=spatial_editor->get_over_gizmo_handle()) {
+ if (selected_handle != spatial_editor->get_over_gizmo_handle()) {
spatial_editor->set_over_gizmo_handle(selected_handle);
spatial_editor->get_selected()->update_gizmo();
- if (selected_handle!=-1)
+ if (selected_handle != -1)
spatial_editor->select_gizmo_hilight_axis(-1);
}
}
}
- if (spatial_editor->get_over_gizmo_handle()==-1 && !(m.button_mask&1) && !_edit.gizmo.is_valid()) {
-
- _gizmo_select(_edit.mouse_pos,true);
+ if (spatial_editor->get_over_gizmo_handle() == -1 && !(m.button_mask & 1) && !_edit.gizmo.is_valid()) {
+ _gizmo_select(_edit.mouse_pos, true);
}
NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation_scheme").operator int();
@@ -1181,12 +1083,12 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (_edit.gizmo.is_valid()) {
- _edit.gizmo->set_handle(_edit.gizmo_handle,camera,Vector2(m.x,m.y));
+ _edit.gizmo->set_handle(_edit.gizmo_handle, camera, Vector2(m.x, m.y));
Variant v = _edit.gizmo->get_handle_value(_edit.gizmo_handle);
String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle);
- set_message(n+": "+String(v));
+ set_message(n + ": " + String(v));
- } else if (m.button_mask&1) {
+ } else if (m.button_mask & 1) {
if (nav_scheme == NAVIGATION_MAYA && m.mod.alt) {
nav_mode = NAVIGATION_ORBIT;
@@ -1201,84 +1103,77 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (!clicked_includes_current) {
- _select_clicked(clicked_wants_append,true);
+ _select_clicked(clicked_wants_append, true);
//clickd processing was deferred
}
-
_compute_edit(_edit.mouse_pos);
- clicked=0;
-
- _edit.mode=TRANSFORM_TRANSLATE;
+ clicked = 0;
+ _edit.mode = TRANSFORM_TRANSLATE;
}
if (cursor.region_select && nav_mode == NAVIGATION_NONE) {
- cursor.region_end=Point2(m.x,m.y);
+ cursor.region_end = Point2(m.x, m.y);
surface->update();
return;
}
- if (_edit.mode==TRANSFORM_NONE && nav_mode == NAVIGATION_NONE)
+ if (_edit.mode == TRANSFORM_NONE && nav_mode == NAVIGATION_NONE)
break;
+ Vector3 ray_pos = _get_ray_pos(Vector2(m.x, m.y));
+ Vector3 ray = _get_ray(Vector2(m.x, m.y));
- Vector3 ray_pos=_get_ray_pos( Vector2( m.x, m.y ) );
- Vector3 ray=_get_ray( Vector2( m.x, m.y ) );
-
-
- switch(_edit.mode) {
+ switch (_edit.mode) {
case TRANSFORM_SCALE: {
-
- Plane plane=Plane(_edit.center,_get_camera_normal());
-
+ Plane plane = Plane(_edit.center, _get_camera_normal());
Vector3 intersection;
- if (!plane.intersects_ray(ray_pos,ray,&intersection))
+ if (!plane.intersects_ray(ray_pos, ray, &intersection))
break;
Vector3 click;
- if (!plane.intersects_ray(_edit.click_ray_pos,_edit.click_ray,&click))
+ if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click))
break;
float center_click_dist = click.distance_to(_edit.center);
float center_inters_dist = intersection.distance_to(_edit.center);
- if (center_click_dist==0)
+ if (center_click_dist == 0)
break;
- float scale = (center_inters_dist / center_click_dist)*100.0;
+ float scale = (center_inters_dist / center_click_dist) * 100.0;
if (_edit.snap || spatial_editor->is_snap_enabled()) {
- scale = Math::stepify(scale,spatial_editor->get_scale_snap());
+ scale = Math::stepify(scale, spatial_editor->get_scale_snap());
}
- set_message(vformat(TTR("Scaling to %s%%."),String::num(scale,1)));
- scale/=100.0;
+ set_message(vformat(TTR("Scaling to %s%%."), String::num(scale, 1)));
+ scale /= 100.0;
Transform r;
- r.basis.scale(Vector3(scale,scale,scale));
+ r.basis.scale(Vector3(scale, scale, scale));
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
if (!sp)
continue;
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se)
continue;
+ Transform original = se->original;
- Transform original=se->original;
-
- Transform base=Transform( Basis(), _edit.center);
- Transform t=base * (r * (base.inverse() * original));
+ Transform base = Transform(Basis(), _edit.center);
+ Transform t = base * (r * (base.inverse() * original));
sp->set_global_transform(t);
}
@@ -1289,44 +1184,43 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
case TRANSFORM_TRANSLATE: {
-
Vector3 motion_mask;
Plane plane;
- switch( _edit.plane ) {
+ switch (_edit.plane) {
case TRANSFORM_VIEW:
- motion_mask=Vector3(0,0,0);
- plane=Plane(_edit.center,_get_camera_normal());
- break;
+ motion_mask = Vector3(0, 0, 0);
+ plane = Plane(_edit.center, _get_camera_normal());
+ break;
case TRANSFORM_X_AXIS:
- motion_mask=spatial_editor->get_gizmo_transform().basis.get_axis(0);
- plane=Plane(_edit.center,motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
- break;
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0);
+ plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
+ break;
case TRANSFORM_Y_AXIS:
- motion_mask=spatial_editor->get_gizmo_transform().basis.get_axis(1);
- plane=Plane(_edit.center,motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
- break;
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(1);
+ plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
+ break;
case TRANSFORM_Z_AXIS:
- motion_mask=spatial_editor->get_gizmo_transform().basis.get_axis(2);
- plane=Plane(_edit.center,motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
- break;
+ motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2);
+ plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized());
+ break;
}
Vector3 intersection;
- if (!plane.intersects_ray(ray_pos,ray,&intersection))
+ if (!plane.intersects_ray(ray_pos, ray, &intersection))
break;
Vector3 click;
- if (!plane.intersects_ray(_edit.click_ray_pos,_edit.click_ray,&click))
+ if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click))
break;
//_validate_selection();
- Vector3 motion = intersection-click;
- if (motion_mask!=Vector3()) {
- motion=motion_mask.dot(motion)*motion_mask;
+ Vector3 motion = intersection - click;
+ if (motion_mask != Vector3()) {
+ motion = motion_mask.dot(motion) * motion_mask;
}
- float snap=0;
+ float snap = 0;
if (_edit.snap || spatial_editor->is_snap_enabled()) {
@@ -1336,98 +1230,92 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
//set_message("Translating: "+motion);
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
if (!sp) {
continue;
}
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se) {
continue;
}
- Transform t=se->original;
- t.origin+=motion;
+ Transform t = se->original;
+ t.origin += motion;
sp->set_global_transform(t);
}
} break;
case TRANSFORM_ROTATE: {
-
Plane plane;
- switch( _edit.plane ) {
+ switch (_edit.plane) {
case TRANSFORM_VIEW:
- plane=Plane(_edit.center,_get_camera_normal());
- break;
+ plane = Plane(_edit.center, _get_camera_normal());
+ break;
case TRANSFORM_X_AXIS:
- plane=Plane(_edit.center,spatial_editor->get_gizmo_transform().basis.get_axis(0));
- break;
+ plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(0));
+ break;
case TRANSFORM_Y_AXIS:
- plane=Plane(_edit.center,spatial_editor->get_gizmo_transform().basis.get_axis(1));
- break;
+ plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(1));
+ break;
case TRANSFORM_Z_AXIS:
- plane=Plane(_edit.center,spatial_editor->get_gizmo_transform().basis.get_axis(2));
- break;
+ plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(2));
+ break;
}
Vector3 intersection;
- if (!plane.intersects_ray(ray_pos,ray,&intersection))
+ if (!plane.intersects_ray(ray_pos, ray, &intersection))
break;
Vector3 click;
- if (!plane.intersects_ray(_edit.click_ray_pos,_edit.click_ray,&click))
+ if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click))
break;
+ Vector3 y_axis = (click - _edit.center).normalized();
+ Vector3 x_axis = plane.normal.cross(y_axis).normalized();
- Vector3 y_axis=(click-_edit.center).normalized();
- Vector3 x_axis=plane.normal.cross(y_axis).normalized();
-
- float angle=Math::atan2( x_axis.dot(intersection-_edit.center), y_axis.dot(intersection-_edit.center) );
+ float angle = Math::atan2(x_axis.dot(intersection - _edit.center), y_axis.dot(intersection - _edit.center));
if (_edit.snap || spatial_editor->is_snap_enabled()) {
float snap = spatial_editor->get_rotate_snap();
if (snap) {
- angle=Math::rad2deg(angle)+snap*0.5; //else it wont reach +180
- angle-=Math::fmod(angle,snap);
- set_message(vformat(TTR("Rotating %s degrees."),rtos(angle)));
- angle=Math::deg2rad(angle);
+ angle = Math::rad2deg(angle) + snap * 0.5; //else it wont reach +180
+ angle -= Math::fmod(angle, snap);
+ set_message(vformat(TTR("Rotating %s degrees."), rtos(angle)));
+ angle = Math::deg2rad(angle);
} else
- set_message(vformat(TTR("Rotating %s degrees."),rtos(Math::rad2deg(angle))));
+ set_message(vformat(TTR("Rotating %s degrees."), rtos(Math::rad2deg(angle))));
} else {
- set_message(vformat(TTR("Rotating %s degrees."),rtos(Math::rad2deg(angle))));
+ set_message(vformat(TTR("Rotating %s degrees."), rtos(Math::rad2deg(angle))));
}
-
-
-
Transform r;
- r.basis.rotate(plane.normal,angle);
+ r.basis.rotate(plane.normal, angle);
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
if (!sp)
continue;
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se)
continue;
+ Transform original = se->original;
- Transform original=se->original;
-
- Transform base=Transform( Basis(), _edit.center);
- Transform t=base * r * base.inverse() * original;
+ Transform base = Transform(Basis(), _edit.center);
+ Transform t = base * r * base.inverse() * original;
sp->set_global_transform(t);
}
@@ -1446,30 +1334,29 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
VisualServer::get_singleton()->poly_add_primitive(indicators,points,empty,colors,empty);
*/
} break;
- default:{}
+ default: {}
}
-
}
- } else if (m.button_mask&2) {
+ } else if (m.button_mask & 2) {
if (nav_scheme == NAVIGATION_MAYA && m.mod.alt) {
nav_mode = NAVIGATION_ZOOM;
}
- } else if (m.button_mask&4) {
+ } else if (m.button_mask & 4) {
if (nav_scheme == NAVIGATION_GODOT) {
int mod = 0;
if (m.mod.shift)
- mod=KEY_SHIFT;
+ mod = KEY_SHIFT;
if (m.mod.alt)
- mod=KEY_ALT;
+ mod = KEY_ALT;
if (m.mod.control)
- mod=KEY_CONTROL;
+ mod = KEY_CONTROL;
if (m.mod.meta)
- mod=KEY_META;
+ mod = KEY_META;
if (mod == _get_key_modifier("editors/3d/pan_modifier"))
nav_mode = NAVIGATION_PAN;
@@ -1483,19 +1370,19 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
nav_mode = NAVIGATION_PAN;
}
- } else if (EditorSettings::get_singleton()->get("editors/3d/emulate_3_button_mouse")) {
+ } else if (EditorSettings::get_singleton()->get("editors/3d/emulate_3_button_mouse")) {
// Handle trackpad (no external mouse) use case
int mod = 0;
if (m.mod.shift)
- mod=KEY_SHIFT;
+ mod = KEY_SHIFT;
if (m.mod.alt)
- mod=KEY_ALT;
+ mod = KEY_ALT;
if (m.mod.control)
- mod=KEY_CONTROL;
+ mod = KEY_CONTROL;
if (m.mod.meta)
- mod=KEY_META;
+ mod = KEY_META;
- if(mod){
+ if (mod) {
if (mod == _get_key_modifier("editors/3d/pan_modifier"))
nav_mode = NAVIGATION_PAN;
else if (mod == _get_key_modifier("editors/3d/zoom_modifier"))
@@ -1505,56 +1392,55 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
}
}
- switch(nav_mode) {
- case NAVIGATION_PAN:{
+ switch (nav_mode) {
+ case NAVIGATION_PAN: {
- real_t pan_speed = 1/150.0;
+ real_t pan_speed = 1 / 150.0;
int pan_speed_modifier = 10;
- if (nav_scheme==NAVIGATION_MAYA && m.mod.shift)
+ if (nav_scheme == NAVIGATION_MAYA && m.mod.shift)
pan_speed *= pan_speed_modifier;
Transform camera_transform;
camera_transform.translate(cursor.pos);
- camera_transform.basis.rotate(Vector3(1,0,0),-cursor.x_rot);
- camera_transform.basis.rotate(Vector3(0,1,0),-cursor.y_rot);
- Vector3 translation(-m.relative_x*pan_speed,m.relative_y*pan_speed,0);
- translation*=cursor.distance/DISTANCE_DEFAULT;
+ camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot);
+ camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot);
+ Vector3 translation(-m.relative_x * pan_speed, m.relative_y * pan_speed, 0);
+ translation *= cursor.distance / DISTANCE_DEFAULT;
camera_transform.translate(translation);
- cursor.pos=camera_transform.origin;
+ cursor.pos = camera_transform.origin;
} break;
case NAVIGATION_ZOOM: {
- real_t zoom_speed = 1/80.0;
+ real_t zoom_speed = 1 / 80.0;
int zoom_speed_modifier = 10;
- if (nav_scheme==NAVIGATION_MAYA && m.mod.shift)
+ if (nav_scheme == NAVIGATION_MAYA && m.mod.shift)
zoom_speed *= zoom_speed_modifier;
NavigationZoomStyle zoom_style = (NavigationZoomStyle)EditorSettings::get_singleton()->get("editors/3d/zoom_style").operator int();
if (zoom_style == NAVIGATION_ZOOM_HORIZONTAL) {
- if ( m.relative_x > 0)
- cursor.distance*=1-m.relative_x*zoom_speed;
+ if (m.relative_x > 0)
+ cursor.distance *= 1 - m.relative_x * zoom_speed;
else if (m.relative_x < 0)
- cursor.distance/=1+m.relative_x*zoom_speed;
- }
- else {
- if ( m.relative_y > 0)
- cursor.distance*=1+m.relative_y*zoom_speed;
+ cursor.distance /= 1 + m.relative_x * zoom_speed;
+ } else {
+ if (m.relative_y > 0)
+ cursor.distance *= 1 + m.relative_y * zoom_speed;
else if (m.relative_y < 0)
- cursor.distance/=1-m.relative_y*zoom_speed;
+ cursor.distance /= 1 - m.relative_y * zoom_speed;
}
} break;
case NAVIGATION_ORBIT: {
- cursor.x_rot+=m.relative_y/80.0;
- cursor.y_rot+=m.relative_x/80.0;
- if (cursor.x_rot>Math_PI/2.0)
- cursor.x_rot=Math_PI/2.0;
- if (cursor.x_rot<-Math_PI/2.0)
- cursor.x_rot=-Math_PI/2.0;
- name="";
+ cursor.x_rot += m.relative_y / 80.0;
+ cursor.y_rot += m.relative_x / 80.0;
+ if (cursor.x_rot > Math_PI / 2.0)
+ cursor.x_rot = Math_PI / 2.0;
+ if (cursor.x_rot < -Math_PI / 2.0)
+ cursor.x_rot = -Math_PI / 2.0;
+ name = "";
_update_name();
} break;
@@ -1568,57 +1454,57 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (ED_IS_SHORTCUT("spatial_editor/snap", p_event)) {
if (_edit.mode != TRANSFORM_NONE) {
- _edit.snap=true;
+ _edit.snap = true;
}
}
if (ED_IS_SHORTCUT("spatial_editor/bottom_view", p_event)) {
cursor.y_rot = 0;
- cursor.x_rot = -Math_PI/2.0;
- set_message(TTR("Bottom View."),2);
+ cursor.x_rot = -Math_PI / 2.0;
+ set_message(TTR("Bottom View."), 2);
name = TTR("Bottom");
_update_name();
}
if (ED_IS_SHORTCUT("spatial_editor/top_view", p_event)) {
cursor.y_rot = 0;
- cursor.x_rot = Math_PI/2.0;
- set_message(TTR("Top View."),2);
+ cursor.x_rot = Math_PI / 2.0;
+ set_message(TTR("Top View."), 2);
name = TTR("Top");
_update_name();
}
if (ED_IS_SHORTCUT("spatial_editor/rear_view", p_event)) {
cursor.x_rot = 0;
cursor.y_rot = Math_PI;
- set_message(TTR("Rear View."),2);
+ set_message(TTR("Rear View."), 2);
name = TTR("Rear");
_update_name();
}
if (ED_IS_SHORTCUT("spatial_editor/front_view", p_event)) {
cursor.x_rot = 0;
- cursor.y_rot=0;
- set_message(TTR("Front View."),2);
- name=TTR("Front");
+ cursor.y_rot = 0;
+ set_message(TTR("Front View."), 2);
+ name = TTR("Front");
_update_name();
}
if (ED_IS_SHORTCUT("spatial_editor/left_view", p_event)) {
- cursor.x_rot=0;
- cursor.y_rot = Math_PI/2.0;
- set_message(TTR("Left View."),2);
+ cursor.x_rot = 0;
+ cursor.y_rot = Math_PI / 2.0;
+ set_message(TTR("Left View."), 2);
name = TTR("Left");
_update_name();
}
if (ED_IS_SHORTCUT("spatial_editor/right_view", p_event)) {
- cursor.x_rot=0;
- cursor.y_rot = -Math_PI/2.0;
- set_message(TTR("Right View."),2);
+ cursor.x_rot = 0;
+ cursor.y_rot = -Math_PI / 2.0;
+ set_message(TTR("Right View."), 2);
name = TTR("Right");
_update_name();
}
if (ED_IS_SHORTCUT("spatial_editor/switch_perspective_orthogonal", p_event)) {
- _menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL);
+ _menu_option(orthogonal ? VIEW_PERSPECTIVE : VIEW_ORTHOGONAL);
_update_name();
}
if (ED_IS_SHORTCUT("spatial_editor/insert_anim_key", p_event)) {
- if (!get_selected_count() || _edit.mode!=TRANSFORM_NONE)
+ if (!get_selected_count() || _edit.mode != TRANSFORM_NONE)
break;
if (!AnimationPlayerEditor::singleton->get_key_editor()->has_keying()) {
@@ -1626,18 +1512,17 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
break;
}
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
if (!sp)
continue;
- emit_signal("transform_key_request",sp,"",sp->get_transform());
+ emit_signal("transform_key_request", sp, "", sp->get_transform());
}
-
set_message(TTR("Animation Key Inserted."));
}
@@ -1646,26 +1531,20 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
}
} break;
-
}
-
}
-void SpatialEditorViewport::set_message(String p_message,float p_time) {
-
- message=p_message;
- message_time=p_time;
+void SpatialEditorViewport::set_message(String p_message, float p_time) {
+ message = p_message;
+ message_time = p_time;
}
-
-
void SpatialEditorViewport::_notification(int p_what) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
-
- bool visible=is_visible_in_tree();
+ bool visible = is_visible_in_tree();
set_process(visible);
@@ -1675,14 +1554,12 @@ void SpatialEditorViewport::_notification(int p_what) {
call_deferred("update_transform_gizmo_view");
}
- if (p_what==NOTIFICATION_RESIZED) {
+ if (p_what == NOTIFICATION_RESIZED) {
call_deferred("update_transform_gizmo_view");
-
}
- if (p_what==NOTIFICATION_PROCESS) {
-
+ if (p_what == NOTIFICATION_PROCESS) {
//force editr camera
/*
@@ -1695,56 +1572,53 @@ void SpatialEditorViewport::_notification(int p_what) {
_update_camera();
- Map<Node*,Object*> &selection = editor_selection->get_selection();
+ Map<Node *, Object *> &selection = editor_selection->get_selection();
- bool changed=false;
- bool exist=false;
+ bool changed = false;
+ bool exist = false;
- for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+ for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->key()->cast_to<Spatial>();
if (!sp)
continue;
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se)
continue;
-
- VisualInstance *vi=sp->cast_to<VisualInstance>();
-
+ VisualInstance *vi = sp->cast_to<VisualInstance>();
if (se->aabb.has_no_surface()) {
- se->aabb=vi?vi->get_aabb():Rect3( Vector3(-0.2,-0.2,-0.2),Vector3(0.4,0.4,0.4));
+ se->aabb = vi ? vi->get_aabb() : Rect3(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4));
}
- Transform t=sp->get_global_transform();
+ Transform t = sp->get_global_transform();
t.translate(se->aabb.pos);
- t.basis.scale( se->aabb.size );
+ t.basis.scale(se->aabb.size);
- exist=true;
- if (se->last_xform==t)
+ exist = true;
+ if (se->last_xform == t)
continue;
- changed=true;
- se->last_xform=t;
- VisualServer::get_singleton()->instance_set_transform(se->sbox_instance,t);
-
+ changed = true;
+ se->last_xform = t;
+ VisualServer::get_singleton()->instance_set_transform(se->sbox_instance, t);
}
if (changed || (spatial_editor->is_gizmo_visible() && !exist)) {
spatial_editor->update_transform_gizmo();
}
- if (message_time>0) {
+ if (message_time > 0) {
- if (message!=last_message) {
+ if (message != last_message) {
surface->update();
- last_message=message;
+ last_message = message;
}
- message_time-=get_fixed_process_delta_time();
- if (message_time<0)
+ message_time -= get_fixed_process_delta_time();
+ if (message_time < 0)
surface->update();
}
@@ -1756,12 +1630,11 @@ void SpatialEditorViewport::_notification(int p_what) {
int atlas_q2 = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/quadrant_2_subdiv");
int atlas_q3 = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/quadrant_3_subdiv");
-
viewport->set_shadow_atlas_size(shadowmap_size);
- viewport->set_shadow_atlas_quadrant_subdiv(0,Viewport::ShadowAtlasQuadrantSubdiv(atlas_q0));
- viewport->set_shadow_atlas_quadrant_subdiv(1,Viewport::ShadowAtlasQuadrantSubdiv(atlas_q1));
- viewport->set_shadow_atlas_quadrant_subdiv(2,Viewport::ShadowAtlasQuadrantSubdiv(atlas_q2));
- viewport->set_shadow_atlas_quadrant_subdiv(3,Viewport::ShadowAtlasQuadrantSubdiv(atlas_q3));
+ viewport->set_shadow_atlas_quadrant_subdiv(0, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q0));
+ viewport->set_shadow_atlas_quadrant_subdiv(1, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q1));
+ viewport->set_shadow_atlas_quadrant_subdiv(2, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q2));
+ viewport->set_shadow_atlas_quadrant_subdiv(3, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q3));
//update msaa if changed
@@ -1770,164 +1643,145 @@ void SpatialEditorViewport::_notification(int p_what) {
bool hdr = GlobalConfig::get_singleton()->get("rendering/quality/hdr");
viewport->set_hdr(hdr);
-
-
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- surface->connect("draw",this,"_draw");
- surface->connect("gui_input",this,"_sinput");
- surface->connect("mouse_entered",this,"_smouseenter");
- preview_camera->set_icon(get_icon("Camera","EditorIcons"));
+ surface->connect("draw", this, "_draw");
+ surface->connect("gui_input", this, "_sinput");
+ surface->connect("mouse_entered", this, "_smouseenter");
+ preview_camera->set_icon(get_icon("Camera", "EditorIcons"));
_init_gizmo_instance(index);
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
-
+ if (p_what == NOTIFICATION_EXIT_TREE) {
_finish_gizmo_instances();
-
}
- if (p_what==NOTIFICATION_MOUSE_ENTER) {
-
-
+ if (p_what == NOTIFICATION_MOUSE_ENTER) {
}
-
- if (p_what==NOTIFICATION_DRAW) {
-
-
-
+ if (p_what == NOTIFICATION_DRAW) {
}
-
}
void SpatialEditorViewport::_draw() {
if (surface->has_focus()) {
Size2 size = surface->get_size();
- Rect2 r =Rect2(Point2(),size);
- get_stylebox("EditorFocus","EditorStyles")->draw(surface->get_canvas_item(),r);
+ Rect2 r = Rect2(Point2(), size);
+ get_stylebox("EditorFocus", "EditorStyles")->draw(surface->get_canvas_item(), r);
}
-
- RID ci=surface->get_canvas_item();
+ RID ci = surface->get_canvas_item();
if (cursor.region_select) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor.region_begin,cursor.region_end-cursor.region_begin),Color(0.7,0.7,1.0,0.3));
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor.region_begin, cursor.region_end - cursor.region_begin), Color(0.7, 0.7, 1.0, 0.3));
}
- if (message_time>0) {
- Ref<Font> font = get_font("font","Label");
- Point2 msgpos=Point2(5,get_size().y-20);
- font->draw(ci,msgpos+Point2(1,1),message,Color(0,0,0,0.8));
- font->draw(ci,msgpos+Point2(-1,-1),message,Color(0,0,0,0.8));
- font->draw(ci,msgpos,message,Color(1,1,1,1));
+ if (message_time > 0) {
+ Ref<Font> font = get_font("font", "Label");
+ Point2 msgpos = Point2(5, get_size().y - 20);
+ font->draw(ci, msgpos + Point2(1, 1), message, Color(0, 0, 0, 0.8));
+ font->draw(ci, msgpos + Point2(-1, -1), message, Color(0, 0, 0, 0.8));
+ font->draw(ci, msgpos, message, Color(1, 1, 1, 1));
}
-
- if (_edit.mode==TRANSFORM_ROTATE) {
+ if (_edit.mode == TRANSFORM_ROTATE) {
Point2 center = _point_to_screen(_edit.center);
- VisualServer::get_singleton()->canvas_item_add_line(ci,_edit.mouse_pos, center, Color(0.4,0.7,1.0,0.8));
-
-
+ VisualServer::get_singleton()->canvas_item_add_line(ci, _edit.mouse_pos, center, Color(0.4, 0.7, 1.0, 0.8));
}
if (previewing) {
-
- Size2 ss = Size2( GlobalConfig::get_singleton()->get("display/width"), GlobalConfig::get_singleton()->get("display/height") );
+ Size2 ss = Size2(GlobalConfig::get_singleton()->get("display/width"), GlobalConfig::get_singleton()->get("display/height"));
float aspect = ss.aspect();
Size2 s = get_size();
Rect2 draw_rect;
-
- switch(previewing->get_keep_aspect_mode()) {
+ switch (previewing->get_keep_aspect_mode()) {
case Camera::KEEP_WIDTH: {
- draw_rect.size = Size2(s.width,s.width/aspect);
- draw_rect.pos.x=0;
- draw_rect.pos.y=(s.height-draw_rect.size.y)*0.5;
+ draw_rect.size = Size2(s.width, s.width / aspect);
+ draw_rect.pos.x = 0;
+ draw_rect.pos.y = (s.height - draw_rect.size.y) * 0.5;
} break;
case Camera::KEEP_HEIGHT: {
- draw_rect.size = Size2(s.height*aspect,s.height);
- draw_rect.pos.y=0;
- draw_rect.pos.x=(s.width-draw_rect.size.x)*0.5;
+ draw_rect.size = Size2(s.height * aspect, s.height);
+ draw_rect.pos.y = 0;
+ draw_rect.pos.x = (s.width - draw_rect.size.x) * 0.5;
} break;
}
- draw_rect = Rect2(Vector2(),s).clip(draw_rect);
+ draw_rect = Rect2(Vector2(), s).clip(draw_rect);
- surface->draw_line(draw_rect.pos,draw_rect.pos+Vector2(draw_rect.size.x,0),Color(0.6,0.6,0.1,0.5),2.0);
- surface->draw_line(draw_rect.pos+Vector2(draw_rect.size.x,0),draw_rect.pos+draw_rect.size,Color(0.6,0.6,0.1,0.5),2.0);
- surface->draw_line(draw_rect.pos+draw_rect.size,draw_rect.pos+Vector2(0,draw_rect.size.y),Color(0.6,0.6,0.1,0.5),2.0);
- surface->draw_line(draw_rect.pos,draw_rect.pos+Vector2(0,draw_rect.size.y),Color(0.6,0.6,0.1,0.5),2.0);
+ surface->draw_line(draw_rect.pos, draw_rect.pos + Vector2(draw_rect.size.x, 0), Color(0.6, 0.6, 0.1, 0.5), 2.0);
+ surface->draw_line(draw_rect.pos + Vector2(draw_rect.size.x, 0), draw_rect.pos + draw_rect.size, Color(0.6, 0.6, 0.1, 0.5), 2.0);
+ surface->draw_line(draw_rect.pos + draw_rect.size, draw_rect.pos + Vector2(0, draw_rect.size.y), Color(0.6, 0.6, 0.1, 0.5), 2.0);
+ surface->draw_line(draw_rect.pos, draw_rect.pos + Vector2(0, draw_rect.size.y), Color(0.6, 0.6, 0.1, 0.5), 2.0);
}
-
}
-
void SpatialEditorViewport::_menu_option(int p_option) {
- switch(p_option) {
+ switch (p_option) {
case VIEW_TOP: {
- cursor.x_rot=Math_PI/2.0;
- cursor.y_rot=0;
- name=TTR("Top");
+ cursor.x_rot = Math_PI / 2.0;
+ cursor.y_rot = 0;
+ name = TTR("Top");
_update_name();
} break;
case VIEW_BOTTOM: {
- cursor.x_rot=-Math_PI/2.0;
- cursor.y_rot=0;
- name=TTR("Bottom");
+ cursor.x_rot = -Math_PI / 2.0;
+ cursor.y_rot = 0;
+ name = TTR("Bottom");
_update_name();
} break;
case VIEW_LEFT: {
- cursor.y_rot=Math_PI/2.0;
- cursor.x_rot=0;
- name=TTR("Left");
+ cursor.y_rot = Math_PI / 2.0;
+ cursor.x_rot = 0;
+ name = TTR("Left");
_update_name();
} break;
case VIEW_RIGHT: {
- cursor.y_rot=-Math_PI/2.0;
- cursor.x_rot=0;
- name=TTR("Right");
+ cursor.y_rot = -Math_PI / 2.0;
+ cursor.x_rot = 0;
+ name = TTR("Right");
_update_name();
} break;
case VIEW_FRONT: {
- cursor.y_rot=0;
- cursor.x_rot=0;
- name=TTR("Front");
+ cursor.y_rot = 0;
+ cursor.x_rot = 0;
+ name = TTR("Front");
_update_name();
} break;
case VIEW_REAR: {
- cursor.y_rot=Math_PI;
- cursor.x_rot=0;
- name=TTR("Rear");
+ cursor.y_rot = Math_PI;
+ cursor.x_rot = 0;
+ name = TTR("Rear");
_update_name();
} break;
case VIEW_CENTER_TO_ORIGIN: {
- cursor.pos = Vector3(0,0,0);
+ cursor.pos = Vector3(0, 0, 0);
} break;
case VIEW_CENTER_TO_SELECTION: {
@@ -1942,32 +1796,32 @@ void SpatialEditorViewport::_menu_option(int p_option) {
Transform camera_transform = camera->get_global_transform();
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
undo_redo->create_action(TTR("Align with view"));
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
if (!sp)
continue;
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se)
continue;
Transform xform = camera_transform;
xform.scale_basis(sp->get_scale());
- undo_redo->add_do_method(sp,"set_global_transform",xform);
- undo_redo->add_undo_method(sp,"set_global_transform",sp->get_global_transform());
+ undo_redo->add_do_method(sp, "set_global_transform", xform);
+ undo_redo->add_undo_method(sp, "set_global_transform", sp->get_global_transform());
}
undo_redo->commit_action();
} break;
case VIEW_ENVIRONMENT: {
int idx = view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT);
- bool current = view_menu->get_popup()->is_item_checked( idx );
- current=!current;
+ bool current = view_menu->get_popup()->is_item_checked(idx);
+ current = !current;
if (current) {
camera->set_environment(RES());
@@ -1976,24 +1830,23 @@ void SpatialEditorViewport::_menu_option(int p_option) {
camera->set_environment(SpatialEditor::get_singleton()->get_viewport_environment());
}
- view_menu->get_popup()->set_item_checked( idx, current );
-
+ view_menu->get_popup()->set_item_checked(idx, current);
} break;
case VIEW_PERSPECTIVE: {
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE), true );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), false );
- orthogonal=false;
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE), true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), false);
+ orthogonal = false;
call_deferred("update_transform_gizmo_view");
_update_name();
} break;
case VIEW_ORTHOGONAL: {
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), true );
- orthogonal=true;
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), true);
+ orthogonal = true;
call_deferred("update_transform_gizmo_view");
_update_name();
@@ -2001,30 +1854,27 @@ void SpatialEditorViewport::_menu_option(int p_option) {
case VIEW_AUDIO_LISTENER: {
int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER);
- bool current = view_menu->get_popup()->is_item_checked( idx );
- current=!current;
+ bool current = view_menu->get_popup()->is_item_checked(idx);
+ current = !current;
viewport->set_as_audio_listener(current);
- view_menu->get_popup()->set_item_checked( idx, current );
+ view_menu->get_popup()->set_item_checked(idx, current);
} break;
case VIEW_GIZMOS: {
int idx = view_menu->get_popup()->get_item_index(VIEW_GIZMOS);
- bool current = view_menu->get_popup()->is_item_checked( idx );
- current=!current;
+ bool current = view_menu->get_popup()->is_item_checked(idx);
+ current = !current;
if (current)
- camera->set_cull_mask( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+index))|(1<<GIZMO_EDIT_LAYER)|(1<<GIZMO_GRID_LAYER) );
+ camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + index)) | (1 << GIZMO_EDIT_LAYER) | (1 << GIZMO_GRID_LAYER));
else
- camera->set_cull_mask( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+index))|(1<<GIZMO_GRID_LAYER) );
- view_menu->get_popup()->set_item_checked( idx, current );
+ camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + index)) | (1 << GIZMO_GRID_LAYER));
+ view_menu->get_popup()->set_item_checked(idx, current);
} break;
-
}
-
}
-
void SpatialEditorViewport::_preview_exited_scene() {
preview_camera->set_pressed(false);
@@ -2032,52 +1882,46 @@ void SpatialEditorViewport::_preview_exited_scene() {
view_menu->show();
}
-
void SpatialEditorViewport::_init_gizmo_instance(int p_idx) {
- uint32_t layer=1<<(GIZMO_BASE_LAYER+p_idx);//|(1<<GIZMO_GRID_LAYER);
+ uint32_t layer = 1 << (GIZMO_BASE_LAYER + p_idx); //|(1<<GIZMO_GRID_LAYER);
- for(int i=0;i<3;i++) {
- move_gizmo_instance[i]=VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(move_gizmo_instance[i],spatial_editor->get_move_gizmo(i)->get_rid());
- VS::get_singleton()->instance_set_scenario(move_gizmo_instance[i],get_tree()->get_root()->get_world()->get_scenario());
- VS::get_singleton()->instance_set_visible(move_gizmo_instance[i],false);
+ for (int i = 0; i < 3; i++) {
+ move_gizmo_instance[i] = VS::get_singleton()->instance_create();
+ VS::get_singleton()->instance_set_base(move_gizmo_instance[i], spatial_editor->get_move_gizmo(i)->get_rid());
+ VS::get_singleton()->instance_set_scenario(move_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
+ VS::get_singleton()->instance_set_visible(move_gizmo_instance[i], false);
//VS::get_singleton()->instance_geometry_set_flag(move_gizmo_instance[i],VS::INSTANCE_FLAG_DEPH_SCALE,true);
VS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
- VS::get_singleton()->instance_set_layer_mask(move_gizmo_instance[i],layer);
+ VS::get_singleton()->instance_set_layer_mask(move_gizmo_instance[i], layer);
- rotate_gizmo_instance[i]=VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(rotate_gizmo_instance[i],spatial_editor->get_rotate_gizmo(i)->get_rid());
- VS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[i],get_tree()->get_root()->get_world()->get_scenario());
- VS::get_singleton()->instance_set_visible(rotate_gizmo_instance[i],false);
+ rotate_gizmo_instance[i] = VS::get_singleton()->instance_create();
+ VS::get_singleton()->instance_set_base(rotate_gizmo_instance[i], spatial_editor->get_rotate_gizmo(i)->get_rid());
+ VS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario());
+ VS::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false);
//VS::get_singleton()->instance_geometry_set_flag(rotate_gizmo_instance[i],VS::INSTANCE_FLAG_DEPH_SCALE,true);
VS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
- VS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[i],layer);
+ VS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[i], layer);
}
-
}
-
void SpatialEditorViewport::_finish_gizmo_instances() {
-
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
VS::get_singleton()->free(move_gizmo_instance[i]);
VS::get_singleton()->free(rotate_gizmo_instance[i]);
}
-
}
void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
-
ERR_FAIL_COND(p_activate && !preview);
ERR_FAIL_COND(!p_activate && !previewing);
if (!p_activate) {
- previewing->disconnect("tree_exited",this,"_preview_exited_scene");
- previewing=NULL;
- VS::get_singleton()->viewport_attach_camera( viewport->get_viewport_rid(), camera->get_camera() ); //restore
+ previewing->disconnect("tree_exited", this, "_preview_exited_scene");
+ previewing = NULL;
+ VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
if (!preview)
preview_camera->hide();
view_menu->show();
@@ -2085,12 +1929,11 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
} else {
- previewing=preview;
- previewing->connect("tree_exited",this,"_preview_exited_scene");
- VS::get_singleton()->viewport_attach_camera( viewport->get_viewport_rid(), preview->get_camera() ); //replace
+ previewing = preview;
+ previewing->connect("tree_exited", this, "_preview_exited_scene");
+ VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace
view_menu->hide();
surface->update();
-
}
}
@@ -2099,11 +1942,11 @@ void SpatialEditorViewport::_selection_result_pressed(int p_result) {
if (selection_results.size() <= p_result)
return;
- clicked=selection_results[p_result].item->get_instance_ID();
+ clicked = selection_results[p_result].item->get_instance_ID();
if (clicked) {
- _select_clicked(clicked_wants_append,true);
- clicked=0;
+ _select_clicked(clicked_wants_append, true);
+ clicked = 0;
}
}
@@ -2114,9 +1957,9 @@ void SpatialEditorViewport::_selection_menu_hide() {
selection_menu->set_size(Vector2(0, 0));
}
-void SpatialEditorViewport::set_can_preview(Camera* p_preview) {
+void SpatialEditorViewport::set_can_preview(Camera *p_preview) {
- preview=p_preview;
+ preview = p_preview;
if (!preview_camera->is_pressed()) {
@@ -2135,42 +1978,39 @@ void SpatialEditorViewport::update_transform_gizmo_view() {
Transform xform = spatial_editor->get_gizmo_transform();
-
Transform camera_xform = camera->get_transform();
Vector3 camz = -camera_xform.get_basis().get_axis(2).normalized();
Vector3 camy = -camera_xform.get_basis().get_axis(1).normalized();
- Plane p(camera_xform.origin,camz);
- float gizmo_d = Math::abs( p.distance_to(xform.origin ));
- float d0 = camera->unproject_position(camera_xform.origin+camz*gizmo_d).y;
- float d1 = camera->unproject_position(camera_xform.origin+camz*gizmo_d+camy).y;
- float dd = Math::abs(d0-d1);
- if (dd==0)
- dd=0.0001;
+ Plane p(camera_xform.origin, camz);
+ float gizmo_d = Math::abs(p.distance_to(xform.origin));
+ float d0 = camera->unproject_position(camera_xform.origin + camz * gizmo_d).y;
+ float d1 = camera->unproject_position(camera_xform.origin + camz * gizmo_d + camy).y;
+ float dd = Math::abs(d0 - d1);
+ if (dd == 0)
+ dd = 0.0001;
float gsize = EditorSettings::get_singleton()->get("editors/3d/manipulator_gizmo_size");
- gizmo_scale=(gsize/Math::abs(dd));
- Vector3 scale = Vector3(1,1,1) * gizmo_scale;
+ gizmo_scale = (gsize / Math::abs(dd));
+ Vector3 scale = Vector3(1, 1, 1) * gizmo_scale;
xform.basis.scale(scale);
//xform.basis.scale(GIZMO_SCALE_DEFAULT*Vector3(1,1,1));
-
- for(int i=0;i<3;i++) {
- VisualServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform );
- VisualServer::get_singleton()->instance_set_visible(move_gizmo_instance[i],spatial_editor->is_gizmo_visible()&& (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_MOVE) );
- VisualServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], xform );
- VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i],spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_ROTATE) );
+ for (int i = 0; i < 3; i++) {
+ VisualServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform);
+ VisualServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE));
+ VisualServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], xform);
+ VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE));
}
-
}
-void SpatialEditorViewport::set_state(const Dictionary& p_state) {
+void SpatialEditorViewport::set_state(const Dictionary &p_state) {
- cursor.pos=p_state["pos"];
- cursor.x_rot=p_state["x_rot"];
- cursor.y_rot=p_state["y_rot"];
- cursor.distance=p_state["distance"];
+ cursor.pos = p_state["pos"];
+ cursor.x_rot = p_state["x_rot"];
+ cursor.y_rot = p_state["y_rot"];
+ cursor.distance = p_state["distance"];
bool env = p_state["use_environment"];
bool orth = p_state["use_orthogonal"];
if (orth)
@@ -2184,15 +2024,15 @@ void SpatialEditorViewport::set_state(const Dictionary& p_state) {
int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER);
viewport->set_as_audio_listener(listener);
- view_menu->get_popup()->set_item_checked( idx, listener );
+ view_menu->get_popup()->set_item_checked(idx, listener);
}
if (p_state.has("previewing")) {
Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]);
if (pv && pv->cast_to<Camera>()) {
- previewing=pv->cast_to<Camera>();
- previewing->connect("tree_exited",this,"_preview_exited_scene");
- VS::get_singleton()->viewport_attach_camera( viewport->get_viewport_rid(), previewing->get_camera() ); //replace
+ previewing = pv->cast_to<Camera>();
+ previewing->connect("tree_exited", this, "_preview_exited_scene");
+ VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace
view_menu->hide();
surface->update();
preview_camera->set_pressed(true);
@@ -2204,127 +2044,121 @@ void SpatialEditorViewport::set_state(const Dictionary& p_state) {
Dictionary SpatialEditorViewport::get_state() const {
Dictionary d;
- d["pos"]=cursor.pos;
- d["x_rot"]=cursor.x_rot;
- d["y_rot"]=cursor.y_rot;
- d["distance"]=cursor.distance;
- d["use_environment"]=camera->get_environment().is_valid();
- d["use_orthogonal"]=camera->get_projection()==Camera::PROJECTION_ORTHOGONAL;
- d["listener"]=viewport->is_audio_listener();
+ d["pos"] = cursor.pos;
+ d["x_rot"] = cursor.x_rot;
+ d["y_rot"] = cursor.y_rot;
+ d["distance"] = cursor.distance;
+ d["use_environment"] = camera->get_environment().is_valid();
+ d["use_orthogonal"] = camera->get_projection() == Camera::PROJECTION_ORTHOGONAL;
+ d["listener"] = viewport->is_audio_listener();
if (previewing) {
- d["previewing"]=EditorNode::get_singleton()->get_edited_scene()->get_path_to(previewing);
+ d["previewing"] = EditorNode::get_singleton()->get_edited_scene()->get_path_to(previewing);
}
return d;
}
+void SpatialEditorViewport::_bind_methods() {
-void SpatialEditorViewport::_bind_methods(){
-
- ClassDB::bind_method(D_METHOD("_draw"),&SpatialEditorViewport::_draw);
- ClassDB::bind_method(D_METHOD("_smouseenter"),&SpatialEditorViewport::_smouseenter);
- ClassDB::bind_method(D_METHOD("_sinput"),&SpatialEditorViewport::_sinput);
- ClassDB::bind_method(D_METHOD("_menu_option"),&SpatialEditorViewport::_menu_option);
- ClassDB::bind_method(D_METHOD("_toggle_camera_preview"),&SpatialEditorViewport::_toggle_camera_preview);
- ClassDB::bind_method(D_METHOD("_preview_exited_scene"),&SpatialEditorViewport::_preview_exited_scene);
- ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"),&SpatialEditorViewport::update_transform_gizmo_view);
- ClassDB::bind_method(D_METHOD("_selection_result_pressed"),&SpatialEditorViewport::_selection_result_pressed);
- ClassDB::bind_method(D_METHOD("_selection_menu_hide"),&SpatialEditorViewport::_selection_menu_hide);
+ ClassDB::bind_method(D_METHOD("_draw"), &SpatialEditorViewport::_draw);
+ ClassDB::bind_method(D_METHOD("_smouseenter"), &SpatialEditorViewport::_smouseenter);
+ ClassDB::bind_method(D_METHOD("_sinput"), &SpatialEditorViewport::_sinput);
+ ClassDB::bind_method(D_METHOD("_menu_option"), &SpatialEditorViewport::_menu_option);
+ ClassDB::bind_method(D_METHOD("_toggle_camera_preview"), &SpatialEditorViewport::_toggle_camera_preview);
+ ClassDB::bind_method(D_METHOD("_preview_exited_scene"), &SpatialEditorViewport::_preview_exited_scene);
+ ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"), &SpatialEditorViewport::update_transform_gizmo_view);
+ ClassDB::bind_method(D_METHOD("_selection_result_pressed"), &SpatialEditorViewport::_selection_result_pressed);
+ ClassDB::bind_method(D_METHOD("_selection_menu_hide"), &SpatialEditorViewport::_selection_menu_hide);
- ADD_SIGNAL( MethodInfo("toggle_maximize_view", PropertyInfo(Variant::OBJECT, "viewport")) );
+ ADD_SIGNAL(MethodInfo("toggle_maximize_view", PropertyInfo(Variant::OBJECT, "viewport")));
}
-
void SpatialEditorViewport::reset() {
- orthogonal=false;
- message_time=0;
- message="";
- last_message="";
- name="";
+ orthogonal = false;
+ message_time = 0;
+ message = "";
+ last_message = "";
+ name = "";
- cursor.x_rot=0.5;
- cursor.y_rot=0.5;
- cursor.distance=4;
- cursor.region_select=false;
+ cursor.x_rot = 0.5;
+ cursor.y_rot = 0.5;
+ cursor.distance = 4;
+ cursor.region_select = false;
_update_name();
}
-
void SpatialEditorViewport::focus_selection() {
if (!get_selected_count())
return;
Vector3 center;
- int count=0;
+ int count = 0;
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
if (!sp)
continue;
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se)
continue;
- center+=sp->get_global_transform().origin;
+ center += sp->get_global_transform().origin;
count++;
}
- if( count != 0 ) {
- center/=float(count);
+ if (count != 0) {
+ center /= float(count);
}
- cursor.pos=center;
+ cursor.pos = center;
}
-
SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index) {
- _edit.mode=TRANSFORM_NONE;
- _edit.plane=TRANSFORM_VIEW;
- _edit.edited_gizmo=0;
- _edit.snap=1;
- _edit.gizmo_handle=0;
-
-
-
- index=p_index;
- editor=p_editor;
- editor_selection=editor->get_editor_selection();
- undo_redo=editor->get_undo_redo();
- clicked=0;
- clicked_includes_current=false;
- orthogonal=false;
- message_time=0;
-
- spatial_editor=p_spatial_editor;
- ViewportContainer *c=memnew(ViewportContainer);
+ _edit.mode = TRANSFORM_NONE;
+ _edit.plane = TRANSFORM_VIEW;
+ _edit.edited_gizmo = 0;
+ _edit.snap = 1;
+ _edit.gizmo_handle = 0;
+
+ index = p_index;
+ editor = p_editor;
+ editor_selection = editor->get_editor_selection();
+ undo_redo = editor->get_undo_redo();
+ clicked = 0;
+ clicked_includes_current = false;
+ orthogonal = false;
+ message_time = 0;
+
+ spatial_editor = p_spatial_editor;
+ ViewportContainer *c = memnew(ViewportContainer);
c->set_stretch(true);
add_child(c);
c->set_area_as_parent_rect();
- viewport = memnew( Viewport );
+ viewport = memnew(Viewport);
viewport->set_disable_input(true);
c->add_child(viewport);
- surface = memnew( Control );
+ surface = memnew(Control);
add_child(surface);
surface->set_area_as_parent_rect();
camera = memnew(Camera);
camera->set_disable_gizmo(true);
- camera->set_cull_mask( ((1<<20)-1)|(1<<(GIZMO_BASE_LAYER+p_index))|(1<<GIZMO_EDIT_LAYER)|(1<<GIZMO_GRID_LAYER) );
+ camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + p_index)) | (1 << GIZMO_EDIT_LAYER) | (1 << GIZMO_GRID_LAYER));
//camera->set_environment(SpatialEditor::get_singleton()->get_viewport_environment());
viewport->add_child(camera);
camera->make_current();
surface->set_focus_mode(FOCUS_ALL);
- view_menu = memnew( MenuButton );
+ view_menu = memnew(MenuButton);
surface->add_child(view_menu);
- view_menu->set_pos( Point2(4,4));
- view_menu->set_self_modulate(Color(1,1,1,0.5));
+ view_menu->set_pos(Point2(4, 4));
+ view_menu->set_self_modulate(Color(1, 1, 1, 0.5));
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/left_view"), VIEW_LEFT);
@@ -2334,60 +2168,52 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_check_item(TTR("Perspective") + " (" + ED_GET_SHORTCUT("spatial_editor/switch_perspective_orthogonal")->get_as_text() + ")", VIEW_PERSPECTIVE);
view_menu->get_popup()->add_check_item(TTR("Orthogonal") + " (" + ED_GET_SHORTCUT("spatial_editor/switch_perspective_orthogonal")->get_as_text() + ")", VIEW_ORTHOGONAL);
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE),true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE), true);
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("Environment")), VIEW_ENVIRONMENT);
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT),true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT), true);
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_listener", TTR("Audio Listener")), VIEW_AUDIO_LISTENER);
view_menu->get_popup()->add_separator();
- view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("Gizmos")),VIEW_GIZMOS);
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(VIEW_GIZMOS),true);
+ view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("Gizmos")), VIEW_GIZMOS);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS), true);
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_origin"), VIEW_CENTER_TO_ORIGIN);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_selection_with_view"), VIEW_ALIGN_SELECTION_WITH_VIEW);
- view_menu->get_popup()->connect("id_pressed",this,"_menu_option");
+ view_menu->get_popup()->connect("id_pressed", this, "_menu_option");
- preview_camera = memnew( Button );
+ preview_camera = memnew(Button);
preview_camera->set_toggle_mode(true);
- preview_camera->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_END,90);
- preview_camera->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,10);
+ preview_camera->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, 90);
+ preview_camera->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10);
preview_camera->set_text("preview");
surface->add_child(preview_camera);
preview_camera->hide();
- preview_camera->connect("toggled",this,"_toggle_camera_preview");
- previewing=NULL;
- preview=NULL;
- gizmo_scale=1.0;
+ preview_camera->connect("toggled", this, "_toggle_camera_preview");
+ previewing = NULL;
+ preview = NULL;
+ gizmo_scale = 1.0;
- selection_menu = memnew( PopupMenu );
+ selection_menu = memnew(PopupMenu);
add_child(selection_menu);
selection_menu->set_custom_minimum_size(Vector2(100, 0));
selection_menu->connect("id_pressed", this, "_selection_result_pressed");
selection_menu->connect("popup_hide", this, "_selection_menu_hide");
- if (p_index==0) {
- view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER),true);
+ if (p_index == 0) {
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER), true);
viewport->set_as_audio_listener(true);
}
-
- name=TTR("Top");
+ name = TTR("Top");
_update_name();
- EditorSettings::get_singleton()->connect("settings_changed",this,"update_transform_gizmo_view");
-
+ EditorSettings::get_singleton()->connect("settings_changed", this, "update_transform_gizmo_view");
}
-
-
-
-
-
-
-SpatialEditor *SpatialEditor::singleton=NULL;
+SpatialEditor *SpatialEditor::singleton = NULL;
SpatialEditorSelectedItem::~SpatialEditorSelectedItem() {
@@ -2395,183 +2221,172 @@ SpatialEditorSelectedItem::~SpatialEditorSelectedItem() {
VisualServer::get_singleton()->free(sbox_instance);
}
-
-
void SpatialEditor::select_gizmo_hilight_axis(int p_axis) {
+ for (int i = 0; i < 3; i++) {
- for(int i=0;i<3;i++) {
-
- move_gizmo[i]->surface_set_material(0,i==p_axis?gizmo_hl:gizmo_color[i]);
- rotate_gizmo[i]->surface_set_material(0,(i+3)==p_axis?gizmo_hl:gizmo_color[i]);
+ move_gizmo[i]->surface_set_material(0, i == p_axis ? gizmo_hl : gizmo_color[i]);
+ rotate_gizmo[i]->surface_set_material(0, (i + 3) == p_axis ? gizmo_hl : gizmo_color[i]);
}
-
}
void SpatialEditor::update_transform_gizmo() {
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
Rect3 center;
- bool first=true;
+ bool first = true;
Basis gizmo_basis;
- bool local_gizmo_coords = transform_menu->get_popup()->is_item_checked( transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS) );
+ bool local_gizmo_coords = transform_menu->get_popup()->is_item_checked(transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS));
-
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
if (!sp)
continue;
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se)
continue;
Transform xf = se->sp->get_global_transform();
if (first) {
- center.pos=xf.origin;
- first=false;
+ center.pos = xf.origin;
+ first = false;
if (local_gizmo_coords) {
- gizmo_basis=xf.basis;
+ gizmo_basis = xf.basis;
gizmo_basis.orthonormalize();
}
} else {
center.expand_to(xf.origin);
- gizmo_basis=Basis();
+ gizmo_basis = Basis();
}
//count++;
}
- Vector3 pcenter = center.pos+center.size*0.5;
- gizmo.visible=!first;
- gizmo.transform.origin=pcenter;
- gizmo.transform.basis=gizmo_basis;
+ Vector3 pcenter = center.pos + center.size * 0.5;
+ gizmo.visible = !first;
+ gizmo.transform.origin = pcenter;
+ gizmo.transform.basis = gizmo_basis;
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
viewports[i]->update_transform_gizmo_view();
}
-
}
-
Object *SpatialEditor::_get_editor_data(Object *p_what) {
Spatial *sp = p_what->cast_to<Spatial>();
if (!sp)
return NULL;
+ SpatialEditorSelectedItem *si = memnew(SpatialEditorSelectedItem);
- SpatialEditorSelectedItem *si = memnew( SpatialEditorSelectedItem );
-
- si->sp=sp;
- si->sbox_instance=VisualServer::get_singleton()->instance_create2(selection_box->get_rid(),sp->get_world()->get_scenario());
+ si->sp = sp;
+ si->sbox_instance = VisualServer::get_singleton()->instance_create2(selection_box->get_rid(), sp->get_world()->get_scenario());
VS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, VS::SHADOW_CASTING_SETTING_OFF);
if (get_tree()->is_editor_hint())
- editor->call("edit_node",sp);
+ editor->call("edit_node", sp);
return si;
}
void SpatialEditor::_generate_selection_box() {
- Rect3 aabb( Vector3(), Vector3(1,1,1) );
- aabb.grow_by( aabb.get_longest_axis_size()/20.0 );
+ Rect3 aabb(Vector3(), Vector3(1, 1, 1));
+ aabb.grow_by(aabb.get_longest_axis_size() / 20.0);
- Ref<SurfaceTool> st = memnew( SurfaceTool );
+ Ref<SurfaceTool> st = memnew(SurfaceTool);
st->begin(Mesh::PRIMITIVE_LINES);
- for (int i=0;i<12;i++) {
+ for (int i = 0; i < 12; i++) {
- Vector3 a,b;
- aabb.get_edge(i,a,b);
+ Vector3 a, b;
+ aabb.get_edge(i, a, b);
/*Vector<Vector3> points;
Vector<Color> colors;
points.push_back(a);
points.push_back(b);*/
- st->add_color( Color(1.0,1.0,0.8,0.8) );
+ st->add_color(Color(1.0, 1.0, 0.8, 0.8));
st->add_vertex(a);
- st->add_color( Color(1.0,1.0,0.8,0.4) );
- st->add_vertex(a.linear_interpolate(b,0.2));
+ st->add_color(Color(1.0, 1.0, 0.8, 0.4));
+ st->add_vertex(a.linear_interpolate(b, 0.2));
- st->add_color( Color(1.0,1.0,0.8,0.4) );
- st->add_vertex(a.linear_interpolate(b,0.8));
- st->add_color( Color(1.0,1.0,0.8,0.8) );
+ st->add_color(Color(1.0, 1.0, 0.8, 0.4));
+ st->add_vertex(a.linear_interpolate(b, 0.8));
+ st->add_color(Color(1.0, 1.0, 0.8, 0.8));
st->add_vertex(b);
-
}
- Ref<FixedSpatialMaterial> mat = memnew( FixedSpatialMaterial );
- mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
- mat->set_albedo(Color(1,1,1));
- mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
- mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
- mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
+ Ref<FixedSpatialMaterial> mat = memnew(FixedSpatialMaterial);
+ mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
+ mat->set_albedo(Color(1, 1, 1));
+ mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
+ mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
st->set_material(mat);
selection_box = st->commit();
}
-
Dictionary SpatialEditor::get_state() const {
-
Dictionary d;
- d["snap_enabled"]=snap_enabled;
- d["translate_snap"]=get_translate_snap();
- d["rotate_snap"]=get_rotate_snap();
- d["scale_snap"]=get_scale_snap();
-
- int local_coords_index=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS);
- d["local_coords"]=transform_menu->get_popup()->is_item_checked( local_coords_index );
-
- int vc=0;
- if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT) ))
- vc=1;
- else if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS) ))
- vc=2;
- else if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS) ))
- vc=3;
- else if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS) ))
- vc=4;
- else if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT) ))
- vc=5;
- else if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT) ))
- vc=6;
-
- d["viewport_mode"]=vc;
+ d["snap_enabled"] = snap_enabled;
+ d["translate_snap"] = get_translate_snap();
+ d["rotate_snap"] = get_rotate_snap();
+ d["scale_snap"] = get_scale_snap();
+
+ int local_coords_index = transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS);
+ d["local_coords"] = transform_menu->get_popup()->is_item_checked(local_coords_index);
+
+ int vc = 0;
+ if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT)))
+ vc = 1;
+ else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS)))
+ vc = 2;
+ else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS)))
+ vc = 3;
+ else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS)))
+ vc = 4;
+ else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT)))
+ vc = 5;
+ else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT)))
+ vc = 6;
+
+ d["viewport_mode"] = vc;
Array vpdata;
- for(int i=0;i<4;i++) {
- vpdata.push_back( viewports[i]->get_state() );
+ for (int i = 0; i < 4; i++) {
+ vpdata.push_back(viewports[i]->get_state());
}
- d["viewports"]=vpdata;
+ d["viewports"] = vpdata;
- d["default_light"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT) );
- d["ambient_light_color"]=settings_ambient_color->get_pick_color();
+ d["default_light"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT));
+ d["ambient_light_color"] = settings_ambient_color->get_pick_color();
- d["default_srgb"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_SRGB) );
- d["show_grid"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_GRID) );
- d["show_origin"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN) );
- d["fov"]=get_fov();
- d["znear"]=get_znear();
- d["zfar"]=get_zfar();
- d["deflight_rot_x"]=settings_default_light_rot_x;
- d["deflight_rot_y"]=settings_default_light_rot_y;
+ d["default_srgb"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_SRGB));
+ d["show_grid"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_GRID));
+ d["show_origin"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN));
+ d["fov"] = get_fov();
+ d["znear"] = get_znear();
+ d["zfar"] = get_zfar();
+ d["deflight_rot_x"] = settings_default_light_rot_x;
+ d["deflight_rot_y"] = settings_default_light_rot_y;
return d;
}
-void SpatialEditor::set_state(const Dictionary& p_state) {
+void SpatialEditor::set_state(const Dictionary &p_state) {
Dictionary d = p_state;
if (d.has("snap_enabled")) {
- snap_enabled=d["snap_enabled"];
- int snap_enabled_idx=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_USE_SNAP);
- transform_menu->get_popup()->set_item_checked( snap_enabled_idx, snap_enabled );
+ snap_enabled = d["snap_enabled"];
+ int snap_enabled_idx = transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_USE_SNAP);
+ transform_menu->get_popup()->set_item_checked(snap_enabled_idx, snap_enabled);
}
if (d.has("translate_snap"))
@@ -2584,33 +2399,33 @@ void SpatialEditor::set_state(const Dictionary& p_state) {
snap_scale->set_text(d["scale_snap"]);
if (d.has("local_coords")) {
- int local_coords_idx=transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS);
- transform_menu->get_popup()->set_item_checked( local_coords_idx, d["local_coords"] );
+ int local_coords_idx = transform_menu->get_popup()->get_item_index(MENU_TRANSFORM_LOCAL_COORDS);
+ transform_menu->get_popup()->set_item_checked(local_coords_idx, d["local_coords"]);
update_transform_gizmo();
}
if (d.has("viewport_mode")) {
int vc = d["viewport_mode"];
- if (vc==1)
+ if (vc == 1)
_menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT);
- else if (vc==2)
+ else if (vc == 2)
_menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS);
- else if (vc==3)
+ else if (vc == 3)
_menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS);
- else if (vc==4)
+ else if (vc == 4)
_menu_item_pressed(MENU_VIEW_USE_4_VIEWPORTS);
- else if (vc==5)
+ else if (vc == 5)
_menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS_ALT);
- else if (vc==6)
+ else if (vc == 6)
_menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS_ALT);
}
if (d.has("viewports")) {
Array vp = d["viewports"];
- ERR_FAIL_COND(vp.size()>4);
+ ERR_FAIL_COND(vp.size() > 4);
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
viewports[i]->set_state(vp[i]);
}
}
@@ -2626,18 +2441,16 @@ void SpatialEditor::set_state(const Dictionary& p_state) {
bool use = d["default_light"];
bool existing = light_instance.is_valid();
- if (use!=existing) {
+ if (use != existing) {
if (existing) {
VisualServer::get_singleton()->free(light_instance);
- light_instance=RID();
+ light_instance = RID();
} else {
- light_instance=VisualServer::get_singleton()->instance_create2(light,get_tree()->get_root()->get_world()->get_scenario());
- VisualServer::get_singleton()->instance_set_transform(light_instance,light_transform);
-
+ light_instance = VisualServer::get_singleton()->instance_create2(light, get_tree()->get_root()->get_world()->get_scenario());
+ VisualServer::get_singleton()->instance_set_transform(light_instance, light_transform);
}
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT), light_instance.is_valid() );
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT), light_instance.is_valid());
}
-
}
if (d.has("ambient_light_color")) {
settings_ambient_color->set_pick_color(d["ambient_light_color"]);
@@ -2653,7 +2466,7 @@ void SpatialEditor::set_state(const Dictionary& p_state) {
if (d.has("show_grid")) {
bool use = d["show_grid"];
- if (use!=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_GRID))) {
+ if (use != view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_GRID))) {
_menu_item_pressed(MENU_VIEW_GRID);
}
}
@@ -2661,26 +2474,23 @@ void SpatialEditor::set_state(const Dictionary& p_state) {
if (d.has("show_origin")) {
bool use = d["show_origin"];
- if (use!=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN))) {
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), use );
- VisualServer::get_singleton()->instance_set_visible(origin_instance,use);
+ if (use != view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN))) {
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), use);
+ VisualServer::get_singleton()->instance_set_visible(origin_instance, use);
}
}
if (d.has("deflight_rot_x"))
- settings_default_light_rot_x=d["deflight_rot_x"];
+ settings_default_light_rot_x = d["deflight_rot_x"];
if (d.has("deflight_rot_y"))
- settings_default_light_rot_y=d["deflight_rot_y"];
+ settings_default_light_rot_y = d["deflight_rot_y"];
_update_default_light_angle();
-
-
}
-
void SpatialEditor::edit(Spatial *p_spatial) {
- if (p_spatial!=selected) {
+ if (p_spatial != selected) {
if (selected) {
Ref<SpatialEditorGizmo> seg = selected->get_gizmo();
@@ -2690,8 +2500,8 @@ void SpatialEditor::edit(Spatial *p_spatial) {
}
}
- selected=p_spatial;
- over_gizmo_handle=-1;
+ selected = p_spatial;
+ over_gizmo_handle = -1;
if (selected) {
@@ -2723,32 +2533,31 @@ void SpatialEditor::_xform_dialog_action() {
Vector3 rotate;
Vector3 translate;
- for(int i=0;i<3;i++) {
- translate[i]=xform_translate[i]->get_text().to_double();
- rotate[i]=Math::deg2rad(xform_rotate[i]->get_text().to_double());
- scale[i]=xform_scale[i]->get_text().to_double();
+ for (int i = 0; i < 3; i++) {
+ translate[i] = xform_translate[i]->get_text().to_double();
+ rotate[i] = Math::deg2rad(xform_rotate[i]->get_text().to_double());
+ scale[i] = xform_scale[i]->get_text().to_double();
}
-
+
t.basis.scale(scale);
t.basis.rotate(rotate);
- t.origin=translate;
-
+ t.origin = translate;
undo_redo->create_action(TTR("XForm Dialog"));
- List<Node*> &selection = editor_selection->get_selected_node_list();
+ List<Node *> &selection = editor_selection->get_selected_node_list();
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
if (!sp)
continue;
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
if (!se)
continue;
- bool post = xform_type->get_selected()>0;
+ bool post = xform_type->get_selected() > 0;
Transform tr = sp->get_global_transform();
if (post)
@@ -2756,18 +2565,18 @@ void SpatialEditor::_xform_dialog_action() {
else {
tr.basis = t.basis * tr.basis;
- tr.origin+=t.origin;
+ tr.origin += t.origin;
}
- undo_redo->add_do_method(sp,"set_global_transform",tr);
- undo_redo->add_undo_method(sp,"set_global_transform",sp->get_global_transform());
+ undo_redo->add_do_method(sp, "set_global_transform", tr);
+ undo_redo->add_undo_method(sp, "set_global_transform", sp->get_global_transform());
}
undo_redo->commit_action();
}
void SpatialEditor::_menu_item_pressed(int p_option) {
- switch(p_option) {
+ switch (p_option) {
case MENU_TOOL_SELECT:
case MENU_TOOL_MOVE:
@@ -2775,9 +2584,9 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
case MENU_TOOL_SCALE:
case MENU_TOOL_LIST_SELECT: {
- for(int i=0;i<TOOL_MAX;i++)
- tool_button[i]->set_pressed(i==p_option);
- tool_mode=(ToolMode)p_option;
+ for (int i = 0; i < TOOL_MAX; i++)
+ tool_button[i]->set_pressed(i == p_option);
+ tool_mode = (ToolMode)p_option;
//static const char *_mode[]={"Selection Mode.","Translation Mode.","Rotation Mode.","Scale Mode.","List Selection Mode."};
//set_message(_mode[p_option],3);
@@ -2786,55 +2595,53 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
} break;
case MENU_TRANSFORM_USE_SNAP: {
- bool is_checked = transform_menu->get_popup()->is_item_checked( transform_menu->get_popup()->get_item_index(p_option) );
- snap_enabled=!is_checked;
- transform_menu->get_popup()->set_item_checked( transform_menu->get_popup()->get_item_index(p_option), snap_enabled );
+ bool is_checked = transform_menu->get_popup()->is_item_checked(transform_menu->get_popup()->get_item_index(p_option));
+ snap_enabled = !is_checked;
+ transform_menu->get_popup()->set_item_checked(transform_menu->get_popup()->get_item_index(p_option), snap_enabled);
} break;
case MENU_TRANSFORM_CONFIGURE_SNAP: {
- snap_dialog->popup_centered(Size2(200,180));
+ snap_dialog->popup_centered(Size2(200, 180));
} break;
case MENU_TRANSFORM_LOCAL_COORDS: {
- bool is_checked = transform_menu->get_popup()->is_item_checked( transform_menu->get_popup()->get_item_index(p_option) );
- transform_menu->get_popup()->set_item_checked( transform_menu->get_popup()->get_item_index(p_option), !is_checked );
+ bool is_checked = transform_menu->get_popup()->is_item_checked(transform_menu->get_popup()->get_item_index(p_option));
+ transform_menu->get_popup()->set_item_checked(transform_menu->get_popup()->get_item_index(p_option), !is_checked);
update_transform_gizmo();
} break;
case MENU_TRANSFORM_DIALOG: {
- for(int i=0;i<3;i++) {
-
+ for (int i = 0; i < 3; i++) {
xform_translate[i]->set_text("0");
xform_rotate[i]->set_text("0");
xform_scale[i]->set_text("1");
-
}
- xform_dialog->popup_centered(Size2(200,200));
+ xform_dialog->popup_centered(Size2(200, 200));
} break;
case MENU_VIEW_USE_DEFAULT_LIGHT: {
- bool is_checked = view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(p_option) );
+ bool is_checked = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(p_option));
if (is_checked) {
VisualServer::get_singleton()->free(light_instance);
- light_instance=RID();
+ light_instance = RID();
} else {
- light_instance=VisualServer::get_singleton()->instance_create2(light,get_tree()->get_root()->get_world()->get_scenario());
- VisualServer::get_singleton()->instance_set_transform(light_instance,light_transform);
+ light_instance = VisualServer::get_singleton()->instance_create2(light, get_tree()->get_root()->get_world()->get_scenario());
+ VisualServer::get_singleton()->instance_set_transform(light_instance, light_transform);
_update_default_light_angle();
}
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(p_option), light_instance.is_valid() );
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(p_option), light_instance.is_valid());
} break;
case MENU_VIEW_USE_DEFAULT_SRGB: {
- bool is_checked = view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(p_option) );
+ bool is_checked = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(p_option));
if (is_checked) {
//viewport_environment->set_enable_fx(Environment::FX_SRGB,false);
@@ -2842,82 +2649,77 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
//viewport_environment->set_enable_fx(Environment::FX_SRGB,true);
}
- is_checked = ! is_checked;
-
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(p_option), is_checked );
+ is_checked = !is_checked;
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(p_option), is_checked);
} break;
case MENU_VIEW_USE_1_VIEWPORT: {
- for(int i=1;i<4;i++) {
+ for (int i = 1; i < 4; i++) {
viewports[i]->hide();
}
viewports[0]->set_area_as_parent_rect();
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), true );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), false );
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), false);
} break;
case MENU_VIEW_USE_2_VIEWPORTS: {
- for(int i=1;i<4;i++) {
+ for (int i = 1; i < 4; i++) {
- if (i==1 || i==3)
+ if (i == 1 || i == 3)
viewports[i]->hide();
else
viewports[i]->show();
-
-
}
viewports[0]->set_area_as_parent_rect();
//viewports[0]->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_RATIO,0.5);
viewports[2]->set_area_as_parent_rect();
//viewports[2]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), true );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), false );
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), false);
} break;
case MENU_VIEW_USE_2_VIEWPORTS_ALT: {
- for(int i=1;i<4;i++) {
+ for (int i = 1; i < 4; i++) {
- if (i==1 || i==3)
+ if (i == 1 || i == 3)
viewports[i]->hide();
else
viewports[i]->show();
-
-
}
viewports[0]->set_area_as_parent_rect();
//viewports[0]->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_RATIO,0.5);
viewports[2]->set_area_as_parent_rect();
//viewports[2]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), true );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), false );
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), false);
} break;
case MENU_VIEW_USE_3_VIEWPORTS: {
- for(int i=1;i<4;i++) {
+ for (int i = 1; i < 4; i++) {
- if (i==1)
+ if (i == 1)
viewports[i]->hide();
else
viewports[i]->show();
@@ -2931,19 +2733,19 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
//viewports[3]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
//viewports[3]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), true );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), false );
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), false);
} break;
case MENU_VIEW_USE_3_VIEWPORTS_ALT: {
- for(int i=1;i<4;i++) {
+ for (int i = 1; i < 4; i++) {
- if (i==1)
+ if (i == 1)
viewports[i]->hide();
else
viewports[i]->show();
@@ -2957,17 +2759,17 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
viewports[3]->set_area_as_parent_rect();
//viewports[3]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), true );
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), true);
} break;
case MENU_VIEW_USE_4_VIEWPORTS: {
- for(int i=1;i<4;i++) {
+ for (int i = 1; i < 4; i++) {
viewports[i]->show();
}
@@ -2984,114 +2786,106 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
//viewports[3]->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_RATIO,0.5);
//viewports[3]->set_anchor_and_margin(MARGIN_TOP,ANCHOR_RATIO,0.5);
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), true );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), false );
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), false);
} break;
case MENU_VIEW_DISPLAY_NORMAL: {
+ VisualServer::get_singleton()->scenario_set_debug(get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_DISABLED);
- VisualServer::get_singleton()->scenario_set_debug( get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_DISABLED );
-
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_NORMAL), true );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_WIREFRAME), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_OVERDRAW), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_SHADELESS), false );
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_NORMAL), true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_WIREFRAME), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_OVERDRAW), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_SHADELESS), false);
} break;
case MENU_VIEW_DISPLAY_WIREFRAME: {
- VisualServer::get_singleton()->scenario_set_debug( get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_WIREFRAME );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_NORMAL), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_WIREFRAME), true );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_OVERDRAW), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_SHADELESS), false );
+ VisualServer::get_singleton()->scenario_set_debug(get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_WIREFRAME);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_NORMAL), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_WIREFRAME), true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_OVERDRAW), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_SHADELESS), false);
} break;
case MENU_VIEW_DISPLAY_OVERDRAW: {
- VisualServer::get_singleton()->scenario_set_debug( get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_OVERDRAW );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_NORMAL), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_WIREFRAME), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_OVERDRAW), true );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_SHADELESS), false );
+ VisualServer::get_singleton()->scenario_set_debug(get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_OVERDRAW);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_NORMAL), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_WIREFRAME), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_OVERDRAW), true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_SHADELESS), false);
} break;
case MENU_VIEW_DISPLAY_SHADELESS: {
- VisualServer::get_singleton()->scenario_set_debug( get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_SHADELESS );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_NORMAL), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_WIREFRAME), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_OVERDRAW), false );
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_SHADELESS), true );
+ VisualServer::get_singleton()->scenario_set_debug(get_tree()->get_root()->get_world()->get_scenario(), VisualServer::SCENARIO_DEBUG_SHADELESS);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_NORMAL), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_WIREFRAME), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_OVERDRAW), false);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_SHADELESS), true);
} break;
case MENU_VIEW_ORIGIN: {
- bool is_checked = view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(p_option) );
+ bool is_checked = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(p_option));
- is_checked=!is_checked;
- VisualServer::get_singleton()->instance_set_visible(origin_instance,is_checked);
+ is_checked = !is_checked;
+ VisualServer::get_singleton()->instance_set_visible(origin_instance, is_checked);
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(p_option), is_checked);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(p_option), is_checked);
} break;
case MENU_VIEW_GRID: {
- bool is_checked = view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(p_option) );
+ bool is_checked = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(p_option));
- grid_enabled=!is_checked;
+ grid_enabled = !is_checked;
- for(int i=0;i<3;++i) {
+ for (int i = 0; i < 3; ++i) {
if (grid_enable[i]) {
- VisualServer::get_singleton()->instance_set_visible(grid_instance[i],grid_enabled);
- grid_visible[i]=grid_enabled;
+ VisualServer::get_singleton()->instance_set_visible(grid_instance[i], grid_enabled);
+ grid_visible[i] = grid_enabled;
}
}
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(p_option), grid_enabled );
-
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(p_option), grid_enabled);
} break;
case MENU_VIEW_CAMERA_SETTINGS: {
- settings_dialog->popup_centered(settings_vbc->get_combined_minimum_size()+Size2(50,50));
+ settings_dialog->popup_centered(settings_vbc->get_combined_minimum_size() + Size2(50, 50));
} break;
-
}
}
-
void SpatialEditor::_init_indicators() {
//make sure that the camera indicator is not selectable
- light=VisualServer::get_singleton()->light_create( VisualServer::LIGHT_DIRECTIONAL );
+ light = VisualServer::get_singleton()->light_create(VisualServer::LIGHT_DIRECTIONAL);
//VisualServer::get_singleton()->light_set_shadow( light, true );
- light_instance=VisualServer::get_singleton()->instance_create2(light,get_tree()->get_root()->get_world()->get_scenario());
-
-
-
- light_transform.rotate(Vector3(1,0,0),-Math_PI/5.0);
- VisualServer::get_singleton()->instance_set_transform(light_instance,light_transform);
+ light_instance = VisualServer::get_singleton()->instance_create2(light, get_tree()->get_root()->get_world()->get_scenario());
+ light_transform.rotate(Vector3(1, 0, 0), -Math_PI / 5.0);
+ VisualServer::get_singleton()->instance_set_transform(light_instance, light_transform);
//RID mat = VisualServer::get_singleton()->fixed_material_create();
///VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA,true);
//VisualServer::get_singleton()->fixed_material_set_flag(mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true);
-
{
indicator_mat.instance();
- indicator_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
+ indicator_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
//indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true);
- indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
- indicator_mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
+ indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ indicator_mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- indicator_mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
+ indicator_mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
PoolVector<Color> grid_colors[3];
PoolVector<Vector3> grid_points[3];
@@ -3100,185 +2894,165 @@ void SpatialEditor::_init_indicators() {
Color grid_color = EditorSettings::get_singleton()->get("editors/3d/grid_color");
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
Vector3 axis;
- axis[i]=1;
+ axis[i] = 1;
Vector3 axis_n1;
- axis_n1[(i+1)%3]=1;
+ axis_n1[(i + 1) % 3] = 1;
Vector3 axis_n2;
- axis_n2[(i+2)%3]=1;
+ axis_n2[(i + 2) % 3] = 1;
- origin_colors.push_back(Color(axis.x,axis.y,axis.z));
- origin_colors.push_back(Color(axis.x,axis.y,axis.z));
- origin_points.push_back(axis*4096);
- origin_points.push_back(axis*-4096);
+ origin_colors.push_back(Color(axis.x, axis.y, axis.z));
+ origin_colors.push_back(Color(axis.x, axis.y, axis.z));
+ origin_points.push_back(axis * 4096);
+ origin_points.push_back(axis * -4096);
#define ORIGIN_GRID_SIZE 25
- for(int j=-ORIGIN_GRID_SIZE;j<=ORIGIN_GRID_SIZE;j++) {
-
+ for (int j = -ORIGIN_GRID_SIZE; j <= ORIGIN_GRID_SIZE; j++) {
grid_colors[i].push_back(grid_color);
grid_colors[i].push_back(grid_color);
grid_colors[i].push_back(grid_color);
grid_colors[i].push_back(grid_color);
- grid_points[i].push_back(axis_n1*ORIGIN_GRID_SIZE+axis_n2*j);
- grid_points[i].push_back(-axis_n1*ORIGIN_GRID_SIZE+axis_n2*j);
- grid_points[i].push_back(axis_n2*ORIGIN_GRID_SIZE+axis_n1*j);
- grid_points[i].push_back(-axis_n2*ORIGIN_GRID_SIZE+axis_n1*j);
-
+ grid_points[i].push_back(axis_n1 * ORIGIN_GRID_SIZE + axis_n2 * j);
+ grid_points[i].push_back(-axis_n1 * ORIGIN_GRID_SIZE + axis_n2 * j);
+ grid_points[i].push_back(axis_n2 * ORIGIN_GRID_SIZE + axis_n1 * j);
+ grid_points[i].push_back(-axis_n2 * ORIGIN_GRID_SIZE + axis_n1 * j);
}
grid[i] = VisualServer::get_singleton()->mesh_create();
Array d;
d.resize(VS::ARRAY_MAX);
- d[VisualServer::ARRAY_VERTEX]=grid_points[i];
- d[VisualServer::ARRAY_COLOR]=grid_colors[i];
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i],VisualServer::PRIMITIVE_LINES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat->get_rid());
- grid_instance[i] = VisualServer::get_singleton()->instance_create2(grid[i],get_tree()->get_root()->get_world()->get_scenario());
-
- grid_visible[i]=false;
- grid_enable[i]=false;
- VisualServer::get_singleton()->instance_set_visible(grid_instance[i],false);
+ d[VisualServer::ARRAY_VERTEX] = grid_points[i];
+ d[VisualServer::ARRAY_COLOR] = grid_colors[i];
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], VisualServer::PRIMITIVE_LINES, d);
+ VisualServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid());
+ grid_instance[i] = VisualServer::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario());
+
+ grid_visible[i] = false;
+ grid_enable[i] = false;
+ VisualServer::get_singleton()->instance_set_visible(grid_instance[i], false);
VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[i], VS::SHADOW_CASTING_SETTING_OFF);
VS::get_singleton()->instance_set_layer_mask(grid_instance[i], 1 << SpatialEditorViewport::GIZMO_GRID_LAYER);
-
-
}
origin = VisualServer::get_singleton()->mesh_create();
Array d;
d.resize(VS::ARRAY_MAX);
- d[VisualServer::ARRAY_VERTEX]=origin_points;
- d[VisualServer::ARRAY_COLOR]=origin_colors;
-
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(origin,VisualServer::PRIMITIVE_LINES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(origin,0,indicator_mat->get_rid());
+ d[VisualServer::ARRAY_VERTEX] = origin_points;
+ d[VisualServer::ARRAY_COLOR] = origin_colors;
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(origin, VisualServer::PRIMITIVE_LINES, d);
+ VisualServer::get_singleton()->mesh_surface_set_material(origin, 0, indicator_mat->get_rid());
//origin = VisualServer::get_singleton()->poly_create();
//VisualServer::get_singleton()->poly_add_primitive(origin,origin_points,Vector<Vector3>(),origin_colors,Vector<Vector3>());
//VisualServer::get_singleton()->poly_set_material(origin,indicator_mat,true);
- origin_instance = VisualServer::get_singleton()->instance_create2(origin,get_tree()->get_root()->get_world()->get_scenario());
- VS::get_singleton()->instance_set_layer_mask(origin_instance,1<<SpatialEditorViewport::GIZMO_GRID_LAYER);
+ origin_instance = VisualServer::get_singleton()->instance_create2(origin, get_tree()->get_root()->get_world()->get_scenario());
+ VS::get_singleton()->instance_set_layer_mask(origin_instance, 1 << SpatialEditorViewport::GIZMO_GRID_LAYER);
VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(origin_instance, VS::SHADOW_CASTING_SETTING_OFF);
-
-
- VisualServer::get_singleton()->instance_set_visible(grid_instance[1],true);
- grid_enable[1]=true;
- grid_visible[1]=true;
- grid_enabled=true;
- last_grid_snap=1;
-
+ VisualServer::get_singleton()->instance_set_visible(grid_instance[1], true);
+ grid_enable[1] = true;
+ grid_visible[1] = true;
+ grid_enabled = true;
+ last_grid_snap = 1;
}
{
cursor_mesh = VisualServer::get_singleton()->mesh_create();
PoolVector<Vector3> cursor_points;
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_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_material.instance();
- cursor_material->set_albedo(Color(0,1,1));
- cursor_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
+ cursor_material->set_albedo(Color(0, 1, 1));
+ cursor_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
Array d;
d.resize(VS::ARRAY_MAX);
- d[VS::ARRAY_VERTEX]=cursor_points;
- VisualServer::get_singleton()->mesh_add_surface_from_arrays(cursor_mesh,VS::PRIMITIVE_LINES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(cursor_mesh,0,cursor_material->get_rid());
+ d[VS::ARRAY_VERTEX] = cursor_points;
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(cursor_mesh, VS::PRIMITIVE_LINES, d);
+ VisualServer::get_singleton()->mesh_surface_set_material(cursor_mesh, 0, cursor_material->get_rid());
- cursor_instance = VisualServer::get_singleton()->instance_create2(cursor_mesh,get_tree()->get_root()->get_world()->get_scenario());
- VS::get_singleton()->instance_set_layer_mask(cursor_instance,1<<SpatialEditorViewport::GIZMO_GRID_LAYER);
+ cursor_instance = VisualServer::get_singleton()->instance_create2(cursor_mesh, get_tree()->get_root()->get_world()->get_scenario());
+ VS::get_singleton()->instance_set_layer_mask(cursor_instance, 1 << SpatialEditorViewport::GIZMO_GRID_LAYER);
VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(cursor_instance, VS::SHADOW_CASTING_SETTING_OFF);
-
-
}
-
{
//move gizmo
-
float gizmo_alph = EditorSettings::get_singleton()->get("editors/3d/manipulator_gizmo_opacity");
- gizmo_hl = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ) );
+ gizmo_hl = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
gizmo_hl->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
gizmo_hl->set_flag(FixedSpatialMaterial::FLAG_ONTOP, true);
gizmo_hl->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
- gizmo_hl->set_albedo(Color(1,1,1,gizmo_alph+0.2f));
+ gizmo_hl->set_albedo(Color(1, 1, 1, gizmo_alph + 0.2f));
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
- move_gizmo[i]=Ref<Mesh>( memnew( Mesh ) );
- rotate_gizmo[i]=Ref<Mesh>( memnew( Mesh ) );
+ move_gizmo[i] = Ref<Mesh>(memnew(Mesh));
+ rotate_gizmo[i] = Ref<Mesh>(memnew(Mesh));
-
- Ref<FixedSpatialMaterial> mat = memnew( FixedSpatialMaterial );
+ Ref<FixedSpatialMaterial> mat = memnew(FixedSpatialMaterial);
mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP, true);
mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
Color col;
- col[i]=1.0;
- col.a= gizmo_alph;
+ col[i] = 1.0;
+ col.a = gizmo_alph;
mat->set_albedo(col);
- gizmo_color[i]=mat;
-
-
-
+ gizmo_color[i] = mat;
Vector3 ivec;
- ivec[i]=1;
+ ivec[i] = 1;
Vector3 nivec;
- nivec[(i+1)%3]=1;
- nivec[(i+2)%3]=1;
+ nivec[(i + 1) % 3] = 1;
+ nivec[(i + 2) % 3] = 1;
Vector3 ivec2;
- ivec2[(i+1)%3]=1;
+ ivec2[(i + 1) % 3] = 1;
Vector3 ivec3;
- ivec3[(i+2)%3]=1;
-
+ ivec3[(i + 2) % 3] = 1;
{
- Ref<SurfaceTool> surftool = memnew( SurfaceTool );
+ Ref<SurfaceTool> surftool = memnew(SurfaceTool);
surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
//translate
- const int arrow_points=5;
- Vector3 arrow[5]={
- nivec*0.0+ivec*0.0,
- nivec*0.01+ivec*0.0,
- nivec*0.01+ivec*1.0,
- nivec*0.1+ivec*1.0,
- nivec*0.0+ivec*(1+GIZMO_ARROW_SIZE),
+ const int arrow_points = 5;
+ Vector3 arrow[5] = {
+ nivec * 0.0 + ivec * 0.0,
+ nivec * 0.01 + ivec * 0.0,
+ nivec * 0.01 + ivec * 1.0,
+ nivec * 0.1 + ivec * 1.0,
+ nivec * 0.0 + ivec * (1 + GIZMO_ARROW_SIZE),
};
- int arrow_sides=6;
+ int arrow_sides = 6;
+ for (int k = 0; k < 7; k++) {
- for(int k = 0; k < 7 ; k++) {
+ Basis ma(ivec, Math_PI * 2 * float(k) / arrow_sides);
+ Basis mb(ivec, Math_PI * 2 * float(k + 1) / arrow_sides);
+ for (int j = 0; j < arrow_points - 1; j++) {
- Basis ma(ivec,Math_PI*2*float(k)/arrow_sides);
- Basis mb(ivec,Math_PI*2*float(k+1)/arrow_sides);
-
-
- 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]),
};
surftool->add_vertex(points[0]);
surftool->add_vertex(points[1]);
@@ -3288,7 +3062,6 @@ void SpatialEditor::_init_indicators() {
surftool->add_vertex(points[2]);
surftool->add_vertex(points[3]);
}
-
}
surftool->set_material(mat);
@@ -3297,33 +3070,29 @@ void SpatialEditor::_init_indicators() {
{
-
- Ref<SurfaceTool> surftool = memnew( SurfaceTool );
+ Ref<SurfaceTool> surftool = memnew(SurfaceTool);
surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
- Vector3 circle[5]={
- ivec*0.02+ivec2*0.02+ivec2*1.0,
- ivec*-0.02+ivec2*0.02+ivec2*1.0,
- ivec*-0.02+ivec2*-0.02+ivec2*1.0,
- ivec*0.02+ivec2*-0.02+ivec2*1.0,
- ivec*0.02+ivec2*0.02+ivec2*1.0,
+ Vector3 circle[5] = {
+ ivec * 0.02 + ivec2 * 0.02 + ivec2 * 1.0,
+ ivec * -0.02 + ivec2 * 0.02 + ivec2 * 1.0,
+ ivec * -0.02 + ivec2 * -0.02 + ivec2 * 1.0,
+ ivec * 0.02 + ivec2 * -0.02 + ivec2 * 1.0,
+ ivec * 0.02 + ivec2 * 0.02 + ivec2 * 1.0,
};
+ for (int k = 0; k < 33; k++) {
- for(int k = 0; k < 33 ; k++) {
+ Basis ma(ivec, Math_PI * 2 * float(k) / 32);
+ Basis mb(ivec, Math_PI * 2 * float(k + 1) / 32);
+ for (int j = 0; j < 4; j++) {
- Basis ma(ivec,Math_PI*2*float(k)/32);
- Basis mb(ivec,Math_PI*2*float(k+1)/32);
-
-
- for(int j=0;j<4;j++) {
-
- Vector3 points[4]={
+ Vector3 points[4] = {
ma.xform(circle[j]),
mb.xform(circle[j]),
- mb.xform(circle[j+1]),
- ma.xform(circle[j+1]),
+ mb.xform(circle[j + 1]),
+ ma.xform(circle[j + 1]),
};
surftool->add_vertex(points[0]);
surftool->add_vertex(points[1]);
@@ -3333,15 +3102,11 @@ void SpatialEditor::_init_indicators() {
surftool->add_vertex(points[2]);
surftool->add_vertex(points[3]);
}
-
}
surftool->set_material(mat);
surftool->commit(rotate_gizmo[i]);
-
}
-
-
}
}
@@ -3352,18 +3117,16 @@ void SpatialEditor::_init_indicators() {
_generate_selection_box();
-
//get_scene()->get_root_node()->cast_to<EditorNode>()->get_scene_root()->add_child(camera);
//current_camera=camera;
-
}
void SpatialEditor::_finish_indicators() {
VisualServer::get_singleton()->free(origin_instance);
VisualServer::get_singleton()->free(origin);
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
VisualServer::get_singleton()->free(grid_instance[i]);
VisualServer::get_singleton()->free(grid[i]);
}
@@ -3427,17 +3190,16 @@ void SpatialEditor::_unhandled_key_input(InputEvent p_event) {
}
#endif
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::KEY: {
-
- const InputEventKey &k=p_event.key;
+ const InputEventKey &k = p_event.key;
if (!k.pressed)
break;
- switch(k.scancode) {
+ switch (k.scancode) {
case KEY_Q: _menu_item_pressed(MENU_TOOL_SELECT); break;
case KEY_W: _menu_item_pressed(MENU_TOOL_MOVE); break;
@@ -3448,7 +3210,7 @@ void SpatialEditor::_unhandled_key_input(InputEvent p_event) {
if (k.mod.shift || k.mod.control || k.mod.command)
break;
- if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_WIREFRAME))) {
+ if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_DISPLAY_WIREFRAME))) {
_menu_item_pressed(MENU_VIEW_DISPLAY_NORMAL);
} else {
_menu_item_pressed(MENU_VIEW_DISPLAY_WIREFRAME);
@@ -3464,55 +3226,51 @@ void SpatialEditor::_unhandled_key_input(InputEvent p_event) {
}
void SpatialEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
- tool_button[SpatialEditor::TOOL_MODE_SELECT]->set_icon( get_icon("ToolSelect","EditorIcons") );
- tool_button[SpatialEditor::TOOL_MODE_MOVE]->set_icon( get_icon("ToolMove","EditorIcons") );
- tool_button[SpatialEditor::TOOL_MODE_ROTATE]->set_icon( get_icon("ToolRotate","EditorIcons") );
- tool_button[SpatialEditor::TOOL_MODE_SCALE]->set_icon( get_icon("ToolScale","EditorIcons") );
- tool_button[SpatialEditor::TOOL_MODE_LIST_SELECT]->set_icon( get_icon("ListSelect","EditorIcons") );
- instance_button->set_icon( get_icon("SpatialAdd","EditorIcons") );
+ tool_button[SpatialEditor::TOOL_MODE_SELECT]->set_icon(get_icon("ToolSelect", "EditorIcons"));
+ tool_button[SpatialEditor::TOOL_MODE_MOVE]->set_icon(get_icon("ToolMove", "EditorIcons"));
+ tool_button[SpatialEditor::TOOL_MODE_ROTATE]->set_icon(get_icon("ToolRotate", "EditorIcons"));
+ tool_button[SpatialEditor::TOOL_MODE_SCALE]->set_icon(get_icon("ToolScale", "EditorIcons"));
+ tool_button[SpatialEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_icon("ListSelect", "EditorIcons"));
+ instance_button->set_icon(get_icon("SpatialAdd", "EditorIcons"));
instance_button->hide();
-
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT),get_icon("Panels1","EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS),get_icon("Panels2","EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT),get_icon("Panels2Alt","EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS),get_icon("Panels3","EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT),get_icon("Panels3Alt","EditorIcons"));
- view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS),get_icon("Panels4","EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_icon("Panels1", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_icon("Panels2", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_icon("Panels2Alt", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_icon("Panels3", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_icon("Panels3Alt", "EditorIcons"));
+ view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_icon("Panels4", "EditorIcons"));
_menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT);
- get_tree()->connect("node_removed",this,"_node_removed");
- VS::get_singleton()->scenario_set_fallback_environment(get_viewport()->find_world()->get_scenario(),viewport_environment->get_rid());
-
+ get_tree()->connect("node_removed", this, "_node_removed");
+ VS::get_singleton()->scenario_set_fallback_environment(get_viewport()->find_world()->get_scenario(), viewport_environment->get_rid());
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- gizmos = memnew( SpatialEditorGizmos );
+ gizmos = memnew(SpatialEditorGizmos);
_init_indicators();
_update_default_light_angle();
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
_finish_indicators();
- memdelete( gizmos );
-
+ memdelete(gizmos);
}
}
void SpatialEditor::add_control_to_menu_panel(Control *p_control) {
-
hbc_menu->add_child(p_control);
}
-void SpatialEditor::set_can_preview(Camera* p_preview) {
+void SpatialEditor::set_can_preview(Camera *p_preview) {
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
viewports[i]->set_can_preview(p_preview);
}
}
@@ -3527,17 +3285,16 @@ HSplitContainer *SpatialEditor::get_palette_split() {
return palette_split;
}
+void SpatialEditor::_request_gizmo(Object *p_obj) {
-void SpatialEditor::_request_gizmo(Object* p_obj) {
-
- Spatial *sp=p_obj->cast_to<Spatial>();
+ Spatial *sp = p_obj->cast_to<Spatial>();
if (!sp)
return;
- if (editor->get_edited_scene() && (sp==editor->get_edited_scene() || sp->get_owner()==editor->get_edited_scene() || editor->get_edited_scene()->is_editable_instance(sp->get_owner()))) {
+ if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || sp->get_owner() == editor->get_edited_scene() || editor->get_edited_scene()->is_editable_instance(sp->get_owner()))) {
Ref<SpatialEditorGizmo> seg;
- for(int i=0;i<EditorNode::get_singleton()->get_editor_data().get_editor_plugin_count();i++) {
+ for (int i = 0; i < EditorNode::get_singleton()->get_editor_data().get_editor_plugin_count(); i++) {
seg = EditorNode::get_singleton()->get_editor_data().get_editor_plugin(i)->create_spatial_gizmo(sp);
if (seg.is_valid())
@@ -3552,265 +3309,246 @@ void SpatialEditor::_request_gizmo(Object* p_obj) {
sp->set_gizmo(seg);
}
-
- if (seg.is_valid() && sp==selected) {
+ if (seg.is_valid() && sp == selected) {
seg->set_selected(true);
selected->update_gizmo();
}
-
}
}
-void SpatialEditor::_toggle_maximize_view(Object* p_viewport) {
+void SpatialEditor::_toggle_maximize_view(Object *p_viewport) {
if (!p_viewport) return;
SpatialEditorViewport *current_viewport = p_viewport->cast_to<SpatialEditorViewport>();
if (!current_viewport) return;
- int index=-1;
+ int index = -1;
bool maximized = false;
- for(int i=0;i<4;i++) {
- if (viewports[i]==current_viewport) {
- index=i;
- if ( current_viewport->get_global_rect() == viewport_base->get_global_rect() )
- maximized=true;
+ for (int i = 0; i < 4; i++) {
+ if (viewports[i] == current_viewport) {
+ index = i;
+ if (current_viewport->get_global_rect() == viewport_base->get_global_rect())
+ maximized = true;
break;
}
}
- if (index==-1) return;
+ if (index == -1) return;
if (!maximized) {
- for(int i=0;i<4;i++) {
- if (i==index)
+ for (int i = 0; i < 4; i++) {
+ if (i == index)
viewports[i]->set_area_as_parent_rect();
else
viewports[i]->hide();
}
} else {
- for(int i=0;i<4;i++)
+ for (int i = 0; i < 4; i++)
viewports[i]->show();
- if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT) ))
+ if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT)))
_menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT);
- else if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS) ))
+ else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS)))
_menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS);
- else if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT) ))
+ else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT)))
_menu_item_pressed(MENU_VIEW_USE_2_VIEWPORTS_ALT);
- else if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS) ))
+ else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS)))
_menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS);
- else if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT) ))
+ else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT)))
_menu_item_pressed(MENU_VIEW_USE_3_VIEWPORTS_ALT);
- else if (view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS) ))
+ else if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS)))
_menu_item_pressed(MENU_VIEW_USE_4_VIEWPORTS);
}
-
}
+void SpatialEditor::_node_removed(Node *p_node) {
-void SpatialEditor::_node_removed(Node* p_node) {
-
- if (p_node==selected)
- selected=NULL;
+ if (p_node == selected)
+ selected = NULL;
}
void SpatialEditor::_bind_methods() {
//ClassDB::bind_method("_gui_input",&SpatialEditor::_gui_input);
- ClassDB::bind_method("_unhandled_key_input",&SpatialEditor::_unhandled_key_input);
- ClassDB::bind_method("_node_removed",&SpatialEditor::_node_removed);
- ClassDB::bind_method("_menu_item_pressed",&SpatialEditor::_menu_item_pressed);
- ClassDB::bind_method("_xform_dialog_action",&SpatialEditor::_xform_dialog_action);
- ClassDB::bind_method("_instance_scene",&SpatialEditor::_instance_scene);
- ClassDB::bind_method("_get_editor_data",&SpatialEditor::_get_editor_data);
- ClassDB::bind_method("_request_gizmo",&SpatialEditor::_request_gizmo);
- ClassDB::bind_method("_default_light_angle_input",&SpatialEditor::_default_light_angle_input);
- ClassDB::bind_method("_update_ambient_light_color",&SpatialEditor::_update_ambient_light_color);
- ClassDB::bind_method("_toggle_maximize_view",&SpatialEditor::_toggle_maximize_view);
-
- ADD_SIGNAL( MethodInfo("transform_key_request") );
-
+ ClassDB::bind_method("_unhandled_key_input", &SpatialEditor::_unhandled_key_input);
+ ClassDB::bind_method("_node_removed", &SpatialEditor::_node_removed);
+ ClassDB::bind_method("_menu_item_pressed", &SpatialEditor::_menu_item_pressed);
+ ClassDB::bind_method("_xform_dialog_action", &SpatialEditor::_xform_dialog_action);
+ ClassDB::bind_method("_instance_scene", &SpatialEditor::_instance_scene);
+ ClassDB::bind_method("_get_editor_data", &SpatialEditor::_get_editor_data);
+ ClassDB::bind_method("_request_gizmo", &SpatialEditor::_request_gizmo);
+ ClassDB::bind_method("_default_light_angle_input", &SpatialEditor::_default_light_angle_input);
+ ClassDB::bind_method("_update_ambient_light_color", &SpatialEditor::_update_ambient_light_color);
+ ClassDB::bind_method("_toggle_maximize_view", &SpatialEditor::_toggle_maximize_view);
+ ADD_SIGNAL(MethodInfo("transform_key_request"));
}
void SpatialEditor::clear() {
- settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov",60.0));
- settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near",0.1));
- settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far",1500.0));
+ settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 60.0));
+ settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.1));
+ settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500.0));
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
viewports[i]->reset();
}
_menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT);
_menu_item_pressed(MENU_VIEW_DISPLAY_NORMAL);
-
- VisualServer::get_singleton()->instance_set_visible(origin_instance,true);
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), true);
- for(int i=0;i<3;++i) {
+ VisualServer::get_singleton()->instance_set_visible(origin_instance, true);
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), true);
+ for (int i = 0; i < 3; ++i) {
if (grid_enable[i]) {
- VisualServer::get_singleton()->instance_set_visible(grid_instance[i],true);
- grid_visible[i]=true;
+ VisualServer::get_singleton()->instance_set_visible(grid_instance[i], true);
+ grid_visible[i] = true;
}
}
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(SpatialEditorViewport::VIEW_AUDIO_LISTENER),i==0);
- viewports[i]->viewport->set_as_audio_listener(i==0);
+ viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(SpatialEditorViewport::VIEW_AUDIO_LISTENER), i == 0);
+ viewports[i]->viewport->set_as_audio_listener(i == 0);
}
- view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_GRID), true );
+ view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_GRID), true);
- settings_default_light_rot_x=Math_PI*0.3;
- settings_default_light_rot_y=Math_PI*0.2;
+ settings_default_light_rot_x = Math_PI * 0.3;
+ settings_default_light_rot_y = Math_PI * 0.2;
//viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0.15,0.15,0.15));
- settings_ambient_color->set_pick_color(Color(0.15,0.15,0.15));
+ settings_ambient_color->set_pick_color(Color(0.15, 0.15, 0.15));
if (!light_instance.is_valid())
_menu_item_pressed(MENU_VIEW_USE_DEFAULT_LIGHT);
_update_default_light_angle();
-
-
}
-
-void SpatialEditor::_update_ambient_light_color(const Color& p_color) {
+void SpatialEditor::_update_ambient_light_color(const Color &p_color) {
//viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,settings_ambient_color->get_color());
-
}
void SpatialEditor::_update_default_light_angle() {
Transform t;
- t.basis.rotate(Vector3(1,0,0),-settings_default_light_rot_x);
- t.basis.rotate(Vector3(0,1,0),-settings_default_light_rot_y);
+ t.basis.rotate(Vector3(1, 0, 0), -settings_default_light_rot_x);
+ t.basis.rotate(Vector3(0, 1, 0), -settings_default_light_rot_y);
settings_dlight->set_transform(t);
if (light_instance.is_valid()) {
- VS::get_singleton()->instance_set_transform(light_instance,t);
+ VS::get_singleton()->instance_set_transform(light_instance, t);
}
-
}
-void SpatialEditor::_default_light_angle_input(const InputEvent& p_event) {
-
+void SpatialEditor::_default_light_angle_input(const InputEvent &p_event) {
- if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&(0x1|0x2|0x4)) {
+ if (p_event.type == InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask & (0x1 | 0x2 | 0x4)) {
- settings_default_light_rot_y = Math::fposmod(settings_default_light_rot_y - p_event.mouse_motion.relative_x*0.01,Math_PI*2.0);
- settings_default_light_rot_x = Math::fposmod(settings_default_light_rot_x - p_event.mouse_motion.relative_y*0.01,Math_PI*2.0);
+ settings_default_light_rot_y = Math::fposmod(settings_default_light_rot_y - p_event.mouse_motion.relative_x * 0.01, Math_PI * 2.0);
+ settings_default_light_rot_x = Math::fposmod(settings_default_light_rot_x - p_event.mouse_motion.relative_y * 0.01, Math_PI * 2.0);
_update_default_light_angle();
}
-
}
-
SpatialEditor::SpatialEditor(EditorNode *p_editor) {
- gizmo.visible=true;
- gizmo.scale=1.0;
+ gizmo.visible = true;
+ gizmo.scale = 1.0;
- viewport_environment = Ref<Environment>( memnew( Environment ) );
- undo_redo=p_editor->get_undo_redo();
+ viewport_environment = Ref<Environment>(memnew(Environment));
+ undo_redo = p_editor->get_undo_redo();
VBoxContainer *vbc = this;
- custom_camera=NULL;
- singleton=this;
- editor=p_editor;
- editor_selection=editor->get_editor_selection();
+ custom_camera = NULL;
+ singleton = this;
+ editor = p_editor;
+ editor_selection = editor->get_editor_selection();
editor_selection->add_editor_plugin(this);
- snap_enabled=false;
+ snap_enabled = false;
tool_mode = TOOL_MODE_SELECT;
//set_focus_mode(FOCUS_ALL);
- hbc_menu = memnew( HBoxContainer );
+ hbc_menu = memnew(HBoxContainer);
vbc->add_child(hbc_menu);
-
Vector<Variant> button_binds;
button_binds.resize(1);
- tool_button[TOOL_MODE_SELECT] = memnew( ToolButton );
- hbc_menu->add_child( tool_button[TOOL_MODE_SELECT] );
+ tool_button[TOOL_MODE_SELECT] = memnew(ToolButton);
+ hbc_menu->add_child(tool_button[TOOL_MODE_SELECT]);
tool_button[TOOL_MODE_SELECT]->set_toggle_mode(true);
tool_button[TOOL_MODE_SELECT]->set_flat(true);
tool_button[TOOL_MODE_SELECT]->set_pressed(true);
- button_binds[0]=MENU_TOOL_SELECT;
- tool_button[TOOL_MODE_SELECT]->connect("pressed", this,"_menu_item_pressed",button_binds);
- tool_button[TOOL_MODE_SELECT]->set_tooltip("Select Mode (Q)\n"+keycode_get_string(KEY_MASK_CMD)+"Drag: Rotate\nAlt+Drag: Move\nAlt+RMB: Depth list selection");
-
+ button_binds[0] = MENU_TOOL_SELECT;
+ tool_button[TOOL_MODE_SELECT]->connect("pressed", this, "_menu_item_pressed", button_binds);
+ tool_button[TOOL_MODE_SELECT]->set_tooltip("Select Mode (Q)\n" + keycode_get_string(KEY_MASK_CMD) + "Drag: Rotate\nAlt+Drag: Move\nAlt+RMB: Depth list selection");
- tool_button[TOOL_MODE_MOVE] = memnew( ToolButton );
+ tool_button[TOOL_MODE_MOVE] = memnew(ToolButton);
- hbc_menu->add_child( tool_button[TOOL_MODE_MOVE] );
+ hbc_menu->add_child(tool_button[TOOL_MODE_MOVE]);
tool_button[TOOL_MODE_MOVE]->set_toggle_mode(true);
tool_button[TOOL_MODE_MOVE]->set_flat(true);
- button_binds[0]=MENU_TOOL_MOVE;
- tool_button[TOOL_MODE_MOVE]->connect("pressed", this,"_menu_item_pressed",button_binds);
+ button_binds[0] = MENU_TOOL_MOVE;
+ tool_button[TOOL_MODE_MOVE]->connect("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_MODE_MOVE]->set_tooltip(TTR("Move Mode (W)"));
- tool_button[TOOL_MODE_ROTATE] = memnew( ToolButton );
- hbc_menu->add_child( tool_button[TOOL_MODE_ROTATE] );
+ tool_button[TOOL_MODE_ROTATE] = memnew(ToolButton);
+ hbc_menu->add_child(tool_button[TOOL_MODE_ROTATE]);
tool_button[TOOL_MODE_ROTATE]->set_toggle_mode(true);
tool_button[TOOL_MODE_ROTATE]->set_flat(true);
- button_binds[0]=MENU_TOOL_ROTATE;
- tool_button[TOOL_MODE_ROTATE]->connect("pressed", this,"_menu_item_pressed",button_binds);
+ button_binds[0] = MENU_TOOL_ROTATE;
+ tool_button[TOOL_MODE_ROTATE]->connect("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_MODE_ROTATE]->set_tooltip(TTR("Rotate Mode (E)"));
- tool_button[TOOL_MODE_SCALE] = memnew( ToolButton );
- hbc_menu->add_child( tool_button[TOOL_MODE_SCALE] );
+ tool_button[TOOL_MODE_SCALE] = memnew(ToolButton);
+ hbc_menu->add_child(tool_button[TOOL_MODE_SCALE]);
tool_button[TOOL_MODE_SCALE]->set_toggle_mode(true);
tool_button[TOOL_MODE_SCALE]->set_flat(true);
- button_binds[0]=MENU_TOOL_SCALE;
- tool_button[TOOL_MODE_SCALE]->connect("pressed", this,"_menu_item_pressed",button_binds);
+ button_binds[0] = MENU_TOOL_SCALE;
+ tool_button[TOOL_MODE_SCALE]->connect("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_MODE_SCALE]->set_tooltip(TTR("Scale Mode (R)"));
- instance_button = memnew( Button );
- hbc_menu->add_child( instance_button );
+ instance_button = memnew(Button);
+ hbc_menu->add_child(instance_button);
instance_button->set_flat(true);
- instance_button->connect("pressed",this,"_instance_scene");
+ instance_button->connect("pressed", this, "_instance_scene");
instance_button->hide();
- VSeparator *vs = memnew( VSeparator );
+ VSeparator *vs = memnew(VSeparator);
hbc_menu->add_child(vs);
- tool_button[TOOL_MODE_LIST_SELECT] = memnew( ToolButton );
- hbc_menu->add_child( tool_button[TOOL_MODE_LIST_SELECT] );
+ tool_button[TOOL_MODE_LIST_SELECT] = memnew(ToolButton);
+ hbc_menu->add_child(tool_button[TOOL_MODE_LIST_SELECT]);
tool_button[TOOL_MODE_LIST_SELECT]->set_toggle_mode(true);
tool_button[TOOL_MODE_LIST_SELECT]->set_flat(true);
- button_binds[0]=MENU_TOOL_LIST_SELECT;
- tool_button[TOOL_MODE_LIST_SELECT]->connect("pressed", this,"_menu_item_pressed",button_binds);
+ button_binds[0] = MENU_TOOL_LIST_SELECT;
+ tool_button[TOOL_MODE_LIST_SELECT]->connect("pressed", this, "_menu_item_pressed", button_binds);
tool_button[TOOL_MODE_LIST_SELECT]->set_tooltip(TTR("Show a list of all objects at the position clicked\n(same as Alt+RMB in select mode)."));
- vs = memnew( VSeparator );
+ vs = memnew(VSeparator);
hbc_menu->add_child(vs);
-
- ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT+KEY_KP_7);
+ ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT + KEY_KP_7);
ED_SHORTCUT("spatial_editor/top_view", TTR("Top View"), KEY_KP_7);
- ED_SHORTCUT("spatial_editor/rear_view", TTR("Rear View"), KEY_MASK_ALT+KEY_KP_1);
+ ED_SHORTCUT("spatial_editor/rear_view", TTR("Rear View"), KEY_MASK_ALT + KEY_KP_1);
ED_SHORTCUT("spatial_editor/front_view", TTR("Front View"), KEY_KP_1);
- ED_SHORTCUT("spatial_editor/left_view", TTR("Left View"), KEY_MASK_ALT+KEY_KP_3);
+ ED_SHORTCUT("spatial_editor/left_view", TTR("Left View"), KEY_MASK_ALT + KEY_KP_3);
ED_SHORTCUT("spatial_editor/right_view", TTR("Right View"), KEY_KP_3);
ED_SHORTCUT("spatial_editor/switch_perspective_orthogonal", TTR("Switch Perspective/Orthogonal view"), KEY_KP_5);
ED_SHORTCUT("spatial_editor/snap", TTR("Snap"), KEY_S);
ED_SHORTCUT("spatial_editor/insert_anim_key", TTR("Insert Animation Key"), KEY_K);
ED_SHORTCUT("spatial_editor/focus_origin", TTR("Focus Origin"), KEY_O);
ED_SHORTCUT("spatial_editor/focus_selection", TTR("Focus Selection"), KEY_F);
- ED_SHORTCUT("spatial_editor/align_selection_with_view", TTR("Align Selection With View"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_F);
-
+ ED_SHORTCUT("spatial_editor/align_selection_with_view", TTR("Align Selection With View"), KEY_MASK_ALT + KEY_MASK_CMD + KEY_F);
PopupMenu *p;
- transform_menu = memnew( MenuButton );
+ transform_menu = memnew(MenuButton);
transform_menu->set_text(TTR("Transform"));
- hbc_menu->add_child( transform_menu );
+ hbc_menu->add_child(transform_menu);
p = transform_menu->get_popup();
p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_snap", TTR("Use Snap")), MENU_TRANSFORM_USE_SNAP);
@@ -3821,12 +3559,12 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("spatial_editor/transform_dialog", TTR("Transform Dialog..")), MENU_TRANSFORM_DIALOG);
- p->connect("id_pressed", this,"_menu_item_pressed");
+ p->connect("id_pressed", this, "_menu_item_pressed");
- view_menu = memnew( MenuButton );
+ view_menu = memnew(MenuButton);
view_menu->set_text(TTR("View"));
- view_menu->set_pos( Point2( 212,0) );
- hbc_menu->add_child( view_menu );
+ view_menu->set_pos(Point2(212, 0));
+ hbc_menu->add_child(view_menu);
p = view_menu->get_popup();
@@ -3834,12 +3572,12 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p->add_check_shortcut(ED_SHORTCUT("spatial_editor/use_default_srgb", TTR("Use Default sRGB")), MENU_VIEW_USE_DEFAULT_SRGB);
p->add_separator();
- p->add_check_shortcut(ED_SHORTCUT("spatial_editor/1_viewport", TTR("1 Viewport"), KEY_MASK_CMD+KEY_1), MENU_VIEW_USE_1_VIEWPORT);
- p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports", TTR("2 Viewports"), KEY_MASK_CMD+KEY_2), MENU_VIEW_USE_2_VIEWPORTS);
- p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports_alt", TTR("2 Viewports (Alt)"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_2), MENU_VIEW_USE_2_VIEWPORTS_ALT);
- p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports", TTR("3 Viewports"),KEY_MASK_CMD+KEY_3), MENU_VIEW_USE_3_VIEWPORTS);
- p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports_alt", TTR("3 Viewports (Alt)"), KEY_MASK_ALT+KEY_MASK_CMD+KEY_3), MENU_VIEW_USE_3_VIEWPORTS_ALT);
- p->add_check_shortcut(ED_SHORTCUT("spatial_editor/4_viewports", TTR("4 Viewports"), KEY_MASK_CMD+KEY_4), MENU_VIEW_USE_4_VIEWPORTS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/1_viewport", TTR("1 Viewport"), KEY_MASK_CMD + KEY_1), MENU_VIEW_USE_1_VIEWPORT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports", TTR("2 Viewports"), KEY_MASK_CMD + KEY_2), MENU_VIEW_USE_2_VIEWPORTS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/2_viewports_alt", TTR("2 Viewports (Alt)"), KEY_MASK_ALT + KEY_MASK_CMD + KEY_2), MENU_VIEW_USE_2_VIEWPORTS_ALT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports", TTR("3 Viewports"), KEY_MASK_CMD + KEY_3), MENU_VIEW_USE_3_VIEWPORTS);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/3_viewports_alt", TTR("3 Viewports (Alt)"), KEY_MASK_ALT + KEY_MASK_CMD + KEY_3), MENU_VIEW_USE_3_VIEWPORTS_ALT);
+ p->add_check_shortcut(ED_SHORTCUT("spatial_editor/4_viewports", TTR("4 Viewports"), KEY_MASK_CMD + KEY_4), MENU_VIEW_USE_4_VIEWPORTS);
p->add_separator();
p->add_check_shortcut(ED_SHORTCUT("spatial_editor/display_normal", TTR("Display Normal")), MENU_VIEW_DISPLAY_NORMAL);
@@ -3852,212 +3590,195 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
p->add_separator();
p->add_shortcut(ED_SHORTCUT("spatial_editor/settings", TTR("Settings")), MENU_VIEW_CAMERA_SETTINGS);
+ p->set_item_checked(p->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT), true);
+ p->set_item_checked(p->get_item_index(MENU_VIEW_DISPLAY_NORMAL), true);
+ p->set_item_checked(p->get_item_index(MENU_VIEW_ORIGIN), true);
+ p->set_item_checked(p->get_item_index(MENU_VIEW_GRID), true);
- p->set_item_checked( p->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT), true );
- p->set_item_checked( p->get_item_index(MENU_VIEW_DISPLAY_NORMAL), true );
- p->set_item_checked( p->get_item_index(MENU_VIEW_ORIGIN), true );
- p->set_item_checked( p->get_item_index(MENU_VIEW_GRID), true );
-
-
- p->connect("id_pressed", this,"_menu_item_pressed");
-
+ p->connect("id_pressed", this, "_menu_item_pressed");
/* REST OF MENU */
- palette_split = memnew( HSplitContainer);
+ palette_split = memnew(HSplitContainer);
palette_split->set_v_size_flags(SIZE_EXPAND_FILL);
vbc->add_child(palette_split);
- shader_split = memnew( VSplitContainer );
+ shader_split = memnew(VSplitContainer);
shader_split->set_h_size_flags(SIZE_EXPAND_FILL);
palette_split->add_child(shader_split);
- viewport_base = memnew( Control );
+ viewport_base = memnew(Control);
shader_split->add_child(viewport_base);
viewport_base->set_v_size_flags(SIZE_EXPAND_FILL);
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- viewports[i] = memnew( SpatialEditorViewport(this,editor,i) );
- viewports[i]->connect("toggle_maximize_view",this,"_toggle_maximize_view");
+ viewports[i] = memnew(SpatialEditorViewport(this, editor, i));
+ viewports[i]->connect("toggle_maximize_view", this, "_toggle_maximize_view");
viewport_base->add_child(viewports[i]);
}
//vbc->add_child(viewport_base);
-
-
-
/* SNAP DIALOG */
- snap_dialog = memnew( ConfirmationDialog );
+ snap_dialog = memnew(ConfirmationDialog);
snap_dialog->set_title(TTR("Snap Settings"));
add_child(snap_dialog);
- VBoxContainer *snap_dialog_vbc = memnew( VBoxContainer );
+ VBoxContainer *snap_dialog_vbc = memnew(VBoxContainer);
snap_dialog->add_child(snap_dialog_vbc);
//snap_dialog->set_child_rect(snap_dialog_vbc);
- snap_translate = memnew( LineEdit );
+ snap_translate = memnew(LineEdit);
snap_translate->set_text("1");
- snap_dialog_vbc->add_margin_child(TTR("Translate Snap:"),snap_translate);
+ snap_dialog_vbc->add_margin_child(TTR("Translate Snap:"), snap_translate);
- snap_rotate = memnew( LineEdit );
+ snap_rotate = memnew(LineEdit);
snap_rotate->set_text("5");
- snap_dialog_vbc->add_margin_child(TTR("Rotate Snap (deg.):"),snap_rotate);
+ snap_dialog_vbc->add_margin_child(TTR("Rotate Snap (deg.):"), snap_rotate);
- snap_scale = memnew( LineEdit );
+ snap_scale = memnew(LineEdit);
snap_scale->set_text("5");
- snap_dialog_vbc->add_margin_child(TTR("Scale Snap (%):"),snap_scale);
+ snap_dialog_vbc->add_margin_child(TTR("Scale Snap (%):"), snap_scale);
/* SETTINGS DIALOG */
- settings_dialog = memnew( ConfirmationDialog );
+ settings_dialog = memnew(ConfirmationDialog);
settings_dialog->set_title(TTR("Viewport Settings"));
add_child(settings_dialog);
- settings_vbc = memnew( VBoxContainer );
- settings_vbc->set_custom_minimum_size(Size2(200,0));
+ settings_vbc = memnew(VBoxContainer);
+ settings_vbc->set_custom_minimum_size(Size2(200, 0));
settings_dialog->add_child(settings_vbc);
//settings_dialog->set_child_rect(settings_vbc);
-
-
- settings_light_base = memnew( ViewportContainer );
- settings_light_base->set_custom_minimum_size(Size2(128,128));
- settings_light_base->connect("gui_input",this,"_default_light_angle_input");
- settings_vbc->add_margin_child(TTR("Default Light Normal:"),settings_light_base);
- settings_light_vp = memnew( Viewport );
+ settings_light_base = memnew(ViewportContainer);
+ settings_light_base->set_custom_minimum_size(Size2(128, 128));
+ settings_light_base->connect("gui_input", this, "_default_light_angle_input");
+ settings_vbc->add_margin_child(TTR("Default Light Normal:"), settings_light_base);
+ settings_light_vp = memnew(Viewport);
settings_light_vp->set_disable_input(true);
settings_light_vp->set_use_own_world(true);
settings_light_base->add_child(settings_light_vp);
- settings_dlight = memnew( DirectionalLight );
+ settings_dlight = memnew(DirectionalLight);
settings_light_vp->add_child(settings_dlight);
- settings_sphere = memnew( ImmediateGeometry );
- settings_sphere->begin(Mesh::PRIMITIVE_TRIANGLES,Ref<Texture>());
- settings_sphere->set_color(Color(1,1,1));
- settings_sphere->add_sphere(32,16,1);
+ settings_sphere = memnew(ImmediateGeometry);
+ settings_sphere->begin(Mesh::PRIMITIVE_TRIANGLES, Ref<Texture>());
+ settings_sphere->set_color(Color(1, 1, 1));
+ settings_sphere->add_sphere(32, 16, 1);
settings_sphere->end();
settings_light_vp->add_child(settings_sphere);
- settings_camera = memnew( Camera );
+ settings_camera = memnew(Camera);
settings_light_vp->add_child(settings_camera);
- settings_camera->set_translation(Vector3(0,0,2));
- settings_camera->set_orthogonal(2.1,0.1,5);
-
- settings_default_light_rot_x=Math_PI*0.3;
- settings_default_light_rot_y=Math_PI*0.2;
-
-
+ settings_camera->set_translation(Vector3(0, 0, 2));
+ settings_camera->set_orthogonal(2.1, 0.1, 5);
- settings_ambient_color = memnew( ColorPickerButton );
- settings_vbc->add_margin_child(TTR("Ambient Light Color:"),settings_ambient_color);
- settings_ambient_color->connect("color_changed",this,"_update_ambient_light_color");
- settings_ambient_color->set_pick_color(Color(0.15,0.15,0.15));
+ settings_default_light_rot_x = Math_PI * 0.3;
+ settings_default_light_rot_y = Math_PI * 0.2;
+ settings_ambient_color = memnew(ColorPickerButton);
+ settings_vbc->add_margin_child(TTR("Ambient Light Color:"), settings_ambient_color);
+ settings_ambient_color->connect("color_changed", this, "_update_ambient_light_color");
+ settings_ambient_color->set_pick_color(Color(0.15, 0.15, 0.15));
- settings_fov = memnew( SpinBox );
+ settings_fov = memnew(SpinBox);
settings_fov->set_max(179);
settings_fov->set_min(1);
settings_fov->set_step(0.01);
- settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov",60.0));
- settings_vbc->add_margin_child(TTR("Perspective FOV (deg.):"),settings_fov);
+ settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 60.0));
+ settings_vbc->add_margin_child(TTR("Perspective FOV (deg.):"), settings_fov);
- settings_znear = memnew( SpinBox );
+ settings_znear = memnew(SpinBox);
settings_znear->set_max(10000);
settings_znear->set_min(0.1);
settings_znear->set_step(0.01);
- settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near",0.1));
- settings_vbc->add_margin_child(TTR("View Z-Near:"),settings_znear);
+ settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.1));
+ settings_vbc->add_margin_child(TTR("View Z-Near:"), settings_znear);
- settings_zfar = memnew( SpinBox );
+ settings_zfar = memnew(SpinBox);
settings_zfar->set_max(10000);
settings_zfar->set_min(0.1);
settings_zfar->set_step(0.01);
- settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far",1500));
- settings_vbc->add_margin_child(TTR("View Z-Far:"),settings_zfar);
+ settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500));
+ settings_vbc->add_margin_child(TTR("View Z-Far:"), settings_zfar);
//settings_dialog->get_cancel()->hide();
/* XFORM DIALOG */
- xform_dialog = memnew( ConfirmationDialog );
+ xform_dialog = memnew(ConfirmationDialog);
xform_dialog->set_title(TTR("Transform Change"));
add_child(xform_dialog);
Label *l = memnew(Label);
l->set_text(TTR("Translate:"));
- l->set_pos(Point2(5,5));
+ l->set_pos(Point2(5, 5));
xform_dialog->add_child(l);
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
- xform_translate[i] = memnew( LineEdit );
- xform_translate[i]->set_pos( Point2(15+i*60,22) );
- xform_translate[i]->set_size( Size2(50,12 ) );
- xform_dialog->add_child( xform_translate[i] );
+ xform_translate[i] = memnew(LineEdit);
+ xform_translate[i]->set_pos(Point2(15 + i * 60, 22));
+ xform_translate[i]->set_size(Size2(50, 12));
+ xform_dialog->add_child(xform_translate[i]);
}
l = memnew(Label);
l->set_text(TTR("Rotate (deg.):"));
- l->set_pos(Point2(5,45));
+ l->set_pos(Point2(5, 45));
xform_dialog->add_child(l);
- for(int i=0;i<3;i++) {
- xform_rotate[i] = memnew( LineEdit );
- xform_rotate[i]->set_pos( Point2(15+i*60,62) );
- xform_rotate[i]->set_size( Size2(50,22 ) );
+ for (int i = 0; i < 3; i++) {
+ xform_rotate[i] = memnew(LineEdit);
+ xform_rotate[i]->set_pos(Point2(15 + i * 60, 62));
+ xform_rotate[i]->set_size(Size2(50, 22));
xform_dialog->add_child(xform_rotate[i]);
}
l = memnew(Label);
l->set_text(TTR("Scale (ratio):"));
- l->set_pos(Point2(5,85));
+ l->set_pos(Point2(5, 85));
xform_dialog->add_child(l);
- for(int i=0;i<3;i++) {
- xform_scale[i] = memnew( LineEdit );
- xform_scale[i]->set_pos( Point2(15+i*60,102) );
- xform_scale[i]->set_size( Size2(50,22 ) );
+ for (int i = 0; i < 3; i++) {
+ xform_scale[i] = memnew(LineEdit);
+ xform_scale[i]->set_pos(Point2(15 + i * 60, 102));
+ xform_scale[i]->set_size(Size2(50, 22));
xform_dialog->add_child(xform_scale[i]);
}
l = memnew(Label);
l->set_text(TTR("Transform Type"));
- l->set_pos(Point2(5,125));
+ l->set_pos(Point2(5, 125));
xform_dialog->add_child(l);
- xform_type = memnew( OptionButton );
- xform_type->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- xform_type->set_begin( Point2(15,142) );
- xform_type->set_end( Point2(15,75) );
+ xform_type = memnew(OptionButton);
+ xform_type->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ xform_type->set_begin(Point2(15, 142));
+ xform_type->set_end(Point2(15, 75));
xform_type->add_item(TTR("Pre"));
xform_type->add_item(TTR("Post"));
xform_dialog->add_child(xform_type);
- xform_dialog->connect("confirmed", this,"_xform_dialog_action");
+ xform_dialog->connect("confirmed", this, "_xform_dialog_action");
- scenario_debug=VisualServer::SCENARIO_DEBUG_DISABLED;
+ scenario_debug = VisualServer::SCENARIO_DEBUG_DISABLED;
- selected=NULL;
+ selected = NULL;
set_process_unhandled_key_input(true);
add_to_group("_spatial_editor_group");
- EDITOR_DEF("editors/3d/manipulator_gizmo_size",80);
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT,"editors/3d/manipulator_gizmo_size",PROPERTY_HINT_RANGE,"16,1024,1"));
- EDITOR_DEF("editors/3d/manipulator_gizmo_opacity",0.2);
+ EDITOR_DEF("editors/3d/manipulator_gizmo_size", 80);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/3d/manipulator_gizmo_size", PROPERTY_HINT_RANGE, "16,1024,1"));
+ EDITOR_DEF("editors/3d/manipulator_gizmo_opacity", 0.2);
- over_gizmo_handle=-1;
+ over_gizmo_handle = -1;
}
SpatialEditor::~SpatialEditor() {
-
-
}
-
-
-
void SpatialEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
-
spatial_editor->show();
spatial_editor->set_process(true);
//VisualServer::get_singleton()->viewport_set_hide_scenario(editor->get_scene_root()->get_viewport(),false);
@@ -4068,9 +3789,7 @@ void SpatialEditorPlugin::make_visible(bool p_visible) {
spatial_editor->hide();
spatial_editor->set_process(false);
//VisualServer::get_singleton()->viewport_set_hide_scenario(editor->get_scene_root()->get_viewport(),true);
-
}
-
}
void SpatialEditorPlugin::edit(Object *p_object) {
@@ -4086,46 +3805,39 @@ Dictionary SpatialEditorPlugin::get_state() const {
return spatial_editor->get_state();
}
-void SpatialEditorPlugin::set_state(const Dictionary& p_state) {
+void SpatialEditorPlugin::set_state(const Dictionary &p_state) {
spatial_editor->set_state(p_state);
}
-void SpatialEditor::snap_cursor_to_plane(const Plane& p_plane) {
+void SpatialEditor::snap_cursor_to_plane(const Plane &p_plane) {
//cursor.pos=p_plane.project(cursor.pos);
}
void SpatialEditorPlugin::_bind_methods() {
- ClassDB::bind_method("snap_cursor_to_plane",&SpatialEditorPlugin::snap_cursor_to_plane);
-
+ ClassDB::bind_method("snap_cursor_to_plane", &SpatialEditorPlugin::snap_cursor_to_plane);
}
-void SpatialEditorPlugin::snap_cursor_to_plane(const Plane& p_plane) {
-
+void SpatialEditorPlugin::snap_cursor_to_plane(const Plane &p_plane) {
spatial_editor->snap_cursor_to_plane(p_plane);
}
-
-
-
SpatialEditorPlugin::SpatialEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- spatial_editor = memnew( SpatialEditor(p_node) );
+ editor = p_node;
+ spatial_editor = memnew(SpatialEditor(p_node));
spatial_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
editor->get_viewport()->add_child(spatial_editor);
//spatial_editor->set_area_as_parent_rect();
spatial_editor->hide();
- spatial_editor->connect("transform_key_request",editor,"_transform_keyed");
+ spatial_editor->connect("transform_key_request", editor, "_transform_keyed");
//spatial_editor->set_process(true);
}
-
SpatialEditorPlugin::~SpatialEditorPlugin() {
-
}
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 44ce4a0281..e0d2a38956 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -29,11 +29,11 @@
#ifndef SPATIAL_EDITOR_PLUGIN_H
#define SPATIAL_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
-#include "scene/3d/visual_instance.h"
+#include "editor/editor_plugin.h"
#include "scene/3d/immediate_geometry.h"
#include "scene/3d/light.h"
+#include "scene/3d/visual_instance.h"
#include "scene/gui/panel_container.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -45,29 +45,28 @@ class SpatialEditorGizmos;
class SpatialEditorGizmo : public SpatialGizmo {
- GDCLASS(SpatialEditorGizmo,SpatialGizmo);
+ GDCLASS(SpatialEditorGizmo, SpatialGizmo);
bool selected;
-public:
- void set_selected(bool p_selected) { selected=p_selected; }
+public:
+ void set_selected(bool p_selected) { selected = p_selected; }
bool is_selected() const { return selected; }
virtual String get_handle_name(int p_idx) const;
virtual Variant get_handle_value(int p_idx) const;
- virtual void set_handle(int p_idx,Camera *p_camera, const Point2& p_point);
- virtual void commit_handle(int p_idx,const Variant& p_restore,bool p_cancel=false);
+ virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
- virtual bool intersect_frustum(const Camera *p_camera,const Vector<Plane> &p_frustum);
- virtual bool intersect_ray(const Camera *p_camera,const Point2& p_point, Vector3& r_pos, Vector3& r_normal,int *r_gizmo_handle=NULL,bool p_sec_first=false);
+ virtual bool intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum);
+ virtual bool intersect_ray(const Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = NULL, bool p_sec_first = false);
SpatialEditorGizmo();
};
-
class SpatialEditorViewport : public Control {
- GDCLASS( SpatialEditorViewport, Control );
-friend class SpatialEditor;
+ GDCLASS(SpatialEditorViewport, Control);
+ friend class SpatialEditor;
enum {
VIEW_TOP,
@@ -85,12 +84,14 @@ friend class SpatialEditor;
VIEW_AUDIO_LISTENER,
VIEW_GIZMOS,
};
+
public:
enum {
- GIZMO_BASE_LAYER=27,
- GIZMO_EDIT_LAYER=26,
- GIZMO_GRID_LAYER=25
+ GIZMO_BASE_LAYER = 27,
+ GIZMO_EDIT_LAYER = 26,
+ GIZMO_GRID_LAYER = 25
};
+
private:
int index;
String name;
@@ -114,31 +115,31 @@ private:
struct _RayResult {
- Spatial* item;
+ Spatial *item;
float depth;
int handle;
- _FORCE_INLINE_ bool operator<(const _RayResult& p_rr) const { return depth<p_rr.depth; }
+ _FORCE_INLINE_ bool operator<(const _RayResult &p_rr) const { return depth < p_rr.depth; }
};
void _update_name();
- void _compute_edit(const Point2& p_point);
+ void _compute_edit(const Point2 &p_point);
void _clear_selected();
- void _select_clicked(bool p_append,bool p_single);
- void _select(Spatial *p_node, bool p_append,bool p_single);
- ObjectID _select_ray(const Point2& p_pos, bool p_append,bool &r_includes_current,int *r_gizmo_handle=NULL,bool p_alt_select=false);
- void _find_items_at_pos(const Point2& p_pos,bool &r_includes_current,Vector<_RayResult> &results,bool p_alt_select=false);
- Vector3 _get_ray_pos(const Vector2& p_pos) const;
- Vector3 _get_ray(const Vector2& p_pos);
- Point2 _point_to_screen(const Vector3& p_point);
+ void _select_clicked(bool p_append, bool p_single);
+ void _select(Spatial *p_node, bool p_append, bool p_single);
+ ObjectID _select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle = NULL, bool p_alt_select = false);
+ void _find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select = false);
+ Vector3 _get_ray_pos(const Vector2 &p_pos) const;
+ Vector3 _get_ray(const Vector2 &p_pos);
+ Point2 _point_to_screen(const Vector3 &p_point);
Transform _get_camera_transform() const;
int get_selected_count() const;
Vector3 _get_camera_pos() const;
Vector3 _get_camera_normal() const;
- Vector3 _get_screen_to_space(const Vector3& p_vector3);
+ Vector3 _get_screen_to_space(const Vector3 &p_vector3);
void _select_region();
- bool _gizmo_select(const Vector2& p_screenpos,bool p_hilite_only=false);
+ bool _gizmo_select(const Vector2 &p_screenpos, bool p_hilite_only = false);
float get_znear() const;
float get_zfar() const;
@@ -204,32 +205,35 @@ private:
Vector3 cursor_pos;
Vector3 pos;
- float x_rot,y_rot,distance;
+ float x_rot, y_rot, distance;
bool region_select;
- Point2 region_begin,region_end;
+ Point2 region_begin, region_end;
- Cursor() { x_rot=y_rot=0.5; distance=4; region_select=false; }
+ Cursor() {
+ x_rot = y_rot = 0.5;
+ distance = 4;
+ region_select = false;
+ }
} cursor;
RID move_gizmo_instance[3], rotate_gizmo_instance[3];
-
String last_message;
String message;
float message_time;
- void set_message(String p_message,float p_time=5);
+ void set_message(String p_message, float p_time = 5);
//
void _update_camera();
void _draw();
void _smouseenter();
- void _sinput(const InputEvent& p_ie);
+ void _sinput(const InputEvent &p_ie);
SpatialEditor *spatial_editor;
- Camera* previewing;
- Camera* preview;
+ Camera *previewing;
+ Camera *preview;
void _preview_exited_scene();
void _toggle_camera_preview(bool);
@@ -239,17 +243,15 @@ private:
void _selection_menu_hide();
void _list_select(InputEventMouseButton b);
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void update_transform_gizmo_view();
- void set_can_preview(Camera* p_preview);
- void set_state(const Dictionary& p_state);
+ void set_can_preview(Camera *p_preview);
+ void set_state(const Dictionary &p_state);
Dictionary get_state() const;
void reset();
@@ -257,33 +259,29 @@ public:
Viewport *get_viewport_node() { return viewport; }
-
- SpatialEditorViewport(SpatialEditor *p_spatial_editor,EditorNode *p_editor,int p_index);
+ SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index);
};
-
-
class SpatialEditorSelectedItem : public Object {
- GDCLASS(SpatialEditorSelectedItem,Object);
+ GDCLASS(SpatialEditorSelectedItem, Object);
public:
-
Rect3 aabb;
Transform original; // original location when moving
Transform last_xform; // last transform
Spatial *sp;
RID sbox_instance;
- SpatialEditorSelectedItem() { sp=NULL; }
+ SpatialEditorSelectedItem() { sp = NULL; }
~SpatialEditorSelectedItem();
};
class SpatialEditor : public VBoxContainer {
- GDCLASS(SpatialEditor, VBoxContainer );
-public:
+ GDCLASS(SpatialEditor, VBoxContainer);
+public:
enum ToolMode {
TOOL_MODE_SELECT,
@@ -295,13 +293,10 @@ public:
};
-
private:
EditorNode *editor;
EditorSelection *editor_selection;
-
-
Control *viewport_base;
SpatialEditorViewport *viewports[4];
VSplitContainer *shader_split;
@@ -312,14 +307,12 @@ private:
ToolMode tool_mode;
bool orthogonal;
-
VisualServer::ScenarioDebugMode scenario_debug;
RID light;
RID light_instance;
Transform light_transform;
-
RID origin;
RID origin_instance;
RID grid[3];
@@ -333,11 +326,8 @@ private:
Ref<FixedSpatialMaterial> gizmo_color[3];
Ref<FixedSpatialMaterial> gizmo_hl;
-
int over_gizmo_handle;
-
-
Ref<Mesh> selection_box;
RID indicators;
RID indicators_instance;
@@ -346,7 +336,7 @@ private:
Ref<FixedSpatialMaterial> indicator_mat;
Ref<FixedSpatialMaterial> cursor_material;
-/*
+ /*
struct Selected {
AABB aabb;
Transform original; // original location when moving
@@ -364,9 +354,6 @@ private:
Transform transform;
} gizmo;
-
-
-
enum MenuOption {
MENU_TOOL_SELECT,
@@ -396,13 +383,11 @@ private:
};
-
Button *tool_button[TOOL_MAX];
Button *instance_button;
-
- MenuButton* transform_menu;
- MenuButton* view_menu;
+ MenuButton *transform_menu;
+ MenuButton *view_menu;
ConfirmationDialog *snap_dialog;
ConfirmationDialog *xform_dialog;
@@ -412,7 +397,7 @@ private:
LineEdit *snap_translate;
LineEdit *snap_rotate;
LineEdit *snap_scale;
- PanelContainer* menu_panel;
+ PanelContainer *menu_panel;
LineEdit *xform_translate[3];
LineEdit *xform_rotate[3];
@@ -434,16 +419,13 @@ private:
ColorPickerButton *settings_ambient_color;
Image settings_light_dir_image;
-
void _xform_dialog_action();
void _menu_item_pressed(int p_option);
HBoxContainer *hbc_menu;
-
-
-//
-//
+ //
+ //
void _generate_selection_box();
UndoRedo *undo_redo;
@@ -451,7 +433,7 @@ private:
void _init_indicators();
void _finish_indicators();
- void _toggle_maximize_view(Object* p_viewport);
+ void _toggle_maximize_view(Object *p_viewport);
Node *custom_camera;
@@ -461,33 +443,28 @@ private:
Spatial *selected;
- void _request_gizmo(Object* p_obj);
+ void _request_gizmo(Object *p_obj);
static SpatialEditor *singleton;
- void _node_removed(Node* p_node);
+ void _node_removed(Node *p_node);
SpatialEditorGizmos *gizmos;
SpatialEditor();
- void _update_ambient_light_color(const Color& p_color);
+ void _update_ambient_light_color(const Color &p_color);
void _update_default_light_angle();
- void _default_light_angle_input(const InputEvent& p_event);
+ void _default_light_angle_input(const InputEvent &p_event);
protected:
-
-
-
-
void _notification(int p_what);
//void _gui_input(InputEvent p_event);
void _unhandled_key_input(InputEvent p_event);
static void _bind_methods();
-public:
-
+public:
static SpatialEditor *get_singleton() { return singleton; }
- void snap_cursor_to_plane(const Plane& p_plane);
+ void snap_cursor_to_plane(const Plane &p_plane);
float get_znear() const { return settings_znear->get_value(); }
float get_zfar() const { return settings_zfar->get_value(); }
@@ -508,11 +485,11 @@ public:
void update_transform_gizmo();
void select_gizmo_hilight_axis(int p_axis);
- void set_custom_camera(Node *p_camera) { custom_camera=p_camera; }
+ void set_custom_camera(Node *p_camera) { custom_camera = p_camera; }
- void set_undo_redo(UndoRedo *p_undo_redo) {undo_redo=p_undo_redo; }
+ void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
Dictionary get_state() const;
- void set_state(const Dictionary& p_state);
+ void set_state(const Dictionary &p_state);
Ref<Environment> get_viewport_environment() { return viewport_environment; }
@@ -526,12 +503,12 @@ public:
Spatial *get_selected() { return selected; }
int get_over_gizmo_handle() const { return over_gizmo_handle; }
- void set_over_gizmo_handle(int idx) { over_gizmo_handle=idx; }
+ void set_over_gizmo_handle(int idx) { over_gizmo_handle = idx; }
- void set_can_preview(Camera* p_preview);
+ void set_can_preview(Camera *p_preview);
SpatialEditorViewport *get_editor_viewport(int p_idx) {
- ERR_FAIL_INDEX_V(p_idx,4,NULL);
+ ERR_FAIL_INDEX_V(p_idx, 4, NULL);
return viewports[p_idx];
}
@@ -544,15 +521,16 @@ public:
class SpatialEditorPlugin : public EditorPlugin {
- GDCLASS( SpatialEditorPlugin, EditorPlugin );
+ GDCLASS(SpatialEditorPlugin, EditorPlugin);
SpatialEditor *spatial_editor;
EditorNode *editor;
+
protected:
static void _bind_methods();
-public:
- void snap_cursor_to_plane(const Plane& p_plane);
+public:
+ void snap_cursor_to_plane(const Plane &p_plane);
SpatialEditor *get_spatial_editor() { return spatial_editor; }
virtual String get_name() const { return "3D"; }
@@ -562,13 +540,11 @@ public:
virtual bool handles(Object *p_object) const;
virtual Dictionary get_state() const;
- virtual void set_state(const Dictionary& p_state);
+ virtual void set_state(const Dictionary &p_state);
virtual void clear() { spatial_editor->clear(); }
-
SpatialEditorPlugin(EditorNode *p_node);
~SpatialEditorPlugin();
-
};
#endif
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 44d6d3c6e1..7adfb90e6f 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -28,51 +28,44 @@
/*************************************************************************/
#include "sprite_frames_editor_plugin.h"
-#include "io/resource_loader.h"
-#include "global_config.h"
#include "editor/editor_settings.h"
+#include "global_config.h"
+#include "io/resource_loader.h"
#include "scene/3d/sprite_3d.h"
-
-
void SpriteFramesEditor::_gui_input(InputEvent p_event) {
-
-
}
void SpriteFramesEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_FIXED_PROCESS) {
-
+ if (p_what == NOTIFICATION_FIXED_PROCESS) {
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
- load->set_icon( get_icon("Folder","EditorIcons") );
- _delete->set_icon( get_icon("Del","EditorIcons") );
- new_anim->set_icon( get_icon("New","EditorIcons") );
- remove_anim->set_icon( get_icon("Del","EditorIcons") );
-
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ load->set_icon(get_icon("Folder", "EditorIcons"));
+ _delete->set_icon(get_icon("Del", "EditorIcons"));
+ new_anim->set_icon(get_icon("New", "EditorIcons"));
+ remove_anim->set_icon(get_icon("Del", "EditorIcons"));
}
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
//NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
}
- if (p_what==NOTIFICATION_DRAW) {
-
+ if (p_what == NOTIFICATION_DRAW) {
}
}
-void SpriteFramesEditor::_file_load_request(const PoolVector<String>& p_path,int p_at_pos) {
+void SpriteFramesEditor::_file_load_request(const PoolVector<String> &p_path, int p_at_pos) {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- List< Ref<Texture> > resources;
+ List<Ref<Texture> > resources;
- for(int i=0;i<p_path.size();i++) {
+ for (int i = 0; i < p_path.size(); i++) {
- Ref<Texture> resource;
+ Ref<Texture> resource;
resource = ResourceLoader::load(p_path[i]);
if (resource.is_null()) {
@@ -87,26 +80,24 @@ void SpriteFramesEditor::_file_load_request(const PoolVector<String>& p_path,int
resources.push_back(resource);
}
-
if (resources.empty()) {
//print_line("added frames!");
return;
}
undo_redo->create_action(TTR("Add Frame"));
- int fc=frames->get_frame_count(edited_anim);
+ int fc = frames->get_frame_count(edited_anim);
- int count=0;
+ int count = 0;
- for(List< Ref<Texture> >::Element *E=resources.front();E;E=E->next() ) {
+ for (List<Ref<Texture> >::Element *E = resources.front(); E; E = E->next()) {
- undo_redo->add_do_method(frames,"add_frame",edited_anim,E->get(),p_at_pos==-1?-1:p_at_pos+count);
- undo_redo->add_undo_method(frames,"remove_frame",edited_anim,p_at_pos==-1?fc:p_at_pos);
+ undo_redo->add_do_method(frames, "add_frame", edited_anim, E->get(), p_at_pos == -1 ? -1 : p_at_pos + count);
+ undo_redo->add_undo_method(frames, "remove_frame", edited_anim, p_at_pos == -1 ? fc : p_at_pos);
count++;
-
}
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
//print_line("added frames!");
@@ -115,21 +106,19 @@ void SpriteFramesEditor::_file_load_request(const PoolVector<String>& p_path,int
void SpriteFramesEditor::_load_pressed() {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- loading_scene=false;
+ loading_scene = false;
file->clear_filters();
List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("Texture",&extensions);
- for(int i=0;i<extensions.size();i++)
- file->add_filter("*."+extensions[i]);
+ ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions);
+ for (int i = 0; i < extensions.size(); i++)
+ file->add_filter("*." + extensions[i]);
file->set_mode(EditorFileDialog::MODE_OPEN_FILES);
file->popup_centered_ratio();
-
}
-
void SpriteFramesEditor::_item_edited() {
#if 0
@@ -163,38 +152,35 @@ void SpriteFramesEditor::_item_edited() {
}
#endif
-
}
void SpriteFramesEditor::_delete_confirm_pressed() {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- if (tree->get_current()<0)
+ if (tree->get_current() < 0)
return;
- sel-=1;
- if (sel<0 && frames->get_frame_count(edited_anim))
- sel=0;
+ sel -= 1;
+ if (sel < 0 && frames->get_frame_count(edited_anim))
+ sel = 0;
int to_remove = tree->get_current();
- sel=to_remove;
- Ref<Texture> r = frames->get_frame(edited_anim,to_remove);
+ sel = to_remove;
+ Ref<Texture> r = frames->get_frame(edited_anim, to_remove);
undo_redo->create_action(TTR("Delete Resource"));
- undo_redo->add_do_method(frames,"remove_frame",edited_anim,to_remove);
- undo_redo->add_undo_method(frames,"add_frame",edited_anim,r,to_remove);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(frames, "remove_frame", edited_anim, to_remove);
+ undo_redo->add_undo_method(frames, "add_frame", edited_anim, r, to_remove);
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
-
}
-
void SpriteFramesEditor::_paste_pressed() {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- Ref<Texture> r=EditorSettings::get_singleton()->get_resource_clipboard();
+ Ref<Texture> r = EditorSettings::get_singleton()->get_resource_clipboard();
if (!r.is_valid()) {
dialog->set_text(TTR("Resource clipboard is empty or not a texture!"));
dialog->set_title(TTR("Error!"));
@@ -204,131 +190,117 @@ void SpriteFramesEditor::_paste_pressed() {
return; ///beh should show an error i guess
}
-
undo_redo->create_action(TTR("Paste Frame"));
- undo_redo->add_do_method(frames,"add_frame",edited_anim,r);
- undo_redo->add_undo_method(frames,"remove_frame",edited_anim,frames->get_frame_count(edited_anim));
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(frames, "add_frame", edited_anim, r);
+ undo_redo->add_undo_method(frames, "remove_frame", edited_anim, frames->get_frame_count(edited_anim));
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
-
}
void SpriteFramesEditor::_empty_pressed() {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- int from=-1;
+ int from = -1;
- if (tree->get_current()>=0) {
+ if (tree->get_current() >= 0) {
from = tree->get_current();
- sel=from;
+ sel = from;
} else {
- from=frames->get_frame_count(edited_anim);
+ from = frames->get_frame_count(edited_anim);
}
-
-
Ref<Texture> r;
undo_redo->create_action(TTR("Add Empty"));
- undo_redo->add_do_method(frames,"add_frame",edited_anim,r,from);
- undo_redo->add_undo_method(frames,"remove_frame",edited_anim,from);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from);
+ undo_redo->add_undo_method(frames, "remove_frame", edited_anim, from);
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
-
}
void SpriteFramesEditor::_empty2_pressed() {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- int from=-1;
+ int from = -1;
- if (tree->get_current()>=0) {
+ if (tree->get_current() >= 0) {
from = tree->get_current();
- sel=from;
+ sel = from;
} else {
- from=frames->get_frame_count(edited_anim);
+ from = frames->get_frame_count(edited_anim);
}
-
-
Ref<Texture> r;
undo_redo->create_action(TTR("Add Empty"));
- undo_redo->add_do_method(frames,"add_frame",edited_anim,r,from+1);
- undo_redo->add_undo_method(frames,"remove_frame",edited_anim,from+1);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from + 1);
+ undo_redo->add_undo_method(frames, "remove_frame", edited_anim, from + 1);
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
-
}
void SpriteFramesEditor::_up_pressed() {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- if (tree->get_current()<0)
+ if (tree->get_current() < 0)
return;
int to_move = tree->get_current();
- if (to_move<1)
+ if (to_move < 1)
return;
- sel=to_move;
- sel-=1;
+ sel = to_move;
+ sel -= 1;
- Ref<Texture> r = frames->get_frame(edited_anim,to_move);
+ Ref<Texture> r = frames->get_frame(edited_anim, to_move);
undo_redo->create_action(TTR("Delete Resource"));
- undo_redo->add_do_method(frames,"set_frame",edited_anim,to_move,frames->get_frame(edited_anim,to_move-1));
- undo_redo->add_do_method(frames,"set_frame",edited_anim,to_move-1,frames->get_frame(edited_anim,to_move));
- undo_redo->add_undo_method(frames,"set_frame",edited_anim,to_move,frames->get_frame(edited_anim,to_move));
- undo_redo->add_undo_method(frames,"set_frame",edited_anim,to_move-1,frames->get_frame(edited_anim,to_move-1));
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move, frames->get_frame(edited_anim, to_move - 1));
+ undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move - 1, frames->get_frame(edited_anim, to_move));
+ undo_redo->add_undo_method(frames, "set_frame", edited_anim, to_move, frames->get_frame(edited_anim, to_move));
+ undo_redo->add_undo_method(frames, "set_frame", edited_anim, to_move - 1, frames->get_frame(edited_anim, to_move - 1));
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
-
}
void SpriteFramesEditor::_down_pressed() {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
- if (tree->get_current()<0)
+ if (tree->get_current() < 0)
return;
int to_move = tree->get_current();
- if (to_move<0 || to_move>=frames->get_frame_count(edited_anim)-1)
+ if (to_move < 0 || to_move >= frames->get_frame_count(edited_anim) - 1)
return;
- sel=to_move;
- sel+=1;
+ sel = to_move;
+ sel += 1;
- Ref<Texture> r = frames->get_frame(edited_anim,to_move);
+ Ref<Texture> r = frames->get_frame(edited_anim, to_move);
undo_redo->create_action(TTR("Delete Resource"));
- undo_redo->add_do_method(frames,"set_frame",edited_anim,to_move,frames->get_frame(edited_anim,to_move+1));
- undo_redo->add_do_method(frames,"set_frame",edited_anim,to_move+1,frames->get_frame(edited_anim,to_move));
- undo_redo->add_undo_method(frames,"set_frame",edited_anim,to_move,frames->get_frame(edited_anim,to_move));
- undo_redo->add_undo_method(frames,"set_frame",edited_anim,to_move+1,frames->get_frame(edited_anim,to_move+1));
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move, frames->get_frame(edited_anim, to_move + 1));
+ undo_redo->add_do_method(frames, "set_frame", edited_anim, to_move + 1, frames->get_frame(edited_anim, to_move));
+ undo_redo->add_undo_method(frames, "set_frame", edited_anim, to_move, frames->get_frame(edited_anim, to_move));
+ undo_redo->add_undo_method(frames, "set_frame", edited_anim, to_move + 1, frames->get_frame(edited_anim, to_move + 1));
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
-
-
-
}
-
void SpriteFramesEditor::_delete_pressed() {
-
- if (tree->get_current()<0)
+ if (tree->get_current() < 0)
return;
_delete_confirm_pressed(); //it has undo.. why bother with a dialog..
@@ -339,10 +311,8 @@ void SpriteFramesEditor::_delete_pressed() {
//dialog->get_ok()->show();
dialog->get_ok()->set_text("Remove");
dialog->popup_centered(Size2(300,60));*/
-
}
-
void SpriteFramesEditor::_animation_select() {
if (updating)
@@ -350,41 +320,38 @@ void SpriteFramesEditor::_animation_select() {
TreeItem *selected = animations->get_selected();
ERR_FAIL_COND(!selected);
- edited_anim=selected->get_text(0);
+ edited_anim = selected->get_text(0);
_update_library(true);
-
}
-
-static void _find_anim_sprites(Node* p_node,List<Node*> *r_nodes,Ref<SpriteFrames> p_sfames) {
+static void _find_anim_sprites(Node *p_node, List<Node *> *r_nodes, Ref<SpriteFrames> p_sfames) {
Node *edited = EditorNode::get_singleton()->get_edited_scene();
if (!edited)
return;
- if (p_node!=edited && p_node->get_owner()!=edited)
+ if (p_node != edited && p_node->get_owner() != edited)
return;
{
AnimatedSprite *as = p_node->cast_to<AnimatedSprite>();
- if (as && as->get_sprite_frames()==p_sfames) {
+ if (as && as->get_sprite_frames() == p_sfames) {
r_nodes->push_back(p_node);
}
}
{
AnimatedSprite3D *as = p_node->cast_to<AnimatedSprite3D>();
- if (as && as->get_sprite_frames()==p_sfames) {
+ if (as && as->get_sprite_frames() == p_sfames) {
r_nodes->push_back(p_node);
}
}
- for(int i=0;i<p_node->get_child_count();i++) {
- _find_anim_sprites(p_node->get_child(i),r_nodes,p_sfames);
+ for (int i = 0; i < p_node->get_child_count(); i++) {
+ _find_anim_sprites(p_node->get_child(i), r_nodes, p_sfames);
}
-
}
-void SpriteFramesEditor::_animation_name_edited(){
+void SpriteFramesEditor::_animation_name_edited() {
if (updating)
return;
@@ -398,86 +365,77 @@ void SpriteFramesEditor::_animation_name_edited(){
String new_name = edited->get_text(0);
- if (new_name==String(edited_anim))
+ if (new_name == String(edited_anim))
return;
- new_name=new_name.replace("/","_").replace(","," ");
+ new_name = new_name.replace("/", "_").replace(",", " ");
- String name=new_name;
- int counter=0;
- while(frames->has_animation(name)) {
+ String name = new_name;
+ int counter = 0;
+ while (frames->has_animation(name)) {
counter++;
- name=new_name+" "+itos(counter);
+ name = new_name + " " + itos(counter);
}
- List<Node*> nodes;
- _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(),&nodes,Ref<SpriteFrames>(frames));
+ List<Node *> nodes;
+ _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(), &nodes, Ref<SpriteFrames>(frames));
undo_redo->create_action(TTR("Rename Animation"));
- undo_redo->add_do_method(frames,"rename_animation",edited_anim,name);
- undo_redo->add_undo_method(frames,"rename_animation",name,edited_anim);
+ undo_redo->add_do_method(frames, "rename_animation", edited_anim, name);
+ undo_redo->add_undo_method(frames, "rename_animation", name, edited_anim);
- for(List<Node*>::Element *E=nodes.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) {
String current = E->get()->call("get_animation");
- if (current!=edited_anim)
+ if (current != edited_anim)
continue;
- undo_redo->add_do_method(E->get(),"set_animation",name);
- undo_redo->add_undo_method(E->get(),"set_animation",edited_anim);
-
+ undo_redo->add_do_method(E->get(), "set_animation", name);
+ undo_redo->add_undo_method(E->get(), "set_animation", edited_anim);
}
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
- edited_anim=new_name;
+ edited_anim = new_name;
undo_redo->commit_action();
-
-
-
}
-void SpriteFramesEditor::_animation_add(){
-
+void SpriteFramesEditor::_animation_add() {
String new_name = "New Anim";
- String name=new_name;
- int counter=0;
- while(frames->has_animation(name)) {
+ String name = new_name;
+ int counter = 0;
+ while (frames->has_animation(name)) {
counter++;
- name=new_name+" "+itos(counter);
+ name = new_name + " " + itos(counter);
}
- List<Node*> nodes;
- _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(),&nodes,Ref<SpriteFrames>(frames));
-
+ List<Node *> nodes;
+ _find_anim_sprites(EditorNode::get_singleton()->get_edited_scene(), &nodes, Ref<SpriteFrames>(frames));
undo_redo->create_action(TTR("Add Animation"));
- undo_redo->add_do_method(frames,"add_animation",name);
- undo_redo->add_undo_method(frames,"remove_animation",name);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(frames, "add_animation", name);
+ undo_redo->add_undo_method(frames, "remove_animation", name);
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
-
- for(List<Node*>::Element *E=nodes.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) {
String current = E->get()->call("get_animation");
if (frames->has_animation(current))
continue;
- undo_redo->add_do_method(E->get(),"set_animation",name);
- undo_redo->add_undo_method(E->get(),"set_animation",current);
-
+ undo_redo->add_do_method(E->get(), "set_animation", name);
+ undo_redo->add_undo_method(E->get(), "set_animation", current);
}
- edited_anim=new_name;
+ edited_anim = new_name;
undo_redo->commit_action();
-
}
-void SpriteFramesEditor::_animation_remove(){
+void SpriteFramesEditor::_animation_remove() {
//fuck everything
if (updating)
@@ -486,37 +444,33 @@ void SpriteFramesEditor::_animation_remove(){
if (!frames->has_animation(edited_anim))
return;
-
undo_redo->create_action(TTR("Remove Animation"));
- undo_redo->add_do_method(frames,"remove_animation",edited_anim);
- undo_redo->add_undo_method(frames,"add_animation",edited_anim);
- undo_redo->add_undo_method(frames,"set_animation_speed",edited_anim,frames->get_animation_speed(edited_anim));
- undo_redo->add_undo_method(frames,"set_animation_loop",edited_anim,frames->get_animation_loop(edited_anim));
+ undo_redo->add_do_method(frames, "remove_animation", edited_anim);
+ undo_redo->add_undo_method(frames, "add_animation", edited_anim);
+ undo_redo->add_undo_method(frames, "set_animation_speed", edited_anim, frames->get_animation_speed(edited_anim));
+ undo_redo->add_undo_method(frames, "set_animation_loop", edited_anim, frames->get_animation_loop(edited_anim));
int fc = frames->get_frame_count(edited_anim);
- for(int i=0;i<fc;i++) {
- Ref<Texture> frame = frames->get_frame(edited_anim,i);
- undo_redo->add_undo_method(frames,"add_frame",edited_anim,frame);
+ for (int i = 0; i < fc; i++) {
+ Ref<Texture> frame = frames->get_frame(edited_anim, i);
+ undo_redo->add_undo_method(frames, "add_frame", edited_anim, frame);
}
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
-
}
-
void SpriteFramesEditor::_animation_loop_changed() {
if (updating)
return;
undo_redo->create_action(TTR("Change Animation Loop"));
- undo_redo->add_do_method(frames,"set_animation_loop",edited_anim,anim_loop->is_pressed());
- undo_redo->add_undo_method(frames,"set_animation_loop",edited_anim,frames->get_animation_loop(edited_anim));
- undo_redo->add_do_method(this,"_update_library",true);
- undo_redo->add_undo_method(this,"_update_library",true);
+ undo_redo->add_do_method(frames, "set_animation_loop", edited_anim, anim_loop->is_pressed());
+ undo_redo->add_undo_method(frames, "set_animation_loop", edited_anim, frames->get_animation_loop(edited_anim));
+ undo_redo->add_do_method(this, "_update_library", true);
+ undo_redo->add_undo_method(this, "_update_library", true);
undo_redo->commit_action();
-
}
void SpriteFramesEditor::_animation_fps_changed(double p_value) {
@@ -524,24 +478,23 @@ void SpriteFramesEditor::_animation_fps_changed(double p_value) {
if (updating)
return;
- undo_redo->create_action(TTR("Change Animation FPS"),UndoRedo::MERGE_ENDS);
- undo_redo->add_do_method(frames,"set_animation_speed",edited_anim,p_value);
- undo_redo->add_undo_method(frames,"set_animation_speed",edited_anim,frames->get_animation_speed(edited_anim));
- undo_redo->add_do_method(this,"_update_library",true);
- undo_redo->add_undo_method(this,"_update_library",true);
+ undo_redo->create_action(TTR("Change Animation FPS"), UndoRedo::MERGE_ENDS);
+ undo_redo->add_do_method(frames, "set_animation_speed", edited_anim, p_value);
+ undo_redo->add_undo_method(frames, "set_animation_speed", edited_anim, frames->get_animation_speed(edited_anim));
+ undo_redo->add_do_method(this, "_update_library", true);
+ undo_redo->add_undo_method(this, "_update_library", true);
undo_redo->commit_action();
-
}
void SpriteFramesEditor::_update_library(bool p_skip_selector) {
- updating=true;
+ updating = true;
if (!p_skip_selector) {
animations->clear();
- TreeItem *anim_root=animations->create_item();
+ TreeItem *anim_root = animations->create_item();
List<StringName> anim_names;
@@ -551,76 +504,69 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) {
anim_names.sort_custom<StringName::AlphCompare>();
- for(List<StringName>::Element *E=anim_names.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) {
String name = E->get();
TreeItem *it = animations->create_item(anim_root);
- it->set_metadata(0,name);
+ it->set_metadata(0, name);
- it->set_text(0,name);
- it->set_editable(0,true);
+ it->set_text(0, name);
+ it->set_editable(0, true);
- if (E->get()==edited_anim) {
+ if (E->get() == edited_anim) {
it->select(0);
}
}
}
-
tree->clear();
if (!frames->has_animation(edited_anim)) {
- updating=false;
+ updating = false;
return;
}
+ if (sel >= frames->get_frame_count(edited_anim))
+ sel = frames->get_frame_count(edited_anim) - 1;
+ else if (sel < 0 && frames->get_frame_count(edited_anim))
+ sel = 0;
- if (sel>=frames->get_frame_count(edited_anim))
- sel=frames->get_frame_count(edited_anim)-1;
- else if (sel<0 && frames->get_frame_count(edited_anim))
- sel=0;
-
- for(int i=0;i<frames->get_frame_count(edited_anim);i++) {
-
+ for (int i = 0; i < frames->get_frame_count(edited_anim); i++) {
String name;
Ref<Texture> icon;
+ if (frames->get_frame(edited_anim, i).is_null()) {
- if (frames->get_frame(edited_anim,i).is_null()) {
-
- name=itos(i)+": "+TTR("(empty)");
+ name = itos(i) + ": " + TTR("(empty)");
} else {
- name=itos(i)+": "+frames->get_frame(edited_anim,i)->get_name();
- icon=frames->get_frame(edited_anim,i);
+ name = itos(i) + ": " + frames->get_frame(edited_anim, i)->get_name();
+ icon = frames->get_frame(edited_anim, i);
}
- tree->add_item(name,icon);
- if (frames->get_frame(edited_anim,i).is_valid())
- tree->set_item_tooltip(tree->get_item_count()-1,frames->get_frame(edited_anim,i)->get_path());
- if (sel==i)
- tree->select(tree->get_item_count()-1);
+ tree->add_item(name, icon);
+ if (frames->get_frame(edited_anim, i).is_valid())
+ tree->set_item_tooltip(tree->get_item_count() - 1, frames->get_frame(edited_anim, i)->get_path());
+ if (sel == i)
+ tree->select(tree->get_item_count() - 1);
}
anim_speed->set_value(frames->get_animation_speed(edited_anim));
anim_loop->set_pressed(frames->get_animation_loop(edited_anim));
- updating=false;
+ updating = false;
//player->add_resource("default",resource);
}
+void SpriteFramesEditor::edit(SpriteFrames *p_frames) {
-
-void SpriteFramesEditor::edit(SpriteFrames* p_frames) {
-
- if (frames==p_frames)
+ if (frames == p_frames)
return;
- frames=p_frames;
-
+ frames = p_frames;
if (p_frames) {
@@ -630,11 +576,10 @@ void SpriteFramesEditor::edit(SpriteFrames* p_frames) {
frames->get_animation_list(&anim_names);
anim_names.sort_custom<StringName::AlphCompare>();
if (anim_names.size()) {
- edited_anim=anim_names.front()->get();
+ edited_anim = anim_names.front()->get();
} else {
- edited_anim=StringName();
+ edited_anim = StringName();
}
-
}
_update_library();
@@ -643,42 +588,38 @@ void SpriteFramesEditor::edit(SpriteFrames* p_frames) {
hide();
//set_fixed_process(false);
}
-
}
-
-Variant SpriteFramesEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) {
+Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
if (!frames->has_animation(edited_anim))
return false;
- int idx = tree->get_item_at_pos(p_point,true);
+ int idx = tree->get_item_at_pos(p_point, true);
- if (idx<0 || idx>=frames->get_frame_count(edited_anim))
+ if (idx < 0 || idx >= frames->get_frame_count(edited_anim))
return Variant();
- RES frame = frames->get_frame(edited_anim,idx);
+ RES frame = frames->get_frame(edited_anim, idx);
if (frame.is_null())
return Variant();
- return EditorNode::get_singleton()->drag_resource(frame,p_from);
-
-
+ return EditorNode::get_singleton()->drag_resource(frame, p_from);
}
-bool SpriteFramesEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{
+bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
Dictionary d = p_data;
if (!d.has("type"))
return false;
- if (d.has("from") && (Object*)(d["from"])==tree)
+ if (d.has("from") && (Object *)(d["from"]) == tree)
return false;
- if (String(d["type"])=="resource" && d.has("resource")) {
- RES r=d["resource"];
+ if (String(d["type"]) == "resource" && d.has("resource")) {
+ RES r = d["resource"];
Ref<Texture> texture = r;
@@ -688,33 +629,30 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2& p_point,const Variant& p
}
}
-
- if (String(d["type"])=="files") {
+ if (String(d["type"]) == "files") {
Vector<String> files = d["files"];
- if (files.size()==0)
+ if (files.size() == 0)
return false;
- for(int i=0;i<files.size();i++) {
+ for (int i = 0; i < files.size(); i++) {
String file = files[0];
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
- if (!ClassDB::is_parent_class(ftype,"Texture")) {
+ if (!ClassDB::is_parent_class(ftype, "Texture")) {
return false;
}
-
}
return true;
-
}
return false;
}
-void SpriteFramesEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){
+void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
- if (!can_drop_data_fw(p_point,p_data,p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from))
return;
Dictionary d = p_data;
@@ -722,205 +660,188 @@ void SpriteFramesEditor::drop_data_fw(const Point2& p_point,const Variant& p_dat
if (!d.has("type"))
return;
- int at_pos = tree->get_item_at_pos(p_point,true);
+ int at_pos = tree->get_item_at_pos(p_point, true);
- if (String(d["type"])=="resource" && d.has("resource")) {
- RES r=d["resource"];
+ if (String(d["type"]) == "resource" && d.has("resource")) {
+ RES r = d["resource"];
Ref<Texture> texture = r;
if (texture.is_valid()) {
undo_redo->create_action(TTR("Add Frame"));
- undo_redo->add_do_method(frames,"add_frame",edited_anim,texture,at_pos==-1?-1:at_pos);
- undo_redo->add_undo_method(frames,"remove_frame",edited_anim,at_pos==-1?frames->get_frame_count(edited_anim):at_pos);
- undo_redo->add_do_method(this,"_update_library");
- undo_redo->add_undo_method(this,"_update_library");
+ undo_redo->add_do_method(frames, "add_frame", edited_anim, texture, at_pos == -1 ? -1 : at_pos);
+ undo_redo->add_undo_method(frames, "remove_frame", edited_anim, at_pos == -1 ? frames->get_frame_count(edited_anim) : at_pos);
+ undo_redo->add_do_method(this, "_update_library");
+ undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
-
}
}
-
- if (String(d["type"])=="files") {
+ if (String(d["type"]) == "files") {
PoolVector<String> files = d["files"];
- _file_load_request(files,at_pos);
+ _file_load_request(files, at_pos);
}
-
}
-
void SpriteFramesEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_gui_input"),&SpriteFramesEditor::_gui_input);
- ClassDB::bind_method(D_METHOD("_load_pressed"),&SpriteFramesEditor::_load_pressed);
- ClassDB::bind_method(D_METHOD("_empty_pressed"),&SpriteFramesEditor::_empty_pressed);
- ClassDB::bind_method(D_METHOD("_empty2_pressed"),&SpriteFramesEditor::_empty2_pressed);
- ClassDB::bind_method(D_METHOD("_item_edited"),&SpriteFramesEditor::_item_edited);
- ClassDB::bind_method(D_METHOD("_delete_pressed"),&SpriteFramesEditor::_delete_pressed);
- ClassDB::bind_method(D_METHOD("_paste_pressed"),&SpriteFramesEditor::_paste_pressed);
- ClassDB::bind_method(D_METHOD("_delete_confirm_pressed"),&SpriteFramesEditor::_delete_confirm_pressed);
- ClassDB::bind_method(D_METHOD("_file_load_request","files","atpos"),&SpriteFramesEditor::_file_load_request,DEFVAL(-1));
- ClassDB::bind_method(D_METHOD("_update_library","skipsel"),&SpriteFramesEditor::_update_library,DEFVAL(false));
- ClassDB::bind_method(D_METHOD("_up_pressed"),&SpriteFramesEditor::_up_pressed);
- ClassDB::bind_method(D_METHOD("_down_pressed"),&SpriteFramesEditor::_down_pressed);
- ClassDB::bind_method(D_METHOD("_animation_select"),&SpriteFramesEditor::_animation_select);
- ClassDB::bind_method(D_METHOD("_animation_name_edited"),&SpriteFramesEditor::_animation_name_edited);
- ClassDB::bind_method(D_METHOD("_animation_add"),&SpriteFramesEditor::_animation_add);
- ClassDB::bind_method(D_METHOD("_animation_remove"),&SpriteFramesEditor::_animation_remove);
- ClassDB::bind_method(D_METHOD("_animation_loop_changed"),&SpriteFramesEditor::_animation_loop_changed);
- ClassDB::bind_method(D_METHOD("_animation_fps_changed"),&SpriteFramesEditor::_animation_fps_changed);
+ ClassDB::bind_method(D_METHOD("_gui_input"), &SpriteFramesEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_load_pressed"), &SpriteFramesEditor::_load_pressed);
+ ClassDB::bind_method(D_METHOD("_empty_pressed"), &SpriteFramesEditor::_empty_pressed);
+ ClassDB::bind_method(D_METHOD("_empty2_pressed"), &SpriteFramesEditor::_empty2_pressed);
+ ClassDB::bind_method(D_METHOD("_item_edited"), &SpriteFramesEditor::_item_edited);
+ ClassDB::bind_method(D_METHOD("_delete_pressed"), &SpriteFramesEditor::_delete_pressed);
+ ClassDB::bind_method(D_METHOD("_paste_pressed"), &SpriteFramesEditor::_paste_pressed);
+ ClassDB::bind_method(D_METHOD("_delete_confirm_pressed"), &SpriteFramesEditor::_delete_confirm_pressed);
+ ClassDB::bind_method(D_METHOD("_file_load_request", "files", "atpos"), &SpriteFramesEditor::_file_load_request, DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("_update_library", "skipsel"), &SpriteFramesEditor::_update_library, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("_up_pressed"), &SpriteFramesEditor::_up_pressed);
+ ClassDB::bind_method(D_METHOD("_down_pressed"), &SpriteFramesEditor::_down_pressed);
+ ClassDB::bind_method(D_METHOD("_animation_select"), &SpriteFramesEditor::_animation_select);
+ ClassDB::bind_method(D_METHOD("_animation_name_edited"), &SpriteFramesEditor::_animation_name_edited);
+ ClassDB::bind_method(D_METHOD("_animation_add"), &SpriteFramesEditor::_animation_add);
+ ClassDB::bind_method(D_METHOD("_animation_remove"), &SpriteFramesEditor::_animation_remove);
+ ClassDB::bind_method(D_METHOD("_animation_loop_changed"), &SpriteFramesEditor::_animation_loop_changed);
+ ClassDB::bind_method(D_METHOD("_animation_fps_changed"), &SpriteFramesEditor::_animation_fps_changed);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SpriteFramesEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SpriteFramesEditor::can_drop_data_fw);
ClassDB::bind_method(D_METHOD("drop_data_fw"), &SpriteFramesEditor::drop_data_fw);
-
-
}
-
SpriteFramesEditor::SpriteFramesEditor() {
//add_style_override("panel", get_stylebox("panel","Panel"));
- split = memnew( HSplitContainer );
+ split = memnew(HSplitContainer);
add_child(split);
- VBoxContainer *vbc_animlist = memnew( VBoxContainer );
+ VBoxContainer *vbc_animlist = memnew(VBoxContainer);
split->add_child(vbc_animlist);
- vbc_animlist->set_custom_minimum_size(Size2(150,0));
+ vbc_animlist->set_custom_minimum_size(Size2(150, 0));
//vbc_animlist->set_v_size_flags(SIZE_EXPAND_FILL);
-
- VBoxContainer *sub_vb = memnew( VBoxContainer );
- vbc_animlist->add_margin_child(TTR("Animations"),sub_vb,true);
+ VBoxContainer *sub_vb = memnew(VBoxContainer);
+ vbc_animlist->add_margin_child(TTR("Animations"), sub_vb, true);
sub_vb->set_v_size_flags(SIZE_EXPAND_FILL);
- HBoxContainer *hbc_animlist = memnew( HBoxContainer );
+ HBoxContainer *hbc_animlist = memnew(HBoxContainer);
sub_vb->add_child(hbc_animlist);
- new_anim = memnew( Button );
+ new_anim = memnew(Button);
hbc_animlist->add_child(new_anim);
- new_anim->connect("pressed",this,"_animation_add");
-
+ new_anim->connect("pressed", this, "_animation_add");
hbc_animlist->add_spacer();
- remove_anim = memnew( Button );
+ remove_anim = memnew(Button);
hbc_animlist->add_child(remove_anim);
- remove_anim->connect("pressed",this,"_animation_remove");
+ remove_anim->connect("pressed", this, "_animation_remove");
- animations = memnew( Tree );
+ animations = memnew(Tree);
sub_vb->add_child(animations);
animations->set_v_size_flags(SIZE_EXPAND_FILL);
animations->set_hide_root(true);
- animations->connect("cell_selected",this,"_animation_select");
- animations->connect("item_edited",this,"_animation_name_edited");
+ animations->connect("cell_selected", this, "_animation_select");
+ animations->connect("item_edited", this, "_animation_name_edited");
animations->set_single_select_cell_editing_only_when_already_selected(true);
-
- anim_speed = memnew( SpinBox);
- vbc_animlist->add_margin_child(TTR("Speed (FPS):"),anim_speed);
+ anim_speed = memnew(SpinBox);
+ vbc_animlist->add_margin_child(TTR("Speed (FPS):"), anim_speed);
anim_speed->set_min(0);
anim_speed->set_max(100);
anim_speed->set_step(0.01);
- anim_speed->connect("value_changed",this,"_animation_fps_changed");
+ anim_speed->connect("value_changed", this, "_animation_fps_changed");
- anim_loop = memnew( CheckButton );
+ anim_loop = memnew(CheckButton);
anim_loop->set_text(TTR("Loop"));
vbc_animlist->add_child(anim_loop);
- anim_loop->connect("pressed",this,"_animation_loop_changed");
+ anim_loop->connect("pressed", this, "_animation_loop_changed");
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
split->add_child(vbc);
vbc->set_h_size_flags(SIZE_EXPAND_FILL);
- sub_vb = memnew( VBoxContainer );
- vbc->add_margin_child(TTR("Animation Frames"),sub_vb,true);
-
+ sub_vb = memnew(VBoxContainer);
+ vbc->add_margin_child(TTR("Animation Frames"), sub_vb, true);
- HBoxContainer *hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
sub_vb->add_child(hbc);
//animations = memnew( ItemList );
-
- load = memnew( Button );
+ load = memnew(Button);
load->set_tooltip(TTR("Load Resource"));
hbc->add_child(load);
- paste = memnew( Button );
+ paste = memnew(Button);
paste->set_text(TTR("Paste"));
hbc->add_child(paste);
- empty = memnew( Button );
+ empty = memnew(Button);
empty->set_text(TTR("Insert Empty (Before)"));
hbc->add_child(empty);
- empty2 = memnew( Button );
+ empty2 = memnew(Button);
empty2->set_text(TTR("Insert Empty (After)"));
hbc->add_child(empty2);
- move_up = memnew( Button );
+ move_up = memnew(Button);
move_up->set_text(TTR("Up"));
hbc->add_child(move_up);
- move_down = memnew( Button );
+ move_down = memnew(Button);
move_down->set_text(TTR("Down"));
hbc->add_child(move_down);
- _delete = memnew( Button );
+ _delete = memnew(Button);
hbc->add_child(_delete);
- file = memnew( EditorFileDialog );
+ file = memnew(EditorFileDialog);
add_child(file);
-
- tree = memnew( ItemList );
+ tree = memnew(ItemList);
tree->set_v_size_flags(SIZE_EXPAND_FILL);
tree->set_icon_mode(ItemList::ICON_MODE_TOP);
int thumbnail_size = 96;
tree->set_max_columns(0);
tree->set_icon_mode(ItemList::ICON_MODE_TOP);
- tree->set_fixed_column_width(thumbnail_size*3/2);
+ tree->set_fixed_column_width(thumbnail_size * 3 / 2);
tree->set_max_text_lines(2);
- tree->set_fixed_icon_size(Size2(thumbnail_size,thumbnail_size));
+ tree->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
//tree->set_min_icon_size(Size2(thumbnail_size,thumbnail_size));
tree->set_drag_forwarding(this);
-
-
sub_vb->add_child(tree);
- dialog = memnew( AcceptDialog );
- add_child( dialog );
-
- load->connect("pressed", this,"_load_pressed");
- _delete->connect("pressed", this,"_delete_pressed");
- paste->connect("pressed", this,"_paste_pressed");
- empty->connect("pressed", this,"_empty_pressed");
- empty2->connect("pressed", this,"_empty2_pressed");
- move_up->connect("pressed", this,"_up_pressed");
- move_down->connect("pressed", this,"_down_pressed");
- file->connect("files_selected", this,"_file_load_request");
+ dialog = memnew(AcceptDialog);
+ add_child(dialog);
+
+ load->connect("pressed", this, "_load_pressed");
+ _delete->connect("pressed", this, "_delete_pressed");
+ paste->connect("pressed", this, "_paste_pressed");
+ empty->connect("pressed", this, "_empty_pressed");
+ empty2->connect("pressed", this, "_empty2_pressed");
+ move_up->connect("pressed", this, "_up_pressed");
+ move_down->connect("pressed", this, "_down_pressed");
+ file->connect("files_selected", this, "_file_load_request");
//dialog->connect("confirmed", this,"_delete_confirm_pressed");
//tree->connect("item_selected", this,"_item_edited");
- loading_scene=false;
- sel=-1;
-
- updating=false;
+ loading_scene = false;
+ sel = -1;
- edited_anim="default";
+ updating = false;
+ edited_anim = "default";
}
-
void SpriteFramesEditorPlugin::edit(Object *p_object) {
frames_editor->set_undo_redo(&get_undo_redo());
- SpriteFrames * s = p_object->cast_to<SpriteFrames>();
+ SpriteFrames *s = p_object->cast_to<SpriteFrames>();
if (!s)
return;
@@ -946,24 +867,16 @@ void SpriteFramesEditorPlugin::make_visible(bool p_visible) {
//frames_editor->set_process(false);
}
-
}
SpriteFramesEditorPlugin::SpriteFramesEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- frames_editor = memnew( SpriteFramesEditor );
- frames_editor->set_custom_minimum_size(Size2(0,300));
- button=editor->add_bottom_panel_item("SpriteFrames",frames_editor);
+ editor = p_node;
+ frames_editor = memnew(SpriteFramesEditor);
+ frames_editor->set_custom_minimum_size(Size2(0, 300));
+ button = editor->add_bottom_panel_item("SpriteFrames", frames_editor);
button->hide();
-
-
-
}
-
-SpriteFramesEditorPlugin::~SpriteFramesEditorPlugin()
-{
+SpriteFramesEditorPlugin::~SpriteFramesEditorPlugin() {
}
-
-
diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h
index 11f545b443..3e9ba710f3 100644
--- a/editor/plugins/sprite_frames_editor_plugin.h
+++ b/editor/plugins/sprite_frames_editor_plugin.h
@@ -29,19 +29,17 @@
#ifndef SPRITE_FRAMES_EDITOR_PLUGIN_H
#define SPRITE_FRAMES_EDITOR_PLUGIN_H
-
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
-#include "scene/gui/tree.h"
+#include "editor/editor_plugin.h"
#include "scene/2d/animated_sprite.h"
-#include "scene/gui/file_dialog.h"
#include "scene/gui/dialogs.h"
+#include "scene/gui/file_dialog.h"
#include "scene/gui/split_container.h"
-
+#include "scene/gui/tree.h"
class SpriteFramesEditor : public PanelContainer {
- GDCLASS(SpriteFramesEditor, PanelContainer );
+ GDCLASS(SpriteFramesEditor, PanelContainer);
Button *load;
Button *_delete;
@@ -58,7 +56,6 @@ class SpriteFramesEditor : public PanelContainer {
Button *new_anim;
Button *remove_anim;
-
Tree *animations;
SpinBox *anim_speed;
CheckButton *anim_loop;
@@ -73,7 +70,7 @@ class SpriteFramesEditor : public PanelContainer {
void _load_pressed();
void _load_scene_pressed();
- void _file_load_request(const PoolVector<String>& p_path, int p_at_pos=-1);
+ void _file_load_request(const PoolVector<String> &p_path, int p_at_pos = -1);
void _paste_pressed();
void _empty_pressed();
void _empty2_pressed();
@@ -81,11 +78,9 @@ class SpriteFramesEditor : public PanelContainer {
void _delete_confirm_pressed();
void _up_pressed();
void _down_pressed();
- void _update_library(bool p_skip_selector=false);
+ void _update_library(bool p_skip_selector = false);
void _item_edited();
-
-
void _animation_select();
void _animation_name_edited();
void _animation_add();
@@ -97,33 +92,32 @@ class SpriteFramesEditor : public PanelContainer {
UndoRedo *undo_redo;
- bool _is_drop_valid(const Dictionary& p_drag_data, const Dictionary& p_item_data) const;
- Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
- bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
- void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
+ bool _is_drop_valid(const Dictionary &p_drag_data, const Dictionary &p_item_data) const;
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
protected:
void _notification(int p_what);
void _gui_input(InputEvent p_event);
static void _bind_methods();
-public:
- void set_undo_redo(UndoRedo *p_undo_redo) {undo_redo=p_undo_redo; }
+public:
+ void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
- void edit(SpriteFrames* p_frames);
+ void edit(SpriteFrames *p_frames);
SpriteFramesEditor();
};
class SpriteFramesEditorPlugin : public EditorPlugin {
- GDCLASS( SpriteFramesEditorPlugin, EditorPlugin );
+ GDCLASS(SpriteFramesEditorPlugin, EditorPlugin);
SpriteFramesEditor *frames_editor;
EditorNode *editor;
Button *button;
public:
-
virtual String get_name() const { return "SpriteFrames"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -132,7 +126,6 @@ public:
SpriteFramesEditorPlugin(EditorNode *p_node);
~SpriteFramesEditorPlugin();
-
};
#endif // SPRITE_FRAMES_EDITOR_PLUGIN_H
diff --git a/editor/plugins/stream_editor_plugin.h b/editor/plugins/stream_editor_plugin.h
index 2ae3b7100e..6b68ba02f9 100644
--- a/editor/plugins/stream_editor_plugin.h
+++ b/editor/plugins/stream_editor_plugin.h
@@ -30,8 +30,8 @@
#define STREAM_EDITOR_PLUGIN_H
#if 0
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/audio/stream_player.h"
/**
diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp
index 396ebd0052..093f25e2b0 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -28,16 +28,14 @@
/*************************************************************************/
#include "style_box_editor_plugin.h"
-
-void StyleBoxEditor::edit(const Ref<StyleBox>& p_stylebox) {
+void StyleBoxEditor::edit(const Ref<StyleBox> &p_stylebox) {
if (stylebox.is_valid())
- stylebox->disconnect("changed",this,"_sb_changed");
- stylebox=p_stylebox;
+ stylebox->disconnect("changed", this, "_sb_changed");
+ stylebox = p_stylebox;
if (p_stylebox.is_valid()) {
- preview->add_style_override("panel",stylebox);
- stylebox->connect("changed",this,"_sb_changed");
-
+ preview->add_style_override("panel", stylebox);
+ stylebox->connect("changed", this, "_sb_changed");
}
}
@@ -48,7 +46,7 @@ void StyleBoxEditor::_sb_changed() {
void StyleBoxEditor::_bind_methods() {
- ClassDB::bind_method("_sb_changed",&StyleBoxEditor::_sb_changed);
+ ClassDB::bind_method("_sb_changed", &StyleBoxEditor::_sb_changed);
//ClassDB::bind_method("_import",&StyleBoxEditor::_import);
//ClassDB::bind_method("_import_accept",&StyleBoxEditor::_import_accept);
//ClassDB::bind_method("_preview_text_changed",&StyleBoxEditor::_preview_text_changed);
@@ -56,39 +54,36 @@ void StyleBoxEditor::_bind_methods() {
StyleBoxEditor::StyleBoxEditor() {
- panel = memnew( Panel );
+ panel = memnew(Panel);
add_child(panel);
panel->set_area_as_parent_rect();
- Label *l = memnew( Label );
+ Label *l = memnew(Label);
l->set_text(TTR("StyleBox Preview:"));
- l->set_pos(Point2(5,5));
+ l->set_pos(Point2(5, 5));
panel->add_child(l);
-
- preview = memnew( Panel );
+ preview = memnew(Panel);
panel->add_child(preview);
- preview->set_pos(Point2(50,50));
- preview->set_size(Size2(200,100));
-
-
+ preview->set_pos(Point2(50, 50));
+ preview->set_size(Size2(200, 100));
}
void StyleBoxEditorPlugin::edit(Object *p_node) {
if (p_node && p_node->cast_to<StyleBox>()) {
- stylebox_editor->edit( p_node->cast_to<StyleBox>() );
+ stylebox_editor->edit(p_node->cast_to<StyleBox>());
stylebox_editor->show();
} else
stylebox_editor->hide();
}
-bool StyleBoxEditorPlugin::handles(Object *p_node) const{
+bool StyleBoxEditorPlugin::handles(Object *p_node) const {
return p_node->is_class("StyleBox");
}
-void StyleBoxEditorPlugin::make_visible(bool p_visible){
+void StyleBoxEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
button->show();
@@ -103,13 +98,10 @@ void StyleBoxEditorPlugin::make_visible(bool p_visible){
StyleBoxEditorPlugin::StyleBoxEditorPlugin(EditorNode *p_node) {
- stylebox_editor = memnew( StyleBoxEditor );
- stylebox_editor->set_custom_minimum_size(Size2(0,250));
+ stylebox_editor = memnew(StyleBoxEditor);
+ stylebox_editor->set_custom_minimum_size(Size2(0, 250));
//p_node->get_viewport()->add_child(stylebox_editor);
- button = p_node->add_bottom_panel_item("StyleBox",stylebox_editor);
+ button = p_node->add_bottom_panel_item("StyleBox", stylebox_editor);
button->hide();
-
-
}
-
diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h
index 01e636472b..1dfe48d97f 100644
--- a/editor/plugins/style_box_editor_plugin.h
+++ b/editor/plugins/style_box_editor_plugin.h
@@ -29,15 +29,14 @@
#ifndef STYLE_BOX_EDITOR_PLUGIN_H
#define STYLE_BOX_EDITOR_PLUGIN_H
-#include "scene/resources/style_box.h"
-#include "scene/gui/texture_rect.h"
-#include "scene/gui/option_button.h"
#include "editor/editor_node.h"
-
+#include "scene/gui/option_button.h"
+#include "scene/gui/texture_rect.h"
+#include "scene/resources/style_box.h"
class StyleBoxEditor : public Control {
- GDCLASS( StyleBoxEditor, Control );
+ GDCLASS(StyleBoxEditor, Control);
Panel *panel;
Panel *preview;
@@ -47,28 +46,23 @@ class StyleBoxEditor : public Control {
void _sb_changed();
protected:
-
-
static void _bind_methods();
-public:
- void edit(const Ref<StyleBox>& p_stylebox);
+public:
+ void edit(const Ref<StyleBox> &p_stylebox);
StyleBoxEditor();
};
-
-
class StyleBoxEditorPlugin : public EditorPlugin {
- GDCLASS( StyleBoxEditorPlugin, EditorPlugin );
+ GDCLASS(StyleBoxEditorPlugin, EditorPlugin);
StyleBoxEditor *stylebox_editor;
EditorNode *editor;
Button *button;
public:
-
virtual String get_name() const { return "StyleBox"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -76,8 +70,6 @@ public:
virtual void make_visible(bool p_visible);
StyleBoxEditorPlugin(EditorNode *p_node);
-
};
-
#endif // STYLE_BOX_EDITOR_PLUGIN_H
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index af05094e5e..3d05e68cac 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -28,76 +28,68 @@
/*************************************************************************/
#include "texture_editor_plugin.h"
-#include "io/resource_loader.h"
-#include "global_config.h"
#include "editor/editor_settings.h"
+#include "global_config.h"
+#include "io/resource_loader.h"
void TextureEditor::_gui_input(InputEvent p_event) {
-
-
}
void TextureEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_FIXED_PROCESS) {
-
+ if (p_what == NOTIFICATION_FIXED_PROCESS) {
}
-
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
//get_scene()->connect("node_removed",this,"_node_removed");
-
}
- if (p_what==NOTIFICATION_DRAW) {
-
+ if (p_what == NOTIFICATION_DRAW) {
- Ref<Texture> checkerboard = get_icon("Checkerboard","EditorIcons");
+ Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons");
Size2 size = get_size();
- draw_texture_rect(checkerboard,Rect2(Point2(),size),true);
+ draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
- int tex_width = texture->get_width() * size.height / texture ->get_height();
+ 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 = (size.width - tex_width)/2;
- int ofs_y = (size.height - tex_height)/2;
+ int ofs_x = (size.width - tex_width) / 2;
+ int ofs_y = (size.height - tex_height) / 2;
- draw_texture_rect(texture,Rect2(ofs_x,ofs_y,tex_width,tex_height));
+ draw_texture_rect(texture, Rect2(ofs_x, ofs_y, tex_width, tex_height));
- Ref<Font> font = get_font("font","Label");
+ Ref<Font> font = get_font("font", "Label");
String format;
if (texture->cast_to<ImageTexture>()) {
format = Image::get_format_name(texture->cast_to<ImageTexture>()->get_format());
} else {
- format=texture->get_class();
+ format = texture->get_class();
}
- String text = itos(texture->get_width())+"x"+itos(texture->get_height())+" "+format;
+ String text = itos(texture->get_width()) + "x" + itos(texture->get_height()) + " " + format;
Size2 rect = font->get_string_size(text);
- Vector2 draw_from = size-rect+Size2(-2,font->get_ascent()-2);
- if (draw_from.x<0)
- draw_from.x=0;
+ Vector2 draw_from = size - rect + Size2(-2, font->get_ascent() - 2);
+ if (draw_from.x < 0)
+ draw_from.x = 0;
- draw_string(font,draw_from+Vector2(2,2),text,Color(0,0,0,0.5),size.width);
- draw_string(font,draw_from-Vector2(2,2),text,Color(0,0,0,0.5),size.width);
- draw_string(font,draw_from,text,Color(1,1,1,1),size.width);
+ draw_string(font, draw_from + Vector2(2, 2), text, Color(0, 0, 0, 0.5), size.width);
+ draw_string(font, draw_from - Vector2(2, 2), text, Color(0, 0, 0, 0.5), size.width);
+ draw_string(font, draw_from, text, Color(1, 1, 1, 1), size.width);
}
}
-
-
void TextureEditor::edit(Ref<Texture> p_texture) {
- texture=p_texture;
+ texture = p_texture;
if (!texture.is_null())
update();
@@ -105,27 +97,21 @@ void TextureEditor::edit(Ref<Texture> p_texture) {
hide();
}
-
}
-
-
void TextureEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_gui_input"),&TextureEditor::_gui_input);
-
+ ClassDB::bind_method(D_METHOD("_gui_input"), &TextureEditor::_gui_input);
}
TextureEditor::TextureEditor() {
- set_custom_minimum_size(Size2(1,150));
-
+ set_custom_minimum_size(Size2(1, 150));
}
-
void TextureEditorPlugin::edit(Object *p_object) {
- Texture * s = p_object->cast_to<Texture>();
+ Texture *s = p_object->cast_to<Texture>();
if (!s)
return;
@@ -147,23 +133,15 @@ void TextureEditorPlugin::make_visible(bool p_visible) {
texture_editor->hide();
//texture_editor->set_process(false);
}
-
}
TextureEditorPlugin::TextureEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- texture_editor = memnew( TextureEditor );
- add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM,texture_editor);
+ editor = p_node;
+ texture_editor = memnew(TextureEditor);
+ add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, texture_editor);
texture_editor->hide();
-
-
-
}
-
-TextureEditorPlugin::~TextureEditorPlugin()
-{
+TextureEditorPlugin::~TextureEditorPlugin() {
}
-
-
diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h
index 7ad0e918cf..083fbada8b 100644
--- a/editor/plugins/texture_editor_plugin.h
+++ b/editor/plugins/texture_editor_plugin.h
@@ -29,40 +29,34 @@
#ifndef TEXTURE_EDITOR_PLUGIN_H
#define TEXTURE_EDITOR_PLUGIN_H
-
-
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/resources/texture.h"
-
class TextureEditor : public Control {
GDCLASS(TextureEditor, Control);
-
Ref<Texture> texture;
protected:
void _notification(int p_what);
void _gui_input(InputEvent p_event);
static void _bind_methods();
-public:
+public:
void edit(Ref<Texture> p_texture);
TextureEditor();
};
-
class TextureEditorPlugin : public EditorPlugin {
- GDCLASS( TextureEditorPlugin, EditorPlugin );
+ GDCLASS(TextureEditorPlugin, EditorPlugin);
TextureEditor *texture_editor;
EditorNode *editor;
public:
-
virtual String get_name() const { return "Texture"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -71,7 +65,6 @@ public:
TextureEditorPlugin(EditorNode *p_node);
~TextureEditorPlugin();
-
};
#endif // TEXTURE_EDITOR_PLUGIN_H
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index aabf938577..5e992d3ec1 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -31,149 +31,148 @@
#include "texture_region_editor_plugin.h"
#include "core/core_string_names.h"
-#include "scene/gui/check_box.h"
#include "os/input.h"
#include "os/keyboard.h"
+#include "scene/gui/check_box.h"
-void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to){
- Vector2 line = (to-from).normalized() * 10;
+void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) {
+ Vector2 line = (to - from).normalized() * 10;
while ((to - from).length_squared() > 200) {
- edit_draw->draw_line(from, from + line,Color(0.97, 0.2, 0.2),2);
- from += line*2;
+ edit_draw->draw_line(from, from + line, Color(0.97, 0.2, 0.2), 2);
+ from += line * 2;
}
}
-void TextureRegionEditor::_region_draw()
-{
+void TextureRegionEditor::_region_draw() {
Ref<Texture> base_tex = NULL;
- if(node_sprite)
+ if (node_sprite)
base_tex = node_sprite->get_texture();
- else if(node_patch9)
+ else if (node_patch9)
base_tex = node_patch9->get_texture();
- else if(obj_styleBox.is_valid())
+ else if (obj_styleBox.is_valid())
base_tex = obj_styleBox->get_texture();
- else if(atlas_tex.is_valid())
+ else if (atlas_tex.is_valid())
base_tex = atlas_tex->get_atlas();
if (base_tex.is_null())
return;
Transform2D mtx;
- mtx.elements[2]=-draw_ofs;
- mtx.scale_basis(Vector2(draw_zoom,draw_zoom));
+ mtx.elements[2] = -draw_ofs;
+ mtx.scale_basis(Vector2(draw_zoom, draw_zoom));
- VS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(),mtx);
- edit_draw->draw_texture(base_tex,Point2());
- VS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(),Transform2D());
+ VS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), mtx);
+ edit_draw->draw_texture(base_tex, Point2());
+ VS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), Transform2D());
if (snap_mode == SNAP_GRID) {
Size2 s = edit_draw->get_size();
int last_cell;
- if (snap_step.x!=0) {
+ if (snap_step.x != 0) {
if (snap_separation.x == 0)
- for(int i=0;i<s.width;i++) {
- int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i,0)).x-snap_offset.x)/snap_step.x));
- if (i==0)
- last_cell=cell;
- if (last_cell!=cell)
- edit_draw->draw_line(Point2(i,0),Point2(i,s.height),Color(0.3,0.7,1,0.3));
- last_cell=cell;
+ for (int i = 0; i < s.width; i++) {
+ int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i, 0)).x - snap_offset.x) / snap_step.x));
+ if (i == 0)
+ last_cell = cell;
+ if (last_cell != cell)
+ edit_draw->draw_line(Point2(i, 0), Point2(i, s.height), Color(0.3, 0.7, 1, 0.3));
+ last_cell = cell;
}
else
- for(int i=0;i<s.width;i++) {
- int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i,0)).x-snap_offset.x)/(snap_step.x+snap_separation.x)));
- if (i==0)
- last_cell=cell;
- if (last_cell!=cell)
- edit_draw->draw_rect(Rect2(i-snap_separation.x*draw_zoom,0,snap_separation.x*draw_zoom,s.height),Color(0.3,0.7,1,0.3));
- last_cell=cell;
+ for (int i = 0; i < s.width; i++) {
+ int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(i, 0)).x - snap_offset.x) / (snap_step.x + snap_separation.x)));
+ if (i == 0)
+ last_cell = cell;
+ if (last_cell != cell)
+ edit_draw->draw_rect(Rect2(i - snap_separation.x * draw_zoom, 0, snap_separation.x * draw_zoom, s.height), Color(0.3, 0.7, 1, 0.3));
+ last_cell = cell;
}
}
- if (snap_step.y!=0) {
+ if (snap_step.y != 0) {
if (snap_separation.y == 0)
- for(int i=0;i<s.height;i++) {
- int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0,i)).y-snap_offset.y)/snap_step.y));
- if (i==0)
- last_cell=cell;
- if (last_cell!=cell)
- edit_draw->draw_line(Point2(0,i),Point2(s.width,i),Color(0.3,0.7,1,0.3));
- last_cell=cell;
+ for (int i = 0; i < s.height; i++) {
+ int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0, i)).y - snap_offset.y) / snap_step.y));
+ if (i == 0)
+ last_cell = cell;
+ if (last_cell != cell)
+ edit_draw->draw_line(Point2(0, i), Point2(s.width, i), Color(0.3, 0.7, 1, 0.3));
+ last_cell = cell;
}
else
- for(int i=0;i<s.height;i++) {
- int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0,i)).y-snap_offset.y)/(snap_step.y+snap_separation.y)));
- if (i==0)
- last_cell=cell;
- if (last_cell!=cell)
- edit_draw->draw_rect(Rect2(0,i-snap_separation.y*draw_zoom,s.width,snap_separation.y*draw_zoom),Color(0.3,0.7,1,0.3));
- last_cell=cell;
+ for (int i = 0; i < s.height; i++) {
+ int cell = Math::fast_ftoi(Math::floor((mtx.affine_inverse().xform(Vector2(0, i)).y - snap_offset.y) / (snap_step.y + snap_separation.y)));
+ if (i == 0)
+ last_cell = cell;
+ if (last_cell != cell)
+ edit_draw->draw_rect(Rect2(0, i - snap_separation.y * draw_zoom, s.width, snap_separation.y * draw_zoom), Color(0.3, 0.7, 1, 0.3));
+ last_cell = cell;
}
}
} else if (snap_mode == SNAP_AUTOSLICE) {
- for (List<Rect2>::Element *E = autoslice_cache.front();E;E=E->next()) {
+ for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) {
Rect2 r = E->get();
- Vector2 endpoints[4]={
+ Vector2 endpoints[4] = {
mtx.basis_xform(r.pos),
- mtx.basis_xform(r.pos+Vector2(r.size.x,0)),
- mtx.basis_xform(r.pos+r.size),
- mtx.basis_xform(r.pos+Vector2(0,r.size.y))
+ mtx.basis_xform(r.pos + Vector2(r.size.x, 0)),
+ mtx.basis_xform(r.pos + r.size),
+ mtx.basis_xform(r.pos + Vector2(0, r.size.y))
};
- for(int i=0;i<4;i++) {
- int next = (i+1)%4;
- edit_draw->draw_line(endpoints[i]-draw_ofs, endpoints[next]-draw_ofs, Color(0.3,0.7,1,1) , 2);
+ for (int i = 0; i < 4; i++) {
+ int next = (i + 1) % 4;
+ edit_draw->draw_line(endpoints[i] - draw_ofs, endpoints[next] - draw_ofs, Color(0.3, 0.7, 1, 1), 2);
}
}
}
- Ref<Texture> select_handle = get_icon("EditorHandle","EditorIcons");
+ Ref<Texture> select_handle = get_icon("EditorHandle", "EditorIcons");
- Rect2 scroll_rect(Point2(),mtx.basis_xform(base_tex->get_size()));
+ Rect2 scroll_rect(Point2(), mtx.basis_xform(base_tex->get_size()));
scroll_rect.expand_to(mtx.basis_xform(edit_draw->get_size()));
- Vector2 endpoints[4]={
+ Vector2 endpoints[4] = {
mtx.basis_xform(rect.pos),
- mtx.basis_xform(rect.pos+Vector2(rect.size.x,0)),
- mtx.basis_xform(rect.pos+rect.size),
- mtx.basis_xform(rect.pos+Vector2(0,rect.size.y))
+ mtx.basis_xform(rect.pos + Vector2(rect.size.x, 0)),
+ mtx.basis_xform(rect.pos + rect.size),
+ mtx.basis_xform(rect.pos + Vector2(0, rect.size.y))
};
- Color color(0.9,0.5,0.5);
- for(int i=0;i<4;i++) {
+ Color color(0.9, 0.5, 0.5);
+ for (int i = 0; i < 4; i++) {
- int prev = (i+3)%4;
- int next = (i+1)%4;
+ int prev = (i + 3) % 4;
+ int next = (i + 1) % 4;
Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized();
- ofs*=1.4144*(select_handle->get_size().width/2);
+ ofs *= 1.4144 * (select_handle->get_size().width / 2);
- edit_draw->draw_line(endpoints[i]-draw_ofs, endpoints[next]-draw_ofs, color , 2);
+ edit_draw->draw_line(endpoints[i] - draw_ofs, endpoints[next] - draw_ofs, color, 2);
if (snap_mode != SNAP_AUTOSLICE)
- edit_draw->draw_texture(select_handle,(endpoints[i]+ofs-(select_handle->get_size()/2)).floor()-draw_ofs);
+ edit_draw->draw_texture(select_handle, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor() - draw_ofs);
- ofs = (endpoints[next]-endpoints[i])/2;
- ofs += (endpoints[next]-endpoints[i]).tangent().normalized()*(select_handle->get_size().width/2);
+ ofs = (endpoints[next] - endpoints[i]) / 2;
+ ofs += (endpoints[next] - endpoints[i]).tangent().normalized() * (select_handle->get_size().width / 2);
if (snap_mode != SNAP_AUTOSLICE)
- edit_draw->draw_texture(select_handle,(endpoints[i]+ofs-(select_handle->get_size()/2)).floor()-draw_ofs);
+ edit_draw->draw_texture(select_handle, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor() - draw_ofs);
scroll_rect.expand_to(endpoints[i]);
}
- scroll_rect=scroll_rect.grow(200);
- updating_scroll=true;
+ scroll_rect = scroll_rect.grow(200);
+ updating_scroll = true;
hscroll->set_min(scroll_rect.pos.x);
- hscroll->set_max(scroll_rect.pos.x+scroll_rect.size.x);
+ hscroll->set_max(scroll_rect.pos.x + scroll_rect.size.x);
hscroll->set_page(edit_draw->get_size().x);
hscroll->set_value(draw_ofs.x);
hscroll->set_step(0.001);
vscroll->set_min(scroll_rect.pos.y);
- vscroll->set_max(scroll_rect.pos.y+scroll_rect.size.y);
+ vscroll->set_max(scroll_rect.pos.y + scroll_rect.size.y);
vscroll->set_page(edit_draw->get_size().y);
vscroll->set_value(draw_ofs.y);
vscroll->set_step(0.001);
- updating_scroll=false;
+ updating_scroll = false;
float margins[4];
if (node_patch9 || obj_styleBox.is_valid()) {
@@ -189,40 +188,40 @@ void TextureRegionEditor::_region_draw()
margins[3] = obj_styleBox->get_margin_size(MARGIN_RIGHT);
}
Vector2 pos[4] = {
- mtx.basis_xform(Vector2(0,margins[0]))+Vector2(0,endpoints[0].y-draw_ofs.y),
- -mtx.basis_xform(Vector2(0,margins[1]))+Vector2(0,endpoints[2].y-draw_ofs.y),
- mtx.basis_xform(Vector2(margins[2],0))+Vector2(endpoints[0].x-draw_ofs.x,0),
- -mtx.basis_xform(Vector2(margins[3],0))+Vector2(endpoints[2].x-draw_ofs.x,0)};
-
- draw_margin_line(edit_draw,pos[0],pos[0]+Vector2(edit_draw->get_size().x,0));
- draw_margin_line(edit_draw,pos[1],pos[1]+Vector2(edit_draw->get_size().x,0));
- draw_margin_line(edit_draw,pos[2],pos[2]+Vector2(0,edit_draw->get_size().y));
- draw_margin_line(edit_draw,pos[3],pos[3]+Vector2(0,edit_draw->get_size().y));
+ mtx.basis_xform(Vector2(0, margins[0])) + Vector2(0, endpoints[0].y - draw_ofs.y),
+ -mtx.basis_xform(Vector2(0, margins[1])) + Vector2(0, endpoints[2].y - draw_ofs.y),
+ mtx.basis_xform(Vector2(margins[2], 0)) + Vector2(endpoints[0].x - draw_ofs.x, 0),
+ -mtx.basis_xform(Vector2(margins[3], 0)) + Vector2(endpoints[2].x - draw_ofs.x, 0)
+ };
+
+ draw_margin_line(edit_draw, pos[0], pos[0] + Vector2(edit_draw->get_size().x, 0));
+ draw_margin_line(edit_draw, pos[1], pos[1] + Vector2(edit_draw->get_size().x, 0));
+ draw_margin_line(edit_draw, pos[2], pos[2] + Vector2(0, edit_draw->get_size().y));
+ draw_margin_line(edit_draw, pos[3], pos[3] + Vector2(0, edit_draw->get_size().y));
}
}
-void TextureRegionEditor::_region_input(const InputEvent& p_input)
-{
+void TextureRegionEditor::_region_input(const InputEvent &p_input) {
Transform2D mtx;
- mtx.elements[2]=-draw_ofs;
- mtx.scale_basis(Vector2(draw_zoom,draw_zoom));
-
- Vector2 endpoints[8]={
- mtx.xform(rect.pos)+Vector2(-4,-4),
- mtx.xform(rect.pos+Vector2(rect.size.x/2,0))+Vector2(0,-4),
- mtx.xform(rect.pos+Vector2(rect.size.x,0))+Vector2(4,-4),
- mtx.xform(rect.pos+Vector2(rect.size.x,rect.size.y/2))+Vector2(4,0),
- mtx.xform(rect.pos+rect.size)+Vector2(4,4),
- mtx.xform(rect.pos+Vector2(rect.size.x/2,rect.size.y))+Vector2(0,4),
- mtx.xform(rect.pos+Vector2(0,rect.size.y))+Vector2(-4,4),
- mtx.xform(rect.pos+Vector2(0,rect.size.y/2))+Vector2(-4,0)
+ mtx.elements[2] = -draw_ofs;
+ mtx.scale_basis(Vector2(draw_zoom, draw_zoom));
+
+ Vector2 endpoints[8] = {
+ mtx.xform(rect.pos) + Vector2(-4, -4),
+ mtx.xform(rect.pos + Vector2(rect.size.x / 2, 0)) + Vector2(0, -4),
+ mtx.xform(rect.pos + Vector2(rect.size.x, 0)) + Vector2(4, -4),
+ mtx.xform(rect.pos + Vector2(rect.size.x, rect.size.y / 2)) + Vector2(4, 0),
+ mtx.xform(rect.pos + rect.size) + Vector2(4, 4),
+ mtx.xform(rect.pos + Vector2(rect.size.x / 2, rect.size.y)) + Vector2(0, 4),
+ mtx.xform(rect.pos + Vector2(0, rect.size.y)) + Vector2(-4, 4),
+ mtx.xform(rect.pos + Vector2(0, rect.size.y / 2)) + Vector2(-4, 0)
};
- if (p_input.type==InputEvent::MOUSE_BUTTON) {
+ if (p_input.type == InputEvent::MOUSE_BUTTON) {
- const InputEventMouseButton &mb=p_input.mouse_button;
+ const InputEventMouseButton &mb = p_input.mouse_button;
- if (mb.button_index==BUTTON_LEFT) {
+ if (mb.button_index == BUTTON_LEFT) {
if (mb.pressed) {
if (node_patch9 || obj_styleBox.is_valid()) {
@@ -240,10 +239,11 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input)
margins[3] = obj_styleBox->get_margin_size(MARGIN_RIGHT);
}
Vector2 pos[4] = {
- mtx.basis_xform(rect.pos+Vector2(0,margins[0]))-draw_ofs,
- mtx.basis_xform(rect.pos+rect.size-Vector2(0,margins[1]))-draw_ofs,
- mtx.basis_xform(rect.pos+Vector2(margins[2],0))-draw_ofs,
- mtx.basis_xform(rect.pos+rect.size-Vector2(margins[3],0))-draw_ofs};
+ mtx.basis_xform(rect.pos + Vector2(0, margins[0])) - draw_ofs,
+ mtx.basis_xform(rect.pos + rect.size - Vector2(0, margins[1])) - draw_ofs,
+ mtx.basis_xform(rect.pos + Vector2(margins[2], 0)) - draw_ofs,
+ mtx.basis_xform(rect.pos + rect.size - Vector2(margins[3], 0)) - draw_ofs
+ };
if (Math::abs(mb.y - pos[0].y) < 8) {
edited_margin = 0;
prev_margin = margins[0];
@@ -258,132 +258,130 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input)
prev_margin = margins[3];
}
if (edited_margin >= 0) {
- drag_from=Vector2(mb.x,mb.y);
- drag=true;
+ drag_from = Vector2(mb.x, mb.y);
+ drag = true;
}
}
- if ( edited_margin < 0 && snap_mode == SNAP_AUTOSLICE) {
- Vector2 point = mtx.affine_inverse().xform(Vector2(mb.x,mb.y));
- for (List<Rect2>::Element *E=autoslice_cache.front();E;E=E->next()) {
+ if (edited_margin < 0 && snap_mode == SNAP_AUTOSLICE) {
+ Vector2 point = mtx.affine_inverse().xform(Vector2(mb.x, mb.y));
+ for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) {
if (E->get().has_point(point)) {
rect = E->get();
- if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)&&!(Input::get_singleton()->is_key_pressed(KEY_SHIFT|KEY_ALT))) {
+ if (Input::get_singleton()->is_key_pressed(KEY_CONTROL) && !(Input::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) {
Rect2 r;
- if(node_sprite )
- r=node_sprite->get_region_rect();
- else if(node_patch9)
- r=node_patch9->get_region_rect();
- else if(obj_styleBox.is_valid())
- r=obj_styleBox->get_region_rect();
- else if(atlas_tex.is_valid())
- r =atlas_tex->get_region();
+ if (node_sprite)
+ r = node_sprite->get_region_rect();
+ else if (node_patch9)
+ r = node_patch9->get_region_rect();
+ else if (obj_styleBox.is_valid())
+ r = obj_styleBox->get_region_rect();
+ else if (atlas_tex.is_valid())
+ r = atlas_tex->get_region();
rect.expand_to(r.pos);
- rect.expand_to(r.pos+r.size);
+ rect.expand_to(r.pos + r.size);
}
undo_redo->create_action("Set Region Rect");
- if(node_sprite){
- undo_redo->add_do_method(node_sprite ,"set_region_rect",rect);
- undo_redo->add_undo_method(node_sprite,"set_region_rect",node_sprite->get_region_rect());
- } else if(node_patch9){
- undo_redo->add_do_method(node_patch9 ,"set_region_rect",rect);
- undo_redo->add_undo_method(node_patch9,"set_region_rect",node_patch9->get_region_rect());
+ if (node_sprite) {
+ undo_redo->add_do_method(node_sprite, "set_region_rect", rect);
+ undo_redo->add_undo_method(node_sprite, "set_region_rect", node_sprite->get_region_rect());
+ } else if (node_patch9) {
+ undo_redo->add_do_method(node_patch9, "set_region_rect", rect);
+ undo_redo->add_undo_method(node_patch9, "set_region_rect", node_patch9->get_region_rect());
} else if (obj_styleBox.is_valid()) {
- undo_redo->add_do_method(obj_styleBox.ptr(),"set_region_rect",rect);
- undo_redo->add_undo_method(obj_styleBox.ptr(),"set_region_rect",obj_styleBox->get_region_rect());
+ undo_redo->add_do_method(obj_styleBox.ptr(), "set_region_rect", rect);
+ undo_redo->add_undo_method(obj_styleBox.ptr(), "set_region_rect", obj_styleBox->get_region_rect());
} else if (atlas_tex.is_valid()) {
- undo_redo->add_do_method(atlas_tex.ptr(),"set_region",rect);
- undo_redo->add_undo_method(atlas_tex.ptr(),"set_region",atlas_tex->get_region());
+ undo_redo->add_do_method(atlas_tex.ptr(), "set_region", rect);
+ undo_redo->add_undo_method(atlas_tex.ptr(), "set_region", atlas_tex->get_region());
}
- undo_redo->add_do_method(edit_draw,"update");
- undo_redo->add_undo_method(edit_draw,"update");
+ undo_redo->add_do_method(edit_draw, "update");
+ undo_redo->add_undo_method(edit_draw, "update");
undo_redo->commit_action();
break;
}
}
} else if (edited_margin < 0) {
- drag_from=mtx.affine_inverse().xform(Vector2(mb.x,mb.y));
+ drag_from = mtx.affine_inverse().xform(Vector2(mb.x, mb.y));
if (snap_mode == SNAP_PIXEL)
- drag_from = drag_from.snapped(Vector2(1,1));
+ drag_from = drag_from.snapped(Vector2(1, 1));
else if (snap_mode == SNAP_GRID)
- drag_from=snap_point(drag_from);
- drag=true;
- if(node_sprite )
- rect_prev=node_sprite->get_region_rect();
- else if(node_patch9)
- rect_prev=node_patch9->get_region_rect();
- else if(obj_styleBox.is_valid())
- rect_prev=obj_styleBox->get_region_rect();
- else if(atlas_tex.is_valid())
- rect_prev=atlas_tex->get_region();
-
- for (int i=0; i<8;i++) {
- Vector2 tuv=endpoints[i];
- if (tuv.distance_to(Vector2(mb.x,mb.y))<8) {
- drag_index=i;
+ drag_from = snap_point(drag_from);
+ drag = true;
+ if (node_sprite)
+ rect_prev = node_sprite->get_region_rect();
+ else if (node_patch9)
+ rect_prev = node_patch9->get_region_rect();
+ else if (obj_styleBox.is_valid())
+ rect_prev = obj_styleBox->get_region_rect();
+ else if (atlas_tex.is_valid())
+ rect_prev = atlas_tex->get_region();
+
+ for (int i = 0; i < 8; i++) {
+ Vector2 tuv = endpoints[i];
+ if (tuv.distance_to(Vector2(mb.x, mb.y)) < 8) {
+ drag_index = i;
}
}
- if (drag_index==-1) {
+ if (drag_index == -1) {
creating = true;
- rect = Rect2(drag_from,Size2());
+ rect = Rect2(drag_from, Size2());
}
}
} else if (drag) {
if (edited_margin >= 0) {
undo_redo->create_action("Set Margin");
- static Margin m[4] = {MARGIN_TOP,MARGIN_BOTTOM,MARGIN_LEFT,MARGIN_RIGHT};
+ static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
if (node_patch9) {
- undo_redo->add_do_method(node_patch9 ,"set_patch_margin",m[edited_margin],node_patch9->get_patch_margin(m[edited_margin]));
- undo_redo->add_undo_method(node_patch9,"set_patch_margin",m[edited_margin],prev_margin);
+ undo_redo->add_do_method(node_patch9, "set_patch_margin", m[edited_margin], node_patch9->get_patch_margin(m[edited_margin]));
+ undo_redo->add_undo_method(node_patch9, "set_patch_margin", m[edited_margin], prev_margin);
} else if (obj_styleBox.is_valid()) {
- undo_redo->add_do_method(obj_styleBox.ptr() ,"set_margin_size",m[edited_margin],obj_styleBox->get_margin_size(m[edited_margin]));
- undo_redo->add_undo_method(obj_styleBox.ptr(),"set_margin_size",m[edited_margin],prev_margin);
+ undo_redo->add_do_method(obj_styleBox.ptr(), "set_margin_size", m[edited_margin], obj_styleBox->get_margin_size(m[edited_margin]));
+ undo_redo->add_undo_method(obj_styleBox.ptr(), "set_margin_size", m[edited_margin], prev_margin);
obj_styleBox->emit_signal(CoreStringNames::get_singleton()->changed);
}
edited_margin = -1;
} else {
undo_redo->create_action("Set Region Rect");
- if(node_sprite){
- undo_redo->add_do_method(node_sprite ,"set_region_rect",node_sprite->get_region_rect());
- undo_redo->add_undo_method(node_sprite,"set_region_rect",rect_prev);
- }
- else if(atlas_tex.is_valid()){
- undo_redo->add_do_method(atlas_tex.ptr() ,"set_region",atlas_tex->get_region());
- undo_redo->add_undo_method(atlas_tex.ptr(),"set_region",rect_prev);
- }
- else if(node_patch9){
+ if (node_sprite) {
+ undo_redo->add_do_method(node_sprite, "set_region_rect", node_sprite->get_region_rect());
+ undo_redo->add_undo_method(node_sprite, "set_region_rect", rect_prev);
+ } else if (atlas_tex.is_valid()) {
+ undo_redo->add_do_method(atlas_tex.ptr(), "set_region", atlas_tex->get_region());
+ undo_redo->add_undo_method(atlas_tex.ptr(), "set_region", rect_prev);
+ } else if (node_patch9) {
// FIXME: Is this intentional?
- } else if(node_patch9){
- undo_redo->add_do_method(node_patch9 ,"set_region_rect",node_patch9->get_region_rect());
- undo_redo->add_undo_method(node_patch9,"set_region_rect",rect_prev);
+ } else if (node_patch9) {
+ undo_redo->add_do_method(node_patch9, "set_region_rect", node_patch9->get_region_rect());
+ undo_redo->add_undo_method(node_patch9, "set_region_rect", rect_prev);
} else if (obj_styleBox.is_valid()) {
- undo_redo->add_do_method(obj_styleBox.ptr() ,"set_region_rect",obj_styleBox->get_region_rect());
- undo_redo->add_undo_method(obj_styleBox.ptr(),"set_region_rect",rect_prev);
+ undo_redo->add_do_method(obj_styleBox.ptr(), "set_region_rect", obj_styleBox->get_region_rect());
+ undo_redo->add_undo_method(obj_styleBox.ptr(), "set_region_rect", rect_prev);
}
drag_index = -1;
}
- undo_redo->add_do_method(edit_draw,"update");
- undo_redo->add_undo_method(edit_draw,"update");
+ undo_redo->add_do_method(edit_draw, "update");
+ undo_redo->add_undo_method(edit_draw, "update");
undo_redo->commit_action();
- drag=false;
+ drag = false;
creating = false;
}
- } else if (mb.button_index==BUTTON_RIGHT && mb.pressed) {
+ } else if (mb.button_index == BUTTON_RIGHT && mb.pressed) {
if (drag) {
- drag=false;
+ drag = false;
if (edited_margin >= 0) {
- static Margin m[4] = {MARGIN_TOP,MARGIN_BOTTOM,MARGIN_LEFT,MARGIN_RIGHT};
+ static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
if (node_patch9)
- node_patch9->set_patch_margin(m[edited_margin],prev_margin);
+ node_patch9->set_patch_margin(m[edited_margin], prev_margin);
if (obj_styleBox.is_valid())
- obj_styleBox->set_margin_size(m[edited_margin],prev_margin);
+ obj_styleBox->set_margin_size(m[edited_margin], prev_margin);
edited_margin = -1;
} else {
apply_rect(rect_prev);
- rect=rect_prev;
+ rect = rect_prev;
edit_draw->update();
drag_index = -1;
}
@@ -393,124 +391,120 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input)
} else if (mb.button_index == BUTTON_WHEEL_DOWN && mb.pressed) {
_zoom_out();
}
- } else if (p_input.type==InputEvent::MOUSE_MOTION) {
+ } else if (p_input.type == InputEvent::MOUSE_MOTION) {
- const InputEventMouseMotion &mm=p_input.mouse_motion;
+ const InputEventMouseMotion &mm = p_input.mouse_motion;
- if (mm.button_mask&BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
+ if (mm.button_mask & BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
- Vector2 draged(mm.relative_x,mm.relative_y);
- hscroll->set_value( hscroll->get_value()-draged.x );
- vscroll->set_value( vscroll->get_value()-draged.y );
+ Vector2 draged(mm.relative_x, mm.relative_y);
+ hscroll->set_value(hscroll->get_value() - draged.x);
+ vscroll->set_value(vscroll->get_value() - draged.y);
} else if (drag) {
if (edited_margin >= 0) {
float new_margin;
if (edited_margin == 0)
- new_margin = prev_margin + (mm.y-drag_from.y) / draw_zoom;
+ new_margin = prev_margin + (mm.y - drag_from.y) / draw_zoom;
else if (edited_margin == 1)
- new_margin = prev_margin - (mm.y-drag_from.y) / draw_zoom;
+ new_margin = prev_margin - (mm.y - drag_from.y) / draw_zoom;
else if (edited_margin == 2)
- new_margin = prev_margin + (mm.x-drag_from.x) / draw_zoom;
+ new_margin = prev_margin + (mm.x - drag_from.x) / draw_zoom;
else if (edited_margin == 3)
- new_margin = prev_margin - (mm.x-drag_from.x) / draw_zoom;
+ new_margin = prev_margin - (mm.x - drag_from.x) / draw_zoom;
if (new_margin < 0)
new_margin = 0;
- static Margin m[4] = {MARGIN_TOP,MARGIN_BOTTOM,MARGIN_LEFT,MARGIN_RIGHT};
+ static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
if (node_patch9)
- node_patch9->set_patch_margin(m[edited_margin],new_margin);
+ node_patch9->set_patch_margin(m[edited_margin], new_margin);
if (obj_styleBox.is_valid())
- obj_styleBox->set_margin_size(m[edited_margin],new_margin);
+ obj_styleBox->set_margin_size(m[edited_margin], new_margin);
} else {
- Vector2 new_pos = mtx.affine_inverse().xform(Vector2(mm.x,mm.y));
+ Vector2 new_pos = mtx.affine_inverse().xform(Vector2(mm.x, mm.y));
if (snap_mode == SNAP_PIXEL)
- new_pos = new_pos.snapped(Vector2(1,1));
+ new_pos = new_pos.snapped(Vector2(1, 1));
else if (snap_mode == SNAP_GRID)
- new_pos=snap_point(new_pos);
+ new_pos = snap_point(new_pos);
if (creating) {
- rect = Rect2(drag_from,Size2());
+ rect = Rect2(drag_from, Size2());
rect.expand_to(new_pos);
apply_rect(rect);
edit_draw->update();
return;
}
- switch(drag_index) {
- case 0: {
- Vector2 p=rect_prev.pos+rect_prev.size;
- rect = Rect2(p,Size2());
+ switch (drag_index) {
+ case 0: {
+ Vector2 p = rect_prev.pos + rect_prev.size;
+ rect = Rect2(p, Size2());
rect.expand_to(new_pos);
apply_rect(rect);
} break;
- case 1: {
- Vector2 p=rect_prev.pos+Vector2(0,rect_prev.size.y);
- rect = Rect2(p,Size2(rect_prev.size.x,0));
+ case 1: {
+ Vector2 p = rect_prev.pos + Vector2(0, rect_prev.size.y);
+ rect = Rect2(p, Size2(rect_prev.size.x, 0));
rect.expand_to(new_pos);
apply_rect(rect);
} break;
- case 2: {
- Vector2 p=rect_prev.pos+Vector2(0,rect_prev.size.y);
- rect = Rect2(p,Size2());
+ case 2: {
+ Vector2 p = rect_prev.pos + Vector2(0, rect_prev.size.y);
+ rect = Rect2(p, Size2());
rect.expand_to(new_pos);
apply_rect(rect);
} break;
- case 3: {
- Vector2 p=rect_prev.pos;
- rect = Rect2(p,Size2(0,rect_prev.size.y));
+ case 3: {
+ Vector2 p = rect_prev.pos;
+ rect = Rect2(p, Size2(0, rect_prev.size.y));
rect.expand_to(new_pos);
apply_rect(rect);
} break;
- case 4: {
- Vector2 p=rect_prev.pos;
- rect = Rect2(p,Size2());
+ case 4: {
+ Vector2 p = rect_prev.pos;
+ rect = Rect2(p, Size2());
rect.expand_to(new_pos);
apply_rect(rect);
} break;
- case 5: {
- Vector2 p=rect_prev.pos;
- rect = Rect2(p,Size2(rect_prev.size.x,0));
+ case 5: {
+ Vector2 p = rect_prev.pos;
+ rect = Rect2(p, Size2(rect_prev.size.x, 0));
rect.expand_to(new_pos);
apply_rect(rect);
} break;
- case 6: {
- Vector2 p=rect_prev.pos+Vector2(rect_prev.size.x,0);
- rect = Rect2(p,Size2());
+ case 6: {
+ Vector2 p = rect_prev.pos + Vector2(rect_prev.size.x, 0);
+ rect = Rect2(p, Size2());
rect.expand_to(new_pos);
apply_rect(rect);
} break;
- case 7: {
- Vector2 p=rect_prev.pos+Vector2(rect_prev.size.x,0);
- rect = Rect2(p,Size2(0,rect_prev.size.y));
+ case 7: {
+ Vector2 p = rect_prev.pos + Vector2(rect_prev.size.x, 0);
+ rect = Rect2(p, Size2(0, rect_prev.size.y));
rect.expand_to(new_pos);
apply_rect(rect);
} break;
-
}
}
edit_draw->update();
}
-
}
}
-void TextureRegionEditor::_scroll_changed(float)
-{
+void TextureRegionEditor::_scroll_changed(float) {
if (updating_scroll)
return;
- draw_ofs.x=hscroll->get_value();
- draw_ofs.y=vscroll->get_value();
+ draw_ofs.x = hscroll->get_value();
+ draw_ofs.y = vscroll->get_value();
edit_draw->update();
}
-void TextureRegionEditor::_set_snap_mode(int p_mode)
-{
- snap_mode_button->get_popup()->set_item_checked(snap_mode,false);
+void TextureRegionEditor::_set_snap_mode(int p_mode) {
+ snap_mode_button->get_popup()->set_item_checked(snap_mode, false);
snap_mode = p_mode;
snap_mode_button->set_text(snap_mode_button->get_popup()->get_item_text(p_mode));
- snap_mode_button->get_popup()->set_item_checked(snap_mode,true);
+ snap_mode_button->get_popup()->set_item_checked(snap_mode, true);
if (snap_mode == SNAP_GRID)
hb_grid->show();
@@ -520,91 +514,80 @@ void TextureRegionEditor::_set_snap_mode(int p_mode)
edit_draw->update();
}
-void TextureRegionEditor::_set_snap_off_x(float p_val)
-{
- snap_offset.x=p_val;
+void TextureRegionEditor::_set_snap_off_x(float p_val) {
+ snap_offset.x = p_val;
edit_draw->update();
}
-void TextureRegionEditor::_set_snap_off_y(float p_val)
-{
- snap_offset.y=p_val;
+void TextureRegionEditor::_set_snap_off_y(float p_val) {
+ snap_offset.y = p_val;
edit_draw->update();
}
-void TextureRegionEditor::_set_snap_step_x(float p_val)
-{
- snap_step.x=p_val;
+void TextureRegionEditor::_set_snap_step_x(float p_val) {
+ snap_step.x = p_val;
edit_draw->update();
}
-void TextureRegionEditor::_set_snap_step_y(float p_val)
-{
- snap_step.y=p_val;
+void TextureRegionEditor::_set_snap_step_y(float p_val) {
+ snap_step.y = p_val;
edit_draw->update();
}
-void TextureRegionEditor::_set_snap_sep_x(float p_val)
-{
+void TextureRegionEditor::_set_snap_sep_x(float p_val) {
snap_separation.x = p_val;
edit_draw->update();
}
-void TextureRegionEditor::_set_snap_sep_y(float p_val)
-{
+void TextureRegionEditor::_set_snap_sep_y(float p_val) {
snap_separation.y = p_val;
edit_draw->update();
}
-void TextureRegionEditor::_zoom_in()
-{
+void TextureRegionEditor::_zoom_in() {
if (draw_zoom < 8) {
draw_zoom *= 2;
edit_draw->update();
}
}
-void TextureRegionEditor::_zoom_reset()
-{
+void TextureRegionEditor::_zoom_reset() {
if (draw_zoom == 1) return;
draw_zoom = 1;
edit_draw->update();
}
-void TextureRegionEditor::_zoom_out()
-{
+void TextureRegionEditor::_zoom_out() {
if (draw_zoom > 0.25) {
draw_zoom /= 2;
edit_draw->update();
}
}
-void TextureRegionEditor::apply_rect(const Rect2& rect){
- if(node_sprite)
+void TextureRegionEditor::apply_rect(const Rect2 &rect) {
+ if (node_sprite)
node_sprite->set_region_rect(rect);
- else if(node_patch9)
+ else if (node_patch9)
node_patch9->set_region_rect(rect);
- else if(obj_styleBox.is_valid())
+ else if (obj_styleBox.is_valid())
obj_styleBox->set_region_rect(rect);
- else if(atlas_tex.is_valid())
+ else if (atlas_tex.is_valid())
atlas_tex->set_region(rect);
}
-void TextureRegionEditor::_notification(int p_what)
-{
- switch(p_what) {
- case NOTIFICATION_READY: {
+void TextureRegionEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_READY: {
zoom_out->set_icon(get_icon("ZoomLess", "EditorIcons"));
zoom_reset->set_icon(get_icon("ZoomReset", "EditorIcons"));
zoom_in->set_icon(get_icon("ZoomMore", "EditorIcons"));
- icon_zoom->set_texture( get_icon("Zoom", "EditorIcons"));
+ icon_zoom->set_texture(get_icon("Zoom", "EditorIcons"));
} break;
}
}
-void TextureRegionEditor::_node_removed(Object *p_obj)
-{
- if(p_obj == node_sprite || p_obj == node_patch9 || p_obj == obj_styleBox.ptr() || p_obj == atlas_tex.ptr()) {
+void TextureRegionEditor::_node_removed(Object *p_obj) {
+ if (p_obj == node_sprite || p_obj == node_patch9 || p_obj == obj_styleBox.ptr() || p_obj == atlas_tex.ptr()) {
node_patch9 = NULL;
node_sprite = NULL;
obj_styleBox = Ref<StyleBox>(NULL);
@@ -613,35 +596,33 @@ void TextureRegionEditor::_node_removed(Object *p_obj)
}
}
-void TextureRegionEditor::_bind_methods()
-{
- ClassDB::bind_method(D_METHOD("_edit_region"),&TextureRegionEditor::_edit_region);
- ClassDB::bind_method(D_METHOD("_region_draw"),&TextureRegionEditor::_region_draw);
- ClassDB::bind_method(D_METHOD("_region_input"),&TextureRegionEditor::_region_input);
- ClassDB::bind_method(D_METHOD("_scroll_changed"),&TextureRegionEditor::_scroll_changed);
- ClassDB::bind_method(D_METHOD("_node_removed"),&TextureRegionEditor::_node_removed);
- ClassDB::bind_method(D_METHOD("_set_snap_mode"),&TextureRegionEditor::_set_snap_mode);
- ClassDB::bind_method(D_METHOD("_set_snap_off_x"),&TextureRegionEditor::_set_snap_off_x);
- ClassDB::bind_method(D_METHOD("_set_snap_off_y"),&TextureRegionEditor::_set_snap_off_y);
- ClassDB::bind_method(D_METHOD("_set_snap_step_x"),&TextureRegionEditor::_set_snap_step_x);
- ClassDB::bind_method(D_METHOD("_set_snap_step_y"),&TextureRegionEditor::_set_snap_step_y);
- ClassDB::bind_method(D_METHOD("_set_snap_sep_x"),&TextureRegionEditor::_set_snap_sep_x);
- ClassDB::bind_method(D_METHOD("_set_snap_sep_y"),&TextureRegionEditor::_set_snap_sep_y);
- ClassDB::bind_method(D_METHOD("_zoom_in"),&TextureRegionEditor::_zoom_in);
- ClassDB::bind_method(D_METHOD("_zoom_reset"),&TextureRegionEditor::_zoom_reset);
- ClassDB::bind_method(D_METHOD("_zoom_out"),&TextureRegionEditor::_zoom_out);
+void TextureRegionEditor::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_edit_region"), &TextureRegionEditor::_edit_region);
+ ClassDB::bind_method(D_METHOD("_region_draw"), &TextureRegionEditor::_region_draw);
+ ClassDB::bind_method(D_METHOD("_region_input"), &TextureRegionEditor::_region_input);
+ ClassDB::bind_method(D_METHOD("_scroll_changed"), &TextureRegionEditor::_scroll_changed);
+ ClassDB::bind_method(D_METHOD("_node_removed"), &TextureRegionEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_set_snap_mode"), &TextureRegionEditor::_set_snap_mode);
+ ClassDB::bind_method(D_METHOD("_set_snap_off_x"), &TextureRegionEditor::_set_snap_off_x);
+ ClassDB::bind_method(D_METHOD("_set_snap_off_y"), &TextureRegionEditor::_set_snap_off_y);
+ ClassDB::bind_method(D_METHOD("_set_snap_step_x"), &TextureRegionEditor::_set_snap_step_x);
+ ClassDB::bind_method(D_METHOD("_set_snap_step_y"), &TextureRegionEditor::_set_snap_step_y);
+ ClassDB::bind_method(D_METHOD("_set_snap_sep_x"), &TextureRegionEditor::_set_snap_sep_x);
+ ClassDB::bind_method(D_METHOD("_set_snap_sep_y"), &TextureRegionEditor::_set_snap_sep_y);
+ ClassDB::bind_method(D_METHOD("_zoom_in"), &TextureRegionEditor::_zoom_in);
+ ClassDB::bind_method(D_METHOD("_zoom_reset"), &TextureRegionEditor::_zoom_reset);
+ ClassDB::bind_method(D_METHOD("_zoom_out"), &TextureRegionEditor::_zoom_out);
}
-void TextureRegionEditor::edit(Object *p_obj)
-{
- if (node_sprite && node_sprite->is_connected("texture_changed",this,"_edit_region"))
- node_sprite->disconnect("texture_changed",this,"_edit_region");
- if (node_patch9 && node_patch9->is_connected("texture_changed",this,"_edit_region"))
- node_patch9->disconnect("texture_changed",this,"_edit_region");
- if (obj_styleBox.is_valid() && obj_styleBox->is_connected("texture_changed",this,"_edit_region"))
- obj_styleBox->disconnect("texture_changed",this,"_edit_region");
- if (atlas_tex.is_valid() && atlas_tex->is_connected("atlas_changed",this,"_edit_region"))
- atlas_tex->disconnect("atlas_changed",this,"_edit_region");
+void TextureRegionEditor::edit(Object *p_obj) {
+ if (node_sprite && node_sprite->is_connected("texture_changed", this, "_edit_region"))
+ node_sprite->disconnect("texture_changed", this, "_edit_region");
+ if (node_patch9 && node_patch9->is_connected("texture_changed", this, "_edit_region"))
+ node_patch9->disconnect("texture_changed", this, "_edit_region");
+ if (obj_styleBox.is_valid() && obj_styleBox->is_connected("texture_changed", this, "_edit_region"))
+ obj_styleBox->disconnect("texture_changed", this, "_edit_region");
+ if (atlas_tex.is_valid() && atlas_tex->is_connected("atlas_changed", this, "_edit_region"))
+ atlas_tex->disconnect("atlas_changed", this, "_edit_region");
if (p_obj) {
node_sprite = p_obj->cast_to<Sprite>();
node_patch9 = p_obj->cast_to<NinePatchRect>();
@@ -649,22 +630,22 @@ void TextureRegionEditor::edit(Object *p_obj)
obj_styleBox = Ref<StyleBoxTexture>(p_obj->cast_to<StyleBoxTexture>());
if (p_obj->cast_to<AtlasTexture>()) {
atlas_tex = Ref<AtlasTexture>(p_obj->cast_to<AtlasTexture>());
- atlas_tex->connect("atlas_changed",this,"_edit_region");
+ atlas_tex->connect("atlas_changed", this, "_edit_region");
} else {
- p_obj->connect("texture_changed",this,"_edit_region");
+ p_obj->connect("texture_changed", this, "_edit_region");
}
p_obj->add_change_receptor(this);
- p_obj->connect("tree_exited",this,"_node_removed",varray(p_obj),CONNECT_ONESHOT);
+ p_obj->connect("tree_exited", this, "_node_removed", varray(p_obj), CONNECT_ONESHOT);
_edit_region();
} else {
- if(node_sprite)
- node_sprite->disconnect("tree_exited",this,"_node_removed");
- else if(node_patch9)
- node_patch9->disconnect("tree_exited",this,"_node_removed");
- else if(obj_styleBox.is_valid())
- obj_styleBox->disconnect("tree_exited",this,"_node_removed");
- else if(atlas_tex.is_valid())
- atlas_tex->disconnect("tree_exited",this,"_node_removed");
+ if (node_sprite)
+ node_sprite->disconnect("tree_exited", this, "_node_removed");
+ else if (node_patch9)
+ node_patch9->disconnect("tree_exited", this, "_node_removed");
+ else if (obj_styleBox.is_valid())
+ obj_styleBox->disconnect("tree_exited", this, "_node_removed");
+ else if (atlas_tex.is_valid())
+ atlas_tex->disconnect("tree_exited", this, "_node_removed");
node_sprite = NULL;
node_patch9 = NULL;
@@ -680,16 +661,15 @@ void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_pro
}
}
-void TextureRegionEditor::_edit_region()
-{
+void TextureRegionEditor::_edit_region() {
Ref<Texture> texture = NULL;
- if(node_sprite )
+ if (node_sprite)
texture = node_sprite->get_texture();
- else if(node_patch9 )
+ else if (node_patch9)
texture = node_patch9->get_texture();
- else if(obj_styleBox.is_valid())
+ else if (obj_styleBox.is_valid())
texture = obj_styleBox->get_texture();
- else if(atlas_tex.is_valid())
+ else if (atlas_tex.is_valid())
texture = atlas_tex->get_atlas();
if (texture.is_null()) {
@@ -703,30 +683,30 @@ void TextureRegionEditor::_edit_region()
bm.create_from_image_alpha(i);
for (int y = 0; y < i.get_height(); y++) {
for (int x = 0; x < i.get_width(); x++) {
- if (bm.get_bit(Point2(x,y))) {
+ if (bm.get_bit(Point2(x, y))) {
bool found = false;
- for (List<Rect2>::Element *E = autoslice_cache.front(); E; E=E->next()) {
+ for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) {
Rect2 grown = E->get().grow(1.5);
- if (grown.has_point(Point2(x,y))) {
- E->get().expand_to(Point2(x,y));
- E->get().expand_to(Point2(x+1,y+1));
- x = E->get().pos.x+E->get().size.x-1;
+ if (grown.has_point(Point2(x, y))) {
+ E->get().expand_to(Point2(x, y));
+ E->get().expand_to(Point2(x + 1, y + 1));
+ x = E->get().pos.x + E->get().size.x - 1;
bool merged = true;
while (merged) {
merged = false;
bool queue_erase = false;
- for (List<Rect2>::Element *F = autoslice_cache.front(); F; F=F->next()) {
- if (queue_erase){
+ for (List<Rect2>::Element *F = autoslice_cache.front(); F; F = F->next()) {
+ if (queue_erase) {
autoslice_cache.erase(F->prev());
queue_erase = false;
}
- if (F==E)
+ if (F == E)
continue;
if (E->get().grow(1).intersects(F->get())) {
E->get().expand_to(F->get().pos);
- E->get().expand_to(F->get().pos+F->get().size);
+ E->get().expand_to(F->get().pos + F->get().size);
if (F->prev()) {
- F=F->prev();
+ F = F->prev();
autoslice_cache.erase(F->next());
} else {
queue_erase = true;
@@ -741,7 +721,7 @@ void TextureRegionEditor::_edit_region()
}
}
if (!found) {
- Rect2 new_rect(x,y,1,1);
+ Rect2 new_rect(x, y, 1, 1);
autoslice_cache.push_back(new_rect);
}
}
@@ -749,12 +729,11 @@ void TextureRegionEditor::_edit_region()
}
}
-
- if(node_sprite )
+ if (node_sprite)
rect = node_sprite->get_region_rect();
- else if(node_patch9 )
+ else if (node_patch9)
rect = node_patch9->get_region_rect();
- else if(obj_styleBox.is_valid())
+ else if (obj_styleBox.is_valid())
rect = obj_styleBox->get_region_rect();
else if (atlas_tex.is_valid())
rect = atlas_tex->get_region();
@@ -764,13 +743,13 @@ void TextureRegionEditor::_edit_region()
inline float _snap_scalar(float p_offset, float p_step, float separation, float p_target) {
if (p_step != 0) {
- float a = Math::stepify(p_target - p_offset, p_step+separation) + p_offset;
+ float a = Math::stepify(p_target - p_offset, p_step + separation) + p_offset;
float b = a;
if (p_target >= 0)
b -= separation;
else
b += p_step;
- return (Math::abs(p_target-a) < Math::abs(p_target-b)) ? a : b;
+ return (Math::abs(p_target - a) < Math::abs(p_target - b)) ? a : b;
}
return p_target;
}
@@ -784,48 +763,47 @@ Vector2 TextureRegionEditor::snap_point(Vector2 p_target) const {
return p_target;
}
-TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor)
-{
+TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
node_sprite = NULL;
node_patch9 = NULL;
obj_styleBox = Ref<StyleBoxTexture>(NULL);
atlas_tex = Ref<AtlasTexture>(NULL);
- editor=p_editor;
+ editor = p_editor;
undo_redo = editor->get_undo_redo();
- snap_step=Vector2(10,10);
- snap_separation = Vector2(0,0);
+ snap_step = Vector2(10, 10);
+ snap_separation = Vector2(0, 0);
edited_margin = -1;
drag_index = -1;
- drag=false;
+ drag = false;
- VBoxContainer *main_vb = memnew( VBoxContainer );
+ VBoxContainer *main_vb = memnew(VBoxContainer);
add_child(main_vb);
main_vb->set_area_as_parent_rect(0);
- HBoxContainer *hb_tools = memnew( HBoxContainer );
+ HBoxContainer *hb_tools = memnew(HBoxContainer);
main_vb->add_child(hb_tools);
- hb_tools->add_child(memnew( Label(TTR("Snap Mode:")) ));
+ hb_tools->add_child(memnew(Label(TTR("Snap Mode:"))));
- snap_mode_button = memnew( MenuButton );
+ snap_mode_button = memnew(MenuButton);
hb_tools->add_child(snap_mode_button);
snap_mode_button->set_text(TTR("<None>"));
PopupMenu *p = snap_mode_button->get_popup();
- p->add_item(TTR("<None>"),0);
- p->add_item(TTR("Pixel Snap"),1);
- p->add_item(TTR("Grid Snap"),2);
- p->add_item(TTR("Auto Slice"),3);
+ p->add_item(TTR("<None>"), 0);
+ p->add_item(TTR("Pixel Snap"), 1);
+ p->add_item(TTR("Grid Snap"), 2);
+ p->add_item(TTR("Auto Slice"), 3);
for (int i = 0; i < 4; i++)
- p->set_item_as_checkable(i,true);
- p->set_item_checked(0,true);
+ p->set_item_as_checkable(i, true);
+ p->set_item_checked(0, true);
p->connect("id_pressed", this, "_set_snap_mode");
- hb_grid = memnew( HBoxContainer );
+ hb_grid = memnew(HBoxContainer);
hb_tools->add_child(hb_grid);
- hb_grid->add_child( memnew( VSeparator ));
+ hb_grid->add_child(memnew(VSeparator));
- hb_grid->add_child( memnew( Label(TTR("Offset:")) ) );
+ hb_grid->add_child(memnew(Label(TTR("Offset:"))));
- sb_off_x = memnew( SpinBox );
+ sb_off_x = memnew(SpinBox);
sb_off_x->set_min(-256);
sb_off_x->set_max(256);
sb_off_x->set_step(1);
@@ -834,7 +812,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor)
sb_off_x->connect("value_changed", this, "_set_snap_off_x");
hb_grid->add_child(sb_off_x);
- sb_off_y = memnew( SpinBox );
+ sb_off_y = memnew(SpinBox);
sb_off_y->set_min(-256);
sb_off_y->set_max(256);
sb_off_y->set_step(1);
@@ -843,10 +821,10 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor)
sb_off_y->connect("value_changed", this, "_set_snap_off_y");
hb_grid->add_child(sb_off_y);
- hb_grid->add_child( memnew( VSeparator ));
- hb_grid->add_child( memnew( Label(TTR("Step:")) ) );
+ hb_grid->add_child(memnew(VSeparator));
+ hb_grid->add_child(memnew(Label(TTR("Step:"))));
- sb_step_x = memnew( SpinBox );
+ sb_step_x = memnew(SpinBox);
sb_step_x->set_min(-256);
sb_step_x->set_max(256);
sb_step_x->set_step(1);
@@ -855,7 +833,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor)
sb_step_x->connect("value_changed", this, "_set_snap_step_x");
hb_grid->add_child(sb_step_x);
- sb_step_y = memnew( SpinBox );
+ sb_step_y = memnew(SpinBox);
sb_step_y->set_min(-256);
sb_step_y->set_max(256);
sb_step_y->set_step(1);
@@ -864,10 +842,10 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor)
sb_step_y->connect("value_changed", this, "_set_snap_step_y");
hb_grid->add_child(sb_step_y);
- hb_grid->add_child( memnew( VSeparator ));
- hb_grid->add_child( memnew( Label(TTR("Separation:")) ) );
+ hb_grid->add_child(memnew(VSeparator));
+ hb_grid->add_child(memnew(Label(TTR("Separation:"))));
- sb_sep_x = memnew( SpinBox );
+ sb_sep_x = memnew(SpinBox);
sb_sep_x->set_min(0);
sb_sep_x->set_max(256);
sb_sep_x->set_step(1);
@@ -876,7 +854,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor)
sb_sep_x->connect("value_changed", this, "_set_snap_sep_x");
hb_grid->add_child(sb_sep_x);
- sb_sep_y = memnew( SpinBox );
+ sb_sep_y = memnew(SpinBox);
sb_sep_y->set_min(0);
sb_sep_y->set_max(256);
sb_sep_y->set_step(1);
@@ -887,60 +865,56 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor)
hb_grid->hide();
- HBoxContainer *main_hb = memnew( HBoxContainer );
+ HBoxContainer *main_hb = memnew(HBoxContainer);
main_vb->add_child(main_hb);
- edit_draw = memnew( Control );
+ edit_draw = memnew(Control);
main_hb->add_child(edit_draw);
main_hb->set_v_size_flags(SIZE_EXPAND_FILL);
edit_draw->set_h_size_flags(SIZE_EXPAND_FILL);
- Control * separator = memnew( Control );
+ Control *separator = memnew(Control);
separator->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb_tools->add_child(separator);
- icon_zoom = memnew( TextureRect );
+ icon_zoom = memnew(TextureRect);
hb_tools->add_child(icon_zoom);
- zoom_out = memnew( ToolButton );
+ zoom_out = memnew(ToolButton);
zoom_out->connect("pressed", this, "_zoom_out");
hb_tools->add_child(zoom_out);
- zoom_reset = memnew( ToolButton );
+ zoom_reset = memnew(ToolButton);
zoom_reset->connect("pressed", this, "_zoom_reset");
hb_tools->add_child(zoom_reset);
- zoom_in = memnew( ToolButton );
+ zoom_in = memnew(ToolButton);
zoom_in->connect("pressed", this, "_zoom_in");
hb_tools->add_child(zoom_in);
- vscroll = memnew( VScrollBar);
+ vscroll = memnew(VScrollBar);
main_hb->add_child(vscroll);
- vscroll->connect("value_changed",this,"_scroll_changed");
- hscroll = memnew( HScrollBar );
+ vscroll->connect("value_changed", this, "_scroll_changed");
+ hscroll = memnew(HScrollBar);
main_vb->add_child(hscroll);
- hscroll->connect("value_changed",this,"_scroll_changed");
+ hscroll->connect("value_changed", this, "_scroll_changed");
- edit_draw->connect("draw",this,"_region_draw");
- edit_draw->connect("gui_input",this,"_region_input");
- draw_zoom=1.0;
- updating_scroll=false;
+ edit_draw->connect("draw", this, "_region_draw");
+ edit_draw->connect("gui_input", this, "_region_input");
+ draw_zoom = 1.0;
+ updating_scroll = false;
edit_draw->set_clip_contents(true);
-
}
-void TextureRegionEditorPlugin::edit(Object *p_node)
-{
+void TextureRegionEditorPlugin::edit(Object *p_node) {
region_editor->edit(p_node);
}
-bool TextureRegionEditorPlugin::handles(Object *p_obj) const
-{
+bool TextureRegionEditorPlugin::handles(Object *p_obj) const {
return p_obj->is_class("Sprite") || p_obj->is_class("Patch9Rect") || p_obj->is_class("StyleBoxTexture") || p_obj->is_class("AtlasTexture");
}
-void TextureRegionEditorPlugin::make_visible(bool p_visible)
-{
+void TextureRegionEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
region_button->show();
if (region_button->is_pressed())
@@ -952,21 +926,20 @@ void TextureRegionEditorPlugin::make_visible(bool p_visible)
}
}
-
Dictionary TextureRegionEditorPlugin::get_state() const {
Dictionary state;
- state["zoom"]=region_editor->draw_zoom;
- state["snap_offset"]=region_editor->snap_offset;
- state["snap_step"]=region_editor->snap_step;
- state["snap_separation"]=region_editor->snap_separation;
- state["snap_mode"]=region_editor->snap_mode;
+ state["zoom"] = region_editor->draw_zoom;
+ state["snap_offset"] = region_editor->snap_offset;
+ state["snap_step"] = region_editor->snap_step;
+ state["snap_separation"] = region_editor->snap_separation;
+ state["snap_mode"] = region_editor->snap_mode;
return state;
}
-void TextureRegionEditorPlugin::set_state(const Dictionary& p_state){
+void TextureRegionEditorPlugin::set_state(const Dictionary &p_state) {
- Dictionary state=p_state;
+ Dictionary state = p_state;
if (state.has("zoom")) {
region_editor->draw_zoom = p_state["zoom"];
}
@@ -995,18 +968,16 @@ void TextureRegionEditorPlugin::set_state(const Dictionary& p_state){
if (state.has("snap_mode")) {
region_editor->_set_snap_mode(state["snap_mode"]);
}
-
}
-TextureRegionEditorPlugin::TextureRegionEditorPlugin(EditorNode *p_node)
-{
+TextureRegionEditorPlugin::TextureRegionEditorPlugin(EditorNode *p_node) {
editor = p_node;
- region_editor = memnew ( TextureRegionEditor(p_node) );
+ region_editor = memnew(TextureRegionEditor(p_node));
region_button = p_node->add_bottom_panel_item(TTR("Texture Region"), region_editor);
region_button->set_tooltip(TTR("Texture Region Editor"));
- region_editor->set_custom_minimum_size(Size2(0,200));
+ region_editor->set_custom_minimum_size(Size2(0, 200));
region_editor->hide();
region_button->hide();
}
diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h
index 8e88f0b707..b3763acc22 100644
--- a/editor/plugins/texture_region_editor_plugin.h
+++ b/editor/plugins/texture_region_editor_plugin.h
@@ -33,8 +33,8 @@
#define TEXTURE_REGION_EDITOR_PLUGIN_H
#include "canvas_item_editor_plugin.h"
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/2d/sprite.h"
#include "scene/gui/patch_9_rect.h"
#include "scene/resources/style_box.h"
@@ -42,7 +42,7 @@
class TextureRegionEditor : public Control {
- GDCLASS(TextureRegionEditor, Control );
+ GDCLASS(TextureRegionEditor, Control);
enum SnapMode {
SNAP_NONE,
@@ -57,7 +57,7 @@ class TextureRegionEditor : public Control {
ToolButton *zoom_in;
ToolButton *zoom_reset;
ToolButton *zoom_out;
- HBoxContainer * hb_grid; //For showing/hiding the grid controls when changing the SnapMode
+ HBoxContainer *hb_grid; //For showing/hiding the grid controls when changing the SnapMode
SpinBox *sb_step_y;
SpinBox *sb_step_x;
SpinBox *sb_off_y;
@@ -70,7 +70,7 @@ class TextureRegionEditor : public Control {
HScrollBar *hscroll;
EditorNode *editor;
- UndoRedo* undo_redo;
+ UndoRedo *undo_redo;
Vector2 draw_ofs;
float draw_zoom;
@@ -107,9 +107,9 @@ class TextureRegionEditor : public Control {
void _zoom_in();
void _zoom_reset();
void _zoom_out();
- void apply_rect(const Rect2& rect);
-protected:
+ void apply_rect(const Rect2 &rect);
+protected:
void _notification(int p_what);
void _node_removed(Object *p_obj);
static void _bind_methods();
@@ -119,26 +119,23 @@ protected:
virtual void _changed_callback(Object *p_changed, const char *p_prop);
public:
-
void _edit_region();
void _region_draw();
void _region_input(const InputEvent &p_input);
void _scroll_changed(float);
void edit(Object *p_obj);
- TextureRegionEditor(EditorNode* p_editor);
-
+ TextureRegionEditor(EditorNode *p_editor);
};
-class TextureRegionEditorPlugin : public EditorPlugin
-{
- GDCLASS( TextureRegionEditorPlugin, EditorPlugin );
+class TextureRegionEditorPlugin : public EditorPlugin {
+ GDCLASS(TextureRegionEditorPlugin, EditorPlugin);
Button *region_button;
TextureRegionEditor *region_editor;
EditorNode *editor;
-public:
+public:
virtual String get_name() const { return "TextureRegion"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 4b8fea5a45..03316cc7d9 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -28,70 +28,64 @@
/*************************************************************************/
#include "theme_editor_plugin.h"
-#include "version.h"
#include "os/file_access.h"
+#include "version.h"
-void ThemeEditor::edit(const Ref<Theme>& p_theme) {
+void ThemeEditor::edit(const Ref<Theme> &p_theme) {
- theme=p_theme;
+ theme = p_theme;
main_vb->set_theme(p_theme);
-
}
-
void ThemeEditor::_propagate_redraw(Control *p_at) {
p_at->notification(NOTIFICATION_THEME_CHANGED);
p_at->minimum_size_changed();
p_at->update();
- for(int i=0;i<p_at->get_child_count();i++) {
+ for (int i = 0; i < p_at->get_child_count(); i++) {
Control *a = p_at->get_child(i)->cast_to<Control>();
if (a)
_propagate_redraw(a);
-
}
}
void ThemeEditor::_refresh_interval() {
_propagate_redraw(main_vb);
-
}
void ThemeEditor::_type_menu_cbk(int p_option) {
-
- type_edit->set_text( type_menu->get_popup()->get_item_text(p_option) );
+ type_edit->set_text(type_menu->get_popup()->get_item_text(p_option));
}
void ThemeEditor::_name_menu_about_to_show() {
- String fromtype=type_edit->get_text();
+ String fromtype = type_edit->get_text();
List<StringName> names;
- if (popup_mode==POPUP_ADD) {
+ if (popup_mode == POPUP_ADD) {
- switch(type_select->get_selected()) {
+ switch (type_select->get_selected()) {
- case 0: Theme::get_default()->get_icon_list(fromtype,&names); break;
- case 1: Theme::get_default()->get_stylebox_list(fromtype,&names); break;
- case 2: Theme::get_default()->get_font_list(fromtype,&names); break;
- case 3: Theme::get_default()->get_color_list(fromtype,&names); break;
- case 4: Theme::get_default()->get_constant_list(fromtype,&names); break;
+ case 0: Theme::get_default()->get_icon_list(fromtype, &names); break;
+ case 1: Theme::get_default()->get_stylebox_list(fromtype, &names); break;
+ case 2: Theme::get_default()->get_font_list(fromtype, &names); break;
+ case 3: Theme::get_default()->get_color_list(fromtype, &names); break;
+ case 4: Theme::get_default()->get_constant_list(fromtype, &names); break;
}
- } else if (popup_mode==POPUP_REMOVE) {
+ } else if (popup_mode == POPUP_REMOVE) {
- theme->get_icon_list(fromtype,&names);
- theme->get_stylebox_list(fromtype,&names);
- theme->get_font_list(fromtype,&names);
- theme->get_color_list(fromtype,&names);
- theme->get_constant_list(fromtype,&names);
+ theme->get_icon_list(fromtype, &names);
+ theme->get_stylebox_list(fromtype, &names);
+ theme->get_font_list(fromtype, &names);
+ theme->get_color_list(fromtype, &names);
+ theme->get_constant_list(fromtype, &names);
}
-
name_menu->get_popup()->clear();
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
name_menu->get_popup()->add_item(E->get());
}
@@ -99,108 +93,103 @@ void ThemeEditor::_name_menu_about_to_show() {
void ThemeEditor::_name_menu_cbk(int p_option) {
- name_edit->set_text( name_menu->get_popup()->get_item_text(p_option) );
+ name_edit->set_text(name_menu->get_popup()->get_item_text(p_option));
}
struct _TECategory {
- template<class T>
+ template <class T>
struct RefItem {
Ref<T> item;
StringName name;
- bool operator<(const RefItem<T>& p) const { return item->get_instance_ID() < p.item->get_instance_ID(); }
+ bool operator<(const RefItem<T> &p) const { return item->get_instance_ID() < p.item->get_instance_ID(); }
};
- template<class T>
+ template <class T>
struct Item {
T item;
String name;
- bool operator<(const Item<T>& p) const { return name < p.name; }
+ bool operator<(const Item<T> &p) const { return name < p.name; }
};
-
Set<RefItem<StyleBox> > stylebox_items;
Set<RefItem<Font> > font_items;
Set<RefItem<Texture> > icon_items;
Set<Item<Color> > color_items;
Set<Item<int> > constant_items;
-
};
-
void ThemeEditor::_save_template_cbk(String fname) {
String filename = file_dialog->get_current_path();
- Map<String,_TECategory> categories;
+ Map<String, _TECategory> categories;
//fill types
List<StringName> type_list;
Theme::get_default()->get_type_list(&type_list);
- for (List<StringName>::Element *E=type_list.front();E;E=E->next()) {
- categories.insert(E->get(),_TECategory());
+ for (List<StringName>::Element *E = type_list.front(); E; E = E->next()) {
+ categories.insert(E->get(), _TECategory());
}
//fill default theme
- for(Map<String,_TECategory>::Element *E=categories.front();E;E=E->next() ) {
+ for (Map<String, _TECategory>::Element *E = categories.front(); E; E = E->next()) {
_TECategory &tc = E->get();
List<StringName> stylebox_list;
- Theme::get_default()->get_stylebox_list(E->key(),&stylebox_list);
- for (List<StringName>::Element *F=stylebox_list.front();F;F=F->next()) {
+ Theme::get_default()->get_stylebox_list(E->key(), &stylebox_list);
+ for (List<StringName>::Element *F = stylebox_list.front(); F; F = F->next()) {
_TECategory::RefItem<StyleBox> it;
- it.name=F->get();
- it.item=Theme::get_default()->get_stylebox(F->get(),E->key());
+ it.name = F->get();
+ it.item = Theme::get_default()->get_stylebox(F->get(), E->key());
tc.stylebox_items.insert(it);
}
List<StringName> font_list;
- Theme::get_default()->get_font_list(E->key(),&font_list);
- for (List<StringName>::Element *F=font_list.front();F;F=F->next()) {
+ Theme::get_default()->get_font_list(E->key(), &font_list);
+ for (List<StringName>::Element *F = font_list.front(); F; F = F->next()) {
_TECategory::RefItem<Font> it;
- it.name=F->get();
- it.item=Theme::get_default()->get_font(F->get(),E->key());
+ it.name = F->get();
+ it.item = Theme::get_default()->get_font(F->get(), E->key());
tc.font_items.insert(it);
}
List<StringName> icon_list;
- Theme::get_default()->get_icon_list(E->key(),&icon_list);
- for (List<StringName>::Element *F=icon_list.front();F;F=F->next()) {
+ Theme::get_default()->get_icon_list(E->key(), &icon_list);
+ for (List<StringName>::Element *F = icon_list.front(); F; F = F->next()) {
_TECategory::RefItem<Texture> it;
- it.name=F->get();
- it.item=Theme::get_default()->get_icon(F->get(),E->key());
+ it.name = F->get();
+ it.item = Theme::get_default()->get_icon(F->get(), E->key());
tc.icon_items.insert(it);
}
List<StringName> color_list;
- Theme::get_default()->get_color_list(E->key(),&color_list);
- for (List<StringName>::Element *F=color_list.front();F;F=F->next()) {
+ Theme::get_default()->get_color_list(E->key(), &color_list);
+ for (List<StringName>::Element *F = color_list.front(); F; F = F->next()) {
_TECategory::Item<Color> it;
- it.name=F->get();
- it.item=Theme::get_default()->get_color(F->get(),E->key());
+ it.name = F->get();
+ it.item = Theme::get_default()->get_color(F->get(), E->key());
tc.color_items.insert(it);
}
List<StringName> constant_list;
- Theme::get_default()->get_constant_list(E->key(),&constant_list);
- for (List<StringName>::Element *F=constant_list.front();F;F=F->next()) {
+ Theme::get_default()->get_constant_list(E->key(), &constant_list);
+ for (List<StringName>::Element *F = constant_list.front(); F; F = F->next()) {
_TECategory::Item<int> it;
- it.name=F->get();
- it.item=Theme::get_default()->get_constant(F->get(),E->key());
+ it.name = F->get();
+ it.item = Theme::get_default()->get_constant(F->get(), E->key());
tc.constant_items.insert(it);
}
-
}
- FileAccess *file = FileAccess::open(filename,FileAccess::WRITE);
+ FileAccess *file = FileAccess::open(filename, FileAccess::WRITE);
if (!file) {
-
- ERR_EXPLAIN(TTR("Can't save theme to file:")+" "+filename);
+ ERR_EXPLAIN(TTR("Can't save theme to file:") + " " + filename);
return;
}
file->store_line("; ******************* ");
@@ -253,7 +242,7 @@ void ThemeEditor::_save_template_cbk(String fname) {
file->store_line("; ");
file->store_line("; ******************* ");
file->store_line("; ");
- file->store_line("; Template Generated Using: "+String(VERSION_MKSTRING));
+ file->store_line("; Template Generated Using: " + String(VERSION_MKSTRING));
file->store_line("; ");
file->store_line("; ");
file->store_line("");
@@ -266,59 +255,58 @@ void ThemeEditor::_save_template_cbk(String fname) {
file->store_line("");
//write default theme
- for(Map<String,_TECategory>::Element *E=categories.front();E;E=E->next() ) {
+ for (Map<String, _TECategory>::Element *E = categories.front(); E; E = E->next()) {
_TECategory &tc = E->get();
- String underline="; ";
- for(int i=0;i<E->key().length();i++)
- underline+="*";
+ String underline = "; ";
+ for (int i = 0; i < E->key().length(); i++)
+ underline += "*";
file->store_line("");
file->store_line(underline);
- file->store_line("; "+E->key());
+ file->store_line("; " + E->key());
file->store_line(underline);
if (tc.stylebox_items.size())
file->store_line("\n; StyleBox Items:\n");
- for (Set<_TECategory::RefItem<StyleBox> >::Element *F=tc.stylebox_items.front();F;F=F->next()) {
+ for (Set<_TECategory::RefItem<StyleBox> >::Element *F = tc.stylebox_items.front(); F; F = F->next()) {
- file->store_line(E->key()+"."+F->get().name+" = default");
+ file->store_line(E->key() + "." + F->get().name + " = default");
}
if (tc.font_items.size())
file->store_line("\n; Font Items:\n");
- for (Set<_TECategory::RefItem<Font> >::Element *F=tc.font_items.front();F;F=F->next()) {
+ for (Set<_TECategory::RefItem<Font> >::Element *F = tc.font_items.front(); F; F = F->next()) {
- file->store_line(E->key()+"."+F->get().name+" = default");
+ file->store_line(E->key() + "." + F->get().name + " = default");
}
if (tc.icon_items.size())
file->store_line("\n; Icon Items:\n");
- for (Set<_TECategory::RefItem<Texture> >::Element *F=tc.icon_items.front();F;F=F->next()) {
+ for (Set<_TECategory::RefItem<Texture> >::Element *F = tc.icon_items.front(); F; F = F->next()) {
- file->store_line(E->key()+"."+F->get().name+" = default");
+ file->store_line(E->key() + "." + F->get().name + " = default");
}
if (tc.color_items.size())
file->store_line("\n; Color Items:\n");
- for (Set<_TECategory::Item<Color> >::Element *F=tc.color_items.front();F;F=F->next()) {
+ for (Set<_TECategory::Item<Color> >::Element *F = tc.color_items.front(); F; F = F->next()) {
- file->store_line(E->key()+"."+F->get().name+" = default");
+ file->store_line(E->key() + "." + F->get().name + " = default");
}
if (tc.constant_items.size())
file->store_line("\n; Constant Items:\n");
- for (Set<_TECategory::Item<int> >::Element *F=tc.constant_items.front();F;F=F->next()) {
+ for (Set<_TECategory::Item<int> >::Element *F = tc.constant_items.front(); F; F = F->next()) {
- file->store_line(E->key()+"."+F->get().name+" = default");
+ file->store_line(E->key() + "." + F->get().name + " = default");
}
-
}
file->close();
@@ -327,16 +315,16 @@ void ThemeEditor::_save_template_cbk(String fname) {
void ThemeEditor::_dialog_cbk() {
- switch(popup_mode) {
+ switch (popup_mode) {
case POPUP_ADD: {
- switch(type_select->get_selected()) {
+ switch (type_select->get_selected()) {
- case 0: theme->set_icon(name_edit->get_text(),type_edit->get_text(),Ref<Texture>()); break;
- case 1: theme->set_stylebox(name_edit->get_text(),type_edit->get_text(),Ref<StyleBox>()); break;
- case 2: theme->set_font(name_edit->get_text(),type_edit->get_text(),Ref<Font>()); break;
- case 3: theme->set_color(name_edit->get_text(),type_edit->get_text(),Color()); break;
- case 4: theme->set_constant(name_edit->get_text(),type_edit->get_text(),0); break;
+ case 0: theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture>()); break;
+ case 1: theme->set_stylebox(name_edit->get_text(), type_edit->get_text(), Ref<StyleBox>()); break;
+ case 2: theme->set_font(name_edit->get_text(), type_edit->get_text(), Ref<Font>()); break;
+ case 3: theme->set_color(name_edit->get_text(), type_edit->get_text(), Color()); break;
+ case 4: theme->set_constant(name_edit->get_text(), type_edit->get_text(), 0); break;
}
} break;
@@ -347,58 +335,50 @@ void ThemeEditor::_dialog_cbk() {
{
names.clear();
- Theme::get_default()->get_icon_list(fromtype,&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
- theme->set_icon(E->get(),fromtype,Ref<Texture>());
-
+ Theme::get_default()->get_icon_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->set_icon(E->get(), fromtype, Ref<Texture>());
}
-
}
{
names.clear();
- Theme::get_default()->get_stylebox_list(fromtype,&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
- theme->set_stylebox(E->get(),fromtype,Ref<StyleBox>());
-
+ Theme::get_default()->get_stylebox_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->set_stylebox(E->get(), fromtype, Ref<StyleBox>());
}
-
}
{
names.clear();
- Theme::get_default()->get_font_list(fromtype,&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
- theme->set_font(E->get(),fromtype,Ref<Font>());
-
+ Theme::get_default()->get_font_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->set_font(E->get(), fromtype, Ref<Font>());
}
}
{
names.clear();
- Theme::get_default()->get_color_list(fromtype,&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
- theme->set_color(E->get(),fromtype,Theme::get_default()->get_color(E->get(),fromtype));
-
+ Theme::get_default()->get_color_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->set_color(E->get(), fromtype, Theme::get_default()->get_color(E->get(), fromtype));
}
}
{
names.clear();
- Theme::get_default()->get_constant_list(fromtype,&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
- theme->set_constant(E->get(),fromtype,Theme::get_default()->get_constant(E->get(),fromtype));
-
+ Theme::get_default()->get_constant_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->set_constant(E->get(), fromtype, Theme::get_default()->get_constant(E->get(), fromtype));
}
}
} break;
case POPUP_REMOVE: {
- switch(type_select->get_selected()) {
+ switch (type_select->get_selected()) {
- case 0: theme->clear_icon(name_edit->get_text(),type_edit->get_text()); break;
- case 1: theme->clear_stylebox(name_edit->get_text(),type_edit->get_text()); break;
- case 2: theme->clear_font(name_edit->get_text(),type_edit->get_text()); break;
- case 3: theme->clear_color(name_edit->get_text(),type_edit->get_text()); break;
- case 4: theme->clear_constant(name_edit->get_text(),type_edit->get_text()); break;
+ case 0: theme->clear_icon(name_edit->get_text(), type_edit->get_text()); break;
+ case 1: theme->clear_stylebox(name_edit->get_text(), type_edit->get_text()); break;
+ case 2: theme->clear_font(name_edit->get_text(), type_edit->get_text()); break;
+ case 3: theme->clear_color(name_edit->get_text(), type_edit->get_text()); break;
+ case 4: theme->clear_constant(name_edit->get_text(), type_edit->get_text()); break;
}
-
} break;
case POPUP_CLASS_REMOVE: {
StringName fromtype = type_edit->get_text();
@@ -406,121 +386,106 @@ void ThemeEditor::_dialog_cbk() {
{
names.clear();
- Theme::get_default()->get_icon_list(fromtype,&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
- theme->clear_icon(E->get(),fromtype);
-
+ Theme::get_default()->get_icon_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->clear_icon(E->get(), fromtype);
}
-
}
{
names.clear();
- Theme::get_default()->get_stylebox_list(fromtype,&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
- theme->clear_stylebox(E->get(),fromtype);
-
+ Theme::get_default()->get_stylebox_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->clear_stylebox(E->get(), fromtype);
}
-
}
{
names.clear();
- Theme::get_default()->get_font_list(fromtype,&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
- theme->clear_font(E->get(),fromtype);
-
+ Theme::get_default()->get_font_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->clear_font(E->get(), fromtype);
}
}
{
names.clear();
- Theme::get_default()->get_color_list(fromtype,&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
- theme->clear_color(E->get(),fromtype);
-
+ Theme::get_default()->get_color_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->clear_color(E->get(), fromtype);
}
}
{
names.clear();
- Theme::get_default()->get_constant_list(fromtype,&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
- theme->clear_constant(E->get(),fromtype);
-
+ Theme::get_default()->get_constant_list(fromtype, &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
+ theme->clear_constant(E->get(), fromtype);
}
}
- }break;
+ } break;
}
-
}
void ThemeEditor::_theme_menu_cbk(int p_option) {
-
- if (p_option==POPUP_CREATE_EMPTY || p_option==POPUP_CREATE_EDITOR_EMPTY) {
-
+ if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY) {
Ref<Theme> base_theme;
- if (p_option==POPUP_CREATE_EMPTY) {
+ if (p_option == POPUP_CREATE_EMPTY) {
base_theme = Theme::get_default();
} else {
base_theme = EditorNode::get_singleton()->get_theme_base()->get_theme();
}
-
{
List<StringName> types;
base_theme->get_type_list(&types);
-
- for (List<StringName>::Element *T=types.front();T;T=T->next()) {
+ for (List<StringName>::Element *T = types.front(); T; T = T->next()) {
StringName type = T->get();
List<StringName> icons;
- base_theme->get_icon_list(type,&icons);
+ base_theme->get_icon_list(type, &icons);
- for (List<StringName>::Element *E=icons.front();E;E=E->next()) {
- theme->set_icon(E->get(),type,Ref<Texture>());
+ for (List<StringName>::Element *E = icons.front(); E; E = E->next()) {
+ theme->set_icon(E->get(), type, Ref<Texture>());
}
List<StringName> shaders;
- base_theme->get_shader_list(type,&shaders);
+ base_theme->get_shader_list(type, &shaders);
- for (List<StringName>::Element *E=shaders.front();E;E=E->next()) {
- theme->set_shader(E->get(),type,Ref<Shader>());
+ for (List<StringName>::Element *E = shaders.front(); E; E = E->next()) {
+ theme->set_shader(E->get(), type, Ref<Shader>());
}
List<StringName> styleboxs;
- base_theme->get_stylebox_list(type,&styleboxs);
+ base_theme->get_stylebox_list(type, &styleboxs);
- for (List<StringName>::Element *E=styleboxs.front();E;E=E->next()) {
- theme->set_stylebox(E->get(),type,Ref<StyleBox>());
+ for (List<StringName>::Element *E = styleboxs.front(); E; E = E->next()) {
+ theme->set_stylebox(E->get(), type, Ref<StyleBox>());
}
List<StringName> fonts;
- base_theme->get_font_list(type,&fonts);
+ base_theme->get_font_list(type, &fonts);
- for (List<StringName>::Element *E=fonts.front();E;E=E->next()) {
- theme->set_font(E->get(),type,Ref<Font>());
+ for (List<StringName>::Element *E = fonts.front(); E; E = E->next()) {
+ theme->set_font(E->get(), type, Ref<Font>());
}
List<StringName> colors;
- base_theme->get_color_list(type,&colors);
+ base_theme->get_color_list(type, &colors);
- for (List<StringName>::Element *E=colors.front();E;E=E->next()) {
- theme->set_color(E->get(),type,Color());
+ for (List<StringName>::Element *E = colors.front(); E; E = E->next()) {
+ theme->set_color(E->get(), type, Color());
}
-
List<StringName> constants;
- base_theme->get_constant_list(type,&constants);
+ base_theme->get_constant_list(type, &constants);
- for (List<StringName>::Element *E=constants.front();E;E=E->next()) {
- theme->set_constant(E->get(),type,base_theme->get_constant(type,E->get()));
+ for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
+ theme->set_constant(E->get(), type, base_theme->get_constant(type, E->get()));
}
-
}
-
}
return;
}
@@ -533,22 +498,21 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
name_edit->show();
name_menu->show();
-
- if (p_option==POPUP_ADD) {//add
+ if (p_option == POPUP_ADD) { //add
add_del_dialog->set_title(TTR("Add Item"));
add_del_dialog->get_ok()->set_text(TTR("Add"));
- add_del_dialog->popup_centered(Size2(490,85)*EDSCALE);
+ add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE);
- base_theme=Theme::get_default();
+ base_theme = Theme::get_default();
- } else if (p_option==POPUP_CLASS_ADD) {//add
+ } else if (p_option == POPUP_CLASS_ADD) { //add
add_del_dialog->set_title(TTR("Add All Items"));
add_del_dialog->get_ok()->set_text(TTR("Add All"));
- add_del_dialog->popup_centered(Size2(240,85)*EDSCALE);
+ add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE);
- base_theme=Theme::get_default();
+ base_theme = Theme::get_default();
type_select->hide();
name_select_label->hide();
@@ -556,21 +520,21 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
name_edit->hide();
name_menu->hide();
- } else if (p_option==POPUP_REMOVE) {
+ } else if (p_option == POPUP_REMOVE) {
add_del_dialog->set_title(TTR("Remove Item"));
add_del_dialog->get_ok()->set_text(TTR("Remove"));
- add_del_dialog->popup_centered(Size2(490,85)*EDSCALE);
+ add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE);
- base_theme=theme;
+ base_theme = theme;
- } else if (p_option==POPUP_CLASS_REMOVE) {
+ } else if (p_option == POPUP_CLASS_REMOVE) {
add_del_dialog->set_title("Remove All Items");
add_del_dialog->get_ok()->set_text("Remove All");
- add_del_dialog->popup_centered(Size2(240,85)*EDSCALE);
+ add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE);
- base_theme=Theme::get_default();
+ base_theme = Theme::get_default();
type_select->hide();
name_select_label->hide();
@@ -578,28 +542,28 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
name_edit->hide();
name_menu->hide();
}
- popup_mode=p_option;
+ popup_mode = p_option;
- ERR_FAIL_COND( theme.is_null() );
+ ERR_FAIL_COND(theme.is_null());
List<StringName> types;
base_theme->get_type_list(&types);
type_menu->get_popup()->clear();
- if (p_option==0 || p_option==1) {//add
+ if (p_option == 0 || p_option == 1) { //add
List<StringName> new_types;
theme->get_type_list(&new_types);
//uh kind of sucks
- for(List<StringName>::Element *F=new_types.front();F;F=F->next()) {
+ for (List<StringName>::Element *F = new_types.front(); F; F = F->next()) {
- bool found=false;
- for(List<StringName>::Element *E=types.front();E;E=E->next()) {
+ bool found = false;
+ for (List<StringName>::Element *E = types.front(); E; E = E->next()) {
- if (E->get()==F->get()) {
- found=true;
+ if (E->get() == F->get()) {
+ found = true;
break;
}
}
@@ -611,20 +575,19 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
//types.sort();
types.sort_custom<StringName::AlphCompare>();
- for(List<StringName>::Element *E=types.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = types.front(); E; E = E->next()) {
- type_menu->get_popup()->add_item( E->get() );
+ type_menu->get_popup()->add_item(E->get());
}
-
}
void ThemeEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_PROCESS) {
+ if (p_what == NOTIFICATION_PROCESS) {
- time_left-=get_process_delta_time();
- if (time_left<0) {
- time_left=1.5;
+ time_left -= get_process_delta_time();
+ if (time_left < 0) {
+ time_left = 1.5;
_refresh_interval();
}
}
@@ -632,110 +595,101 @@ void ThemeEditor::_notification(int p_what) {
void ThemeEditor::_bind_methods() {
- ClassDB::bind_method("_type_menu_cbk",&ThemeEditor::_type_menu_cbk);
- ClassDB::bind_method("_name_menu_about_to_show",&ThemeEditor::_name_menu_about_to_show);
- ClassDB::bind_method("_name_menu_cbk",&ThemeEditor::_name_menu_cbk);
- ClassDB::bind_method("_theme_menu_cbk",&ThemeEditor::_theme_menu_cbk);
- ClassDB::bind_method("_dialog_cbk",&ThemeEditor::_dialog_cbk);
- ClassDB::bind_method("_save_template_cbk",&ThemeEditor::_save_template_cbk);
+ ClassDB::bind_method("_type_menu_cbk", &ThemeEditor::_type_menu_cbk);
+ ClassDB::bind_method("_name_menu_about_to_show", &ThemeEditor::_name_menu_about_to_show);
+ ClassDB::bind_method("_name_menu_cbk", &ThemeEditor::_name_menu_cbk);
+ ClassDB::bind_method("_theme_menu_cbk", &ThemeEditor::_theme_menu_cbk);
+ ClassDB::bind_method("_dialog_cbk", &ThemeEditor::_dialog_cbk);
+ ClassDB::bind_method("_save_template_cbk", &ThemeEditor::_save_template_cbk);
}
ThemeEditor::ThemeEditor() {
- time_left=0;
+ time_left = 0;
- scroll = memnew( ScrollContainer );
+ scroll = memnew(ScrollContainer);
add_child(scroll);
scroll->set_area_as_parent_rect(3);
- scroll->set_margin(MARGIN_TOP,30*EDSCALE);
+ scroll->set_margin(MARGIN_TOP, 30 * EDSCALE);
//scroll->set_enable_h_scroll(true);
scroll->set_enable_v_scroll(true);
scroll->set_enable_h_scroll(false);
- Panel * panel = memnew( Panel );
+ Panel *panel = memnew(Panel);
scroll->add_child(panel);
- panel->set_custom_minimum_size(Size2(500,800)*EDSCALE);
+ panel->set_custom_minimum_size(Size2(500, 800) * EDSCALE);
panel->set_theme(Theme::get_default());
panel->set_h_size_flags(SIZE_EXPAND_FILL);
- main_vb= memnew( VBoxContainer );
+ main_vb = memnew(VBoxContainer);
panel->add_child(main_vb);
- main_vb->set_area_as_parent_rect(4*EDSCALE);
-
+ main_vb->set_area_as_parent_rect(4 * EDSCALE);
HBoxContainer *hb_menu = memnew(HBoxContainer);
main_vb->add_child(hb_menu);
-
-
- theme_menu = memnew( MenuButton );
+ theme_menu = memnew(MenuButton);
theme_menu->set_text(TTR("Theme"));
- theme_menu->get_popup()->add_item(TTR("Add Item"),POPUP_ADD);
- theme_menu->get_popup()->add_item(TTR("Add Class Items"),POPUP_CLASS_ADD);
- theme_menu->get_popup()->add_item(TTR("Remove Item"),POPUP_REMOVE);
- theme_menu->get_popup()->add_item(TTR("Remove Class Items"),POPUP_CLASS_REMOVE);
+ theme_menu->get_popup()->add_item(TTR("Add Item"), POPUP_ADD);
+ theme_menu->get_popup()->add_item(TTR("Add Class Items"), POPUP_CLASS_ADD);
+ theme_menu->get_popup()->add_item(TTR("Remove Item"), POPUP_REMOVE);
+ theme_menu->get_popup()->add_item(TTR("Remove Class Items"), POPUP_CLASS_REMOVE);
theme_menu->get_popup()->add_separator();
- theme_menu->get_popup()->add_item(TTR("Create Empty Template"),POPUP_CREATE_EMPTY);
- theme_menu->get_popup()->add_item(TTR("Create Empty Editor Template"),POPUP_CREATE_EDITOR_EMPTY);
+ theme_menu->get_popup()->add_item(TTR("Create Empty Template"), POPUP_CREATE_EMPTY);
+ theme_menu->get_popup()->add_item(TTR("Create Empty Editor Template"), POPUP_CREATE_EDITOR_EMPTY);
add_child(theme_menu);
- theme_menu->set_pos(Vector2(3,3)*EDSCALE);
- theme_menu->get_popup()->connect("id_pressed", this,"_theme_menu_cbk");
+ theme_menu->set_pos(Vector2(3, 3) * EDSCALE);
+ theme_menu->get_popup()->connect("id_pressed", this, "_theme_menu_cbk");
-
- HBoxContainer *main_hb = memnew( HBoxContainer );
+ HBoxContainer *main_hb = memnew(HBoxContainer);
main_vb->add_child(main_hb);
-
-
- VBoxContainer *first_vb = memnew( VBoxContainer);
+ VBoxContainer *first_vb = memnew(VBoxContainer);
first_vb->set_h_size_flags(SIZE_EXPAND_FILL);
main_hb->add_child(first_vb);
-
-
//main_panel->add_child(panel);
//panel->set_area_as_parent_rect();
//panel->set_margin( MARGIN_TOP,20 );
- first_vb->add_child(memnew( Label("Label") ));
+ first_vb->add_child(memnew(Label("Label")));
- first_vb->add_child(memnew( Button("Button")) );
- ToolButton *tb = memnew( ToolButton );
+ first_vb->add_child(memnew(Button("Button")));
+ ToolButton *tb = memnew(ToolButton);
tb->set_text("ToolButton");
- first_vb->add_child(tb );
- CheckButton *cb = memnew( CheckButton );
+ first_vb->add_child(tb);
+ CheckButton *cb = memnew(CheckButton);
cb->set_text("CheckButton");
- first_vb->add_child(cb );
- CheckBox *cbx = memnew( CheckBox );
+ first_vb->add_child(cb);
+ CheckBox *cbx = memnew(CheckBox);
cbx->set_text("CheckBox");
- first_vb->add_child(cbx );
+ first_vb->add_child(cbx);
-
- VBoxContainer *bg = memnew( VBoxContainer );
+ VBoxContainer *bg = memnew(VBoxContainer);
bg->set_v_size_flags(SIZE_EXPAND_FILL);
- VBoxContainer *gbvb = memnew( VBoxContainer );
+ VBoxContainer *gbvb = memnew(VBoxContainer);
gbvb->set_v_size_flags(SIZE_EXPAND_FILL);
- CheckBox *rbx1 = memnew( CheckBox );
+ CheckBox *rbx1 = memnew(CheckBox);
rbx1->set_text(TTR("CheckBox Radio1"));
rbx1->set_pressed(true);
gbvb->add_child(rbx1);
- CheckBox *rbx2 = memnew( CheckBox );
+ CheckBox *rbx2 = memnew(CheckBox);
rbx2->set_text(TTR("CheckBox Radio2"));
gbvb->add_child(rbx2);
bg->add_child(gbvb);
first_vb->add_child(bg);
- MenuButton* test_menu_button = memnew( MenuButton );
+ MenuButton *test_menu_button = memnew(MenuButton);
test_menu_button->set_text("MenuButton");
test_menu_button->get_popup()->add_item(TTR("Item"));
test_menu_button->get_popup()->add_separator();
test_menu_button->get_popup()->add_check_item(TTR("Check Item"));
test_menu_button->get_popup()->add_check_item(TTR("Checked Item"));
- test_menu_button->get_popup()->set_item_checked(2,true);
+ test_menu_button->get_popup()->set_item_checked(2, true);
first_vb->add_child(test_menu_button);
- OptionButton *test_option_button = memnew( OptionButton );
+ OptionButton *test_option_button = memnew(OptionButton);
test_option_button->add_item("OptionButton");
test_option_button->add_separator();
test_option_button->add_item(TTR("Has"));
@@ -743,89 +697,85 @@ ThemeEditor::ThemeEditor() {
test_option_button->add_item(TTR("Options"));
first_vb->add_child(test_option_button);
- ColorPickerButton *cpb = memnew( ColorPickerButton );
- first_vb->add_child(cpb );
+ ColorPickerButton *cpb = memnew(ColorPickerButton);
+ first_vb->add_child(cpb);
- first_vb->add_child( memnew( HSeparator ));
- first_vb->add_child( memnew( HSlider ));
- first_vb->add_child( memnew( HScrollBar ));
- first_vb->add_child( memnew( SpinBox ));
- ProgressBar *pb=memnew( ProgressBar );
+ first_vb->add_child(memnew(HSeparator));
+ first_vb->add_child(memnew(HSlider));
+ first_vb->add_child(memnew(HScrollBar));
+ first_vb->add_child(memnew(SpinBox));
+ ProgressBar *pb = memnew(ProgressBar);
pb->set_value(50);
- first_vb->add_child( pb);
- Panel *pn=memnew( Panel );
- pn->set_custom_minimum_size(Size2(40,40)*EDSCALE);
- first_vb->add_child( pn);
- first_vb->add_constant_override("separation",10*EDSCALE);
+ first_vb->add_child(pb);
+ Panel *pn = memnew(Panel);
+ pn->set_custom_minimum_size(Size2(40, 40) * EDSCALE);
+ first_vb->add_child(pn);
+ first_vb->add_constant_override("separation", 10 * EDSCALE);
- VBoxContainer *second_vb = memnew( VBoxContainer );
+ VBoxContainer *second_vb = memnew(VBoxContainer);
second_vb->set_h_size_flags(SIZE_EXPAND_FILL);
main_hb->add_child(second_vb);
- second_vb->add_constant_override("separation",10*EDSCALE);
- LineEdit *le = memnew( LineEdit );
+ second_vb->add_constant_override("separation", 10 * EDSCALE);
+ LineEdit *le = memnew(LineEdit);
le->set_text("LineEdit");
second_vb->add_child(le);
- TextEdit *te = memnew( TextEdit );
+ TextEdit *te = memnew(TextEdit);
te->set_text("TextEdit");
//te->set_v_size_flags(SIZE_EXPAND_FILL);
- te->set_custom_minimum_size(Size2(0,160)*EDSCALE);
+ te->set_custom_minimum_size(Size2(0, 160) * EDSCALE);
second_vb->add_child(te);
Tree *test_tree = memnew(Tree);
second_vb->add_child(test_tree);
- test_tree->set_custom_minimum_size(Size2(0,160)*EDSCALE);
-
+ test_tree->set_custom_minimum_size(Size2(0, 160) * EDSCALE);
TreeItem *item = test_tree->create_item();
- item->set_editable(0,true);
- item->set_text(0,"Tree");
- item = test_tree->create_item( test_tree->get_root() );
+ item->set_editable(0, true);
+ item->set_text(0, "Tree");
+ item = test_tree->create_item(test_tree->get_root());
item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
- item->set_editable(0,true);
- item->set_text(0,"check");
- item = test_tree->create_item( test_tree->get_root() );
+ item->set_editable(0, true);
+ item->set_text(0, "check");
+ item = test_tree->create_item(test_tree->get_root());
item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE);
- item->set_editable(0,true);
- item->set_range_config(0,0,20,0.1);
- item->set_range(0,2);
- item = test_tree->create_item( test_tree->get_root() );
+ item->set_editable(0, true);
+ item->set_range_config(0, 0, 20, 0.1);
+ item->set_range(0, 2);
+ item = test_tree->create_item(test_tree->get_root());
item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE);
- item->set_editable(0,true);
- item->set_text(0,TTR("Have,Many,Several,Options!"));
- item->set_range(0,2);
+ item->set_editable(0, true);
+ item->set_text(0, TTR("Have,Many,Several,Options!"));
+ item->set_range(0, 2);
- VBoxContainer *third_vb = memnew( VBoxContainer );
+ VBoxContainer *third_vb = memnew(VBoxContainer);
third_vb->set_h_size_flags(SIZE_EXPAND_FILL);
- third_vb->add_constant_override("separation",10);
+ third_vb->add_constant_override("separation", 10);
main_hb->add_child(third_vb);
- HBoxContainer *vhb = memnew( HBoxContainer );
- vhb->set_custom_minimum_size(Size2(0,160)*EDSCALE);
+ HBoxContainer *vhb = memnew(HBoxContainer);
+ vhb->set_custom_minimum_size(Size2(0, 160) * EDSCALE);
vhb->add_child(memnew(VSeparator));
vhb->add_child(memnew(VSlider));
vhb->add_child(memnew(VScrollBar));
third_vb->add_child(vhb);
- TabContainer *tc = memnew( TabContainer );
+ TabContainer *tc = memnew(TabContainer);
third_vb->add_child(tc);
- tc->set_custom_minimum_size(Size2(0,160)*EDSCALE);
- Control *tcc = memnew( Control );
+ tc->set_custom_minimum_size(Size2(0, 160) * EDSCALE);
+ Control *tcc = memnew(Control);
tcc->set_name(TTR("Tab 1"));
tc->add_child(tcc);
- tcc = memnew( Control );
+ tcc = memnew(Control);
tcc->set_name(TTR("Tab 2"));
tc->add_child(tcc);
- tcc = memnew( Control );
+ tcc = memnew(Control);
tcc->set_name(TTR("Tab 3"));
tc->add_child(tcc);
- main_hb->add_constant_override("separation",20*EDSCALE);
-
-
+ main_hb->add_constant_override("separation", 20 * EDSCALE);
-
-/*
+ /*
test_h_scroll = memnew( HScrollBar );
test_h_scroll->set_pos( Point2( 25, 225 ) );
test_h_scroll->set_size( Point2( 150, 5 ) );
@@ -881,93 +831,88 @@ ThemeEditor::ThemeEditor() {
add_del_dialog->hide();
add_child(add_del_dialog);
-
- Label *l = memnew( Label );
- l->set_pos( Point2(5,5)*EDSCALE );
+ Label *l = memnew(Label);
+ l->set_pos(Point2(5, 5) * EDSCALE);
l->set_text(TTR("Type:"));
add_del_dialog->add_child(l);
- dtype_select_label=l;
-
+ dtype_select_label = l;
- type_edit = memnew( LineEdit );
- type_edit->set_pos(Point2(5,25)*EDSCALE);
- type_edit->set_size(Point2(150,5)*EDSCALE);
+ type_edit = memnew(LineEdit);
+ type_edit->set_pos(Point2(5, 25) * EDSCALE);
+ type_edit->set_size(Point2(150, 5) * EDSCALE);
add_del_dialog->add_child(type_edit);
- type_menu = memnew( MenuButton );
- type_menu->set_pos(Point2(160,25)*EDSCALE);
- type_menu->set_size(Point2(30,5)*EDSCALE);
+ type_menu = memnew(MenuButton);
+ type_menu->set_pos(Point2(160, 25) * EDSCALE);
+ type_menu->set_size(Point2(30, 5) * EDSCALE);
type_menu->set_text("..");
add_del_dialog->add_child(type_menu);
- type_menu->get_popup()->connect("id_pressed", this,"_type_menu_cbk");
+ type_menu->get_popup()->connect("id_pressed", this, "_type_menu_cbk");
- l = memnew( Label );
- l->set_pos( Point2(200,5)*EDSCALE );
+ l = memnew(Label);
+ l->set_pos(Point2(200, 5) * EDSCALE);
l->set_text(TTR("Name:"));
add_del_dialog->add_child(l);
- name_select_label=l;
+ name_select_label = l;
- name_edit = memnew( LineEdit );
- name_edit->set_pos(Point2(200,25)*EDSCALE);
- name_edit->set_size(Point2(150,5)*EDSCALE);
+ name_edit = memnew(LineEdit);
+ name_edit->set_pos(Point2(200, 25) * EDSCALE);
+ name_edit->set_size(Point2(150, 5) * EDSCALE);
add_del_dialog->add_child(name_edit);
- name_menu = memnew( MenuButton );
- name_menu->set_pos(Point2(360,25)*EDSCALE);
- name_menu->set_size(Point2(30,5)*EDSCALE);
+ name_menu = memnew(MenuButton);
+ name_menu->set_pos(Point2(360, 25) * EDSCALE);
+ name_menu->set_size(Point2(30, 5) * EDSCALE);
name_menu->set_text("..");
add_del_dialog->add_child(name_menu);
- name_menu->get_popup()->connect("about_to_show", this,"_name_menu_about_to_show");
- name_menu->get_popup()->connect("id_pressed", this,"_name_menu_cbk");
+ name_menu->get_popup()->connect("about_to_show", this, "_name_menu_about_to_show");
+ name_menu->get_popup()->connect("id_pressed", this, "_name_menu_cbk");
- type_select_label= memnew( Label );
- type_select_label->set_pos( Point2(400,5)*EDSCALE );
+ type_select_label = memnew(Label);
+ type_select_label->set_pos(Point2(400, 5) * EDSCALE);
type_select_label->set_text(TTR("Data Type:"));
add_del_dialog->add_child(type_select_label);
- type_select = memnew( OptionButton );
+ type_select = memnew(OptionButton);
type_select->add_item(TTR("Icon"));
type_select->add_item(TTR("Style"));
type_select->add_item(TTR("Font"));
type_select->add_item(TTR("Color"));
type_select->add_item(TTR("Constant"));
- type_select->set_pos( Point2( 400,25 )*EDSCALE );
- type_select->set_size( Point2( 80,5 )*EDSCALE );
-
+ type_select->set_pos(Point2(400, 25) * EDSCALE);
+ type_select->set_size(Point2(80, 5) * EDSCALE);
add_del_dialog->add_child(type_select);
- add_del_dialog->get_ok()->connect("pressed", this,"_dialog_cbk");
-
+ add_del_dialog->get_ok()->connect("pressed", this, "_dialog_cbk");
- file_dialog = memnew( EditorFileDialog );
+ file_dialog = memnew(EditorFileDialog);
file_dialog->add_filter("*.theme ; Theme File");
add_child(file_dialog);
- file_dialog->connect("file_selected",this,"_save_template_cbk");
+ file_dialog->connect("file_selected", this, "_save_template_cbk");
//MenuButton *name_menu;
//LineEdit *name_edit;
-
}
void ThemeEditorPlugin::edit(Object *p_node) {
if (p_node && p_node->cast_to<Theme>()) {
theme_editor->show();
- theme_editor->edit( p_node->cast_to<Theme>() );
+ theme_editor->edit(p_node->cast_to<Theme>());
} else {
- theme_editor->edit( Ref<Theme>() );
+ theme_editor->edit(Ref<Theme>());
theme_editor->hide();
}
}
-bool ThemeEditorPlugin::handles(Object *p_node) const{
+bool ThemeEditorPlugin::handles(Object *p_node) const {
return p_node->is_class("Theme");
}
-void ThemeEditorPlugin::make_visible(bool p_visible){
+void ThemeEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
theme_editor->set_process(true);
@@ -984,14 +929,11 @@ void ThemeEditorPlugin::make_visible(bool p_visible){
ThemeEditorPlugin::ThemeEditorPlugin(EditorNode *p_node) {
- editor=p_node;
- theme_editor = memnew( ThemeEditor );
- theme_editor->set_custom_minimum_size(Size2(0,200));
+ editor = p_node;
+ theme_editor = memnew(ThemeEditor);
+ theme_editor->set_custom_minimum_size(Size2(0, 200));
//p_node->get_viewport()->add_child(theme_editor);
- button=editor->add_bottom_panel_item("Theme",theme_editor);
+ button = editor->add_bottom_panel_item("Theme", theme_editor);
button->hide();
-
-
}
-
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index f661da4cd5..3881cf1a41 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -29,23 +29,19 @@
#ifndef THEME_EDITOR_PLUGIN_H
#define THEME_EDITOR_PLUGIN_H
-#include "scene/resources/theme.h"
-#include "scene/gui/texture_rect.h"
-#include "scene/gui/option_button.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/check_box.h"
#include "scene/gui/button_group.h"
+#include "scene/gui/check_box.h"
+#include "scene/gui/file_dialog.h"
+#include "scene/gui/option_button.h"
#include "scene/gui/scroll_container.h"
+#include "scene/gui/texture_rect.h"
+#include "scene/resources/theme.h"
#include "editor/editor_node.h"
-
-
-
class ThemeEditor : public Control {
- GDCLASS( ThemeEditor, Control );
-
+ GDCLASS(ThemeEditor, Control);
ScrollContainer *scroll;
VBoxContainer *main_vb;
@@ -62,9 +58,9 @@ class ThemeEditor : public Control {
MenuButton *name_menu;
LineEdit *name_edit;
OptionButton *type_select;
- Label * type_select_label;
- Label * name_select_label;
- Label * dtype_select_label;
+ Label *type_select_label;
+ Label *name_select_label;
+ Label *dtype_select_label;
enum PopupMode {
POPUP_ADD,
@@ -88,29 +84,25 @@ class ThemeEditor : public Control {
void _propagate_redraw(Control *p_at);
void _refresh_interval();
-
protected:
void _notification(int p_what);
static void _bind_methods();
-public:
- void edit(const Ref<Theme>& p_theme);
+public:
+ void edit(const Ref<Theme> &p_theme);
ThemeEditor();
};
-
-
class ThemeEditorPlugin : public EditorPlugin {
- GDCLASS( ThemeEditorPlugin, EditorPlugin );
+ GDCLASS(ThemeEditorPlugin, EditorPlugin);
ThemeEditor *theme_editor;
EditorNode *editor;
Button *button;
public:
-
virtual String get_name() const { return "Theme"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
@@ -118,8 +110,6 @@ public:
virtual void make_visible(bool p_visible);
ThemeEditorPlugin(EditorNode *p_node);
-
};
-
#endif // THEME_EDITOR_PLUGIN_H
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index fb6d5a786a..8cda9848bd 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -28,25 +28,25 @@
/*************************************************************************/
#include "tile_map_editor_plugin.h"
-#include "os/keyboard.h"
-#include "os/input.h"
#include "canvas_item_editor_plugin.h"
-#include "editor/editor_settings.h"
#include "editor/editor_scale.h"
+#include "editor/editor_settings.h"
+#include "os/input.h"
+#include "os/keyboard.h"
void TileMapEditor::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- transp->set_icon(get_icon("Transpose","EditorIcons"));
- mirror_x->set_icon(get_icon("MirrorX","EditorIcons"));
- mirror_y->set_icon(get_icon("MirrorY","EditorIcons"));
- rotate_0->set_icon(get_icon("Rotate0","EditorIcons"));
- rotate_90->set_icon(get_icon("Rotate90","EditorIcons"));
- rotate_180->set_icon(get_icon("Rotate180","EditorIcons"));
- rotate_270->set_icon(get_icon("Rotate270","EditorIcons"));
+ transp->set_icon(get_icon("Transpose", "EditorIcons"));
+ mirror_x->set_icon(get_icon("MirrorX", "EditorIcons"));
+ mirror_y->set_icon(get_icon("MirrorY", "EditorIcons"));
+ rotate_0->set_icon(get_icon("Rotate0", "EditorIcons"));
+ rotate_90->set_icon(get_icon("Rotate90", "EditorIcons"));
+ rotate_180->set_icon(get_icon("Rotate180", "EditorIcons"));
+ rotate_270->set_icon(get_icon("Rotate270", "EditorIcons"));
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
@@ -60,24 +60,24 @@ void TileMapEditor::_notification(int p_what) {
void TileMapEditor::_menu_option(int p_option) {
- switch(p_option) {
+ switch (p_option) {
case OPTION_BUCKET: {
- tool=TOOL_BUCKET;
+ tool = TOOL_BUCKET;
canvas_item_editor->update();
} break;
case OPTION_PICK_TILE: {
- tool=TOOL_PICKING;
+ tool = TOOL_PICKING;
canvas_item_editor->update();
} break;
case OPTION_SELECT: {
- tool=TOOL_SELECTING;
- selection_active=false;
+ tool = TOOL_SELECTING;
+ selection_active = false;
canvas_item_editor->update();
} break;
@@ -86,7 +86,7 @@ void TileMapEditor::_menu_option(int p_option) {
_update_copydata();
if (selection_active) {
- tool=TOOL_DUPLICATING;
+ tool = TOOL_DUPLICATING;
canvas_item_editor->update();
}
@@ -97,15 +97,15 @@ void TileMapEditor::_menu_option(int p_option) {
return;
undo_redo->create_action("Erase Selection");
- for (int i=rectangle.pos.y;i<=rectangle.pos.y+rectangle.size.y;i++) {
- for (int j=rectangle.pos.x;j<=rectangle.pos.x+rectangle.size.x;j++) {
+ for (int i = rectangle.pos.y; i <= rectangle.pos.y + rectangle.size.y; i++) {
+ for (int j = rectangle.pos.x; j <= rectangle.pos.x + rectangle.size.x; j++) {
_set_cell(Point2i(j, i), TileMap::INVALID_CELL, false, false, false, true);
}
}
undo_redo->commit_action();
- selection_active=false;
+ selection_active = false;
copydata.clear();
canvas_item_editor->update();
@@ -113,15 +113,15 @@ void TileMapEditor::_menu_option(int p_option) {
}
}
-void TileMapEditor::_canvas_mouse_enter() {
+void TileMapEditor::_canvas_mouse_enter() {
- mouse_over=true;
+ mouse_over = true;
canvas_item_editor->update();
}
-void TileMapEditor::_canvas_mouse_exit() {
+void TileMapEditor::_canvas_mouse_exit() {
- mouse_over=false;
+ mouse_over = false;
canvas_item_editor->update();
}
@@ -129,7 +129,7 @@ int TileMapEditor::get_selected_tile() const {
int item = palette->get_current();
- if (item==-1)
+ if (item == -1)
return TileMap::INVALID_CELL;
return palette->get_item_metadata(item);
@@ -145,47 +145,45 @@ void TileMapEditor::set_selected_tile(int p_tile) {
}
}
-void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bool p_flip_v, bool p_transpose,bool p_with_undo) {
+void TileMapEditor::_set_cell(const Point2i &p_pos, int p_value, bool p_flip_h, bool p_flip_v, bool p_transpose, bool p_with_undo) {
ERR_FAIL_COND(!node);
- int prev_val=node->get_cell(p_pos.x,p_pos.y);
+ int prev_val = node->get_cell(p_pos.x, p_pos.y);
- bool prev_flip_h=node->is_cell_x_flipped(p_pos.x,p_pos.y);
- bool prev_flip_v=node->is_cell_y_flipped(p_pos.x,p_pos.y);
- bool prev_transpose=node->is_cell_transposed(p_pos.x,p_pos.y);
+ bool prev_flip_h = node->is_cell_x_flipped(p_pos.x, p_pos.y);
+ bool prev_flip_v = node->is_cell_y_flipped(p_pos.x, p_pos.y);
+ bool prev_transpose = node->is_cell_transposed(p_pos.x, p_pos.y);
- if (p_value==prev_val && p_flip_h==prev_flip_h && p_flip_v==prev_flip_v && p_transpose==prev_transpose)
+ if (p_value == prev_val && p_flip_h == prev_flip_h && p_flip_v == prev_flip_v && p_transpose == prev_transpose)
return; //check that it's actually different
if (p_with_undo) {
- undo_redo->add_do_method(node,"set_cellv",Point2(p_pos),p_value,p_flip_h,p_flip_v,p_transpose);
- undo_redo->add_undo_method(node,"set_cellv",Point2(p_pos),prev_val,prev_flip_h,prev_flip_v,prev_transpose);
+ undo_redo->add_do_method(node, "set_cellv", Point2(p_pos), p_value, p_flip_h, p_flip_v, p_transpose);
+ undo_redo->add_undo_method(node, "set_cellv", Point2(p_pos), prev_val, prev_flip_h, prev_flip_v, prev_transpose);
} else {
- node->set_cell(p_pos.x,p_pos.y,p_value,p_flip_h,p_flip_v,p_transpose);
+ node->set_cell(p_pos.x, p_pos.y, p_value, p_flip_h, p_flip_v, p_transpose);
}
-
}
-void TileMapEditor::_text_entered(const String& p_text) {
+void TileMapEditor::_text_entered(const String &p_text) {
canvas_item_editor->grab_focus();
}
-void TileMapEditor::_text_changed(const String& p_text) {
+void TileMapEditor::_text_changed(const String &p_text) {
_update_palette();
}
-void TileMapEditor::_sbox_input(const InputEvent& p_ie) {
+void TileMapEditor::_sbox_input(const InputEvent &p_ie) {
- if (p_ie.type==InputEvent::KEY && (
- p_ie.key.scancode == KEY_UP ||
- p_ie.key.scancode == KEY_DOWN ||
- p_ie.key.scancode == KEY_PAGEUP ||
- p_ie.key.scancode == KEY_PAGEDOWN ) ) {
+ if (p_ie.type == InputEvent::KEY && (p_ie.key.scancode == KEY_UP ||
+ p_ie.key.scancode == KEY_DOWN ||
+ p_ie.key.scancode == KEY_PAGEUP ||
+ p_ie.key.scancode == KEY_PAGEDOWN)) {
palette->call("_gui_input", p_ie);
search_box->accept_event();
@@ -200,7 +198,7 @@ void TileMapEditor::_update_palette() {
int selected = get_selected_tile();
palette->clear();
- Ref<TileSet> tileset=node->get_tileset();
+ Ref<TileSet> tileset = node->get_tileset();
if (tileset.is_null())
return;
@@ -212,25 +210,25 @@ void TileMapEditor::_update_palette() {
float min_size = EDITOR_DEF("editors/tile_map/preview_size", 64);
min_size *= EDSCALE;
- int hseparation = EDITOR_DEF("editors/tile_map/palette_item_hseparation",8);
+ int hseparation = EDITOR_DEF("editors/tile_map/palette_item_hseparation", 8);
bool show_tile_names = bool(EDITOR_DEF("editors/tile_map/show_tile_names", true));
- palette->add_constant_override("hseparation", hseparation*EDSCALE);
- palette->add_constant_override("vseparation", 8*EDSCALE);
+ palette->add_constant_override("hseparation", hseparation * EDSCALE);
+ palette->add_constant_override("vseparation", 8 * EDSCALE);
palette->set_fixed_icon_size(Size2(min_size, min_size));
palette->set_fixed_column_width(min_size * MAX(size_slider->get_value(), 1));
String filter = search_box->get_text().strip_edges();
- for (List<int>::Element *E=tiles.front();E;E=E->next()) {
+ for (List<int>::Element *E = tiles.front(); E; E = E->next()) {
String name;
- if (tileset->tile_get_name(E->get())!="") {
- name = itos(E->get())+" - "+tileset->tile_get_name(E->get());
+ if (tileset->tile_get_name(E->get()) != "") {
+ name = itos(E->get()) + " - " + tileset->tile_get_name(E->get());
} else {
- name = "#"+itos(E->get());
+ name = "#" + itos(E->get());
}
if (filter != "" && !filter.is_subsequence_ofi(name))
@@ -248,14 +246,14 @@ void TileMapEditor::_update_palette() {
Rect2 region = tileset->tile_get_region(E->get());
if (!region.has_no_area())
- palette->set_item_icon_region(palette->get_item_count()-1, region);
+ palette->set_item_icon_region(palette->get_item_count() - 1, region);
- palette->set_item_icon(palette->get_item_count()-1, tex);
+ palette->set_item_icon(palette->get_item_count() - 1, tex);
}
- palette->set_item_metadata(palette->get_item_count()-1, E->get());
+ palette->set_item_metadata(palette->get_item_count() - 1, E->get());
}
-
+
palette->set_same_column_width(true);
if (selected != -1)
@@ -264,11 +262,11 @@ void TileMapEditor::_update_palette() {
palette->select(0);
}
-void TileMapEditor::_pick_tile(const Point2& p_pos) {
+void TileMapEditor::_pick_tile(const Point2 &p_pos) {
int id = node->get_cell(p_pos.x, p_pos.y);
- if (id==TileMap::INVALID_CELL)
+ if (id == TileMap::INVALID_CELL)
return;
if (search_box->get_text().strip_edges() != "") {
@@ -287,7 +285,7 @@ void TileMapEditor::_pick_tile(const Point2& p_pos) {
canvas_item_editor->update();
}
-PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i& p_start, bool erase, bool preview) {
+PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, bool preview) {
int prev_id = node->get_cell(p_start.x, p_start.y);
int id = TileMap::INVALID_CELL;
@@ -299,34 +297,33 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i& p_start, bool era
}
Rect2i r = node->get_item_rect();
- r.pos = r.pos/node->get_cell_size();
- r.size = r.size/node->get_cell_size();
+ r.pos = r.pos / node->get_cell_size();
+ r.size = r.size / node->get_cell_size();
int area = r.get_area();
- if(preview) {
+ if (preview) {
// Test if we can re-use the result from preview bucket fill
bool invalidate_cache = false;
// Area changed
- if(r != bucket_cache_rect)
+ if (r != bucket_cache_rect)
_clear_bucket_cache();
// Cache grid is not initialized
- if(bucket_cache_visited == 0) {
+ if (bucket_cache_visited == 0) {
bucket_cache_visited = new bool[area];
invalidate_cache = true;
}
// Tile ID changed or position wasn't visited by the previous fill
int loc = (p_start.x - r.get_pos().x) + (p_start.y - r.get_pos().y) * r.get_size().x;
- if(prev_id != bucket_cache_tile || !bucket_cache_visited[loc]) {
+ if (prev_id != bucket_cache_tile || !bucket_cache_visited[loc]) {
invalidate_cache = true;
}
- if(invalidate_cache) {
- for(int i = 0; i < area; ++i)
+ if (invalidate_cache) {
+ for (int i = 0; i < area; ++i)
bucket_cache_visited[i] = false;
bucket_cache = PoolVector<Vector2>();
bucket_cache_tile = prev_id;
bucket_cache_rect = r;
- }
- else {
+ } else {
return bucket_cache;
}
}
@@ -346,14 +343,13 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i& p_start, bool era
if (node->get_cell(n.x, n.y) == prev_id) {
- if(preview) {
+ if (preview) {
int loc = (n.x - r.get_pos().x) + (n.y - r.get_pos().y) * r.get_size().x;
- if(bucket_cache_visited[loc])
+ if (bucket_cache_visited[loc])
continue;
bucket_cache_visited[loc] = true;
bucket_cache.push_back(n);
- }
- else {
+ } else {
node->set_cellv(n, id, flip_h, flip_v, transpose);
points.push_back(n);
}
@@ -368,7 +364,7 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i& p_start, bool era
return preview ? bucket_cache : points;
}
-void TileMapEditor::_fill_points(const PoolVector<Vector2> p_points, const Dictionary& p_op) {
+void TileMapEditor::_fill_points(const PoolVector<Vector2> p_points, const Dictionary &p_op) {
int len = p_points.size();
PoolVector<Vector2>::Read pr = p_points.read();
@@ -378,7 +374,7 @@ void TileMapEditor::_fill_points(const PoolVector<Vector2> p_points, const Dicti
bool yf = p_op["flip_v"];
bool tr = p_op["transpose"];
- for (int i=0;i<len;i++) {
+ for (int i = 0; i < len; i++) {
_set_cell(pr[i], id, xf, yf, tr);
}
@@ -389,33 +385,33 @@ void TileMapEditor::_erase_points(const PoolVector<Vector2> p_points) {
int len = p_points.size();
PoolVector<Vector2>::Read pr = p_points.read();
- for (int i=0;i<len;i++) {
+ for (int i = 0; i < len; i++) {
_set_cell(pr[i], TileMap::INVALID_CELL);
}
}
-void TileMapEditor::_select(const Point2i& p_from, const Point2i& p_to) {
+void TileMapEditor::_select(const Point2i &p_from, const Point2i &p_to) {
- Point2i begin=p_from;
- Point2i end=p_to;
+ Point2i begin = p_from;
+ Point2i end = p_to;
if (begin.x > end.x) {
- SWAP( begin.x, end.x);
+ SWAP(begin.x, end.x);
}
if (begin.y > end.y) {
- SWAP( begin.y, end.y);
+ SWAP(begin.y, end.y);
}
- rectangle.pos=begin;
- rectangle.size=end-begin;
+ rectangle.pos = begin;
+ rectangle.size = end - begin;
canvas_item_editor->update();
}
-void TileMapEditor::_draw_cell(int p_cell, const Point2i& p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D& p_xform) {
+void TileMapEditor::_draw_cell(int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform) {
Ref<Texture> t = node->get_tileset()->tile_get_texture(p_cell);
@@ -448,75 +444,74 @@ void TileMapEditor::_draw_cell(int p_cell, const Point2i& p_point, bool p_flip_h
SWAP(tile_ofs.x, tile_ofs.y);
}
if (p_flip_h) {
- sc.x*=-1.0;
- tile_ofs.x*=-1.0;
+ sc.x *= -1.0;
+ tile_ofs.x *= -1.0;
}
if (p_flip_v) {
- sc.y*=-1.0;
- tile_ofs.y*=-1.0;
+ sc.y *= -1.0;
+ tile_ofs.y *= -1.0;
}
- if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) {
+ if (node->get_tile_origin() == TileMap::TILE_ORIGIN_TOP_LEFT) {
- rect.pos+=tile_ofs;
- } else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_BOTTOM_LEFT) {
+ rect.pos += tile_ofs;
+ } else if (node->get_tile_origin() == TileMap::TILE_ORIGIN_BOTTOM_LEFT) {
Size2 cell_size = node->get_cell_size();
-
- rect.pos+=tile_ofs;
-
- if(p_transpose)
- {
- if(p_flip_h)
- rect.pos.x-=cell_size.x;
+
+ rect.pos += tile_ofs;
+
+ if (p_transpose) {
+ if (p_flip_h)
+ rect.pos.x -= cell_size.x;
else
- rect.pos.x+=cell_size.x;
+ rect.pos.x += cell_size.x;
} else {
- if(p_flip_v)
- rect.pos.y-=cell_size.y;
+ if (p_flip_v)
+ rect.pos.y -= cell_size.y;
else
- rect.pos.y+=cell_size.y;
+ rect.pos.y += cell_size.y;
}
- } else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) {
- rect.pos+=node->get_cell_size()/2;
+ } else if (node->get_tile_origin() == TileMap::TILE_ORIGIN_CENTER) {
+ rect.pos += node->get_cell_size() / 2;
Vector2 s = r.size;
- Vector2 center = (s/2) - tile_ofs;
+ Vector2 center = (s / 2) - tile_ofs;
if (p_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 (p_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;
}
- rect.pos=p_xform.xform(rect.pos);
- rect.size*=sc;
+ rect.pos = p_xform.xform(rect.pos);
+ rect.size *= sc;
if (r.has_no_area())
- canvas_item_editor->draw_texture_rect(t, rect, false, Color(1,1,1,0.5), p_transpose);
+ canvas_item_editor->draw_texture_rect(t, rect, false, Color(1, 1, 1, 0.5), p_transpose);
else
- canvas_item_editor->draw_texture_rect_region(t, rect, r, Color(1,1,1,0.5), p_transpose);
+ canvas_item_editor->draw_texture_rect_region(t, rect, r, Color(1, 1, 1, 0.5), p_transpose);
}
-void TileMapEditor::_draw_fill_preview(int p_cell, const Point2i& p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D& p_xform) {
+void TileMapEditor::_draw_fill_preview(int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform) {
PoolVector<Vector2> points = _bucket_fill(p_point, false, true);
PoolVector<Vector2>::Read pr = points.read();
int len = points.size();
int time_after = OS::get_singleton()->get_ticks_msec();
- for(int i = 0; i < len; ++i) {
+ for (int i = 0; i < len; ++i) {
_draw_cell(p_cell, pr[i], p_flip_h, p_flip_v, p_transpose, p_xform);
}
}
void TileMapEditor::_clear_bucket_cache() {
- if(bucket_cache_visited) {
+ if (bucket_cache_visited) {
delete[] bucket_cache_visited;
bucket_cache_visited = 0;
}
@@ -529,19 +524,19 @@ void TileMapEditor::_update_copydata() {
if (!selection_active)
return;
- for (int i=rectangle.pos.y;i<=rectangle.pos.y+rectangle.size.y;i++) {
+ for (int i = rectangle.pos.y; i <= rectangle.pos.y + rectangle.size.y; i++) {
- for (int j=rectangle.pos.x;j<=rectangle.pos.x+rectangle.size.x;j++) {
+ for (int j = rectangle.pos.x; j <= rectangle.pos.x + rectangle.size.x; j++) {
TileData tcd;
- tcd.cell=node->get_cell(j, i);
+ tcd.cell = node->get_cell(j, i);
- if (tcd.cell!=TileMap::INVALID_CELL) {
- tcd.pos=Point2i(j, i);
- tcd.flip_h=node->is_cell_x_flipped(j,i);
- tcd.flip_v=node->is_cell_y_flipped(j,i);
- tcd.transpose=node->is_cell_transposed(j,i);
+ if (tcd.cell != TileMap::INVALID_CELL) {
+ tcd.pos = Point2i(j, i);
+ tcd.flip_h = node->is_cell_x_flipped(j, i);
+ tcd.flip_v = node->is_cell_y_flipped(j, i);
+ tcd.transpose = node->is_cell_transposed(j, i);
}
copydata.push_back(tcd);
@@ -563,7 +558,7 @@ static inline Vector<Point2i> line(int x0, int x1, int y0, int y1) {
int sy = y0 > y1 ? -1 : 1;
if (dx > dy) {
- float err = dx/2;
+ float err = dx / 2;
for (; x != x1; x += sx) {
points.push_back(Vector2(x, y));
@@ -575,7 +570,7 @@ static inline Vector<Point2i> line(int x0, int x1, int y0, int y1) {
}
}
} else {
- float err = dy/2;
+ float err = dy / 2;
for (; y != y1; y += sy) {
points.push_back(Vector2(x, y));
@@ -593,7 +588,7 @@ static inline Vector<Point2i> line(int x0, int x1, int y0, int y1) {
return points;
}
-bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
+bool TileMapEditor::forward_gui_input(const InputEvent &p_event) {
if (!node || !node->get_tileset().is_valid() || !node->is_visible_in_tree())
return false;
@@ -601,98 +596,98 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
Transform2D xform_inv = xform.affine_inverse();
- switch(p_event.type) {
+ switch (p_event.type) {
case 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) {
if (Input::get_singleton()->is_key_pressed(KEY_SPACE))
return false; //drag
- if (tool==TOOL_NONE) {
+ if (tool == TOOL_NONE) {
if (mb.mod.shift) {
if (mb.mod.control)
- tool=TOOL_RECTANGLE_PAINT;
+ tool = TOOL_RECTANGLE_PAINT;
else
- tool=TOOL_LINE_PAINT;
+ tool = TOOL_LINE_PAINT;
- selection_active=false;
- rectangle_begin=over_tile;
+ selection_active = false;
+ rectangle_begin = over_tile;
return true;
}
if (mb.mod.control) {
- tool=TOOL_PICKING;
+ tool = TOOL_PICKING;
_pick_tile(over_tile);
return true;
}
- tool=TOOL_PAINTING;
+ tool = TOOL_PAINTING;
}
- if (tool==TOOL_PAINTING) {
+ if (tool == TOOL_PAINTING) {
int id = get_selected_tile();
- if (id!=TileMap::INVALID_CELL) {
+ if (id != TileMap::INVALID_CELL) {
- tool=TOOL_PAINTING;
+ tool = TOOL_PAINTING;
paint_undo.clear();
- paint_undo[over_tile]=_get_op_from_cell(over_tile);
+ paint_undo[over_tile] = _get_op_from_cell(over_tile);
_set_cell(over_tile, id, flip_h, flip_v, transpose);
}
- } else if (tool==TOOL_PICKING) {
+ } else if (tool == TOOL_PICKING) {
_pick_tile(over_tile);
- } else if (tool==TOOL_SELECTING) {
+ } else if (tool == TOOL_SELECTING) {
- selection_active=true;
- rectangle_begin=over_tile;
+ selection_active = true;
+ rectangle_begin = over_tile;
}
return true;
} else {
- if (tool!=TOOL_NONE) {
+ if (tool != TOOL_NONE) {
- if (tool==TOOL_PAINTING) {
+ if (tool == TOOL_PAINTING) {
- int id=get_selected_tile();
+ int id = get_selected_tile();
- if (id!=TileMap::INVALID_CELL && paint_undo.size()) {
+ if (id != TileMap::INVALID_CELL && paint_undo.size()) {
undo_redo->create_action(TTR("Paint TileMap"));
- for (Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+ for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
- Point2 p=E->key();
- undo_redo->add_do_method(node,"set_cellv",p,id,flip_h,flip_v,transpose);
- undo_redo->add_undo_method(node,"set_cellv",p,E->get().idx,E->get().xf,E->get().yf,E->get().tr);
+ Point2 p = E->key();
+ undo_redo->add_do_method(node, "set_cellv", p, id, flip_h, flip_v, transpose);
+ undo_redo->add_undo_method(node, "set_cellv", p, E->get().idx, E->get().xf, E->get().yf, E->get().tr);
}
undo_redo->commit_action();
paint_undo.clear();
}
- } else if (tool==TOOL_LINE_PAINT) {
+ } else if (tool == TOOL_LINE_PAINT) {
- int id=get_selected_tile();
+ int id = get_selected_tile();
- if (id!=TileMap::INVALID_CELL) {
+ if (id != TileMap::INVALID_CELL) {
undo_redo->create_action("Line Draw");
- for (Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+ for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
_set_cell(E->key(), id, flip_h, flip_v, transpose, true);
}
@@ -702,15 +697,15 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
canvas_item_editor->update();
}
- } else if (tool==TOOL_RECTANGLE_PAINT) {
+ } else if (tool == TOOL_RECTANGLE_PAINT) {
- int id=get_selected_tile();
+ int id = get_selected_tile();
- if (id!=TileMap::INVALID_CELL) {
+ if (id != TileMap::INVALID_CELL) {
undo_redo->create_action("Rectangle Paint");
- for (int i=rectangle.pos.y;i<=rectangle.pos.y+rectangle.size.y;i++) {
- for (int j=rectangle.pos.x;j<=rectangle.pos.x+rectangle.size.x;j++) {
+ for (int i = rectangle.pos.y; i <= rectangle.pos.y + rectangle.size.y; i++) {
+ for (int j = rectangle.pos.x; j <= rectangle.pos.x + rectangle.size.x; j++) {
_set_cell(Point2i(j, i), id, flip_h, flip_v, transpose, true);
}
@@ -719,14 +714,14 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
canvas_item_editor->update();
}
- } else if (tool==TOOL_DUPLICATING) {
+ } else if (tool == TOOL_DUPLICATING) {
- Point2 ofs = over_tile-rectangle.pos;
+ Point2 ofs = over_tile - rectangle.pos;
undo_redo->create_action(TTR("Duplicate"));
- for (List<TileData>::Element *E=copydata.front();E;E=E->next()) {
+ for (List<TileData>::Element *E = copydata.front(); E; E = E->next()) {
- _set_cell(E->get().pos+ofs,E->get().cell,E->get().flip_h,E->get().flip_v,E->get().transpose,true);
+ _set_cell(E->get().pos + ofs, E->get().cell, E->get().flip_h, E->get().flip_v, E->get().transpose, true);
}
undo_redo->commit_action();
@@ -734,11 +729,11 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
canvas_item_editor->update();
- } else if (tool==TOOL_SELECTING) {
+ } else if (tool == TOOL_SELECTING) {
canvas_item_editor->update();
- } else if (tool==TOOL_BUCKET) {
+ } else if (tool == TOOL_BUCKET) {
Dictionary pop;
pop["id"] = node->get_cell(over_tile.x, over_tile.y);
@@ -765,28 +760,28 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
undo_redo->commit_action();
}
- tool=TOOL_NONE;
+ tool = TOOL_NONE;
return true;
}
}
- } else if (mb.button_index==BUTTON_RIGHT) {
+ } else if (mb.button_index == BUTTON_RIGHT) {
if (mb.pressed) {
- if (tool==TOOL_SELECTING || selection_active) {
+ if (tool == TOOL_SELECTING || selection_active) {
- tool=TOOL_NONE;
- selection_active=false;
+ tool = TOOL_NONE;
+ selection_active = false;
canvas_item_editor->update();
return true;
}
- if (tool==TOOL_DUPLICATING) {
+ if (tool == TOOL_DUPLICATING) {
- tool=TOOL_NONE;
+ tool = TOOL_NONE;
copydata.clear();
canvas_item_editor->update();
@@ -794,7 +789,7 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
return true;
}
- if (tool==TOOL_NONE) {
+ if (tool == TOOL_NONE) {
paint_undo.clear();
@@ -803,17 +798,17 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
if (mb.mod.shift) {
if (mb.mod.control)
- tool=TOOL_RECTANGLE_ERASE;
+ tool = TOOL_RECTANGLE_ERASE;
else
- tool=TOOL_LINE_ERASE;
+ tool = TOOL_LINE_ERASE;
- selection_active=false;
- rectangle_begin=local;
+ selection_active = false;
+ rectangle_begin = local;
} else {
- tool=TOOL_ERASING;
+ tool = TOOL_ERASING;
- paint_undo[local]=_get_op_from_cell(local);
+ paint_undo[local] = _get_op_from_cell(local);
_set_cell(local, TileMap::INVALID_CELL);
}
@@ -821,30 +816,30 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
}
} else {
- if (tool==TOOL_ERASING || tool==TOOL_RECTANGLE_ERASE || tool==TOOL_LINE_ERASE) {
+ if (tool == TOOL_ERASING || tool == TOOL_RECTANGLE_ERASE || tool == TOOL_LINE_ERASE) {
if (paint_undo.size()) {
undo_redo->create_action(TTR("Erase TileMap"));
- for (Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+ for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
- Point2 p=E->key();
- undo_redo->add_do_method(node,"set_cellv",p,TileMap::INVALID_CELL,false,false,false);
- undo_redo->add_undo_method(node,"set_cellv",p,E->get().idx,E->get().xf,E->get().yf,E->get().tr);
+ Point2 p = E->key();
+ undo_redo->add_do_method(node, "set_cellv", p, TileMap::INVALID_CELL, false, false, false);
+ undo_redo->add_undo_method(node, "set_cellv", p, E->get().idx, E->get().xf, E->get().yf, E->get().tr);
}
undo_redo->commit_action();
paint_undo.clear();
}
- if (tool==TOOL_RECTANGLE_ERASE || tool==TOOL_LINE_ERASE) {
+ if (tool == TOOL_RECTANGLE_ERASE || tool == TOOL_LINE_ERASE) {
canvas_item_editor->update();
}
- tool=TOOL_NONE;
+ tool = TOOL_NONE;
return true;
- } else if (tool==TOOL_BUCKET) {
+ } else if (tool == TOOL_BUCKET) {
Dictionary pop;
pop["id"] = node->get_cell(over_tile.x, over_tile.y);
@@ -869,13 +864,13 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_event.mouse_motion;
+ const InputEventMouseMotion &mm = p_event.mouse_motion;
- Point2i new_over_tile = node->world_to_map(xform_inv.xform(Point2(mm.x,mm.y)));
+ Point2i new_over_tile = node->world_to_map(xform_inv.xform(Point2(mm.x, mm.y)));
- if (new_over_tile!=over_tile) {
+ if (new_over_tile != over_tile) {
- over_tile=new_over_tile;
+ over_tile = new_over_tile;
canvas_item_editor->update();
}
@@ -884,15 +879,15 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
if (node->get_tileset()->has_tile(tile_under))
tile_name = node->get_tileset()->tile_get_name(tile_under);
- tile_info->set_text(String::num(over_tile.x)+", "+String::num(over_tile.y)+" ["+tile_name+"]");
+ tile_info->set_text(String::num(over_tile.x) + ", " + String::num(over_tile.y) + " [" + tile_name + "]");
- if (tool==TOOL_PAINTING) {
+ if (tool == TOOL_PAINTING) {
int id = get_selected_tile();
- if (id!=TileMap::INVALID_CELL) {
+ if (id != TileMap::INVALID_CELL) {
if (!paint_undo.has(over_tile)) {
- paint_undo[over_tile]=_get_op_from_cell(over_tile);
+ paint_undo[over_tile] = _get_op_from_cell(over_tile);
}
_set_cell(over_tile, id, flip_h, flip_v, transpose);
@@ -901,21 +896,21 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
}
}
- if (tool==TOOL_SELECTING) {
+ if (tool == TOOL_SELECTING) {
_select(rectangle_begin, over_tile);
return true;
}
- if (tool==TOOL_LINE_PAINT || tool==TOOL_LINE_ERASE) {
+ if (tool == TOOL_LINE_PAINT || tool == TOOL_LINE_ERASE) {
int id = get_selected_tile();
- bool erasing = (tool==TOOL_LINE_ERASE);
+ bool erasing = (tool == TOOL_LINE_ERASE);
if (erasing && paint_undo.size()) {
- for (Map<Point2i, CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+ for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
_set_cell(E->key(), E->get().idx, E->get().xf, E->get().yf, E->get().tr);
}
@@ -923,13 +918,13 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
paint_undo.clear();
- if (id!=TileMap::INVALID_CELL) {
+ if (id != TileMap::INVALID_CELL) {
Vector<Point2i> points = line(rectangle_begin.x, over_tile.x, rectangle_begin.y, over_tile.y);
- for (int i=0;i<points.size();i++) {
+ for (int i = 0; i < points.size(); i++) {
- paint_undo[points[i]]=_get_op_from_cell(points[i]);
+ paint_undo[points[i]] = _get_op_from_cell(points[i]);
if (erasing)
_set_cell(points[i], TileMap::INVALID_CELL);
@@ -940,15 +935,15 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
return true;
}
- if (tool==TOOL_RECTANGLE_PAINT || tool==TOOL_RECTANGLE_ERASE) {
+ if (tool == TOOL_RECTANGLE_PAINT || tool == TOOL_RECTANGLE_ERASE) {
_select(rectangle_begin, over_tile);
- if (tool==TOOL_RECTANGLE_ERASE) {
+ if (tool == TOOL_RECTANGLE_ERASE) {
if (paint_undo.size()) {
- for (Map<Point2i, CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+ for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
_set_cell(E->key(), E->get().idx, E->get().xf, E->get().yf, E->get().tr);
}
@@ -956,11 +951,11 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
paint_undo.clear();
- for (int i=rectangle.pos.y;i<=rectangle.pos.y+rectangle.size.y;i++) {
- for (int j=rectangle.pos.x;j<=rectangle.pos.x+rectangle.size.x;j++) {
+ for (int i = rectangle.pos.y; i <= rectangle.pos.y + rectangle.size.y; i++) {
+ for (int j = rectangle.pos.x; j <= rectangle.pos.x + rectangle.size.x; j++) {
Point2i tile = Point2i(j, i);
- paint_undo[tile]=_get_op_from_cell(tile);
+ paint_undo[tile] = _get_op_from_cell(tile);
_set_cell(tile, TileMap::INVALID_CELL);
}
@@ -969,17 +964,17 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
return true;
}
- if (tool==TOOL_ERASING) {
+ if (tool == TOOL_ERASING) {
if (!paint_undo.has(over_tile)) {
- paint_undo[over_tile]=_get_op_from_cell(over_tile);
+ paint_undo[over_tile] = _get_op_from_cell(over_tile);
}
_set_cell(over_tile, TileMap::INVALID_CELL);
return true;
}
- if (tool==TOOL_PICKING && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+ if (tool == TOOL_PICKING && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
_pick_tile(over_tile);
@@ -993,21 +988,21 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
if (!k.pressed)
break;
- if (k.scancode==KEY_ESCAPE) {
+ if (k.scancode == KEY_ESCAPE) {
- if (tool==TOOL_DUPLICATING)
+ if (tool == TOOL_DUPLICATING)
copydata.clear();
- else if (tool==TOOL_SELECTING || selection_active)
- selection_active=false;
+ else if (tool == TOOL_SELECTING || selection_active)
+ selection_active = false;
- tool=TOOL_NONE;
+ tool = TOOL_NONE;
canvas_item_editor->update();
return true;
}
- if (tool!=TOOL_NONE || !mouse_over)
+ if (tool != TOOL_NONE || !mouse_over)
return false;
if (ED_IS_SHORTCUT("tile_map_editor/erase_selection", p_event)) {
@@ -1016,8 +1011,8 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
return true;
}
if (ED_IS_SHORTCUT("tile_map_editor/select", p_event)) {
- tool=TOOL_SELECTING;
- selection_active=false;
+ tool = TOOL_SELECTING;
+ selection_active = false;
canvas_item_editor->update();
@@ -1027,7 +1022,7 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
_update_copydata();
if (selection_active) {
- tool=TOOL_DUPLICATING;
+ tool = TOOL_DUPLICATING;
canvas_item_editor->update();
@@ -1041,13 +1036,13 @@ bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
return true;
}
if (ED_IS_SHORTCUT("tile_map_editor/mirror_x", p_event)) {
- flip_h=!flip_h;
+ flip_h = !flip_h;
mirror_x->set_pressed(flip_h);
canvas_item_editor->update();
return true;
}
if (ED_IS_SHORTCUT("tile_map_editor/mirror_y", p_event)) {
- flip_v=!flip_v;
+ flip_v = !flip_v;
mirror_y->set_pressed(flip_v);
canvas_item_editor->update();
return true;
@@ -1074,92 +1069,86 @@ void TileMapEditor::_canvas_draw() {
Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
Transform2D xform_inv = xform.affine_inverse();
-
- Size2 screen_size=canvas_item_editor->get_size();
+ Size2 screen_size = canvas_item_editor->get_size();
{
Rect2 aabb;
- aabb.pos=node->world_to_map(xform_inv.xform(Vector2()));
- aabb.expand_to(node->world_to_map(xform_inv.xform(Vector2(0,screen_size.height))));
- aabb.expand_to(node->world_to_map(xform_inv.xform(Vector2(screen_size.width,0))));
+ aabb.pos = node->world_to_map(xform_inv.xform(Vector2()));
+ aabb.expand_to(node->world_to_map(xform_inv.xform(Vector2(0, screen_size.height))));
+ aabb.expand_to(node->world_to_map(xform_inv.xform(Vector2(screen_size.width, 0))));
aabb.expand_to(node->world_to_map(xform_inv.xform(screen_size)));
- Rect2i si=aabb.grow(1.0);
+ Rect2i si = aabb.grow(1.0);
- if (node->get_half_offset()!=TileMap::HALF_OFFSET_X) {
+ if (node->get_half_offset() != TileMap::HALF_OFFSET_X) {
- int max_lines=2000; //avoid crash if size too smal
+ int max_lines = 2000; //avoid crash if size too smal
- for (int i=(si.pos.x)-1;i<=(si.pos.x+si.size.x);i++) {
+ for (int i = (si.pos.x) - 1; i <= (si.pos.x + si.size.x); i++) {
- Vector2 from = xform.xform(node->map_to_world(Vector2(i,si.pos.y)));
- Vector2 to = xform.xform(node->map_to_world(Vector2(i,si.pos.y+si.size.y+1)));
+ Vector2 from = xform.xform(node->map_to_world(Vector2(i, si.pos.y)));
+ Vector2 to = xform.xform(node->map_to_world(Vector2(i, si.pos.y + si.size.y + 1)));
- Color col=i==0?Color(1,0.8,0.2,0.5):Color(1,0.3,0.1,0.2);
- canvas_item_editor->draw_line(from,to,col,1);
- if (max_lines--==0)
+ Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
+ canvas_item_editor->draw_line(from, to, col, 1);
+ if (max_lines-- == 0)
break;
}
} else {
- int max_lines=10000; //avoid crash if size too smal
+ int max_lines = 10000; //avoid crash if size too smal
- for (int i=(si.pos.x)-1;i<=(si.pos.x+si.size.x);i++) {
+ for (int i = (si.pos.x) - 1; i <= (si.pos.x + si.size.x); i++) {
- for (int j=(si.pos.y)-1;j<=(si.pos.y+si.size.y);j++) {
+ for (int j = (si.pos.y) - 1; j <= (si.pos.y + si.size.y); j++) {
Vector2 ofs;
- if (ABS(j)&1) {
- ofs=cell_xf[0]*0.5;
+ if (ABS(j) & 1) {
+ ofs = cell_xf[0] * 0.5;
}
- Vector2 from = xform.xform(node->map_to_world(Vector2(i,j),true)+ofs);
- Vector2 to = xform.xform(node->map_to_world(Vector2(i,j+1),true)+ofs);
- Color col=i==0?Color(1,0.8,0.2,0.5):Color(1,0.3,0.1,0.2);
- canvas_item_editor->draw_line(from,to,col,1);
+ Vector2 from = xform.xform(node->map_to_world(Vector2(i, j), true) + ofs);
+ Vector2 to = xform.xform(node->map_to_world(Vector2(i, j + 1), true) + ofs);
+ Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
+ canvas_item_editor->draw_line(from, to, col, 1);
- if (max_lines--==0)
+ if (max_lines-- == 0)
break;
-
}
-
}
}
- int max_lines=10000; //avoid crash if size too smal
+ int max_lines = 10000; //avoid crash if size too smal
- if (node->get_half_offset()!=TileMap::HALF_OFFSET_Y) {
+ if (node->get_half_offset() != TileMap::HALF_OFFSET_Y) {
- for (int i=(si.pos.y)-1;i<=(si.pos.y+si.size.y);i++) {
+ for (int i = (si.pos.y) - 1; i <= (si.pos.y + si.size.y); i++) {
- Vector2 from = xform.xform(node->map_to_world(Vector2(si.pos.x,i)));
- Vector2 to = xform.xform(node->map_to_world(Vector2(si.pos.x+si.size.x+1,i)));
+ Vector2 from = xform.xform(node->map_to_world(Vector2(si.pos.x, i)));
+ Vector2 to = xform.xform(node->map_to_world(Vector2(si.pos.x + si.size.x + 1, i)));
- Color col=i==0?Color(1,0.8,0.2,0.5):Color(1,0.3,0.1,0.2);
- canvas_item_editor->draw_line(from,to,col,1);
+ Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
+ canvas_item_editor->draw_line(from, to, col, 1);
- if (max_lines--==0)
+ if (max_lines-- == 0)
break;
-
}
} else {
+ for (int i = (si.pos.y) - 1; i <= (si.pos.y + si.size.y); i++) {
- for (int i=(si.pos.y)-1;i<=(si.pos.y+si.size.y);i++) {
-
- for (int j=(si.pos.x)-1;j<=(si.pos.x+si.size.x);j++) {
+ for (int j = (si.pos.x) - 1; j <= (si.pos.x + si.size.x); j++) {
Vector2 ofs;
- if (ABS(j)&1) {
- ofs=cell_xf[1]*0.5;
+ if (ABS(j) & 1) {
+ ofs = cell_xf[1] * 0.5;
}
- Vector2 from = xform.xform(node->map_to_world(Vector2(j,i),true)+ofs);
- Vector2 to = xform.xform(node->map_to_world(Vector2(j+1,i),true)+ofs);
- Color col=i==0?Color(1,0.8,0.2,0.5):Color(1,0.3,0.1,0.2);
- canvas_item_editor->draw_line(from,to,col,1);
+ Vector2 from = xform.xform(node->map_to_world(Vector2(j, i), true) + ofs);
+ Vector2 to = xform.xform(node->map_to_world(Vector2(j + 1, i), true) + ofs);
+ Color col = i == 0 ? Color(1, 0.8, 0.2, 0.5) : Color(1, 0.3, 0.1, 0.2);
+ canvas_item_editor->draw_line(from, to, col, 1);
- if (max_lines--==0)
+ if (max_lines-- == 0)
break;
-
}
}
}
@@ -1168,74 +1157,73 @@ void TileMapEditor::_canvas_draw() {
if (selection_active) {
Vector<Vector2> points;
- points.push_back( xform.xform( node->map_to_world(( rectangle.pos ) )));
- points.push_back( xform.xform( node->map_to_world((rectangle.pos+Point2(rectangle.size.x+1,0)) ) ));
- points.push_back( xform.xform( node->map_to_world((rectangle.pos+Point2(rectangle.size.x+1,rectangle.size.y+1)) ) ));
- points.push_back( xform.xform( node->map_to_world((rectangle.pos+Point2(0,rectangle.size.y+1)) ) ));
+ points.push_back(xform.xform(node->map_to_world((rectangle.pos))));
+ points.push_back(xform.xform(node->map_to_world((rectangle.pos + Point2(rectangle.size.x + 1, 0)))));
+ points.push_back(xform.xform(node->map_to_world((rectangle.pos + Point2(rectangle.size.x + 1, rectangle.size.y + 1)))));
+ points.push_back(xform.xform(node->map_to_world((rectangle.pos + Point2(0, rectangle.size.y + 1)))));
- canvas_item_editor->draw_colored_polygon(points, Color(0.2,0.8,1,0.4));
+ canvas_item_editor->draw_colored_polygon(points, Color(0.2, 0.8, 1, 0.4));
}
- if (mouse_over){
+ if (mouse_over) {
- Vector2 endpoints[4]={
+ Vector2 endpoints[4] = {
node->map_to_world(over_tile, true),
- node->map_to_world((over_tile+Point2(1,0)), true),
- node->map_to_world((over_tile+Point2(1,1)), true),
- node->map_to_world((over_tile+Point2(0,1)), true)
+ node->map_to_world((over_tile + Point2(1, 0)), true),
+ node->map_to_world((over_tile + Point2(1, 1)), true),
+ node->map_to_world((over_tile + Point2(0, 1)), true)
};
- for (int i=0;i<4;i++) {
- if (node->get_half_offset()==TileMap::HALF_OFFSET_X && ABS(over_tile.y)&1)
- endpoints[i]+=cell_xf[0]*0.5;
- if (node->get_half_offset()==TileMap::HALF_OFFSET_Y && ABS(over_tile.x)&1)
- endpoints[i]+=cell_xf[1]*0.5;
- endpoints[i]=xform.xform(endpoints[i]);
+ for (int i = 0; i < 4; i++) {
+ if (node->get_half_offset() == TileMap::HALF_OFFSET_X && ABS(over_tile.y) & 1)
+ endpoints[i] += cell_xf[0] * 0.5;
+ if (node->get_half_offset() == TileMap::HALF_OFFSET_Y && ABS(over_tile.x) & 1)
+ endpoints[i] += cell_xf[1] * 0.5;
+ endpoints[i] = xform.xform(endpoints[i]);
}
Color col;
- if (node->get_cell(over_tile.x,over_tile.y)!=TileMap::INVALID_CELL)
- col=Color(0.2,0.8,1.0,0.8);
+ if (node->get_cell(over_tile.x, over_tile.y) != TileMap::INVALID_CELL)
+ col = Color(0.2, 0.8, 1.0, 0.8);
else
- col=Color(1.0,0.4,0.2,0.8);
-
- for (int i=0;i<4;i++)
- canvas_item_editor->draw_line(endpoints[i],endpoints[(i+1)%4],col,2);
+ col = Color(1.0, 0.4, 0.2, 0.8);
+ for (int i = 0; i < 4; i++)
+ canvas_item_editor->draw_line(endpoints[i], endpoints[(i + 1) % 4], col, 2);
bool bucket_preview = EditorSettings::get_singleton()->get("editors/tile_map/bucket_fill_preview");
- if (tool==TOOL_SELECTING || tool==TOOL_PICKING || !bucket_preview) {
+ if (tool == TOOL_SELECTING || tool == TOOL_PICKING || !bucket_preview) {
return;
}
- if (tool==TOOL_LINE_PAINT) {
+ if (tool == TOOL_LINE_PAINT) {
if (paint_undo.empty())
return;
int id = get_selected_tile();
- if (id==TileMap::INVALID_CELL)
+ if (id == TileMap::INVALID_CELL)
return;
- for (Map<Point2i, CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+ for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) {
_draw_cell(id, E->key(), flip_h, flip_v, transpose, xform);
}
- } else if (tool==TOOL_RECTANGLE_PAINT) {
+ } else if (tool == TOOL_RECTANGLE_PAINT) {
int id = get_selected_tile();
- if (id==TileMap::INVALID_CELL)
+ if (id == TileMap::INVALID_CELL)
return;
- for (int i=rectangle.pos.y;i<=rectangle.pos.y+rectangle.size.y;i++) {
- for (int j=rectangle.pos.x;j<=rectangle.pos.x+rectangle.size.x;j++) {
+ for (int i = rectangle.pos.y; i <= rectangle.pos.y + rectangle.size.y; i++) {
+ for (int j = rectangle.pos.x; j <= rectangle.pos.x + rectangle.size.x; j++) {
_draw_cell(id, Point2i(j, i), flip_h, flip_v, transpose, xform);
}
}
- } else if (tool==TOOL_DUPLICATING) {
+ } else if (tool == TOOL_DUPLICATING) {
if (copydata.empty())
return;
@@ -1245,30 +1233,30 @@ void TileMapEditor::_canvas_draw() {
if (ts.is_null())
return;
- Point2 ofs = over_tile-rectangle.pos;
+ Point2 ofs = over_tile - rectangle.pos;
- for (List<TileData>::Element *E=copydata.front();E;E=E->next()) {
+ for (List<TileData>::Element *E = copydata.front(); E; E = E->next()) {
if (!ts->has_tile(E->get().cell))
continue;
TileData tcd = E->get();
- _draw_cell(tcd.cell, tcd.pos+ofs, tcd.flip_h, tcd.flip_v, tcd.transpose, xform);
+ _draw_cell(tcd.cell, tcd.pos + ofs, tcd.flip_h, tcd.flip_v, tcd.transpose, xform);
}
- Rect2i duplicate=rectangle;
- duplicate.pos=over_tile;
+ Rect2i duplicate = rectangle;
+ duplicate.pos = over_tile;
Vector<Vector2> points;
- points.push_back( xform.xform( node->map_to_world(duplicate.pos ) ));
- points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(duplicate.size.x+1,0)) ) ));
- points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(duplicate.size.x+1,duplicate.size.y+1))) ));
- points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(0,duplicate.size.y+1))) ));
+ points.push_back(xform.xform(node->map_to_world(duplicate.pos)));
+ points.push_back(xform.xform(node->map_to_world((duplicate.pos + Point2(duplicate.size.x + 1, 0)))));
+ points.push_back(xform.xform(node->map_to_world((duplicate.pos + Point2(duplicate.size.x + 1, duplicate.size.y + 1)))));
+ points.push_back(xform.xform(node->map_to_world((duplicate.pos + Point2(0, duplicate.size.y + 1)))));
- canvas_item_editor->draw_colored_polygon(points, Color(0.2,1.0,0.8,0.2));
+ canvas_item_editor->draw_colored_polygon(points, Color(0.2, 1.0, 0.8, 0.2));
- } else if(tool == TOOL_BUCKET) {
+ } else if (tool == TOOL_BUCKET) {
int tile = get_selected_tile();
_draw_fill_preview(tile, over_tile, flip_h, flip_v, transpose, xform);
@@ -1277,7 +1265,7 @@ void TileMapEditor::_canvas_draw() {
int st = get_selected_tile();
- if (st==TileMap::INVALID_CELL)
+ if (st == TileMap::INVALID_CELL)
return;
_draw_cell(st, over_tile, flip_h, flip_v, transpose, xform);
@@ -1290,41 +1278,40 @@ void TileMapEditor::edit(Node *p_tile_map) {
search_box->set_text("");
if (!canvas_item_editor) {
- canvas_item_editor=CanvasItemEditor::get_singleton()->get_viewport_control();
+ canvas_item_editor = CanvasItemEditor::get_singleton()->get_viewport_control();
}
if (node)
- node->disconnect("settings_changed",this,"_tileset_settings_changed");
+ node->disconnect("settings_changed", this, "_tileset_settings_changed");
if (p_tile_map) {
- node=p_tile_map->cast_to<TileMap>();
- if (!canvas_item_editor->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->connect("draw",this,"_canvas_draw");
- if (!canvas_item_editor->is_connected("mouse_entered",this,"_canvas_mouse_enter"))
- canvas_item_editor->connect("mouse_entered",this,"_canvas_mouse_enter");
- if (!canvas_item_editor->is_connected("mouse_exited",this,"_canvas_mouse_exit"))
- canvas_item_editor->connect("mouse_exited",this,"_canvas_mouse_exit");
+ node = p_tile_map->cast_to<TileMap>();
+ if (!canvas_item_editor->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->connect("draw", this, "_canvas_draw");
+ if (!canvas_item_editor->is_connected("mouse_entered", this, "_canvas_mouse_enter"))
+ canvas_item_editor->connect("mouse_entered", this, "_canvas_mouse_enter");
+ if (!canvas_item_editor->is_connected("mouse_exited", this, "_canvas_mouse_exit"))
+ canvas_item_editor->connect("mouse_exited", this, "_canvas_mouse_exit");
_update_palette();
} else {
- node=NULL;
+ node = NULL;
- if (canvas_item_editor->is_connected("draw",this,"_canvas_draw"))
- canvas_item_editor->disconnect("draw",this,"_canvas_draw");
- if (canvas_item_editor->is_connected("mouse_entered",this,"_canvas_mouse_enter"))
- canvas_item_editor->disconnect("mouse_entered",this,"_canvas_mouse_enter");
- if (canvas_item_editor->is_connected("mouse_exited",this,"_canvas_mouse_exit"))
- canvas_item_editor->disconnect("mouse_exited",this,"_canvas_mouse_exit");
+ if (canvas_item_editor->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->disconnect("draw", this, "_canvas_draw");
+ if (canvas_item_editor->is_connected("mouse_entered", this, "_canvas_mouse_enter"))
+ canvas_item_editor->disconnect("mouse_entered", this, "_canvas_mouse_enter");
+ if (canvas_item_editor->is_connected("mouse_exited", this, "_canvas_mouse_exit"))
+ canvas_item_editor->disconnect("mouse_exited", this, "_canvas_mouse_exit");
_update_palette();
}
if (node)
- node->connect("settings_changed",this,"_tileset_settings_changed");
+ node->connect("settings_changed", this, "_tileset_settings_changed");
_clear_bucket_cache();
-
}
void TileMapEditor::_tileset_settings_changed() {
@@ -1344,66 +1331,62 @@ void TileMapEditor::_icon_size_changed(float p_value) {
void TileMapEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_text_entered"),&TileMapEditor::_text_entered);
- ClassDB::bind_method(D_METHOD("_text_changed"),&TileMapEditor::_text_changed);
- ClassDB::bind_method(D_METHOD("_sbox_input"),&TileMapEditor::_sbox_input);
- ClassDB::bind_method(D_METHOD("_menu_option"),&TileMapEditor::_menu_option);
- ClassDB::bind_method(D_METHOD("_canvas_draw"),&TileMapEditor::_canvas_draw);
- ClassDB::bind_method(D_METHOD("_canvas_mouse_enter"),&TileMapEditor::_canvas_mouse_enter);
- ClassDB::bind_method(D_METHOD("_canvas_mouse_exit"),&TileMapEditor::_canvas_mouse_exit);
- ClassDB::bind_method(D_METHOD("_tileset_settings_changed"),&TileMapEditor::_tileset_settings_changed);
- ClassDB::bind_method(D_METHOD("_update_transform_buttons"),&TileMapEditor::_update_transform_buttons);
+ ClassDB::bind_method(D_METHOD("_text_entered"), &TileMapEditor::_text_entered);
+ ClassDB::bind_method(D_METHOD("_text_changed"), &TileMapEditor::_text_changed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"), &TileMapEditor::_sbox_input);
+ ClassDB::bind_method(D_METHOD("_menu_option"), &TileMapEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"), &TileMapEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_canvas_mouse_enter"), &TileMapEditor::_canvas_mouse_enter);
+ ClassDB::bind_method(D_METHOD("_canvas_mouse_exit"), &TileMapEditor::_canvas_mouse_exit);
+ ClassDB::bind_method(D_METHOD("_tileset_settings_changed"), &TileMapEditor::_tileset_settings_changed);
+ ClassDB::bind_method(D_METHOD("_update_transform_buttons"), &TileMapEditor::_update_transform_buttons);
- ClassDB::bind_method(D_METHOD("_fill_points"),&TileMapEditor::_fill_points);
- ClassDB::bind_method(D_METHOD("_erase_points"),&TileMapEditor::_erase_points);
+ ClassDB::bind_method(D_METHOD("_fill_points"), &TileMapEditor::_fill_points);
+ ClassDB::bind_method(D_METHOD("_erase_points"), &TileMapEditor::_erase_points);
ClassDB::bind_method(D_METHOD("_icon_size_changed"), &TileMapEditor::_icon_size_changed);
}
-TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i& p_pos)
-{
+TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i &p_pos) {
CellOp op;
- op.idx = node->get_cell(p_pos.x,p_pos.y);
- if (op.idx!=TileMap::INVALID_CELL) {
- if (node->is_cell_x_flipped(p_pos.x,p_pos.y))
- op.xf=true;
- if (node->is_cell_y_flipped(p_pos.x,p_pos.y))
- op.yf=true;
- if (node->is_cell_transposed(p_pos.x,p_pos.y))
- op.tr=true;
+ op.idx = node->get_cell(p_pos.x, p_pos.y);
+ if (op.idx != TileMap::INVALID_CELL) {
+ if (node->is_cell_x_flipped(p_pos.x, p_pos.y))
+ op.xf = true;
+ if (node->is_cell_y_flipped(p_pos.x, p_pos.y))
+ op.yf = true;
+ if (node->is_cell_transposed(p_pos.x, p_pos.y))
+ op.tr = true;
}
return op;
}
void TileMapEditor::_update_transform_buttons(Object *p_button) {
//ERR_FAIL_NULL(p_button);
- ToolButton *b=p_button->cast_to<ToolButton>();
+ ToolButton *b = p_button->cast_to<ToolButton>();
//ERR_FAIL_COND(!b);
if (b == rotate_0) {
mirror_x->set_pressed(false);
mirror_y->set_pressed(false);
transp->set_pressed(false);
- }
- else if (b == rotate_90) {
+ } else if (b == rotate_90) {
mirror_x->set_pressed(true);
mirror_y->set_pressed(false);
transp->set_pressed(true);
- }
- else if (b == rotate_180) {
+ } else if (b == rotate_180) {
mirror_x->set_pressed(true);
mirror_y->set_pressed(true);
transp->set_pressed(false);
- }
- else if (b == rotate_270) {
+ } else if (b == rotate_270) {
mirror_x->set_pressed(false);
mirror_y->set_pressed(true);
transp->set_pressed(true);
}
- flip_h=mirror_x->is_pressed();
- flip_v=mirror_y->is_pressed();
- transpose=transp->is_pressed();
+ flip_h = mirror_x->is_pressed();
+ flip_v = mirror_y->is_pressed();
+ transpose = transp->is_pressed();
rotate_0->set_pressed(!flip_h && !flip_v && !transpose);
rotate_90->set_pressed(flip_h && !flip_v && transpose);
@@ -1413,36 +1396,36 @@ void TileMapEditor::_update_transform_buttons(Object *p_button) {
TileMapEditor::TileMapEditor(EditorNode *p_editor) {
- node=NULL;
- canvas_item_editor=NULL;
- editor=p_editor;
- undo_redo=editor->get_undo_redo();
+ node = NULL;
+ canvas_item_editor = NULL;
+ editor = p_editor;
+ undo_redo = editor->get_undo_redo();
- tool=TOOL_NONE;
- selection_active=false;
- mouse_over=false;
+ tool = TOOL_NONE;
+ selection_active = false;
+ mouse_over = false;
- flip_h=false;
- flip_v=false;
- transpose=false;
+ flip_h = false;
+ flip_v = false;
+ transpose = false;
bucket_cache_tile = -1;
bucket_cache_visited = 0;
ED_SHORTCUT("tile_map_editor/erase_selection", TTR("Erase selection"), KEY_DELETE);
- ED_SHORTCUT("tile_map_editor/find_tile", TTR("Find tile"), KEY_MASK_CMD+KEY_F);
+ ED_SHORTCUT("tile_map_editor/find_tile", TTR("Find tile"), KEY_MASK_CMD + KEY_F);
ED_SHORTCUT("tile_map_editor/transpose", TTR("Transpose"));
ED_SHORTCUT("tile_map_editor/mirror_x", TTR("Mirror X"), KEY_A);
ED_SHORTCUT("tile_map_editor/mirror_y", TTR("Mirror Y"), KEY_S);
- search_box = memnew( LineEdit );
+ search_box = memnew(LineEdit);
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
search_box->connect("text_entered", this, "_text_entered");
search_box->connect("text_changed", this, "_text_changed");
search_box->connect("gui_input", this, "_sbox_input");
add_child(search_box);
- size_slider = memnew( HSlider );
+ size_slider = memnew(HSlider);
size_slider->set_h_size_flags(SIZE_EXPAND_FILL);
size_slider->set_min(0.1f);
size_slider->set_max(4.0f);
@@ -1454,25 +1437,25 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
int mw = EDITOR_DEF("editors/tile_map/palette_min_width", 80);
// Add tile palette
- palette = memnew( ItemList );
+ palette = memnew(ItemList);
palette->set_v_size_flags(SIZE_EXPAND_FILL);
- palette->set_custom_minimum_size(Size2(mw,0));
+ palette->set_custom_minimum_size(Size2(mw, 0));
palette->set_max_columns(0);
palette->set_icon_mode(ItemList::ICON_MODE_TOP);
palette->set_max_text_lines(2);
add_child(palette);
// Add menu items
- toolbar = memnew( HBoxContainer );
+ toolbar = memnew(HBoxContainer);
toolbar->set_h_size_flags(SIZE_EXPAND_FILL);
toolbar->set_alignment(BoxContainer::ALIGN_END);
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(toolbar);
// Tile position
- tile_info = memnew( Label );
+ tile_info = memnew(Label);
toolbar->add_child(tile_info);
- options = memnew( MenuButton );
+ options = memnew(MenuButton);
options->set_text("Tile Map");
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("TileMap", "EditorIcons"));
options->set_process_unhandled_key_input(false);
@@ -1483,56 +1466,56 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
p->add_separator();
p->add_item(TTR("Pick Tile"), OPTION_PICK_TILE, KEY_CONTROL);
p->add_separator();
- p->add_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_MASK_CMD+KEY_B), OPTION_SELECT);
- p->add_shortcut(ED_SHORTCUT("tile_map_editor/duplicate_selection", TTR("Duplicate Selection"), KEY_MASK_CMD+KEY_D), OPTION_DUPLICATE);
+ p->add_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_MASK_CMD + KEY_B), OPTION_SELECT);
+ p->add_shortcut(ED_SHORTCUT("tile_map_editor/duplicate_selection", TTR("Duplicate Selection"), KEY_MASK_CMD + KEY_D), OPTION_DUPLICATE);
p->add_shortcut(ED_GET_SHORTCUT("tile_map_editor/erase_selection"), OPTION_ERASE_SELECTION);
p->connect("id_pressed", this, "_menu_option");
toolbar->add_child(options);
- toolbar->add_child( memnew( VSeparator ) );
+ toolbar->add_child(memnew(VSeparator));
- transp = memnew( ToolButton );
+ transp = memnew(ToolButton);
transp->set_toggle_mode(true);
- transp->set_tooltip(TTR("Transpose") + " ("+ED_GET_SHORTCUT("tile_map_editor/transpose")->get_as_text()+")");
+ transp->set_tooltip(TTR("Transpose") + " (" + ED_GET_SHORTCUT("tile_map_editor/transpose")->get_as_text() + ")");
transp->set_focus_mode(FOCUS_NONE);
transp->connect("pressed", this, "_update_transform_buttons", make_binds(transp));
toolbar->add_child(transp);
- mirror_x = memnew( ToolButton );
+ mirror_x = memnew(ToolButton);
mirror_x->set_toggle_mode(true);
- mirror_x->set_tooltip(TTR("Mirror X") + " ("+ED_GET_SHORTCUT("tile_map_editor/mirror_x")->get_as_text()+")");
+ mirror_x->set_tooltip(TTR("Mirror X") + " (" + ED_GET_SHORTCUT("tile_map_editor/mirror_x")->get_as_text() + ")");
mirror_x->set_focus_mode(FOCUS_NONE);
mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x));
toolbar->add_child(mirror_x);
- mirror_y = memnew( ToolButton );
+ mirror_y = memnew(ToolButton);
mirror_y->set_toggle_mode(true);
- mirror_y->set_tooltip(TTR("Mirror Y") + " ("+ED_GET_SHORTCUT("tile_map_editor/mirror_y")->get_as_text()+")");
+ mirror_y->set_tooltip(TTR("Mirror Y") + " (" + ED_GET_SHORTCUT("tile_map_editor/mirror_y")->get_as_text() + ")");
mirror_y->set_focus_mode(FOCUS_NONE);
mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y));
toolbar->add_child(mirror_y);
- toolbar->add_child( memnew( VSeparator ) );
+ toolbar->add_child(memnew(VSeparator));
- rotate_0 = memnew( ToolButton );
+ rotate_0 = memnew(ToolButton);
rotate_0->set_toggle_mode(true);
rotate_0->set_tooltip(TTR("Rotate 0 degrees"));
rotate_0->set_focus_mode(FOCUS_NONE);
rotate_0->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_0));
toolbar->add_child(rotate_0);
- rotate_90 = memnew( ToolButton );
+ rotate_90 = memnew(ToolButton);
rotate_90->set_toggle_mode(true);
rotate_90->set_tooltip(TTR("Rotate 90 degrees"));
rotate_90->set_focus_mode(FOCUS_NONE);
rotate_90->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_90));
toolbar->add_child(rotate_90);
- rotate_180 = memnew( ToolButton );
+ rotate_180 = memnew(ToolButton);
rotate_180->set_toggle_mode(true);
rotate_180->set_tooltip(TTR("Rotate 180 degrees"));
rotate_180->set_focus_mode(FOCUS_NONE);
rotate_180->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_180));
toolbar->add_child(rotate_180);
- rotate_270 = memnew( ToolButton );
+ rotate_270 = memnew(ToolButton);
rotate_270->set_toggle_mode(true);
rotate_270->set_tooltip(TTR("Rotate 270 degrees"));
rotate_270->set_focus_mode(FOCUS_NONE);
@@ -1577,17 +1560,15 @@ void TileMapEditorPlugin::make_visible(bool p_visible) {
TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) {
- EDITOR_DEF("editors/tile_map/preview_size",64);
- EDITOR_DEF("editors/tile_map/palette_item_hseparation",8);
+ EDITOR_DEF("editors/tile_map/preview_size", 64);
+ EDITOR_DEF("editors/tile_map/palette_item_hseparation", 8);
EDITOR_DEF("editors/tile_map/show_tile_names", true);
EDITOR_DEF("editors/tile_map/bucket_fill_preview", true);
- tile_map_editor = memnew( TileMapEditor(p_node) );
+ tile_map_editor = memnew(TileMapEditor(p_node));
add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE, tile_map_editor);
tile_map_editor->hide();
}
-TileMapEditorPlugin::~TileMapEditorPlugin()
-{
+TileMapEditorPlugin::~TileMapEditorPlugin() {
}
-
diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h
index 82e2a396d1..a4774a23b9 100644
--- a/editor/plugins/tile_map_editor_plugin.h
+++ b/editor/plugins/tile_map_editor_plugin.h
@@ -29,14 +29,14 @@
#ifndef TILE_MAP_EDITOR_PLUGIN_H
#define TILE_MAP_EDITOR_PLUGIN_H
-#include "editor/editor_plugin.h"
#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
#include "scene/2d/tile_map.h"
+#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
-#include "scene/gui/tool_button.h"
#include "scene/gui/menu_button.h"
-#include "scene/gui/label.h"
+#include "scene/gui/tool_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -44,7 +44,7 @@
class TileMapEditor : public VBoxContainer {
- GDCLASS(TileMapEditor, VBoxContainer );
+ GDCLASS(TileMapEditor, VBoxContainer);
enum Tool {
@@ -77,7 +77,7 @@ class TileMapEditor : public VBoxContainer {
Control *canvas_item_editor;
LineEdit *search_box;
- HSlider *size_slider;
+ HSlider *size_slider;
ItemList *palette;
HBoxContainer *toolbar;
@@ -106,7 +106,7 @@ class TileMapEditor : public VBoxContainer {
Point2i over_tile;
- bool * bucket_cache_visited;
+ bool *bucket_cache_visited;
Rect2i bucket_cache_rect;
int bucket_cache_tile;
PoolVector<Vector2> bucket_cache;
@@ -117,7 +117,12 @@ class TileMapEditor : public VBoxContainer {
bool yf;
bool tr;
- CellOp() { idx=-1; xf=false; yf=false; tr=false; }
+ CellOp() {
+ idx = -1;
+ xf = false;
+ yf = false;
+ tr = false;
+ }
};
Map<Point2i, CellOp> paint_undo;
@@ -132,17 +137,17 @@ class TileMapEditor : public VBoxContainer {
List<TileData> copydata;
- void _pick_tile(const Point2& p_pos);
+ void _pick_tile(const Point2 &p_pos);
- PoolVector<Vector2> _bucket_fill(const Point2i& p_start, bool erase=false, bool preview=false);
+ PoolVector<Vector2> _bucket_fill(const Point2i &p_start, bool erase = false, bool preview = false);
- void _fill_points(const PoolVector<Vector2> p_points, const Dictionary& p_op);
+ void _fill_points(const PoolVector<Vector2> p_points, const Dictionary &p_op);
void _erase_points(const PoolVector<Vector2> p_points);
- void _select(const Point2i& p_from, const Point2i& p_to);
+ void _select(const Point2i &p_from, const Point2i &p_to);
- void _draw_cell(int p_cell, const Point2i& p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D& p_xform);
- void _draw_fill_preview(int p_cell, const Point2i& p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D& p_xform);
+ void _draw_cell(int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform);
+ void _draw_fill_preview(int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform);
void _clear_bucket_cache();
void _update_copydata();
@@ -150,14 +155,14 @@ class TileMapEditor : public VBoxContainer {
int get_selected_tile() const;
void set_selected_tile(int p_tile);
- void _text_entered(const String& p_text);
- void _text_changed(const String& p_text);
- void _sbox_input(const InputEvent& p_ie);
+ void _text_entered(const String &p_text);
+ void _text_changed(const String &p_text);
+ void _sbox_input(const InputEvent &p_ie);
void _update_palette();
void _canvas_draw();
void _menu_option(int p_option);
- void _set_cell(const Point2i& p_pos, int p_value, bool p_flip_h=false, bool p_flip_v=false, bool p_transpose=false, bool p_with_undo=false);
+ void _set_cell(const Point2i &p_pos, int p_value, bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false, bool p_with_undo = false);
void _canvas_mouse_enter();
void _canvas_mouse_exit();
@@ -165,17 +170,15 @@ class TileMapEditor : public VBoxContainer {
void _icon_size_changed(float p_value);
protected:
-
void _notification(int p_what);
static void _bind_methods();
- CellOp _get_op_from_cell(const Point2i& p_pos);
- void _update_transform_buttons(Object *p_button=NULL);
+ CellOp _get_op_from_cell(const Point2i &p_pos);
+ void _update_transform_buttons(Object *p_button = NULL);
public:
-
HBoxContainer *get_toolbar() const { return toolbar; }
- bool forward_gui_input(const InputEvent& p_event);
+ bool forward_gui_input(const InputEvent &p_event);
void edit(Node *p_tile_map);
TileMapEditor(EditorNode *p_editor);
@@ -184,13 +187,12 @@ public:
class TileMapEditorPlugin : public EditorPlugin {
- GDCLASS( TileMapEditorPlugin, EditorPlugin );
+ GDCLASS(TileMapEditorPlugin, EditorPlugin);
TileMapEditor *tile_map_editor;
public:
-
- virtual bool forward_canvas_gui_input(const Transform2D& p_canvas_xform,const InputEvent& p_event) { return tile_map_editor->forward_gui_input(p_event); }
+ virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const InputEvent &p_event) { return tile_map_editor->forward_gui_input(p_event); }
virtual String get_name() const { return "TileMap"; }
bool has_main_screen() const { return false; }
@@ -200,8 +202,6 @@ public:
TileMapEditorPlugin(EditorNode *p_node);
~TileMapEditorPlugin();
-
};
-
#endif // TILE_MAP_EDITOR_PLUGIN_H
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 3db6c94917..6dee151d99 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -28,12 +28,12 @@
/*************************************************************************/
#include "tile_set_editor_plugin.h"
-#include "scene/2d/sprite.h"
#include "scene/2d/physics_body_2d.h"
+#include "scene/2d/sprite.h"
-void TileSetEditor::edit(const Ref<TileSet>& p_tileset) {
+void TileSetEditor::edit(const Ref<TileSet> &p_tileset) {
- tileset=p_tileset;
+ tileset = p_tileset;
}
void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_merge) {
@@ -41,85 +41,80 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me
if (!p_merge)
p_library->clear();
- for(int i=0;i<scene->get_child_count();i++) {
-
+ for (int i = 0; i < scene->get_child_count(); i++) {
Node *child = scene->get_child(i);
-
if (!child->cast_to<Sprite>()) {
- if (child->get_child_count()>0) {
- child=child->get_child(0);
+ if (child->get_child_count() > 0) {
+ child = child->get_child(0);
if (!child->cast_to<Sprite>()) {
continue;
}
} else
continue;
-
-
}
Sprite *mi = child->cast_to<Sprite>();
- Ref<Texture> texture=mi->get_texture();
- Ref<CanvasItemMaterial> material=mi->get_material();
+ Ref<Texture> texture = mi->get_texture();
+ Ref<CanvasItemMaterial> material = mi->get_material();
if (texture.is_null())
continue;
int id = p_library->find_tile_by_name(mi->get_name());
- if (id<0) {
+ if (id < 0) {
- id=p_library->get_last_unused_tile_id();
+ id = p_library->get_last_unused_tile_id();
p_library->create_tile(id);
- p_library->tile_set_name(id,mi->get_name());
+ p_library->tile_set_name(id, mi->get_name());
}
- p_library->tile_set_texture(id,texture);
- p_library->tile_set_material(id,material);
+ p_library->tile_set_texture(id, texture);
+ p_library->tile_set_material(id, material);
- p_library->tile_set_modulate(id,mi->get_modulate());
+ p_library->tile_set_modulate(id, mi->get_modulate());
Vector2 phys_offset;
Size2 s;
if (mi->is_region()) {
- s=mi->get_region_rect().size;
- p_library->tile_set_region(id,mi->get_region_rect());
+ s = mi->get_region_rect().size;
+ p_library->tile_set_region(id, mi->get_region_rect());
} else {
const int frame = mi->get_frame();
const int hframes = mi->get_hframes();
- s=texture->get_size()/Size2(hframes,mi->get_vframes());
- p_library->tile_set_region(id,Rect2(Vector2(frame%hframes,frame/hframes)*s,s));
+ s = texture->get_size() / Size2(hframes, mi->get_vframes());
+ p_library->tile_set_region(id, Rect2(Vector2(frame % hframes, frame / hframes) * s, s));
}
-
+
if (mi->is_centered()) {
- phys_offset+=-s/2;
+ phys_offset += -s / 2;
}
- Vector<Ref<Shape2D> >collisions;
+ Vector<Ref<Shape2D> > collisions;
Ref<NavigationPolygon> nav_poly;
Ref<OccluderPolygon2D> occluder;
- for(int j=0;j<mi->get_child_count();j++) {
+ for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j);
if (child2->cast_to<NavigationPolygonInstance>())
- nav_poly=child2->cast_to<NavigationPolygonInstance>()->get_navigation_polygon();
+ nav_poly = child2->cast_to<NavigationPolygonInstance>()->get_navigation_polygon();
if (child2->cast_to<LightOccluder2D>())
- occluder=child2->cast_to<LightOccluder2D>()->get_occluder_polygon();
+ occluder = child2->cast_to<LightOccluder2D>()->get_occluder_polygon();
if (!child2->cast_to<StaticBody2D>())
continue;
StaticBody2D *sb = child2->cast_to<StaticBody2D>();
int shape_count = sb->get_shape_count();
- if (shape_count==0)
+ if (shape_count == 0)
continue;
- for (int shape_index=0; shape_index<shape_count; ++shape_index)
- {
- Ref<Shape2D> collision=sb->get_shape(shape_index);
+ for (int shape_index = 0; shape_index < shape_count; ++shape_index) {
+ Ref<Shape2D> collision = sb->get_shape(shape_index);
if (collision.is_valid()) {
collisions.push_back(collision);
}
@@ -128,58 +123,53 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me
if (collisions.size()) {
- p_library->tile_set_shapes(id,collisions);
- p_library->tile_set_shape_offset(id,-phys_offset);
+ p_library->tile_set_shapes(id, collisions);
+ p_library->tile_set_shape_offset(id, -phys_offset);
} else {
- p_library->tile_set_shape_offset(id,Vector2());
-
+ p_library->tile_set_shape_offset(id, Vector2());
}
- p_library->tile_set_texture_offset(id,mi->get_offset());
- p_library->tile_set_navigation_polygon(id,nav_poly);
- p_library->tile_set_light_occluder(id,occluder);
- p_library->tile_set_occluder_offset(id,-phys_offset);
- p_library->tile_set_navigation_polygon_offset(id,-phys_offset);
-
-
+ p_library->tile_set_texture_offset(id, mi->get_offset());
+ p_library->tile_set_navigation_polygon(id, nav_poly);
+ p_library->tile_set_light_occluder(id, occluder);
+ p_library->tile_set_occluder_offset(id, -phys_offset);
+ p_library->tile_set_navigation_polygon_offset(id, -phys_offset);
}
}
void TileSetEditor::_menu_confirm() {
- switch(option) {
+ switch (option) {
case MENU_OPTION_MERGE_FROM_SCENE:
case MENU_OPTION_CREATE_FROM_SCENE: {
-
EditorNode *en = editor;
- Node * scene = en->get_edited_scene();
+ Node *scene = en->get_edited_scene();
if (!scene)
break;
- _import_scene(scene,tileset,option==MENU_OPTION_MERGE_FROM_SCENE);
-
+ _import_scene(scene, tileset, option == MENU_OPTION_MERGE_FROM_SCENE);
} break;
}
}
-void TileSetEditor::_name_dialog_confirm(const String& name) {
+void TileSetEditor::_name_dialog_confirm(const String &name) {
switch (option) {
case MENU_OPTION_REMOVE_ITEM: {
- int id=tileset->find_tile_by_name(name);
+ int id = tileset->find_tile_by_name(name);
- if (id<0 && name.is_valid_integer())
- id=name.to_int();
+ if (id < 0 && name.is_valid_integer())
+ id = name.to_int();
if (tileset->has_tile(id)) {
tileset->remove_tile(id);
} else {
- err_dialog->set_text(TTR("Could not find tile:")+" " + name);
+ err_dialog->set_text(TTR("Could not find tile:") + " " + name);
err_dialog->popup_centered(Size2(300, 60));
}
} break;
@@ -188,8 +178,8 @@ void TileSetEditor::_name_dialog_confirm(const String& name) {
void TileSetEditor::_menu_cbk(int p_option) {
- option=p_option;
- switch(p_option) {
+ option = p_option;
+ switch (p_option) {
case MENU_OPTION_ADD_ITEM: {
@@ -204,57 +194,54 @@ void TileSetEditor::_menu_cbk(int p_option) {
case MENU_OPTION_CREATE_FROM_SCENE: {
cd->set_text(TTR("Create from scene?"));
- cd->popup_centered(Size2(300,60));
+ cd->popup_centered(Size2(300, 60));
} break;
case MENU_OPTION_MERGE_FROM_SCENE: {
cd->set_text(TTR("Merge from scene?"));
- cd->popup_centered(Size2(300,60));
+ cd->popup_centered(Size2(300, 60));
} break;
}
}
+Error TileSetEditor::update_library_file(Node *p_base_scene, Ref<TileSet> ml, bool p_merge) {
-
-Error TileSetEditor::update_library_file(Node *p_base_scene, Ref<TileSet> ml,bool p_merge) {
-
- _import_scene(p_base_scene,ml,p_merge);
+ _import_scene(p_base_scene, ml, p_merge);
return OK;
-
}
void TileSetEditor::_bind_methods() {
- ClassDB::bind_method("_menu_cbk",&TileSetEditor::_menu_cbk);
- ClassDB::bind_method("_menu_confirm",&TileSetEditor::_menu_confirm);
- ClassDB::bind_method("_name_dialog_confirm",&TileSetEditor::_name_dialog_confirm);
+ ClassDB::bind_method("_menu_cbk", &TileSetEditor::_menu_cbk);
+ ClassDB::bind_method("_menu_confirm", &TileSetEditor::_menu_confirm);
+ ClassDB::bind_method("_name_dialog_confirm", &TileSetEditor::_name_dialog_confirm);
}
TileSetEditor::TileSetEditor(EditorNode *p_editor) {
- Panel *panel = memnew( Panel );
+ Panel *panel = memnew(Panel);
panel->set_area_as_parent_rect();
add_child(panel);
- MenuButton * options = memnew( MenuButton );
+ MenuButton *options = memnew(MenuButton);
panel->add_child(options);
- options->set_pos(Point2(1,1));
+ options->set_pos(Point2(1, 1));
options->set_text("Theme");
- options->get_popup()->add_item(TTR("Add Item"),MENU_OPTION_ADD_ITEM);
- options->get_popup()->add_item(TTR("Remove Item"),MENU_OPTION_REMOVE_ITEM);
+ options->get_popup()->add_item(TTR("Add Item"), MENU_OPTION_ADD_ITEM);
+ options->get_popup()->add_item(TTR("Remove Item"), MENU_OPTION_REMOVE_ITEM);
options->get_popup()->add_separator();
- options->get_popup()->add_item(TTR("Create from Scene"),MENU_OPTION_CREATE_FROM_SCENE);
- options->get_popup()->add_item(TTR("Merge from Scene"),MENU_OPTION_MERGE_FROM_SCENE);
- options->get_popup()->connect("id_pressed", this,"_menu_cbk");
- editor=p_editor;
+ options->get_popup()->add_item(TTR("Create from Scene"), MENU_OPTION_CREATE_FROM_SCENE);
+ options->get_popup()->add_item(TTR("Merge from Scene"), MENU_OPTION_MERGE_FROM_SCENE);
+ options->get_popup()->connect("id_pressed", this, "_menu_cbk");
+ editor = p_editor;
cd = memnew(ConfirmationDialog);
add_child(cd);
- cd->get_ok()->connect("pressed", this,"_menu_confirm");
+ cd->get_ok()->connect("pressed", this, "_menu_confirm");
nd = memnew(EditorNameDialog);
add_child(nd);
nd->set_hide_on_ok(true);
- nd->get_line_edit()->set_margin(MARGIN_TOP,28);
- nd->connect("name_confirmed", this,"_name_dialog_confirm");
+ nd->get_line_edit()->set_margin(MARGIN_TOP, 28);
+ nd->connect("name_confirmed", this, "_name_dialog_confirm");
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
@@ -264,18 +251,18 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
void TileSetEditorPlugin::edit(Object *p_node) {
if (p_node && p_node->cast_to<TileSet>()) {
- tileset_editor->edit( p_node->cast_to<TileSet>() );
+ tileset_editor->edit(p_node->cast_to<TileSet>());
tileset_editor->show();
} else
tileset_editor->hide();
}
-bool TileSetEditorPlugin::handles(Object *p_node) const{
+bool TileSetEditorPlugin::handles(Object *p_node) const {
return p_node->is_class("TileSet");
}
-void TileSetEditorPlugin::make_visible(bool p_visible){
+void TileSetEditorPlugin::make_visible(bool p_visible) {
if (p_visible)
tileset_editor->show();
@@ -285,13 +272,12 @@ void TileSetEditorPlugin::make_visible(bool p_visible){
TileSetEditorPlugin::TileSetEditorPlugin(EditorNode *p_node) {
- tileset_editor = memnew( TileSetEditor(p_node) );
+ tileset_editor = memnew(TileSetEditor(p_node));
p_node->get_viewport()->add_child(tileset_editor);
tileset_editor->set_area_as_parent_rect();
- tileset_editor->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
- tileset_editor->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_BEGIN );
- tileset_editor->set_end( Point2(0,22) );
+ tileset_editor->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END);
+ tileset_editor->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_BEGIN);
+ tileset_editor->set_end(Point2(0, 22));
tileset_editor->hide();
-
}
diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h
index 02a82ebd6b..0dabf58f7c 100644
--- a/editor/plugins/tile_set_editor_plugin.h
+++ b/editor/plugins/tile_set_editor_plugin.h
@@ -29,16 +29,13 @@
#ifndef TILE_SET_EDITOR_PLUGIN_H
#define TILE_SET_EDITOR_PLUGIN_H
-
-
-#include "scene/resources/tile_set.h"
-#include "editor/editor_node.h"
#include "editor/editor_name_dialog.h"
-
+#include "editor/editor_node.h"
+#include "scene/resources/tile_set.h"
class TileSetEditor : public Control {
- GDCLASS( TileSetEditor, Control );
+ GDCLASS(TileSetEditor, Control);
Ref<TileSet> tileset;
@@ -59,43 +56,35 @@ class TileSetEditor : public Control {
int option;
void _menu_cbk(int p_option);
void _menu_confirm();
- void _name_dialog_confirm(const String& name);
+ void _name_dialog_confirm(const String &name);
static void _import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge);
-
protected:
static void _bind_methods();
-public:
- void edit(const Ref<TileSet>& p_tileset);
- static Error update_library_file(Node *p_base_scene, Ref<TileSet> ml,bool p_merge=true);
+public:
+ void edit(const Ref<TileSet> &p_tileset);
+ static Error update_library_file(Node *p_base_scene, Ref<TileSet> ml, bool p_merge = true);
TileSetEditor(EditorNode *p_editor);
};
-
-
class TileSetEditorPlugin : public EditorPlugin {
- GDCLASS( TileSetEditorPlugin, EditorPlugin );
+ GDCLASS(TileSetEditorPlugin, EditorPlugin);
TileSetEditor *tileset_editor;
EditorNode *editor;
public:
-
virtual String get_name() const { return "TileSet"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_node);
virtual bool handles(Object *p_node) const;
virtual void make_visible(bool p_visible);
-
-
TileSetEditorPlugin(EditorNode *p_node);
-
};
-
#endif // TILE_SET_EDITOR_PLUGIN_H
diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp
index 76626c4556..55f220ba9a 100644
--- a/editor/progress_dialog.cpp
+++ b/editor/progress_dialog.cpp
@@ -28,201 +28,184 @@
/*************************************************************************/
#include "progress_dialog.h"
+#include "editor_scale.h"
#include "main/main.h"
#include "message_queue.h"
#include "os/os.h"
-#include "editor_scale.h"
-void BackgroundProgress::_add_task(const String& p_task,const String& p_label, int p_steps) {
+void BackgroundProgress::_add_task(const String &p_task, const String &p_label, int p_steps) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(tasks.has(p_task));
Task t;
- t.hb = memnew( HBoxContainer );
- Label *l=memnew( Label );
- l->set_text(p_label+" ");
+ t.hb = memnew(HBoxContainer);
+ Label *l = memnew(Label);
+ l->set_text(p_label + " ");
t.hb->add_child(l);
- t.progress = memnew( ProgressBar );
+ t.progress = memnew(ProgressBar);
t.progress->set_max(p_steps);
t.progress->set_value(p_steps);
- Control *ec = memnew( Control );
+ Control *ec = memnew(Control);
ec->set_h_size_flags(SIZE_EXPAND_FILL);
ec->set_v_size_flags(SIZE_EXPAND_FILL);
t.progress->set_area_as_parent_rect();
ec->add_child(t.progress);
- ec->set_custom_minimum_size(Size2(80,5)*EDSCALE);
+ ec->set_custom_minimum_size(Size2(80, 5) * EDSCALE);
t.hb->add_child(ec);
add_child(t.hb);
- tasks[p_task]=t;
-
+ tasks[p_task] = t;
}
void BackgroundProgress::_update() {
_THREAD_SAFE_METHOD_
- for (Map<String,int>::Element *E=updates.front();E;E=E->next()) {
+ for (Map<String, int>::Element *E = updates.front(); E; E = E->next()) {
if (tasks.has(E->key())) {
- _task_step(E->key(),E->get());
+ _task_step(E->key(), E->get());
}
}
updates.clear();
-
-
-
}
-
-void BackgroundProgress::_task_step(const String& p_task, int p_step){
+void BackgroundProgress::_task_step(const String &p_task, int p_step) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!tasks.has(p_task));
- Task &t=tasks[p_task];
- if (p_step<0)
- t.progress->set_value(t.progress->get_value()+1);
+ Task &t = tasks[p_task];
+ if (p_step < 0)
+ t.progress->set_value(t.progress->get_value() + 1);
else
t.progress->set_value(p_step);
-
}
-void BackgroundProgress::_end_task(const String& p_task){
+void BackgroundProgress::_end_task(const String &p_task) {
_THREAD_SAFE_METHOD_
ERR_FAIL_COND(!tasks.has(p_task));
- Task &t=tasks[p_task];
+ Task &t = tasks[p_task];
memdelete(t.hb);
tasks.erase(p_task);
}
-void BackgroundProgress::_bind_methods(){
-
- ClassDB::bind_method("_add_task",&BackgroundProgress::_add_task);
- ClassDB::bind_method("_task_step",&BackgroundProgress::_task_step);
- ClassDB::bind_method("_end_task",&BackgroundProgress::_end_task);
- ClassDB::bind_method("_update",&BackgroundProgress::_update);
+void BackgroundProgress::_bind_methods() {
+ ClassDB::bind_method("_add_task", &BackgroundProgress::_add_task);
+ ClassDB::bind_method("_task_step", &BackgroundProgress::_task_step);
+ ClassDB::bind_method("_end_task", &BackgroundProgress::_end_task);
+ ClassDB::bind_method("_update", &BackgroundProgress::_update);
}
-void BackgroundProgress::add_task(const String& p_task,const String& p_label, int p_steps){
+void BackgroundProgress::add_task(const String &p_task, const String &p_label, int p_steps) {
- MessageQueue::get_singleton()->push_call(this,"_add_task",p_task,p_label,p_steps);
+ MessageQueue::get_singleton()->push_call(this, "_add_task", p_task, p_label, p_steps);
}
-void BackgroundProgress::task_step(const String& p_task, int p_step){
+void BackgroundProgress::task_step(const String &p_task, int p_step) {
//this code is weird, but it prevents deadlock.
bool no_updates;
{
_THREAD_SAFE_METHOD_
- no_updates=updates.empty();
+ no_updates = updates.empty();
}
if (no_updates)
- MessageQueue::get_singleton()->push_call(this,"_update");
+ MessageQueue::get_singleton()->push_call(this, "_update");
{
_THREAD_SAFE_METHOD_
- updates[p_task]=p_step;
+ updates[p_task] = p_step;
}
-
}
-void BackgroundProgress::end_task(const String& p_task){
-
- MessageQueue::get_singleton()->push_call(this,"_end_task",p_task);
+void BackgroundProgress::end_task(const String &p_task) {
+ MessageQueue::get_singleton()->push_call(this, "_end_task", p_task);
}
-
////////////////////////////////////////////////
-
-ProgressDialog *ProgressDialog::singleton=NULL;
+ProgressDialog *ProgressDialog::singleton = NULL;
void ProgressDialog::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
- Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
- draw_style_box(style,Rect2(Point2(),get_size()));
+ Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
+ draw_style_box(style, Rect2(Point2(), get_size()));
} break;
}
}
-
void ProgressDialog::_popup() {
Size2 ms = main->get_combined_minimum_size();
- ms.width = MAX(500*EDSCALE,ms.width);
+ ms.width = MAX(500 * EDSCALE, ms.width);
-
- Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
- ms+=style->get_minimum_size();
- for(int i=0;i<4;i++) {
- main->set_margin(Margin(i),style->get_margin(Margin(i)));
+ Ref<StyleBox> style = get_stylebox("panel", "PopupMenu");
+ ms += style->get_minimum_size();
+ for (int i = 0; i < 4; i++) {
+ main->set_margin(Margin(i), style->get_margin(Margin(i)));
}
popup_centered(ms);
-
}
-void ProgressDialog::add_task(const String& p_task,const String& p_label,int p_steps) {
+void ProgressDialog::add_task(const String &p_task, const String &p_label, int p_steps) {
ERR_FAIL_COND(tasks.has(p_task));
Task t;
- t.vb = memnew( VBoxContainer );
- VBoxContainer *vb2 = memnew( VBoxContainer );
- t.vb->add_margin_child(p_label,vb2);
- t.progress = memnew( ProgressBar );
+ t.vb = memnew(VBoxContainer);
+ VBoxContainer *vb2 = memnew(VBoxContainer);
+ t.vb->add_margin_child(p_label, vb2);
+ t.progress = memnew(ProgressBar);
t.progress->set_max(p_steps);
t.progress->set_value(p_steps);
vb2->add_child(t.progress);
- t.state=memnew( Label );
+ t.state = memnew(Label);
t.state->set_clip_text(true);
vb2->add_child(t.state);
main->add_child(t.vb);
- tasks[p_task]=t;
+ tasks[p_task] = t;
_popup();
-
}
-void ProgressDialog::task_step(const String& p_task, const String& p_state, int p_step,bool p_force_redraw){
+void ProgressDialog::task_step(const String &p_task, const String &p_state, int p_step, bool p_force_redraw) {
ERR_FAIL_COND(!tasks.has(p_task));
if (!p_force_redraw) {
uint64_t tus = OS::get_singleton()->get_ticks_usec();
- if (tus-last_progress_tick < 50000) //50ms
+ if (tus - last_progress_tick < 50000) //50ms
return;
}
- Task &t=tasks[p_task];
- if (p_step<0)
- t.progress->set_value(t.progress->get_value()+1);
+ Task &t = tasks[p_task];
+ if (p_step < 0)
+ t.progress->set_value(t.progress->get_value() + 1);
else
t.progress->set_value(p_step);
t.state->set_text(p_state);
- last_progress_tick=OS::get_singleton()->get_ticks_usec();
+ last_progress_tick = OS::get_singleton()->get_ticks_usec();
Main::iteration(); // this will not work on a lot of platforms, so it's only meant for the editor
-
}
-
-void ProgressDialog::end_task(const String& p_task){
+void ProgressDialog::end_task(const String &p_task) {
ERR_FAIL_COND(!tasks.has(p_task));
- Task &t=tasks[p_task];
+ Task &t = tasks[p_task];
memdelete(t.vb);
tasks.erase(p_task);
@@ -233,14 +216,12 @@ void ProgressDialog::end_task(const String& p_task){
_popup();
}
-
-
ProgressDialog::ProgressDialog() {
- main = memnew( VBoxContainer );
+ main = memnew(VBoxContainer);
add_child(main);
main->set_area_as_parent_rect();
set_exclusive(true);
- last_progress_tick=0;
- singleton=this;
+ last_progress_tick = 0;
+ singleton = this;
}
diff --git a/editor/progress_dialog.h b/editor/progress_dialog.h
index 60acf825a9..346d6a58b3 100644
--- a/editor/progress_dialog.h
+++ b/editor/progress_dialog.h
@@ -29,15 +29,14 @@
#ifndef PROGRESS_DIALOG_H
#define PROGRESS_DIALOG_H
-#include "scene/gui/popup.h"
#include "scene/gui/box_container.h"
-#include "scene/gui/progress_bar.h"
#include "scene/gui/label.h"
-
+#include "scene/gui/popup.h"
+#include "scene/gui/progress_bar.h"
class BackgroundProgress : public HBoxContainer {
- GDCLASS(BackgroundProgress,HBoxContainer);
+ GDCLASS(BackgroundProgress, HBoxContainer);
_THREAD_SAFE_CLASS_
@@ -45,59 +44,53 @@ class BackgroundProgress : public HBoxContainer {
HBoxContainer *hb;
ProgressBar *progress;
-
};
- Map<String,Task> tasks;
- Map<String,int> updates;
+ Map<String, Task> tasks;
+ Map<String, int> updates;
void _update();
protected:
-
- void _add_task(const String& p_task,const String& p_label, int p_steps);
- void _task_step(const String& p_task, int p_step=-1);
- void _end_task(const String& p_task);
+ void _add_task(const String &p_task, const String &p_label, int p_steps);
+ void _task_step(const String &p_task, int p_step = -1);
+ void _end_task(const String &p_task);
static void _bind_methods();
public:
- void add_task(const String& p_task,const String& p_label, int p_steps);
- void task_step(const String& p_task, int p_step=-1);
- void end_task(const String& p_task);
+ void add_task(const String &p_task, const String &p_label, int p_steps);
+ void task_step(const String &p_task, int p_step = -1);
+ void end_task(const String &p_task);
BackgroundProgress() {}
};
-
-
class ProgressDialog : public Popup {
- GDCLASS( ProgressDialog, Popup );
+ GDCLASS(ProgressDialog, Popup);
struct Task {
String task;
VBoxContainer *vb;
ProgressBar *progress;
Label *state;
-
};
- Map<String,Task> tasks;
+ Map<String, Task> tasks;
VBoxContainer *main;
uint64_t last_progress_tick;
static ProgressDialog *singleton;
void _popup();
-protected:
+protected:
void _notification(int p_what);
-public:
+public:
static ProgressDialog *get_singleton() { return singleton; }
- void add_task(const String& p_task,const String& p_label, int p_steps);
- void task_step(const String& p_task, const String& p_state, int p_step=-1, bool p_force_redraw=true);
- void end_task(const String& p_task);
-
+ void add_task(const String &p_task, const String &p_label, int p_steps);
+ void task_step(const String &p_task, const String &p_state, int p_step = -1, bool p_force_redraw = true);
+ void end_task(const String &p_task);
ProgressDialog();
};
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index fc6d8793d8..78327a5d66 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -27,29 +27,29 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "project_export.h"
-#include "os/dir_access.h"
-#include "os/file_access.h"
+#include "compressed_translation.h"
+#include "editor_data.h"
+#include "editor_node.h"
+#include "editor_settings.h"
#include "global_config.h"
+#include "io/image_loader.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
+#include "io_plugins/editor_texture_import_plugin.h"
+#include "os/dir_access.h"
+#include "os/file_access.h"
#include "os/os.h"
#include "scene/gui/box_container.h"
-#include "scene/gui/tab_container.h"
-#include "scene/gui/scroll_container.h"
#include "scene/gui/margin_container.h"
-#include "editor_data.h"
-#include "io/image_loader.h"
-#include "compressed_translation.h"
-#include "editor_node.h"
-#include "io_plugins/editor_texture_import_plugin.h"
-#include "editor_settings.h"
+#include "scene/gui/scroll_container.h"
+#include "scene/gui/tab_container.h"
void ProjectExportDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
- delete_preset->set_icon(get_icon("Del","EditorIcons"));
- connect("confirmed",this,"_export_pck_zip");
+ delete_preset->set_icon(get_icon("Del", "EditorIcons"));
+ connect("confirmed", this, "_export_pck_zip");
} break;
case NOTIFICATION_POPUP_HIDE: {
EditorSettings::get_singleton()->set("interface/dialogs/export_bounds", get_rect());
@@ -57,16 +57,14 @@ void ProjectExportDialog::_notification(int p_what) {
}
}
-
void ProjectExportDialog::popup_export() {
add_preset->get_popup()->clear();
- for(int i=0;i<EditorExport::get_singleton()->get_export_platform_count();i++) {
+ for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
Ref<EditorExportPlatform> plat = EditorExport::get_singleton()->get_export_platform(i);
- add_preset->get_popup()->add_icon_item(plat->get_logo(),plat->get_name());
-
+ add_preset->get_popup()->add_icon_item(plat->get_logo(), plat->get_name());
}
_update_presets();
@@ -85,30 +83,28 @@ void ProjectExportDialog::_add_preset(int p_platform) {
ERR_FAIL_COND(!preset.is_valid());
String name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name();
- bool make_runnable=true;
- int attempt=1;
- while(true) {
+ bool make_runnable = true;
+ int attempt = 1;
+ while (true) {
- bool valid=true;
+ bool valid = true;
- for(int i=0;i<EditorExport::get_singleton()->get_export_preset_count();i++) {
+ for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
Ref<EditorExportPreset> p = EditorExport::get_singleton()->get_export_preset(i);
- if (p->get_platform()==preset->get_platform() && p->is_runnable()) {
- make_runnable=false;
+ if (p->get_platform() == preset->get_platform() && p->is_runnable()) {
+ make_runnable = false;
}
- if (p->get_name()==name) {
- valid=false;
+ if (p->get_name() == name) {
+ valid = false;
break;
}
-
}
if (valid)
break;
attempt++;
- name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name()+" "+itos(attempt);
-
+ name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name() + " " + itos(attempt);
}
preset->set_name(name);
@@ -116,45 +112,42 @@ void ProjectExportDialog::_add_preset(int p_platform) {
preset->set_runnable(make_runnable);
EditorExport::get_singleton()->add_export_preset(preset);
_update_presets();
- _edit_preset(EditorExport::get_singleton()->get_export_preset_count()-1);
-
+ _edit_preset(EditorExport::get_singleton()->get_export_preset_count() - 1);
}
-
void ProjectExportDialog::_update_presets() {
- updating=true;
+ updating = true;
Ref<EditorExportPreset> current;
- if (presets->get_current()>=0 && presets->get_current()<presets->get_item_count())
+ if (presets->get_current() >= 0 && presets->get_current() < presets->get_item_count())
current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
- int current_idx=-1;
+ int current_idx = -1;
presets->clear();
- for(int i=0;i<EditorExport::get_singleton()->get_export_preset_count();i++) {
+ for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(i);
- if (preset==current) {
- current_idx=i;
+ if (preset == current) {
+ current_idx = i;
}
String name = preset->get_name();
if (preset->is_runnable())
- name+=" ("+TTR("Runnable")+")";
- presets->add_item(name,preset->get_platform()->get_logo());
+ name += " (" + TTR("Runnable") + ")";
+ presets->add_item(name, preset->get_platform()->get_logo());
}
- if (current_idx!=-1) {
+ if (current_idx != -1) {
presets->select(current_idx);
//_edit_preset(current_idx);
}
- updating=false;
-
+ updating = false;
}
void ProjectExportDialog::_edit_preset(int p_index) {
- if (p_index<0 || p_index>=presets->get_item_count()) {
+ if (p_index < 0 || p_index >= presets->get_item_count()) {
name->set_text("");
name->set_editable(false);
runnable->set_disabled(true);
@@ -165,12 +158,10 @@ void ProjectExportDialog::_edit_preset(int p_index) {
return;
}
-
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(p_index);
ERR_FAIL_COND(current.is_null());
-
- updating=true;
+ updating = true;
presets->select(p_index);
sections->show();
@@ -186,53 +177,50 @@ void ProjectExportDialog::_edit_preset(int p_index) {
include_filters->set_text(current->get_include_filter());
exclude_filters->set_text(current->get_exclude_filter());
-
patches->clear();
TreeItem *patch_root = patches->create_item();
Vector<String> patchlist = current->get_patches();
- for(int i=0;i<patchlist.size();i++) {
+ for (int i = 0; i < patchlist.size(); i++) {
TreeItem *patch = patches->create_item(patch_root);
- patch->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
+ patch->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
String file = patchlist[i].get_file();
- patch->set_editable(0,true);
- patch->set_text(0,file.get_file().replace("*",""));
+ patch->set_editable(0, true);
+ patch->set_text(0, file.get_file().replace("*", ""));
if (file.ends_with("*"))
- patch->set_checked(0,true);
- patch->set_tooltip(0,patchlist[i]);
- patch->set_metadata(0,i);
- patch->add_button(0,get_icon("Del","EditorIcons"),0);
- patch->add_button(0,get_icon("folder","FileDialog"),1);
+ patch->set_checked(0, true);
+ patch->set_tooltip(0, patchlist[i]);
+ patch->set_metadata(0, i);
+ patch->add_button(0, get_icon("Del", "EditorIcons"), 0);
+ patch->add_button(0, get_icon("folder", "FileDialog"), 1);
}
TreeItem *patch_add = patches->create_item(patch_root);
- patch_add->set_metadata(0,patchlist.size());
- if (patchlist.size()==0)
- patch_add->set_text(0,"Add initial export..");
+ patch_add->set_metadata(0, patchlist.size());
+ if (patchlist.size() == 0)
+ patch_add->set_text(0, "Add initial export..");
else
- patch_add->set_text(0,"Add previous patches..");
+ patch_add->set_text(0, "Add previous patches..");
- patch_add->add_button(0,get_icon("folder","FileDialog"),1);
+ patch_add->add_button(0, get_icon("folder", "FileDialog"), 1);
_fill_resource_tree();
- updating=false;
-
+ updating = false;
}
-void ProjectExportDialog::_patch_button_pressed(Object* p_item,int p_column,int p_id) {
-
+void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, int p_id) {
- TreeItem *ti = (TreeItem*)p_item;
+ TreeItem *ti = (TreeItem *)p_item;
- patch_index=ti->get_metadata(0);
+ patch_index = ti->get_metadata(0);
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
ERR_FAIL_COND(current.is_null());
- if (p_id==0) {
+ if (p_id == 0) {
Vector<String> patches = current->get_patches();
- ERR_FAIL_INDEX(patch_index,patches.size());
- patch_erase->set_text(vformat(TTR("Delete patch '"+patches[patch_index].get_file()+"' from list?")));
+ ERR_FAIL_INDEX(patch_index, patches.size());
+ patch_erase->set_text(vformat(TTR("Delete patch '" + patches[patch_index].get_file() + "' from list?")));
patch_erase->popup_centered_minsize();
} else {
patch_dialog->popup_centered_ratio();
@@ -251,38 +239,33 @@ void ProjectExportDialog::_patch_edited() {
Vector<String> patches = current->get_patches();
- ERR_FAIL_INDEX(index,patches.size());
+ ERR_FAIL_INDEX(index, patches.size());
- String patch = patches[index].replace("*","");
+ String patch = patches[index].replace("*", "");
if (item->is_checked(0)) {
- patch+="*";
+ patch += "*";
}
- current->set_patch(index,patch);
-
-
-
+ current->set_patch(index, patch);
}
-void ProjectExportDialog::_patch_selected(const String& p_path) {
+void ProjectExportDialog::_patch_selected(const String &p_path) {
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
ERR_FAIL_COND(current.is_null());
Vector<String> patches = current->get_patches();
- if (patch_index >=patches.size()) {
+ if (patch_index >= patches.size()) {
- current->add_patch(GlobalConfig::get_singleton()->get_resource_path().path_to(p_path)+"*");
+ current->add_patch(GlobalConfig::get_singleton()->get_resource_path().path_to(p_path) + "*");
} else {
String enabled = patches[patch_index].ends_with("*") ? String("*") : String();
- current->set_patch(patch_index,GlobalConfig::get_singleton()->get_resource_path().path_to(p_path)+enabled);
-
+ current->set_patch(patch_index, GlobalConfig::get_singleton()->get_resource_path().path_to(p_path) + enabled);
}
_edit_preset(presets->get_current());
-
}
void ProjectExportDialog::_patch_deleted() {
@@ -291,12 +274,11 @@ void ProjectExportDialog::_patch_deleted() {
ERR_FAIL_COND(current.is_null());
Vector<String> patches = current->get_patches();
- if (patch_index <patches.size()) {
+ if (patch_index < patches.size()) {
current->remove_patch(patch_index);
_edit_preset(presets->get_current());
}
-
}
void ProjectExportDialog::_runnable_pressed() {
@@ -309,10 +291,10 @@ void ProjectExportDialog::_runnable_pressed() {
if (runnable->is_pressed()) {
- for(int i=0;i<EditorExport::get_singleton()->get_export_preset_count();i++) {
+ for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
Ref<EditorExportPreset> p = EditorExport::get_singleton()->get_export_preset(i);
- if (p->get_platform()==current->get_platform()) {
- p->set_runnable(current==p);
+ if (p->get_platform() == current->get_platform()) {
+ p->set_runnable(current == p);
}
}
} else {
@@ -323,7 +305,7 @@ void ProjectExportDialog::_runnable_pressed() {
_update_presets();
}
-void ProjectExportDialog::_name_changed(const String& p_string) {
+void ProjectExportDialog::_name_changed(const String &p_string) {
if (updating)
return;
@@ -333,8 +315,6 @@ void ProjectExportDialog::_name_changed(const String& p_string) {
current->set_name(p_string);
_update_presets();
-
-
}
void ProjectExportDialog::_delete_preset() {
@@ -343,81 +323,76 @@ void ProjectExportDialog::_delete_preset() {
if (current.is_null())
return;
- delete_confirm->set_text(vformat(TTR("Delete preset '%s'?"),current->get_name()));
+ delete_confirm->set_text(vformat(TTR("Delete preset '%s'?"), current->get_name()));
delete_confirm->popup_centered_minsize();
-
}
void ProjectExportDialog::_delete_preset_confirm() {
int idx = presets->get_current();
- parameters->edit(NULL);//to avoid crash
+ parameters->edit(NULL); //to avoid crash
EditorExport::get_singleton()->remove_export_preset(idx);
_update_presets();
_edit_preset(-1);
}
+Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-Variant ProjectExportDialog::get_drag_data_fw(const Point2& p_point,Control* p_from) {
+ if (p_from == presets) {
+ int pos = presets->get_item_at_pos(p_point, true);
- if (p_from==presets) {
- int pos = presets->get_item_at_pos(p_point,true);
-
- if (pos>=0) {
+ if (pos >= 0) {
Dictionary d;
- d["type"]="export_preset";
- d["preset"]=pos;
+ d["type"] = "export_preset";
+ d["preset"] = pos;
- HBoxContainer *drag = memnew( HBoxContainer);
+ HBoxContainer *drag = memnew(HBoxContainer);
TextureRect *tr = memnew(TextureRect);
tr->set_texture(presets->get_item_icon(pos));
drag->add_child(tr);
- Label *label = memnew( Label );
+ Label *label = memnew(Label);
label->set_text(presets->get_item_text(pos));
drag->add_child(label);
set_drag_preview(drag);
return d;
-
}
- } else if (p_from==patches) {
+ } else if (p_from == patches) {
TreeItem *item = patches->get_item_at_pos(p_point);
- if (item && item->get_cell_mode(0)==TreeItem::CELL_MODE_CHECK) {
+ if (item && item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK) {
int metadata = item->get_metadata(0);
Dictionary d;
- d["type"]="export_patch";
- d["patch"]=metadata;
+ d["type"] = "export_patch";
+ d["patch"] = metadata;
- Label *label = memnew( Label );
+ Label *label = memnew(Label);
label->set_text(item->get_text(0));
set_drag_preview(label);
return d;
}
-
}
return Variant();
}
-bool ProjectExportDialog::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{
+bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
- if (p_from==presets) {
+ if (p_from == presets) {
Dictionary d = p_data;
- if (!d.has("type") || String(d["type"])!="export_preset")
+ if (!d.has("type") || String(d["type"]) != "export_preset")
return false;
-
- if (presets->get_item_at_pos(p_point,true)<0 && !presets->is_pos_at_end_of_items(p_point))
+ if (presets->get_item_at_pos(p_point, true) < 0 && !presets->is_pos_at_end_of_items(p_point))
return false;
- } else if (p_from==patches) {
+ } else if (p_from == patches) {
Dictionary d = p_data;
- if (!d.has("type") || String(d["type"])!="export_patch")
+ if (!d.has("type") || String(d["type"]) != "export_patch")
return false;
patches->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
@@ -428,47 +403,45 @@ bool ProjectExportDialog::can_drop_data_fw(const Point2& p_point,const Variant&
return false;
}
-
}
return true;
}
-void ProjectExportDialog::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){
+void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
- if (p_from==presets) {
- Dictionary d=p_data;
+ if (p_from == presets) {
+ Dictionary d = p_data;
int from_pos = d["preset"];
- int to_pos=-1;
+ int to_pos = -1;
- if (presets->get_item_at_pos(p_point,true)>=0) {
- to_pos = presets->get_item_at_pos(p_point,true);
+ if (presets->get_item_at_pos(p_point, true) >= 0) {
+ to_pos = presets->get_item_at_pos(p_point, true);
}
- if (to_pos==-1 && !presets->is_pos_at_end_of_items(p_point))
+ if (to_pos == -1 && !presets->is_pos_at_end_of_items(p_point))
return;
- if (to_pos==from_pos)
+ if (to_pos == from_pos)
return;
- else if (to_pos>from_pos) {
+ else if (to_pos > from_pos) {
to_pos--;
}
-
Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(from_pos);
EditorExport::get_singleton()->remove_export_preset(from_pos);
- EditorExport::get_singleton()->add_export_preset(preset,to_pos);
+ EditorExport::get_singleton()->add_export_preset(preset, to_pos);
_update_presets();
- if (to_pos>=0)
+ if (to_pos >= 0)
_edit_preset(to_pos);
else
- _edit_preset(presets->get_item_count()-1);
- } else if (p_from==patches) {
+ _edit_preset(presets->get_item_count() - 1);
+ } else if (p_from == patches) {
Dictionary d = p_data;
- if (!d.has("type") || String(d["type"])!="export_patch")
+ if (!d.has("type") || String(d["type"]) != "export_patch")
return;
int from_pos = d["patch"];
@@ -477,23 +450,21 @@ void ProjectExportDialog::drop_data_fw(const Point2& p_point,const Variant& p_da
if (!item)
return;
- int to_pos = item->get_cell_mode(0)==TreeItem::CELL_MODE_CHECK ? int(item->get_metadata(0)) : -1;
+ int to_pos = item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK ? int(item->get_metadata(0)) : -1;
- if (to_pos==from_pos)
+ if (to_pos == from_pos)
return;
- else if (to_pos>from_pos) {
+ else if (to_pos > from_pos) {
to_pos--;
}
Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(presets->get_current());
String patch = preset->get_patch(from_pos);
preset->remove_patch(from_pos);
- preset->add_patch(patch,to_pos);
+ preset->add_patch(patch, to_pos);
_edit_preset(presets->get_current());
-
}
-
}
void ProjectExportDialog::_export_type_changed(int p_which) {
@@ -506,13 +477,12 @@ void ProjectExportDialog::_export_type_changed(int p_which) {
return;
current->set_export_filter(EditorExportPreset::ExportFilter(p_which));
- updating=true;
+ updating = true;
_fill_resource_tree();
- updating=false;
-
+ updating = false;
}
-void ProjectExportDialog::_filter_changed(const String& p_filter) {
+void ProjectExportDialog::_filter_changed(const String &p_filter) {
if (updating)
return;
@@ -523,9 +493,6 @@ void ProjectExportDialog::_filter_changed(const String& p_filter) {
current->set_include_filter(include_filters->get_text());
current->set_exclude_filter(exclude_filters->get_text());
-
-
-
}
void ProjectExportDialog::_fill_resource_tree() {
@@ -540,7 +507,7 @@ void ProjectExportDialog::_fill_resource_tree() {
EditorExportPreset::ExportFilter f = current->get_export_filter();
- if (f==EditorExportPreset::EXPORT_ALL_RESOURCES) {
+ if (f == EditorExportPreset::EXPORT_ALL_RESOURCES) {
return;
}
@@ -549,56 +516,50 @@ void ProjectExportDialog::_fill_resource_tree() {
TreeItem *root = include_files->create_item();
-
- _fill_tree(EditorFileSystem::get_singleton()->get_filesystem(),root,current,f==EditorExportPreset::EXPORT_SELECTED_SCENES);
-
+ _fill_tree(EditorFileSystem::get_singleton()->get_filesystem(), root, current, f == EditorExportPreset::EXPORT_SELECTED_SCENES);
}
+bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem *p_item, Ref<EditorExportPreset> &current, bool p_only_scenes) {
-bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir,TreeItem *p_item,Ref<EditorExportPreset> &current,bool p_only_scenes) {
-
- p_item->set_icon(0,get_icon("folder","FileDialog"));
- p_item->set_text(0,p_dir->get_name()+"/");
+ p_item->set_icon(0, get_icon("folder", "FileDialog"));
+ p_item->set_text(0, p_dir->get_name() + "/");
- bool used=false;
- for(int i=0;i<p_dir->get_subdir_count();i++) {
+ bool used = false;
+ for (int i = 0; i < p_dir->get_subdir_count(); i++) {
TreeItem *subdir = include_files->create_item(p_item);
- if (_fill_tree(p_dir->get_subdir(i),subdir,current,p_only_scenes)==false) {
+ if (_fill_tree(p_dir->get_subdir(i), subdir, current, p_only_scenes) == false) {
memdelete(subdir);
} else {
- used=true;
+ used = true;
}
}
-
-
- for(int i=0;i<p_dir->get_file_count();i++) {
+ for (int i = 0; i < p_dir->get_file_count(); i++) {
String type = p_dir->get_file_type(i);
- if (p_only_scenes && type!="PackedScene")
+ if (p_only_scenes && type != "PackedScene")
continue;
TreeItem *file = include_files->create_item(p_item);
- file->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- file->set_text(0,p_dir->get_file(i));
+ file->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ file->set_text(0, p_dir->get_file(i));
Ref<Texture> tex;
- if (has_icon(type,editor_icons)) {
- tex = get_icon(type,editor_icons);
+ if (has_icon(type, editor_icons)) {
+ tex = get_icon(type, editor_icons);
} else {
- tex = get_icon("Object",editor_icons);
+ tex = get_icon("Object", editor_icons);
}
String path = p_dir->get_file_path(i);
- file->set_icon(0,tex);
- file->set_editable(0,true);
- file->set_checked(0,current->has_export_file(path));
- file->set_metadata(0,path);
-
- used=true;
+ file->set_icon(0, tex);
+ file->set_editable(0, true);
+ file->set_checked(0, current->has_export_file(path));
+ file->set_metadata(0, path);
+ used = true;
}
return used;
@@ -624,172 +585,166 @@ void ProjectExportDialog::_tree_changed() {
current->add_export_file(path);
} else {
current->remove_export_file(path);
-
}
}
-
void ProjectExportDialog::_export_pck_zip() {
export_pck_zip->popup_centered_ratio();
}
-void ProjectExportDialog::_export_pck_zip_selected(const String& p_path) {
+void ProjectExportDialog::_export_pck_zip_selected(const String &p_path) {
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
- ERR_FAIL_COND (current.is_null());
+ ERR_FAIL_COND(current.is_null());
Ref<EditorExportPlatform> platform = current->get_platform();
- ERR_FAIL_COND( platform.is_null() );
+ ERR_FAIL_COND(platform.is_null());
if (p_path.ends_with(".zip")) {
- platform->save_zip(current,p_path);
+ platform->save_zip(current, p_path);
} else if (p_path.ends_with(".pck")) {
- platform->save_pack(current,p_path);
+ platform->save_pack(current, p_path);
}
}
-
void ProjectExportDialog::_bind_methods() {
- ClassDB::bind_method("_add_preset",&ProjectExportDialog::_add_preset);
- ClassDB::bind_method("_edit_preset",&ProjectExportDialog::_edit_preset);
- ClassDB::bind_method("_runnable_pressed",&ProjectExportDialog::_runnable_pressed);
- ClassDB::bind_method("_name_changed",&ProjectExportDialog::_name_changed);
- ClassDB::bind_method("_delete_preset",&ProjectExportDialog::_delete_preset);
- ClassDB::bind_method("_delete_preset_confirm",&ProjectExportDialog::_delete_preset_confirm);
- ClassDB::bind_method("get_drag_data_fw",&ProjectExportDialog::get_drag_data_fw);
- ClassDB::bind_method("can_drop_data_fw",&ProjectExportDialog::can_drop_data_fw);
- ClassDB::bind_method("drop_data_fw",&ProjectExportDialog::drop_data_fw);
- ClassDB::bind_method("_export_type_changed",&ProjectExportDialog::_export_type_changed);
- ClassDB::bind_method("_filter_changed",&ProjectExportDialog::_filter_changed);
- ClassDB::bind_method("_tree_changed",&ProjectExportDialog::_tree_changed);
- ClassDB::bind_method("_patch_button_pressed",&ProjectExportDialog::_patch_button_pressed);
- ClassDB::bind_method("_patch_selected",&ProjectExportDialog::_patch_selected);
- ClassDB::bind_method("_patch_deleted",&ProjectExportDialog::_patch_deleted);
- ClassDB::bind_method("_patch_edited",&ProjectExportDialog::_patch_edited);
- ClassDB::bind_method("_export_pck_zip",&ProjectExportDialog::_export_pck_zip);
- ClassDB::bind_method("_export_pck_zip_selected",&ProjectExportDialog::_export_pck_zip_selected);
-
-
+ ClassDB::bind_method("_add_preset", &ProjectExportDialog::_add_preset);
+ ClassDB::bind_method("_edit_preset", &ProjectExportDialog::_edit_preset);
+ ClassDB::bind_method("_runnable_pressed", &ProjectExportDialog::_runnable_pressed);
+ ClassDB::bind_method("_name_changed", &ProjectExportDialog::_name_changed);
+ ClassDB::bind_method("_delete_preset", &ProjectExportDialog::_delete_preset);
+ ClassDB::bind_method("_delete_preset_confirm", &ProjectExportDialog::_delete_preset_confirm);
+ ClassDB::bind_method("get_drag_data_fw", &ProjectExportDialog::get_drag_data_fw);
+ ClassDB::bind_method("can_drop_data_fw", &ProjectExportDialog::can_drop_data_fw);
+ ClassDB::bind_method("drop_data_fw", &ProjectExportDialog::drop_data_fw);
+ ClassDB::bind_method("_export_type_changed", &ProjectExportDialog::_export_type_changed);
+ ClassDB::bind_method("_filter_changed", &ProjectExportDialog::_filter_changed);
+ ClassDB::bind_method("_tree_changed", &ProjectExportDialog::_tree_changed);
+ ClassDB::bind_method("_patch_button_pressed", &ProjectExportDialog::_patch_button_pressed);
+ ClassDB::bind_method("_patch_selected", &ProjectExportDialog::_patch_selected);
+ ClassDB::bind_method("_patch_deleted", &ProjectExportDialog::_patch_deleted);
+ ClassDB::bind_method("_patch_edited", &ProjectExportDialog::_patch_edited);
+ ClassDB::bind_method("_export_pck_zip", &ProjectExportDialog::_export_pck_zip);
+ ClassDB::bind_method("_export_pck_zip_selected", &ProjectExportDialog::_export_pck_zip_selected);
}
ProjectExportDialog::ProjectExportDialog() {
set_title(TTR("Export"));
set_resizable(true);
- HBoxContainer *hbox = memnew( HBoxContainer );
+ HBoxContainer *hbox = memnew(HBoxContainer);
add_child(hbox);
- VBoxContainer *preset_vb = memnew( VBoxContainer );
+ VBoxContainer *preset_vb = memnew(VBoxContainer);
preset_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbox->add_child(preset_vb);
- HBoxContainer *preset_hb = memnew( HBoxContainer );
+ HBoxContainer *preset_hb = memnew(HBoxContainer);
preset_hb->add_child(memnew(Label(TTR("Presets"))));
preset_hb->add_spacer();
preset_vb->add_child(preset_hb);
- add_preset = memnew( MenuButton );
+ add_preset = memnew(MenuButton);
add_preset->set_text(TTR("Add.."));
- add_preset->get_popup()->connect("index_pressed",this,"_add_preset");
+ add_preset->get_popup()->connect("index_pressed", this, "_add_preset");
preset_hb->add_child(add_preset);
- MarginContainer *mc = memnew( MarginContainer );
+ MarginContainer *mc = memnew(MarginContainer);
preset_vb->add_child(mc);
mc->set_v_size_flags(SIZE_EXPAND_FILL);
- presets = memnew( ItemList );
+ presets = memnew(ItemList);
presets->set_drag_forwarding(this);
mc->add_child(presets);
- presets->connect("item_selected",this,"_edit_preset");
- delete_preset = memnew( ToolButton );
+ presets->connect("item_selected", this, "_edit_preset");
+ delete_preset = memnew(ToolButton);
preset_hb->add_child(delete_preset);
- delete_preset->connect("pressed",this,"_delete_preset");
+ delete_preset->connect("pressed", this, "_delete_preset");
- VBoxContainer *settings_vb = memnew( VBoxContainer );
+ VBoxContainer *settings_vb = memnew(VBoxContainer);
settings_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbox->add_child(settings_vb);
name = memnew(LineEdit);
- settings_vb->add_margin_child(TTR("Name:"),name);
- name->connect("text_changed",this,"_name_changed");
+ settings_vb->add_margin_child(TTR("Name:"), name);
+ name->connect("text_changed", this, "_name_changed");
runnable = memnew(CheckButton);
runnable->set_text(TTR("Runnable"));
- runnable->connect("pressed",this,"_runnable_pressed");
+ runnable->connect("pressed", this, "_runnable_pressed");
settings_vb->add_child(runnable);
- sections = memnew (TabContainer );
+ sections = memnew(TabContainer);
settings_vb->add_child(sections);
sections->set_v_size_flags(SIZE_EXPAND_FILL);
- parameters = memnew (PropertyEditor );
+ parameters = memnew(PropertyEditor);
sections->add_child(parameters);
parameters->set_name(TTR("Options"));
parameters->hide_top_label();
parameters->set_v_size_flags(SIZE_EXPAND_FILL);
parameters->set_hide_script(true);
- VBoxContainer *resources_vb = memnew( VBoxContainer );
+ VBoxContainer *resources_vb = memnew(VBoxContainer);
sections->add_child(resources_vb);
resources_vb->set_name(TTR("Resources"));
- export_filter = memnew( OptionButton );
+ export_filter = memnew(OptionButton);
export_filter->add_item(TTR("Export all resources in the project"));
export_filter->add_item(TTR("Export selected scenes (and dependencies)"));
export_filter->add_item(TTR("Export selected resources (and dependencies)"));
- resources_vb->add_margin_child(TTR("Export Mode:"),export_filter);
- export_filter->connect("item_selected",this,"_export_type_changed");
+ resources_vb->add_margin_child(TTR("Export Mode:"), export_filter);
+ export_filter->connect("item_selected", this, "_export_type_changed");
- include_label = memnew( Label );
+ include_label = memnew(Label);
include_label->set_text(TTR("Resources to export:"));
resources_vb->add_child(include_label);
- include_margin = memnew( MarginContainer );
+ include_margin = memnew(MarginContainer);
include_margin->set_v_size_flags(SIZE_EXPAND_FILL);
resources_vb->add_child(include_margin);
include_files = memnew(Tree);
include_margin->add_child(include_files);
- include_files->connect("item_edited",this,"_tree_changed");
+ include_files->connect("item_edited", this, "_tree_changed");
- include_filters = memnew( LineEdit );
- resources_vb->add_margin_child(TTR("Filters to export non-resource files (comma separated, e.g: *.json, *.txt)"),include_filters);
- include_filters->connect("text_changed",this,"_filter_changed");
+ include_filters = memnew(LineEdit);
+ resources_vb->add_margin_child(TTR("Filters to export non-resource files (comma separated, e.g: *.json, *.txt)"), include_filters);
+ include_filters->connect("text_changed", this, "_filter_changed");
- exclude_filters = memnew( LineEdit );
- resources_vb->add_margin_child(TTR("Filters to exclude files from project (comma separated, e.g: *.json, *.txt)"),exclude_filters);
- exclude_filters->connect("text_changed",this,"_filter_changed");
+ exclude_filters = memnew(LineEdit);
+ resources_vb->add_margin_child(TTR("Filters to exclude files from project (comma separated, e.g: *.json, *.txt)"), exclude_filters);
+ exclude_filters->connect("text_changed", this, "_filter_changed");
- VBoxContainer *patch_vb = memnew( VBoxContainer );
+ VBoxContainer *patch_vb = memnew(VBoxContainer);
sections->add_child(patch_vb);
patch_vb->set_name(TTR("Patches"));
- patches = memnew( Tree );
+ patches = memnew(Tree);
patch_vb->add_child(patches);
patches->set_v_size_flags(SIZE_EXPAND_FILL);
patches->set_hide_root(true);
- patches->connect("button_pressed",this,"_patch_button_pressed");
- patches->connect("item_edited",this,"_patch_edited");
+ patches->connect("button_pressed", this, "_patch_button_pressed");
+ patches->connect("item_edited", this, "_patch_edited");
patches->set_drag_forwarding(this);
patches->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
- HBoxContainer *patches_hb = memnew( HBoxContainer );
+ HBoxContainer *patches_hb = memnew(HBoxContainer);
patch_vb->add_child(patches_hb);
patches_hb->add_spacer();
- patch_export = memnew( Button );
+ patch_export = memnew(Button);
patch_export->set_text(TTR("Make Patch"));
patches_hb->add_child(patch_export);
patches_hb->add_spacer();
- patch_dialog = memnew( FileDialog );
+ patch_dialog = memnew(FileDialog);
patch_dialog->add_filter("*.pck ; Pack File");
patch_dialog->set_mode(FileDialog::MODE_OPEN_FILE);
- patch_dialog->connect("file_selected",this,"_patch_selected");
+ patch_dialog->connect("file_selected", this, "_patch_selected");
add_child(patch_dialog);
- patch_erase = memnew( ConfirmationDialog );
+ patch_erase = memnew(ConfirmationDialog);
patch_erase->get_ok()->set_text(TTR("Delete"));
- patch_erase->connect("confirmed",this,"_patch_deleted");
+ patch_erase->connect("confirmed", this, "_patch_deleted");
add_child(patch_erase);
-
//disable by default
name->set_editable(false);
runnable->set_disabled(true);
@@ -797,32 +752,28 @@ ProjectExportDialog::ProjectExportDialog() {
sections->hide();
parameters->edit(NULL);
- delete_confirm = memnew( ConfirmationDialog );
+ delete_confirm = memnew(ConfirmationDialog);
add_child(delete_confirm);
delete_confirm->get_ok()->set_text(TTR("Delete"));
- delete_confirm->connect("confirmed",this,"_delete_preset_confirm");
+ delete_confirm->connect("confirmed", this, "_delete_preset_confirm");
- updating=false;
+ updating = false;
get_ok()->set_text("Export PCK/Zip");
- export_button = add_button("Export Project",!OS::get_singleton()->get_swap_ok_cancel(),"export");
+ export_button = add_button("Export Project", !OS::get_singleton()->get_swap_ok_cancel(), "export");
- export_pck_zip = memnew( FileDialog );
+ export_pck_zip = memnew(FileDialog);
export_pck_zip->add_filter("*.zip ; ZIP File");
export_pck_zip->add_filter("*.pck ; Godot Game Pack");
export_pck_zip->set_access(FileDialog::ACCESS_FILESYSTEM);
export_pck_zip->set_mode(FileDialog::MODE_SAVE_FILE);
add_child(export_pck_zip);
- export_pck_zip->connect("file_selected",this,"_export_pck_zip_selected");
+ export_pck_zip->connect("file_selected", this, "_export_pck_zip_selected");
set_hide_on_ok(false);
-
-
editor_icons = "EditorIcons";
}
ProjectExportDialog::~ProjectExportDialog() {
-
-
}
diff --git a/editor/project_export.h b/editor/project_export.h
index b58ce2dc9d..dff3ab356f 100644
--- a/editor/project_export.h
+++ b/editor/project_export.h
@@ -29,33 +29,30 @@
#ifndef PROJECT_EXPORT_SETTINGS_H
#define PROJECT_EXPORT_SETTINGS_H
-#include "scene/main/timer.h"
-#include "scene/gui/control.h"
-#include "scene/gui/tree.h"
-#include "scene/gui/label.h"
#include "editor/editor_file_dialog.h"
-#include "scene/gui/button.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/dialogs.h"
-#include "scene/gui/tab_container.h"
#include "os/dir_access.h"
#include "os/thread.h"
+#include "scene/gui/button.h"
+#include "scene/gui/control.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/file_dialog.h"
+#include "scene/gui/label.h"
#include "scene/gui/option_button.h"
+#include "scene/gui/tab_container.h"
+#include "scene/gui/tree.h"
+#include "scene/main/timer.h"
-#include "scene/gui/slider.h"
#include "editor/editor_file_system.h"
-#include "property_editor.h"
#include "editor_export.h"
-
+#include "property_editor.h"
+#include "scene/gui/slider.h"
class EditorNode;
class ProjectExportDialog : public ConfirmationDialog {
- GDCLASS( ProjectExportDialog, ConfirmationDialog );
+ GDCLASS(ProjectExportDialog, ConfirmationDialog);
private:
-
-
TabContainer *sections;
MenuButton *add_preset;
@@ -66,7 +63,6 @@ private:
PropertyEditor *parameters;
CheckButton *runnable;
-
EditorFileDialog *pck_export;
EditorFileDialog *file_export;
@@ -80,7 +76,7 @@ private:
LineEdit *exclude_filters;
Tree *include_files;
- Label* include_label;
+ Label *include_label;
MarginContainer *include_margin;
StringName editor_icons;
@@ -93,11 +89,11 @@ private:
Button *export_button;
- void _patch_selected(const String& p_path);
+ void _patch_selected(const String &p_path);
void _patch_deleted();
void _runnable_pressed();
- void _name_changed(const String& p_string);
+ void _name_changed(const String &p_string);
void _add_preset(int p_platform);
void _edit_preset(int p_index);
void _delete_preset();
@@ -106,37 +102,32 @@ private:
void _update_presets();
void _export_type_changed(int p_which);
- void _filter_changed(const String& p_filter);
+ void _filter_changed(const String &p_filter);
void _fill_resource_tree();
- bool _fill_tree(EditorFileSystemDirectory *p_dir,TreeItem *p_item,Ref<EditorExportPreset> &current,bool p_only_scenes);
+ bool _fill_tree(EditorFileSystemDirectory *p_dir, TreeItem *p_item, Ref<EditorExportPreset> &current, bool p_only_scenes);
void _tree_changed();
- void _patch_button_pressed(Object* p_item,int p_column,int p_id);
+ void _patch_button_pressed(Object *p_item, int p_column, int p_id);
void _patch_edited();
-
- Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
- bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
- void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
FileDialog *export_pck_zip;
void _export_pck_zip();
- void _export_pck_zip_selected(const String& p_path);
+ void _export_pck_zip_selected(const String &p_path);
protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void popup_export();
ProjectExportDialog();
~ProjectExportDialog();
};
-
-
-
#endif // PROJECT_EXPORT_SETTINGS_H
-
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 34b2d3e82c..7fa8e9bf84 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -28,42 +28,41 @@
/*************************************************************************/
#include "project_manager.h"
-#include "version.h"
-#include "os/os.h"
+#include "editor_initialize_ssl.h"
+#include "editor_scale.h"
+#include "editor_settings.h"
+#include "editor_themes.h"
+#include "io/config_file.h"
+#include "io/resource_saver.h"
+#include "io/stream_peer_ssl.h"
+#include "io/zip_io.h"
#include "os/dir_access.h"
#include "os/file_access.h"
#include "os/keyboard.h"
-#include "editor_settings.h"
-#include "scene/gui/separator.h"
-#include "scene/gui/tool_button.h"
-#include "io/config_file.h"
+#include "os/os.h"
+#include "scene/gui/center_container.h"
#include "scene/gui/line_edit.h"
+#include "scene/gui/margin_container.h"
#include "scene/gui/panel_container.h"
-#include "scene/gui/center_container.h"
-#include "io/stream_peer_ssl.h"
+#include "scene/gui/separator.h"
#include "scene/gui/texture_rect.h"
-#include "scene/gui/margin_container.h"
-#include "io/resource_saver.h"
-#include "editor_themes.h"
-#include "editor_initialize_ssl.h"
-#include "editor_scale.h"
-#include "io/zip_io.h"
+#include "scene/gui/tool_button.h"
+#include "version.h"
class NewProjectDialog : public ConfirmationDialog {
- GDCLASS(NewProjectDialog,ConfirmationDialog);
+ GDCLASS(NewProjectDialog, ConfirmationDialog);
public:
-
enum Mode {
MODE_NEW,
MODE_IMPORT,
MODE_INSTALL
};
-private:
+private:
Mode mode;
- Label *pp,*pn;
+ Label *pp, *pn;
Label *error;
LineEdit *project_path;
LineEdit *project_name;
@@ -78,10 +77,10 @@ private:
get_ok()->set_disabled(true);
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
String valid_path;
- if (d->change_dir(project_path->get_text())==OK){
- valid_path=project_path->get_text();
- } else if (d->change_dir(project_path->get_text().strip_edges())==OK) {
- valid_path=project_path->get_text().strip_edges();
+ if (d->change_dir(project_path->get_text()) == OK) {
+ valid_path = project_path->get_text();
+ } else if (d->change_dir(project_path->get_text().strip_edges()) == OK) {
+ valid_path = project_path->get_text().strip_edges();
}
if (valid_path == "") {
@@ -90,7 +89,7 @@ private:
return "";
}
- if (mode!=MODE_IMPORT) {
+ if (mode != MODE_IMPORT) {
if (d->file_exists("godot.cfg")) {
@@ -112,34 +111,33 @@ private:
memdelete(d);
get_ok()->set_disabled(false);
return valid_path;
-
}
- void _path_text_changed(const String& p_path) {
+ void _path_text_changed(const String &p_path) {
- String sp=_test_path();
- if ( sp!="" ) {
+ String sp = _test_path();
+ if (sp != "") {
- sp=sp.replace("\\","/");
- int lidx=sp.find_last("/");
+ sp = sp.replace("\\", "/");
+ int lidx = sp.find_last("/");
- if (lidx!=-1) {
- sp=sp.substr(lidx+1,sp.length());
+ if (lidx != -1) {
+ sp = sp.substr(lidx + 1, sp.length());
}
- if (sp=="" && mode==MODE_IMPORT )
- sp=TTR("Imported Project");
+ if (sp == "" && mode == MODE_IMPORT)
+ sp = TTR("Imported Project");
project_name->set_text(sp);
}
}
- void _file_selected(const String& p_path) {
+ void _file_selected(const String &p_path) {
String p = p_path;
- if (mode==MODE_IMPORT) {
+ if (mode == MODE_IMPORT) {
if (p.ends_with("godot.cfg")) {
- p=p.get_base_dir();
+ p = p.get_base_dir();
}
}
String sp = p.simplify_path();
@@ -148,7 +146,7 @@ private:
get_ok()->call_deferred("grab_focus");
}
- void _path_selected(const String& p_path) {
+ void _path_selected(const String &p_path) {
String p = p_path;
String sp = p.simplify_path();
@@ -159,7 +157,7 @@ private:
void _browse_path() {
- if (mode==MODE_IMPORT) {
+ if (mode == MODE_IMPORT) {
fdialog->set_mode(FileDialog::MODE_OPEN_FILE);
fdialog->clear_filters();
@@ -170,27 +168,24 @@ private:
fdialog->popup_centered_ratio();
}
- void _text_changed(const String& p_text) {
+ void _text_changed(const String &p_text) {
_test_path();
}
void ok_pressed() {
- String dir=_test_path();
- if (dir=="") {
+ String dir = _test_path();
+ if (dir == "") {
error->set_text(TTR("Invalid project path (changed anything?)."));
return;
}
- if (mode==MODE_IMPORT) {
+ if (mode == MODE_IMPORT) {
// nothing to do
} else {
- if (mode==MODE_NEW) {
-
-
+ if (mode == MODE_NEW) {
-
- FileAccess *f = FileAccess::open(dir.plus_file("/godot.cfg"),FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(dir.plus_file("/godot.cfg"), FileAccess::WRITE);
if (!f) {
error->set_text(TTR("Couldn't create godot.cfg in project path."));
} else {
@@ -205,18 +200,17 @@ private:
f->store_line("\n");
f->store_line("[application]");
f->store_line("\n");
- f->store_line("name=\""+project_name->get_text()+"\"");
+ f->store_line("name=\"" + project_name->get_text() + "\"");
f->store_line("icon=\"res://icon.png\"");
memdelete(f);
- ResourceSaver::save(dir.plus_file("/icon.png"),get_icon("DefaultProjectIcon","EditorIcons"));
+ ResourceSaver::save(dir.plus_file("/icon.png"), get_icon("DefaultProjectIcon", "EditorIcons"));
}
- } else if (mode==MODE_INSTALL) {
-
+ } else if (mode == MODE_INSTALL) {
- FileAccess *src_f=NULL;
+ FileAccess *src_f = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io);
@@ -230,34 +224,33 @@ private:
Vector<String> failed_files;
- int idx=0;
- while(ret==UNZ_OK) {
+ int idx = 0;
+ while (ret == UNZ_OK) {
//get filename
unz_file_info info;
char fname[16384];
- ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0);
+ ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
- String path=fname;
+ String path = fname;
- int depth=1; //stuff from github comes with tag
- bool skip=false;
- while(depth>0) {
+ int depth = 1; //stuff from github comes with tag
+ bool skip = false;
+ while (depth > 0) {
int pp = path.find("/");
- if (pp==-1) {
- skip=true;
+ if (pp == -1) {
+ skip = true;
break;
}
- path=path.substr(pp+1,path.length());
+ path = path.substr(pp + 1, path.length());
depth--;
}
-
- if (skip || path==String()) {
+ if (skip || path == String()) {
//
} else if (path.ends_with("/")) { // a dir
- path=path.substr(0,path.length()-1);
+ path = path.substr(0, path.length() - 1);
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->make_dir(dir.plus_file(path));
@@ -270,19 +263,17 @@ private:
//read
unzOpenCurrentFile(pkg);
- unzReadCurrentFile(pkg,data.ptr(),data.size());
+ unzReadCurrentFile(pkg, data.ptr(), data.size());
unzCloseCurrentFile(pkg);
- FileAccess *f=FileAccess::open(dir.plus_file(path),FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(dir.plus_file(path), FileAccess::WRITE);
if (f) {
- f->store_buffer(data.ptr(),data.size());
+ f->store_buffer(data.ptr(), data.size());
memdelete(f);
} else {
failed_files.push_back(path);
}
-
-
}
idx++;
@@ -292,14 +283,14 @@ private:
unzClose(pkg);
if (failed_files.size()) {
- String msg=TTR("The following files failed extraction from package:")+"\n\n";
- for(int i=0;i<failed_files.size();i++) {
+ String msg = TTR("The following files failed extraction from package:") + "\n\n";
+ for (int i = 0; i < failed_files.size(); i++) {
- if (i>15) {
- msg+="\nAnd "+itos(failed_files.size()-i)+" more files.";
+ if (i > 15) {
+ msg += "\nAnd " + itos(failed_files.size() - i) + " more files.";
break;
}
- msg+=failed_files[i]+"\n";
+ msg += failed_files[i] + "\n";
}
dialog_error->set_text(msg);
@@ -309,58 +300,50 @@ private:
dialog_error->set_text(TTR("Package Installed Successfully!"));
dialog_error->popup_centered_minsize();
}
-
}
-
}
- dir=dir.replace("\\","/");
+ dir = dir.replace("\\", "/");
if (dir.ends_with("/"))
- dir=dir.substr(0,dir.length()-1);
- String proj=dir.replace("/","::");
- EditorSettings::get_singleton()->set("projects/"+proj,dir);
+ dir = dir.substr(0, dir.length() - 1);
+ String proj = dir.replace("/", "::");
+ EditorSettings::get_singleton()->set("projects/" + proj, dir);
EditorSettings::get_singleton()->save();
-
-
hide();
emit_signal("project_created", dir);
-
}
protected:
-
static void _bind_methods() {
- ClassDB::bind_method("_browse_path",&NewProjectDialog::_browse_path);
- ClassDB::bind_method("_text_changed",&NewProjectDialog::_text_changed);
- ClassDB::bind_method("_path_text_changed",&NewProjectDialog::_path_text_changed);
- ClassDB::bind_method("_path_selected",&NewProjectDialog::_path_selected);
- ClassDB::bind_method("_file_selected",&NewProjectDialog::_file_selected);
- ADD_SIGNAL( MethodInfo("project_created") );
+ ClassDB::bind_method("_browse_path", &NewProjectDialog::_browse_path);
+ ClassDB::bind_method("_text_changed", &NewProjectDialog::_text_changed);
+ ClassDB::bind_method("_path_text_changed", &NewProjectDialog::_path_text_changed);
+ ClassDB::bind_method("_path_selected", &NewProjectDialog::_path_selected);
+ ClassDB::bind_method("_file_selected", &NewProjectDialog::_file_selected);
+ ADD_SIGNAL(MethodInfo("project_created"));
}
public:
-
- void set_zip_path(const String& p_path) {
- zip_path=p_path;
+ void set_zip_path(const String &p_path) {
+ zip_path = p_path;
}
- void set_zip_title(const String& p_title) {
- zip_title=p_title;
+ void set_zip_title(const String &p_title) {
+ zip_title = p_title;
}
void set_mode(Mode p_mode) {
- mode=p_mode;
+ mode = p_mode;
}
void show_dialog() {
-
project_path->clear();
project_name->clear();
- if (mode==MODE_IMPORT) {
+ if (mode == MODE_IMPORT) {
set_title(TTR("Import Existing Project"));
get_ok()->set_text(TTR("Import"));
pp->set_text(TTR("Project Path (Must Exist):"));
@@ -368,9 +351,9 @@ public:
pn->hide();
project_name->hide();
- popup_centered(Size2(500,125)*EDSCALE);
+ popup_centered(Size2(500, 125) * EDSCALE);
- } else if (mode==MODE_NEW){
+ } else if (mode == MODE_NEW) {
set_title(TTR("Create New Project"));
get_ok()->set_text(TTR("Create"));
@@ -379,17 +362,16 @@ public:
pn->show();
project_name->show();
- popup_centered(Size2(500,145)*EDSCALE);
- } else if (mode==MODE_INSTALL){
+ popup_centered(Size2(500, 145) * EDSCALE);
+ } else if (mode == MODE_INSTALL) {
- set_title(TTR("Install Project:")+" "+zip_title);
+ set_title(TTR("Install Project:") + " " + zip_title);
get_ok()->set_text(TTR("Install"));
pp->set_text(TTR("Project Path:"));
pn->hide();
project_name->hide();
- popup_centered(Size2(500,125)*EDSCALE);
-
+ popup_centered(Size2(500, 125) * EDSCALE);
}
project_path->grab_focus();
@@ -398,69 +380,65 @@ public:
NewProjectDialog() {
-
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
//set_child_rect(vb);
- Label* l = memnew(Label);
+ Label *l = memnew(Label);
l->set_text(TTR("Project Path:"));
vb->add_child(l);
- pp=l;
+ pp = l;
- project_path = memnew( LineEdit );
- MarginContainer *mc = memnew( MarginContainer );
+ project_path = memnew(LineEdit);
+ MarginContainer *mc = memnew(MarginContainer);
vb->add_child(mc);
- HBoxContainer *pphb = memnew( HBoxContainer );
+ HBoxContainer *pphb = memnew(HBoxContainer);
mc->add_child(pphb);
pphb->add_child(project_path);
project_path->set_h_size_flags(SIZE_EXPAND_FILL);
- Button* browse = memnew( Button );
+ Button *browse = memnew(Button);
pphb->add_child(browse);
browse->set_text(TTR("Browse"));
- browse->connect("pressed", this,"_browse_path");
+ browse->connect("pressed", this, "_browse_path");
l = memnew(Label);
l->set_text(TTR("Project Name:"));
- l->set_pos(Point2(5,50));
+ l->set_pos(Point2(5, 50));
vb->add_child(l);
- pn=l;
+ pn = l;
- project_name = memnew( LineEdit );
- mc = memnew( MarginContainer );
+ project_name = memnew(LineEdit);
+ mc = memnew(MarginContainer);
vb->add_child(mc);
mc->add_child(project_name);
project_name->set_text(TTR("New Game Project"));
-
l = memnew(Label);
l->set_text(TTR("That's a BINGO!"));
vb->add_child(l);
- error=l;
- l->add_color_override("font_color",Color(1,0.4,0.3,0.8));
+ error = l;
+ l->add_color_override("font_color", Color(1, 0.4, 0.3, 0.8));
l->set_align(Label::ALIGN_CENTER);
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
project_path->set_text(d->get_current_dir());
memdelete(d);
- fdialog = memnew( FileDialog );
+ fdialog = memnew(FileDialog);
add_child(fdialog);
fdialog->set_access(FileDialog::ACCESS_FILESYSTEM);
- fdialog->set_current_dir( EditorSettings::get_singleton()->get("filesystem/directories/default_project_path") );
- project_name->connect("text_changed", this,"_text_changed");
- project_path->connect("text_changed", this,"_path_text_changed");
- fdialog->connect("dir_selected", this,"_path_selected");
- fdialog->connect("file_selected", this,"_file_selected");
+ fdialog->set_current_dir(EditorSettings::get_singleton()->get("filesystem/directories/default_project_path"));
+ project_name->connect("text_changed", this, "_text_changed");
+ project_path->connect("text_changed", this, "_path_text_changed");
+ fdialog->connect("dir_selected", this, "_path_selected");
+ fdialog->connect("file_selected", this, "_file_selected");
set_hide_on_ok(false);
- mode=MODE_NEW;
+ mode = MODE_NEW;
- dialog_error = memnew( AcceptDialog );
+ dialog_error = memnew(AcceptDialog);
add_child(dialog_error);
}
-
-
};
struct ProjectItem {
@@ -470,20 +448,24 @@ struct ProjectItem {
uint64_t last_modified;
bool favorite;
ProjectItem() {}
- ProjectItem(const String &p_project, const String &p_path, const String &p_conf, uint64_t p_last_modified, bool p_favorite=false) {
- project = p_project; path = p_path; conf = p_conf; last_modified = p_last_modified; favorite=p_favorite;
+ ProjectItem(const String &p_project, const String &p_path, const String &p_conf, uint64_t p_last_modified, bool p_favorite = false) {
+ project = p_project;
+ path = p_path;
+ conf = p_conf;
+ last_modified = p_last_modified;
+ favorite = p_favorite;
}
- _FORCE_INLINE_ bool operator <(const ProjectItem& l) const { return last_modified > l.last_modified; }
- _FORCE_INLINE_ bool operator ==(const ProjectItem& l) const { return project==l.project; }
+ _FORCE_INLINE_ bool operator<(const ProjectItem &l) const { return last_modified > l.last_modified; }
+ _FORCE_INLINE_ bool operator==(const ProjectItem &l) const { return project == l.project; }
};
void ProjectManager::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
get_tree()->set_editor_hint(true);
- } else if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
set_process_unhandled_input(is_visible_in_tree());
}
@@ -493,61 +475,60 @@ void ProjectManager::_panel_draw(Node *p_hb) {
HBoxContainer *hb = p_hb->cast_to<HBoxContainer>();
- hb->draw_line(Point2(0,hb->get_size().y+1),Point2(hb->get_size().x-10,hb->get_size().y+1),get_color("guide_color","Tree"));
+ hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x - 10, hb->get_size().y + 1), get_color("guide_color", "Tree"));
if (selected_list.has(hb->get_meta("name"))) {
- hb->draw_style_box( gui_base->get_stylebox("selected","Tree"),Rect2(Point2(),hb->get_size()-Size2(10,0)));
+ hb->draw_style_box(gui_base->get_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size() - Size2(10, 0)));
}
}
-void ProjectManager::_update_project_buttons()
-{
- for(int i=0;i<scroll_childs->get_child_count();i++) {
+void ProjectManager::_update_project_buttons() {
+ for (int i = 0; i < scroll_childs->get_child_count(); i++) {
CanvasItem *item = scroll_childs->get_child(i)->cast_to<CanvasItem>();
item->update();
}
bool has_runnable_scene = false;
- for (Map<String,String>::Element *E=selected_list.front(); E; E=E->next()) {
+ for (Map<String, String>::Element *E = selected_list.front(); E; E = E->next()) {
const String &selected_main = E->get();
if (selected_main == "") continue;
has_runnable_scene = true;
break;
}
- erase_btn->set_disabled(selected_list.size()<1);
- open_btn->set_disabled(selected_list.size()<1);
+ erase_btn->set_disabled(selected_list.size() < 1);
+ open_btn->set_disabled(selected_list.size() < 1);
run_btn->set_disabled(!has_runnable_scene);
}
-void ProjectManager::_panel_input(const InputEvent& p_ev,Node *p_hb) {
+void ProjectManager::_panel_input(const InputEvent &p_ev, Node *p_hb) {
- if (p_ev.type==InputEvent::MOUSE_BUTTON && p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {
+ if (p_ev.type == InputEvent::MOUSE_BUTTON && p_ev.mouse_button.pressed && p_ev.mouse_button.button_index == BUTTON_LEFT) {
String clicked = p_hb->get_meta("name");
String clicked_main_scene = p_hb->get_meta("main_scene");
- if (p_ev.key.mod.shift && selected_list.size()>0 && last_clicked!="" && clicked != last_clicked) {
+ if (p_ev.key.mod.shift && selected_list.size() > 0 && last_clicked != "" && clicked != last_clicked) {
int clicked_id = -1;
int last_clicked_id = -1;
- for(int i=0;i<scroll_childs->get_child_count();i++) {
+ for (int i = 0; i < scroll_childs->get_child_count(); i++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
if (!hb) continue;
if (hb->get_meta("name") == clicked) clicked_id = i;
if (hb->get_meta("name") == last_clicked) last_clicked_id = i;
}
- if (last_clicked_id!=-1 && clicked_id!=-1) {
- int min = clicked_id < last_clicked_id? clicked_id : last_clicked_id;
- int max = clicked_id > last_clicked_id? clicked_id : last_clicked_id;
- for(int i=0; i<scroll_childs->get_child_count(); ++i) {
+ if (last_clicked_id != -1 && clicked_id != -1) {
+ int min = clicked_id < last_clicked_id ? clicked_id : last_clicked_id;
+ int max = clicked_id > last_clicked_id ? clicked_id : last_clicked_id;
+ for (int i = 0; i < scroll_childs->get_child_count(); ++i) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
if (!hb) continue;
- if (i!=clicked_id && (i<min || i>max) && !p_ev.key.mod.control) {
+ if (i != clicked_id && (i < min || i > max) && !p_ev.key.mod.control) {
selected_list.erase(hb->get_meta("name"));
- } else if (i>=min && i<=max) {
+ } else if (i >= min && i <= max) {
selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
}
}
@@ -560,7 +541,7 @@ void ProjectManager::_panel_input(const InputEvent& p_ev,Node *p_hb) {
} else {
last_clicked = clicked;
- if (p_ev.key.mod.control || selected_list.size()==0) {
+ if (p_ev.key.mod.control || selected_list.size() == 0) {
selected_list.insert(clicked, clicked_main_scene);
} else {
selected_list.clear();
@@ -572,13 +553,12 @@ void ProjectManager::_panel_input(const InputEvent& p_ev,Node *p_hb) {
if (p_ev.mouse_button.doubleclick)
_open_project(); //open if doubleclicked
-
}
}
-void ProjectManager::_unhandled_input(const InputEvent& p_ev) {
+void ProjectManager::_unhandled_input(const InputEvent &p_ev) {
- if (p_ev.type==InputEvent::KEY) {
+ if (p_ev.type == InputEvent::KEY) {
const InputEventKey &k = p_ev.key;
@@ -595,7 +575,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) {
} break;
case KEY_HOME: {
- for (int i=0; i<scroll_childs->get_child_count(); i++) {
+ for (int i = 0; i < scroll_childs->get_child_count(); i++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
if (hb) {
@@ -610,7 +590,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) {
} break;
case KEY_END: {
- for (int i=scroll_childs->get_child_count()-1; i>=0; i--) {
+ for (int i = scroll_childs->get_child_count() - 1; i >= 0; i--) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
if (hb) {
@@ -632,7 +612,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) {
bool found = false;
- for (int i=scroll_childs->get_child_count()-1; i>=0; i--) {
+ for (int i = scroll_childs->get_child_count() - 1; i >= 0; i--) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
if (!hb) continue;
@@ -652,7 +632,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) {
break;
- } else if (current==selected_list.back()->key()) {
+ } else if (current == selected_list.back()->key()) {
found = true;
}
@@ -669,7 +649,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) {
bool found = selected_list.empty();
- for (int i=0; i<scroll_childs->get_child_count(); i++) {
+ for (int i = 0; i < scroll_childs->get_child_count(); i++) {
HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
if (!hb) continue;
@@ -690,7 +670,7 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) {
break;
- } else if (current==selected_list.back()->key()) {
+ } else if (current == selected_list.back()->key()) {
found = true;
}
@@ -698,8 +678,10 @@ void ProjectManager::_unhandled_input(const InputEvent& p_ev) {
} break;
case KEY_F: {
- if (k.mod.command) this->project_filter->search_box->grab_focus();
- else scancode_handled = false;
+ if (k.mod.command)
+ this->project_filter->search_box->grab_focus();
+ else
+ scancode_handled = false;
} break;
default: {
scancode_handled = false;
@@ -716,26 +698,25 @@ void ProjectManager::_favorite_pressed(Node *p_hb) {
String clicked = p_hb->get_meta("name");
bool favorite = !p_hb->get_meta("favorite");
- String proj=clicked.replace(":::",":/");
- proj=proj.replace("::","/");
+ String proj = clicked.replace(":::", ":/");
+ proj = proj.replace("::", "/");
if (favorite) {
- EditorSettings::get_singleton()->set("favorite_projects/"+clicked,proj);
+ EditorSettings::get_singleton()->set("favorite_projects/" + clicked, proj);
} else {
- EditorSettings::get_singleton()->erase("favorite_projects/"+clicked);
+ EditorSettings::get_singleton()->erase("favorite_projects/" + clicked);
}
EditorSettings::get_singleton()->save();
call_deferred("_load_recent_projects");
}
-
void ProjectManager::_load_recent_projects() {
ProjectListFilter::FilterOption filter_option = project_filter->get_filter_option();
String search_term = project_filter->get_search_term();
- while(scroll_childs->get_child_count()>0) {
- memdelete( scroll_childs->get_child(0));
+ while (scroll_childs->get_child_count() > 0) {
+ memdelete(scroll_childs->get_child(0));
}
Map<String, String> selected_list_copy = selected_list;
@@ -743,24 +724,24 @@ void ProjectManager::_load_recent_projects() {
List<PropertyInfo> properties;
EditorSettings::get_singleton()->get_property_list(&properties);
- Color font_color = gui_base->get_color("font_color","Tree");
+ Color font_color = gui_base->get_color("font_color", "Tree");
List<ProjectItem> projects;
List<ProjectItem> favorite_projects;
- for(List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
String _name = E->get().name;
if (!_name.begins_with("projects/") && !_name.begins_with("favorite_projects/"))
continue;
String path = EditorSettings::get_singleton()->get(_name);
- if (filter_option == ProjectListFilter::FILTER_PATH && search_term!="" && path.findn(search_term)==-1)
+ if (filter_option == ProjectListFilter::FILTER_PATH && search_term != "" && path.findn(search_term) == -1)
continue;
- String project = _name.get_slice("/",1);
- String conf=path.plus_file("godot.cfg");
- bool favorite = (_name.begins_with("favorite_projects/"))?true:false;
+ String project = _name.get_slice("/", 1);
+ String conf = path.plus_file("godot.cfg");
+ bool favorite = (_name.begins_with("favorite_projects/")) ? true : false;
uint64_t last_modified = 0;
if (FileAccess::exists(conf)) {
@@ -769,7 +750,7 @@ void ProjectManager::_load_recent_projects() {
String fscache = path.plus_file(".fscache");
if (FileAccess::exists(fscache)) {
uint64_t cache_modified = FileAccess::get_modified_time(fscache);
- if ( cache_modified > last_modified )
+ if (cache_modified > last_modified)
last_modified = cache_modified;
}
@@ -787,19 +768,19 @@ void ProjectManager::_load_recent_projects() {
projects.sort();
favorite_projects.sort();
- for(List<ProjectItem>::Element *E=projects.front();E;) {
+ for (List<ProjectItem>::Element *E = projects.front(); E;) {
List<ProjectItem>::Element *next = E->next();
if (favorite_projects.find(E->get()) != NULL)
projects.erase(E->get());
- E=next;
+ E = next;
}
- for(List<ProjectItem>::Element *E=favorite_projects.back();E;E=E->prev()) {
+ for (List<ProjectItem>::Element *E = favorite_projects.back(); E; E = E->prev()) {
projects.push_front(E->get());
}
- Ref<Texture> favorite_icon = get_icon("Favorites","EditorIcons");
+ Ref<Texture> favorite_icon = get_icon("Favorites", "EditorIcons");
- for(List<ProjectItem>::Element *E=projects.front();E;E=E->next()) {
+ for (List<ProjectItem>::Element *E = projects.front(); E; E = E->next()) {
ProjectItem &item = E->get();
String project = item.project;
@@ -807,89 +788,88 @@ void ProjectManager::_load_recent_projects() {
String conf = item.conf;
bool is_favorite = item.favorite;
- Ref<ConfigFile> cf = memnew( ConfigFile );
+ Ref<ConfigFile> cf = memnew(ConfigFile);
Error err = cf->load(conf);
- ERR_CONTINUE(err!=OK);
+ ERR_CONTINUE(err != OK);
+ String project_name = TTR("Unnamed Project");
- String project_name=TTR("Unnamed Project");
-
- if (cf->has_section_key("application","name")) {
- project_name = static_cast<String>(cf->get_value("application","name")).xml_unescape();
+ if (cf->has_section_key("application", "name")) {
+ project_name = static_cast<String>(cf->get_value("application", "name")).xml_unescape();
}
- if (filter_option==ProjectListFilter::FILTER_NAME && search_term!="" && project_name.findn(search_term)==-1)
+ if (filter_option == ProjectListFilter::FILTER_NAME && search_term != "" && project_name.findn(search_term) == -1)
continue;
Ref<Texture> icon;
- if (cf->has_section_key("application","icon")) {
- String appicon = cf->get_value("application","icon");
- if (appicon!="") {
+ if (cf->has_section_key("application", "icon")) {
+ String appicon = cf->get_value("application", "icon");
+ if (appicon != "") {
Image img;
- Error err = img.load(appicon.replace_first("res://",path+"/"));
- if (err==OK) {
+ Error err = img.load(appicon.replace_first("res://", path + "/"));
+ if (err == OK) {
- img.resize(64,64);
- Ref<ImageTexture> it = memnew( ImageTexture );
+ img.resize(64, 64);
+ Ref<ImageTexture> it = memnew(ImageTexture);
it->create_from_image(img);
- icon=it;
+ icon = it;
}
}
}
if (icon.is_null()) {
- icon=get_icon("DefaultProjectIcon","EditorIcons");
+ icon = get_icon("DefaultProjectIcon", "EditorIcons");
}
String main_scene;
- if (cf->has_section_key("application","main_scene")) {
- main_scene = cf->get_value("application","main_scene");
+ if (cf->has_section_key("application", "main_scene")) {
+ main_scene = cf->get_value("application", "main_scene");
}
selected_list_copy.erase(project);
- HBoxContainer *hb = memnew( HBoxContainer );
- hb->set_meta("name",project);
- hb->set_meta("main_scene",main_scene);
- hb->set_meta("favorite",is_favorite);
- hb->connect("draw",this,"_panel_draw",varray(hb));
- hb->connect("gui_input",this,"_panel_input",varray(hb));
- hb->add_constant_override("separation",10*EDSCALE);
+ HBoxContainer *hb = memnew(HBoxContainer);
+ hb->set_meta("name", project);
+ hb->set_meta("main_scene", main_scene);
+ hb->set_meta("favorite", is_favorite);
+ hb->connect("draw", this, "_panel_draw", varray(hb));
+ hb->connect("gui_input", this, "_panel_input", varray(hb));
+ hb->add_constant_override("separation", 10 * EDSCALE);
- VBoxContainer *favorite_box = memnew( VBoxContainer );
- TextureButton *favorite = memnew( TextureButton );
+ VBoxContainer *favorite_box = memnew(VBoxContainer);
+ TextureButton *favorite = memnew(TextureButton);
favorite->set_normal_texture(favorite_icon);
if (!is_favorite)
- favorite->set_modulate(Color(1,1,1,0.2));
+ favorite->set_modulate(Color(1, 1, 1, 0.2));
favorite->set_v_size_flags(SIZE_EXPAND);
- favorite->connect("pressed",this,"_favorite_pressed",varray(hb));
+ favorite->connect("pressed", this, "_favorite_pressed", varray(hb));
favorite_box->add_child(favorite);
hb->add_child(favorite_box);
- TextureRect *tf = memnew( TextureRect );
+ TextureRect *tf = memnew(TextureRect);
tf->set_texture(icon);
hb->add_child(tf);
VBoxContainer *vb = memnew(VBoxContainer);
vb->set_name("project");
hb->add_child(vb);
- Control *ec = memnew( Control );
- ec->set_custom_minimum_size(Size2(0,1));
+ Control *ec = memnew(Control);
+ ec->set_custom_minimum_size(Size2(0, 1));
vb->add_child(ec);
- Label *title = memnew( Label(project_name) );
- title->add_font_override("font", gui_base->get_font("large","Fonts"));
- title->add_color_override("font_color",font_color);
+ Label *title = memnew(Label(project_name));
+ title->add_font_override("font", gui_base->get_font("large", "Fonts"));
+ title->add_color_override("font_color", font_color);
vb->add_child(title);
- Label *fpath = memnew( Label(path) );
+ Label *fpath = memnew(Label(path));
fpath->set_name("path");
vb->add_child(fpath);
- fpath->set_modulate(Color(1,1,1,0.5));
- fpath->add_color_override("font_color",font_color);
+ fpath->set_modulate(Color(1, 1, 1, 0.5));
+ fpath->add_color_override("font_color", font_color);
scroll_childs->add_child(hb);
}
- for (Map<String,String>::Element *E = selected_list_copy.front();E;E = E->next()) {
+ for (Map<String, String>::Element *E = selected_list_copy.front(); E; E = E->next()) {
String key = E->key();
selected_list.erase(key);
}
@@ -903,13 +883,13 @@ void ProjectManager::_load_recent_projects() {
tabs->set_current_tab(0);
}
-void ProjectManager::_on_project_created(const String& dir) {
- bool has_already=false;
- for (int i=0;i<scroll_childs->get_child_count();i++) {
- HBoxContainer *hb=scroll_childs->get_child(i)->cast_to<HBoxContainer>();
- Label *fpath=hb->get_node(NodePath("project/path"))->cast_to<Label>();
- if (fpath->get_text()==dir) {
- has_already=true;
+void ProjectManager::_on_project_created(const String &dir) {
+ bool has_already = false;
+ for (int i = 0; i < scroll_childs->get_child_count(); i++) {
+ HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
+ Label *fpath = hb->get_node(NodePath("project/path"))->cast_to<Label>();
+ if (fpath->get_text() == dir) {
+ has_already = true;
break;
}
}
@@ -921,20 +901,20 @@ void ProjectManager::_on_project_created(const String& dir) {
}
}
-void ProjectManager::_update_scroll_pos(const String& dir) {
- for (int i=0;i<scroll_childs->get_child_count();i++) {
- HBoxContainer *hb=scroll_childs->get_child(i)->cast_to<HBoxContainer>();
- Label *fpath=hb->get_node(NodePath("project/path"))->cast_to<Label>();
- if (fpath->get_text()==dir) {
- last_clicked=hb->get_meta("name");
+void ProjectManager::_update_scroll_pos(const String &dir) {
+ for (int i = 0; i < scroll_childs->get_child_count(); i++) {
+ HBoxContainer *hb = scroll_childs->get_child(i)->cast_to<HBoxContainer>();
+ Label *fpath = hb->get_node(NodePath("project/path"))->cast_to<Label>();
+ if (fpath->get_text() == dir) {
+ last_clicked = hb->get_meta("name");
selected_list.clear();
selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
_update_project_buttons();
- int last_y_visible=scroll->get_v_scroll()+scroll->get_size().y;
- int offset_diff=(hb->get_pos().y + hb->get_size().y)-last_y_visible;
+ int last_y_visible = scroll->get_v_scroll() + scroll->get_size().y;
+ int offset_diff = (hb->get_pos().y + hb->get_size().y) - last_y_visible;
- if (offset_diff>0)
- scroll->set_v_scroll(scroll->get_v_scroll()+offset_diff);
+ if (offset_diff > 0)
+ scroll->set_v_scroll(scroll->get_v_scroll() + offset_diff);
break;
}
}
@@ -942,10 +922,10 @@ void ProjectManager::_update_scroll_pos(const String& dir) {
void ProjectManager::_open_project_confirm() {
- for (Map<String,String>::Element *E=selected_list.front(); E; E=E->next()) {
+ for (Map<String, String>::Element *E = selected_list.front(); E; E = E->next()) {
const String &selected = E->key();
- String path = EditorSettings::get_singleton()->get("projects/"+selected);
- print_line("OPENING: "+path+" ("+selected+")");
+ String path = EditorSettings::get_singleton()->get("projects/" + selected);
+ print_line("OPENING: " + path + " (" + selected + ")");
List<String> args;
@@ -956,8 +936,8 @@ void ProjectManager::_open_project_confirm() {
String exec = OS::get_singleton()->get_executable_path();
- OS::ProcessID pid=0;
- Error err = OS::get_singleton()->execute(exec,args,false,&pid);
+ OS::ProcessID pid = 0;
+ Error err = OS::get_singleton()->execute(exec, args, false, &pid);
ERR_FAIL_COND(err);
}
@@ -966,11 +946,11 @@ void ProjectManager::_open_project_confirm() {
void ProjectManager::_open_project() {
- if (selected_list.size()<1) {
+ if (selected_list.size() < 1) {
return;
}
- if (selected_list.size()>1) {
+ if (selected_list.size() > 1) {
multi_open_ask->set_text(TTR("Are you sure to open more than one project?"));
multi_open_ask->popup_centered_minsize();
} else {
@@ -980,14 +960,14 @@ void ProjectManager::_open_project() {
void ProjectManager::_run_project_confirm() {
- for (Map<String,String>::Element *E=selected_list.front(); E; E=E->next()) {
+ for (Map<String, String>::Element *E = selected_list.front(); E; E = E->next()) {
const String &selected_main = E->get();
if (selected_main == "") continue;
const String &selected = E->key();
- String path = EditorSettings::get_singleton()->get("projects/"+selected);
- print_line("OPENING: "+path+" ("+selected+")");
+ String path = EditorSettings::get_singleton()->get("projects/" + selected);
+ print_line("OPENING: " + path + " (" + selected + ")");
List<String> args;
@@ -996,8 +976,8 @@ void ProjectManager::_run_project_confirm() {
String exec = OS::get_singleton()->get_executable_path();
- OS::ProcessID pid=0;
- Error err = OS::get_singleton()->execute(exec,args,false,&pid);
+ OS::ProcessID pid = 0;
+ Error err = OS::get_singleton()->execute(exec, args, false, &pid);
ERR_FAIL_COND(err);
}
//get_scene()->quit(); do not quit
@@ -1005,12 +985,11 @@ void ProjectManager::_run_project_confirm() {
void ProjectManager::_run_project() {
-
- if (selected_list.size()<1) {
+ if (selected_list.size() < 1) {
return;
}
- if (selected_list.size()>1) {
+ if (selected_list.size() > 1) {
multi_run_ask->set_text(TTR("Are you sure to run more than one project?"));
multi_run_ask->popup_centered_minsize();
} else {
@@ -1018,111 +997,97 @@ void ProjectManager::_run_project() {
}
}
-void ProjectManager::_scan_dir(DirAccess *da,float pos, float total,List<String> *r_projects) {
-
+void ProjectManager::_scan_dir(DirAccess *da, float pos, float total, List<String> *r_projects) {
List<String> subdirs;
da->list_dir_begin();
String n = da->get_next();
- while(n!=String()) {
+ while (n != String()) {
if (da->current_is_dir() && !n.begins_with(".")) {
subdirs.push_front(n);
- } else if (n=="godot.cfg") {
+ } else if (n == "godot.cfg") {
r_projects->push_back(da->get_current_dir());
}
- n=da->get_next();
+ n = da->get_next();
}
da->list_dir_end();
- int m=0;
- for(List<String>::Element *E=subdirs.front();E;E=E->next()) {
+ int m = 0;
+ for (List<String>::Element *E = subdirs.front(); E; E = E->next()) {
da->change_dir(E->get());
- float slice=total/subdirs.size();
- _scan_dir(da,pos+slice*m,slice,r_projects);
+ float slice = total / subdirs.size();
+ _scan_dir(da, pos + slice * m, slice, r_projects);
da->change_dir("..");
m++;
}
-
-
}
+void ProjectManager::_scan_begin(const String &p_base) {
-void ProjectManager::_scan_begin(const String& p_base) {
-
- print_line("SCAN PROJECTS AT: "+p_base);
+ print_line("SCAN PROJECTS AT: " + p_base);
List<String> projects;
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->change_dir(p_base);
- _scan_dir(da,0,1,&projects);
+ _scan_dir(da, 0, 1, &projects);
memdelete(da);
- print_line("found: "+itos(projects.size())+" projects.");
-
- for(List<String>::Element *E=projects.front();E;E=E->next()) {
- String proj=E->get().replace("/","::");
- EditorSettings::get_singleton()->set("projects/"+proj,E->get());
+ print_line("found: " + itos(projects.size()) + " projects.");
+ for (List<String>::Element *E = projects.front(); E; E = E->next()) {
+ String proj = E->get().replace("/", "::");
+ EditorSettings::get_singleton()->set("projects/" + proj, E->get());
}
EditorSettings::get_singleton()->save();
_load_recent_projects();
-
}
void ProjectManager::_scan_projects() {
scan_dir->popup_centered_ratio();
-
}
-
-void ProjectManager::_new_project() {
+void ProjectManager::_new_project() {
npdialog->set_mode(NewProjectDialog::MODE_NEW);
npdialog->show_dialog();
}
-
-void ProjectManager::_import_project() {
+void ProjectManager::_import_project() {
npdialog->set_mode(NewProjectDialog::MODE_IMPORT);
npdialog->show_dialog();
}
-void ProjectManager::_erase_project_confirm() {
+void ProjectManager::_erase_project_confirm() {
- if (selected_list.size()==0) {
+ if (selected_list.size() == 0) {
return;
}
- for (Map<String,String>::Element *E=selected_list.front(); E; E=E->next()) {
- EditorSettings::get_singleton()->erase("projects/"+E->key());
- EditorSettings::get_singleton()->erase("favorite_projects/"+E->key());
+ for (Map<String, String>::Element *E = selected_list.front(); E; E = E->next()) {
+ EditorSettings::get_singleton()->erase("projects/" + E->key());
+ EditorSettings::get_singleton()->erase("favorite_projects/" + E->key());
}
EditorSettings::get_singleton()->save();
selected_list.clear();
last_clicked = "";
_load_recent_projects();
-
}
-void ProjectManager::_erase_project() {
+void ProjectManager::_erase_project() {
- if (selected_list.size()==0)
+ if (selected_list.size() == 0)
return;
-
erase_ask->set_text(TTR("Remove project from the list? (Folder contents will not be modified)"));
erase_ask->popup_centered_minsize();
-
}
-
-void ProjectManager::_exit_dialog() {
+void ProjectManager::_exit_dialog() {
get_tree()->quit();
}
-
-void ProjectManager::_install_project(const String& p_zip_path,const String& p_title) {
+void ProjectManager::_install_project(const String &p_zip_path, const String &p_title) {
npdialog->set_mode(NewProjectDialog::MODE_INSTALL);
npdialog->set_zip_path(p_zip_path);
@@ -1138,19 +1103,19 @@ void ProjectManager::_files_dropped(PoolStringArray p_files, int p_screen) {
folders_set.insert(da->dir_exists(file) ? file : file.get_base_dir());
}
memdelete(da);
- if (folders_set.size()>0) {
+ if (folders_set.size() > 0) {
PoolStringArray folders;
- for (Set<String>::Element *E=folders_set.front();E;E=E->next()) {
+ for (Set<String>::Element *E = folders_set.front(); E; E = E->next()) {
folders.append(E->get());
}
bool confirm = true;
- if (folders.size()==1) {
+ if (folders.size() == 1) {
DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- if (dir->change_dir(folders[0])==OK) {
+ if (dir->change_dir(folders[0]) == OK) {
dir->list_dir_begin();
String file = dir->get_next();
- while(confirm && file!=String()) {
+ while (confirm && file != String()) {
if (!dir->current_is_dir() && file.ends_with("godot.cfg")) {
confirm = false;
}
@@ -1171,8 +1136,7 @@ void ProjectManager::_files_dropped(PoolStringArray p_files, int p_screen) {
}
}
-void ProjectManager::_scan_multiple_folders(PoolStringArray p_files)
-{
+void ProjectManager::_scan_multiple_folders(PoolStringArray p_files) {
for (int i = 0; i < p_files.size(); i++) {
_scan_begin(p_files.get(i));
}
@@ -1180,29 +1144,27 @@ void ProjectManager::_scan_multiple_folders(PoolStringArray p_files)
void ProjectManager::_bind_methods() {
- ClassDB::bind_method("_open_project",&ProjectManager::_open_project);
- ClassDB::bind_method("_open_project_confirm",&ProjectManager::_open_project_confirm);
- ClassDB::bind_method("_run_project",&ProjectManager::_run_project);
- ClassDB::bind_method("_run_project_confirm",&ProjectManager::_run_project_confirm);
- ClassDB::bind_method("_scan_projects",&ProjectManager::_scan_projects);
- ClassDB::bind_method("_scan_begin",&ProjectManager::_scan_begin);
- ClassDB::bind_method("_import_project",&ProjectManager::_import_project);
- ClassDB::bind_method("_new_project",&ProjectManager::_new_project);
- ClassDB::bind_method("_erase_project",&ProjectManager::_erase_project);
- ClassDB::bind_method("_erase_project_confirm",&ProjectManager::_erase_project_confirm);
- ClassDB::bind_method("_exit_dialog",&ProjectManager::_exit_dialog);
- ClassDB::bind_method("_load_recent_projects",&ProjectManager::_load_recent_projects);
- ClassDB::bind_method("_on_project_created",&ProjectManager::_on_project_created);
- ClassDB::bind_method("_update_scroll_pos",&ProjectManager::_update_scroll_pos);
- ClassDB::bind_method("_panel_draw",&ProjectManager::_panel_draw);
- ClassDB::bind_method("_panel_input",&ProjectManager::_panel_input);
- ClassDB::bind_method("_unhandled_input",&ProjectManager::_unhandled_input);
- ClassDB::bind_method("_favorite_pressed",&ProjectManager::_favorite_pressed);
- ClassDB::bind_method("_install_project",&ProjectManager::_install_project);
- ClassDB::bind_method("_files_dropped",&ProjectManager::_files_dropped);
- ClassDB::bind_method(D_METHOD("_scan_multiple_folders", "files"),&ProjectManager::_scan_multiple_folders);
-
-
+ ClassDB::bind_method("_open_project", &ProjectManager::_open_project);
+ ClassDB::bind_method("_open_project_confirm", &ProjectManager::_open_project_confirm);
+ ClassDB::bind_method("_run_project", &ProjectManager::_run_project);
+ ClassDB::bind_method("_run_project_confirm", &ProjectManager::_run_project_confirm);
+ ClassDB::bind_method("_scan_projects", &ProjectManager::_scan_projects);
+ ClassDB::bind_method("_scan_begin", &ProjectManager::_scan_begin);
+ ClassDB::bind_method("_import_project", &ProjectManager::_import_project);
+ ClassDB::bind_method("_new_project", &ProjectManager::_new_project);
+ ClassDB::bind_method("_erase_project", &ProjectManager::_erase_project);
+ ClassDB::bind_method("_erase_project_confirm", &ProjectManager::_erase_project_confirm);
+ ClassDB::bind_method("_exit_dialog", &ProjectManager::_exit_dialog);
+ ClassDB::bind_method("_load_recent_projects", &ProjectManager::_load_recent_projects);
+ ClassDB::bind_method("_on_project_created", &ProjectManager::_on_project_created);
+ ClassDB::bind_method("_update_scroll_pos", &ProjectManager::_update_scroll_pos);
+ ClassDB::bind_method("_panel_draw", &ProjectManager::_panel_draw);
+ ClassDB::bind_method("_panel_input", &ProjectManager::_panel_input);
+ ClassDB::bind_method("_unhandled_input", &ProjectManager::_unhandled_input);
+ ClassDB::bind_method("_favorite_pressed", &ProjectManager::_favorite_pressed);
+ ClassDB::bind_method("_install_project", &ProjectManager::_install_project);
+ ClassDB::bind_method("_files_dropped", &ProjectManager::_files_dropped);
+ ClassDB::bind_method(D_METHOD("_scan_multiple_folders", "files"), &ProjectManager::_scan_multiple_folders);
}
ProjectManager::ProjectManager() {
@@ -1211,20 +1173,19 @@ ProjectManager::ProjectManager() {
if (!EditorSettings::get_singleton())
EditorSettings::create();
-
EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came
{
int dpi_mode = EditorSettings::get_singleton()->get("interface/hidpi_mode");
- if (dpi_mode==0) {
- editor_set_scale( OS::get_singleton()->get_screen_dpi(0) > 150 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x>2000 ? 2.0 : 1.0 );
- } else if (dpi_mode==1) {
+ if (dpi_mode == 0) {
+ editor_set_scale(OS::get_singleton()->get_screen_dpi(0) > 150 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x > 2000 ? 2.0 : 1.0);
+ } else if (dpi_mode == 1) {
editor_set_scale(0.75);
- } else if (dpi_mode==2) {
+ } else if (dpi_mode == 2) {
editor_set_scale(1.0);
- } else if (dpi_mode==3) {
+ } else if (dpi_mode == 3) {
editor_set_scale(1.5);
- } else if (dpi_mode==4) {
+ } else if (dpi_mode == 4) {
editor_set_scale(2.0);
}
}
@@ -1234,37 +1195,37 @@ ProjectManager::ProjectManager() {
set_area_as_parent_rect();
set_theme(create_editor_theme());
- gui_base = memnew( Control );
+ gui_base = memnew(Control);
add_child(gui_base);
gui_base->set_area_as_parent_rect();
gui_base->set_theme(create_custom_theme());
- Panel *panel = memnew( Panel );
+ Panel *panel = memnew(Panel);
gui_base->add_child(panel);
panel->set_area_as_parent_rect();
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
panel->add_child(vb);
- vb->set_area_as_parent_rect(20*EDSCALE);
- vb->set_margin(MARGIN_TOP,4*EDSCALE);
- vb->set_margin(MARGIN_BOTTOM,4*EDSCALE);
- vb->add_constant_override("separation",15*EDSCALE);
+ vb->set_area_as_parent_rect(20 * EDSCALE);
+ vb->set_margin(MARGIN_TOP, 4 * EDSCALE);
+ vb->set_margin(MARGIN_BOTTOM, 4 * EDSCALE);
+ vb->add_constant_override("separation", 15 * EDSCALE);
String cp;
cp.push_back(0xA9);
cp.push_back(0);
- OS::get_singleton()->set_window_title(_MKSTR(VERSION_NAME)+String(" - ")+TTR("Project Manager")+" - "+cp+" 2008-2017 Juan Linietsky, Ariel Manzur.");
+ OS::get_singleton()->set_window_title(_MKSTR(VERSION_NAME) + String(" - ") + TTR("Project Manager") + " - " + cp + " 2008-2017 Juan Linietsky, Ariel Manzur.");
- HBoxContainer *top_hb = memnew( HBoxContainer);
+ HBoxContainer *top_hb = memnew(HBoxContainer);
vb->add_child(top_hb);
- CenterContainer *ccl = memnew( CenterContainer );
- Label *l = memnew( Label );
- l->set_text(_MKSTR(VERSION_NAME)+String(" - ")+TTR("Project Manager"));
- l->add_font_override("font", gui_base->get_font("doc","EditorFonts"));
+ CenterContainer *ccl = memnew(CenterContainer);
+ Label *l = memnew(Label);
+ l->set_text(_MKSTR(VERSION_NAME) + String(" - ") + TTR("Project Manager"));
+ l->add_font_override("font", gui_base->get_font("doc", "EditorFonts"));
ccl->add_child(l);
top_hb->add_child(ccl);
top_hb->add_spacer();
- l = memnew( Label );
+ l = memnew(Label);
l->set_text("v" VERSION_MKSTRING);
//l->add_font_override("font",get_font("bold","Fonts"));
l->set_align(Label::ALIGN_CENTER);
@@ -1272,11 +1233,11 @@ ProjectManager::ProjectManager() {
//vb->add_child(memnew(HSeparator));
//vb->add_margin_child("\n",memnew(Control));
- tabs = memnew( TabContainer );
+ tabs = memnew(TabContainer);
vb->add_child(tabs);
tabs->set_v_size_flags(SIZE_EXPAND_FILL);
- HBoxContainer *tree_hb = memnew( HBoxContainer);
+ HBoxContainer *tree_hb = memnew(HBoxContainer);
projects_hb = tree_hb;
projects_hb->set_name(TTR("Project List"));
@@ -1292,131 +1253,126 @@ ProjectManager::ProjectManager() {
project_filter = memnew(ProjectListFilter);
search_box->add_child(project_filter);
project_filter->connect("filter_changed", this, "_load_recent_projects");
- project_filter->set_custom_minimum_size(Size2(250,10));
+ project_filter->set_custom_minimum_size(Size2(250, 10));
search_tree_vb->add_child(search_box);
- PanelContainer *pc = memnew( PanelContainer);
- pc->add_style_override("panel", gui_base->get_stylebox("bg","Tree"));
+ PanelContainer *pc = memnew(PanelContainer);
+ pc->add_style_override("panel", gui_base->get_stylebox("bg", "Tree"));
search_tree_vb->add_child(pc);
pc->set_v_size_flags(SIZE_EXPAND_FILL);
- scroll = memnew( ScrollContainer );
+ scroll = memnew(ScrollContainer);
pc->add_child(scroll);
scroll->set_enable_h_scroll(false);
- VBoxContainer *tree_vb = memnew( VBoxContainer);
+ VBoxContainer *tree_vb = memnew(VBoxContainer);
tree_hb->add_child(tree_vb);
- scroll_childs = memnew( VBoxContainer );
+ scroll_childs = memnew(VBoxContainer);
scroll_childs->set_h_size_flags(SIZE_EXPAND_FILL);
scroll->add_child(scroll_childs);
//HBoxContainer *hb = memnew( HBoxContainer );
//vb->add_child(hb);
- Button *open = memnew( Button );
+ Button *open = memnew(Button);
open->set_text(TTR("Edit"));
tree_vb->add_child(open);
- open->connect("pressed", this,"_open_project");
- open_btn=open;
+ open->connect("pressed", this, "_open_project");
+ open_btn = open;
- Button *run = memnew( Button );
+ Button *run = memnew(Button);
run->set_text(TTR("Run"));
tree_vb->add_child(run);
- run->connect("pressed", this,"_run_project");
- run_btn=run;
+ run->connect("pressed", this, "_run_project");
+ run_btn = run;
- tree_vb->add_child(memnew( HSeparator ));
+ tree_vb->add_child(memnew(HSeparator));
- Button *scan = memnew( Button );
+ Button *scan = memnew(Button);
scan->set_text(TTR("Scan"));
tree_vb->add_child(scan);
- scan->connect("pressed", this,"_scan_projects");
+ scan->connect("pressed", this, "_scan_projects");
- tree_vb->add_child(memnew( HSeparator ));
+ tree_vb->add_child(memnew(HSeparator));
- scan_dir = memnew( FileDialog );
+ scan_dir = memnew(FileDialog);
scan_dir->set_access(FileDialog::ACCESS_FILESYSTEM);
scan_dir->set_mode(FileDialog::MODE_OPEN_DIR);
scan_dir->set_title(TTR("Select a Folder to Scan")); // must be after mode or it's overridden
- scan_dir->set_current_dir( EditorSettings::get_singleton()->get("filesystem/directories/default_project_path") );
+ scan_dir->set_current_dir(EditorSettings::get_singleton()->get("filesystem/directories/default_project_path"));
gui_base->add_child(scan_dir);
- scan_dir->connect("dir_selected",this,"_scan_begin");
-
+ scan_dir->connect("dir_selected", this, "_scan_begin");
- Button* create = memnew( Button );
+ Button *create = memnew(Button);
create->set_text(TTR("New Project"));
tree_vb->add_child(create);
- create->connect("pressed", this,"_new_project");
+ create->connect("pressed", this, "_new_project");
- Button* import = memnew( Button );
+ Button *import = memnew(Button);
import->set_text(TTR("Import"));
tree_vb->add_child(import);
- import->connect("pressed", this,"_import_project");
+ import->connect("pressed", this, "_import_project");
-
- Button* erase = memnew( Button );
+ Button *erase = memnew(Button);
erase->set_text(TTR("Remove"));
tree_vb->add_child(erase);
- erase->connect("pressed", this,"_erase_project");
- erase_btn=erase;
-
+ erase->connect("pressed", this, "_erase_project");
+ erase_btn = erase;
tree_vb->add_spacer();
-
if (StreamPeerSSL::is_available()) {
- asset_library = memnew( EditorAssetLibrary(true) );
+ asset_library = memnew(EditorAssetLibrary(true));
asset_library->set_name("Templates");
tabs->add_child(asset_library);
- asset_library->connect("install_asset",this,"_install_project");
+ asset_library->connect("install_asset", this, "_install_project");
} else {
WARN_PRINT("Asset Library not available, as it requires SSL to work.");
}
-
- CenterContainer *cc = memnew( CenterContainer );
- Button * cancel = memnew( Button );
+ CenterContainer *cc = memnew(CenterContainer);
+ Button *cancel = memnew(Button);
cancel->set_text(TTR("Exit"));
- cancel->set_custom_minimum_size(Size2(100,1)*EDSCALE);
+ cancel->set_custom_minimum_size(Size2(100, 1) * EDSCALE);
cc->add_child(cancel);
- cancel->connect("pressed", this,"_exit_dialog");
+ cancel->connect("pressed", this, "_exit_dialog");
vb->add_child(cc);
//
- erase_ask = memnew( ConfirmationDialog );
+ erase_ask = memnew(ConfirmationDialog);
erase_ask->get_ok()->set_text(TTR("Remove"));
- erase_ask->get_ok()->connect("pressed", this,"_erase_project_confirm");
+ erase_ask->get_ok()->connect("pressed", this, "_erase_project_confirm");
gui_base->add_child(erase_ask);
- multi_open_ask = memnew( ConfirmationDialog );
+ multi_open_ask = memnew(ConfirmationDialog);
multi_open_ask->get_ok()->set_text(TTR("Edit"));
multi_open_ask->get_ok()->connect("pressed", this, "_open_project_confirm");
gui_base->add_child(multi_open_ask);
- multi_run_ask = memnew( ConfirmationDialog );
+ multi_run_ask = memnew(ConfirmationDialog);
multi_run_ask->get_ok()->set_text(TTR("Run"));
multi_run_ask->get_ok()->connect("pressed", this, "_run_project_confirm");
gui_base->add_child(multi_run_ask);
- multi_scan_ask = memnew( ConfirmationDialog );
+ multi_scan_ask = memnew(ConfirmationDialog);
multi_scan_ask->get_ok()->set_text(TTR("Scan"));
gui_base->add_child(multi_scan_ask);
OS::get_singleton()->set_low_processor_usage_mode(true);
- npdialog = memnew( NewProjectDialog );
+ npdialog = memnew(NewProjectDialog);
gui_base->add_child(npdialog);
- npdialog->connect("project_created", this,"_on_project_created");
+ npdialog->connect("project_created", this, "_on_project_created");
_load_recent_projects();
- if ( EditorSettings::get_singleton()->get("filesystem/directories/autoscan_project_path") ) {
- _scan_begin( EditorSettings::get_singleton()->get("filesystem/directories/autoscan_project_path") );
+ if (EditorSettings::get_singleton()->get("filesystem/directories/autoscan_project_path")) {
+ _scan_begin(EditorSettings::get_singleton()->get("filesystem/directories/autoscan_project_path"));
}
//get_ok()->set_text("Open");
@@ -1427,7 +1383,6 @@ ProjectManager::ProjectManager() {
SceneTree::get_singleton()->connect("files_dropped", this, "_files_dropped");
}
-
ProjectManager::~ProjectManager() {
if (EditorSettings::get_singleton())
@@ -1445,11 +1400,11 @@ void ProjectListFilter::_command(int p_command) {
switch (p_command) {
case CMD_CLEAR_FILTER: {
- if (search_box->get_text()!="") {
+ if (search_box->get_text() != "") {
search_box->clear();
emit_signal("filter_changed");
}
- }break;
+ } break;
}
}
@@ -1467,27 +1422,27 @@ ProjectListFilter::FilterOption ProjectListFilter::get_filter_option() {
void ProjectListFilter::_filter_option_selected(int p_idx) {
FilterOption selected = (FilterOption)(filter_option->get_selected());
- if (_current_filter != selected ) {
+ if (_current_filter != selected) {
_current_filter = selected;
emit_signal("filter_changed");
}
}
void ProjectListFilter::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- clear_search_button->set_icon(get_icon("CloseHover","EditorIcons"));
+ clear_search_button->set_icon(get_icon("CloseHover", "EditorIcons"));
} break;
}
}
void ProjectListFilter::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_command"),&ProjectListFilter::_command);
+ ClassDB::bind_method(D_METHOD("_command"), &ProjectListFilter::_command);
ClassDB::bind_method(D_METHOD("_search_text_changed"), &ProjectListFilter::_search_text_changed);
ClassDB::bind_method(D_METHOD("_filter_option_selected"), &ProjectListFilter::_filter_option_selected);
- ADD_SIGNAL( MethodInfo("filter_changed") );
+ ADD_SIGNAL(MethodInfo("filter_changed"));
}
ProjectListFilter::ProjectListFilter() {
@@ -1497,20 +1452,19 @@ ProjectListFilter::ProjectListFilter() {
_current_filter = FILTER_NAME;
filter_option = memnew(OptionButton);
- filter_option->set_custom_minimum_size(Size2(80,10));
+ filter_option->set_custom_minimum_size(Size2(80, 10));
filter_option->set_clip_text(true);
filter_option->connect("item_selected", this, "_filter_option_selected");
add_child(filter_option);
_setup_filters();
- search_box = memnew( LineEdit );
- search_box->connect("text_changed",this,"_search_text_changed");
+ search_box = memnew(LineEdit);
+ search_box->connect("text_changed", this, "_search_text_changed");
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
add_child(search_box);
- clear_search_button = memnew( ToolButton );
- clear_search_button->connect("pressed",this,"_command",make_binds(CMD_CLEAR_FILTER));
+ clear_search_button = memnew(ToolButton);
+ clear_search_button->connect("pressed", this, "_command", make_binds(CMD_CLEAR_FILTER));
add_child(clear_search_button);
-
}
diff --git a/editor/project_manager.h b/editor/project_manager.h
index cb6c0b7f26..918b76cb01 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -29,18 +29,18 @@
#ifndef PROJECT_MANAGER_H
#define PROJECT_MANAGER_H
+#include "editor/asset_library_editor_plugin.h"
#include "scene/gui/dialogs.h"
-#include "scene/gui/tree.h"
-#include "scene/gui/scroll_container.h"
#include "scene/gui/file_dialog.h"
+#include "scene/gui/scroll_container.h"
#include "scene/gui/tool_button.h"
-#include "editor/asset_library_editor_plugin.h"
+#include "scene/gui/tree.h"
class NewProjectDialog;
class ProjectListFilter;
class ProjectManager : public Control {
- GDCLASS( ProjectManager, Control );
+ GDCLASS(ProjectManager, Control);
Button *erase_btn;
Button *open_btn;
@@ -69,8 +69,6 @@ class ProjectManager : public Control {
Control *gui_base;
-
-
void _scan_projects();
void _run_project();
void _run_project_confirm();
@@ -82,26 +80,26 @@ class ProjectManager : public Control {
void _erase_project_confirm();
void _update_project_buttons();
void _exit_dialog();
- void _scan_begin(const String& p_base);
+ void _scan_begin(const String &p_base);
void _load_recent_projects();
- void _on_project_created(const String& dir);
- void _update_scroll_pos(const String& dir);
- void _scan_dir(DirAccess *da,float pos, float total,List<String> *r_projects);
+ void _on_project_created(const String &dir);
+ void _update_scroll_pos(const String &dir);
+ void _scan_dir(DirAccess *da, float pos, float total, List<String> *r_projects);
- void _install_project(const String& p_zip_path,const String& p_title);
+ void _install_project(const String &p_zip_path, const String &p_title);
void _panel_draw(Node *p_hb);
- void _panel_input(const InputEvent& p_ev,Node *p_hb);
- void _unhandled_input(const InputEvent& p_ev);
+ void _panel_input(const InputEvent &p_ev, Node *p_hb);
+ void _unhandled_input(const InputEvent &p_ev);
void _favorite_pressed(Node *p_hb);
void _files_dropped(PoolStringArray p_files, int p_screen);
void _scan_multiple_folders(PoolStringArray p_files);
protected:
-
void _notification(int p_what);
static void _bind_methods();
+
public:
ProjectManager();
~ProjectManager();
@@ -109,10 +107,9 @@ public:
class ProjectListFilter : public HBoxContainer {
- GDCLASS( ProjectListFilter, HBoxContainer );
+ GDCLASS(ProjectListFilter, HBoxContainer);
private:
-
friend class ProjectManager;
enum Command {
@@ -130,7 +127,7 @@ private:
FilterOption _current_filter;
void _command(int p_command);
- void _search_text_changed(const String& p_newtext);
+ void _search_text_changed(const String &p_newtext);
void _setup_filters();
void _filter_option_selected(int p_idx);
@@ -139,7 +136,6 @@ protected:
static void _bind_methods();
public:
-
String get_search_term();
FilterOption get_filter_option();
ProjectListFilter();
diff --git a/editor/project_settings.cpp b/editor/project_settings.cpp
index 15019b8ca8..43c5ccf3a2 100644
--- a/editor/project_settings.cpp
+++ b/editor/project_settings.cpp
@@ -28,36 +28,36 @@
/*************************************************************************/
#include "project_settings.h"
-#include "scene/gui/tab_container.h"
+#include "editor_node.h"
#include "global_config.h"
+#include "global_constants.h"
#include "os/keyboard.h"
-#include "editor_node.h"
#include "scene/gui/margin_container.h"
+#include "scene/gui/tab_container.h"
#include "translation.h"
-#include "global_constants.h"
-ProjectSettings *ProjectSettings::singleton=NULL;
-
-static const char* _button_names[JOY_BUTTON_MAX]={
-"PS X, XBox A, Nintendo B",
-"PS Circle, XBox B, Nintendo A",
-"PS Square, XBox X, Nintendo Y",
-"PS Triangle, XBox Y, Nintendo X",
-"L, L1",
-"R, R1",
-"L2",
-"R2",
-"L3",
-"R3",
-"Select, Nintendo -",
-"Start, Nintendo +",
-"D-Pad Up",
-"D-Pad Down",
-"D-Pad Left",
-"D-Pad Right"
+ProjectSettings *ProjectSettings::singleton = NULL;
+
+static const char *_button_names[JOY_BUTTON_MAX] = {
+ "PS X, XBox A, Nintendo B",
+ "PS Circle, XBox B, Nintendo A",
+ "PS Square, XBox X, Nintendo Y",
+ "PS Triangle, XBox Y, Nintendo X",
+ "L, L1",
+ "R, R1",
+ "L2",
+ "R2",
+ "L3",
+ "R3",
+ "Select, Nintendo -",
+ "Start, Nintendo +",
+ "D-Pad Up",
+ "D-Pad Down",
+ "D-Pad Left",
+ "D-Pad Right"
};
-static const char* _axis_names[JOY_AXIS_MAX*2] = {
+static const char *_axis_names[JOY_AXIS_MAX * 2] = {
" (Left Stick Left)",
" (Left Stick Right)",
" (Left Stick Up)",
@@ -66,7 +66,7 @@ static const char* _axis_names[JOY_AXIS_MAX*2] = {
" (Right Stick Right)",
" (Right Stick Up)",
" (Right Stick Down)",
- "","","","",
+ "", "", "", "",
"", " (L2)",
"", " (R2)"
};
@@ -77,29 +77,29 @@ void ProjectSettings::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
globals_editor->edit(GlobalConfig::get_singleton());
- search_button->set_icon(get_icon("Zoom","EditorIcons"));
- clear_button->set_icon(get_icon("Close","EditorIcons"));
+ search_button->set_icon(get_icon("Zoom", "EditorIcons"));
+ clear_button->set_icon(get_icon("Close", "EditorIcons"));
- translation_list->connect("button_pressed",this,"_translation_delete");
+ translation_list->connect("button_pressed", this, "_translation_delete");
_update_actions();
- popup_add->add_icon_item(get_icon("Keyboard","EditorIcons"),TTR("Key "),InputEvent::KEY);//"Key " - because the word 'key' has already been used as a key animation
- popup_add->add_icon_item(get_icon("JoyButton","EditorIcons"),TTR("Joy Button"),InputEvent::JOYPAD_BUTTON);
- popup_add->add_icon_item(get_icon("JoyAxis","EditorIcons"),TTR("Joy Axis"),InputEvent::JOYPAD_MOTION);
- popup_add->add_icon_item(get_icon("Mouse","EditorIcons"),TTR("Mouse Button"),InputEvent::MOUSE_BUTTON);
+ popup_add->add_icon_item(get_icon("Keyboard", "EditorIcons"), TTR("Key "), InputEvent::KEY); //"Key " - because the word 'key' has already been used as a key animation
+ popup_add->add_icon_item(get_icon("JoyButton", "EditorIcons"), TTR("Joy Button"), InputEvent::JOYPAD_BUTTON);
+ popup_add->add_icon_item(get_icon("JoyAxis", "EditorIcons"), TTR("Joy Axis"), InputEvent::JOYPAD_MOTION);
+ popup_add->add_icon_item(get_icon("Mouse", "EditorIcons"), TTR("Mouse Button"), InputEvent::MOUSE_BUTTON);
List<String> tfn;
- ResourceLoader::get_recognized_extensions_for_type("Translation",&tfn);
- for (List<String>::Element *E=tfn.front();E;E=E->next()) {
+ ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn);
+ for (List<String>::Element *E = tfn.front(); E; E = E->next()) {
- translation_file_open->add_filter("*."+E->get());
+ translation_file_open->add_filter("*." + E->get());
}
List<String> rfn;
- ResourceLoader::get_recognized_extensions_for_type("Resource",&rfn);
- for (List<String>::Element *E=rfn.front();E;E=E->next()) {
+ ResourceLoader::get_recognized_extensions_for_type("Resource", &rfn);
+ for (List<String>::Element *E = rfn.front(); E; E = E->next()) {
- translation_res_file_open->add_filter("*."+E->get());
- translation_res_option_file_open->add_filter("*."+E->get());
+ translation_res_file_open->add_filter("*." + E->get());
+ translation_res_option_file_open->add_filter("*." + E->get());
}
} break;
case NOTIFICATION_POPUP_HIDE: {
@@ -110,164 +110,155 @@ void ProjectSettings::_notification(int p_what) {
void ProjectSettings::_action_selected() {
- TreeItem *ti=input_editor->get_selected();
+ TreeItem *ti = input_editor->get_selected();
if (!ti || !ti->is_editable(0))
return;
- add_at="input/"+ti->get_text(0);
+ add_at = "input/" + ti->get_text(0);
}
void ProjectSettings::_action_edited() {
- TreeItem *ti=input_editor->get_selected();
+ TreeItem *ti = input_editor->get_selected();
if (!ti)
return;
- String new_name=ti->get_text(0);
- String old_name=add_at.substr(add_at.find("/")+1,add_at.length());
+ String new_name = ti->get_text(0);
+ String old_name = add_at.substr(add_at.find("/") + 1, add_at.length());
- if (new_name==old_name)
+ if (new_name == old_name)
return;
- if (new_name.find("/")!=-1 || new_name.find(":")!=-1 || new_name=="") {
+ if (new_name.find("/") != -1 || new_name.find(":") != -1 || new_name == "") {
- ti->set_text(0,old_name);
- add_at="input/"+old_name;
+ ti->set_text(0, old_name);
+ add_at = "input/" + old_name;
message->set_text(TTR("Invalid action (anything goes but '/' or ':')."));
- message->popup_centered(Size2(300,100));
+ message->popup_centered(Size2(300, 100));
return;
}
- String action_prop="input/"+new_name;
+ String action_prop = "input/" + new_name;
if (GlobalConfig::get_singleton()->has(action_prop)) {
- ti->set_text(0,old_name);
- add_at="input/"+old_name;
+ ti->set_text(0, old_name);
+ add_at = "input/" + old_name;
- message->set_text(vformat(TTR("Action '%s' already exists!"),new_name));
- message->popup_centered(Size2(300,100));
+ message->set_text(vformat(TTR("Action '%s' already exists!"), new_name));
+ message->popup_centered(Size2(300, 100));
return;
}
int order = GlobalConfig::get_singleton()->get_order(add_at);
Array va = GlobalConfig::get_singleton()->get(add_at);
- setting=true;
+ setting = true;
undo_redo->create_action(TTR("Rename Input Action Event"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(),"clear",add_at);
- undo_redo->add_do_method(GlobalConfig::get_singleton(),"set",action_prop,va);
- undo_redo->add_do_method(GlobalConfig::get_singleton(),"set_order",action_prop,order);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(),"clear",action_prop);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(),"set",add_at,va);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(),"set_order",add_at,order);
- undo_redo->add_do_method(this,"_update_actions");
- undo_redo->add_undo_method(this,"_update_actions");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_method(GlobalConfig::get_singleton(), "clear", add_at);
+ undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", action_prop, va);
+ undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", action_prop, order);
+ undo_redo->add_undo_method(GlobalConfig::get_singleton(), "clear", action_prop);
+ undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", add_at, va);
+ undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", add_at, order);
+ undo_redo->add_do_method(this, "_update_actions");
+ undo_redo->add_undo_method(this, "_update_actions");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
- setting=false;
-
- add_at=action_prop;
+ setting = false;
+ add_at = action_prop;
}
-
void ProjectSettings::_device_input_add() {
-
-
-
InputEvent ie;
- String name=add_at;
+ String name = add_at;
Variant old_val = GlobalConfig::get_singleton()->get(name);
- Array arr=old_val;
- ie.device=device_id->get_value();
+ Array arr = old_val;
+ ie.device = device_id->get_value();
- ie.type=add_type;
+ ie.type = add_type;
- switch(add_type) {
+ switch (add_type) {
case InputEvent::MOUSE_BUTTON: {
+ ie.mouse_button.button_index = device_index->get_selected() + 1;
- ie.mouse_button.button_index=device_index->get_selected()+1;
-
- for(int i=0;i<arr.size();i++) {
+ for (int i = 0; i < arr.size(); i++) {
- InputEvent aie=arr[i];
- if (aie.device == ie.device && aie.type==InputEvent::MOUSE_BUTTON && aie.mouse_button.button_index==ie.mouse_button.button_index) {
- return;
- }
+ InputEvent aie = arr[i];
+ if (aie.device == ie.device && aie.type == InputEvent::MOUSE_BUTTON && aie.mouse_button.button_index == ie.mouse_button.button_index) {
+ return;
}
+ }
} break;
case InputEvent::JOYPAD_MOTION: {
- ie.joy_motion.axis = device_index->get_selected()>>1;
- ie.joy_motion.axis_value = device_index->get_selected()&1?1:-1;
+ ie.joy_motion.axis = device_index->get_selected() >> 1;
+ ie.joy_motion.axis_value = device_index->get_selected() & 1 ? 1 : -1;
+ for (int i = 0; i < arr.size(); i++) {
- for(int i=0;i<arr.size();i++) {
-
- InputEvent aie=arr[i];
- if (aie.device == ie.device && aie.type==InputEvent::JOYPAD_MOTION && aie.joy_motion.axis==ie.joy_motion.axis && aie.joy_motion.axis_value==ie.joy_motion.axis_value) {
- return;
- }
+ InputEvent aie = arr[i];
+ if (aie.device == ie.device && aie.type == InputEvent::JOYPAD_MOTION && aie.joy_motion.axis == ie.joy_motion.axis && aie.joy_motion.axis_value == ie.joy_motion.axis_value) {
+ return;
}
+ }
} break;
case InputEvent::JOYPAD_BUTTON: {
- ie.joy_button.button_index=device_index->get_selected();
+ ie.joy_button.button_index = device_index->get_selected();
- for(int i=0;i<arr.size();i++) {
+ for (int i = 0; i < arr.size(); i++) {
- InputEvent aie=arr[i];
- if (aie.device == ie.device && aie.type==InputEvent::JOYPAD_BUTTON && aie.joy_button.button_index==ie.joy_button.button_index) {
- return;
- }
+ InputEvent aie = arr[i];
+ if (aie.device == ie.device && aie.type == InputEvent::JOYPAD_BUTTON && aie.joy_button.button_index == ie.joy_button.button_index) {
+ return;
}
+ }
} break;
- default:{}
+ default: {}
}
-
arr.push_back(ie);
undo_redo->create_action(TTR("Add Input Action Event"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(),"set",name,arr);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(),"set",name,old_val);
- undo_redo->add_do_method(this,"_update_actions");
- undo_redo->add_undo_method(this,"_update_actions");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, arr);
+ undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val);
+ undo_redo->add_do_method(this, "_update_actions");
+ undo_redo->add_undo_method(this, "_update_actions");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
_show_last_added(ie, name);
}
-
void ProjectSettings::_press_a_key_confirm() {
- if (last_wait_for_key.type!=InputEvent::KEY)
+ if (last_wait_for_key.type != InputEvent::KEY)
return;
InputEvent ie;
- ie.type=InputEvent::KEY;
- ie.key.scancode=last_wait_for_key.key.scancode;
- ie.key.mod=last_wait_for_key.key.mod;
- String name=add_at;
+ ie.type = InputEvent::KEY;
+ ie.key.scancode = last_wait_for_key.key.scancode;
+ ie.key.mod = last_wait_for_key.key.mod;
+ String name = add_at;
Variant old_val = GlobalConfig::get_singleton()->get(name);
- Array arr=old_val;
+ Array arr = old_val;
- for(int i=0;i<arr.size();i++) {
+ for (int i = 0; i < arr.size(); i++) {
- InputEvent aie=arr[i];
- if (aie.type==InputEvent::KEY && aie.key.scancode==ie.key.scancode && aie.key.mod==ie.key.mod) {
+ InputEvent aie = arr[i];
+ if (aie.type == InputEvent::KEY && aie.key.scancode == ie.key.scancode && aie.key.mod == ie.key.mod) {
return;
}
}
@@ -275,85 +266,81 @@ void ProjectSettings::_press_a_key_confirm() {
arr.push_back(ie);
undo_redo->create_action(TTR("Add Input Action Event"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(),"set",name,arr);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(),"set",name,old_val);
- undo_redo->add_do_method(this,"_update_actions");
- undo_redo->add_undo_method(this,"_update_actions");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, arr);
+ undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val);
+ undo_redo->add_do_method(this, "_update_actions");
+ undo_redo->add_undo_method(this, "_update_actions");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
_show_last_added(ie, name);
}
-void ProjectSettings::_show_last_added(const InputEvent& p_event, const String &p_name) {
+void ProjectSettings::_show_last_added(const InputEvent &p_event, const String &p_name) {
TreeItem *r = input_editor->get_root();
String name = p_name;
- name.erase(0,6);
+ name.erase(0, 6);
if (!r)
return;
- r=r->get_children();
+ r = r->get_children();
if (!r)
return;
bool found = false;
- while(r){
+ while (r) {
if (r->get_text(0) != name) {
- r=r->get_next();
+ r = r->get_next();
continue;
}
TreeItem *child = r->get_children();
- while(child){
+ while (child) {
Variant input = child->get_meta("__input");
- if (p_event==input){
+ if (p_event == input) {
child->select(0);
found = true;
break;
}
- child=child->get_next();
+ child = child->get_next();
}
if (found) break;
- r=r->get_next();
+ r = r->get_next();
}
if (found) input_editor->ensure_cursor_is_visible();
}
-void ProjectSettings::_wait_for_key(const InputEvent& p_event) {
-
+void ProjectSettings::_wait_for_key(const InputEvent &p_event) {
- if (p_event.type==InputEvent::KEY && p_event.key.pressed && p_event.key.scancode!=0) {
+ if (p_event.type == InputEvent::KEY && p_event.key.pressed && p_event.key.scancode != 0) {
- last_wait_for_key=p_event;
- String str=keycode_get_string(p_event.key.scancode).capitalize();
+ last_wait_for_key = p_event;
+ String str = keycode_get_string(p_event.key.scancode).capitalize();
if (p_event.key.mod.meta)
- str=TTR("Meta+")+str;
+ str = TTR("Meta+") + str;
if (p_event.key.mod.shift)
- str=TTR("Shift+")+str;
+ str = TTR("Shift+") + str;
if (p_event.key.mod.alt)
- str=TTR("Alt+")+str;
+ str = TTR("Alt+") + str;
if (p_event.key.mod.control)
- str=TTR("Control+")+str;
-
+ str = TTR("Control+") + str;
press_a_key_label->set_text(str);
press_a_key->accept_event();
-
}
}
+void ProjectSettings::_add_item(int p_item) {
-void ProjectSettings::_add_item(int p_item){
+ add_type = InputEvent::Type(p_item);
- add_type=InputEvent::Type(p_item);
-
- switch(add_type) {
+ switch (add_type) {
case InputEvent::KEY: {
press_a_key_label->set_text(TTR("Press a Key.."));
- last_wait_for_key=InputEvent();
- press_a_key->popup_centered(Size2(250,80)*EDSCALE);
+ last_wait_for_key = InputEvent();
+ press_a_key->popup_centered(Size2(250, 80) * EDSCALE);
press_a_key->grab_focus();
} break;
case InputEvent::MOUSE_BUTTON: {
@@ -370,19 +357,19 @@ void ProjectSettings::_add_item(int p_item){
device_index->add_item(TTR("Button 7"));
device_index->add_item(TTR("Button 8"));
device_index->add_item(TTR("Button 9"));
- device_input->popup_centered_minsize(Size2(350,95));
+ device_input->popup_centered_minsize(Size2(350, 95));
} break;
case InputEvent::JOYPAD_MOTION: {
device_id->set_value(0);
device_index_label->set_text(TTR("Joypad Axis Index:"));
device_index->clear();
- for(int i=0;i<JOY_AXIS_MAX*2;i++) {
+ for (int i = 0; i < JOY_AXIS_MAX * 2; i++) {
String desc = _axis_names[i];
- device_index->add_item(TTR("Axis")+" "+itos(i/2)+" "+(i&1?"+":"-")+desc);
+ device_index->add_item(TTR("Axis") + " " + itos(i / 2) + " " + (i & 1 ? "+" : "-") + desc);
}
- device_input->popup_centered_minsize(Size2(350,95));
+ device_input->popup_centered_minsize(Size2(350, 95));
} break;
case InputEvent::JOYPAD_BUTTON: {
@@ -391,90 +378,83 @@ void ProjectSettings::_add_item(int p_item){
device_index_label->set_text(TTR("Joypad Button Index:"));
device_index->clear();
- for(int i=0;i<JOY_BUTTON_MAX;i++) {
+ for (int i = 0; i < JOY_BUTTON_MAX; i++) {
- device_index->add_item(itos(i)+": "+String(_button_names[i]));
+ device_index->add_item(itos(i) + ": " + String(_button_names[i]));
}
- device_input->popup_centered_minsize(Size2(350,95));
+ device_input->popup_centered_minsize(Size2(350, 95));
} break;
- default:{}
+ default: {}
}
}
+void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_id) {
-
-
-void ProjectSettings::_action_button_pressed(Object* p_obj, int p_column,int p_id) {
-
- TreeItem *ti=p_obj->cast_to<TreeItem>();
+ TreeItem *ti = p_obj->cast_to<TreeItem>();
ERR_FAIL_COND(!ti);
- if (p_id==1) {
+ if (p_id == 1) {
Point2 ofs = input_editor->get_global_pos();
- Rect2 ir=input_editor->get_item_rect(ti);
- ir.pos.y-=input_editor->get_scroll().y;
- ofs+=ir.pos+ir.size;
- ofs.x-=100;
+ Rect2 ir = input_editor->get_item_rect(ti);
+ ir.pos.y -= input_editor->get_scroll().y;
+ ofs += ir.pos + ir.size;
+ ofs.x -= 100;
popup_add->set_pos(ofs);
popup_add->popup();
- add_at="input/"+ti->get_text(0);
+ add_at = "input/" + ti->get_text(0);
- } else if (p_id==2) {
+ } else if (p_id == 2) {
//remove
- if (ti->get_parent()==input_editor->get_root()) {
+ if (ti->get_parent() == input_editor->get_root()) {
//remove main thing
- String name="input/"+ti->get_text(0);
+ String name = "input/" + ti->get_text(0);
Variant old_val = GlobalConfig::get_singleton()->get(name);
- int order=GlobalConfig::get_singleton()->get_order(name);
+ int order = GlobalConfig::get_singleton()->get_order(name);
undo_redo->create_action(TTR("Add Input Action"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(),"clear",name);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(),"set",name,old_val);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(),"set_order",name,order);
- undo_redo->add_do_method(this,"_update_actions");
- undo_redo->add_undo_method(this,"_update_actions");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_method(GlobalConfig::get_singleton(), "clear", name);
+ undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val);
+ undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", name, order);
+ undo_redo->add_do_method(this, "_update_actions");
+ undo_redo->add_undo_method(this, "_update_actions");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
} else {
//remove action
- String name="input/"+ti->get_parent()->get_text(0);
+ String name = "input/" + ti->get_parent()->get_text(0);
Variant old_val = GlobalConfig::get_singleton()->get(name);
int idx = ti->get_metadata(0);
Array va = old_val;
- ERR_FAIL_INDEX(idx,va.size());
+ ERR_FAIL_INDEX(idx, va.size());
- for(int i=idx;i<va.size()-1;i++) {
+ for (int i = idx; i < va.size() - 1; i++) {
- va[i]=va[i+1];
+ va[i] = va[i + 1];
}
- va.resize(va.size()-1);
-
+ va.resize(va.size() - 1);
undo_redo->create_action(TTR("Erase Input Action Event"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(),"set",name,va);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(),"set",name,old_val);
- undo_redo->add_do_method(this,"_update_actions");
- undo_redo->add_undo_method(this,"_update_actions");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, va);
+ undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val);
+ undo_redo->add_do_method(this, "_update_actions");
+ undo_redo->add_undo_method(this, "_update_actions");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
-
}
}
-
}
-
void ProjectSettings::_update_actions() {
if (setting)
@@ -487,100 +467,98 @@ void ProjectSettings::_update_actions() {
List<PropertyInfo> props;
GlobalConfig::get_singleton()->get_property_list(&props);
- for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
- const PropertyInfo &pi=E->get();
+ const PropertyInfo &pi = E->get();
if (!pi.name.begins_with("input/"))
continue;
- String name = pi.name.get_slice("/",1);
- if (name=="")
+ String name = pi.name.get_slice("/", 1);
+ if (name == "")
continue;
- TreeItem *item=input_editor->create_item(root);
+ TreeItem *item = input_editor->create_item(root);
//item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- item->set_text(0,name);
- item->add_button(0,get_icon("Add","EditorIcons"),1);
+ item->set_text(0, name);
+ item->add_button(0, get_icon("Add", "EditorIcons"), 1);
if (!GlobalConfig::get_singleton()->get_input_presets().find(pi.name)) {
- item->add_button(0,get_icon("Remove","EditorIcons"),2);
- item->set_editable(0,true);
+ item->add_button(0, get_icon("Remove", "EditorIcons"), 2);
+ item->set_editable(0, true);
}
- item->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
+ item->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
//item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED);
+ Array actions = GlobalConfig::get_singleton()->get(pi.name);
- Array actions=GlobalConfig::get_singleton()->get(pi.name);
-
- for(int i=0;i<actions.size();i++) {
+ for (int i = 0; i < actions.size(); i++) {
- if (actions[i].get_type()!=Variant::INPUT_EVENT)
+ if (actions[i].get_type() != Variant::INPUT_EVENT)
continue;
InputEvent ie = actions[i];
TreeItem *action = input_editor->create_item(item);
- switch(ie.type) {
+ switch (ie.type) {
case InputEvent::KEY: {
- String str=keycode_get_string(ie.key.scancode).capitalize();
+ String str = keycode_get_string(ie.key.scancode).capitalize();
if (ie.key.mod.meta)
- str=TTR("Meta+")+str;
+ str = TTR("Meta+") + str;
if (ie.key.mod.shift)
- str=TTR("Shift+")+str;
+ str = TTR("Shift+") + str;
if (ie.key.mod.alt)
- str=TTR("Alt+")+str;
+ str = TTR("Alt+") + str;
if (ie.key.mod.control)
- str=TTR("Control+")+str;
+ str = TTR("Control+") + str;
- action->set_text(0,str);
- action->set_icon(0,get_icon("Keyboard","EditorIcons"));
+ action->set_text(0, str);
+ action->set_icon(0, get_icon("Keyboard", "EditorIcons"));
} break;
case InputEvent::JOYPAD_BUTTON: {
- String str = TTR("Device")+" "+itos(ie.device)+", "+TTR("Button")+" "+itos(ie.joy_button.button_index);
- if (ie.joy_button.button_index>=0 && ie.joy_button.button_index<JOY_BUTTON_MAX)
- str+=String()+" ("+_button_names[ie.joy_button.button_index]+").";
+ String str = TTR("Device") + " " + itos(ie.device) + ", " + TTR("Button") + " " + itos(ie.joy_button.button_index);
+ if (ie.joy_button.button_index >= 0 && ie.joy_button.button_index < JOY_BUTTON_MAX)
+ str += String() + " (" + _button_names[ie.joy_button.button_index] + ").";
else
- str+=".";
+ str += ".";
- action->set_text(0,str);
- action->set_icon(0,get_icon("JoyButton","EditorIcons"));
+ action->set_text(0, str);
+ action->set_icon(0, get_icon("JoyButton", "EditorIcons"));
} break;
case InputEvent::MOUSE_BUTTON: {
- String str = TTR("Device")+" "+itos(ie.device)+", ";
+ String str = TTR("Device") + " " + itos(ie.device) + ", ";
switch (ie.mouse_button.button_index) {
- case BUTTON_LEFT: str+=TTR("Left Button."); break;
- case BUTTON_RIGHT: str+=TTR("Right Button."); break;
- case BUTTON_MIDDLE: str+=TTR("Middle Button."); break;
- case BUTTON_WHEEL_UP: str+=TTR("Wheel Up."); break;
- case BUTTON_WHEEL_DOWN: str+=TTR("Wheel Down."); break;
- default: str+=TTR("Button")+" "+itos(ie.mouse_button.button_index)+".";
+ case BUTTON_LEFT: str += TTR("Left Button."); break;
+ case BUTTON_RIGHT: str += TTR("Right Button."); break;
+ case BUTTON_MIDDLE: str += TTR("Middle Button."); break;
+ case BUTTON_WHEEL_UP: str += TTR("Wheel Up."); break;
+ case BUTTON_WHEEL_DOWN: str += TTR("Wheel Down."); break;
+ default: str += TTR("Button") + " " + itos(ie.mouse_button.button_index) + ".";
}
- action->set_text(0,str);
- action->set_icon(0,get_icon("Mouse","EditorIcons"));
+ action->set_text(0, str);
+ action->set_icon(0, get_icon("Mouse", "EditorIcons"));
} break;
case InputEvent::JOYPAD_MOTION: {
int ax = ie.joy_motion.axis;
- int n = 2*ax + (ie.joy_motion.axis_value<0 ? 0:1);
+ int n = 2 * ax + (ie.joy_motion.axis_value < 0 ? 0 : 1);
String desc = _axis_names[n];
- String str = TTR("Device")+" "+itos(ie.device)+", "+TTR("Axis")+" "+itos(ax)+" "+(ie.joy_motion.axis_value<0?"-":"+")+desc +".";
- action->set_text(0,str);
- action->set_icon(0,get_icon("JoyAxis","EditorIcons"));
+ String str = TTR("Device") + " " + itos(ie.device) + ", " + TTR("Axis") + " " + itos(ax) + " " + (ie.joy_motion.axis_value < 0 ? "-" : "+") + desc + ".";
+ action->set_text(0, str);
+ action->set_icon(0, get_icon("JoyAxis", "EditorIcons"));
} break;
}
- action->add_button(0,get_icon("Remove","EditorIcons"),2);
- action->set_metadata(0,i);
+ action->add_button(0, get_icon("Remove", "EditorIcons"), 2);
+ action->set_metadata(0, i);
action->set_meta("__input", ie);
}
}
}
-
void ProjectSettings::popup_project_settings() {
// Restore valid window bounds or pop up at default size.
@@ -595,10 +573,8 @@ void ProjectSettings::popup_project_settings() {
plugin_settings->update_plugins();
}
-
void ProjectSettings::_item_selected() {
-
TreeItem *ti = globals_editor->get_property_editor()->get_scene_tree()->get_selected();
if (!ti)
return;
@@ -607,11 +583,8 @@ void ProjectSettings::_item_selected() {
category->set_text(globals_editor->get_current_section());
property->set_text(ti->get_text(0));
popup_platform->set_disabled(false);
-
-
}
-
void ProjectSettings::_item_adds(String) {
_item_add();
@@ -620,11 +593,11 @@ void ProjectSettings::_item_adds(String) {
void ProjectSettings::_item_add() {
Variant value;
- switch(type->get_selected()) {
- case 0: value=false; break;
- case 1: value=0; break;
- case 2: value=0.0; break;
- case 3: value=""; break;
+ switch (type->get_selected()) {
+ case 0: value = false; break;
+ case 1: value = 0; break;
+ case 2: value = 0.0; break;
+ case 3: value = ""; break;
}
String catname = category->get_text().strip_edges();
@@ -641,7 +614,7 @@ void ProjectSettings::_item_add() {
return;
}*/
- String name = catname!="" ? catname+"/"+propname : propname;
+ String name = catname != "" ? catname + "/" + propname : propname;
undo_redo->create_action("Add Global Property");
@@ -673,7 +646,7 @@ void ProjectSettings::_item_del() {
String propname = property->get_text().strip_edges();
//ERR_FAIL_COND(!propname.is_valid_identifier());
- String name = catname!="" ? catname+"/"+propname : propname;
+ String name = catname != "" ? catname + "/" + propname : propname;
undo_redo->create_action("Delete Global Property");
@@ -700,64 +673,56 @@ void ProjectSettings::_action_adds(String) {
void ProjectSettings::_action_add() {
String action = action_name->get_text();
- if (action.find("/")!=-1 || action.find(":")!=-1 || action=="") {
+ if (action.find("/") != -1 || action.find(":") != -1 || action == "") {
message->set_text(TTR("Invalid action (anything goes but '/' or ':')."));
- message->popup_centered(Size2(300,100));
+ message->popup_centered(Size2(300, 100));
return;
}
- if (GlobalConfig::get_singleton()->has("input/"+action)) {
- message->set_text(vformat(TTR("Action '%s' already exists!"),action));
- message->popup_centered(Size2(300,100));
+ if (GlobalConfig::get_singleton()->has("input/" + action)) {
+ message->set_text(vformat(TTR("Action '%s' already exists!"), action));
+ message->popup_centered(Size2(300, 100));
return;
}
Array va;
- String name = "input/"+action;
+ String name = "input/" + action;
undo_redo->create_action(TTR("Add Input Action Event"));
- undo_redo->add_do_method(GlobalConfig::get_singleton(),"set",name,va);
- undo_redo->add_undo_method(GlobalConfig::get_singleton(),"clear",name);
- undo_redo->add_do_method(this,"_update_actions");
- undo_redo->add_undo_method(this,"_update_actions");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, va);
+ undo_redo->add_undo_method(GlobalConfig::get_singleton(), "clear", name);
+ undo_redo->add_do_method(this, "_update_actions");
+ undo_redo->add_undo_method(this, "_update_actions");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
TreeItem *r = input_editor->get_root();
if (!r)
return;
- r=r->get_children();
+ r = r->get_children();
if (!r)
return;
- while(r->get_next())
- r=r->get_next();
+ while (r->get_next())
+ r = r->get_next();
if (!r)
return;
r->select(0);
input_editor->ensure_cursor_is_visible();
-
}
-
-void ProjectSettings::_item_checked(const String& p_item, bool p_check) {
-
-
-
+void ProjectSettings::_item_checked(const String &p_item, bool p_check) {
}
-
void ProjectSettings::_save() {
Error err = GlobalConfig::get_singleton()->save();
- message->set_text(err!=OK?TTR("Error saving settings."):TTR("Settings saved OK."));
- message->popup_centered(Size2(300,100));
+ message->set_text(err != OK ? TTR("Error saving settings.") : TTR("Settings saved OK."));
+ message->popup_centered(Size2(300, 100));
}
-
-
-void ProjectSettings::_settings_prop_edited(const String& p_name) {
+void ProjectSettings::_settings_prop_edited(const String &p_name) {
String full_item = globals_editor->get_full_item_path(p_name);
@@ -773,62 +738,56 @@ void ProjectSettings::queue_save() {
_settings_changed();
}
-
void ProjectSettings::_copy_to_platform(int p_which) {
String catname = category->get_text();
if (!catname.is_valid_identifier()) {
message->set_text("Invalid Category.\nValid characters: a-z,A-Z,0-9 or _");
- message->popup_centered(Size2(300,100));
+ message->popup_centered(Size2(300, 100));
return;
}
-
String propname = property->get_text();
if (!propname.is_valid_identifier()) {
message->set_text("Invalid Property.\nValid characters: a-z,A-Z,0-9 or _");
- message->popup_centered(Size2(300,100));
+ message->popup_centered(Size2(300, 100));
return;
}
- String name = catname+"/"+propname;
- Variant value=GlobalConfig::get_singleton()->get(name);
+ String name = catname + "/" + propname;
+ Variant value = GlobalConfig::get_singleton()->get(name);
- catname+="."+popup_platform->get_popup()->get_item_text(p_which);
- name = catname+"/"+propname;
+ catname += "." + popup_platform->get_popup()->get_item_text(p_which);
+ name = catname + "/" + propname;
- GlobalConfig::get_singleton()->set(name,value);
+ GlobalConfig::get_singleton()->set(name, value);
globals_editor->get_property_editor()->update_tree();
-
}
-
-void ProjectSettings::add_translation(const String& p_translation) {
+void ProjectSettings::add_translation(const String &p_translation) {
_translation_add(p_translation);
}
-void ProjectSettings::_translation_add(const String& p_path) {
+void ProjectSettings::_translation_add(const String &p_path) {
PoolStringArray translations = GlobalConfig::get_singleton()->get("locale/translations");
+ for (int i = 0; i < translations.size(); i++) {
- for(int i=0;i<translations.size();i++) {
-
- if (translations[i]==p_path)
+ if (translations[i] == p_path)
return; //exists
}
translations.push_back(p_path);
undo_redo->create_action(TTR("Add Translation"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(),"locale/translations",translations);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(),"locale/translations",GlobalConfig::get_singleton()->get("locale/translations"));
- undo_redo->add_do_method(this,"_update_translations");
- undo_redo->add_undo_method(this,"_update_translations");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translations", translations);
+ undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translations", GlobalConfig::get_singleton()->get("locale/translations"));
+ undo_redo->add_do_method(this, "_update_translations");
+ undo_redo->add_undo_method(this, "_update_translations");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
-
}
void ProjectSettings::_translation_file_open() {
@@ -836,69 +795,64 @@ void ProjectSettings::_translation_file_open() {
translation_file_open->popup_centered_ratio();
}
-void ProjectSettings::_translation_delete(Object *p_item,int p_column, int p_button) {
+void ProjectSettings::_translation_delete(Object *p_item, int p_column, int p_button) {
TreeItem *ti = p_item->cast_to<TreeItem>();
ERR_FAIL_COND(!ti);
- int idx=ti->get_metadata(0);
+ int idx = ti->get_metadata(0);
PoolStringArray translations = GlobalConfig::get_singleton()->get("locale/translations");
- ERR_FAIL_INDEX(idx,translations.size());
+ ERR_FAIL_INDEX(idx, translations.size());
translations.remove(idx);
undo_redo->create_action(TTR("Remove Translation"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(),"locale/translations",translations);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(),"locale/translations",GlobalConfig::get_singleton()->get("locale/translations"));
- undo_redo->add_do_method(this,"_update_translations");
- undo_redo->add_undo_method(this,"_update_translations");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translations", translations);
+ undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translations", GlobalConfig::get_singleton()->get("locale/translations"));
+ undo_redo->add_do_method(this, "_update_translations");
+ undo_redo->add_undo_method(this, "_update_translations");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
-
-
}
void ProjectSettings::_translation_res_file_open() {
translation_res_file_open->popup_centered_ratio();
-
}
-void ProjectSettings::_translation_res_add(const String& p_path){
+void ProjectSettings::_translation_res_add(const String &p_path) {
Variant prev;
Dictionary remaps;
if (GlobalConfig::get_singleton()->has("locale/translation_remaps")) {
remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
- prev=remaps;
+ prev = remaps;
}
if (remaps.has(p_path))
return; //pointless already has it
- remaps[p_path]=PoolStringArray();
+ remaps[p_path] = PoolStringArray();
undo_redo->create_action(TTR("Add Remapped Path"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(),"locale/translation_remaps",remaps);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(),"locale/translation_remaps",prev);
- undo_redo->add_do_method(this,"_update_translations");
- undo_redo->add_undo_method(this,"_update_translations");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps);
+ undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", prev);
+ undo_redo->add_do_method(this, "_update_translations");
+ undo_redo->add_undo_method(this, "_update_translations");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
-
}
-void ProjectSettings::_translation_res_option_file_open(){
+void ProjectSettings::_translation_res_option_file_open() {
translation_res_option_file_open->popup_centered_ratio();
-
}
-void ProjectSettings::_translation_res_option_add(const String& p_path) {
+void ProjectSettings::_translation_res_option_add(const String &p_path) {
ERR_FAIL_COND(!GlobalConfig::get_singleton()->has("locale/translation_remaps"));
@@ -911,29 +865,24 @@ void ProjectSettings::_translation_res_option_add(const String& p_path) {
ERR_FAIL_COND(!remaps.has(key));
PoolStringArray r = remaps[key];
- r.push_back(p_path+":"+"en");
- remaps[key]=r;
-
+ r.push_back(p_path + ":" + "en");
+ remaps[key] = r;
undo_redo->create_action(TTR("Resource Remap Add Remap"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(),"locale/translation_remaps",remaps);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(),"locale/translation_remaps",GlobalConfig::get_singleton()->get("locale/translation_remaps"));
- undo_redo->add_do_method(this,"_update_translations");
- undo_redo->add_undo_method(this,"_update_translations");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps);
+ undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps"));
+ undo_redo->add_do_method(this, "_update_translations");
+ undo_redo->add_undo_method(this, "_update_translations");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
-
}
-
-
void ProjectSettings::_translation_res_select() {
if (updating_translations)
return;
-
call_deferred("_update_translations");
}
@@ -959,31 +908,27 @@ void ProjectSettings::_translation_res_option_changed() {
Vector<String> langs = TranslationServer::get_all_locales();
- ERR_FAIL_INDEX(which,langs.size());
-
+ ERR_FAIL_INDEX(which, langs.size());
ERR_FAIL_COND(!remaps.has(key));
PoolStringArray r = remaps[key];
- ERR_FAIL_INDEX(idx,r.size());
- r.set(idx,path+":"+langs[which]);
- remaps[key]=r;
+ ERR_FAIL_INDEX(idx, r.size());
+ r.set(idx, path + ":" + langs[which]);
+ remaps[key] = r;
- updating_translations=true;
+ updating_translations = true;
undo_redo->create_action(TTR("Change Resource Remap Language"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(),"locale/translation_remaps",remaps);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(),"locale/translation_remaps",GlobalConfig::get_singleton()->get("locale/translation_remaps"));
- undo_redo->add_do_method(this,"_update_translations");
- undo_redo->add_undo_method(this,"_update_translations");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps);
+ undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps"));
+ undo_redo->add_do_method(this, "_update_translations");
+ undo_redo->add_undo_method(this, "_update_translations");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
- updating_translations=false;
-
+ updating_translations = false;
}
-
-void ProjectSettings::_translation_res_delete(Object *p_item,int p_column, int p_button) {
-
+void ProjectSettings::_translation_res_delete(Object *p_item, int p_column, int p_button) {
if (updating_translations)
return;
@@ -1001,16 +946,16 @@ void ProjectSettings::_translation_res_delete(Object *p_item,int p_column, int p
remaps.erase(key);
undo_redo->create_action(TTR("Remove Resource Remap"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(),"locale/translation_remaps",remaps);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(),"locale/translation_remaps",GlobalConfig::get_singleton()->get("locale/translation_remaps"));
- undo_redo->add_do_method(this,"_update_translations");
- undo_redo->add_undo_method(this,"_update_translations");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps);
+ undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps"));
+ undo_redo->add_do_method(this, "_update_translations");
+ undo_redo->add_undo_method(this, "_update_translations");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
}
-void ProjectSettings::_translation_res_option_delete(Object *p_item,int p_column, int p_button) {
+void ProjectSettings::_translation_res_option_delete(Object *p_item, int p_column, int p_button) {
if (updating_translations)
return;
@@ -1030,20 +975,18 @@ void ProjectSettings::_translation_res_option_delete(Object *p_item,int p_column
ERR_FAIL_COND(!remaps.has(key));
PoolStringArray r = remaps[key];
- ERR_FAIL_INDEX(idx,remaps.size());
+ ERR_FAIL_INDEX(idx, remaps.size());
r.remove(idx);
- remaps[key]=r;
-
+ remaps[key] = r;
undo_redo->create_action(TTR("Remove Resource Remap Option"));
- undo_redo->add_do_property(GlobalConfig::get_singleton(),"locale/translation_remaps",remaps);
- undo_redo->add_undo_property(GlobalConfig::get_singleton(),"locale/translation_remaps",GlobalConfig::get_singleton()->get("locale/translation_remaps"));
- undo_redo->add_do_method(this,"_update_translations");
- undo_redo->add_undo_method(this,"_update_translations");
- undo_redo->add_do_method(this,"_settings_changed");
- undo_redo->add_undo_method(this,"_settings_changed");
+ undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps);
+ undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps"));
+ undo_redo->add_do_method(this, "_update_translations");
+ undo_redo->add_undo_method(this, "_update_translations");
+ undo_redo->add_do_method(this, "_settings_changed");
+ undo_redo->add_undo_method(this, "_settings_changed");
undo_redo->commit_action();
-
}
void ProjectSettings::_update_translations() {
@@ -1053,7 +996,7 @@ void ProjectSettings::_update_translations() {
if (updating_translations)
return;
- updating_translations=true;
+ updating_translations = true;
translation_list->clear();
TreeItem *root = translation_list->create_item(NULL);
@@ -1061,18 +1004,17 @@ void ProjectSettings::_update_translations() {
if (GlobalConfig::get_singleton()->has("locale/translations")) {
PoolStringArray translations = GlobalConfig::get_singleton()->get("locale/translations");
- for(int i=0;i<translations.size();i++) {
+ for (int i = 0; i < translations.size(); i++) {
TreeItem *t = translation_list->create_item(root);
- t->set_editable(0,false);
- t->set_text(0,translations[i].replace_first("res://",""));
- t->set_tooltip(0,translations[i]);
- t->set_metadata(0,i);
- t->add_button(0,get_icon("Del","EditorIcons"),0);
+ t->set_editable(0, false);
+ t->set_text(0, translations[i].replace_first("res://", ""));
+ t->set_tooltip(0, translations[i]);
+ t->set_metadata(0, i);
+ t->add_button(0, get_icon("Del", "EditorIcons"), 0);
}
}
-
//update translation remaps
String remap_selected;
@@ -1091,10 +1033,10 @@ void ProjectSettings::_update_translations() {
Vector<String> langs = TranslationServer::get_all_locales();
Vector<String> names = TranslationServer::get_all_locale_names();
String langnames;
- for(int i=0;i<names.size();i++) {
- if (i>0)
- langnames+=",";
- langnames+=names[i];
+ for (int i = 0; i < names.size(); i++) {
+ if (i > 0)
+ langnames += ",";
+ langnames += names[i];
}
if (GlobalConfig::get_singleton()->has("locale/translation_remaps")) {
@@ -1103,57 +1045,53 @@ void ProjectSettings::_update_translations() {
List<Variant> rk;
remaps.get_key_list(&rk);
Vector<String> keys;
- for(List<Variant>::Element *E=rk.front();E;E=E->next()) {
+ for (List<Variant>::Element *E = rk.front(); E; E = E->next()) {
keys.push_back(E->get());
}
keys.sort();
- for(int i=0;i<keys.size();i++) {
+ for (int i = 0; i < keys.size(); i++) {
TreeItem *t = translation_remap->create_item(root);
- t->set_editable(0,false);
- t->set_text(0,keys[i].replace_first("res://",""));
- t->set_tooltip(0,keys[i]);
- t->set_metadata(0,keys[i]);
- t->add_button(0,get_icon("Del","EditorIcons"),0);
- if (keys[i]==remap_selected) {
+ t->set_editable(0, false);
+ t->set_text(0, keys[i].replace_first("res://", ""));
+ t->set_tooltip(0, keys[i]);
+ t->set_metadata(0, keys[i]);
+ t->add_button(0, get_icon("Del", "EditorIcons"), 0);
+ if (keys[i] == remap_selected) {
t->select(0);
translation_res_option_add_button->set_disabled(false);
PoolStringArray selected = remaps[keys[i]];
- for(int j=0;j<selected.size();j++) {
+ for (int j = 0; j < selected.size(); j++) {
String s = selected[j];
int qp = s.find_last(":");
- String path = s.substr(0,qp);
- String locale = s.substr(qp+1,s.length());
+ String path = s.substr(0, qp);
+ String locale = s.substr(qp + 1, s.length());
TreeItem *t2 = translation_remap_options->create_item(root2);
- t2->set_editable(0,false);
- t2->set_text(0,path.replace_first("res://",""));
- t2->set_tooltip(0,path);
- t2->set_metadata(0,j);
- t2->add_button(0,get_icon("Del","EditorIcons"),0);
- t2->set_cell_mode(1,TreeItem::CELL_MODE_RANGE);
- t2->set_text(1,langnames);
- t2->set_editable(1,true);
- t2->set_metadata(1,path);
+ t2->set_editable(0, false);
+ t2->set_text(0, path.replace_first("res://", ""));
+ t2->set_tooltip(0, path);
+ t2->set_metadata(0, j);
+ t2->add_button(0, get_icon("Del", "EditorIcons"), 0);
+ t2->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
+ t2->set_text(1, langnames);
+ t2->set_editable(1, true);
+ t2->set_metadata(1, path);
int idx = langs.find(locale);
- print_line("find "+locale+" at "+itos(idx));
- if (idx<0)
- idx=0;
+ print_line("find " + locale + " at " + itos(idx));
+ if (idx < 0)
+ idx = 0;
- t2->set_range(1,idx);
+ t2->set_range(1, idx);
}
}
-
-
}
}
-
- updating_translations=false;
-
+ updating_translations = false;
}
void ProjectSettings::_toggle_search_bar(bool p_pressed) {
@@ -1175,7 +1113,7 @@ void ProjectSettings::_toggle_search_bar(bool p_pressed) {
void ProjectSettings::_clear_search_box() {
- if (search_box->get_text()=="")
+ if (search_box->get_text() == "")
return;
search_box->clear();
@@ -1184,60 +1122,57 @@ void ProjectSettings::_clear_search_box() {
void ProjectSettings::set_plugins_page() {
- tab_container->set_current_tab( plugin_settings->get_index() );
+ tab_container->set_current_tab(plugin_settings->get_index());
}
void ProjectSettings::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_item_selected"),&ProjectSettings::_item_selected);
- ClassDB::bind_method(D_METHOD("_item_add"),&ProjectSettings::_item_add);
- ClassDB::bind_method(D_METHOD("_item_adds"),&ProjectSettings::_item_adds);
- ClassDB::bind_method(D_METHOD("_item_del"),&ProjectSettings::_item_del);
- ClassDB::bind_method(D_METHOD("_item_checked"),&ProjectSettings::_item_checked);
- ClassDB::bind_method(D_METHOD("_save"),&ProjectSettings::_save);
- ClassDB::bind_method(D_METHOD("_action_add"),&ProjectSettings::_action_add);
- ClassDB::bind_method(D_METHOD("_action_adds"),&ProjectSettings::_action_adds);
- ClassDB::bind_method(D_METHOD("_action_selected"),&ProjectSettings::_action_selected);
- ClassDB::bind_method(D_METHOD("_action_edited"),&ProjectSettings::_action_edited);
- ClassDB::bind_method(D_METHOD("_action_button_pressed"),&ProjectSettings::_action_button_pressed);
- ClassDB::bind_method(D_METHOD("_update_actions"),&ProjectSettings::_update_actions);
- ClassDB::bind_method(D_METHOD("_wait_for_key"),&ProjectSettings::_wait_for_key);
- ClassDB::bind_method(D_METHOD("_add_item"),&ProjectSettings::_add_item);
- ClassDB::bind_method(D_METHOD("_device_input_add"),&ProjectSettings::_device_input_add);
- ClassDB::bind_method(D_METHOD("_press_a_key_confirm"),&ProjectSettings::_press_a_key_confirm);
- ClassDB::bind_method(D_METHOD("_settings_prop_edited"),&ProjectSettings::_settings_prop_edited);
- ClassDB::bind_method(D_METHOD("_copy_to_platform"),&ProjectSettings::_copy_to_platform);
- ClassDB::bind_method(D_METHOD("_update_translations"),&ProjectSettings::_update_translations);
- ClassDB::bind_method(D_METHOD("_translation_delete"),&ProjectSettings::_translation_delete);
- ClassDB::bind_method(D_METHOD("_settings_changed"),&ProjectSettings::_settings_changed);
- ClassDB::bind_method(D_METHOD("_translation_add"),&ProjectSettings::_translation_add);
- ClassDB::bind_method(D_METHOD("_translation_file_open"),&ProjectSettings::_translation_file_open);
-
- ClassDB::bind_method(D_METHOD("_translation_res_add"),&ProjectSettings::_translation_res_add);
- ClassDB::bind_method(D_METHOD("_translation_res_file_open"),&ProjectSettings::_translation_res_file_open);
- ClassDB::bind_method(D_METHOD("_translation_res_option_add"),&ProjectSettings::_translation_res_option_add);
- ClassDB::bind_method(D_METHOD("_translation_res_option_file_open"),&ProjectSettings::_translation_res_option_file_open);
- ClassDB::bind_method(D_METHOD("_translation_res_select"),&ProjectSettings::_translation_res_select);
- ClassDB::bind_method(D_METHOD("_translation_res_option_changed"),&ProjectSettings::_translation_res_option_changed);
- ClassDB::bind_method(D_METHOD("_translation_res_delete"),&ProjectSettings::_translation_res_delete);
- ClassDB::bind_method(D_METHOD("_translation_res_option_delete"),&ProjectSettings::_translation_res_option_delete);
-
- ClassDB::bind_method(D_METHOD("_clear_search_box"),&ProjectSettings::_clear_search_box);
- ClassDB::bind_method(D_METHOD("_toggle_search_bar"),&ProjectSettings::_toggle_search_bar);
-
+ ClassDB::bind_method(D_METHOD("_item_selected"), &ProjectSettings::_item_selected);
+ ClassDB::bind_method(D_METHOD("_item_add"), &ProjectSettings::_item_add);
+ ClassDB::bind_method(D_METHOD("_item_adds"), &ProjectSettings::_item_adds);
+ ClassDB::bind_method(D_METHOD("_item_del"), &ProjectSettings::_item_del);
+ ClassDB::bind_method(D_METHOD("_item_checked"), &ProjectSettings::_item_checked);
+ ClassDB::bind_method(D_METHOD("_save"), &ProjectSettings::_save);
+ ClassDB::bind_method(D_METHOD("_action_add"), &ProjectSettings::_action_add);
+ ClassDB::bind_method(D_METHOD("_action_adds"), &ProjectSettings::_action_adds);
+ ClassDB::bind_method(D_METHOD("_action_selected"), &ProjectSettings::_action_selected);
+ ClassDB::bind_method(D_METHOD("_action_edited"), &ProjectSettings::_action_edited);
+ ClassDB::bind_method(D_METHOD("_action_button_pressed"), &ProjectSettings::_action_button_pressed);
+ ClassDB::bind_method(D_METHOD("_update_actions"), &ProjectSettings::_update_actions);
+ ClassDB::bind_method(D_METHOD("_wait_for_key"), &ProjectSettings::_wait_for_key);
+ ClassDB::bind_method(D_METHOD("_add_item"), &ProjectSettings::_add_item);
+ ClassDB::bind_method(D_METHOD("_device_input_add"), &ProjectSettings::_device_input_add);
+ ClassDB::bind_method(D_METHOD("_press_a_key_confirm"), &ProjectSettings::_press_a_key_confirm);
+ ClassDB::bind_method(D_METHOD("_settings_prop_edited"), &ProjectSettings::_settings_prop_edited);
+ ClassDB::bind_method(D_METHOD("_copy_to_platform"), &ProjectSettings::_copy_to_platform);
+ ClassDB::bind_method(D_METHOD("_update_translations"), &ProjectSettings::_update_translations);
+ ClassDB::bind_method(D_METHOD("_translation_delete"), &ProjectSettings::_translation_delete);
+ ClassDB::bind_method(D_METHOD("_settings_changed"), &ProjectSettings::_settings_changed);
+ ClassDB::bind_method(D_METHOD("_translation_add"), &ProjectSettings::_translation_add);
+ ClassDB::bind_method(D_METHOD("_translation_file_open"), &ProjectSettings::_translation_file_open);
+
+ ClassDB::bind_method(D_METHOD("_translation_res_add"), &ProjectSettings::_translation_res_add);
+ ClassDB::bind_method(D_METHOD("_translation_res_file_open"), &ProjectSettings::_translation_res_file_open);
+ ClassDB::bind_method(D_METHOD("_translation_res_option_add"), &ProjectSettings::_translation_res_option_add);
+ ClassDB::bind_method(D_METHOD("_translation_res_option_file_open"), &ProjectSettings::_translation_res_option_file_open);
+ ClassDB::bind_method(D_METHOD("_translation_res_select"), &ProjectSettings::_translation_res_select);
+ ClassDB::bind_method(D_METHOD("_translation_res_option_changed"), &ProjectSettings::_translation_res_option_changed);
+ ClassDB::bind_method(D_METHOD("_translation_res_delete"), &ProjectSettings::_translation_res_delete);
+ ClassDB::bind_method(D_METHOD("_translation_res_option_delete"), &ProjectSettings::_translation_res_option_delete);
+
+ ClassDB::bind_method(D_METHOD("_clear_search_box"), &ProjectSettings::_clear_search_box);
+ ClassDB::bind_method(D_METHOD("_toggle_search_bar"), &ProjectSettings::_toggle_search_bar);
}
ProjectSettings::ProjectSettings(EditorData *p_data) {
-
- singleton=this;
+ singleton = this;
set_title(TTR("Project Settings (godot.cfg)"));
set_resizable(true);
- undo_redo=&p_data->get_undo_redo();
- data=p_data;
-
+ undo_redo = &p_data->get_undo_redo();
+ data = p_data;
- tab_container = memnew( TabContainer );
+ tab_container = memnew(TabContainer);
add_child(tab_container);
//set_child_rect(tab_container);
@@ -1246,52 +1181,52 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
//tab_container->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 15 );
//tab_container->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );
- VBoxContainer *props_base = memnew( VBoxContainer );
+ VBoxContainer *props_base = memnew(VBoxContainer);
props_base->set_alignment(BoxContainer::ALIGN_BEGIN);
props_base->set_v_size_flags(Control::SIZE_EXPAND_FILL);
tab_container->add_child(props_base);
props_base->set_name(TTR("General"));
- HBoxContainer *hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
props_base->add_child(hbc);
- search_button = memnew( ToolButton );
+ search_button = memnew(ToolButton);
search_button->set_toggle_mode(true);
search_button->set_pressed(false);
search_button->set_text(TTR("Search"));
hbc->add_child(search_button);
- search_button->connect("toggled",this,"_toggle_search_bar");
+ search_button->connect("toggled", this, "_toggle_search_bar");
- hbc->add_child( memnew( VSeparator ) );
+ hbc->add_child(memnew(VSeparator));
- add_prop_bar = memnew( HBoxContainer );
+ add_prop_bar = memnew(HBoxContainer);
add_prop_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->add_child(add_prop_bar);
- Label *l = memnew( Label );
+ Label *l = memnew(Label);
add_prop_bar->add_child(l);
l->set_text(TTR("Category:"));
- category = memnew( LineEdit );
+ category = memnew(LineEdit);
category->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_prop_bar->add_child(category);
- category->connect("text_entered",this,"_item_adds");
+ category->connect("text_entered", this, "_item_adds");
- l = memnew( Label );
+ l = memnew(Label);
add_prop_bar->add_child(l);
l->set_text(TTR("Property:"));
- property = memnew( LineEdit );
+ property = memnew(LineEdit);
property->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_prop_bar->add_child(property);
- property->connect("text_entered",this,"_item_adds");
+ property->connect("text_entered", this, "_item_adds");
- l = memnew( Label );
+ l = memnew(Label);
add_prop_bar->add_child(l);
l->set_text(TTR("Type:"));
- type = memnew( OptionButton );
+ type = memnew(OptionButton);
type->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_prop_bar->add_child(type);
type->add_item("bool");
@@ -1299,41 +1234,41 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
type->add_item("float");
type->add_item("string");
- Button *add = memnew( Button );
+ Button *add = memnew(Button);
add_prop_bar->add_child(add);
add->set_text(TTR("Add"));
- add->connect("pressed",this,"_item_add");
+ add->connect("pressed", this, "_item_add");
- Button *del = memnew( Button );
+ Button *del = memnew(Button);
add_prop_bar->add_child(del);
del->set_text(TTR("Del"));
- del->connect("pressed",this,"_item_del");
+ del->connect("pressed", this, "_item_del");
- search_bar = memnew( HBoxContainer );
+ search_bar = memnew(HBoxContainer);
search_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->add_child(search_bar);
search_bar->hide();
- search_box = memnew( LineEdit );
+ search_box = memnew(LineEdit);
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search_bar->add_child(search_box);
- clear_button = memnew( ToolButton );
+ clear_button = memnew(ToolButton);
search_bar->add_child(clear_button);
- clear_button->connect("pressed",this,"_clear_search_box");
+ clear_button->connect("pressed", this, "_clear_search_box");
- globals_editor = memnew( SectionedPropertyEditor );
+ globals_editor = memnew(SectionedPropertyEditor);
props_base->add_child(globals_editor);
globals_editor->get_property_editor()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
//globals_editor->hide_top_label();
globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
globals_editor->get_property_editor()->register_text_enter(search_box);
globals_editor->get_property_editor()->set_capitalize_paths(false);
- globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected",this,"_item_selected");
- globals_editor->get_property_editor()->connect("property_toggled",this,"_item_checked",varray(),CONNECT_DEFERRED);
- globals_editor->get_property_editor()->connect("property_edited",this,"_settings_prop_edited");
+ globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected", this, "_item_selected");
+ globals_editor->get_property_editor()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED);
+ globals_editor->get_property_editor()->connect("property_edited", this, "_settings_prop_edited");
-/*
+ /*
Button *save = memnew( Button );
props_base->add_child(save);
@@ -1347,10 +1282,10 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
save->connect("pressed",this,"_save");
*/
- hbc = memnew( HBoxContainer );
+ hbc = memnew(HBoxContainer);
props_base->add_child(hbc);
- popup_platform = memnew( MenuButton );
+ popup_platform = memnew(MenuButton);
popup_platform->set_text(TTR("Copy To Platform.."));
popup_platform->set_disabled(true);
hbc->add_child(popup_platform);
@@ -1367,102 +1302,101 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
}*/
- popup_platform->get_popup()->connect("id_pressed",this,"_copy_to_platform");
+ popup_platform->get_popup()->connect("id_pressed", this, "_copy_to_platform");
get_ok()->set_text(TTR("Close"));
set_hide_on_ok(true);
- message = memnew( ConfirmationDialog );
+ message = memnew(ConfirmationDialog);
add_child(message);
//message->get_cancel()->hide();
message->set_hide_on_ok(true);
- Control *input_base = memnew( Control );
+ Control *input_base = memnew(Control);
input_base->set_name(TTR("Input Map"));
input_base->set_area_as_parent_rect();
tab_container->add_child(input_base);
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
input_base->add_child(vbc);
- vbc->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 5 );
- vbc->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 5 );
- vbc->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 5 );
- vbc->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 5 );
+ vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 5);
+ vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 5);
+ vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5);
+ vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 5);
- l = memnew( Label );
+ l = memnew(Label);
vbc->add_child(l);
- l->set_pos(Point2(6,5));
+ l->set_pos(Point2(6, 5));
l->set_text(TTR("Action:"));
- hbc = memnew( HBoxContainer );
+ hbc = memnew(HBoxContainer);
vbc->add_child(hbc);
- action_name = memnew( LineEdit );
+ action_name = memnew(LineEdit);
action_name->set_h_size_flags(SIZE_EXPAND_FILL);
hbc->add_child(action_name);
- action_name->connect("text_entered",this,"_action_adds");
+ action_name->connect("text_entered", this, "_action_adds");
- add = memnew( Button );
+ add = memnew(Button);
hbc->add_child(add);
add->set_custom_minimum_size(Size2(150, 0));
add->set_text(TTR("Add"));
- add->connect("pressed",this,"_action_add");
+ add->connect("pressed", this, "_action_add");
- input_editor = memnew( Tree );
+ input_editor = memnew(Tree);
vbc->add_child(input_editor);
input_editor->set_v_size_flags(SIZE_EXPAND_FILL);
- input_editor->connect("item_edited",this,"_action_edited");
- input_editor->connect("cell_selected",this,"_action_selected");
- input_editor->connect("button_pressed",this,"_action_button_pressed");
- popup_add = memnew( PopupMenu );
+ input_editor->connect("item_edited", this, "_action_edited");
+ input_editor->connect("cell_selected", this, "_action_selected");
+ input_editor->connect("button_pressed", this, "_action_button_pressed");
+ popup_add = memnew(PopupMenu);
add_child(popup_add);
- popup_add->connect("id_pressed",this,"_add_item");
+ popup_add->connect("id_pressed", this, "_add_item");
- press_a_key = memnew( ConfirmationDialog );
+ press_a_key = memnew(ConfirmationDialog);
press_a_key->set_focus_mode(FOCUS_ALL);
add_child(press_a_key);
- l = memnew( Label );
+ l = memnew(Label);
l->set_text(TTR("Press a Key.."));
l->set_area_as_parent_rect();
l->set_align(Label::ALIGN_CENTER);
- l->set_margin(MARGIN_TOP,20);
- l->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_BEGIN,30);
- press_a_key_label=l;
+ l->set_margin(MARGIN_TOP, 20);
+ l->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 30);
+ press_a_key_label = l;
press_a_key->add_child(l);
- press_a_key->connect("gui_input",this,"_wait_for_key");
- press_a_key->connect("confirmed",this,"_press_a_key_confirm");
-
+ press_a_key->connect("gui_input", this, "_wait_for_key");
+ press_a_key->connect("confirmed", this, "_press_a_key_confirm");
- device_input=memnew( ConfirmationDialog );
+ device_input = memnew(ConfirmationDialog);
add_child(device_input);
device_input->get_ok()->set_text(TTR("Add"));
- device_input->connect("confirmed",this,"_device_input_add");
+ device_input->connect("confirmed", this, "_device_input_add");
- hbc = memnew( HBoxContainer );
+ hbc = memnew(HBoxContainer);
device_input->add_child(hbc);
//device_input->set_child_rect(hbc);
- VBoxContainer *vbc_left = memnew( VBoxContainer );
+ VBoxContainer *vbc_left = memnew(VBoxContainer);
hbc->add_child(vbc_left);
- l = memnew( Label );
+ l = memnew(Label);
l->set_text(TTR("Device:"));
vbc_left->add_child(l);
- device_id = memnew( SpinBox );
+ device_id = memnew(SpinBox);
device_id->set_value(0);
vbc_left->add_child(device_id);
- VBoxContainer *vbc_right = memnew( VBoxContainer );
+ VBoxContainer *vbc_right = memnew(VBoxContainer);
hbc->add_child(vbc_right);
vbc_right->set_h_size_flags(SIZE_EXPAND_FILL);
- l = memnew( Label );
+ l = memnew(Label);
l->set_text(TTR("Index:"));
vbc_right->add_child(l);
- device_index_label=l;
+ device_index_label = l;
- device_index = memnew( OptionButton );
+ device_index = memnew(OptionButton);
vbc_right->add_child(device_index);
/*
@@ -1477,99 +1411,96 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
save->set_text("Save");
save->connect("pressed",this,"_save");
*/
- setting=false;
+ setting = false;
//translations
- TabContainer *translations = memnew( TabContainer );
+ TabContainer *translations = memnew(TabContainer);
translations->set_name(TTR("Localization"));
tab_container->add_child(translations);
{
- VBoxContainer *tvb = memnew( VBoxContainer );
+ VBoxContainer *tvb = memnew(VBoxContainer);
translations->add_child(tvb);
tvb->set_name(TTR("Translations"));
- HBoxContainer *thb = memnew( HBoxContainer);
+ HBoxContainer *thb = memnew(HBoxContainer);
tvb->add_child(thb);
- thb->add_child( memnew( Label(TTR("Translations:"))));
+ thb->add_child(memnew(Label(TTR("Translations:"))));
thb->add_spacer();
- Button *addtr = memnew( Button(TTR("Add..")) );
- addtr->connect("pressed",this,"_translation_file_open");
+ Button *addtr = memnew(Button(TTR("Add..")));
+ addtr->connect("pressed", this, "_translation_file_open");
thb->add_child(addtr);
- MarginContainer *tmc = memnew( MarginContainer );
+ MarginContainer *tmc = memnew(MarginContainer);
tvb->add_child(tmc);
tmc->set_v_size_flags(SIZE_EXPAND_FILL);
- translation_list = memnew( Tree );
+ translation_list = memnew(Tree);
translation_list->set_v_size_flags(SIZE_EXPAND_FILL);
tmc->add_child(translation_list);
- translation_file_open=memnew( EditorFileDialog );
+ translation_file_open = memnew(EditorFileDialog);
add_child(translation_file_open);
translation_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- translation_file_open->connect("file_selected",this,"_translation_add");
-
+ translation_file_open->connect("file_selected", this, "_translation_add");
}
{
- VBoxContainer *tvb = memnew( VBoxContainer );
+ VBoxContainer *tvb = memnew(VBoxContainer);
translations->add_child(tvb);
tvb->set_name(TTR("Remaps"));
- HBoxContainer *thb = memnew( HBoxContainer);
+ HBoxContainer *thb = memnew(HBoxContainer);
tvb->add_child(thb);
- thb->add_child( memnew( Label(TTR("Resources:"))));
+ thb->add_child(memnew(Label(TTR("Resources:"))));
thb->add_spacer();
- Button *addtr = memnew( Button(TTR("Add..")) );
- addtr->connect("pressed",this,"_translation_res_file_open");
+ Button *addtr = memnew(Button(TTR("Add..")));
+ addtr->connect("pressed", this, "_translation_res_file_open");
thb->add_child(addtr);
- MarginContainer *tmc = memnew( MarginContainer );
+ MarginContainer *tmc = memnew(MarginContainer);
tvb->add_child(tmc);
tmc->set_v_size_flags(SIZE_EXPAND_FILL);
- translation_remap = memnew( Tree );
+ translation_remap = memnew(Tree);
translation_remap->set_v_size_flags(SIZE_EXPAND_FILL);
- translation_remap->connect("cell_selected",this,"_translation_res_select");
+ translation_remap->connect("cell_selected", this, "_translation_res_select");
tmc->add_child(translation_remap);
- translation_remap->connect("button_pressed",this,"_translation_res_delete");
+ translation_remap->connect("button_pressed", this, "_translation_res_delete");
- translation_res_file_open=memnew( EditorFileDialog );
+ translation_res_file_open = memnew(EditorFileDialog);
add_child(translation_res_file_open);
translation_res_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- translation_res_file_open->connect("file_selected",this,"_translation_res_add");
+ translation_res_file_open->connect("file_selected", this, "_translation_res_add");
- thb = memnew( HBoxContainer);
+ thb = memnew(HBoxContainer);
tvb->add_child(thb);
- thb->add_child( memnew( Label(TTR("Remaps by Locale:"))));
+ thb->add_child(memnew(Label(TTR("Remaps by Locale:"))));
thb->add_spacer();
- addtr = memnew( Button(TTR("Add..")) );
- addtr->connect("pressed",this,"_translation_res_option_file_open");
- translation_res_option_add_button=addtr;
+ addtr = memnew(Button(TTR("Add..")));
+ addtr->connect("pressed", this, "_translation_res_option_file_open");
+ translation_res_option_add_button = addtr;
thb->add_child(addtr);
- tmc = memnew( MarginContainer );
+ tmc = memnew(MarginContainer);
tvb->add_child(tmc);
tmc->set_v_size_flags(SIZE_EXPAND_FILL);
- translation_remap_options = memnew( Tree );
+ translation_remap_options = memnew(Tree);
translation_remap_options->set_v_size_flags(SIZE_EXPAND_FILL);
tmc->add_child(translation_remap_options);
translation_remap_options->set_columns(2);
- translation_remap_options->set_column_title(0,TTR("Path"));
- translation_remap_options->set_column_title(1,TTR("Locale"));
+ translation_remap_options->set_column_title(0, TTR("Path"));
+ translation_remap_options->set_column_title(1, TTR("Locale"));
translation_remap_options->set_column_titles_visible(true);
- translation_remap_options->set_column_expand(0,true);
- translation_remap_options->set_column_expand(1,false);
- translation_remap_options->set_column_min_width(1,200);
- translation_remap_options->connect("item_edited",this,"_translation_res_option_changed");
- translation_remap_options->connect("button_pressed",this,"_translation_res_option_delete");
+ translation_remap_options->set_column_expand(0, true);
+ translation_remap_options->set_column_expand(1, false);
+ translation_remap_options->set_column_min_width(1, 200);
+ translation_remap_options->connect("item_edited", this, "_translation_res_option_changed");
+ translation_remap_options->connect("button_pressed", this, "_translation_res_option_delete");
- translation_res_option_file_open=memnew( EditorFileDialog );
+ translation_res_option_file_open = memnew(EditorFileDialog);
add_child(translation_res_option_file_open);
translation_res_option_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- translation_res_option_file_open->connect("file_selected",this,"_translation_res_option_add");
-
+ translation_res_option_file_open->connect("file_selected", this, "_translation_res_option_add");
}
-
{
- autoload_settings = memnew( EditorAutoloadSettings );
+ autoload_settings = memnew(EditorAutoloadSettings);
autoload_settings->set_name(TTR("AutoLoad"));
tab_container->add_child(autoload_settings);
autoload_settings->connect("autoload_changed", this, "_settings_changed");
@@ -1577,19 +1508,18 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
{
- plugin_settings = memnew( EditorPluginSettings );
+ plugin_settings = memnew(EditorPluginSettings);
plugin_settings->set_name(TTR("Plugins"));
tab_container->add_child(plugin_settings);
}
- timer = memnew( Timer );
+ timer = memnew(Timer);
timer->set_wait_time(1.5);
- timer->connect("timeout",GlobalConfig::get_singleton(),"save");
+ timer->connect("timeout", GlobalConfig::get_singleton(), "save");
timer->set_one_shot(true);
add_child(timer);
- updating_translations=false;
-
+ updating_translations = false;
/*
Control * es = memnew( Control );
diff --git a/editor/project_settings.h b/editor/project_settings.h
index 96ac2e2c11..892198e00f 100644
--- a/editor/project_settings.h
+++ b/editor/project_settings.h
@@ -29,19 +29,18 @@
#ifndef PROJECT_SETTINGS_H
#define PROJECT_SETTINGS_H
-#include "scene/gui/dialogs.h"
-#include "property_editor.h"
-#include "undo_redo.h"
-#include "editor_data.h"
-#include "scene/gui/tab_container.h"
#include "editor_autoload_settings.h"
+#include "editor_data.h"
#include "editor_plugin_settings.h"
+#include "property_editor.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/tab_container.h"
+#include "undo_redo.h"
//#include "project_export_settings.h"
class ProjectSettings : public AcceptDialog {
- GDCLASS( ProjectSettings, AcceptDialog );
-
+ GDCLASS(ProjectSettings, AcceptDialog);
TabContainer *tab_container;
@@ -65,7 +64,7 @@ class ProjectSettings : public AcceptDialog {
OptionButton *type;
PopupMenu *popup_add;
ConfirmationDialog *press_a_key;
- Label*press_a_key_label;
+ Label *press_a_key_label;
ConfirmationDialog *device_input;
SpinBox *device_id;
OptionButton *device_index;
@@ -82,7 +81,6 @@ class ProjectSettings : public AcceptDialog {
EditorFileDialog *translation_file_open;
Tree *translation_list;
-
Button *translation_res_option_add_button;
EditorFileDialog *translation_res_file_open;
EditorFileDialog *translation_res_option_file_open;
@@ -105,59 +103,53 @@ class ProjectSettings : public AcceptDialog {
void _action_add();
void _device_input_add();
- void _item_checked(const String& p_item, bool p_check);
+ void _item_checked(const String &p_item, bool p_check);
void _action_selected();
void _action_edited();
- void _action_button_pressed(Object* p_obj, int p_column,int p_id);
- void _wait_for_key(const InputEvent& p_event);
+ void _action_button_pressed(Object *p_obj, int p_column, int p_id);
+ void _wait_for_key(const InputEvent &p_event);
void _press_a_key_confirm();
- void _show_last_added(const InputEvent& p_event, const String& p_name);
+ void _show_last_added(const InputEvent &p_event, const String &p_name);
- void _settings_prop_edited(const String& p_name);
+ void _settings_prop_edited(const String &p_name);
void _settings_changed();
//ProjectExportSettings *export_settings;
void _copy_to_platform(int p_which);
-
void _translation_file_open();
- void _translation_add(const String& p_path);
- void _translation_delete(Object *p_item,int p_column, int p_button);
+ void _translation_add(const String &p_path);
+ void _translation_delete(Object *p_item, int p_column, int p_button);
void _update_translations();
void _translation_res_file_open();
- void _translation_res_add(const String& p_path);
- void _translation_res_delete(Object *p_item,int p_column, int p_button);
+ void _translation_res_add(const String &p_path);
+ void _translation_res_delete(Object *p_item, int p_column, int p_button);
void _translation_res_select();
void _translation_res_option_file_open();
- void _translation_res_option_add(const String& p_path);
+ void _translation_res_option_add(const String &p_path);
void _translation_res_option_changed();
- void _translation_res_option_delete(Object *p_item,int p_column, int p_button);
+ void _translation_res_option_delete(Object *p_item, int p_column, int p_button);
void _toggle_search_bar(bool p_pressed);
void _clear_search_box();
-
-
ProjectSettings();
-
static ProjectSettings *singleton;
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
public:
-
- void add_translation(const String& p_translation);
+ void add_translation(const String &p_translation);
static ProjectSettings *get_singleton() { return singleton; }
void popup_project_settings();
void set_plugins_page();
void queue_save();
-
ProjectSettings(EditorData *p_data);
};
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 533a5b156b..f8234d93fd 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -28,37 +28,36 @@
/*************************************************************************/
#include "property_editor.h"
-#include "scene/gui/label.h"
-#include "io/resource_loader.h"
+#include "array_property_edit.h"
+#include "class_db.h"
+#include "create_dialog.h"
+#include "editor_export.h"
+#include "editor_file_system.h"
+#include "editor_help.h"
+#include "editor_node.h"
+#include "editor_settings.h"
+#include "global_config.h"
+#include "global_config.h"
#include "io/image_loader.h"
+#include "io/resource_loader.h"
+#include "multi_node_edit.h"
#include "os/input.h"
#include "os/keyboard.h"
-#include "class_db.h"
+#include "pair.h"
#include "print_string.h"
-#include "global_config.h"
+#include "property_selector.h"
+#include "scene/gui/label.h"
+#include "scene/main/viewport.h"
#include "scene/resources/font.h"
-#include "pair.h"
-#include "scene/scene_string_names.h"
-#include "editor_settings.h"
-#include "editor_export.h"
-#include "editor_node.h"
-#include "multi_node_edit.h"
-#include "array_property_edit.h"
-#include "editor_help.h"
#include "scene/resources/packed_scene.h"
-#include "scene/main/viewport.h"
-#include "editor_file_system.h"
-#include "create_dialog.h"
-#include "property_selector.h"
-#include "global_config.h"
+#include "scene/scene_string_names.h"
void CustomPropertyEditor::_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()));
/*
if (v.get_type()==Variant::COLOR) {
@@ -67,68 +66,63 @@ void CustomPropertyEditor::_notification(int p_what) {
}
}
-
void CustomPropertyEditor::_menu_option(int p_which) {
-
- switch(type) {
+ switch (type) {
case Variant::INT: {
- if (hint==PROPERTY_HINT_FLAGS) {
+ if (hint == PROPERTY_HINT_FLAGS) {
int val = v;
- if (val&(1<<p_which)) {
+ if (val & (1 << p_which)) {
- val&=~(1<<p_which);
+ val &= ~(1 << p_which);
} else {
- val|=(1<<p_which);
+ val |= (1 << p_which);
}
- v=val;
+ v = val;
emit_signal("variant_changed");
- } else if (hint==PROPERTY_HINT_ENUM) {
+ } else if (hint == PROPERTY_HINT_ENUM) {
- v=p_which;
+ v = p_which;
emit_signal("variant_changed");
-
}
} break;
case Variant::STRING: {
- if (hint==PROPERTY_HINT_ENUM) {
+ if (hint == PROPERTY_HINT_ENUM) {
- v=hint_text.get_slice(",",p_which);
+ v = hint_text.get_slice(",", p_which);
emit_signal("variant_changed");
-
}
} break;
case Variant::OBJECT: {
- switch(p_which) {
+ switch (p_which) {
case OBJ_MENU_LOAD: {
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- String type=(hint==PROPERTY_HINT_RESOURCE_TYPE)?hint_text:String();
+ String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String();
List<String> extensions;
- for (int i=0;i<type.get_slice_count(",");i++) {
+ for (int i = 0; i < type.get_slice_count(","); i++) {
- ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",",i),&extensions);
+ ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",", i), &extensions);
}
Set<String> valid_extensions;
- for (List<String>::Element *E=extensions.front();E;E=E->next()) {
- print_line("found: "+E->get());
+ for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
+ print_line("found: " + E->get());
valid_extensions.insert(E->get());
}
file->clear_filters();
- for (Set<String>::Element *E=valid_extensions.front();E;E=E->next()) {
-
- file->add_filter("*."+E->get()+" ; "+E->get().to_upper() );
+ for (Set<String>::Element *E = valid_extensions.front(); E; E = E->next()) {
+ file->add_filter("*." + E->get() + " ; " + E->get().to_upper());
}
file->popup_centered_ratio();
@@ -136,7 +130,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
case OBJ_MENU_EDIT: {
- RefPtr RefPtr=v;
+ RefPtr RefPtr = v;
if (!RefPtr.is_null()) {
@@ -146,32 +140,30 @@ void CustomPropertyEditor::_menu_option(int p_which) {
} break;
case OBJ_MENU_CLEAR: {
-
- v=Variant();
+ v = Variant();
emit_signal("variant_changed");
hide();
} break;
case OBJ_MENU_MAKE_UNIQUE: {
-
- RefPtr RefPtr=v;
+ RefPtr RefPtr = v;
Ref<Resource> res_orig = RefPtr;
if (res_orig.is_null())
return;
List<PropertyInfo> property_list;
res_orig->get_property_list(&property_list);
- List< Pair<String,Variant> > propvalues;
+ List<Pair<String, Variant> > propvalues;
- for(List<PropertyInfo>::Element *E=property_list.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
- Pair<String,Variant> p;
+ Pair<String, Variant> p;
PropertyInfo &pi = E->get();
- if (pi.usage&PROPERTY_USAGE_STORAGE) {
+ if (pi.usage & PROPERTY_USAGE_STORAGE) {
- p.first=pi.name;
- p.second=res_orig->get(pi.name);
+ p.first = pi.name;
+ p.second = res_orig->get(pi.name);
}
propvalues.push_back(p);
@@ -179,19 +171,19 @@ void CustomPropertyEditor::_menu_option(int p_which) {
String orig_type = res_orig->get_class();
- Object *inst = ClassDB::instance( orig_type );
+ Object *inst = ClassDB::instance(orig_type);
- Ref<Resource> res = Ref<Resource>( inst->cast_to<Resource>() );
+ Ref<Resource> res = Ref<Resource>(inst->cast_to<Resource>());
ERR_FAIL_COND(res.is_null());
- for(List< Pair<String,Variant> >::Element *E=propvalues.front();E;E=E->next()) {
+ for (List<Pair<String, Variant> >::Element *E = propvalues.front(); E; E = E->next()) {
- Pair<String,Variant> &p=E->get();
- res->set(p.first,p.second);
+ Pair<String, Variant> &p = E->get();
+ res->set(p.first, p.second);
}
- v=res.get_ref_ptr();
+ v = res.get_ref_ptr();
emit_signal("variant_changed");
hide();
} break;
@@ -203,14 +195,14 @@ void CustomPropertyEditor::_menu_option(int p_which) {
} break;
case OBJ_MENU_PASTE: {
- v=EditorSettings::get_singleton()->get_resource_clipboard();
+ v = EditorSettings::get_singleton()->get_resource_clipboard();
emit_signal("variant_changed");
} break;
case OBJ_MENU_REIMPORT: {
- RES r=v;
-/* if (r.is_valid() && r->get_import_metadata().is_valid()) {
+ RES r = v;
+ /* if (r.is_valid() && r->get_import_metadata().is_valid()) {
Ref<ResourceImportMetadata> rimd = r->get_import_metadata();
Ref<EditorImportPlugin> eip = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor());
if (eip.is_valid()) {
@@ -225,53 +217,45 @@ void CustomPropertyEditor::_menu_option(int p_which) {
} break;
case OBJ_MENU_SHOW_IN_FILE_SYSTEM: {
- RES r=v;
- FileSystemDock *file_system_dock=EditorNode::get_singleton()->get_filesystem_dock();
+ RES r = v;
+ FileSystemDock *file_system_dock = EditorNode::get_singleton()->get_filesystem_dock();
file_system_dock->navigate_to_path(r->get_path());
// Ensure that the FileSystem dock is visible.
- TabContainer* tab_container=(TabContainer*)file_system_dock->get_parent_control();
+ TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control();
tab_container->set_current_tab(file_system_dock->get_position_in_parent());
} break;
default: {
+ ERR_FAIL_COND(inheritors_array.empty());
- ERR_FAIL_COND( inheritors_array.empty() );
-
+ String intype = inheritors_array[p_which - TYPE_BASE_ID];
-
-
- String intype=inheritors_array[p_which-TYPE_BASE_ID];
-
- if (intype=="ViewportTexture") {
+ if (intype == "ViewportTexture") {
scene_tree->set_title(TTR("Pick a Viewport"));
scene_tree->popup_centered_ratio();
- picking_viewport=true;
+ picking_viewport = true;
return;
-
}
Object *obj = ClassDB::instance(intype);
- ERR_BREAK( !obj );
- Resource *res=obj->cast_to<Resource>();
- ERR_BREAK( !res );
- if (owner && hint==PROPERTY_HINT_RESOURCE_TYPE && hint_text=="Script") {
+ ERR_BREAK(!obj);
+ Resource *res = obj->cast_to<Resource>();
+ ERR_BREAK(!res);
+ if (owner && hint == PROPERTY_HINT_RESOURCE_TYPE && hint_text == "Script") {
//make visual script the right type
- res->call("set_instance_base_type",owner->get_class());
+ res->call("set_instance_base_type", owner->get_class());
}
- v=Ref<Resource>(res).get_ref_ptr();
+ v = Ref<Resource>(res).get_ref_ptr();
emit_signal("variant_changed");
} break;
}
-
} break;
- default:{}
+ default: {}
}
-
-
}
void CustomPropertyEditor::hide_menu() {
@@ -288,15 +272,15 @@ String CustomPropertyEditor::get_name() const {
return name;
}
-bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Type p_type, const Variant& p_variant,int p_hint,String p_hint_text) {
+bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::Type p_type, const Variant &p_variant, int p_hint, String p_hint_text) {
- owner=p_owner;
- updating=true;
- name=p_name;
- v=p_variant;
+ owner = p_owner;
+ updating = true;
+ name = p_name;
+ v = p_variant;
field_names.clear();
- hint=p_hint;
- hint_text=p_hint_text;
+ hint = p_hint;
+ hint_text = p_hint_text;
type_button->hide();
if (color_picker)
color_picker->hide();
@@ -307,245 +291,251 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
spinbox->hide();
slider->hide();
- for (int i=0;i<MAX_VALUE_EDITORS;i++) {
+ for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
value_editor[i]->hide();
value_label[i]->hide();
- if (i<4)
+ if (i < 4)
scroll[i]->hide();
}
- for (int i=0;i<MAX_ACTION_BUTTONS;i++) {
+ for (int i = 0; i < MAX_ACTION_BUTTONS; i++) {
action_buttons[i]->hide();
}
checks20gc->hide();
- for(int i=0;i<20;i++)
+ for (int i = 0; i < 20; i++)
checks20[i]->hide();
- type = (p_variant.get_type()!=Variant::NIL && p_variant.get_type()!=Variant::_RID && p_type!=Variant::OBJECT)? p_variant.get_type() : p_type;
+ type = (p_variant.get_type() != Variant::NIL && p_variant.get_type() != Variant::_RID && p_type != Variant::OBJECT) ? p_variant.get_type() : p_type;
-
- switch(type) {
+ switch (type) {
case Variant::BOOL: {
checks20gc->show();
- CheckBox *c=checks20[0];
+ CheckBox *c = checks20[0];
c->set_text("True");
- checks20gc->set_pos(Vector2(4,4));
+ checks20gc->set_pos(Vector2(4, 4));
c->set_pressed(v);
c->show();
checks20gc->set_size(checks20gc->get_minimum_size());
- set_size(checks20gc->get_pos()+checks20gc->get_size()+Vector2(4,4)*EDSCALE);
+ set_size(checks20gc->get_pos() + checks20gc->get_size() + Vector2(4, 4) * EDSCALE);
} break;
case Variant::INT:
case Variant::REAL: {
- if (hint==PROPERTY_HINT_RANGE) {
+ if (hint == PROPERTY_HINT_RANGE) {
int c = hint_text.get_slice_count(",");
- float min=0,max=100,step=1;
- if (c>=1) {
+ float min = 0, max = 100, step = 1;
+ if (c >= 1) {
- if (!hint_text.get_slice(",",0).empty())
- min=hint_text.get_slice(",",0).to_double();
+ if (!hint_text.get_slice(",", 0).empty())
+ min = hint_text.get_slice(",", 0).to_double();
}
- if (c>=2) {
+ if (c >= 2) {
- if (!hint_text.get_slice(",",1).empty())
- max=hint_text.get_slice(",",1).to_double();
+ if (!hint_text.get_slice(",", 1).empty())
+ max = hint_text.get_slice(",", 1).to_double();
}
- if (c>=3) {
+ if (c >= 3) {
- if (!hint_text.get_slice(",",2).empty())
- step= hint_text.get_slice(",",2).to_double();
+ if (!hint_text.get_slice(",", 2).empty())
+ step = hint_text.get_slice(",", 2).to_double();
}
- if (c>=4 && hint_text.get_slice(",",3)=="slider") {
+ if (c >= 4 && hint_text.get_slice(",", 3) == "slider") {
slider->set_min(min);
slider->set_max(max);
slider->set_step(step);
slider->set_value(v);
slider->show();
- set_size(Size2(110,30)*EDSCALE);
+ set_size(Size2(110, 30) * EDSCALE);
} else {
spinbox->set_min(min);
spinbox->set_max(max);
spinbox->set_step(step);
spinbox->set_value(v);
spinbox->show();
- set_size(Size2(70,35)*EDSCALE);
+ set_size(Size2(70, 35) * EDSCALE);
}
- } else if (hint==PROPERTY_HINT_ENUM) {
+ } else if (hint == PROPERTY_HINT_ENUM) {
menu->clear();
Vector<String> options = hint_text.split(",");
- for(int i=0;i<options.size();i++) {
- menu->add_item(options[i],i);
+ for (int i = 0; i < options.size(); i++) {
+ menu->add_item(options[i], i);
}
menu->set_pos(get_pos());
menu->popup();
hide();
- updating=false;
+ updating = false;
return false;
-
- } else if (hint==PROPERTY_HINT_LAYERS_2D_PHYSICS || hint==PROPERTY_HINT_LAYERS_2D_RENDER || hint==PROPERTY_HINT_LAYERS_3D_PHYSICS || hint==PROPERTY_HINT_LAYERS_3D_RENDER) {
-
+ } else if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || hint == PROPERTY_HINT_LAYERS_2D_RENDER || hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || hint == PROPERTY_HINT_LAYERS_3D_RENDER) {
String title;
String basename;
switch (hint) {
- case PROPERTY_HINT_LAYERS_2D_RENDER: basename="layer_names/2d_render"; title="2D Render Layers"; break;
- case PROPERTY_HINT_LAYERS_2D_PHYSICS: basename="layer_names/2d_physics"; title="2D Physics Layers"; break;
- case PROPERTY_HINT_LAYERS_3D_RENDER: basename="layer_names/3d_render"; title="3D Render Layers"; break;
- case PROPERTY_HINT_LAYERS_3D_PHYSICS: basename="layer_names/3d_physics";title="3D Physics Layers"; break;
+ case PROPERTY_HINT_LAYERS_2D_RENDER:
+ basename = "layer_names/2d_render";
+ title = "2D Render Layers";
+ break;
+ case PROPERTY_HINT_LAYERS_2D_PHYSICS:
+ basename = "layer_names/2d_physics";
+ title = "2D Physics Layers";
+ break;
+ case PROPERTY_HINT_LAYERS_3D_RENDER:
+ basename = "layer_names/3d_render";
+ title = "3D Render Layers";
+ break;
+ case PROPERTY_HINT_LAYERS_3D_PHYSICS:
+ basename = "layer_names/3d_physics";
+ title = "3D Physics Layers";
+ break;
}
checks20gc->show();
uint32_t flgs = v;
- for(int i=0;i<2;i++) {
+ for (int i = 0; i < 2; i++) {
- Point2 ofs(4,4);
- ofs.y+=22*i;
- for(int j=0;j<10;j++) {
+ Point2 ofs(4, 4);
+ ofs.y += 22 * i;
+ for (int j = 0; j < 10; j++) {
- int idx = i*10+j;
- CheckBox *c=checks20[idx];
- c->set_text(GlobalConfig::get_singleton()->get(basename+"/layer_"+itos(idx+1)));
- c->set_pressed( flgs & (1<<(i*10+j)) );
+ int idx = i * 10 + j;
+ CheckBox *c = checks20[idx];
+ c->set_text(GlobalConfig::get_singleton()->get(basename + "/layer_" + itos(idx + 1)));
+ c->set_pressed(flgs & (1 << (i * 10 + j)));
c->show();
}
-
-
}
show();
value_label[0]->set_text(title);
value_label[0]->show();
- value_label[0]->set_pos(Vector2(4,4)*EDSCALE);
+ value_label[0]->set_pos(Vector2(4, 4) * EDSCALE);
- checks20gc->set_pos(Vector2(4,4)*EDSCALE+Vector2(0,value_label[0]->get_size().height+4*EDSCALE));
+ checks20gc->set_pos(Vector2(4, 4) * EDSCALE + Vector2(0, value_label[0]->get_size().height + 4 * EDSCALE));
checks20gc->set_size(checks20gc->get_minimum_size());
- set_size(Vector2(4,4)*EDSCALE+checks20gc->get_pos()+checks20gc->get_size());
+ set_size(Vector2(4, 4) * EDSCALE + checks20gc->get_pos() + checks20gc->get_size());
+ } else if (hint == PROPERTY_HINT_EXP_EASING) {
- } else if (hint==PROPERTY_HINT_EXP_EASING) {
-
- easing_draw->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
- easing_draw->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
- easing_draw->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,5);
- easing_draw->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,30);
- type_button->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,3);
- type_button->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,3);
- type_button->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,25);
- type_button->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,7);
+ easing_draw->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5);
+ easing_draw->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 5);
+ easing_draw->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 5);
+ easing_draw->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 30);
+ type_button->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 3);
+ type_button->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 3);
+ type_button->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, 25);
+ type_button->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 7);
type_button->set_text(TTR("Preset.."));
type_button->get_popup()->clear();
- type_button->get_popup()->add_item(TTR("Linear"),EASING_LINEAR);
- type_button->get_popup()->add_item(TTR("Ease In"),EASING_EASE_IN);
- type_button->get_popup()->add_item(TTR("Ease Out"),EASING_EASE_OUT);
- if (hint_text!="attenuation") {
- type_button->get_popup()->add_item(TTR("Zero"),EASING_ZERO);
- type_button->get_popup()->add_item(TTR("Easing In-Out"),EASING_IN_OUT);
- type_button->get_popup()->add_item(TTR("Easing Out-In"),EASING_OUT_IN);
+ type_button->get_popup()->add_item(TTR("Linear"), EASING_LINEAR);
+ type_button->get_popup()->add_item(TTR("Ease In"), EASING_EASE_IN);
+ type_button->get_popup()->add_item(TTR("Ease Out"), EASING_EASE_OUT);
+ if (hint_text != "attenuation") {
+ type_button->get_popup()->add_item(TTR("Zero"), EASING_ZERO);
+ type_button->get_popup()->add_item(TTR("Easing In-Out"), EASING_IN_OUT);
+ type_button->get_popup()->add_item(TTR("Easing Out-In"), EASING_OUT_IN);
}
type_button->show();
easing_draw->show();
- set_size(Size2(200,150)*EDSCALE);
- } else if (hint==PROPERTY_HINT_FLAGS) {
+ set_size(Size2(200, 150) * EDSCALE);
+ } else if (hint == PROPERTY_HINT_FLAGS) {
menu->clear();
Vector<String> flags = hint_text.split(",");
- for(int i=0;i<flags.size();i++) {
+ for (int i = 0; i < flags.size(); i++) {
String flag = flags[i];
- if (flag=="")
+ if (flag == "")
continue;
- menu->add_check_item(flag,i);
+ menu->add_check_item(flag, i);
int f = v;
- if (f&(1<<i))
- menu->set_item_checked(menu->get_item_index(i),true);
+ if (f & (1 << i))
+ menu->set_item_checked(menu->get_item_index(i), true);
}
menu->set_pos(get_pos());
menu->popup();
hide();
- updating=false;
+ updating = false;
return false;
} else {
List<String> names;
names.push_back("value:");
- config_value_editors(1,1,50,names);
- value_editor[0]->set_text( String::num(v) );
+ config_value_editors(1, 1, 50, names);
+ value_editor[0]->set_text(String::num(v));
}
} break;
case Variant::STRING: {
- if (hint==PROPERTY_HINT_FILE || hint==PROPERTY_HINT_GLOBAL_FILE) {
+ if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_GLOBAL_FILE) {
List<String> names;
names.push_back(TTR("File.."));
names.push_back(TTR("Clear"));
config_action_buttons(names);
- } else if (hint==PROPERTY_HINT_DIR || hint==PROPERTY_HINT_GLOBAL_DIR) {
+ } else if (hint == PROPERTY_HINT_DIR || hint == PROPERTY_HINT_GLOBAL_DIR) {
List<String> names;
names.push_back(TTR("Dir.."));
names.push_back(TTR("Clear"));
config_action_buttons(names);
- } else if (hint==PROPERTY_HINT_ENUM) {
+ } else if (hint == PROPERTY_HINT_ENUM) {
menu->clear();
Vector<String> options = hint_text.split(",");
- for(int i=0;i<options.size();i++) {
- menu->add_item(options[i],i);
+ for (int i = 0; i < options.size(); i++) {
+ menu->add_item(options[i], i);
}
menu->set_pos(get_pos());
menu->popup();
hide();
- updating=false;
+ updating = false;
return false;
- } else if (hint==PROPERTY_HINT_MULTILINE_TEXT) {
+ } else if (hint == PROPERTY_HINT_MULTILINE_TEXT) {
text_edit->show();
text_edit->set_text(v);
//action_buttons[0];
- int button_margin = get_constant("button_margin","Dialogs");
- int margin = get_constant("margin","Dialogs");
+ int button_margin = get_constant("button_margin", "Dialogs");
+ int margin = get_constant("margin", "Dialogs");
- action_buttons[0]->set_anchor( MARGIN_LEFT, ANCHOR_END );
- action_buttons[0]->set_anchor( MARGIN_TOP, ANCHOR_END );
- action_buttons[0]->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- action_buttons[0]->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
- action_buttons[0]->set_begin( Point2( 70, button_margin-5 ) );
- action_buttons[0]->set_end( Point2( margin, margin ) );
+ action_buttons[0]->set_anchor(MARGIN_LEFT, ANCHOR_END);
+ action_buttons[0]->set_anchor(MARGIN_TOP, ANCHOR_END);
+ action_buttons[0]->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ action_buttons[0]->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
+ action_buttons[0]->set_begin(Point2(70, button_margin - 5));
+ action_buttons[0]->set_end(Point2(margin, margin));
action_buttons[0]->set_text(TTR("Close"));
action_buttons[0]->show();
- } else if (hint==PROPERTY_HINT_TYPE_STRING) {
+ } else if (hint == PROPERTY_HINT_TYPE_STRING) {
/* FIXME: This is repeated twice, with slightly different behavior! Which one? Check line 644 */
if (!create_dialog) {
- create_dialog = memnew( CreateDialog );
- create_dialog->connect("create",this,"_create_dialog_callback");
+ create_dialog = memnew(CreateDialog);
+ create_dialog->connect("create", this, "_create_dialog_callback");
add_child(create_dialog);
}
- if (hint_text!=String()) {
+ if (hint_text != String()) {
create_dialog->set_base_type(hint_text);
} else {
create_dialog->set_base_type("Object");
@@ -553,119 +543,124 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
create_dialog->popup(false);
hide();
- updating=false;
+ updating = false;
return false;
-
- } else if (hint==PROPERTY_HINT_METHOD_OF_VARIANT_TYPE) {
-#define MAKE_PROPSELECT if (!property_select) { property_select = memnew(PropertySelector); property_select->connect("selected",this,"_create_selected_property"); add_child(property_select); } hide();
+ } else if (hint == PROPERTY_HINT_METHOD_OF_VARIANT_TYPE) {
+#define MAKE_PROPSELECT \
+ if (!property_select) { \
+ property_select = memnew(PropertySelector); \
+ property_select->connect("selected", this, "_create_selected_property"); \
+ add_child(property_select); \
+ } \
+ hide();
MAKE_PROPSELECT;
- Variant::Type type=Variant::NIL;
- for(int i=0;i<Variant::VARIANT_MAX;i++) {
- if (hint_text==Variant::get_type_name(Variant::Type(i))) {
- type=Variant::Type(i);
+ Variant::Type type = Variant::NIL;
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
+ if (hint_text == Variant::get_type_name(Variant::Type(i))) {
+ type = Variant::Type(i);
}
}
if (type)
- property_select->select_method_from_basic_type(type,v);
- updating=false;
+ property_select->select_method_from_basic_type(type, v);
+ updating = false;
return false;
- } else if (hint==PROPERTY_HINT_METHOD_OF_BASE_TYPE) {
+ } else if (hint == PROPERTY_HINT_METHOD_OF_BASE_TYPE) {
MAKE_PROPSELECT
- property_select->select_method_from_base_type(hint_text,v);
+ property_select->select_method_from_base_type(hint_text, v);
- updating=false;
+ updating = false;
return false;
- } else if (hint==PROPERTY_HINT_METHOD_OF_INSTANCE) {
+ } else if (hint == PROPERTY_HINT_METHOD_OF_INSTANCE) {
MAKE_PROPSELECT
Object *instance = ObjectDB::get_instance(hint_text.to_int64());
if (instance)
- property_select->select_method_from_instance(instance,v);
- updating=false;
+ property_select->select_method_from_instance(instance, v);
+ updating = false;
return false;
- } else if (hint==PROPERTY_HINT_METHOD_OF_SCRIPT) {
+ } else if (hint == PROPERTY_HINT_METHOD_OF_SCRIPT) {
MAKE_PROPSELECT
Object *obj = ObjectDB::get_instance(hint_text.to_int64());
if (obj && obj->cast_to<Script>()) {
- property_select->select_method_from_script(obj->cast_to<Script>(),v);
+ property_select->select_method_from_script(obj->cast_to<Script>(), v);
}
- updating=false;
+ updating = false;
return false;
- } else if (hint==PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE) {
+ } else if (hint == PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE) {
MAKE_PROPSELECT
- Variant::Type type=Variant::NIL;
- String tname=hint_text;
- if (tname.find(".")!=-1)
- tname=tname.get_slice(".",0);
- for(int i=0;i<Variant::VARIANT_MAX;i++) {
- if (tname==Variant::get_type_name(Variant::Type(i))) {
- type=Variant::Type(Variant::Type(i));
+ Variant::Type type = Variant::NIL;
+ String tname = hint_text;
+ if (tname.find(".") != -1)
+ tname = tname.get_slice(".", 0);
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
+ if (tname == Variant::get_type_name(Variant::Type(i))) {
+ type = Variant::Type(Variant::Type(i));
}
}
InputEvent::Type iet = InputEvent::NONE;
- if (hint_text.find(".")!=-1) {
- iet=InputEvent::Type(int(hint_text.get_slice(".",1).to_int()));
+ if (hint_text.find(".") != -1) {
+ iet = InputEvent::Type(int(hint_text.get_slice(".", 1).to_int()));
}
if (type)
- property_select->select_property_from_basic_type(type,iet,v);
+ property_select->select_property_from_basic_type(type, iet, v);
- updating=false;
+ updating = false;
return false;
- } else if (hint==PROPERTY_HINT_PROPERTY_OF_BASE_TYPE) {
+ } else if (hint == PROPERTY_HINT_PROPERTY_OF_BASE_TYPE) {
MAKE_PROPSELECT
- property_select->select_property_from_base_type(hint_text,v);
+ property_select->select_property_from_base_type(hint_text, v);
- updating=false;
+ updating = false;
return false;
- } else if (hint==PROPERTY_HINT_PROPERTY_OF_INSTANCE) {
+ } else if (hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE) {
Object *instance = ObjectDB::get_instance(hint_text.to_int64());
if (instance)
- property_select->select_property_from_instance(instance,v);
+ property_select->select_property_from_instance(instance, v);
- updating=false;
+ updating = false;
return false;
- } else if (hint==PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
+ } else if (hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
MAKE_PROPSELECT
Object *obj = ObjectDB::get_instance(hint_text.to_int64());
if (obj && obj->cast_to<Script>()) {
- property_select->select_property_from_script(obj->cast_to<Script>(),v);
+ property_select->select_property_from_script(obj->cast_to<Script>(), v);
}
- updating=false;
+ updating = false;
return false;
- } else if (hint==PROPERTY_HINT_TYPE_STRING) {
+ } else if (hint == PROPERTY_HINT_TYPE_STRING) {
if (!create_dialog) {
/* FIXME: ... and here. See line 529 */
- create_dialog = memnew( CreateDialog );
- create_dialog->connect("create",this,"_create_dialog_callback");
+ create_dialog = memnew(CreateDialog);
+ create_dialog->connect("create", this, "_create_dialog_callback");
add_child(create_dialog);
}
} else {
List<String> names;
names.push_back("string:");
- config_value_editors(1,1,50,names);
- value_editor[0]->set_text( v );
+ config_value_editors(1, 1, 50, names);
+ value_editor[0]->set_text(v);
}
} break;
@@ -673,10 +668,10 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
field_names.push_back("x");
field_names.push_back("y");
- config_value_editors(2,2,10,field_names);
- Vector2 vec=v;
- value_editor[0]->set_text( String::num( vec.x) );
- value_editor[1]->set_text( String::num( vec.y) );
+ config_value_editors(2, 2, 10, field_names);
+ Vector2 vec = v;
+ value_editor[0]->set_text(String::num(vec.x));
+ value_editor[1]->set_text(String::num(vec.y));
} break;
case Variant::RECT2: {
@@ -684,23 +679,23 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
field_names.push_back("y");
field_names.push_back("w");
field_names.push_back("h");
- config_value_editors(4,4,10,field_names);
- Rect2 r=v;
- value_editor[0]->set_text( String::num( r.pos.x) );
- value_editor[1]->set_text( String::num( r.pos.y) );
- value_editor[2]->set_text( String::num( r.size.x) );
- value_editor[3]->set_text( String::num( r.size.y) );
+ config_value_editors(4, 4, 10, field_names);
+ Rect2 r = v;
+ value_editor[0]->set_text(String::num(r.pos.x));
+ value_editor[1]->set_text(String::num(r.pos.y));
+ value_editor[2]->set_text(String::num(r.size.x));
+ value_editor[3]->set_text(String::num(r.size.y));
} break;
case Variant::VECTOR3: {
field_names.push_back("x");
field_names.push_back("y");
field_names.push_back("z");
- config_value_editors(3,3,10,field_names);
- Vector3 vec=v;
- value_editor[0]->set_text( String::num( vec.x) );
- value_editor[1]->set_text( String::num( vec.y) );
- value_editor[2]->set_text( String::num( vec.z) );
+ config_value_editors(3, 3, 10, field_names);
+ Vector3 vec = v;
+ value_editor[0]->set_text(String::num(vec.x));
+ value_editor[1]->set_text(String::num(vec.y));
+ value_editor[2]->set_text(String::num(vec.z));
} break;
case Variant::PLANE: {
@@ -708,12 +703,12 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
field_names.push_back("y");
field_names.push_back("z");
field_names.push_back("d");
- config_value_editors(4,4,10,field_names);
- Plane plane=v;
- value_editor[0]->set_text( String::num( plane.normal.x ) );
- value_editor[1]->set_text( String::num( plane.normal.y ) );
- value_editor[2]->set_text( String::num( plane.normal.z ) );
- value_editor[3]->set_text( String::num( plane.d ) );
+ config_value_editors(4, 4, 10, field_names);
+ Plane plane = v;
+ value_editor[0]->set_text(String::num(plane.normal.x));
+ value_editor[1]->set_text(String::num(plane.normal.y));
+ value_editor[2]->set_text(String::num(plane.normal.z));
+ value_editor[3]->set_text(String::num(plane.d));
} break;
case Variant::QUAT: {
@@ -722,12 +717,12 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
field_names.push_back("y");
field_names.push_back("z");
field_names.push_back("w");
- config_value_editors(4,4,10,field_names);
- Quat q=v;
- value_editor[0]->set_text( String::num( q.x ) );
- value_editor[1]->set_text( String::num( q.y ) );
- value_editor[2]->set_text( String::num( q.z ) );
- value_editor[3]->set_text( String::num( q.w ) );
+ config_value_editors(4, 4, 10, field_names);
+ Quat q = v;
+ value_editor[0]->set_text(String::num(q.x));
+ value_editor[1]->set_text(String::num(q.y));
+ value_editor[2]->set_text(String::num(q.z));
+ value_editor[3]->set_text(String::num(q.w));
} break;
case Variant::RECT3: {
@@ -738,15 +733,15 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
field_names.push_back("sx");
field_names.push_back("sy");
field_names.push_back("sz");
- config_value_editors(6,3,16,field_names);
+ config_value_editors(6, 3, 16, field_names);
- Rect3 aabb=v;
- value_editor[0]->set_text( String::num( aabb.pos.x ) );
- value_editor[1]->set_text( String::num( aabb.pos.y ) );
- value_editor[2]->set_text( String::num( aabb.pos.z ) );
- value_editor[3]->set_text( String::num( aabb.size.x ) );
- value_editor[4]->set_text( String::num( aabb.size.y ) );
- value_editor[5]->set_text( String::num( aabb.size.z ) );
+ Rect3 aabb = v;
+ value_editor[0]->set_text(String::num(aabb.pos.x));
+ value_editor[1]->set_text(String::num(aabb.pos.y));
+ value_editor[2]->set_text(String::num(aabb.pos.z));
+ value_editor[3]->set_text(String::num(aabb.size.x));
+ value_editor[4]->set_text(String::num(aabb.size.y));
+ value_editor[5]->set_text(String::num(aabb.size.z));
} break;
case Variant::TRANSFORM2D: {
@@ -757,12 +752,12 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
field_names.push_back("yy");
field_names.push_back("ox");
field_names.push_back("oy");
- config_value_editors(6,2,16,field_names);
+ config_value_editors(6, 2, 16, field_names);
- Transform2D basis=v;
- for(int i=0;i<6;i++) {
+ Transform2D basis = v;
+ for (int i = 0; i < 6; i++) {
- value_editor[i]->set_text( String::num( basis.elements[i/2][i%2] ) );
+ value_editor[i]->set_text(String::num(basis.elements[i / 2][i % 2]));
}
} break;
@@ -777,18 +772,17 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
field_names.push_back("zx");
field_names.push_back("zy");
field_names.push_back("zz");
- config_value_editors(9,3,16,field_names);
+ config_value_editors(9, 3, 16, field_names);
- Basis basis=v;
- for(int i=0;i<9;i++) {
+ Basis basis = v;
+ for (int i = 0; i < 9; i++) {
- value_editor[i]->set_text( String::num( basis.elements[i/3][i%3] ) );
+ value_editor[i]->set_text(String::num(basis.elements[i / 3][i % 3]));
}
} break;
case Variant::TRANSFORM: {
-
field_names.push_back("xx");
field_names.push_back("xy");
field_names.push_back("xz");
@@ -801,36 +795,36 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
field_names.push_back("zy");
field_names.push_back("zz");
field_names.push_back("zo");
- config_value_editors(12,4,16,field_names);
+ config_value_editors(12, 4, 16, field_names);
- Transform tr=v;
- for(int i=0;i<9;i++) {
+ Transform tr = v;
+ for (int i = 0; i < 9; i++) {
- value_editor[(i/3)*4+i%3]->set_text( String::num( tr.basis.elements[i/3][i%3] ) );
+ value_editor[(i / 3) * 4 + i % 3]->set_text(String::num(tr.basis.elements[i / 3][i % 3]));
}
- value_editor[3]->set_text( String::num( tr.origin.x ) );
- value_editor[7]->set_text( String::num( tr.origin.y ) );
- value_editor[11]->set_text( String::num( tr.origin.z ) );
+ value_editor[3]->set_text(String::num(tr.origin.x));
+ value_editor[7]->set_text(String::num(tr.origin.y));
+ value_editor[11]->set_text(String::num(tr.origin.z));
} break;
case Variant::COLOR: {
if (!color_picker) {
//late init for performance
- color_picker = memnew( ColorPicker );
+ color_picker = memnew(ColorPicker);
add_child(color_picker);
color_picker->hide();
color_picker->set_area_as_parent_rect();
- for(int i=0;i<4;i++)
- color_picker->set_margin((Margin)i,5);
- color_picker->connect("color_changed",this,"_color_changed");
+ for (int i = 0; i < 4; i++)
+ color_picker->set_margin((Margin)i, 5);
+ color_picker->connect("color_changed", this, "_color_changed");
}
color_picker->show();
- color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA);
+ color_picker->set_edit_alpha(hint != PROPERTY_HINT_COLOR_NO_ALPHA);
color_picker->set_pick_color(v);
- set_size( Size2(300*EDSCALE, color_picker->get_combined_minimum_size().height+10*EDSCALE));
+ set_size(Size2(300 * EDSCALE, color_picker->get_combined_minimum_size().height + 10 * EDSCALE));
color_picker->set_focus_on_line_edit();
/*
int ofs=80;
@@ -886,69 +880,62 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} break;
case Variant::OBJECT: {
- if (hint!=PROPERTY_HINT_RESOURCE_TYPE)
+ if (hint != PROPERTY_HINT_RESOURCE_TYPE)
break;
-
menu->clear();
- menu->set_size(Size2(1,1));
+ menu->set_size(Size2(1, 1));
- if (p_name=="script" && hint_text=="Script" && owner->cast_to<Node>()) {
- menu->add_icon_item(get_icon("Script","EditorIcons"),TTR("New Script"),OBJ_MENU_NEW_SCRIPT);
+ if (p_name == "script" && hint_text == "Script" && owner->cast_to<Node>()) {
+ menu->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT);
menu->add_separator();
- } else if (hint_text!="") {
- int idx=0;
-
- for(int i=0;i<hint_text.get_slice_count(",");i++) {
+ } else if (hint_text != "") {
+ int idx = 0;
+ for (int i = 0; i < hint_text.get_slice_count(","); i++) {
-
- String base=hint_text.get_slice(",",i);
+ String base = hint_text.get_slice(",", i);
Set<String> valid_inheritors;
valid_inheritors.insert(base);
List<StringName> inheritors;
- ClassDB::get_inheriters_from_class(base.strip_edges(),&inheritors);
- List<StringName>::Element *E=inheritors.front();
- while(E) {
+ ClassDB::get_inheriters_from_class(base.strip_edges(), &inheritors);
+ List<StringName>::Element *E = inheritors.front();
+ while (E) {
valid_inheritors.insert(E->get());
- E=E->next();
+ E = E->next();
}
- for(Set<String>::Element *E=valid_inheritors.front();E;E=E->next()) {
+ for (Set<String>::Element *E = valid_inheritors.front(); E; E = E->next()) {
String t = E->get();
if (!ClassDB::can_instance(t))
continue;
inheritors_array.push_back(t);
- int id = TYPE_BASE_ID+idx;
- if (has_icon(t,"EditorIcons")) {
+ int id = TYPE_BASE_ID + idx;
+ if (has_icon(t, "EditorIcons")) {
- menu->add_icon_item(get_icon(t,"EditorIcons"),TTR("New")+" "+t,id);
+ menu->add_icon_item(get_icon(t, "EditorIcons"), TTR("New") + " " + t, id);
} else {
- menu->add_item(TTR("New")+" "+t,id);
+ menu->add_item(TTR("New") + " " + t, id);
}
idx++;
}
-
-
}
if (menu->get_item_count())
menu->add_separator();
}
- menu->add_icon_item(get_icon("Load","EditorIcons"),"Load",OBJ_MENU_LOAD);
+ menu->add_icon_item(get_icon("Load", "EditorIcons"), "Load", OBJ_MENU_LOAD);
if (!RES(v).is_null()) {
-
-
- menu->add_icon_item(get_icon("EditResource","EditorIcons"),"Edit",OBJ_MENU_EDIT);
- menu->add_icon_item(get_icon("Del","EditorIcons"),"Clear",OBJ_MENU_CLEAR);
- menu->add_icon_item(get_icon("Duplicate","EditorIcons"),"Make Unique",OBJ_MENU_MAKE_UNIQUE);
+ menu->add_icon_item(get_icon("EditResource", "EditorIcons"), "Edit", OBJ_MENU_EDIT);
+ menu->add_icon_item(get_icon("Del", "EditorIcons"), "Clear", OBJ_MENU_CLEAR);
+ menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), "Make Unique", OBJ_MENU_MAKE_UNIQUE);
RES r = v;
if (r.is_valid() && r->get_path().is_resource_file()) {
/*if (r->get_import_metadata().is_valid()) {
@@ -956,7 +943,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
menu->add_icon_item(get_icon("ReloadSmall","EditorIcons"),"Re-Import",OBJ_MENU_REIMPORT);
}*/
menu->add_separator();
- menu->add_item(TTR("Show in File System"),OBJ_MENU_SHOW_IN_FILE_SYSTEM);
+ menu->add_item(TTR("Show in File System"), OBJ_MENU_SHOW_IN_FILE_SYSTEM);
}
/*if (r.is_valid() && r->get_path().is_resource_file()) {
menu->set_item_tooltip(1,r->get_path());
@@ -964,19 +951,17 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
menu->set_item_tooltip(1,r->get_name()+" ("+r->get_type()+")");
}*/
} else {
-
}
-
- RES cb=EditorSettings::get_singleton()->get_resource_clipboard();
- bool paste_valid=false;
+ RES cb = EditorSettings::get_singleton()->get_resource_clipboard();
+ bool paste_valid = false;
if (cb.is_valid()) {
- if (hint_text=="")
- paste_valid=true;
+ if (hint_text == "")
+ paste_valid = true;
else
- for (int i = 0; i < hint_text.get_slice_count(",");i++)
- if (ClassDB::is_parent_class(cb->get_class(),hint_text.get_slice(",",i))) {
- paste_valid=true;
+ for (int i = 0; i < hint_text.get_slice_count(","); i++)
+ if (ClassDB::is_parent_class(cb->get_class(), hint_text.get_slice(",", i))) {
+ paste_valid = true;
break;
}
}
@@ -984,64 +969,52 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
if (!RES(v).is_null() || paste_valid) {
menu->add_separator();
-
if (!RES(v).is_null()) {
- menu->add_item(TTR("Copy"),OBJ_MENU_COPY);
+ menu->add_item(TTR("Copy"), OBJ_MENU_COPY);
}
if (paste_valid) {
- menu->add_item(TTR("Paste"),OBJ_MENU_PASTE);
+ menu->add_item(TTR("Paste"), OBJ_MENU_PASTE);
}
}
-
-
menu->set_pos(get_pos());
menu->popup();
hide();
- updating=false;
+ updating = false;
return false;
-
} break;
case Variant::INPUT_EVENT: {
-
} break;
case Variant::DICTIONARY: {
-
} break;
case Variant::POOL_BYTE_ARRAY: {
-
} break;
case Variant::POOL_INT_ARRAY: {
-
} break;
case Variant::POOL_REAL_ARRAY: {
-
} break;
case Variant::POOL_STRING_ARRAY: {
-
} break;
case Variant::POOL_VECTOR3_ARRAY: {
-
} break;
case Variant::POOL_COLOR_ARRAY: {
-
} break;
default: {}
}
- updating=false;
+ updating = false;
return true;
}
@@ -1055,20 +1028,20 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
void CustomPropertyEditor::_file_selected(String p_file) {
- switch(type) {
+ switch (type) {
case Variant::STRING: {
- if (hint==PROPERTY_HINT_FILE || hint==PROPERTY_HINT_DIR) {
+ if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_DIR) {
- v=GlobalConfig::get_singleton()->localize_path(p_file);
+ v = GlobalConfig::get_singleton()->localize_path(p_file);
emit_signal("variant_changed");
hide();
}
- if (hint==PROPERTY_HINT_GLOBAL_FILE || hint==PROPERTY_HINT_GLOBAL_DIR) {
+ if (hint == PROPERTY_HINT_GLOBAL_FILE || hint == PROPERTY_HINT_GLOBAL_DIR) {
- v=p_file;
+ v = p_file;
emit_signal("variant_changed");
hide();
}
@@ -1076,25 +1049,25 @@ void CustomPropertyEditor::_file_selected(String p_file) {
} break;
case Variant::OBJECT: {
- String type=(hint==PROPERTY_HINT_RESOURCE_TYPE)?hint_text:String();
+ String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String();
- RES res = ResourceLoader::load(p_file,type);
+ RES res = ResourceLoader::load(p_file, type);
if (res.is_null()) {
error->set_text(TTR("Error loading file: Not a resource!"));
error->popup_centered_minsize();
break;
}
- v=res.get_ref_ptr();
+ v = res.get_ref_ptr();
emit_signal("variant_changed");
hide();
} break;
case Variant::IMAGE: {
Image image;
- Error err = ImageLoader::load_image(p_file,&image);
+ Error err = ImageLoader::load_image(p_file, &image);
ERR_EXPLAIN(TTR("Couldn't load image"));
ERR_FAIL_COND(err);
- v=image;
+ v = image;
emit_signal("variant_changed");
hide();
} break;
@@ -1104,80 +1077,74 @@ void CustomPropertyEditor::_file_selected(String p_file) {
void CustomPropertyEditor::_type_create_selected(int p_idx) {
+ if (type == Variant::INT || type == Variant::REAL) {
- if (type==Variant::INT || type==Variant::REAL) {
-
-
- float newval=0;
- switch(p_idx) {
+ float newval = 0;
+ switch (p_idx) {
case EASING_LINEAR: {
- newval=1;
+ newval = 1;
} break;
case EASING_EASE_IN: {
- newval=2.0;
+ newval = 2.0;
} break;
case EASING_EASE_OUT: {
- newval=0.5;
+ newval = 0.5;
} break;
case EASING_ZERO: {
- newval=0;
+ newval = 0;
} break;
case EASING_IN_OUT: {
- newval=-0.5;
+ newval = -0.5;
} break;
case EASING_OUT_IN: {
- newval=-2.0;
+ newval = -2.0;
} break;
}
- v=newval;
+ v = newval;
emit_signal("variant_changed");
easing_draw->update();
- } else if (type==Variant::OBJECT) {
+ } else if (type == Variant::OBJECT) {
- ERR_FAIL_INDEX(p_idx,inheritors_array.size());
+ ERR_FAIL_INDEX(p_idx, inheritors_array.size());
//List<String> inheritors;
//ClassDB::get_inheriters_from(hint_text,&inheritors);
//inheritors.push_front(hint_text);
//ERR_FAIL_INDEX( p_idx, inheritors.size() );
- String intype=inheritors_array[p_idx];
+ String intype = inheritors_array[p_idx];
Object *obj = ClassDB::instance(intype);
- ERR_FAIL_COND( !obj );
-
+ ERR_FAIL_COND(!obj);
- Resource *res=obj->cast_to<Resource>();
- ERR_FAIL_COND( !res );
+ Resource *res = obj->cast_to<Resource>();
+ ERR_FAIL_COND(!res);
- v=Ref<Resource>(res).get_ref_ptr();
+ v = Ref<Resource>(res).get_ref_ptr();
emit_signal("variant_changed");
hide();
}
-
}
+void CustomPropertyEditor::_color_changed(const Color &p_color) {
-void CustomPropertyEditor::_color_changed(const Color& p_color) {
-
- v=p_color;
+ v = p_color;
emit_signal("variant_changed");
-
}
void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
if (picking_viewport) {
- Node* to_node=get_node(p_path);
+ Node *to_node = get_node(p_path);
if (!to_node->cast_to<Viewport>()) {
EditorNode::get_singleton()->show_warning("Selected node is not a Viewport!");
return;
@@ -1187,86 +1154,84 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) {
vt.instance();
vt->set_viewport_path_in_scene(get_tree()->get_edited_scene_root()->get_path_to(to_node));
vt->setup_local_to_scene();
- v=vt;
+ v = vt;
emit_signal("variant_changed");
return;
}
- if (hint==PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && hint_text!=String()) {
+ if (hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && hint_text != String()) {
- Node* node=get_node(hint_text);
+ Node *node = get_node(hint_text);
if (node) {
- Node *tonode=node->get_node(p_path);
+ Node *tonode = node->get_node(p_path);
if (tonode) {
- p_path=node->get_path_to(tonode);
+ p_path = node->get_path_to(tonode);
}
}
} else if (owner) {
- Node *node=NULL;
+ Node *node = NULL;
- if (owner->is_class("Node"))
+ if (owner->is_class("Node"))
node = owner->cast_to<Node>();
else if (owner->is_class("ArrayPropertyEdit"))
node = owner->cast_to<ArrayPropertyEdit>()->get_node();
if (!node) {
- v=p_path;
+ v = p_path;
emit_signal("variant_changed");
call_deferred("hide"); //to not mess with dialogs
return;
}
- Node *tonode=node->get_node(p_path);
+ Node *tonode = node->get_node(p_path);
if (tonode) {
- p_path=node->get_path_to(tonode);
+ p_path = node->get_path_to(tonode);
}
}
- v=p_path;
+ v = p_path;
emit_signal("variant_changed");
call_deferred("hide"); //to not mess with dialogs
-
}
void CustomPropertyEditor::_action_pressed(int p_which) {
-
if (updating)
return;
- switch(type) {
+ switch (type) {
case Variant::BOOL: {
- v=checks20[0]->is_pressed();
+ v = checks20[0]->is_pressed();
emit_signal("variant_changed");
} break;
case Variant::INT: {
- if (hint==PROPERTY_HINT_LAYERS_2D_PHYSICS || hint==PROPERTY_HINT_LAYERS_2D_RENDER || hint==PROPERTY_HINT_LAYERS_3D_PHYSICS || hint==PROPERTY_HINT_LAYERS_3D_RENDER) {
+ if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || hint == PROPERTY_HINT_LAYERS_2D_RENDER || hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || hint == PROPERTY_HINT_LAYERS_3D_RENDER) {
uint32_t f = v;
if (checks20[p_which]->is_pressed())
- f|=(1<<p_which);
+ f |= (1 << p_which);
else
- f&=~(1<<p_which);
+ f &= ~(1 << p_which);
- v=f;
+ v = f;
emit_signal("variant_changed");
}
} break;
case Variant::STRING: {
- if (hint==PROPERTY_HINT_MULTILINE_TEXT) {
+ if (hint == PROPERTY_HINT_MULTILINE_TEXT) {
hide();
- } else if (hint==PROPERTY_HINT_FILE || hint==PROPERTY_HINT_GLOBAL_FILE) {
- if (p_which==0) {
+ } else if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_GLOBAL_FILE) {
+ if (p_which == 0) {
- if (hint==PROPERTY_HINT_FILE)
+ if (hint == PROPERTY_HINT_FILE)
file->set_access(EditorFileDialog::ACCESS_RESOURCES);
else
file->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
@@ -1276,36 +1241,32 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
file->clear_filters();
-
- if (hint_text!="") {
- Vector<String> extensions=hint_text.split(",");
- for(int i=0;i<extensions.size();i++) {
+ if (hint_text != "") {
+ Vector<String> extensions = hint_text.split(",");
+ for (int i = 0; i < extensions.size(); i++) {
String filter = extensions[i];
if (filter.begins_with("."))
- filter="*"+extensions[i];
+ filter = "*" + extensions[i];
else if (!filter.begins_with("*"))
- filter="*."+extensions[i];
-
-
- file->add_filter(filter+" ; "+extensions[i].to_upper() );
+ filter = "*." + extensions[i];
+ file->add_filter(filter + " ; " + extensions[i].to_upper());
}
}
file->popup_centered_ratio();
} else {
- v="";
+ v = "";
emit_signal("variant_changed");
hide();
-
}
- } else if (hint==PROPERTY_HINT_DIR || hint==PROPERTY_HINT_GLOBAL_DIR) {
+ } else if (hint == PROPERTY_HINT_DIR || hint == PROPERTY_HINT_GLOBAL_DIR) {
- if (p_which==0) {
+ if (p_which == 0) {
- if (hint==PROPERTY_HINT_DIR)
+ if (hint == PROPERTY_HINT_DIR)
file->set_access(EditorFileDialog::ACCESS_RESOURCES);
else
file->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
@@ -1314,73 +1275,66 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
file->popup_centered_ratio();
} else {
- v="";
+ v = "";
emit_signal("variant_changed");
hide();
-
}
-
}
} break;
case Variant::NODE_PATH: {
- if (p_which==0) {
+ if (p_which == 0) {
- picking_viewport=false;
+ picking_viewport = false;
scene_tree->set_title(TTR("Pick a Node"));
scene_tree->popup_centered_ratio();
- } else if (p_which==1) {
-
+ } else if (p_which == 1) {
- v=NodePath();
+ v = NodePath();
emit_signal("variant_changed");
hide();
}
} break;
case Variant::OBJECT: {
- if (p_which==0) {
+ if (p_which == 0) {
+ ERR_FAIL_COND(inheritors_array.empty());
- ERR_FAIL_COND( inheritors_array.empty() );
+ String intype = inheritors_array[0];
- String intype=inheritors_array[0];
-
-
- if (hint==PROPERTY_HINT_RESOURCE_TYPE) {
+ if (hint == PROPERTY_HINT_RESOURCE_TYPE) {
Object *obj = ClassDB::instance(intype);
- ERR_BREAK( !obj );
- Resource *res=obj->cast_to<Resource>();
- ERR_BREAK( !res );
+ ERR_BREAK(!obj);
+ Resource *res = obj->cast_to<Resource>();
+ ERR_BREAK(!res);
- v=Ref<Resource>(res).get_ref_ptr();
+ v = Ref<Resource>(res).get_ref_ptr();
emit_signal("variant_changed");
hide();
-
}
- } else if (p_which==1) {
+ } else if (p_which == 1) {
file->set_access(EditorFileDialog::ACCESS_RESOURCES);
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
List<String> extensions;
- String type=(hint==PROPERTY_HINT_RESOURCE_TYPE)?hint_text:String();
+ String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String();
- ResourceLoader::get_recognized_extensions_for_type(type,&extensions);
+ ResourceLoader::get_recognized_extensions_for_type(type, &extensions);
file->clear_filters();
- for (List<String>::Element *E=extensions.front();E;E=E->next()) {
-
- file->add_filter("*."+E->get()+" ; "+E->get().to_upper() );
+ for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
+ file->add_filter("*." + E->get() + " ; " + E->get().to_upper());
}
file->popup_centered_ratio();
- } else if (p_which==2) {
+ } else if (p_which == 2) {
- RefPtr RefPtr=v;
+ RefPtr RefPtr = v;
if (!RefPtr.is_null()) {
@@ -1388,48 +1342,46 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
hide();
}
- } else if (p_which==3) {
-
+ } else if (p_which == 3) {
- v=Variant();
+ v = Variant();
emit_signal("variant_changed");
hide();
- } else if (p_which==4) {
+ } else if (p_which == 4) {
-
- RefPtr RefPtr=v;
+ RefPtr RefPtr = v;
Ref<Resource> res_orig = RefPtr;
if (res_orig.is_null())
return;
List<PropertyInfo> property_list;
res_orig->get_property_list(&property_list);
- List< Pair<String,Variant> > propvalues;
+ List<Pair<String, Variant> > propvalues;
- for(List<PropertyInfo>::Element *E=property_list.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
- Pair<String,Variant> p;
+ Pair<String, Variant> p;
PropertyInfo &pi = E->get();
- if (pi.usage&PROPERTY_USAGE_STORAGE) {
+ if (pi.usage & PROPERTY_USAGE_STORAGE) {
- p.first=pi.name;
- p.second=res_orig->get(pi.name);
+ p.first = pi.name;
+ p.second = res_orig->get(pi.name);
}
propvalues.push_back(p);
}
- Ref<Resource> res = Ref<Resource>( ClassDB::instance( res_orig->get_class() ));
+ Ref<Resource> res = Ref<Resource>(ClassDB::instance(res_orig->get_class()));
ERR_FAIL_COND(res.is_null());
- for(List< Pair<String,Variant> >::Element *E=propvalues.front();E;E=E->next()) {
+ for (List<Pair<String, Variant> >::Element *E = propvalues.front(); E; E = E->next()) {
- Pair<String,Variant> &p=E->get();
- res->set(p.first,p.second);
+ Pair<String, Variant> &p = E->get();
+ res->set(p.first, p.second);
}
- v=res.get_ref_ptr();
+ v = res.get_ref_ptr();
emit_signal("variant_changed");
hide();
}
@@ -1437,11 +1389,11 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
} break;
case Variant::IMAGE: {
- if (p_which==0) {
+ if (p_which == 0) {
//new image too difficult
ERR_PRINT("New Image Unimplemented");
- } else if (p_which==1) {
+ } else if (p_which == 1) {
file->set_access(EditorFileDialog::ACCESS_RESOURCES);
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
@@ -1450,17 +1402,16 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
file->clear_filters();
- for (List<String>::Element *E=extensions.front();E;E=E->next()) {
-
- file->add_filter("*."+E->get()+" ; "+E->get().to_upper() );
+ for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
+ file->add_filter("*." + E->get() + " ; " + E->get().to_upper());
}
file->popup_centered_ratio();
- } else if (p_which==2) {
+ } else if (p_which == 2) {
- v=Image();
+ v = Image();
emit_signal("variant_changed");
hide();
}
@@ -1468,7 +1419,6 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
} break;
default: {};
}
-
}
void CustomPropertyEditor::_scroll_modified(double p_value) {
@@ -1498,107 +1448,96 @@ void CustomPropertyEditor::_scroll_modified(double p_value) {
*/
}
+void CustomPropertyEditor::_drag_easing(const InputEvent &p_ev) {
-void CustomPropertyEditor::_drag_easing(const InputEvent& p_ev) {
-
-
- if (p_ev.type==InputEvent::MOUSE_MOTION && p_ev.mouse_motion.button_mask&BUTTON_MASK_LEFT) {
+ if (p_ev.type == InputEvent::MOUSE_MOTION && p_ev.mouse_motion.button_mask & BUTTON_MASK_LEFT) {
float rel = p_ev.mouse_motion.relative_x;
- if (rel==0)
+ if (rel == 0)
return;
- bool flip=hint_text=="attenuation";
+ bool flip = hint_text == "attenuation";
if (flip)
- rel=-rel;
+ rel = -rel;
float val = v;
- if (val==0)
+ if (val == 0)
return;
bool sg = val < 0;
val = Math::absf(val);
- val = Math::log(val)/Math::log((float)2.0);
+ val = Math::log(val) / Math::log((float)2.0);
//logspace
- val+=rel*0.05;
+ val += rel * 0.05;
//
- val = Math::pow(2.0f,val);
+ val = Math::pow(2.0f, val);
if (sg)
- val=-val;
+ val = -val;
- v=val;
+ v = val;
easing_draw->update();
//emit_signal("variant_changed");
emit_signal("variant_changed");
}
- if (p_ev.type==InputEvent::MOUSE_BUTTON && p_ev.mouse_button.button_index==BUTTON_LEFT) {
-
-
+ if (p_ev.type == InputEvent::MOUSE_BUTTON && p_ev.mouse_button.button_index == BUTTON_LEFT) {
}
-
}
-
void CustomPropertyEditor::_draw_easing() {
-
RID ci = easing_draw->get_canvas_item();
Size2 s = easing_draw->get_size();
- Rect2 r(Point2(),s);
- r=r.grow(3);
- get_stylebox("normal","LineEdit")->draw(ci,r);
+ Rect2 r(Point2(), s);
+ r = r.grow(3);
+ get_stylebox("normal", "LineEdit")->draw(ci, r);
//VisualServer::get_singleton()->canvas_item_add
-
int points = 48;
- float prev=1.0;
- float exp=v;
- bool flip=hint_text=="attenuation";
+ float prev = 1.0;
+ float exp = v;
+ bool flip = hint_text == "attenuation";
- Ref<Font> f = get_font("font","Label");
- Color color = get_color("font_color","Label");
+ Ref<Font> f = get_font("font", "Label");
+ Color color = get_color("font_color", "Label");
- for(int i=1;i<=points;i++) {
+ for (int i = 1; i <= points; i++) {
- float ifl = i/float(points);
- float iflp = (i-1)/float(points);
+ float ifl = i / float(points);
+ float iflp = (i - 1) / float(points);
- float h = 1.0-Math::ease(ifl,exp);
+ float h = 1.0 - Math::ease(ifl, exp);
if (flip) {
- ifl=1.0-ifl;
- iflp=1.0-iflp;
+ ifl = 1.0 - ifl;
+ iflp = 1.0 - iflp;
}
- VisualServer::get_singleton()->canvas_item_add_line(ci,Point2(iflp*s.width,prev*s.height),Point2(ifl*s.width,h*s.height),color);
- prev=h;
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(iflp * s.width, prev * s.height), Point2(ifl * s.width, h * s.height), color);
+ prev = h;
}
- f->draw(ci,Point2(10,10+f->get_ascent()),String::num(exp,2),color);
+ f->draw(ci, Point2(10, 10 + f->get_ascent()), String::num(exp, 2), color);
}
void CustomPropertyEditor::_text_edit_changed() {
- v=text_edit->get_text();
+ v = text_edit->get_text();
emit_signal("variant_changed");
-
}
void CustomPropertyEditor::_create_dialog_callback() {
-
- v=create_dialog->get_selected_type();
+ v = create_dialog->get_selected_type();
emit_signal("variant_changed");
}
-void CustomPropertyEditor::_create_selected_property(const String& p_prop) {
-
+void CustomPropertyEditor::_create_selected_property(const String &p_prop) {
- v=p_prop;
+ v = p_prop;
emit_signal("variant_changed");
}
@@ -1606,46 +1545,44 @@ void CustomPropertyEditor::_modified(String p_string) {
if (updating)
return;
- updating=true;
- switch(type) {
+ updating = true;
+ switch (type) {
case Variant::INT: {
if (evaluator)
- v=evaluator->eval(value_editor[0]->get_text());
+ v = evaluator->eval(value_editor[0]->get_text());
else
- v=value_editor[0]->get_text().to_int();
+ v = value_editor[0]->get_text().to_int();
emit_signal("variant_changed");
-
} break;
case Variant::REAL: {
- if (hint!=PROPERTY_HINT_EXP_EASING) {
+ if (hint != PROPERTY_HINT_EXP_EASING) {
if (evaluator)
- v=evaluator->eval(value_editor[0]->get_text());
+ v = evaluator->eval(value_editor[0]->get_text());
else
- v=value_editor[0]->get_text().to_double();
+ v = value_editor[0]->get_text().to_double();
emit_signal("variant_changed");
-
}
} break;
case Variant::STRING: {
- v=value_editor[0]->get_text();
+ v = value_editor[0]->get_text();
emit_signal("variant_changed");
} break;
case Variant::VECTOR2: {
Vector2 vec;
if (evaluator) {
- vec.x=evaluator->eval(value_editor[0]->get_text());
- vec.y=evaluator->eval(value_editor[1]->get_text());
+ vec.x = evaluator->eval(value_editor[0]->get_text());
+ vec.y = evaluator->eval(value_editor[1]->get_text());
} else {
- vec.x=value_editor[0]->get_text().to_double();
- vec.y=value_editor[1]->get_text().to_double();
+ vec.x = value_editor[0]->get_text().to_double();
+ vec.y = value_editor[1]->get_text().to_double();
}
- v=vec;
+ v = vec;
_emit_changed_whole_or_field();
} break;
@@ -1653,17 +1590,17 @@ void CustomPropertyEditor::_modified(String p_string) {
Rect2 r2;
if (evaluator) {
- r2.pos.x=evaluator->eval(value_editor[0]->get_text());
- r2.pos.y=evaluator->eval(value_editor[1]->get_text());
- r2.size.x=evaluator->eval(value_editor[2]->get_text());
- r2.size.y=evaluator->eval(value_editor[3]->get_text());
+ r2.pos.x = evaluator->eval(value_editor[0]->get_text());
+ r2.pos.y = evaluator->eval(value_editor[1]->get_text());
+ r2.size.x = evaluator->eval(value_editor[2]->get_text());
+ r2.size.y = evaluator->eval(value_editor[3]->get_text());
} else {
- r2.pos.x=value_editor[0]->get_text().to_double();
- r2.pos.y=value_editor[1]->get_text().to_double();
- r2.size.x=value_editor[2]->get_text().to_double();
- r2.size.y=value_editor[3]->get_text().to_double();
+ r2.pos.x = value_editor[0]->get_text().to_double();
+ r2.pos.y = value_editor[1]->get_text().to_double();
+ r2.size.x = value_editor[2]->get_text().to_double();
+ r2.size.y = value_editor[3]->get_text().to_double();
}
- v=r2;
+ v = r2;
_emit_changed_whole_or_field();
} break;
@@ -1672,15 +1609,15 @@ void CustomPropertyEditor::_modified(String p_string) {
Vector3 vec;
if (evaluator) {
- vec.x=evaluator->eval(value_editor[0]->get_text());
- vec.y=evaluator->eval(value_editor[1]->get_text());
- vec.z=evaluator->eval(value_editor[2]->get_text());
+ vec.x = evaluator->eval(value_editor[0]->get_text());
+ vec.y = evaluator->eval(value_editor[1]->get_text());
+ vec.z = evaluator->eval(value_editor[2]->get_text());
} else {
- vec.x=value_editor[0]->get_text().to_double();
- vec.y=value_editor[1]->get_text().to_double();
- vec.z=value_editor[2]->get_text().to_double();
+ vec.x = value_editor[0]->get_text().to_double();
+ vec.y = value_editor[1]->get_text().to_double();
+ vec.z = value_editor[2]->get_text().to_double();
}
- v=vec;
+ v = vec;
_emit_changed_whole_or_field();
} break;
@@ -1688,17 +1625,17 @@ void CustomPropertyEditor::_modified(String p_string) {
Plane pl;
if (evaluator) {
- pl.normal.x=evaluator->eval(value_editor[0]->get_text());
- pl.normal.y=evaluator->eval(value_editor[1]->get_text());
- pl.normal.z=evaluator->eval(value_editor[2]->get_text());
- pl.d=evaluator->eval(value_editor[3]->get_text());
+ pl.normal.x = evaluator->eval(value_editor[0]->get_text());
+ pl.normal.y = evaluator->eval(value_editor[1]->get_text());
+ pl.normal.z = evaluator->eval(value_editor[2]->get_text());
+ pl.d = evaluator->eval(value_editor[3]->get_text());
} else {
- pl.normal.x=value_editor[0]->get_text().to_double();
- pl.normal.y=value_editor[1]->get_text().to_double();
- pl.normal.z=value_editor[2]->get_text().to_double();
- pl.d=value_editor[3]->get_text().to_double();
+ pl.normal.x = value_editor[0]->get_text().to_double();
+ pl.normal.y = value_editor[1]->get_text().to_double();
+ pl.normal.z = value_editor[2]->get_text().to_double();
+ pl.d = value_editor[3]->get_text().to_double();
}
- v=pl;
+ v = pl;
_emit_changed_whole_or_field();
} break;
@@ -1706,17 +1643,17 @@ void CustomPropertyEditor::_modified(String p_string) {
Quat q;
if (evaluator) {
- q.x=evaluator->eval(value_editor[0]->get_text());
- q.y=evaluator->eval(value_editor[1]->get_text());
- q.z=evaluator->eval(value_editor[2]->get_text());
- q.w=evaluator->eval(value_editor[3]->get_text());
+ q.x = evaluator->eval(value_editor[0]->get_text());
+ q.y = evaluator->eval(value_editor[1]->get_text());
+ q.z = evaluator->eval(value_editor[2]->get_text());
+ q.w = evaluator->eval(value_editor[3]->get_text());
} else {
- q.x=value_editor[0]->get_text().to_double();
- q.y=value_editor[1]->get_text().to_double();
- q.z=value_editor[2]->get_text().to_double();
- q.w=value_editor[3]->get_text().to_double();
+ q.x = value_editor[0]->get_text().to_double();
+ q.y = value_editor[1]->get_text().to_double();
+ q.z = value_editor[2]->get_text().to_double();
+ q.w = value_editor[3]->get_text().to_double();
}
- v=q;
+ v = q;
_emit_changed_whole_or_field();
} break;
@@ -1726,83 +1663,82 @@ void CustomPropertyEditor::_modified(String p_string) {
Vector3 size;
if (evaluator) {
- pos.x=evaluator->eval(value_editor[0]->get_text());
- pos.y=evaluator->eval(value_editor[1]->get_text());
- pos.z=evaluator->eval(value_editor[2]->get_text());
- size.x=evaluator->eval(value_editor[3]->get_text());
- size.y=evaluator->eval(value_editor[4]->get_text());
- size.z=evaluator->eval(value_editor[5]->get_text());
+ pos.x = evaluator->eval(value_editor[0]->get_text());
+ pos.y = evaluator->eval(value_editor[1]->get_text());
+ pos.z = evaluator->eval(value_editor[2]->get_text());
+ size.x = evaluator->eval(value_editor[3]->get_text());
+ size.y = evaluator->eval(value_editor[4]->get_text());
+ size.z = evaluator->eval(value_editor[5]->get_text());
} else {
- pos.x=value_editor[0]->get_text().to_double();
- pos.y=value_editor[1]->get_text().to_double();
- pos.z=value_editor[2]->get_text().to_double();
- size.x=value_editor[3]->get_text().to_double();
- size.y=value_editor[4]->get_text().to_double();
- size.z=value_editor[5]->get_text().to_double();
+ pos.x = value_editor[0]->get_text().to_double();
+ pos.y = value_editor[1]->get_text().to_double();
+ pos.z = value_editor[2]->get_text().to_double();
+ size.x = value_editor[3]->get_text().to_double();
+ size.y = value_editor[4]->get_text().to_double();
+ size.z = value_editor[5]->get_text().to_double();
}
- v=Rect3(pos,size);
+ v = Rect3(pos, size);
_emit_changed_whole_or_field();
} break;
case Variant::TRANSFORM2D: {
Transform2D m;
- for(int i=0;i<6;i++) {
+ for (int i = 0; i < 6; i++) {
if (evaluator) {
- m.elements[i/2][i%2]=evaluator->eval(value_editor[i]->get_text());
+ m.elements[i / 2][i % 2] = evaluator->eval(value_editor[i]->get_text());
} else {
- m.elements[i/2][i%2]=value_editor[i]->get_text().to_double();
+ m.elements[i / 2][i % 2] = value_editor[i]->get_text().to_double();
}
}
- v=m;
+ v = m;
_emit_changed_whole_or_field();
} break;
case Variant::BASIS: {
Basis m;
- for(int i=0;i<9;i++) {
+ for (int i = 0; i < 9; i++) {
if (evaluator) {
- m.elements[i/3][i%3]=evaluator->eval(value_editor[i]->get_text());
+ m.elements[i / 3][i % 3] = evaluator->eval(value_editor[i]->get_text());
} else {
- m.elements[i/3][i%3]=value_editor[i]->get_text().to_double();
+ m.elements[i / 3][i % 3] = value_editor[i]->get_text().to_double();
}
}
- v=m;
+ v = m;
_emit_changed_whole_or_field();
} break;
case Variant::TRANSFORM: {
Basis basis;
- for(int i=0;i<9;i++) {
+ for (int i = 0; i < 9; i++) {
if (evaluator) {
- basis.elements[i/3][i%3]=evaluator->eval(value_editor[(i/3)*4+i%3]->get_text());
+ basis.elements[i / 3][i % 3] = evaluator->eval(value_editor[(i / 3) * 4 + i % 3]->get_text());
} else {
- basis.elements[i/3][i%3]=value_editor[(i/3)*4+i%3]->get_text().to_double();
+ basis.elements[i / 3][i % 3] = value_editor[(i / 3) * 4 + i % 3]->get_text().to_double();
}
}
Vector3 origin;
if (evaluator) {
- origin.x=evaluator->eval(value_editor[3]->get_text());
- origin.y=evaluator->eval(value_editor[7]->get_text());
- origin.z=evaluator->eval(value_editor[11]->get_text());
+ origin.x = evaluator->eval(value_editor[3]->get_text());
+ origin.y = evaluator->eval(value_editor[7]->get_text());
+ origin.z = evaluator->eval(value_editor[11]->get_text());
} else {
- origin.x=value_editor[3]->get_text().to_double();
- origin.y=value_editor[7]->get_text().to_double();
- origin.z=value_editor[11]->get_text().to_double();
+ origin.x = value_editor[3]->get_text().to_double();
+ origin.y = value_editor[7]->get_text().to_double();
+ origin.z = value_editor[11]->get_text().to_double();
}
- v=Transform(basis,origin);
+ v = Transform(basis, origin);
_emit_changed_whole_or_field();
-
} break;
case Variant::COLOR: {
/*
@@ -1822,49 +1758,40 @@ void CustomPropertyEditor::_modified(String p_string) {
} break;
case Variant::IMAGE: {
-
} break;
case Variant::NODE_PATH: {
- v=NodePath(value_editor[0]->get_text());
+ v = NodePath(value_editor[0]->get_text());
emit_signal("variant_changed");
} break;
case Variant::INPUT_EVENT: {
-
} break;
case Variant::DICTIONARY: {
-
} break;
case Variant::POOL_BYTE_ARRAY: {
-
} break;
case Variant::POOL_INT_ARRAY: {
-
} break;
case Variant::POOL_REAL_ARRAY: {
-
} break;
case Variant::POOL_STRING_ARRAY: {
-
} break;
case Variant::POOL_VECTOR3_ARRAY: {
-
} break;
case Variant::POOL_COLOR_ARRAY: {
-
} break;
default: {}
}
- updating=false;
+ updating = false;
}
void CustomPropertyEditor::_emit_changed_whole_or_field() {
@@ -1872,18 +1799,17 @@ void CustomPropertyEditor::_emit_changed_whole_or_field() {
if (!Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
emit_signal("variant_changed");
} else {
- emit_signal("variant_field_changed",field_names[focused_value_editor]);
+ emit_signal("variant_field_changed", field_names[focused_value_editor]);
}
}
-void CustomPropertyEditor::_range_modified(double p_value)
-{
- v=p_value;
+void CustomPropertyEditor::_range_modified(double p_value) {
+ v = p_value;
emit_signal("variant_changed");
}
void CustomPropertyEditor::_focus_enter() {
- switch(type) {
+ switch (type) {
case Variant::REAL:
case Variant::STRING:
case Variant::VECTOR2:
@@ -1895,9 +1821,9 @@ void CustomPropertyEditor::_focus_enter() {
case Variant::TRANSFORM2D:
case Variant::BASIS:
case Variant::TRANSFORM: {
- for (int i=0;i<MAX_VALUE_EDITORS;++i) {
+ for (int i = 0; i < MAX_VALUE_EDITORS; ++i) {
if (value_editor[i]->has_focus()) {
- focused_value_editor=i;
+ focused_value_editor = i;
value_editor[i]->select_all();
break;
}
@@ -1905,11 +1831,10 @@ void CustomPropertyEditor::_focus_enter() {
} break;
default: {}
}
-
}
void CustomPropertyEditor::_focus_exit() {
- switch(type) {
+ switch (type) {
case Variant::REAL:
case Variant::STRING:
case Variant::VECTOR2:
@@ -1921,225 +1846,211 @@ void CustomPropertyEditor::_focus_exit() {
case Variant::TRANSFORM2D:
case Variant::BASIS:
case Variant::TRANSFORM: {
- for (int i=0;i<MAX_VALUE_EDITORS;++i) {
+ for (int i = 0; i < MAX_VALUE_EDITORS; ++i) {
value_editor[i]->select(0, 0);
}
} break;
default: {}
}
-
}
-void CustomPropertyEditor::config_action_buttons(const List<String>& p_strings) {
+void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) {
- int w=100;
- int h=18;
- int m=5;
+ int w = 100;
+ int h = 18;
+ int m = 5;
- set_size( Size2( w, m*2+(h+m)*p_strings.size() ) );
+ set_size(Size2(w, m * 2 + (h + m) * p_strings.size()));
- for (int i=0;i<MAX_ACTION_BUTTONS;i++) {
+ for (int i = 0; i < MAX_ACTION_BUTTONS; i++) {
- if (i<p_strings.size()) {
+ if (i < p_strings.size()) {
action_buttons[i]->show();
action_buttons[i]->set_text(p_strings[i]);
- action_buttons[i]->set_pos( Point2( m, m+i*(h+m) ));
- action_buttons[i]->set_size( Size2( w-m*2, h ) );
+ action_buttons[i]->set_pos(Point2(m, m + i * (h + m)));
+ action_buttons[i]->set_size(Size2(w - m * 2, h));
action_buttons[i]->set_flat(true);
} else {
action_buttons[i]->hide();
}
}
-
-
}
-void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns,int p_label_w,const List<String>& p_strings) {
+void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns, int p_label_w, const List<String> &p_strings) {
- int w=80;
- int h=20;
- int m=10;
+ int w = 80;
+ int h = 20;
+ int m = 10;
- int rows=((p_amount-1)/p_columns)+1;
+ int rows = ((p_amount - 1) / p_columns) + 1;
- set_size( Size2( m*(1+p_columns)+(w+p_label_w)*p_columns, m*(1+rows)+h*rows ) );
+ set_size(Size2(m * (1 + p_columns) + (w + p_label_w) * p_columns, m * (1 + rows) + h * rows));
- for (int i=0;i<MAX_VALUE_EDITORS;i++) {
+ for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
- int c=i%p_columns;
- int r=i/p_columns;
+ int c = i % p_columns;
+ int r = i / p_columns;
- if (i<p_amount) {
+ if (i < p_amount) {
value_editor[i]->show();
value_label[i]->show();
- value_label[i]->set_text(i<p_strings.size()?p_strings[i]:String(""));
- value_editor[i]->set_pos( Point2( m+p_label_w+c*(w+m+p_label_w), m+r*(h+m) ));
- value_editor[i]->set_size( Size2( w, h ) );
- value_label[i]->set_pos( Point2( m+c*(w+m+p_label_w), m+r*(h+m) ) );
+ value_label[i]->set_text(i < p_strings.size() ? p_strings[i] : String(""));
+ value_editor[i]->set_pos(Point2(m + p_label_w + c * (w + m + p_label_w), m + r * (h + m)));
+ value_editor[i]->set_size(Size2(w, h));
+ value_label[i]->set_pos(Point2(m + c * (w + m + p_label_w), m + r * (h + m)));
value_editor[i]->set_editable(!read_only);
} else {
value_editor[i]->hide();
value_label[i]->hide();
}
}
-
-
-
}
-
void CustomPropertyEditor::_bind_methods() {
ClassDB::bind_method("_focus_enter", &CustomPropertyEditor::_focus_enter);
ClassDB::bind_method("_focus_exit", &CustomPropertyEditor::_focus_exit);
- ClassDB::bind_method("_modified",&CustomPropertyEditor::_modified);
+ ClassDB::bind_method("_modified", &CustomPropertyEditor::_modified);
ClassDB::bind_method("_range_modified", &CustomPropertyEditor::_range_modified);
- ClassDB::bind_method("_scroll_modified",&CustomPropertyEditor::_scroll_modified);
- ClassDB::bind_method("_action_pressed",&CustomPropertyEditor::_action_pressed);
- ClassDB::bind_method("_file_selected",&CustomPropertyEditor::_file_selected);
- ClassDB::bind_method("_type_create_selected",&CustomPropertyEditor::_type_create_selected);
- ClassDB::bind_method("_node_path_selected",&CustomPropertyEditor::_node_path_selected);
- ClassDB::bind_method("_color_changed",&CustomPropertyEditor::_color_changed);
- ClassDB::bind_method("_draw_easing",&CustomPropertyEditor::_draw_easing);
- ClassDB::bind_method("_drag_easing",&CustomPropertyEditor::_drag_easing);
- ClassDB::bind_method( "_text_edit_changed",&CustomPropertyEditor::_text_edit_changed);
- ClassDB::bind_method( "_menu_option",&CustomPropertyEditor::_menu_option);
- ClassDB::bind_method( "_create_dialog_callback",&CustomPropertyEditor::_create_dialog_callback);
- ClassDB::bind_method( "_create_selected_property",&CustomPropertyEditor::_create_selected_property);
-
-
-
- ADD_SIGNAL( MethodInfo("variant_changed") );
- ADD_SIGNAL( MethodInfo("variant_field_changed",PropertyInfo(Variant::STRING,"field")) );
- ADD_SIGNAL( MethodInfo("resource_edit_request") );
+ ClassDB::bind_method("_scroll_modified", &CustomPropertyEditor::_scroll_modified);
+ ClassDB::bind_method("_action_pressed", &CustomPropertyEditor::_action_pressed);
+ ClassDB::bind_method("_file_selected", &CustomPropertyEditor::_file_selected);
+ ClassDB::bind_method("_type_create_selected", &CustomPropertyEditor::_type_create_selected);
+ ClassDB::bind_method("_node_path_selected", &CustomPropertyEditor::_node_path_selected);
+ ClassDB::bind_method("_color_changed", &CustomPropertyEditor::_color_changed);
+ ClassDB::bind_method("_draw_easing", &CustomPropertyEditor::_draw_easing);
+ ClassDB::bind_method("_drag_easing", &CustomPropertyEditor::_drag_easing);
+ ClassDB::bind_method("_text_edit_changed", &CustomPropertyEditor::_text_edit_changed);
+ ClassDB::bind_method("_menu_option", &CustomPropertyEditor::_menu_option);
+ ClassDB::bind_method("_create_dialog_callback", &CustomPropertyEditor::_create_dialog_callback);
+ ClassDB::bind_method("_create_selected_property", &CustomPropertyEditor::_create_selected_property);
+
+ ADD_SIGNAL(MethodInfo("variant_changed"));
+ ADD_SIGNAL(MethodInfo("variant_field_changed", PropertyInfo(Variant::STRING, "field")));
+ ADD_SIGNAL(MethodInfo("resource_edit_request"));
}
CustomPropertyEditor::CustomPropertyEditor() {
+ read_only = false;
+ updating = false;
- read_only=false;
- updating=false;
-
- for (int i=0;i<MAX_VALUE_EDITORS;i++) {
+ for (int i = 0; i < MAX_VALUE_EDITORS; i++) {
- value_editor[i]=memnew( LineEdit );
- add_child( value_editor[i] );
- value_label[i]=memnew( Label );
- add_child( value_label[i] );
+ value_editor[i] = memnew(LineEdit);
+ add_child(value_editor[i]);
+ value_label[i] = memnew(Label);
+ add_child(value_label[i]);
value_editor[i]->hide();
value_label[i]->hide();
- value_editor[i]->connect("text_entered", this,"_modified");
+ value_editor[i]->connect("text_entered", this, "_modified");
value_editor[i]->connect("focus_entered", this, "_focus_enter");
value_editor[i]->connect("focus_exited", this, "_focus_exit");
}
- focused_value_editor=-1;
+ focused_value_editor = -1;
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- scroll[i] = memnew( HScrollBar );
+ scroll[i] = memnew(HScrollBar);
scroll[i]->hide();
scroll[i]->set_min(0);
scroll[i]->set_max(1.0);
scroll[i]->set_step(0.01);
add_child(scroll[i]);
- scroll[i]->connect("value_changed", this,"_scroll_modified");
-
+ scroll[i]->connect("value_changed", this, "_scroll_modified");
}
- checks20gc = memnew( GridContainer );
+ checks20gc = memnew(GridContainer);
add_child(checks20gc);
checks20gc->set_columns(11);
- for(int i=0;i<20;i++) {
- if (i==5 || i==15) {
- Control *space = memnew( Control );
- space->set_custom_minimum_size(Size2(20,0)*EDSCALE);
+ for (int i = 0; i < 20; i++) {
+ if (i == 5 || i == 15) {
+ Control *space = memnew(Control);
+ space->set_custom_minimum_size(Size2(20, 0) * EDSCALE);
checks20gc->add_child(space);
}
- checks20[i]=memnew( CheckBox );
+ checks20[i] = memnew(CheckBox);
checks20[i]->set_toggle_mode(true);
- checks20[i]->set_focus_mode(FOCUS_NONE);
+ checks20[i]->set_focus_mode(FOCUS_NONE);
checks20gc->add_child(checks20[i]);
checks20[i]->hide();
- checks20[i]->connect("pressed",this,"_action_pressed",make_binds(i));
- checks20[i]->set_tooltip(vformat(TTR("Bit %d, val %d."), i, 1<<i));
+ checks20[i]->connect("pressed", this, "_action_pressed", make_binds(i));
+ checks20[i]->set_tooltip(vformat(TTR("Bit %d, val %d."), i, 1 << i));
}
- text_edit = memnew( TextEdit );
+ text_edit = memnew(TextEdit);
add_child(text_edit);
text_edit->set_area_as_parent_rect();
- for(int i=0;i<4;i++)
- text_edit->set_margin((Margin)i,5);
- text_edit->set_margin(MARGIN_BOTTOM,30);
+ for (int i = 0; i < 4; i++)
+ text_edit->set_margin((Margin)i, 5);
+ text_edit->set_margin(MARGIN_BOTTOM, 30);
text_edit->hide();
- text_edit->connect("text_changed",this,"_text_edit_changed");
+ text_edit->connect("text_changed", this, "_text_edit_changed");
- for (int i=0;i<MAX_ACTION_BUTTONS;i++) {
+ for (int i = 0; i < MAX_ACTION_BUTTONS; i++) {
- action_buttons[i]=memnew(Button);
+ action_buttons[i] = memnew(Button);
action_buttons[i]->hide();
add_child(action_buttons[i]);
Vector<Variant> binds;
binds.push_back(i);
- action_buttons[i]->connect("pressed", this,"_action_pressed",binds);
+ action_buttons[i]->connect("pressed", this, "_action_pressed", binds);
}
- color_picker=NULL;
-
-
+ color_picker = NULL;
set_as_toplevel(true);
- file = memnew ( EditorFileDialog );
+ file = memnew(EditorFileDialog);
add_child(file);
file->hide();
- file->connect("file_selected", this,"_file_selected");
- file->connect("dir_selected", this,"_file_selected");
+ file->connect("file_selected", this, "_file_selected");
+ file->connect("dir_selected", this, "_file_selected");
- error = memnew( ConfirmationDialog );
+ error = memnew(ConfirmationDialog);
error->set_title(TTR("Error!"));
add_child(error);
//error->get_cancel()->hide();
- type_button = memnew( MenuButton );
+ type_button = memnew(MenuButton);
add_child(type_button);
type_button->hide();
- type_button->get_popup()->connect("id_pressed", this,"_type_create_selected");
+ type_button->get_popup()->connect("id_pressed", this, "_type_create_selected");
-
- scene_tree = memnew( SceneTreeDialog );
+ scene_tree = memnew(SceneTreeDialog);
add_child(scene_tree);
- scene_tree->connect("selected", this,"_node_path_selected");
+ scene_tree->connect("selected", this, "_node_path_selected");
scene_tree->get_scene_tree()->set_show_enabled_subscene(true);
- texture_preview = memnew( TextureRect );
- add_child( texture_preview);
+ texture_preview = memnew(TextureRect);
+ add_child(texture_preview);
texture_preview->hide();
- easing_draw=memnew( Control );
+ easing_draw = memnew(Control);
add_child(easing_draw);
easing_draw->hide();
- easing_draw->connect("draw",this,"_draw_easing");
- easing_draw->connect("gui_input",this,"_drag_easing");
+ easing_draw->connect("draw", this, "_draw_easing");
+ easing_draw->connect("gui_input", this, "_drag_easing");
//easing_draw->emit_signal(SceneStringNames::get_singleton()->input_event,InputEvent());
easing_draw->set_default_cursor_shape(Control::CURSOR_MOVE);
menu = memnew(PopupMenu);
add_child(menu);
- menu->connect("id_pressed",this,"_menu_option");
+ menu->connect("id_pressed", this, "_menu_option");
evaluator = NULL;
- spinbox = memnew ( SpinBox );
+ spinbox = memnew(SpinBox);
add_child(spinbox);
spinbox->set_area_as_parent_rect(5);
- spinbox->connect("value_changed",this,"_range_modified");
+ spinbox->connect("value_changed", this, "_range_modified");
- slider = memnew ( HSlider );
+ slider = memnew(HSlider);
add_child(slider);
slider->set_area_as_parent_rect(5);
- slider->connect("value_changed",this,"_range_modified");
+ slider->connect("value_changed", this, "_range_modified");
create_dialog = NULL;
property_select = NULL;
@@ -2152,56 +2063,54 @@ bool PropertyEditor::_might_be_in_instance() {
Node *node = obj->cast_to<Node>();
- Node* edited_scene =EditorNode::get_singleton()->get_edited_scene();
+ Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
- bool might_be=false;
+ bool might_be = false;
- while(node) {
+ while (node) {
if (node->get_scene_instance_state().is_valid()) {
- might_be=true;
+ might_be = true;
break;
}
- if (node==edited_scene) {
+ if (node == edited_scene) {
if (node->get_scene_inherited_state().is_valid()) {
- might_be=true;
+ might_be = true;
break;
}
- might_be=false;
+ might_be = false;
break;
}
- node=node->get_owner();
+ node = node->get_owner();
}
return might_be;
-
}
-bool PropertyEditor::_get_instanced_node_original_property(const StringName& p_prop, Variant& value) {
+bool PropertyEditor::_get_instanced_node_original_property(const StringName &p_prop, Variant &value) {
Node *node = obj->cast_to<Node>();
if (!node)
return false;
- Node *orig=node;
+ Node *orig = node;
- Node* edited_scene =EditorNode::get_singleton()->get_edited_scene();
+ Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
- bool found=false;
+ bool found = false;
//print_line("for prop - "+String(p_prop));
-
- while(node) {
+ while (node) {
Ref<SceneState> ss;
- if (node==edited_scene) {
- ss=node->get_scene_inherited_state();
+ if (node == edited_scene) {
+ ss = node->get_scene_inherited_state();
} else {
- ss=node->get_scene_instance_state();
+ ss = node->get_scene_instance_state();
}
//print_line("at - "+String(edited_scene->get_path_to(node)));
@@ -2210,239 +2119,223 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName& p_p
NodePath np = node->get_path_to(orig);
int node_idx = ss->find_node_by_path(np);
//print_line("\t valid, nodeidx "+itos(node_idx));
- if (node_idx>=0) {
- bool lfound=false;
+ if (node_idx >= 0) {
+ bool lfound = false;
Variant lvar;
- lvar=ss->get_property_value(node_idx,p_prop,lfound);
+ lvar = ss->get_property_value(node_idx, p_prop, lfound);
if (lfound) {
- found=true;
- value=lvar;
+ found = true;
+ value = lvar;
//print_line("\t found value "+String(value));
}
}
}
- if (node==edited_scene) {
+ if (node == edited_scene) {
//just in case
break;
}
- node=node->get_owner();
-
+ node = node->get_owner();
}
return found;
}
-bool PropertyEditor::_is_property_different(const Variant& p_current, const Variant& p_orig,int p_usage) {
-
+bool PropertyEditor::_is_property_different(const Variant &p_current, const Variant &p_orig, int p_usage) {
{
Node *node = obj->cast_to<Node>();
if (!node)
return false;
- Node* edited_scene =EditorNode::get_singleton()->get_edited_scene();
- bool found_state=false;
+ Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
+ bool found_state = false;
//print_line("for prop - "+String(p_prop));
-
- while(node) {
+ while (node) {
Ref<SceneState> ss;
- if (node==edited_scene) {
- ss=node->get_scene_inherited_state();
+ if (node == edited_scene) {
+ ss = node->get_scene_inherited_state();
} else {
- ss=node->get_scene_instance_state();
+ ss = node->get_scene_instance_state();
}
if (ss.is_valid()) {
- found_state=true;
+ found_state = true;
}
- if (node==edited_scene) {
+ if (node == edited_scene) {
//just in case
break;
}
- node=node->get_owner();
+ node = node->get_owner();
}
if (!found_state)
return false; //pointless to check if we are not comparing against anything.
}
- if (p_orig.get_type()==Variant::NIL) {
-
-
+ if (p_orig.get_type() == Variant::NIL) {
//special cases
- if (p_current.is_zero() && p_usage&PROPERTY_USAGE_STORE_IF_NONZERO)
+ if (p_current.is_zero() && p_usage & PROPERTY_USAGE_STORE_IF_NONZERO)
return false;
- if (p_current.is_one() && p_usage&PROPERTY_USAGE_STORE_IF_NONONE)
+ if (p_current.is_one() && p_usage & PROPERTY_USAGE_STORE_IF_NONONE)
return false;
}
- if (p_current.get_type()==Variant::REAL && p_orig.get_type()==Variant::REAL) {
+ if (p_current.get_type() == Variant::REAL && p_orig.get_type() == Variant::REAL) {
float a = p_current;
float b = p_orig;
- return Math::abs(a-b)>CMP_EPSILON; //this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error
+ return Math::abs(a - b) > CMP_EPSILON; //this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error
}
- return bool(Variant::evaluate(Variant::OP_NOT_EQUAL,p_current,p_orig));
+ return bool(Variant::evaluate(Variant::OP_NOT_EQUAL, p_current, p_orig));
}
-TreeItem *PropertyEditor::find_item(TreeItem *p_item,const String& p_name) {
-
+TreeItem *PropertyEditor::find_item(TreeItem *p_item, const String &p_name) {
if (!p_item)
return NULL;
String name = p_item->get_metadata(1);
- if (name==p_name) {
+ if (name == p_name) {
return p_item;
}
- TreeItem *c=p_item->get_children();
+ TreeItem *c = p_item->get_children();
while (c) {
- TreeItem *found = find_item(c,p_name);
+ TreeItem *found = find_item(c, p_name);
if (found)
return found;
- c=c->get_next();
+ c = c->get_next();
}
return NULL;
}
+void PropertyEditor::_changed_callback(Object *p_changed, const char *p_prop) {
-void PropertyEditor::_changed_callback(Object *p_changed,const char * p_prop) {
-
-
- _changed_callbacks(p_changed,p_prop);
+ _changed_callbacks(p_changed, p_prop);
}
-void PropertyEditor::_changed_callbacks(Object *p_changed,const String& p_prop) {
+void PropertyEditor::_changed_callbacks(Object *p_changed, const String &p_prop) {
-
- if (p_changed!=obj)
+ if (p_changed != obj)
return;
if (changing)
return;
- if (p_prop==String())
- update_tree_pending=true;
+ if (p_prop == String())
+ update_tree_pending = true;
else {
- pending[p_prop]=p_prop;
-
+ pending[p_prop] = p_prop;
}
}
-void PropertyEditor::update_property(const String& p_prop) {
+void PropertyEditor::update_property(const String &p_prop) {
if (obj)
- _changed_callbacks(obj,p_prop);
+ _changed_callbacks(obj, p_prop);
}
+void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p_name, int p_hint, const String &p_hint_text) {
-void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p_name, int p_hint, const String& p_hint_text) {
-
- switch( p_type ) {
+ switch (p_type) {
case Variant::BOOL: {
- p_item->set_checked( 1, obj->get( p_name ) );
+ p_item->set_checked(1, obj->get(p_name));
} break;
case Variant::REAL:
case Variant::INT: {
- if (p_hint==PROPERTY_HINT_LAYERS_2D_PHYSICS || p_hint==PROPERTY_HINT_LAYERS_2D_RENDER || p_hint==PROPERTY_HINT_LAYERS_3D_PHYSICS || p_hint==PROPERTY_HINT_LAYERS_3D_RENDER) {
+ if (p_hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || p_hint == PROPERTY_HINT_LAYERS_2D_RENDER || p_hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || p_hint == PROPERTY_HINT_LAYERS_3D_RENDER) {
tree->update();
break;
}
- if (p_hint==PROPERTY_HINT_FLAGS) {
+ if (p_hint == PROPERTY_HINT_FLAGS) {
Vector<String> values = p_hint_text.split(",");
String flags;
int val = obj->get(p_name);
- for(int i=0;i<values.size();i++) {
+ for (int i = 0; i < values.size(); i++) {
String v = values[i];
- if (v=="")
+ if (v == "")
continue;
- if (!(val&(1<<i)))
+ if (!(val & (1 << i)))
continue;
- if (flags!="")
- flags+=", ";
- flags+=v;
+ if (flags != "")
+ flags += ", ";
+ flags += v;
}
- p_item->set_text(1, flags );
+ p_item->set_text(1, flags);
break;
}
- if (p_hint==PROPERTY_HINT_EXP_EASING) {
+ if (p_hint == PROPERTY_HINT_EXP_EASING) {
- p_item->set_text(1, String::num(obj->get( p_name ),2) );
+ p_item->set_text(1, String::num(obj->get(p_name), 2));
break;
}
-
//p_item->set_cell_mode( 1, TreeItem::CELL_MODE_RANGE );
- if (p_type==Variant::REAL) {
- p_item->set_range(1, obj->get( p_name ) );
+ if (p_type == Variant::REAL) {
+ p_item->set_range(1, obj->get(p_name));
} else {
/* FIXME: Why are both statements equal? */
- p_item->set_range(1, obj->get( p_name ) );
+ p_item->set_range(1, obj->get(p_name));
}
-
- p_item->set_editable(1,!read_only);
-
+ p_item->set_editable(1, !read_only);
} break;
case Variant::STRING:
+ if (p_hint == PROPERTY_HINT_TYPE_STRING) {
- if (p_hint==PROPERTY_HINT_TYPE_STRING) {
-
- p_item->set_text(1,obj->get(p_name));
+ p_item->set_text(1, obj->get(p_name));
}
- if ( p_hint==PROPERTY_HINT_METHOD_OF_VARIANT_TYPE ||
- p_hint==PROPERTY_HINT_METHOD_OF_BASE_TYPE ||
- p_hint==PROPERTY_HINT_METHOD_OF_INSTANCE ||
- p_hint==PROPERTY_HINT_METHOD_OF_SCRIPT ||
- p_hint==PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE ||
- p_hint==PROPERTY_HINT_PROPERTY_OF_BASE_TYPE ||
- p_hint==PROPERTY_HINT_PROPERTY_OF_INSTANCE ||
- p_hint==PROPERTY_HINT_PROPERTY_OF_SCRIPT ) {
+ if (p_hint == PROPERTY_HINT_METHOD_OF_VARIANT_TYPE ||
+ p_hint == PROPERTY_HINT_METHOD_OF_BASE_TYPE ||
+ p_hint == PROPERTY_HINT_METHOD_OF_INSTANCE ||
+ p_hint == PROPERTY_HINT_METHOD_OF_SCRIPT ||
+ p_hint == PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE ||
+ p_hint == PROPERTY_HINT_PROPERTY_OF_BASE_TYPE ||
+ p_hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE ||
+ p_hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
- p_item->set_text(1,obj->get(p_name));
+ p_item->set_text(1, obj->get(p_name));
}
-
- if (p_hint==PROPERTY_HINT_ENUM) {
+ if (p_hint == PROPERTY_HINT_ENUM) {
Vector<String> strings = p_hint_text.split(",");
String current = obj->get(p_name);
- int idx=0;
- for(int x=0;x<strings.size();x++) {
- if (strings[x]==current) {
- idx=x;
+ int idx = 0;
+ for (int x = 0; x < strings.size(); x++) {
+ if (strings[x] == current) {
+ idx = x;
break;
}
}
p_item->set_text(1, p_hint_text);
- p_item->set_range(1,idx);
+ p_item->set_range(1, idx);
break;
}
@@ -2455,7 +2348,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
case Variant::BASIS:
case Variant::TRANSFORM: {
- p_item->set_text(1,obj->get(p_name));
+ p_item->set_text(1, obj->get(p_name));
} break;
case Variant::COLOR: {
@@ -2466,209 +2359,188 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
} break;
case Variant::IMAGE: {
- Image img = obj->get( p_name );
+ Image img = obj->get(p_name);
if (img.empty())
- p_item->set_text(1,"[Image (empty)]");
+ p_item->set_text(1, "[Image (empty)]");
else
- p_item->set_text(1,"[Image "+itos(img.get_width())+"x"+itos(img.get_height())+"-"+String(Image::get_format_name(img.get_format()))+"]");
+ p_item->set_text(1, "[Image " + itos(img.get_width()) + "x" + itos(img.get_height()) + "-" + String(Image::get_format_name(img.get_format())) + "]");
} break;
case Variant::NODE_PATH: {
- p_item->set_text(1,obj->get(p_name));
+ p_item->set_text(1, obj->get(p_name));
} break;
case Variant::OBJECT: {
-
- if (obj->get( p_name ).get_type() == Variant::NIL || obj->get( p_name ).operator RefPtr().is_null()) {
- p_item->set_text(1,"<null>");
- p_item->set_icon(1,Ref<Texture>());
+ if (obj->get(p_name).get_type() == Variant::NIL || obj->get(p_name).operator RefPtr().is_null()) {
+ p_item->set_text(1, "<null>");
+ p_item->set_icon(1, Ref<Texture>());
Dictionary d = p_item->get_metadata(0);
- int hint=d.has("hint")?d["hint"].operator int():-1;
- String hint_text=d.has("hint_text")?d["hint_text"]:"";
- if (hint==PROPERTY_HINT_RESOURCE_TYPE && hint_text == "Texture") {
- p_item->set_icon(1,NULL);
+ int hint = d.has("hint") ? d["hint"].operator int() : -1;
+ String hint_text = d.has("hint_text") ? d["hint_text"] : "";
+ if (hint == PROPERTY_HINT_RESOURCE_TYPE && hint_text == "Texture") {
+ p_item->set_icon(1, NULL);
}
} else {
- RES res = obj->get( p_name ).operator RefPtr();
+ RES res = obj->get(p_name).operator RefPtr();
if (res->is_class("Texture")) {
int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width");
- p_item->set_icon_max_width(1,tw);
- p_item->set_icon(1,res);
- p_item->set_text(1,"");
+ p_item->set_icon_max_width(1, tw);
+ p_item->set_icon(1, res);
+ p_item->set_text(1, "");
} else if (res->get_name() != "") {
p_item->set_text(1, res->get_name());
- } else if (res->get_path()!="" && !res->get_path().begins_with("local://")) {
+ } else if (res->get_path() != "" && !res->get_path().begins_with("local://")) {
p_item->set_text(1, res->get_path().get_file());
} else {
- p_item->set_text(1,"<"+res->get_class()+">");
+ p_item->set_text(1, "<" + res->get_class() + ">");
};
-
if (res.is_valid() && res->get_path().is_resource_file()) {
- p_item->set_tooltip(1,res->get_path());
+ p_item->set_tooltip(1, res->get_path());
} else if (res.is_valid()) {
- p_item->set_tooltip(1,res->get_name()+" ("+res->get_class()+")");
+ p_item->set_tooltip(1, res->get_name() + " (" + res->get_class() + ")");
}
+ if (has_icon(res->get_class(), "EditorIcons")) {
- if (has_icon(res->get_class(),"EditorIcons")) {
-
- p_item->set_icon(0,get_icon(res->get_class(),"EditorIcons"));
+ p_item->set_icon(0, get_icon(res->get_class(), "EditorIcons"));
} else {
Dictionary d = p_item->get_metadata(0);
- int hint=d.has("hint")?d["hint"].operator int():-1;
- String hint_text=d.has("hint_text")?d["hint_text"]:"";
- if (hint==PROPERTY_HINT_RESOURCE_TYPE) {
+ int hint = d.has("hint") ? d["hint"].operator int() : -1;
+ String hint_text = d.has("hint_text") ? d["hint_text"] : "";
+ if (hint == PROPERTY_HINT_RESOURCE_TYPE) {
- if (has_icon(hint_text,"EditorIcons")) {
+ if (has_icon(hint_text, "EditorIcons")) {
- p_item->set_icon(0,get_icon(hint_text,"EditorIcons"));
+ p_item->set_icon(0, get_icon(hint_text, "EditorIcons"));
} else {
- p_item->set_icon(0,get_icon("Object","EditorIcons"));
-
+ p_item->set_icon(0, get_icon("Object", "EditorIcons"));
}
}
}
if (!res->is_class("Texture")) {
//texture already previews via itself
- EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res,this,"_resource_preview_done",p_item->get_instance_ID());
+ EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_resource_preview_done", p_item->get_instance_ID());
}
-
-
-
}
-
} break;
default: {};
}
-
}
+void PropertyEditor::_check_reload_status(const String &p_name, TreeItem *item) {
-void PropertyEditor::_check_reload_status(const String&p_name, TreeItem* item) {
-
- bool has_reload=false;
- int found=-1;
- bool is_disabled=false;
+ bool has_reload = false;
+ int found = -1;
+ bool is_disabled = false;
- for(int i=0;i<item->get_button_count(1);i++) {
+ for (int i = 0; i < item->get_button_count(1); i++) {
- if (item->get_button_id(1,i)==3) {
- found=i;
- is_disabled=item->is_button_disabled(1,i);
+ if (item->get_button_id(1, i) == 3) {
+ found = i;
+ is_disabled = item->is_button_disabled(1, i);
break;
}
}
if (_might_be_in_instance()) {
-
Variant vorig;
- Dictionary d=item->get_metadata(0);
- int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0;
-
+ Dictionary d = item->get_metadata(0);
+ int usage = d.has("usage") ? int(int(d["usage"]) & (PROPERTY_USAGE_STORE_IF_NONONE | PROPERTY_USAGE_STORE_IF_NONZERO)) : 0;
- if (_get_instanced_node_original_property(p_name,vorig) || usage) {
+ if (_get_instanced_node_original_property(p_name, vorig) || usage) {
Variant v = obj->get(p_name);
-
- bool changed = _is_property_different(v,vorig,usage);
+ bool changed = _is_property_different(v, vorig, usage);
//if ((found!=-1 && !is_disabled)!=changed) {
- if (changed) {
+ if (changed) {
- has_reload=true;
- } else {
-
- }
+ has_reload = true;
+ } else {
+ }
//}
-
}
-
}
- if (obj->call("property_can_revert",p_name).operator bool()) {
+ if (obj->call("property_can_revert", p_name).operator bool()) {
- has_reload=true;
+ has_reload = true;
}
-
if (!has_reload && !obj->get_script().is_null()) {
Ref<Script> scr = obj->get_script();
Variant orig_value;
- if (scr->get_property_default_value(p_name,orig_value)) {
- if (orig_value!=obj->get(p_name)) {
- has_reload=true;
+ if (scr->get_property_default_value(p_name, orig_value)) {
+ if (orig_value != obj->get(p_name)) {
+ has_reload = true;
}
}
}
//print_line("found: "+itos(found)+" has reload: "+itos(has_reload)+" is_disabled "+itos(is_disabled));
- if (found!=-1 && !has_reload) {
+ if (found != -1 && !has_reload) {
if (!is_disabled) {
- item->erase_button(1,found);
- if (item->get_cell_mode(1)==TreeItem::CELL_MODE_RANGE && item->get_text(1)==String()) {
- item->add_button(1,get_icon("ReloadEmpty","EditorIcons"),3,true);
+ item->erase_button(1, found);
+ if (item->get_cell_mode(1) == TreeItem::CELL_MODE_RANGE && item->get_text(1) == String()) {
+ item->add_button(1, get_icon("ReloadEmpty", "EditorIcons"), 3, true);
}
}
- } else if (found==-1 && has_reload) {
- item->add_button(1,get_icon("ReloadSmall","EditorIcons"),3);
- } else if (found!=-1 && has_reload && is_disabled) {
- item->erase_button(1,found);
- item->add_button(1,get_icon("ReloadSmall","EditorIcons"),3);
+ } else if (found == -1 && has_reload) {
+ item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3);
+ } else if (found != -1 && has_reload && is_disabled) {
+ item->erase_button(1, found);
+ item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3);
}
}
-
-
-bool PropertyEditor::_is_drop_valid(const Dictionary& p_drag_data, const Dictionary& p_item_data) const {
+bool PropertyEditor::_is_drop_valid(const Dictionary &p_drag_data, const Dictionary &p_item_data) const {
Dictionary d = p_item_data;
if (d.has("type")) {
int type = d["type"];
- if (type==Variant::OBJECT && d.has("hint") && d.has("hint_text") && int(d["hint"])==PROPERTY_HINT_RESOURCE_TYPE) {
+ if (type == Variant::OBJECT && d.has("hint") && d.has("hint_text") && int(d["hint"]) == PROPERTY_HINT_RESOURCE_TYPE) {
-
- String allowed_type=d["hint_text"];
+ String allowed_type = d["hint_text"];
Dictionary drag_data = p_drag_data;
- if (drag_data.has("type") && String(drag_data["type"])=="resource") {
+ if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
Ref<Resource> res = drag_data["resource"];
- for(int i=0;i<allowed_type.get_slice_count(",");i++) {
- String at = allowed_type.get_slice(",",i).strip_edges();
- if (res.is_valid() && ClassDB::is_parent_class(res->get_class(),at)) {
+ for (int i = 0; i < allowed_type.get_slice_count(","); i++) {
+ String at = allowed_type.get_slice(",", i).strip_edges();
+ if (res.is_valid() && ClassDB::is_parent_class(res->get_class(), at)) {
return true;
}
}
-
}
- if (drag_data.has("type") && String(drag_data["type"])=="files") {
+ if (drag_data.has("type") && String(drag_data["type"]) == "files") {
Vector<String> files = drag_data["files"];
- if (files.size()==1) {
+ if (files.size() == 1) {
String file = files[0];
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
- if (ftype!="") {
+ if (ftype != "") {
- for(int i=0;i<allowed_type.get_slice_count(",");i++) {
- String at = allowed_type.get_slice(",",i).strip_edges();
- if (ClassDB::is_parent_class(ftype,at)) {
+ for (int i = 0; i < allowed_type.get_slice_count(","); i++) {
+ String at = allowed_type.get_slice(",", i).strip_edges();
+ if (ClassDB::is_parent_class(ftype, at)) {
return true;
}
}
@@ -2678,14 +2550,12 @@ bool PropertyEditor::_is_drop_valid(const Dictionary& p_drag_data, const Diction
}
}
-
return false;
-
}
-void PropertyEditor::_mark_drop_fields(TreeItem* p_at) {
+void PropertyEditor::_mark_drop_fields(TreeItem *p_at) {
- if (_is_drop_valid(get_viewport()->gui_get_drag_data(),p_at->get_metadata(0)))
- p_at->set_custom_bg_color(1,Color(0.7,0.5,0.2),true);
+ if (_is_drop_valid(get_viewport()->gui_get_drag_data(), p_at->get_metadata(0)))
+ p_at->set_custom_bg_color(1, Color(0.7, 0.5, 0.2), true);
if (p_at->get_children()) {
_mark_drop_fields(p_at->get_children());
@@ -2696,7 +2566,7 @@ void PropertyEditor::_mark_drop_fields(TreeItem* p_at) {
}
}
-Variant PropertyEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) {
+Variant PropertyEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
TreeItem *item = tree->get_item_at_pos(p_point);
if (!item)
@@ -2707,60 +2577,57 @@ Variant PropertyEditor::get_drag_data_fw(const Point2& p_point,Control* p_from)
return Variant();
int col = tree->get_column_at_pos(p_point);
- if (col==0) {
+ if (col == 0) {
Dictionary dp;
- dp["type"]="obj_property";
- dp["object"]=obj;
- dp["property"]=d["name"];
- dp["value"]=obj->get(d["name"]);
+ dp["type"] = "obj_property";
+ dp["object"] = obj;
+ dp["property"] = d["name"];
+ dp["value"] = obj->get(d["name"]);
- Label *label =memnew( Label );
+ Label *label = memnew(Label);
label->set_text(d["name"]);
set_drag_preview(label);
return dp;
}
-
-
Variant val = obj->get(d["name"]);
- if (val.get_type()==Variant::OBJECT) {
+ if (val.get_type() == Variant::OBJECT) {
RES res = val;
if (res.is_valid()) {
custom_editor->hide_menu();
- return EditorNode::get_singleton()->drag_resource(res,p_from);
+ return EditorNode::get_singleton()->drag_resource(res, p_from);
}
}
return Variant();
}
-bool PropertyEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{
+bool PropertyEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
TreeItem *item = tree->get_item_at_pos(p_point);
if (!item)
return false;
int col = tree->get_column_at_pos(p_point);
- if (col!=1)
+ if (col != 1)
return false;
- return _is_drop_valid(p_data,item->get_metadata(0));
-
+ return _is_drop_valid(p_data, item->get_metadata(0));
}
-void PropertyEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){
+void PropertyEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
TreeItem *item = tree->get_item_at_pos(p_point);
if (!item)
return;
int col = tree->get_column_at_pos(p_point);
- if (col!=1)
+ if (col != 1)
return;
- if (!_is_drop_valid(p_data,item->get_metadata(0)))
+ if (!_is_drop_valid(p_data, item->get_metadata(0)))
return;
Dictionary d = item->get_metadata(0);
@@ -2768,44 +2635,42 @@ void PropertyEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,Co
if (!d.has("name"))
return;
- String name=d["name"];
+ String name = d["name"];
Dictionary drag_data = p_data;
- if (drag_data.has("type") && String(drag_data["type"])=="resource") {
+ if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
Ref<Resource> res = drag_data["resource"];
if (res.is_valid()) {
- _edit_set(name,res);
+ _edit_set(name, res);
return;
}
}
- if (drag_data.has("type") && String(drag_data["type"])=="files") {
+ if (drag_data.has("type") && String(drag_data["type"]) == "files") {
Vector<String> files = drag_data["files"];
- if (files.size()==1) {
+ if (files.size() == 1) {
String file = files[0];
RES res = ResourceLoader::load(file);
if (res.is_valid()) {
- _edit_set(name,res);
+ _edit_set(name, res);
return;
}
}
}
}
-
-void PropertyEditor::_clear_drop_fields(TreeItem* p_at) {
+void PropertyEditor::_clear_drop_fields(TreeItem *p_at) {
Dictionary d = p_at->get_metadata(0);
if (d.has("type")) {
int type = d["type"];
- if (type==Variant::OBJECT) {
+ if (type == Variant::OBJECT) {
p_at->clear_custom_bg_color(1);
}
-
}
if (p_at->get_children()) {
@@ -2819,77 +2684,73 @@ void PropertyEditor::_clear_drop_fields(TreeItem* p_at) {
void PropertyEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- get_tree()->connect("node_removed",this,"_node_removed");
+ get_tree()->connect("node_removed", this, "_node_removed");
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
- get_tree()->disconnect("node_removed",this,"_node_removed");
+ get_tree()->disconnect("node_removed", this, "_node_removed");
edit(NULL);
}
-
- if (p_what==NOTIFICATION_DRAG_BEGIN) {
+ if (p_what == NOTIFICATION_DRAG_BEGIN) {
if (is_visible_in_tree() && tree->get_root()) {
_mark_drop_fields(tree->get_root());
}
}
- if (p_what==NOTIFICATION_DRAG_END) {
+ if (p_what == NOTIFICATION_DRAG_END) {
if (is_visible_in_tree() && tree->get_root()) {
_clear_drop_fields(tree->get_root());
}
-
}
- if (p_what==NOTIFICATION_FIXED_PROCESS) {
-
+ if (p_what == NOTIFICATION_FIXED_PROCESS) {
- if (refresh_countdown>0) {
- refresh_countdown-=get_fixed_process_delta_time();
- if (refresh_countdown<=0) {
+ if (refresh_countdown > 0) {
+ refresh_countdown -= get_fixed_process_delta_time();
+ if (refresh_countdown <= 0) {
TreeItem *root = tree->get_root();
_refresh_item(root);
}
}
- changing=true;
+ changing = true;
if (update_tree_pending) {
update_tree();
- update_tree_pending=false;
+ update_tree_pending = false;
} else {
- const String *k=NULL;
- while ((k=pending.next(k))) {
+ const String *k = NULL;
+ while ((k = pending.next(k))) {
- TreeItem * item = find_item(tree->get_root(),*k);
+ TreeItem *item = find_item(tree->get_root(), *k);
if (!item)
continue;
- _check_reload_status(*k,item);
+ _check_reload_status(*k, item);
- Dictionary d=item->get_metadata(0);
- set_item_text(item,d["type"],d["name"],d["hint"],d["hint_text"]);
+ Dictionary d = item->get_metadata(0);
+ set_item_text(item, d["type"], d["name"], d["hint"], d["hint_text"]);
}
}
pending.clear();
- changing=false;
-
+ changing = false;
}
}
-TreeItem *PropertyEditor::get_parent_node(String p_path,HashMap<String,TreeItem*>& item_paths,TreeItem *root) {
+TreeItem *PropertyEditor::get_parent_node(String p_path, HashMap<String, TreeItem *> &item_paths, TreeItem *root) {
- TreeItem *item=NULL;
+ TreeItem *item = NULL;
- if (p_path=="") {
+ if (p_path == "") {
item = root;
} else if (item_paths.has(p_path)) {
@@ -2898,38 +2759,36 @@ TreeItem *PropertyEditor::get_parent_node(String p_path,HashMap<String,TreeItem*
} else {
//printf("path %s parent path %s - item name %s\n",p_path.ascii().get_data(),p_path.left( p_path.find_last("/") ).ascii().get_data(),p_path.right( p_path.find_last("/") ).ascii().get_data() );
- TreeItem *parent = get_parent_node( p_path.left( p_path.find_last("/") ),item_paths,root );
- item = tree->create_item( parent );
+ TreeItem *parent = get_parent_node(p_path.left(p_path.find_last("/")), item_paths, root);
+ item = tree->create_item(parent);
- String name = (p_path.find("/")!=-1)?p_path.right( p_path.find_last("/")+1 ):p_path;
+ String name = (p_path.find("/") != -1) ? p_path.right(p_path.find_last("/") + 1) : p_path;
if (capitalize_paths)
- item->set_text(0, name.capitalize() );
+ item->set_text(0, name.capitalize());
else
- item->set_text(0, name );
+ item->set_text(0, name);
item->set_tooltip(0, p_path);
- if (item->get_parent()!=root) {
- item->set_icon( 0, get_icon("Folder","EditorIcons"));
+ if (item->get_parent() != root) {
+ item->set_icon(0, get_icon("Folder", "EditorIcons"));
}
- item->set_editable(0,false);
- item->set_selectable(0,subsection_selectable);
- item->set_editable(1,false);
- item->set_selectable(1,subsection_selectable);
+ item->set_editable(0, false);
+ item->set_selectable(0, subsection_selectable);
+ item->set_editable(1, false);
+ item->set_selectable(1, subsection_selectable);
- if (item->get_parent()==root) {
+ if (item->get_parent() == root) {
- item->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
- item->set_custom_bg_color(1,get_color("prop_subsection","Editor"));
+ item->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
+ item->set_custom_bg_color(1, get_color("prop_subsection", "Editor"));
}
- item_paths[p_path]=item;
+ item_paths[p_path] = item;
}
return item;
-
}
-
void PropertyEditor::_refresh_item(TreeItem *p_item) {
if (!p_item)
@@ -2937,10 +2796,9 @@ void PropertyEditor::_refresh_item(TreeItem *p_item) {
String name = p_item->get_metadata(1);
- if (name!=String()) {
+ if (name != String()) {
-
- _check_reload_status(name,p_item);
+ _check_reload_status(name, p_item);
#if 0
bool has_reload=false;
@@ -2999,38 +2857,35 @@ void PropertyEditor::_refresh_item(TreeItem *p_item) {
p_item->add_button(1,get_icon("ReloadSmall","EditorIcons"),3);
}
#endif
- Dictionary d=p_item->get_metadata(0);
- set_item_text(p_item,d["type"],d["name"],d["hint"],d["hint_text"]);
+ Dictionary d = p_item->get_metadata(0);
+ set_item_text(p_item, d["type"], d["name"], d["hint"], d["hint_text"]);
}
- TreeItem *c=p_item->get_children();
+ TreeItem *c = p_item->get_children();
while (c) {
_refresh_item(c);
- c=c->get_next();
+ c = c->get_next();
}
-
}
void PropertyEditor::refresh() {
- if (refresh_countdown>0)
+ if (refresh_countdown > 0)
return;
- refresh_countdown=EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval");
-
+ refresh_countdown = EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval");
}
void PropertyEditor::update_tree() {
-
tree->clear();
if (!obj)
return;
- HashMap<String,TreeItem*> item_path;
+ HashMap<String, TreeItem *> item_path;
TreeItem *root = tree->create_item(NULL);
tree->set_hide_root(true);
@@ -3075,127 +2930,123 @@ void PropertyEditor::update_tree() {
}
*/
List<PropertyInfo> plist;
- obj->get_property_list(&plist,true);
+ obj->get_property_list(&plist, true);
- bool draw_red=false;
+ bool draw_red = false;
{
Node *nod = obj->cast_to<Node>();
Node *es = EditorNode::get_singleton()->get_edited_scene();
- if (nod && es!=nod && nod->get_owner()!=es) {
- draw_red=true;
+ if (nod && es != nod && nod->get_owner() != es) {
+ draw_red = true;
}
}
+ Color sscolor = get_color("prop_subsection", "Editor");
- Color sscolor=get_color("prop_subsection","Editor");
-
- TreeItem * current_category=NULL;
+ TreeItem *current_category = NULL;
String filter = search_box ? search_box->get_text() : "";
String group;
String group_base;
- for (List<PropertyInfo>::Element *I=plist.front() ; I ; I=I->next()) {
+ for (List<PropertyInfo>::Element *I = plist.front(); I; I = I->next()) {
- PropertyInfo& p = I->get();
+ PropertyInfo &p = I->get();
//make sure the property can be edited
- if (p.usage&PROPERTY_USAGE_GROUP) {
+ if (p.usage & PROPERTY_USAGE_GROUP) {
- group=p.name;
- group_base=p.hint_string;
+ group = p.name;
+ group_base = p.hint_string;
continue;
- } else if (p.usage&PROPERTY_USAGE_CATEGORY) {
+ } else if (p.usage & PROPERTY_USAGE_CATEGORY) {
- group="";
- group_base="";
+ group = "";
+ group_base = "";
if (!show_categories)
continue;
- List<PropertyInfo>::Element *N=I->next();
- bool valid=true;
+ List<PropertyInfo>::Element *N = I->next();
+ bool valid = true;
//if no properties in category, skip
- while(N) {
- if (N->get().usage&PROPERTY_USAGE_EDITOR)
+ while (N) {
+ if (N->get().usage & PROPERTY_USAGE_EDITOR)
break;
- if (N->get().usage&PROPERTY_USAGE_CATEGORY) {
- valid=false;
+ if (N->get().usage & PROPERTY_USAGE_CATEGORY) {
+ valid = false;
break;
}
- N=N->next();
+ N = N->next();
}
if (!valid)
continue; //empty, ignore
- TreeItem * sep = tree->create_item(root);
- current_category=sep;
- String type=p.name;
+ TreeItem *sep = tree->create_item(root);
+ current_category = sep;
+ String type = p.name;
/*if (has_icon(type,"EditorIcons"))
sep->set_icon(0,get_icon(type,"EditorIcons") );
else
sep->set_icon(0,get_icon("Object","EditorIcons") );
print_line("CATEGORY: "+type);
*/
- sep->set_text(0,type);
- sep->set_selectable(0,false);
- sep->set_selectable(1,false);
- sep->set_custom_bg_color(0,get_color("prop_category","Editor"));
- sep->set_custom_bg_color(1,get_color("prop_category","Editor"));
+ sep->set_text(0, type);
+ sep->set_selectable(0, false);
+ sep->set_selectable(1, false);
+ sep->set_custom_bg_color(0, get_color("prop_category", "Editor"));
+ sep->set_custom_bg_color(1, get_color("prop_category", "Editor"));
if (use_doc_hints) {
- StringName type=p.name;
+ StringName type = p.name;
if (!class_descr_cache.has(type)) {
String descr;
- DocData *dd=EditorHelp::get_doc_data();
- Map<String,DocData::ClassDoc>::Element *E=dd->class_list.find(type);
+ DocData *dd = EditorHelp::get_doc_data();
+ Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type);
if (E) {
- descr=E->get().brief_description;
+ descr = E->get().brief_description;
}
- class_descr_cache[type]=descr.word_wrap(80);
-
+ class_descr_cache[type] = descr.word_wrap(80);
}
- sep->set_tooltip(0,TTR("Class:")+" "+p.name+":\n\n"+class_descr_cache[type]);
+ sep->set_tooltip(0, TTR("Class:") + " " + p.name + ":\n\n" + class_descr_cache[type]);
}
//sep->set_custom_color(0,Color(1,1,1));
-
continue;
- } else if ( ! (p.usage&PROPERTY_USAGE_EDITOR ) )
+ } else if (!(p.usage & PROPERTY_USAGE_EDITOR))
continue;
-
- if (hide_script && p.name=="script")
+ if (hide_script && p.name == "script")
continue;
- String basename=p.name;
- if (group!="") {
- if (group_base!="") {
+ String basename = p.name;
+ if (group != "") {
+ if (group_base != "") {
if (basename.begins_with(group_base)) {
- basename=basename.replace_first(group_base,"");
+ basename = basename.replace_first(group_base, "");
} else {
- group=""; //no longer using group base, clear
+ group = ""; //no longer using group base, clear
}
}
}
- if (group!="") {
- basename=group+"/"+basename;
+ if (group != "") {
+ basename = group + "/" + basename;
}
- String name = (basename.find("/")!=-1)?basename.right( basename.find_last("/")+1 ):basename;
+ String name = (basename.find("/") != -1) ? basename.right(basename.find_last("/") + 1) : basename;
if (capitalize_paths)
name = name.camelcase_to_underscore().capitalize();
- String path=basename.left( basename.find_last("/") ) ;
+ String path = basename.left(basename.find_last("/"));
- if (use_filter && filter!="") {
+ if (use_filter && filter != "") {
String cat = path;
@@ -3207,41 +3058,41 @@ void PropertyEditor::update_tree() {
}
//printf("property %s\n",basename.ascii().get_data());
- TreeItem * parent = get_parent_node(path,item_path,current_category?current_category:root );
+ TreeItem *parent = get_parent_node(path, item_path, current_category ? current_category : root);
/*
if (parent->get_parent()==root)
parent=root;
*/
int level = 0;
- if (parent!=root) {
+ if (parent != root) {
level++;
- TreeItem *parent_lev=parent;
- while(parent_lev->get_parent()!=root) {
- parent_lev=parent_lev->get_parent();
+ TreeItem *parent_lev = parent;
+ while (parent_lev->get_parent() != root) {
+ parent_lev = parent_lev->get_parent();
level++;
}
}
- if (level>4)
- level=4;
+ if (level > 4)
+ level = 4;
Color col = sscolor;
- col.a=(level/4.0)*0.7;
+ col.a = (level / 4.0) * 0.7;
- TreeItem * item = tree->create_item( parent );
+ TreeItem *item = tree->create_item(parent);
- if (level>0) {
- item->set_custom_bg_color(0,col);
+ if (level > 0) {
+ item->set_custom_bg_color(0, col);
//item->set_custom_bg_color(1,col);
}
- item->set_editable(0,false);
- item->set_selectable(0,false);
+ item->set_editable(0, false);
+ item->set_selectable(0, false);
- if (p.usage&PROPERTY_USAGE_CHECKABLE) {
+ if (p.usage & PROPERTY_USAGE_CHECKABLE) {
- item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- item->set_selectable(0,true);
- item->set_editable(0,true);
- item->set_checked(0,p.usage&PROPERTY_USAGE_CHECKED);
+ item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
+ item->set_selectable(0, true);
+ item->set_editable(0, true);
+ item->set_checked(0, p.usage & PROPERTY_USAGE_CHECKED);
}
item->set_text(0, name);
@@ -3250,182 +3101,175 @@ void PropertyEditor::update_tree() {
if (use_doc_hints) {
StringName setter;
StringName type;
- if (ClassDB::get_setter_and_type_for_property(obj->get_class_name(),p.name,type,setter)) {
+ if (ClassDB::get_setter_and_type_for_property(obj->get_class_name(), p.name, type, setter)) {
String descr;
- bool found=false;
- Map<StringName,Map<StringName,String> >::Element *E=descr_cache.find(type);
+ bool found = false;
+ Map<StringName, Map<StringName, String> >::Element *E = descr_cache.find(type);
if (E) {
- Map<StringName,String>::Element *F=E->get().find(setter);
+ Map<StringName, String>::Element *F = E->get().find(setter);
if (F) {
- found=true;
- descr=F->get();
+ found = true;
+ descr = F->get();
}
}
if (!found) {
- DocData *dd=EditorHelp::get_doc_data();
- Map<String,DocData::ClassDoc>::Element *E=dd->class_list.find(type);
+ DocData *dd = EditorHelp::get_doc_data();
+ Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type);
if (E) {
- for(int i=0;i<E->get().methods.size();i++) {
- if (E->get().methods[i].name==setter.operator String()) {
- descr=E->get().methods[i].description.strip_edges().word_wrap(80);
+ for (int i = 0; i < E->get().methods.size(); i++) {
+ if (E->get().methods[i].name == setter.operator String()) {
+ descr = E->get().methods[i].description.strip_edges().word_wrap(80);
}
}
}
- descr_cache[type][setter]=descr;
+ descr_cache[type][setter] = descr;
}
- item->set_tooltip(0, TTR("Property:")+" "+p.name+"\n\n"+descr);
+ item->set_tooltip(0, TTR("Property:") + " " + p.name + "\n\n" + descr);
}
}
//EditorHelp::get_doc_data();
Dictionary d;
- d["name"]=p.name;
- d["type"]=(int)p.type;
- d["hint"]=(int)p.hint;
- d["hint_text"]=p.hint_string;
- d["usage"]=(int)p.usage;
+ d["name"] = p.name;
+ d["type"] = (int)p.type;
+ d["hint"] = (int)p.hint;
+ d["hint_text"] = p.hint_string;
+ d["usage"] = (int)p.usage;
- item->set_metadata( 0, d );
- item->set_metadata( 1, p.name );
+ item->set_metadata(0, d);
+ item->set_metadata(1, p.name);
if (draw_red)
- item->set_custom_color(0,Color(0.8,0.4,0.20));
-
+ item->set_custom_color(0, Color(0.8, 0.4, 0.20));
- if (p.name==selected_property) {
+ if (p.name == selected_property) {
item->select(1);
}
-
//printf("property %s type %i\n",p.name.ascii().get_data(),p.type);
- switch( p.type ) {
+ switch (p.type) {
case Variant::BOOL: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CHECK );
- item->set_text(1,TTR("On"));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CHECK);
+ item->set_text(1, TTR("On"));
item->set_tooltip(1, obj->get(p.name) ? "True" : "False");
- item->set_checked( 1, obj->get( p.name ) );
+ item->set_checked(1, obj->get(p.name));
if (show_type_icons)
- item->set_icon( 0, get_icon("Bool","EditorIcons") );
- item->set_editable(1,!read_only);
+ item->set_icon(0, get_icon("Bool", "EditorIcons"));
+ item->set_editable(1, !read_only);
} break;
case Variant::REAL:
case Variant::INT: {
- if (p.hint==PROPERTY_HINT_EXP_EASING) {
+ if (p.hint == PROPERTY_HINT_EXP_EASING) {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_text(1, String::num(obj->get( p.name ),2) );
- item->set_editable(1,!read_only);
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_text(1, String::num(obj->get(p.name), 2));
+ item->set_editable(1, !read_only);
if (show_type_icons)
- item->set_icon( 0, get_icon("Curve","EditorIcons"));
+ item->set_icon(0, get_icon("Curve", "EditorIcons"));
break;
-
}
- if (p.hint==PROPERTY_HINT_LAYERS_2D_PHYSICS || p.hint==PROPERTY_HINT_LAYERS_2D_RENDER || p.hint==PROPERTY_HINT_LAYERS_3D_PHYSICS || p.hint==PROPERTY_HINT_LAYERS_3D_RENDER) {
+ if (p.hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || p.hint == PROPERTY_HINT_LAYERS_2D_RENDER || p.hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || p.hint == PROPERTY_HINT_LAYERS_3D_RENDER) {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable(1,!read_only);
- item->set_custom_draw(1,this,"_draw_flags");
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, !read_only);
+ item->set_custom_draw(1, this, "_draw_flags");
break;
}
- if (p.hint==PROPERTY_HINT_FLAGS) {
-
+ if (p.hint == PROPERTY_HINT_FLAGS) {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable(1,!read_only);
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, !read_only);
//item->set_icon( 0, get_icon("Curve","EditorIcons"));
Vector<String> values = p.hint_string.split(",");
String flags;
int val = obj->get(p.name);
- for(int i=0;i<values.size();i++) {
+ for (int i = 0; i < values.size(); i++) {
String v = values[i];
- if (v=="")
+ if (v == "")
continue;
- if (!(val&(1<<i)))
+ if (!(val & (1 << i)))
continue;
- if (flags!="")
- flags+=", ";
- flags+=v;
+ if (flags != "")
+ flags += ", ";
+ flags += v;
}
- item->set_text(1, flags );
+ item->set_text(1, flags);
break;
-
}
- if (p.hint==PROPERTY_HINT_ENUM)
- item->set_cell_mode( 1, TreeItem::CELL_MODE_RANGE );
+ if (p.hint == PROPERTY_HINT_ENUM)
+ item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
else
- item->set_cell_mode( 1, TreeItem::CELL_MODE_RANGE_EXPRESSION );
-
+ item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE_EXPRESSION);
- if (p.hint==PROPERTY_HINT_SPRITE_FRAME || p.hint==PROPERTY_HINT_RANGE || p.hint==PROPERTY_HINT_EXP_RANGE) {
+ if (p.hint == PROPERTY_HINT_SPRITE_FRAME || p.hint == PROPERTY_HINT_RANGE || p.hint == PROPERTY_HINT_EXP_RANGE) {
int c = p.hint_string.get_slice_count(",");
- float min=0,max=100,step=1;
- if (c>=1) {
+ float min = 0, max = 100, step = 1;
+ if (c >= 1) {
- min=p.hint_string.get_slice(",",0).to_double();
+ min = p.hint_string.get_slice(",", 0).to_double();
}
- if (c>=2) {
+ if (c >= 2) {
- max=p.hint_string.get_slice(",",1).to_double();
+ max = p.hint_string.get_slice(",", 1).to_double();
}
- if (p.hint!=PROPERTY_HINT_SPRITE_FRAME && c>=3) {
+ if (p.hint != PROPERTY_HINT_SPRITE_FRAME && c >= 3) {
- step= p.hint_string.get_slice(",",2).to_double();
+ step = p.hint_string.get_slice(",", 2).to_double();
}
-
- item->set_range_config(1,min,max,step,p.hint==PROPERTY_HINT_EXP_RANGE);
- } else if (p.hint==PROPERTY_HINT_ENUM) {
+ item->set_range_config(1, min, max, step, p.hint == PROPERTY_HINT_EXP_RANGE);
+ } else if (p.hint == PROPERTY_HINT_ENUM) {
//int c = p.hint_string.get_slice_count(",");
- item->set_text(1,p.hint_string);
+ item->set_text(1, p.hint_string);
if (show_type_icons)
- item->set_icon( 0,get_icon("Enum","EditorIcons") );
- item->set_range(1, obj->get( p.name ) );
- item->set_editable(1,!read_only);
+ item->set_icon(0, get_icon("Enum", "EditorIcons"));
+ item->set_range(1, obj->get(p.name));
+ item->set_editable(1, !read_only);
break;
- } else if (p.hint==PROPERTY_HINT_OBJECT_ID) {
+ } else if (p.hint == PROPERTY_HINT_OBJECT_ID) {
//int c = p.hint_string.get_slice_count(",");
- item->set_cell_mode(1,TreeItem::CELL_MODE_CUSTOM);
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
- String type=p.hint_string;
- if (type=="")
- type="Object";
+ String type = p.hint_string;
+ if (type == "")
+ type = "Object";
- ObjectID id = obj->get( p.name );
- if (id!=0) {
- item->set_text(1,type+" ID: "+itos(id));
- item->add_button(1,get_icon("EditResource","EditorIcons"));
+ ObjectID id = obj->get(p.name);
+ if (id != 0) {
+ item->set_text(1, type + " ID: " + itos(id));
+ item->add_button(1, get_icon("EditResource", "EditorIcons"));
} else {
- item->set_text(1,"[Empty]");
+ item->set_text(1, "[Empty]");
}
- if (has_icon(p.hint_string,"EditorIcons")) {
- type=p.hint_string;
+ if (has_icon(p.hint_string, "EditorIcons")) {
+ type = p.hint_string;
} else {
- type="Object";
+ type = "Object";
}
- item->set_icon(0,get_icon(type,"EditorIcons"));
+ item->set_icon(0, get_icon(type, "EditorIcons"));
break;
@@ -3439,20 +3283,18 @@ void PropertyEditor::update_tree() {
}
};
- if (p.type==Variant::REAL) {
+ if (p.type == Variant::REAL) {
if (show_type_icons)
- item->set_icon( 0, get_icon("Real","EditorIcons"));
- item->set_range(1, obj->get( p.name ) );
+ item->set_icon(0, get_icon("Real", "EditorIcons"));
+ item->set_range(1, obj->get(p.name));
} else {
if (show_type_icons)
- item->set_icon( 0,get_icon("Integer","EditorIcons") );
- item->set_range(1, obj->get( p.name ) );
+ item->set_icon(0, get_icon("Integer", "EditorIcons"));
+ item->set_range(1, obj->get(p.name));
}
-
- item->set_editable(1,!read_only);
-
+ item->set_editable(1, !read_only);
} break;
case Variant::STRING: {
@@ -3464,32 +3306,31 @@ void PropertyEditor::update_tree() {
case PROPERTY_HINT_GLOBAL_DIR:
case PROPERTY_HINT_GLOBAL_FILE: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_STRING );
- item->set_editable(1,!read_only);
+ item->set_cell_mode(1, TreeItem::CELL_MODE_STRING);
+ item->set_editable(1, !read_only);
if (show_type_icons)
- item->set_icon( 0, get_icon("File","EditorIcons") );
- item->set_text(1,obj->get(p.name));
- item->add_button(1,get_icon("Folder","EditorIcons"));
+ item->set_icon(0, get_icon("File", "EditorIcons"));
+ item->set_text(1, obj->get(p.name));
+ item->add_button(1, get_icon("Folder", "EditorIcons"));
} break;
case PROPERTY_HINT_ENUM: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_RANGE );
+ item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
Vector<String> strings = p.hint_string.split(",");
String current = obj->get(p.name);
- int idx=0;
- for(int x=0;x<strings.size();x++) {
- if (strings[x]==current) {
- idx=x;
+ int idx = 0;
+ for (int x = 0; x < strings.size(); x++) {
+ if (strings[x] == current) {
+ idx = x;
break;
}
}
item->set_text(1, p.hint_string);
- item->set_range(1,idx);
- item->set_editable( 1, !read_only );
+ item->set_range(1, idx);
+ item->set_editable(1, !read_only);
if (show_type_icons)
- item->set_icon( 0,get_icon("Enum","EditorIcons") );
-
+ item->set_icon(0, get_icon("Enum", "EditorIcons"));
} break;
case PROPERTY_HINT_METHOD_OF_VARIANT_TYPE: ///< a property of a type
@@ -3502,23 +3343,23 @@ void PropertyEditor::update_tree() {
case PROPERTY_HINT_PROPERTY_OF_SCRIPT: ///< a property of a script & base
case PROPERTY_HINT_TYPE_STRING: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM);
- item->set_editable(1,!read_only);
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, !read_only);
if (show_type_icons)
- item->set_icon( 0, get_icon("String","EditorIcons") );
- item->set_text(1,obj->get(p.name));
+ item->set_icon(0, get_icon("String", "EditorIcons"));
+ item->set_text(1, obj->get(p.name));
} break;
default: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_STRING );
- item->set_editable(1,!read_only);
+ item->set_cell_mode(1, TreeItem::CELL_MODE_STRING);
+ item->set_editable(1, !read_only);
if (show_type_icons)
- item->set_icon( 0, get_icon("String","EditorIcons") );
- item->set_text(1,obj->get(p.name));
- if (p.hint==PROPERTY_HINT_MULTILINE_TEXT)
- item->add_button(1,get_icon("MultiLine","EditorIcons") );
+ item->set_icon(0, get_icon("String", "EditorIcons"));
+ item->set_text(1, obj->get(p.name));
+ if (p.hint == PROPERTY_HINT_MULTILINE_TEXT)
+ item->add_button(1, get_icon("MultiLine", "EditorIcons"));
} break;
}
@@ -3526,304 +3367,293 @@ void PropertyEditor::update_tree() {
} break;
case Variant::ARRAY: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->add_button(1,get_icon("EditResource","EditorIcons"));
-
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->add_button(1, get_icon("EditResource", "EditorIcons"));
Variant v = obj->get(p.name);
String type_name = "Array";
String type_name_suffix = "";
-
+
String hint = p.hint_string;
- while(hint.begins_with(itos(Variant::ARRAY)+":")) {
+ while (hint.begins_with(itos(Variant::ARRAY) + ":")) {
type_name += "<Array";
type_name_suffix += ">";
- hint = hint.substr(2, hint.size()-2);
+ hint = hint.substr(2, hint.size() - 2);
}
- if(hint.find(":") >= 0) {
- hint = hint.substr(0,hint.find(":"));
- if(hint.find("/") >= 0) {
- hint = hint.substr(0,hint.find("/"));
+ if (hint.find(":") >= 0) {
+ hint = hint.substr(0, hint.find(":"));
+ if (hint.find("/") >= 0) {
+ hint = hint.substr(0, hint.find("/"));
}
type_name += "<" + Variant::get_type_name(Variant::Type(hint.to_int()));
type_name_suffix += ">";
}
type_name += type_name_suffix;
-
+
if (v.is_array())
- item->set_text(1,type_name+"["+itos(v.call("size"))+"]");
+ item->set_text(1, type_name + "[" + itos(v.call("size")) + "]");
else
- item->set_text(1,type_name+"[]");
-
- if (show_type_icons)
- item->set_icon( 0, get_icon("ArrayData","EditorIcons") );
+ item->set_text(1, type_name + "[]");
+ if (show_type_icons)
+ item->set_icon(0, get_icon("ArrayData", "EditorIcons"));
} break;
case Variant::POOL_INT_ARRAY: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->add_button(1,get_icon("EditResource","EditorIcons"));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->add_button(1, get_icon("EditResource", "EditorIcons"));
Variant v = obj->get(p.name);
if (v.is_array())
- item->set_text(1,"IntArray["+itos(v.call("size"))+"]");
+ item->set_text(1, "IntArray[" + itos(v.call("size")) + "]");
else
- item->set_text(1,"IntArray[]");
+ item->set_text(1, "IntArray[]");
if (show_type_icons)
- item->set_icon( 0, get_icon("ArrayInt","EditorIcons") );
-
+ item->set_icon(0, get_icon("ArrayInt", "EditorIcons"));
} break;
case Variant::POOL_REAL_ARRAY: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->add_button(1,get_icon("EditResource","EditorIcons"));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->add_button(1, get_icon("EditResource", "EditorIcons"));
Variant v = obj->get(p.name);
if (v.is_array())
- item->set_text(1,"FloatArray["+itos(v.call("size"))+"]");
+ item->set_text(1, "FloatArray[" + itos(v.call("size")) + "]");
else
- item->set_text(1,"FloatArray[]");
+ item->set_text(1, "FloatArray[]");
if (show_type_icons)
- item->set_icon( 0, get_icon("ArrayReal","EditorIcons") );
-
+ item->set_icon(0, get_icon("ArrayReal", "EditorIcons"));
} break;
case Variant::POOL_STRING_ARRAY: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->add_button(1,get_icon("EditResource","EditorIcons"));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->add_button(1, get_icon("EditResource", "EditorIcons"));
Variant v = obj->get(p.name);
if (v.is_array())
- item->set_text(1,"String["+itos(v.call("size"))+"]");
+ item->set_text(1, "String[" + itos(v.call("size")) + "]");
else
- item->set_text(1,"String[]");
+ item->set_text(1, "String[]");
if (show_type_icons)
- item->set_icon( 0, get_icon("ArrayString","EditorIcons") );
-
+ item->set_icon(0, get_icon("ArrayString", "EditorIcons"));
} break;
case Variant::POOL_BYTE_ARRAY: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->add_button(1,get_icon("EditResource","EditorIcons"));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->add_button(1, get_icon("EditResource", "EditorIcons"));
Variant v = obj->get(p.name);
if (v.is_array())
- item->set_text(1,"Byte["+itos(v.call("size"))+"]");
+ item->set_text(1, "Byte[" + itos(v.call("size")) + "]");
else
- item->set_text(1,"Byte[]");
+ item->set_text(1, "Byte[]");
if (show_type_icons)
- item->set_icon( 0, get_icon("ArrayData","EditorIcons") );
-
+ item->set_icon(0, get_icon("ArrayData", "EditorIcons"));
} break;
case Variant::POOL_VECTOR2_ARRAY: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->add_button(1,get_icon("EditResource","EditorIcons"));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->add_button(1, get_icon("EditResource", "EditorIcons"));
Variant v = obj->get(p.name);
if (v.is_array())
- item->set_text(1,"Vector2["+itos(v.call("size"))+"]");
+ item->set_text(1, "Vector2[" + itos(v.call("size")) + "]");
else
- item->set_text(1,"Vector2[]");
+ item->set_text(1, "Vector2[]");
if (show_type_icons)
- item->set_icon( 0, get_icon("Vector2","EditorIcons") );
-
+ item->set_icon(0, get_icon("Vector2", "EditorIcons"));
} break;
case Variant::POOL_VECTOR3_ARRAY: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->add_button(1,get_icon("EditResource","EditorIcons"));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->add_button(1, get_icon("EditResource", "EditorIcons"));
Variant v = obj->get(p.name);
if (v.is_array())
- item->set_text(1,"Vector3["+itos(v.call("size"))+"]");
+ item->set_text(1, "Vector3[" + itos(v.call("size")) + "]");
else
- item->set_text(1,"Vector3[]");
+ item->set_text(1, "Vector3[]");
if (show_type_icons)
- item->set_icon( 0, get_icon("Vector","EditorIcons") );
-
+ item->set_icon(0, get_icon("Vector", "EditorIcons"));
} break;
case Variant::POOL_COLOR_ARRAY: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->add_button(1,get_icon("EditResource","EditorIcons"));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->add_button(1, get_icon("EditResource", "EditorIcons"));
Variant v = obj->get(p.name);
if (v.is_array())
- item->set_text(1,"Color["+itos(v.call("size"))+"]");
+ item->set_text(1, "Color[" + itos(v.call("size")) + "]");
else
- item->set_text(1,"Color[]");
+ item->set_text(1, "Color[]");
if (show_type_icons)
- item->set_icon( 0, get_icon("Color","EditorIcons") );
-
+ item->set_icon(0, get_icon("Color", "EditorIcons"));
} break;
case Variant::VECTOR2: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable( 1, true );
- item->set_text(1,obj->get(p.name));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, true);
+ item->set_text(1, obj->get(p.name));
if (show_type_icons)
- item->set_icon( 0,get_icon("Vector2","EditorIcons") );
+ item->set_icon(0, get_icon("Vector2", "EditorIcons"));
} break;
case Variant::RECT2: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable( 1, true );
- item->set_text(1,obj->get(p.name));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, true);
+ item->set_text(1, obj->get(p.name));
if (show_type_icons)
- item->set_icon( 0,get_icon("Rect2","EditorIcons") );
+ item->set_icon(0, get_icon("Rect2", "EditorIcons"));
} break;
case Variant::VECTOR3: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable( 1, true );
- item->set_text(1,obj->get(p.name));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, true);
+ item->set_text(1, obj->get(p.name));
if (show_type_icons)
- item->set_icon( 0,get_icon("Vector","EditorIcons") );
+ item->set_icon(0, get_icon("Vector", "EditorIcons"));
} break;
case Variant::TRANSFORM2D:
case Variant::BASIS: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable( 1, true );
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, true);
item->set_text(1, obj->get(p.name));
} break;
case Variant::TRANSFORM: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable( 1, true );
- item->set_text(1,obj->get(p.name));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, true);
+ item->set_text(1, obj->get(p.name));
if (show_type_icons)
- item->set_icon( 0,get_icon("Matrix","EditorIcons") );
+ item->set_icon(0, get_icon("Matrix", "EditorIcons"));
} break;
case Variant::PLANE: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable( 1, true );
- item->set_text(1,obj->get(p.name));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, true);
+ item->set_text(1, obj->get(p.name));
if (show_type_icons)
- item->set_icon( 0,get_icon("Plane","EditorIcons") );
+ item->set_icon(0, get_icon("Plane", "EditorIcons"));
} break;
case Variant::RECT3: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable( 1, true );
- item->set_text(1,"Rect3");
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, true);
+ item->set_text(1, "Rect3");
if (show_type_icons)
- item->set_icon( 0,get_icon("Rect3","EditorIcons") );
+ item->set_icon(0, get_icon("Rect3", "EditorIcons"));
} break;
case Variant::QUAT: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable( 1, true );
- item->set_text(1,obj->get(p.name));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, true);
+ item->set_text(1, obj->get(p.name));
if (show_type_icons)
- item->set_icon( 0,get_icon("Quat","EditorIcons") );
+ item->set_icon(0, get_icon("Quat", "EditorIcons"));
} break;
case Variant::COLOR: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable( 1, !read_only );
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, !read_only);
//item->set_text(1,obj->get(p.name));
- item->set_custom_draw(1,this,"_draw_transparency");
+ item->set_custom_draw(1, this, "_draw_transparency");
if (show_type_icons)
- item->set_icon( 0,get_icon("Color","EditorIcons") );
+ item->set_icon(0, get_icon("Color", "EditorIcons"));
} break;
case Variant::IMAGE: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable( 1, !read_only );
- Image img = obj->get( p.name );
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, !read_only);
+ Image img = obj->get(p.name);
if (img.empty())
- item->set_text(1,"[Image (empty)]");
+ item->set_text(1, "[Image (empty)]");
else
- item->set_text(1,"[Image "+itos(img.get_width())+"x"+itos(img.get_height())+"-"+String(Image::get_format_name(img.get_format()))+"]");
+ item->set_text(1, "[Image " + itos(img.get_width()) + "x" + itos(img.get_height()) + "-" + String(Image::get_format_name(img.get_format())) + "]");
if (show_type_icons)
- item->set_icon( 0,get_icon("Image","EditorIcons") );
+ item->set_icon(0, get_icon("Image", "EditorIcons"));
} break;
case Variant::NODE_PATH: {
item->set_cell_mode(1, TreeItem::CELL_MODE_STRING);
- item->set_editable( 1, !read_only );
- item->set_text(1,obj->get(p.name));
+ item->set_editable(1, !read_only);
+ item->set_text(1, obj->get(p.name));
item->add_button(1, get_icon("CopyNodePath", "EditorIcons"));
} break;
case Variant::OBJECT: {
- item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
- item->set_editable( 1, !read_only );
- item->add_button(1,get_icon("EditResource","EditorIcons"));
+ item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
+ item->set_editable(1, !read_only);
+ item->add_button(1, get_icon("EditResource", "EditorIcons"));
String type;
- if (p.hint==PROPERTY_HINT_RESOURCE_TYPE)
- type=p.hint_string;
+ if (p.hint == PROPERTY_HINT_RESOURCE_TYPE)
+ type = p.hint_string;
- if (obj->get( p.name ).get_type() == Variant::NIL || obj->get( p.name ).operator RefPtr().is_null()) {
- item->set_text(1,"<null>");
- item->set_icon(1,Ref<Texture>());
+ if (obj->get(p.name).get_type() == Variant::NIL || obj->get(p.name).operator RefPtr().is_null()) {
+ item->set_text(1, "<null>");
+ item->set_icon(1, Ref<Texture>());
} else {
- RES res = obj->get( p.name ).operator RefPtr();
+ RES res = obj->get(p.name).operator RefPtr();
if (res->is_class("Texture")) {
int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width");
- item->set_icon_max_width(1,tw);
- item->set_icon(1,res);
- item->set_text(1,"");
+ item->set_icon_max_width(1, tw);
+ item->set_icon(1, res);
+ item->set_text(1, "");
} else if (res->get_name() != "") {
item->set_text(1, res->get_name());
- } else if (res->get_path()!="" && !res->get_path().begins_with("local://")) {
+ } else if (res->get_path() != "" && !res->get_path().begins_with("local://")) {
item->set_text(1, res->get_path().get_file());
} else {
- item->set_text(1,"<"+res->get_class()+">");
+ item->set_text(1, "<" + res->get_class() + ">");
}
- if (has_icon(res->get_class(),"EditorIcons")) {
- type=res->get_class();
+ if (has_icon(res->get_class(), "EditorIcons")) {
+ type = res->get_class();
}
if (res.is_valid() && res->get_path().is_resource_file()) {
- item->set_tooltip(1,res->get_path());
+ item->set_tooltip(1, res->get_path());
} else if (res.is_valid()) {
- item->set_tooltip(1,res->get_name()+" ("+res->get_class()+")");
+ item->set_tooltip(1, res->get_name() + " (" + res->get_class() + ")");
}
if (!res->is_class("Texture")) {
//texture already previews via itself
- EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res,this,"_resource_preview_done",item->get_instance_ID());
+ EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_resource_preview_done", item->get_instance_ID());
}
-
}
-
- if (type!=String()) {
- if (type.find(",")!=-1)
- type=type.get_slice(",",0);
+ if (type != String()) {
+ if (type.find(",") != -1)
+ type = type.get_slice(",", 0);
//printf("prop %s , type %s\n",p.name.ascii().get_data(),p.hint_string.ascii().get_data());
- if (has_icon(type,"EditorIcons"))
- item->set_icon( 0, get_icon(type,"EditorIcons") );
+ if (has_icon(type, "EditorIcons"))
+ item->set_icon(0, get_icon(type, "EditorIcons"));
else
- item->set_icon( 0, get_icon("Object","EditorIcons") );
+ item->set_icon(0, get_icon("Object", "EditorIcons"));
}
//item->double_click_signal.connect( Method1<int>( Method2<int,String>( this, &Editoritem_obj_edited ), p.name ) );
@@ -3834,239 +3664,225 @@ void PropertyEditor::update_tree() {
if (keying) {
- if (p.hint==PROPERTY_HINT_SPRITE_FRAME) {
+ if (p.hint == PROPERTY_HINT_SPRITE_FRAME) {
- item->add_button(1,get_icon("KeyNext","EditorIcons"),5);
+ item->add_button(1, get_icon("KeyNext", "EditorIcons"), 5);
} else {
- item->add_button(1,get_icon("Key","EditorIcons"),2);
+ item->add_button(1, get_icon("Key", "EditorIcons"), 2);
}
}
- bool has_reload=false;
+ bool has_reload = false;
bool mbi = _might_be_in_instance();
if (mbi) {
Variant vorig;
- Dictionary d=item->get_metadata(0);
- int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0;
- if (_get_instanced_node_original_property(p.name,vorig) || usage) {
+ Dictionary d = item->get_metadata(0);
+ int usage = d.has("usage") ? int(int(d["usage"]) & (PROPERTY_USAGE_STORE_IF_NONONE | PROPERTY_USAGE_STORE_IF_NONZERO)) : 0;
+ if (_get_instanced_node_original_property(p.name, vorig) || usage) {
Variant v = obj->get(p.name);
-
- if (_is_property_different(v,vorig,usage)) {
+ if (_is_property_different(v, vorig, usage)) {
//print_line("FOR "+String(p.name)+" RELOAD WITH: "+String(v)+"("+Variant::get_type_name(v.get_type())+")=="+String(vorig)+"("+Variant::get_type_name(vorig.get_type())+")");
- item->add_button(1,get_icon("ReloadSmall","EditorIcons"),3);
- has_reload=true;
+ item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3);
+ has_reload = true;
}
}
-
}
- if (obj->call("property_can_revert",p.name).operator bool()) {
+ if (obj->call("property_can_revert", p.name).operator bool()) {
- item->add_button(1,get_icon("ReloadSmall","EditorIcons"),3);
- has_reload=true;
+ item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3);
+ has_reload = true;
}
if (!has_reload && !obj->get_script().is_null()) {
Ref<Script> scr = obj->get_script();
Variant orig_value;
- if (scr->get_property_default_value(p.name,orig_value)) {
- if (orig_value!=obj->get(p.name)) {
- item->add_button(1,get_icon("ReloadSmall","EditorIcons"),3);
- has_reload=true;
+ if (scr->get_property_default_value(p.name, orig_value)) {
+ if (orig_value != obj->get(p.name)) {
+ item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3);
+ has_reload = true;
}
}
}
- if (mbi && !has_reload && item->get_cell_mode(1)==TreeItem::CELL_MODE_RANGE && item->get_text(1)==String()) {
- item->add_button(1,get_icon("ReloadEmpty","EditorIcons"),3,true);
+ if (mbi && !has_reload && item->get_cell_mode(1) == TreeItem::CELL_MODE_RANGE && item->get_text(1) == String()) {
+ item->add_button(1, get_icon("ReloadEmpty", "EditorIcons"), 3, true);
}
-
-
-
}
}
-void PropertyEditor::_draw_transparency(Object *t, const Rect2& p_rect) {
+void PropertyEditor::_draw_transparency(Object *t, const Rect2 &p_rect) {
- TreeItem *ti=t->cast_to<TreeItem>();
+ TreeItem *ti = t->cast_to<TreeItem>();
if (!ti)
- return;
+ return;
- Color color=obj->get(ti->get_metadata(1));
- Ref<Texture> arrow=tree->get_icon("select_arrow");
+ Color color = obj->get(ti->get_metadata(1));
+ Ref<Texture> arrow = tree->get_icon("select_arrow");
// make a little space between consecutive color fields
- Rect2 area=p_rect;
- area.pos.y+=1;
- area.size.height-=2;
- area.size.width-=arrow->get_size().width+5;
+ Rect2 area = p_rect;
+ area.pos.y += 1;
+ area.size.height -= 2;
+ area.size.width -= arrow->get_size().width + 5;
tree->draw_texture_rect(get_icon("Transparent", "EditorIcons"), area, true);
tree->draw_rect(area, color);
-
}
-
void PropertyEditor::_item_selected() {
-
TreeItem *item = tree->get_selected();
ERR_FAIL_COND(!item);
- selected_property=item->get_metadata(1);
-
+ selected_property = item->get_metadata(1);
}
-
-void PropertyEditor::_edit_set(const String& p_name, const Variant& p_value, bool p_refresh_all, const String& p_changed_field) {
+void PropertyEditor::_edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field) {
if (autoclear) {
TreeItem *item = tree->get_selected();
- if (item && item->get_cell_mode(0)==TreeItem::CELL_MODE_CHECK) {
+ if (item && item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK) {
- item->set_checked(0,true);
+ item->set_checked(0, true);
}
}
- if (!undo_redo|| obj->cast_to<ArrayPropertyEdit>()) { //kind of hacky
+ if (!undo_redo || obj->cast_to<ArrayPropertyEdit>()) { //kind of hacky
- obj->set(p_name,p_value);
+ obj->set(p_name, p_value);
if (p_refresh_all)
- _changed_callbacks(obj,"");
+ _changed_callbacks(obj, "");
else
- _changed_callbacks(obj,p_name);
+ _changed_callbacks(obj, p_name);
- emit_signal(_prop_edited,p_name);
+ emit_signal(_prop_edited, p_name);
} else if (obj->cast_to<MultiNodeEdit>()) {
- obj->cast_to<MultiNodeEdit>()->set_property_field(p_name,p_value,p_changed_field);
- _changed_callbacks(obj,p_name);
- emit_signal(_prop_edited,p_name);
+ obj->cast_to<MultiNodeEdit>()->set_property_field(p_name, p_value, p_changed_field);
+ _changed_callbacks(obj, p_name);
+ emit_signal(_prop_edited, p_name);
} else {
- undo_redo->create_action(TTR("Set")+" "+p_name,UndoRedo::MERGE_ENDS);
- undo_redo->add_do_property(obj,p_name,p_value);
- undo_redo->add_undo_property(obj,p_name,obj->get(p_name));
+ undo_redo->create_action(TTR("Set") + " " + p_name, UndoRedo::MERGE_ENDS);
+ undo_redo->add_do_property(obj, p_name, p_value);
+ undo_redo->add_undo_property(obj, p_name, obj->get(p_name));
if (p_refresh_all) {
- undo_redo->add_do_method(this,"_changed_callback",obj,"");
- undo_redo->add_undo_method(this,"_changed_callback",obj,"");
+ undo_redo->add_do_method(this, "_changed_callback", obj, "");
+ undo_redo->add_undo_method(this, "_changed_callback", obj, "");
} else {
- undo_redo->add_do_method(this,"_changed_callback",obj,p_name);
- undo_redo->add_undo_method(this,"_changed_callback",obj,p_name);
+ undo_redo->add_do_method(this, "_changed_callback", obj, p_name);
+ undo_redo->add_undo_method(this, "_changed_callback", obj, p_name);
}
Resource *r = obj->cast_to<Resource>();
if (r) {
- if (!r->is_edited() && String(p_name)!="resource/edited") {
- undo_redo->add_do_method(r,"set_edited",true);
- undo_redo->add_undo_method(r,"set_edited",false);
+ if (!r->is_edited() && String(p_name) != "resource/edited") {
+ undo_redo->add_do_method(r, "set_edited", true);
+ undo_redo->add_undo_method(r, "set_edited", false);
}
- if (String(p_name)=="resource_local_to_scene") {
+ if (String(p_name) == "resource_local_to_scene") {
bool prev = obj->get(p_name);
bool next = p_value;
if (next) {
- undo_redo->add_do_method(this,"setup_local_to_scene");
+ undo_redo->add_do_method(this, "setup_local_to_scene");
}
if (prev) {
- undo_redo->add_undo_method(this,"setup_local_to_scene");
+ undo_redo->add_undo_method(this, "setup_local_to_scene");
}
}
}
- undo_redo->add_do_method(this,"emit_signal",_prop_edited,p_name);
- undo_redo->add_undo_method(this,"emit_signal",_prop_edited,p_name);
+ undo_redo->add_do_method(this, "emit_signal", _prop_edited, p_name);
+ undo_redo->add_undo_method(this, "emit_signal", _prop_edited, p_name);
undo_redo->commit_action();
}
}
-
void PropertyEditor::_item_edited() {
-
- TreeItem * item = tree->get_edited();
+ TreeItem *item = tree->get_edited();
if (!item)
return; //it all happened too fast..
Dictionary d = item->get_metadata(0);
- String name=d["name"];
+ String name = d["name"];
- if (tree->get_edited_column()==0) {
+ if (tree->get_edited_column() == 0) {
//property checked
if (autoclear) {
if (!item->is_checked(0)) {
- obj->set(name,Variant());
+ obj->set(name, Variant());
update_property(name);
} else {
Variant::CallError ce;
- obj->set(name,Variant::construct(Variant::Type(int(d["type"])),NULL,0,ce));
+ obj->set(name, Variant::construct(Variant::Type(int(d["type"])), NULL, 0, ce));
}
} else {
- emit_signal("property_toggled",name,item->is_checked(0));
+ emit_signal("property_toggled", name, item->is_checked(0));
}
return;
}
- if (autoclear && item->get_cell_mode(0)==TreeItem::CELL_MODE_CHECK && item->get_cell_mode(1)!=TreeItem::CELL_MODE_CUSTOM) {
- item->set_checked(0,true);
-
+ if (autoclear && item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK && item->get_cell_mode(1) != TreeItem::CELL_MODE_CUSTOM) {
+ item->set_checked(0, true);
}
-
- int type=d["type"];
- int hint= d["hint"];
+ int type = d["type"];
+ int hint = d["hint"];
int usage = d["usage"];
- bool refresh_all = usage&PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED;
+ bool refresh_all = usage & PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED;
- String hint_text=d["hint_text"];
- switch(type) {
+ String hint_text = d["hint_text"];
+ switch (type) {
case Variant::NIL: {
} break;
case Variant::BOOL: {
- _edit_set(name,item->is_checked(1),refresh_all);
+ _edit_set(name, item->is_checked(1), refresh_all);
item->set_tooltip(1, item->is_checked(1) ? "True" : "False");
} break;
case Variant::INT:
case Variant::REAL: {
- if (hint==PROPERTY_HINT_LAYERS_2D_PHYSICS || hint==PROPERTY_HINT_LAYERS_2D_RENDER || hint==PROPERTY_HINT_LAYERS_3D_PHYSICS || hint==PROPERTY_HINT_LAYERS_3D_RENDER)
+ if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || hint == PROPERTY_HINT_LAYERS_2D_RENDER || hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || hint == PROPERTY_HINT_LAYERS_3D_RENDER)
break;
- if (hint==PROPERTY_HINT_EXP_EASING)
+ if (hint == PROPERTY_HINT_EXP_EASING)
break;
- if (hint==PROPERTY_HINT_FLAGS)
+ if (hint == PROPERTY_HINT_FLAGS)
break;
- if (type==Variant::INT)
- _edit_set(name,int(item->get_range(1)),refresh_all);
+ if (type == Variant::INT)
+ _edit_set(name, int(item->get_range(1)), refresh_all);
else
- _edit_set(name,item->get_range(1),refresh_all);
+ _edit_set(name, item->get_range(1), refresh_all);
} break;
case Variant::STRING: {
- if (hint==PROPERTY_HINT_ENUM) {
+ if (hint == PROPERTY_HINT_ENUM) {
- int idx= item->get_range(1);
+ int idx = item->get_range(1);
Vector<String> strings = hint_text.split(",");
String txt;
- if (idx>=0 && idx<strings.size()) {
+ if (idx >= 0 && idx < strings.size()) {
- txt=strings[idx];
+ txt = strings[idx];
}
- _edit_set(name,txt,refresh_all);
+ _edit_set(name, txt, refresh_all);
} else {
- _edit_set(name,item->get_text(1),refresh_all);
+ _edit_set(name, item->get_text(1), refresh_all);
}
} break;
- // math types
+ // math types
case Variant::VECTOR3: {
@@ -4094,7 +3910,7 @@ void PropertyEditor::_item_edited() {
} break;
case Variant::NODE_PATH: {
- _edit_set(name, NodePath(item->get_text(1)),refresh_all);
+ _edit_set(name, NodePath(item->get_text(1)), refresh_all);
} break;
@@ -4105,7 +3921,7 @@ void PropertyEditor::_item_edited() {
} break;
- // arrays
+ // arrays
case Variant::POOL_BYTE_ARRAY: {
} break;
@@ -4124,36 +3940,31 @@ void PropertyEditor::_item_edited() {
case Variant::POOL_COLOR_ARRAY: {
} break;
-
-
};
}
-
void PropertyEditor::_resource_edit_request() {
- RES res=custom_editor->get_variant();
+ RES res = custom_editor->get_variant();
if (res.is_null())
return;
- String name=custom_editor->get_name();
+ String name = custom_editor->get_name();
-
- emit_signal("resource_selected",res.get_ref_ptr(),name);
+ emit_signal("resource_selected", res.get_ref_ptr(), name);
}
void PropertyEditor::_custom_editor_edited() {
-
if (!obj)
return;
_edit_set(custom_editor->get_name(), custom_editor->get_variant());
}
-void PropertyEditor::_custom_editor_edited_field(const String& p_field_name) {
+void PropertyEditor::_custom_editor_edited_field(const String &p_field_name) {
- ERR_FAIL_COND(p_field_name=="");
+ ERR_FAIL_COND(p_field_name == "");
if (!obj)
return;
@@ -4163,38 +3974,37 @@ void PropertyEditor::_custom_editor_edited_field(const String& p_field_name) {
void PropertyEditor::_custom_editor_request(bool p_arrow) {
- TreeItem * item = tree->get_edited();
+ TreeItem *item = tree->get_edited();
ERR_FAIL_COND(!item);
Dictionary d = item->get_metadata(0);
//int type=d["type"];
- String name=d["name"];
- Variant::Type type=Variant::NIL;
+ String name = d["name"];
+ Variant::Type type = Variant::NIL;
if (d.has("type"))
- type=(Variant::Type)((int)(d["type"]));
+ type = (Variant::Type)((int)(d["type"]));
- Variant v=obj->get(name);
- int hint=d.has("hint")?d["hint"].operator int():-1;
- String hint_text=d.has("hint_text")?d["hint_text"]:"";
- Rect2 where=tree->get_custom_popup_rect();
+ Variant v = obj->get(name);
+ int hint = d.has("hint") ? d["hint"].operator int() : -1;
+ String hint_text = d.has("hint_text") ? d["hint_text"] : "";
+ Rect2 where = tree->get_custom_popup_rect();
custom_editor->set_pos(where.pos);
- if (custom_editor->edit(obj,name,type,v,hint,hint_text)) {
+ if (custom_editor->edit(obj, name, type, v, hint, hint_text)) {
custom_editor->popup();
}
}
-void PropertyEditor::edit(Object* p_object) {
+void PropertyEditor::edit(Object *p_object) {
-
- if (obj==p_object)
+ if (obj == p_object)
return;
if (obj) {
obj->remove_change_receptor(this);
}
- obj=p_object;
+ obj = p_object;
evaluator->edit(p_object);
@@ -4204,18 +4014,15 @@ void PropertyEditor::edit(Object* p_object) {
obj->add_change_receptor(this);
}
-
-
}
-void PropertyEditor::_set_range_def(Object *p_item, String prop,float p_frame) {
+void PropertyEditor::_set_range_def(Object *p_item, String prop, float p_frame) {
TreeItem *ti = p_item->cast_to<TreeItem>();
ERR_FAIL_COND(!ti);
- ti->call_deferred("set_range",1, p_frame);
- obj->call_deferred("set",prop,p_frame);
-
+ ti->call_deferred("set_range", 1, p_frame);
+ obj->call_deferred("set", prop, p_frame);
}
void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
@@ -4224,49 +4031,48 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
Dictionary d = ti->get_metadata(0);
- if (p_button==2) {
+ if (p_button == 2) {
if (!d.has("name"))
return;
- String prop=d["name"];
- emit_signal("property_keyed",prop,obj->get(prop),false);
- } else if (p_button==5) {
+ String prop = d["name"];
+ emit_signal("property_keyed", prop, obj->get(prop), false);
+ } else if (p_button == 5) {
print_line("PB5");
if (!d.has("name"))
return;
- String prop=d["name"];
- emit_signal("property_keyed",prop,obj->get(prop),true);
+ String prop = d["name"];
+ emit_signal("property_keyed", prop, obj->get(prop), true);
//set_range(p_column, ti->get_range(p_column)+1.0 );
- call_deferred("_set_range_def",ti,prop,ti->get_range(p_column)+1.0);
- } else if (p_button==3) {
+ call_deferred("_set_range_def", ti, prop, ti->get_range(p_column) + 1.0);
+ } else if (p_button == 3) {
if (!d.has("name"))
return;
- String prop=d["name"];
+ String prop = d["name"];
Variant vorig;
- if (_might_be_in_instance() && _get_instanced_node_original_property(prop,vorig)) {
+ if (_might_be_in_instance() && _get_instanced_node_original_property(prop, vorig)) {
- _edit_set(prop,vorig);
+ _edit_set(prop, vorig);
return;
}
- if (obj->call("property_can_revert",prop).operator bool()) {
- Variant rev = obj->call("property_get_revert",prop);
- _edit_set(prop,rev);
+ if (obj->call("property_can_revert", prop).operator bool()) {
+ Variant rev = obj->call("property_get_revert", prop);
+ _edit_set(prop, rev);
}
- if (!obj->get_script().is_null()) {
+ if (!obj->get_script().is_null()) {
Ref<Script> scr = obj->get_script();
Variant orig_value;
- if (scr->get_property_default_value(prop,orig_value)) {
- _edit_set(prop,orig_value);
+ if (scr->get_property_default_value(prop, orig_value)) {
+ _edit_set(prop, orig_value);
}
}
-
} else {
Dictionary d = ti->get_metadata(0);
@@ -4284,7 +4090,7 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
String n = d["name"];
String ht = d["hint_text"];
- if(t == Variant::NODE_PATH) {
+ if (t == Variant::NODE_PATH) {
Variant v = obj->get(n);
custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht);
@@ -4294,72 +4100,69 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) {
custom_editor->set_pos(where.pos);
custom_editor->popup();
- } else if (t==Variant::STRING) {
-
+ } else if (t == Variant::STRING) {
Variant v = obj->get(n);
- custom_editor->edit(obj,n,(Variant::Type)t,v,h,ht);
+ custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht);
//Rect2 where=tree->get_custom_popup_rect();
- if (h==PROPERTY_HINT_FILE || h==PROPERTY_HINT_DIR || h==PROPERTY_HINT_GLOBAL_DIR || h==PROPERTY_HINT_GLOBAL_FILE) {
+ if (h == PROPERTY_HINT_FILE || h == PROPERTY_HINT_DIR || h == PROPERTY_HINT_GLOBAL_DIR || h == PROPERTY_HINT_GLOBAL_FILE) {
- Rect2 where=tree->get_item_rect(ti,1);
- where.pos-=tree->get_scroll();
- where.pos+=tree->get_global_pos();
+ Rect2 where = tree->get_item_rect(ti, 1);
+ where.pos -= tree->get_scroll();
+ where.pos += tree->get_global_pos();
custom_editor->set_pos(where.pos);
custom_editor->popup();
} else {
custom_editor->popup_centered_ratio();
}
- } else if (t==Variant::OBJECT) {
+ } else if (t == Variant::OBJECT) {
RES r = obj->get(n);
if (r.is_valid()) {
- emit_signal("resource_selected",r,n);
+ emit_signal("resource_selected", r, n);
}
- } else if (t==Variant::INT && h==PROPERTY_HINT_OBJECT_ID) {
+ } else if (t == Variant::INT && h == PROPERTY_HINT_OBJECT_ID) {
- emit_signal("object_id_selected",obj->get(n));
+ emit_signal("object_id_selected", obj->get(n));
print_line("OBJ ID SELECTED");
- } else if (t==Variant::ARRAY || t==Variant::POOL_INT_ARRAY || t==Variant::POOL_REAL_ARRAY || t==Variant::POOL_STRING_ARRAY || t==Variant::POOL_VECTOR2_ARRAY || t==Variant::POOL_VECTOR3_ARRAY || t==Variant::POOL_COLOR_ARRAY || t==Variant::POOL_BYTE_ARRAY) {
+ } else if (t == Variant::ARRAY || t == Variant::POOL_INT_ARRAY || t == Variant::POOL_REAL_ARRAY || t == Variant::POOL_STRING_ARRAY || t == Variant::POOL_VECTOR2_ARRAY || t == Variant::POOL_VECTOR3_ARRAY || t == Variant::POOL_COLOR_ARRAY || t == Variant::POOL_BYTE_ARRAY) {
Variant v = obj->get(n);
- if (v.get_type()!=t) {
+ if (v.get_type() != t) {
Variant::CallError ce;
- v=Variant::construct(Variant::Type(t),NULL,0,ce);
+ v = Variant::construct(Variant::Type(t), NULL, 0, ce);
}
- Ref<ArrayPropertyEdit> ape = memnew( ArrayPropertyEdit );
- ape->edit(obj,n,ht,Variant::Type(t));
+ Ref<ArrayPropertyEdit> ape = memnew(ArrayPropertyEdit);
+ ape->edit(obj, n, ht, Variant::Type(t));
EditorNode::get_singleton()->push_item(ape.ptr());
}
}
}
-
void PropertyEditor::_node_removed(Node *p_node) {
- if (p_node==obj) {
+ if (p_node == obj) {
edit(NULL);
}
}
-
void PropertyEditor::set_keying(bool p_active) {
- if (keying==p_active)
+ if (keying == p_active)
return;
- keying=p_active;
+ keying = p_active;
update_tree();
}
-void PropertyEditor::_draw_flags(Object *t,const Rect2& p_rect) {
+void PropertyEditor::_draw_flags(Object *t, const Rect2 &p_rect) {
TreeItem *ti = t->cast_to<TreeItem>();
if (!ti)
@@ -4372,41 +4175,37 @@ void PropertyEditor::_draw_flags(Object *t,const Rect2& p_rect) {
uint32_t f = obj->get(d["name"]);
- int bsize = (p_rect.size.height*80/100)/2;
+ int bsize = (p_rect.size.height * 80 / 100) / 2;
- int h = bsize*2+1;
- int vofs = (p_rect.size.height-h)/2;
+ int h = bsize * 2 + 1;
+ int vofs = (p_rect.size.height - h) / 2;
- for(int i=0;i<2;i++) {
+ for (int i = 0; i < 2; i++) {
- Point2 ofs(4,vofs);
- if (i==1)
- ofs.y+=bsize+1;
+ Point2 ofs(4, vofs);
+ if (i == 1)
+ ofs.y += bsize + 1;
- ofs+=p_rect.pos;
- for(int j=0;j<10;j++) {
+ ofs += p_rect.pos;
+ for (int j = 0; j < 10; j++) {
- Point2 o = ofs+Point2(j*(bsize+1),0);
- if (j>=5)
- o.x+=1;
+ Point2 o = ofs + Point2(j * (bsize + 1), 0);
+ if (j >= 5)
+ o.x += 1;
- uint32_t idx=i*10+j;
- bool on=f&(1<<idx);
- tree->draw_rect(Rect2(o,Size2(bsize,bsize)),Color(0,0,0,on?0.8:0.3));
+ uint32_t idx = i * 10 + j;
+ bool on = f & (1 << idx);
+ tree->draw_rect(Rect2(o, Size2(bsize, bsize)), Color(0, 0, 0, on ? 0.8 : 0.3));
}
}
-
-
}
-void PropertyEditor::_filter_changed(const String& p_text) {
+void PropertyEditor::_filter_changed(const String &p_text) {
update_tree();
}
-
-
-void PropertyEditor::_resource_preview_done(const String& p_path,const Ref<Texture>& p_preview,Variant p_ud) {
+void PropertyEditor::_resource_preview_done(const String &p_path, const Ref<Texture> &p_preview, Variant p_ud) {
if (p_preview.is_null())
return; //don't bother with empty preview
@@ -4423,38 +4222,38 @@ void PropertyEditor::_resource_preview_done(const String& p_path,const Ref<Textu
int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width");
- ti->set_icon(1,p_preview); //should be scaled I think?
- ti->set_icon_max_width(1,tw);
- ti->set_text(1,"");
+ ti->set_icon(1, p_preview); //should be scaled I think?
+ ti->set_icon_max_width(1, tw);
+ ti->set_text(1, "");
}
void PropertyEditor::_bind_methods() {
- ClassDB::bind_method( "_item_edited",&PropertyEditor::_item_edited);
- ClassDB::bind_method( "_item_selected",&PropertyEditor::_item_selected);
- ClassDB::bind_method( "_custom_editor_request",&PropertyEditor::_custom_editor_request);
- ClassDB::bind_method( "_custom_editor_edited",&PropertyEditor::_custom_editor_edited);
- ClassDB::bind_method( "_custom_editor_edited_field",&PropertyEditor::_custom_editor_edited_field,DEFVAL(""));
- ClassDB::bind_method( "_resource_edit_request",&PropertyEditor::_resource_edit_request);
- ClassDB::bind_method( "_node_removed",&PropertyEditor::_node_removed);
- ClassDB::bind_method( "_edit_button",&PropertyEditor::_edit_button);
- ClassDB::bind_method( "_changed_callback",&PropertyEditor::_changed_callbacks);
- ClassDB::bind_method( "_draw_flags",&PropertyEditor::_draw_flags);
- ClassDB::bind_method( "_set_range_def",&PropertyEditor::_set_range_def);
- ClassDB::bind_method( "_filter_changed",&PropertyEditor::_filter_changed);
- ClassDB::bind_method( "update_tree",&PropertyEditor::update_tree);
- ClassDB::bind_method( "_resource_preview_done",&PropertyEditor::_resource_preview_done);
- ClassDB::bind_method( "refresh",&PropertyEditor::refresh);
- ClassDB::bind_method( "_draw_transparency",&PropertyEditor::_draw_transparency);
+ ClassDB::bind_method("_item_edited", &PropertyEditor::_item_edited);
+ ClassDB::bind_method("_item_selected", &PropertyEditor::_item_selected);
+ ClassDB::bind_method("_custom_editor_request", &PropertyEditor::_custom_editor_request);
+ ClassDB::bind_method("_custom_editor_edited", &PropertyEditor::_custom_editor_edited);
+ ClassDB::bind_method("_custom_editor_edited_field", &PropertyEditor::_custom_editor_edited_field, DEFVAL(""));
+ ClassDB::bind_method("_resource_edit_request", &PropertyEditor::_resource_edit_request);
+ ClassDB::bind_method("_node_removed", &PropertyEditor::_node_removed);
+ ClassDB::bind_method("_edit_button", &PropertyEditor::_edit_button);
+ ClassDB::bind_method("_changed_callback", &PropertyEditor::_changed_callbacks);
+ ClassDB::bind_method("_draw_flags", &PropertyEditor::_draw_flags);
+ ClassDB::bind_method("_set_range_def", &PropertyEditor::_set_range_def);
+ ClassDB::bind_method("_filter_changed", &PropertyEditor::_filter_changed);
+ ClassDB::bind_method("update_tree", &PropertyEditor::update_tree);
+ ClassDB::bind_method("_resource_preview_done", &PropertyEditor::_resource_preview_done);
+ ClassDB::bind_method("refresh", &PropertyEditor::refresh);
+ ClassDB::bind_method("_draw_transparency", &PropertyEditor::_draw_transparency);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &PropertyEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &PropertyEditor::can_drop_data_fw);
ClassDB::bind_method(D_METHOD("drop_data_fw"), &PropertyEditor::drop_data_fw);
- ADD_SIGNAL( MethodInfo("property_toggled",PropertyInfo( Variant::STRING, "property"),PropertyInfo( Variant::BOOL, "value")));
- ADD_SIGNAL( MethodInfo("resource_selected", PropertyInfo( Variant::OBJECT, "res"),PropertyInfo( Variant::STRING, "prop") ) );
- ADD_SIGNAL( MethodInfo("object_id_selected", PropertyInfo( Variant::INT, "id")) );
- ADD_SIGNAL( MethodInfo("property_keyed",PropertyInfo( Variant::STRING, "property")));
- ADD_SIGNAL( MethodInfo("property_edited",PropertyInfo( Variant::STRING, "property")));
+ ADD_SIGNAL(MethodInfo("property_toggled", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::BOOL, "value")));
+ ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "res"), PropertyInfo(Variant::STRING, "prop")));
+ ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::INT, "id")));
+ ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property")));
+ ADD_SIGNAL(MethodInfo("property_edited", PropertyInfo(Variant::STRING, "property")));
}
Tree *PropertyEditor::get_scene_tree() {
@@ -4462,7 +4261,7 @@ Tree *PropertyEditor::get_scene_tree() {
return tree;
}
-Label* PropertyEditor::get_top_label() {
+Label *PropertyEditor::get_top_label() {
return top_label;
}
@@ -4470,12 +4269,11 @@ Label* PropertyEditor::get_top_label() {
void PropertyEditor::hide_top_label() {
top_label->hide();
- tree->set_begin( Point2(0,0 ));
+ tree->set_begin(Point2(0, 0));
}
String PropertyEditor::get_selected_path() const {
-
TreeItem *ti = tree->get_selected();
if (!ti)
return "";
@@ -4490,244 +4288,228 @@ String PropertyEditor::get_selected_path() const {
void PropertyEditor::set_capitalize_paths(bool p_capitalize) {
- capitalize_paths=p_capitalize;
+ capitalize_paths = p_capitalize;
}
void PropertyEditor::set_autoclear(bool p_enable) {
- autoclear=p_enable;
+ autoclear = p_enable;
}
void PropertyEditor::set_show_categories(bool p_show) {
- show_categories=p_show;
+ show_categories = p_show;
update_tree();
}
void PropertyEditor::set_use_filter(bool p_use) {
- if (p_use==use_filter)
+ if (p_use == use_filter)
return;
- use_filter=p_use;
+ use_filter = p_use;
update_tree();
}
-void PropertyEditor::register_text_enter(Node* p_line_edit) {
+void PropertyEditor::register_text_enter(Node *p_line_edit) {
ERR_FAIL_NULL(p_line_edit);
- search_box=p_line_edit->cast_to<LineEdit>();
+ search_box = p_line_edit->cast_to<LineEdit>();
if (search_box)
- search_box->connect("text_changed",this,"_filter_changed");
+ search_box->connect("text_changed", this, "_filter_changed");
}
void PropertyEditor::set_subsection_selectable(bool p_selectable) {
- if (p_selectable==subsection_selectable)
+ if (p_selectable == subsection_selectable)
return;
- subsection_selectable=p_selectable;
+ subsection_selectable = p_selectable;
update_tree();
}
PropertyEditor::PropertyEditor() {
- _prop_edited="property_edited";
+ _prop_edited = "property_edited";
- hide_script=false;
+ hide_script = false;
- undo_redo=NULL;
- obj=NULL;
- search_box=NULL;
- changing=false;
- update_tree_pending=false;
+ undo_redo = NULL;
+ obj = NULL;
+ search_box = NULL;
+ changing = false;
+ update_tree_pending = false;
- top_label = memnew( Label );
+ top_label = memnew(Label);
top_label->set_text(TTR("Properties:"));
- top_label->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- top_label->set_begin( Point2( 10,0) );
- top_label->set_end( Point2( 0,12) );
+ top_label->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ top_label->set_begin(Point2(10, 0));
+ top_label->set_end(Point2(0, 12));
add_child(top_label);
-
- tree = memnew( Tree );
- tree->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
- tree->set_begin( Point2(0,19 ));
- tree->set_end( Point2(0,0 ));
+ tree = memnew(Tree);
+ tree->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ tree->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
+ tree->set_begin(Point2(0, 19));
+ tree->set_end(Point2(0, 0));
tree->set_columns(2);
- tree->set_column_expand(0,true);
- tree->set_column_min_width(0,30);
- tree->set_column_expand(1,true);
- tree->set_column_min_width(1,18);
+ tree->set_column_expand(0, true);
+ tree->set_column_min_width(0, 30);
+ tree->set_column_expand(1, true);
+ tree->set_column_min_width(1, 18);
//tree->set_hide_root(true);
- add_child( tree );
+ add_child(tree);
- tree->connect("item_edited", this,"_item_edited",varray(),CONNECT_DEFERRED);
- tree->connect("cell_selected", this,"_item_selected");
+ tree->connect("item_edited", this, "_item_edited", varray(), CONNECT_DEFERRED);
+ tree->connect("cell_selected", this, "_item_selected");
tree->set_drag_forwarding(this);
set_fixed_process(true);
- custom_editor = memnew( CustomPropertyEditor );
+ custom_editor = memnew(CustomPropertyEditor);
add_child(custom_editor);
- tree->connect("custom_popup_edited", this,"_custom_editor_request");
- tree->connect("button_pressed", this,"_edit_button");
- custom_editor->connect("variant_changed", this,"_custom_editor_edited");
- custom_editor->connect("variant_field_changed", this,"_custom_editor_edited_field");
- custom_editor->connect("resource_edit_request", this,"_resource_edit_request",make_binds(),CONNECT_DEFERRED);
+ tree->connect("custom_popup_edited", this, "_custom_editor_request");
+ tree->connect("button_pressed", this, "_edit_button");
+ custom_editor->connect("variant_changed", this, "_custom_editor_edited");
+ custom_editor->connect("variant_field_changed", this, "_custom_editor_edited_field");
+ custom_editor->connect("resource_edit_request", this, "_resource_edit_request", make_binds(), CONNECT_DEFERRED);
tree->set_hide_folding(true);
- evaluator = memnew (PropertyValueEvaluator);
+ evaluator = memnew(PropertyValueEvaluator);
tree->set_value_evaluator(evaluator);
custom_editor->set_value_evaluator(evaluator);
- capitalize_paths=true;
- autoclear=false;
+ capitalize_paths = true;
+ autoclear = false;
tree->set_column_titles_visible(false);
- keying=false;
- read_only=false;
- show_categories=false;
- refresh_countdown=0;
- use_doc_hints=false;
- use_filter=false;
- subsection_selectable=false;
- show_type_icons=EDITOR_DEF("interface/show_type_icons",false);
-
+ keying = false;
+ read_only = false;
+ show_categories = false;
+ refresh_countdown = 0;
+ use_doc_hints = false;
+ use_filter = false;
+ subsection_selectable = false;
+ show_type_icons = EDITOR_DEF("interface/show_type_icons", false);
}
-
-PropertyEditor::~PropertyEditor()
-{
+PropertyEditor::~PropertyEditor() {
memdelete(evaluator);
}
-
/////////////////////////////
-
-
-
-
class SectionedPropertyEditorFilter : public Object {
- GDCLASS( SectionedPropertyEditorFilter, Object );
+ GDCLASS(SectionedPropertyEditorFilter, Object);
Object *edited;
String section;
bool allow_sub;
- bool _set(const StringName& p_name, const Variant& p_value) {
+ bool _set(const StringName &p_name, const Variant &p_value) {
if (!edited)
return false;
- String name=p_name;
- if (section!="") {
- name=section+"/"+name;
+ String name = p_name;
+ if (section != "") {
+ name = section + "/" + name;
}
bool valid;
- edited->set(name,p_value,&valid);
+ edited->set(name, p_value, &valid);
//_change_notify(p_name.operator String().utf8().get_data());
return valid;
}
- bool _get(const StringName& p_name,Variant &r_ret) const{
+ bool _get(const StringName &p_name, Variant &r_ret) const {
if (!edited)
return false;
- String name=p_name;
- if (section!="") {
- name=section+"/"+name;
+ String name = p_name;
+ if (section != "") {
+ name = section + "/" + name;
}
- bool valid=false;
+ bool valid = false;
- r_ret=edited->get(name,&valid);
+ r_ret = edited->get(name, &valid);
return valid;
-
-
}
- void _get_property_list(List<PropertyInfo> *p_list) const{
+ void _get_property_list(List<PropertyInfo> *p_list) const {
if (!edited)
return;
List<PropertyInfo> pinfo;
edited->get_property_list(&pinfo);
- for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- PropertyInfo pi=E->get();
+ PropertyInfo pi = E->get();
int sp = pi.name.find("/");
- if (pi.name=="resource_path" || pi.name=="resource_name" || pi.name.begins_with("script/")) //skip resource stuff
+ if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name.begins_with("script/")) //skip resource stuff
continue;
- if (sp==-1) {
- pi.name="Global/"+pi.name;
-
+ if (sp == -1) {
+ pi.name = "Global/" + pi.name;
}
- if (pi.name.begins_with(section+"/")) {
- pi.name=pi.name.replace_first(section+"/","");
- if (!allow_sub && pi.name.find("/")!=-1)
+ if (pi.name.begins_with(section + "/")) {
+ pi.name = pi.name.replace_first(section + "/", "");
+ if (!allow_sub && pi.name.find("/") != -1)
continue;
p_list->push_back(pi);
}
}
-
}
- bool property_can_revert(const String& p_name) {
+ bool property_can_revert(const String &p_name) {
- return edited->call("property_can_revert",section+"/"+p_name);
+ return edited->call("property_can_revert", section + "/" + p_name);
}
- Variant property_get_revert(const String& p_name) {
+ Variant property_get_revert(const String &p_name) {
- return edited->call("property_get_revert",section+"/"+p_name);
+ return edited->call("property_get_revert", section + "/" + p_name);
}
protected:
static void _bind_methods() {
- ClassDB::bind_method("property_can_revert",&SectionedPropertyEditorFilter::property_can_revert);
- ClassDB::bind_method("property_get_revert",&SectionedPropertyEditorFilter::property_get_revert);
+ ClassDB::bind_method("property_can_revert", &SectionedPropertyEditorFilter::property_can_revert);
+ ClassDB::bind_method("property_get_revert", &SectionedPropertyEditorFilter::property_get_revert);
}
public:
+ void set_section(const String &p_section, bool p_allow_sub) {
- void set_section(const String& p_section,bool p_allow_sub) {
-
- section=p_section;
- allow_sub=p_allow_sub;
+ section = p_section;
+ allow_sub = p_allow_sub;
_change_notify();
}
- void set_edited(Object* p_edited) {
- edited=p_edited;
+ void set_edited(Object *p_edited) {
+ edited = p_edited;
_change_notify();
}
SectionedPropertyEditorFilter() {
- edited=NULL;
+ edited = NULL;
}
-
};
-
void SectionedPropertyEditor::_bind_methods() {
- ClassDB::bind_method("_section_selected",&SectionedPropertyEditor::_section_selected);
+ ClassDB::bind_method("_section_selected", &SectionedPropertyEditor::_section_selected);
ClassDB::bind_method("update_category_list", &SectionedPropertyEditor::update_category_list);
}
@@ -4737,10 +4519,10 @@ void SectionedPropertyEditor::_section_selected() {
if (!sections->get_selected())
return;
- filter->set_section( sections->get_selected()->get_metadata(0), sections->get_selected()->get_children()==NULL);
+ filter->set_section(sections->get_selected()->get_metadata(0), sections->get_selected()->get_children() == NULL);
}
-void SectionedPropertyEditor::set_current_section(const String& p_section) {
+void SectionedPropertyEditor::set_current_section(const String &p_section) {
if (section_map.has(p_section)) {
section_map[p_section]->select(0);
@@ -4755,17 +4537,17 @@ String SectionedPropertyEditor::get_current_section() const {
return "";
}
-String SectionedPropertyEditor::get_full_item_path(const String& p_item) {
+String SectionedPropertyEditor::get_full_item_path(const String &p_item) {
String base = get_current_section();
- if (base!="")
- return base+"/"+p_item;
+ if (base != "")
+ return base + "/" + p_item;
else
return p_item;
}
-void SectionedPropertyEditor::edit(Object* p_object) {
+void SectionedPropertyEditor::edit(Object *p_object) {
if (!p_object) {
obj = -1;
@@ -4798,7 +4580,7 @@ void SectionedPropertyEditor::edit(Object* p_object) {
void SectionedPropertyEditor::update_category_list() {
- String selected_category=get_current_section();
+ String selected_category = get_current_section();
sections->clear();
Object *o = ObjectDB::get_instance(obj);
@@ -4812,48 +4594,43 @@ void SectionedPropertyEditor::update_category_list() {
section_map.clear();
TreeItem *root = sections->create_item();
- section_map[""]=root;
+ section_map[""] = root;
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
+ PropertyInfo pi = E->get();
- PropertyInfo pi=E->get();
-
- if (pi.usage&PROPERTY_USAGE_CATEGORY)
+ if (pi.usage & PROPERTY_USAGE_CATEGORY)
continue;
- else if ( !(pi.usage&PROPERTY_USAGE_EDITOR) )
+ else if (!(pi.usage & PROPERTY_USAGE_EDITOR))
continue;
- if (pi.name.find(":")!=-1 || pi.name=="script" || pi.name=="resource_name" || pi.name=="resource_path")
+ if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path")
continue;
int sp = pi.name.find("/");
- if (sp==-1)
- pi.name="Global/"+pi.name;
+ if (sp == -1)
+ pi.name = "Global/" + pi.name;
Vector<String> sectionarr = pi.name.split("/");
String metasection;
-
- for(int i=0;i<MIN(2,sectionarr.size()-1);i++) {
+ for (int i = 0; i < MIN(2, sectionarr.size() - 1); i++) {
TreeItem *parent = section_map[metasection];
- if (i>0) {
- metasection+="/"+sectionarr[i];
+ if (i > 0) {
+ metasection += "/" + sectionarr[i];
} else {
- metasection=sectionarr[i];
+ metasection = sectionarr[i];
}
-
if (!section_map.has(metasection)) {
TreeItem *ms = sections->create_item(parent);
- section_map[metasection]=ms;
- ms->set_text(0,sectionarr[i].capitalize());
- ms->set_metadata(0,metasection);
-
+ section_map[metasection] = ms;
+ ms->set_text(0, sectionarr[i].capitalize());
+ ms->set_metadata(0, metasection);
}
}
-
}
if (section_map.has(selected_category)) {
@@ -4870,32 +4647,30 @@ SectionedPropertyEditor::SectionedPropertyEditor() {
obj = -1;
- VBoxContainer *left_vb = memnew( VBoxContainer);
- left_vb->set_custom_minimum_size(Size2(160,0)*EDSCALE);
+ VBoxContainer *left_vb = memnew(VBoxContainer);
+ left_vb->set_custom_minimum_size(Size2(160, 0) * EDSCALE);
add_child(left_vb);
- sections = memnew( Tree );
+ sections = memnew(Tree);
sections->set_v_size_flags(SIZE_EXPAND_FILL);
sections->set_hide_root(true);
- left_vb->add_margin_child(TTR("Sections:"),sections,true);
+ left_vb->add_margin_child(TTR("Sections:"), sections, true);
- VBoxContainer *right_vb = memnew( VBoxContainer);
+ VBoxContainer *right_vb = memnew(VBoxContainer);
right_vb->set_h_size_flags(SIZE_EXPAND_FILL);
add_child(right_vb);
- filter = memnew( SectionedPropertyEditorFilter );
- editor = memnew( PropertyEditor );
+ filter = memnew(SectionedPropertyEditorFilter);
+ editor = memnew(PropertyEditor);
editor->set_v_size_flags(SIZE_EXPAND_FILL);
- right_vb->add_margin_child(TTR("Properties:"),editor,true);
+ right_vb->add_margin_child(TTR("Properties:"), editor, true);
editor->get_scene_tree()->set_column_titles_visible(false);
-
editor->hide_top_label();
- sections->connect("cell_selected",this,"_section_selected");
-
+ sections->connect("cell_selected", this, "_section_selected");
}
SectionedPropertyEditor::~SectionedPropertyEditor() {
@@ -4903,12 +4678,12 @@ SectionedPropertyEditor::~SectionedPropertyEditor() {
memdelete(filter);
}
-double PropertyValueEvaluator::eval(const String& p_text) {
+double PropertyValueEvaluator::eval(const String &p_text) {
if (!obj || !script_language)
return _default_eval(p_text);
- Ref<Script> script= Ref<Script>(script_language ->create_script());
+ Ref<Script> script = Ref<Script>(script_language->create_script());
script->set_source_code(_build_script(p_text));
Error err = script->reload();
if (err) {
@@ -4921,8 +4696,8 @@ double PropertyValueEvaluator::eval(const String& p_text) {
return _default_eval(p_text);
Variant::CallError call_err;
- script_instance->call("set_this",obj);
- double result = script_instance->call("e", NULL, 0, call_err );
+ script_instance->call("set_this", obj);
+ double result = script_instance->call("e", NULL, 0, call_err);
if (call_err.error == Variant::CallError::CALL_OK) {
return result;
}
@@ -4933,12 +4708,11 @@ double PropertyValueEvaluator::eval(const String& p_text) {
return _default_eval(p_text);
}
-
void PropertyValueEvaluator::edit(Object *p_obj) {
obj = p_obj;
}
-String PropertyValueEvaluator::_build_script(const String& p_text) {
+String PropertyValueEvaluator::_build_script(const String &p_text) {
String script_text = "tool\nvar this\nfunc set_this(p_this):\n\tthis=p_this\nfunc e():\n\treturn ";
script_text += p_text.strip_edges();
script_text += "\n";
@@ -4946,15 +4720,14 @@ String PropertyValueEvaluator::_build_script(const String& p_text) {
}
PropertyValueEvaluator::PropertyValueEvaluator() {
- script_language=NULL;
+ script_language = NULL;
- for(int i=0;i<ScriptServer::get_language_count();i++) {
- if (ScriptServer::get_language(i)->get_name()=="GDScript") {
- script_language=ScriptServer::get_language(i);
+ for (int i = 0; i < ScriptServer::get_language_count(); i++) {
+ if (ScriptServer::get_language(i)->get_name() == "GDScript") {
+ script_language = ScriptServer::get_language(i);
}
}
}
PropertyValueEvaluator::~PropertyValueEvaluator() {
-
}
diff --git a/editor/property_editor.h b/editor/property_editor.h
index c9ae9a85cc..f7f8d0e974 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -29,19 +29,19 @@
#ifndef PROPERTY_EDITOR_H
#define PROPERTY_EDITOR_H
-#include "scene/gui/tree.h"
+#include "editor/editor_file_dialog.h"
#include "scene/gui/button.h"
#include "scene/gui/check_box.h"
-#include "scene/gui/label.h"
-#include "editor/editor_file_dialog.h"
-#include "scene/gui/dialogs.h"
+#include "scene/gui/check_button.h"
#include "scene/gui/color_picker.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/grid_container.h"
+#include "scene/gui/label.h"
#include "scene/gui/menu_button.h"
-#include "scene/gui/texture_rect.h"
-#include "scene/gui/text_edit.h"
-#include "scene/gui/check_button.h"
#include "scene/gui/split_container.h"
-#include "scene/gui/grid_container.h"
+#include "scene/gui/text_edit.h"
+#include "scene/gui/texture_rect.h"
+#include "scene/gui/tree.h"
#include "scene_tree_editor.h"
/**
@@ -54,21 +54,21 @@ class PropertySelector;
class CustomPropertyEditor : public Popup {
- GDCLASS( CustomPropertyEditor, Popup );
+ GDCLASS(CustomPropertyEditor, Popup);
enum {
- MAX_VALUE_EDITORS=12,
- MAX_ACTION_BUTTONS=5,
- OBJ_MENU_LOAD=0,
- OBJ_MENU_EDIT=1,
- OBJ_MENU_CLEAR=2,
- OBJ_MENU_MAKE_UNIQUE=3,
- OBJ_MENU_COPY=4,
- OBJ_MENU_PASTE=5,
- OBJ_MENU_REIMPORT=6,
- OBJ_MENU_NEW_SCRIPT=7,
- OBJ_MENU_SHOW_IN_FILE_SYSTEM=8,
- TYPE_BASE_ID=100
+ MAX_VALUE_EDITORS = 12,
+ MAX_ACTION_BUTTONS = 5,
+ OBJ_MENU_LOAD = 0,
+ OBJ_MENU_EDIT = 1,
+ OBJ_MENU_CLEAR = 2,
+ OBJ_MENU_MAKE_UNIQUE = 3,
+ OBJ_MENU_COPY = 4,
+ OBJ_MENU_PASTE = 5,
+ OBJ_MENU_REIMPORT = 6,
+ OBJ_MENU_NEW_SCRIPT = 7,
+ OBJ_MENU_SHOW_IN_FILE_SYSTEM = 8,
+ TYPE_BASE_ID = 100
};
enum {
@@ -80,7 +80,6 @@ class CustomPropertyEditor : public Popup {
EASING_OUT_IN
};
-
PopupMenu *menu;
SceneTreeDialog *scene_tree;
EditorFileDialog *file;
@@ -108,12 +107,11 @@ class CustomPropertyEditor : public Popup {
SpinBox *spinbox;
HSlider *slider;
-
Control *easing_draw;
CreateDialog *create_dialog;
PropertySelector *property_select;
- Object* owner;
+ Object *owner;
bool updating;
@@ -131,46 +129,41 @@ class CustomPropertyEditor : public Popup {
void _create_dialog_callback();
void _create_selected_property(const String &p_prop);
-
- void _color_changed(const Color& p_color);
+ void _color_changed(const Color &p_color);
void _draw_easing();
void _menu_option(int p_which);
- void _drag_easing(const InputEvent& p_ev);
+ void _drag_easing(const InputEvent &p_ev);
void _node_path_selected(NodePath p_path);
void show_value_editors(int p_amount);
- void config_value_editors(int p_amount, int p_columns,int p_label_w,const List<String>& p_strings);
- void config_action_buttons(const List<String>& p_strings);
+ void config_value_editors(int p_amount, int p_columns, int p_label_w, const List<String> &p_strings);
+ void config_action_buttons(const List<String> &p_strings);
void _emit_changed_whole_or_field();
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
public:
-
-
void hide_menu();
Variant get_variant() const;
String get_name() const;
- void set_read_only(bool p_read_only) { read_only=p_read_only; }
+ void set_read_only(bool p_read_only) { read_only = p_read_only; }
- void set_value_evaluator( PropertyValueEvaluator *p_evaluator) { evaluator=p_evaluator; }
+ void set_value_evaluator(PropertyValueEvaluator *p_evaluator) { evaluator = p_evaluator; }
- bool edit(Object* p_owner,const String& p_name,Variant::Type p_type, const Variant& p_variant,int p_hint,String p_hint_text);
+ bool edit(Object *p_owner, const String &p_name, Variant::Type p_type, const Variant &p_variant, int p_hint, String p_hint_text);
CustomPropertyEditor();
};
class PropertyEditor : public Control {
- GDCLASS( PropertyEditor, Control );
+ GDCLASS(PropertyEditor, Control);
Tree *tree;
Label *top_label;
@@ -179,8 +172,7 @@ class PropertyEditor : public Control {
PropertyValueEvaluator *evaluator;
- Object* obj;
-
+ Object *obj;
StringName _prop_edited;
@@ -198,91 +190,93 @@ class PropertyEditor : public Control {
bool subsection_selectable;
bool hide_script;
- HashMap<String,String> pending;
+ HashMap<String, String> pending;
String selected_property;
- Map<StringName,Map<StringName,String> > descr_cache;
- Map<StringName,String > class_descr_cache;
+ Map<StringName, Map<StringName, String> > descr_cache;
+ Map<StringName, String> class_descr_cache;
CustomPropertyEditor *custom_editor;
void _resource_edit_request();
void _custom_editor_edited();
- void _custom_editor_edited_field(const String& p_field_name);
+ void _custom_editor_edited_field(const String &p_field_name);
void _custom_editor_request(bool p_arrow);
void _item_selected();
void _item_edited();
- TreeItem *get_parent_node(String p_path,HashMap<String,TreeItem*>& item_paths,TreeItem *root);
-
- void set_item_text(TreeItem *p_item, int p_type, const String& p_name, int p_hint=PROPERTY_HINT_NONE, const String& p_hint_text="");
+ TreeItem *get_parent_node(String p_path, HashMap<String, TreeItem *> &item_paths, TreeItem *root);
- TreeItem *find_item(TreeItem *p_item,const String& p_name);
+ void set_item_text(TreeItem *p_item, int p_type, const String &p_name, int p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "");
+ TreeItem *find_item(TreeItem *p_item, const String &p_name);
- virtual void _changed_callback(Object *p_changed,const char * p_what);
- virtual void _changed_callbacks(Object *p_changed,const String& p_callback);
+ virtual void _changed_callback(Object *p_changed, const char *p_what);
+ virtual void _changed_callbacks(Object *p_changed, const String &p_callback);
- void _check_reload_status(const String&p_name,TreeItem* item);
+ void _check_reload_status(const String &p_name, TreeItem *item);
void _edit_button(Object *p_item, int p_column, int p_button);
void _node_removed(Node *p_node);
-friend class ProjectExportDialog;
- void _edit_set(const String& p_name, const Variant& p_value,bool p_refresh_all=false, const String& p_changed_field="");
- void _draw_flags(Object *ti,const Rect2& p_rect);
+ friend class ProjectExportDialog;
+ void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all = false, const String &p_changed_field = "");
+ void _draw_flags(Object *ti, const Rect2 &p_rect);
bool _might_be_in_instance();
- bool _get_instanced_node_original_property(const StringName& p_prop,Variant& value);
- bool _is_property_different(const Variant& p_current, const Variant& p_orig,int p_usage=0);
+ bool _get_instanced_node_original_property(const StringName &p_prop, Variant &value);
+ bool _is_property_different(const Variant &p_current, const Variant &p_orig, int p_usage = 0);
void _refresh_item(TreeItem *p_item);
void _set_range_def(Object *p_item, String prop, float p_frame);
- void _filter_changed(const String& p_text);
+ void _filter_changed(const String &p_text);
- void _mark_drop_fields(TreeItem* p_at);
- void _clear_drop_fields(TreeItem* p_at);
+ void _mark_drop_fields(TreeItem *p_at);
+ void _clear_drop_fields(TreeItem *p_at);
- bool _is_drop_valid(const Dictionary& p_drag_data, const Dictionary& p_item_data) const;
- Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
- bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
- void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
+ bool _is_drop_valid(const Dictionary &p_drag_data, const Dictionary &p_item_data) const;
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
- void _resource_preview_done(const String& p_path,const Ref<Texture>& p_preview,Variant p_ud);
- void _draw_transparency(Object *t, const Rect2& p_rect);
+ void _resource_preview_done(const String &p_path, const Ref<Texture> &p_preview, Variant p_ud);
+ void _draw_transparency(Object *t, const Rect2 &p_rect);
UndoRedo *undo_redo;
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; }
+public:
+ void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
String get_selected_path() const;
Tree *get_scene_tree();
- Label* get_top_label();
+ Label *get_top_label();
void hide_top_label();
void update_tree();
- void update_property(const String& p_prop);
+ void update_property(const String &p_prop);
void refresh();
- void edit(Object* p_object);
+ void edit(Object *p_object);
void set_keying(bool p_active);
- void set_read_only(bool p_read_only) { read_only=p_read_only; custom_editor->set_read_only(p_read_only);}
+ void set_read_only(bool p_read_only) {
+ read_only = p_read_only;
+ custom_editor->set_read_only(p_read_only);
+ }
void set_capitalize_paths(bool p_capitalize);
void set_autoclear(bool p_enable);
void set_show_categories(bool p_show);
- void set_use_doc_hints(bool p_enable) { use_doc_hints=p_enable; }
- void set_hide_script(bool p_hide) { hide_script=p_hide; }
+ void set_use_doc_hints(bool p_enable) { use_doc_hints = p_enable; }
+ void set_hide_script(bool p_hide) { hide_script = p_hide; }
void set_use_filter(bool p_use);
void register_text_enter(Node *p_line_edit);
@@ -291,36 +285,31 @@ public:
PropertyEditor();
~PropertyEditor();
-
};
-
class SectionedPropertyEditorFilter;
class SectionedPropertyEditor : public HBoxContainer {
-
- GDCLASS(SectionedPropertyEditor,HBoxContainer);
+ GDCLASS(SectionedPropertyEditor, HBoxContainer);
ObjectID obj;
Tree *sections;
SectionedPropertyEditorFilter *filter;
- Map<String,TreeItem*> section_map;
+ Map<String, TreeItem *> section_map;
PropertyEditor *editor;
-
static void _bind_methods();
void _section_selected();
public:
-
PropertyEditor *get_property_editor();
- void edit(Object* p_object);
- String get_full_item_path(const String& p_item);
+ void edit(Object *p_object);
+ String get_full_item_path(const String &p_item);
- void set_current_section(const String& p_section);
+ void set_current_section(const String &p_section);
String get_current_section() const;
void update_category_list();
@@ -330,20 +319,19 @@ public:
};
class PropertyValueEvaluator : public ValueEvaluator {
- GDCLASS( PropertyValueEvaluator, ValueEvaluator );
+ GDCLASS(PropertyValueEvaluator, ValueEvaluator);
Object *obj;
ScriptLanguage *script_language;
- String _build_script(const String& p_text);
+ String _build_script(const String &p_text);
- _FORCE_INLINE_ double _default_eval(const String& p_text) {
+ _FORCE_INLINE_ double _default_eval(const String &p_text) {
return p_text.to_double();
}
public:
-
void edit(Object *p_obj);
- double eval(const String& p_text);
+ double eval(const String &p_text);
PropertyValueEvaluator();
~PropertyValueEvaluator();
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp
index 71ffae4729..34086ba905 100644
--- a/editor/property_selector.cpp
+++ b/editor/property_selector.cpp
@@ -31,16 +31,16 @@
#include "editor_scale.h"
#include "os/keyboard.h"
-void PropertySelector::_text_changed(const String& p_newtext) {
+void PropertySelector::_text_changed(const String &p_newtext) {
_update_search();
}
-void PropertySelector::_sbox_input(const InputEvent& p_ie) {
+void PropertySelector::_sbox_input(const InputEvent &p_ie) {
- if (p_ie.type==InputEvent::KEY) {
+ if (p_ie.type == InputEvent::KEY) {
- switch(p_ie.key.scancode) {
+ switch (p_ie.key.scancode) {
case KEY_UP:
case KEY_DOWN:
case KEY_PAGEUP:
@@ -68,10 +68,8 @@ void PropertySelector::_sbox_input(const InputEvent& p_ie) {
}
}
-
void PropertySelector::_update_search() {
-
if (properties)
set_title(TTR("Select Property"));
else
@@ -80,138 +78,132 @@ void PropertySelector::_update_search() {
search_options->clear();
help_bit->set_text("");
-
TreeItem *root = search_options->create_item();
-
if (properties) {
List<PropertyInfo> props;
if (instance) {
- instance->get_property_list(&props,true);
- } else if (type!=Variant::NIL) {
+ instance->get_property_list(&props, true);
+ } else if (type != Variant::NIL) {
Variant v;
- if (type==Variant::INPUT_EVENT) {
+ if (type == Variant::INPUT_EVENT) {
InputEvent ie;
- ie.type=event_type;
- v=ie;
+ ie.type = event_type;
+ v = ie;
} else {
Variant::CallError ce;
- v=Variant::construct(type,NULL,0,ce);
+ v = Variant::construct(type, NULL, 0, ce);
}
v.get_property_list(&props);
} else {
-
Object *obj = ObjectDB::get_instance(script);
if (obj && obj->cast_to<Script>()) {
- props.push_back(PropertyInfo(Variant::NIL,"Script Variables",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_CATEGORY));
+ props.push_back(PropertyInfo(Variant::NIL, "Script Variables", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_CATEGORY));
obj->cast_to<Script>()->get_script_property_list(&props);
}
- StringName base=base_type;
- while(base) {
- props.push_back(PropertyInfo(Variant::NIL,base,PROPERTY_HINT_NONE,"",PROPERTY_USAGE_CATEGORY));
- ClassDB::get_property_list(base,&props,true);
- base=ClassDB::get_parent_class(base);
+ StringName base = base_type;
+ while (base) {
+ props.push_back(PropertyInfo(Variant::NIL, base, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_CATEGORY));
+ ClassDB::get_property_list(base, &props, true);
+ base = ClassDB::get_parent_class(base);
}
-
}
- TreeItem *category=NULL;
-
- bool found=false;
-
- Ref<Texture> type_icons[Variant::VARIANT_MAX]={
- Control::get_icon("MiniVariant","EditorIcons"),
- Control::get_icon("MiniBoolean","EditorIcons"),
- Control::get_icon("MiniInteger","EditorIcons"),
- Control::get_icon("MiniFloat","EditorIcons"),
- Control::get_icon("MiniString","EditorIcons"),
- Control::get_icon("MiniVector2","EditorIcons"),
- Control::get_icon("MiniRect2","EditorIcons"),
- Control::get_icon("MiniVector3","EditorIcons"),
- Control::get_icon("MiniMatrix2","EditorIcons"),
- Control::get_icon("MiniPlane","EditorIcons"),
- Control::get_icon("MiniQuat","EditorIcons"),
- Control::get_icon("MiniAabb","EditorIcons"),
- Control::get_icon("MiniMatrix3","EditorIcons"),
- Control::get_icon("MiniTransform","EditorIcons"),
- Control::get_icon("MiniColor","EditorIcons"),
- Control::get_icon("MiniImage","EditorIcons"),
- Control::get_icon("MiniPath","EditorIcons"),
- Control::get_icon("MiniRid","EditorIcons"),
- Control::get_icon("MiniObject","EditorIcons"),
- Control::get_icon("MiniInput","EditorIcons"),
- Control::get_icon("MiniDictionary","EditorIcons"),
- Control::get_icon("MiniArray","EditorIcons"),
- Control::get_icon("MiniRawArray","EditorIcons"),
- Control::get_icon("MiniIntArray","EditorIcons"),
- Control::get_icon("MiniFloatArray","EditorIcons"),
- Control::get_icon("MiniStringArray","EditorIcons"),
- Control::get_icon("MiniVector2Array","EditorIcons"),
- Control::get_icon("MiniVector3Array","EditorIcons"),
- Control::get_icon("MiniColorArray","EditorIcons")
+ TreeItem *category = NULL;
+
+ bool found = false;
+
+ Ref<Texture> type_icons[Variant::VARIANT_MAX] = {
+ Control::get_icon("MiniVariant", "EditorIcons"),
+ Control::get_icon("MiniBoolean", "EditorIcons"),
+ Control::get_icon("MiniInteger", "EditorIcons"),
+ Control::get_icon("MiniFloat", "EditorIcons"),
+ Control::get_icon("MiniString", "EditorIcons"),
+ Control::get_icon("MiniVector2", "EditorIcons"),
+ Control::get_icon("MiniRect2", "EditorIcons"),
+ Control::get_icon("MiniVector3", "EditorIcons"),
+ Control::get_icon("MiniMatrix2", "EditorIcons"),
+ Control::get_icon("MiniPlane", "EditorIcons"),
+ Control::get_icon("MiniQuat", "EditorIcons"),
+ Control::get_icon("MiniAabb", "EditorIcons"),
+ Control::get_icon("MiniMatrix3", "EditorIcons"),
+ Control::get_icon("MiniTransform", "EditorIcons"),
+ Control::get_icon("MiniColor", "EditorIcons"),
+ Control::get_icon("MiniImage", "EditorIcons"),
+ Control::get_icon("MiniPath", "EditorIcons"),
+ Control::get_icon("MiniRid", "EditorIcons"),
+ Control::get_icon("MiniObject", "EditorIcons"),
+ Control::get_icon("MiniInput", "EditorIcons"),
+ Control::get_icon("MiniDictionary", "EditorIcons"),
+ Control::get_icon("MiniArray", "EditorIcons"),
+ Control::get_icon("MiniRawArray", "EditorIcons"),
+ Control::get_icon("MiniIntArray", "EditorIcons"),
+ Control::get_icon("MiniFloatArray", "EditorIcons"),
+ Control::get_icon("MiniStringArray", "EditorIcons"),
+ Control::get_icon("MiniVector2Array", "EditorIcons"),
+ Control::get_icon("MiniVector3Array", "EditorIcons"),
+ Control::get_icon("MiniColorArray", "EditorIcons")
};
-
- for (List<PropertyInfo>::Element *E=props.front();E;E=E->next()) {
- if (E->get().usage==PROPERTY_USAGE_CATEGORY) {
- if (category && category->get_children()==NULL) {
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+ if (E->get().usage == PROPERTY_USAGE_CATEGORY) {
+ if (category && category->get_children() == NULL) {
memdelete(category); //old category was unused
}
category = search_options->create_item(root);
- category->set_text(0,E->get().name);
- category->set_selectable(0,false);
+ category->set_text(0, E->get().name);
+ category->set_selectable(0, false);
Ref<Texture> icon;
- if (E->get().name=="Script Variables") {
- icon=get_icon("Script","EditorIcons");
- } else if (has_icon(E->get().name,"EditorIcons")) {
- icon=get_icon(E->get().name,"EditorIcons");
+ if (E->get().name == "Script Variables") {
+ icon = get_icon("Script", "EditorIcons");
+ } else if (has_icon(E->get().name, "EditorIcons")) {
+ icon = get_icon(E->get().name, "EditorIcons");
} else {
- icon=get_icon("Object","EditorIcons");
+ icon = get_icon("Object", "EditorIcons");
}
- category->set_icon(0,icon);
+ category->set_icon(0, icon);
continue;
}
- if (!(E->get().usage&PROPERTY_USAGE_EDITOR))
+ if (!(E->get().usage & PROPERTY_USAGE_EDITOR))
continue;
- if (search_box->get_text()!=String() && E->get().name.find(search_box->get_text())==-1)
+ if (search_box->get_text() != String() && E->get().name.find(search_box->get_text()) == -1)
continue;
- TreeItem *item = search_options->create_item(category?category:root);
- item->set_text(0,E->get().name);
- item->set_metadata(0,E->get().name);
- item->set_icon(0,type_icons[E->get().type]);
+ TreeItem *item = search_options->create_item(category ? category : root);
+ item->set_text(0, E->get().name);
+ item->set_metadata(0, E->get().name);
+ item->set_icon(0, type_icons[E->get().type]);
- if (!found && search_box->get_text()!=String() && E->get().name.find(search_box->get_text())!=-1) {
+ if (!found && search_box->get_text() != String() && E->get().name.find(search_box->get_text()) != -1) {
item->select(0);
- found=true;
+ found = true;
}
- item->set_selectable(0,true);
+ item->set_selectable(0, true);
}
- if (category && category->get_children()==NULL) {
+ if (category && category->get_children() == NULL) {
memdelete(category); //old category was unused
}
} else {
List<MethodInfo> methods;
- if (type!=Variant::NIL) {
+ if (type != Variant::NIL) {
Variant v;
Variant::CallError ce;
- v=Variant::construct(type,NULL,0,ce);
+ v = Variant::construct(type, NULL, 0, ce);
v.get_method_list(&methods);
} else {
-
Object *obj = ObjectDB::get_instance(script);
if (obj && obj->cast_to<Script>()) {
@@ -219,116 +211,107 @@ void PropertySelector::_update_search() {
obj->cast_to<Script>()->get_script_method_list(&methods);
}
- StringName base=base_type;
- while(base) {
- methods.push_back(MethodInfo("*"+String(base)));
- ClassDB::get_method_list(base,&methods,true);
- base=ClassDB::get_parent_class(base);
+ StringName base = base_type;
+ while (base) {
+ methods.push_back(MethodInfo("*" + String(base)));
+ ClassDB::get_method_list(base, &methods, true);
+ base = ClassDB::get_parent_class(base);
}
-
}
- TreeItem *category=NULL;
+ TreeItem *category = NULL;
- bool found=false;
- bool script_methods=false;
+ bool found = false;
+ bool script_methods = false;
- for (List<MethodInfo>::Element *E=methods.front();E;E=E->next()) {
+ for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
if (E->get().name.begins_with("*")) {
- if (category && category->get_children()==NULL) {
+ if (category && category->get_children() == NULL) {
memdelete(category); //old category was unused
}
category = search_options->create_item(root);
- category->set_text(0,E->get().name.replace_first("*",""));
- category->set_selectable(0,false);
+ category->set_text(0, E->get().name.replace_first("*", ""));
+ category->set_selectable(0, false);
Ref<Texture> icon;
- script_methods=false;
- if (E->get().name=="*Script Methods") {
- icon=get_icon("Script","EditorIcons");
- script_methods=true;
- } else if (has_icon(E->get().name,"EditorIcons")) {
- icon=get_icon(E->get().name,"EditorIcons");
+ script_methods = false;
+ if (E->get().name == "*Script Methods") {
+ icon = get_icon("Script", "EditorIcons");
+ script_methods = true;
+ } else if (has_icon(E->get().name, "EditorIcons")) {
+ icon = get_icon(E->get().name, "EditorIcons");
} else {
- icon=get_icon("Object","EditorIcons");
+ icon = get_icon("Object", "EditorIcons");
}
- category->set_icon(0,icon);
+ category->set_icon(0, icon);
continue;
}
- String name = E->get().name.get_slice(":",0);
- if (!script_methods && name.begins_with("_") && !(E->get().flags&METHOD_FLAG_VIRTUAL))
+ String name = E->get().name.get_slice(":", 0);
+ if (!script_methods && name.begins_with("_") && !(E->get().flags & METHOD_FLAG_VIRTUAL))
continue;
- if (search_box->get_text()!=String() && name.find(search_box->get_text())==-1)
+ if (search_box->get_text() != String() && name.find(search_box->get_text()) == -1)
continue;
- TreeItem *item = search_options->create_item(category?category:root);
+ TreeItem *item = search_options->create_item(category ? category : root);
- MethodInfo mi=E->get();
+ MethodInfo mi = E->get();
String desc;
- if (mi.name.find(":")!=-1) {
- desc=mi.name.get_slice(":",1)+" ";
- mi.name=mi.name.get_slice(":",0);
- } else if (mi.return_val.type!=Variant::NIL)
- desc=Variant::get_type_name(mi.return_val.type);
+ if (mi.name.find(":") != -1) {
+ desc = mi.name.get_slice(":", 1) + " ";
+ mi.name = mi.name.get_slice(":", 0);
+ } else if (mi.return_val.type != Variant::NIL)
+ desc = Variant::get_type_name(mi.return_val.type);
else
- desc="void ";
-
-
+ desc = "void ";
- desc+=" "+mi.name+" ( ";
+ desc += " " + mi.name + " ( ";
- for(int i=0;i<mi.arguments.size();i++) {
+ for (int i = 0; i < mi.arguments.size(); i++) {
- if (i>0)
- desc+=", ";
+ if (i > 0)
+ desc += ", ";
- if (mi.arguments[i].type==Variant::NIL)
- desc+="var ";
- else if (mi.arguments[i].name.find(":")!=-1) {
- desc+=mi.arguments[i].name.get_slice(":",1)+" ";
- mi.arguments[i].name=mi.arguments[i].name.get_slice(":",0);
+ if (mi.arguments[i].type == Variant::NIL)
+ desc += "var ";
+ else if (mi.arguments[i].name.find(":") != -1) {
+ desc += mi.arguments[i].name.get_slice(":", 1) + " ";
+ mi.arguments[i].name = mi.arguments[i].name.get_slice(":", 0);
} else
- desc+=Variant::get_type_name(mi.arguments[i].type)+" ";
-
- desc+=mi.arguments[i].name;
+ desc += Variant::get_type_name(mi.arguments[i].type) + " ";
+ desc += mi.arguments[i].name;
}
- desc+=" )";
+ desc += " )";
- item->set_text(0,desc);
- item->set_metadata(0,name);
- item->set_selectable(0,true);
+ item->set_text(0, desc);
+ item->set_metadata(0, name);
+ item->set_selectable(0, true);
- if (!found && search_box->get_text()!=String() && name.find(search_box->get_text())!=-1) {
+ if (!found && search_box->get_text() != String() && name.find(search_box->get_text()) != -1) {
item->select(0);
- found=true;
+ found = true;
}
-
}
- if (category && category->get_children()==NULL) {
+ if (category && category->get_children() == NULL) {
memdelete(category); //old category was unused
}
-
}
- get_ok()->set_disabled(root->get_children()==NULL);
-
+ get_ok()->set_disabled(root->get_children() == NULL);
}
-
-
void PropertySelector::_confirmed() {
TreeItem *ti = search_options->get_selected();
if (!ti)
return;
- emit_signal("selected",ti->get_metadata(0));
+ emit_signal("selected", ti->get_metadata(0));
hide();
}
@@ -336,125 +319,112 @@ void PropertySelector::_item_selected() {
help_bit->set_text("");
- TreeItem *item=search_options->get_selected();
+ TreeItem *item = search_options->get_selected();
if (!item)
return;
String name = item->get_metadata(0);
String class_type;
- if (properties && type==Variant::INPUT_EVENT) {
-
- switch(event_type) {
- case InputEvent::NONE: class_type="InputEvent"; break;
- case InputEvent::KEY: class_type="InputEventKey"; break;
- case InputEvent::MOUSE_MOTION: class_type="InputEventMouseMotion"; break;
- case InputEvent::MOUSE_BUTTON: class_type="InputEventMouseButton"; break;
- case InputEvent::JOYPAD_MOTION: class_type="InputEventJoypadMotion"; break;
- case InputEvent::JOYPAD_BUTTON: class_type="InputEventJoypadButton"; break;
- case InputEvent::SCREEN_TOUCH: class_type="InputEventScreenTouch"; break;
- case InputEvent::SCREEN_DRAG: class_type="InputEventScreenDrag"; break;
- case InputEvent::ACTION: class_type="InputEventAction"; break;
+ if (properties && type == Variant::INPUT_EVENT) {
+
+ switch (event_type) {
+ case InputEvent::NONE: class_type = "InputEvent"; break;
+ case InputEvent::KEY: class_type = "InputEventKey"; break;
+ case InputEvent::MOUSE_MOTION: class_type = "InputEventMouseMotion"; break;
+ case InputEvent::MOUSE_BUTTON: class_type = "InputEventMouseButton"; break;
+ case InputEvent::JOYPAD_MOTION: class_type = "InputEventJoypadMotion"; break;
+ case InputEvent::JOYPAD_BUTTON: class_type = "InputEventJoypadButton"; break;
+ case InputEvent::SCREEN_TOUCH: class_type = "InputEventScreenTouch"; break;
+ case InputEvent::SCREEN_DRAG: class_type = "InputEventScreenDrag"; break;
+ case InputEvent::ACTION: class_type = "InputEventAction"; break;
default: {}
}
} else if (type) {
- class_type=Variant::get_type_name(type);
+ class_type = Variant::get_type_name(type);
} else {
- class_type=base_type;
+ class_type = base_type;
}
- DocData *dd=EditorHelp::get_doc_data();
+ DocData *dd = EditorHelp::get_doc_data();
String text;
-
if (properties) {
- String at_class=class_type;
-
-
+ String at_class = class_type;
- while(at_class!=String()) {
+ while (at_class != String()) {
-
- Map<String,DocData::ClassDoc>::Element *E=dd->class_list.find(at_class);
+ Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class);
if (E) {
- for(int i=0;i<E->get().properties.size();i++) {
- if (E->get().properties[i].name==name) {
- text=E->get().properties[i].description;
+ for (int i = 0; i < E->get().properties.size(); i++) {
+ if (E->get().properties[i].name == name) {
+ text = E->get().properties[i].description;
}
}
}
- at_class=ClassDB::get_parent_class(at_class);
+ at_class = ClassDB::get_parent_class(at_class);
}
- if (text==String()) {
+ if (text == String()) {
StringName setter;
StringName type;
- if (ClassDB::get_setter_and_type_for_property(class_type,name,type,setter)) {
- Map<String,DocData::ClassDoc>::Element *E=dd->class_list.find(type);
+ if (ClassDB::get_setter_and_type_for_property(class_type, name, type, setter)) {
+ Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type);
if (E) {
- for(int i=0;i<E->get().methods.size();i++) {
- if (E->get().methods[i].name==setter.operator String()) {
- text=E->get().methods[i].description;
+ for (int i = 0; i < E->get().methods.size(); i++) {
+ if (E->get().methods[i].name == setter.operator String()) {
+ text = E->get().methods[i].description;
}
}
}
-
-
}
}
} else {
+ String at_class = class_type;
- String at_class=class_type;
-
- while(at_class!=String()) {
+ while (at_class != String()) {
- Map<String,DocData::ClassDoc>::Element *E=dd->class_list.find(at_class);
+ Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class);
if (E) {
- for(int i=0;i<E->get().methods.size();i++) {
- if (E->get().methods[i].name==name) {
- text=E->get().methods[i].description;
+ for (int i = 0; i < E->get().methods.size(); i++) {
+ if (E->get().methods[i].name == name) {
+ text = E->get().methods[i].description;
}
}
}
- at_class=ClassDB::get_parent_class(at_class);
+ at_class = ClassDB::get_parent_class(at_class);
}
}
-
- if (text==String())
+ if (text == String())
return;
help_bit->set_text(text);
-
}
-
void PropertySelector::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
-
- connect("confirmed",this,"_confirmed");
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ connect("confirmed", this, "_confirmed");
}
}
+void PropertySelector::select_method_from_base_type(const String &p_base, const String &p_current) {
-
-void PropertySelector::select_method_from_base_type(const String& p_base,const String& p_current) {
-
- base_type=p_base;
- selected=p_current;
- type=Variant::NIL;
- script=0;
- properties=false;
- instance=NULL;
+ base_type = p_base;
+ selected = p_current;
+ type = Variant::NIL;
+ script = 0;
+ properties = false;
+ instance = NULL;
popup_centered_ratio(0.6);
search_box->set_text("");
@@ -462,70 +432,65 @@ void PropertySelector::select_method_from_base_type(const String& p_base,const S
_update_search();
}
-void PropertySelector::select_method_from_script(const Ref<Script>& p_script,const String& p_current){
+void PropertySelector::select_method_from_script(const Ref<Script> &p_script, const String &p_current) {
- ERR_FAIL_COND( p_script.is_null() );
- base_type=p_script->get_instance_base_type();
- selected=p_current;
- type=Variant::NIL;
- script=p_script->get_instance_ID();
- properties=false;
- instance=NULL;
+ ERR_FAIL_COND(p_script.is_null());
+ base_type = p_script->get_instance_base_type();
+ selected = p_current;
+ type = Variant::NIL;
+ script = p_script->get_instance_ID();
+ properties = false;
+ instance = NULL;
popup_centered_ratio(0.6);
search_box->set_text("");
search_box->grab_focus();
_update_search();
-
}
-void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const String &p_current){
+void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const String &p_current) {
- ERR_FAIL_COND(p_type==Variant::NIL);
- base_type="";
- selected=p_current;
- type=p_type;
- script=0;
- properties=false;
- instance=NULL;
+ ERR_FAIL_COND(p_type == Variant::NIL);
+ base_type = "";
+ selected = p_current;
+ type = p_type;
+ script = 0;
+ properties = false;
+ instance = NULL;
popup_centered_ratio(0.6);
search_box->set_text("");
search_box->grab_focus();
_update_search();
-
}
-void PropertySelector::select_method_from_instance(Object* p_instance, const String &p_current){
-
+void PropertySelector::select_method_from_instance(Object *p_instance, const String &p_current) {
- base_type=p_instance->get_class();
- selected=p_current;
- type=Variant::NIL;
- script=0;
+ base_type = p_instance->get_class();
+ selected = p_current;
+ type = Variant::NIL;
+ script = 0;
{
Ref<Script> scr = p_instance->get_script();
if (scr.is_valid())
- script=scr->get_instance_ID();
+ script = scr->get_instance_ID();
}
- properties=false;
- instance=NULL;
+ properties = false;
+ instance = NULL;
popup_centered_ratio(0.6);
search_box->set_text("");
search_box->grab_focus();
_update_search();
-
}
+void PropertySelector::select_property_from_base_type(const String &p_base, const String &p_current) {
-void PropertySelector::select_property_from_base_type(const String& p_base,const String& p_current) {
-
- base_type=p_base;
- selected=p_current;
- type=Variant::NIL;
- script=0;
- properties=true;
- instance=NULL;
+ base_type = p_base;
+ selected = p_current;
+ type = Variant::NIL;
+ script = 0;
+ properties = true;
+ instance = NULL;
popup_centered_ratio(0.6);
search_box->set_text("");
@@ -533,94 +498,85 @@ void PropertySelector::select_property_from_base_type(const String& p_base,const
_update_search();
}
-void PropertySelector::select_property_from_script(const Ref<Script>& p_script,const String& p_current){
+void PropertySelector::select_property_from_script(const Ref<Script> &p_script, const String &p_current) {
- ERR_FAIL_COND( p_script.is_null() );
+ ERR_FAIL_COND(p_script.is_null());
- base_type=p_script->get_instance_base_type();
- selected=p_current;
- type=Variant::NIL;
- script=p_script->get_instance_ID();
- properties=true;
- instance=NULL;
+ base_type = p_script->get_instance_base_type();
+ selected = p_current;
+ type = Variant::NIL;
+ script = p_script->get_instance_ID();
+ properties = true;
+ instance = NULL;
popup_centered_ratio(0.6);
search_box->set_text("");
search_box->grab_focus();
_update_search();
-
}
-void PropertySelector::select_property_from_basic_type(Variant::Type p_type, InputEvent::Type p_event_type, const String &p_current){
+void PropertySelector::select_property_from_basic_type(Variant::Type p_type, InputEvent::Type p_event_type, const String &p_current) {
- ERR_FAIL_COND(p_type==Variant::NIL);
- base_type="";
- selected=p_current;
- type=p_type;
- event_type=p_event_type;
- script=0;
- properties=true;
- instance=NULL;
+ ERR_FAIL_COND(p_type == Variant::NIL);
+ base_type = "";
+ selected = p_current;
+ type = p_type;
+ event_type = p_event_type;
+ script = 0;
+ properties = true;
+ instance = NULL;
popup_centered_ratio(0.6);
search_box->set_text("");
search_box->grab_focus();
_update_search();
-
}
-void PropertySelector::select_property_from_instance(Object* p_instance, const String &p_current){
-
+void PropertySelector::select_property_from_instance(Object *p_instance, const String &p_current) {
- base_type="";
- selected=p_current;
- type=Variant::NIL;
- script=0;
- properties=true;
- instance=p_instance;
+ base_type = "";
+ selected = p_current;
+ type = Variant::NIL;
+ script = 0;
+ properties = true;
+ instance = p_instance;
popup_centered_ratio(0.6);
search_box->set_text("");
search_box->grab_focus();
_update_search();
-
}
void PropertySelector::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_text_changed"),&PropertySelector::_text_changed);
- ClassDB::bind_method(D_METHOD("_confirmed"),&PropertySelector::_confirmed);
- ClassDB::bind_method(D_METHOD("_sbox_input"),&PropertySelector::_sbox_input);
- ClassDB::bind_method(D_METHOD("_item_selected"),&PropertySelector::_item_selected);
-
- ADD_SIGNAL(MethodInfo("selected",PropertyInfo(Variant::STRING,"name")));
+ ClassDB::bind_method(D_METHOD("_text_changed"), &PropertySelector::_text_changed);
+ ClassDB::bind_method(D_METHOD("_confirmed"), &PropertySelector::_confirmed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"), &PropertySelector::_sbox_input);
+ ClassDB::bind_method(D_METHOD("_item_selected"), &PropertySelector::_item_selected);
+ ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::STRING, "name")));
}
-
PropertySelector::PropertySelector() {
-
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
//set_child_rect(vbc);
- search_box = memnew( LineEdit );
- vbc->add_margin_child(TTR("Search:"),search_box);
- search_box->connect("text_changed",this,"_text_changed");
- search_box->connect("gui_input",this,"_sbox_input");
- search_options = memnew( Tree );
- vbc->add_margin_child(TTR("Matches:"),search_options,true);
+ search_box = memnew(LineEdit);
+ vbc->add_margin_child(TTR("Search:"), search_box);
+ search_box->connect("text_changed", this, "_text_changed");
+ search_box->connect("gui_input", this, "_sbox_input");
+ search_options = memnew(Tree);
+ vbc->add_margin_child(TTR("Matches:"), search_options, true);
get_ok()->set_text(TTR("Open"));
get_ok()->set_disabled(true);
register_text_enter(search_box);
set_hide_on_ok(false);
- search_options->connect("item_activated",this,"_confirmed");
- search_options->connect("cell_selected",this,"_item_selected");
+ search_options->connect("item_activated", this, "_confirmed");
+ search_options->connect("cell_selected", this, "_item_selected");
search_options->set_hide_root(true);
search_options->set_hide_folding(true);
- help_bit = memnew( EditorHelpBit );
- vbc->add_margin_child(TTR("Description:"),help_bit);
- help_bit->connect("request_hide",this,"_closed");
-
-
+ help_bit = memnew(EditorHelpBit);
+ vbc->add_margin_child(TTR("Description:"), help_bit);
+ help_bit->connect("request_hide", this, "_closed");
}
diff --git a/editor/property_selector.h b/editor/property_selector.h
index c2ce996be2..c6903ee680 100644
--- a/editor/property_selector.h
+++ b/editor/property_selector.h
@@ -30,22 +30,21 @@
#define PROPERTYSELECTOR_H
#include "editor/property_editor.h"
-#include "scene/gui/rich_text_label.h"
#include "editor_help.h"
+#include "scene/gui/rich_text_label.h"
class PropertySelector : public ConfirmationDialog {
- GDCLASS(PropertySelector,ConfirmationDialog )
-
+ GDCLASS(PropertySelector, ConfirmationDialog)
LineEdit *search_box;
Tree *search_options;
void _update_search();
- void _sbox_input(const InputEvent& p_ie);
+ void _sbox_input(const InputEvent &p_ie);
void _confirmed();
- void _text_changed(const String& p_newtext);
+ void _text_changed(const String &p_newtext);
EditorHelpBit *help_bit;
@@ -58,24 +57,21 @@ class PropertySelector : public ConfirmationDialog {
Object *instance;
void _item_selected();
+
protected:
void _notification(int p_what);
static void _bind_methods();
-
-
public:
-
-
- void select_method_from_base_type(const String& p_base,const String& p_current="");
- void select_method_from_script(const Ref<Script>& p_script,const String& p_current="");
- void select_method_from_basic_type(Variant::Type p_type,const String& p_current="");
- void select_method_from_instance(Object* p_instance, const String &p_current="");
-
- void select_property_from_base_type(const String& p_base,const String& p_current="");
- void select_property_from_script(const Ref<Script>& p_script,const String& p_current="");
- void select_property_from_basic_type(Variant::Type p_type,InputEvent::Type p_event_type,const String& p_current="");
- void select_property_from_instance(Object* p_instance, const String &p_current="");
+ void select_method_from_base_type(const String &p_base, const String &p_current = "");
+ void select_method_from_script(const Ref<Script> &p_script, const String &p_current = "");
+ void select_method_from_basic_type(Variant::Type p_type, const String &p_current = "");
+ void select_method_from_instance(Object *p_instance, const String &p_current = "");
+
+ void select_property_from_base_type(const String &p_base, const String &p_current = "");
+ void select_property_from_script(const Ref<Script> &p_script, const String &p_current = "");
+ void select_property_from_basic_type(Variant::Type p_type, InputEvent::Type p_event_type, const String &p_current = "");
+ void select_property_from_instance(Object *p_instance, const String &p_current = "");
PropertySelector();
};
diff --git a/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp
index b130f6c773..4b4e74cd62 100644
--- a/editor/pvrtc_compress.cpp
+++ b/editor/pvrtc_compress.cpp
@@ -29,21 +29,21 @@
#include "pvrtc_compress.h"
#include "editor_settings.h"
-#include "scene/resources/texture.h"
-#include "io/resource_saver.h"
#include "io/resource_loader.h"
-#include "os/os.h"
+#include "io/resource_saver.h"
#include "os/file_access.h"
+#include "os/os.h"
+#include "scene/resources/texture.h"
-static void (*_base_image_compress_pvrtc2_func)(Image *)=NULL;
-static void (*_base_image_compress_pvrtc4_func)(Image *)=NULL;
+static void (*_base_image_compress_pvrtc2_func)(Image *) = NULL;
+static void (*_base_image_compress_pvrtc4_func)(Image *) = NULL;
-static void _compress_image(Image::CompressMode p_mode,Image *p_image) {
+static void _compress_image(Image::CompressMode p_mode, Image *p_image) {
String ttpath = EditorSettings::get_singleton()->get("filesystem/import/pvrtc_texture_tool");
- if (ttpath.strip_edges()=="" || !FileAccess::exists(ttpath)) {
- switch(p_mode) {
+ if (ttpath.strip_edges() == "" || !FileAccess::exists(ttpath)) {
+ switch (p_mode) {
case Image::COMPRESS_PVRTC2:
if (_base_image_compress_pvrtc2_func)
@@ -51,37 +51,34 @@ static void _compress_image(Image::CompressMode p_mode,Image *p_image) {
else if (_base_image_compress_pvrtc4_func)
_base_image_compress_pvrtc4_func(p_image);
- break;
+ break;
case Image::COMPRESS_PVRTC4:
if (_base_image_compress_pvrtc4_func)
_base_image_compress_pvrtc4_func(p_image);
- break;
+ break;
default: ERR_FAIL();
-
}
return;
}
String spath = EditorSettings::get_singleton()->get_settings_path();
-
List<String> args;
- String src_img = spath+"/"+"_tmp_src_img.png";
- String dst_img = spath+"/"+"_tmp_dst_img.pvr";
+ String src_img = spath + "/" + "_tmp_src_img.png";
+ String dst_img = spath + "/" + "_tmp_dst_img.pvr";
args.push_back("-i");
args.push_back(src_img);
args.push_back("-o");
args.push_back(dst_img);
args.push_back("-f");
- switch(p_mode) {
+ switch (p_mode) {
case Image::COMPRESS_PVRTC2: args.push_back("PVRTC2"); break;
case Image::COMPRESS_PVRTC4: args.push_back("PVRTC4"); break;
case Image::COMPRESS_ETC: args.push_back("ETC"); break;
default: ERR_FAIL();
-
}
if (EditorSettings::get_singleton()->get("filesystem/import/pvrtc_fast_conversion").operator bool()) {
@@ -90,45 +87,43 @@ static void _compress_image(Image::CompressMode p_mode,Image *p_image) {
if (p_image->has_mipmaps())
args.push_back("-m");
- Ref<ImageTexture> t = memnew( ImageTexture );
- t->create_from_image(*p_image,0);
- ResourceSaver::save(src_img,t);
+ Ref<ImageTexture> t = memnew(ImageTexture);
+ t->create_from_image(*p_image, 0);
+ ResourceSaver::save(src_img, t);
- Error err = OS::get_singleton()->execute(ttpath,args,true);
- ERR_EXPLAIN(TTR("Could not execute PVRTC tool:")+" "+ttpath);
- ERR_FAIL_COND(err!=OK);
+ Error err = OS::get_singleton()->execute(ttpath, args, true);
+ ERR_EXPLAIN(TTR("Could not execute PVRTC tool:") + " " + ttpath);
+ ERR_FAIL_COND(err != OK);
+ t = ResourceLoader::load(dst_img, "Texture");
- t=ResourceLoader::load(dst_img,"Texture");
-
- ERR_EXPLAIN(TTR("Can't load back converted image using PVRTC tool:")+" "+dst_img);
+ ERR_EXPLAIN(TTR("Can't load back converted image using PVRTC tool:") + " " + dst_img);
ERR_FAIL_COND(t.is_null());
- *p_image=t->get_data();
+ *p_image = t->get_data();
}
-
static void _compress_pvrtc2(Image *p_image) {
- _compress_image(Image::COMPRESS_PVRTC2,p_image);
+ _compress_image(Image::COMPRESS_PVRTC2, p_image);
}
static void _compress_pvrtc4(Image *p_image) {
- _compress_image(Image::COMPRESS_PVRTC4,p_image);
+ _compress_image(Image::COMPRESS_PVRTC4, p_image);
}
static void _compress_etc(Image *p_image) {
- _compress_image(Image::COMPRESS_ETC,p_image);
+ _compress_image(Image::COMPRESS_ETC, p_image);
}
void _pvrtc_register_compressors() {
- _base_image_compress_pvrtc2_func=Image::_image_compress_pvrtc2_func;
- _base_image_compress_pvrtc4_func=Image::_image_compress_pvrtc4_func;
+ _base_image_compress_pvrtc2_func = Image::_image_compress_pvrtc2_func;
+ _base_image_compress_pvrtc4_func = Image::_image_compress_pvrtc4_func;
- Image::_image_compress_pvrtc2_func=_compress_pvrtc2;
- Image::_image_compress_pvrtc4_func=_compress_pvrtc4;
+ Image::_image_compress_pvrtc2_func = _compress_pvrtc2;
+ Image::_image_compress_pvrtc4_func = _compress_pvrtc4;
//Image::_image_compress_etc_func=_compress_etc; //use the built in one for ETC
}
diff --git a/editor/pvrtc_compress.h b/editor/pvrtc_compress.h
index 4ba29026c5..3699a731a0 100644
--- a/editor/pvrtc_compress.h
+++ b/editor/pvrtc_compress.h
@@ -33,5 +33,4 @@
void _pvrtc_register_compressors();
-
#endif // PVRTC_COMPRESS_H
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp
index f43189a7bf..bc6b0ad9f3 100644
--- a/editor/quick_open.cpp
+++ b/editor/quick_open.cpp
@@ -32,7 +32,7 @@
void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) {
- add_directories=p_add_dirs;
+ add_directories = p_add_dirs;
popup_centered_ratio(0.6);
if (p_dontclear)
search_box->select_all();
@@ -43,7 +43,7 @@ void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool
else
search_options->set_select_mode(Tree::SELECT_SINGLE);
search_box->grab_focus();
- base_type=p_base;
+ base_type = p_base;
_update_search();
}
@@ -60,10 +60,10 @@ Vector<String> EditorQuickOpen::get_selected_files() const {
Vector<String> files;
- TreeItem* item = search_options->get_next_selected(search_options->get_root());
+ TreeItem *item = search_options->get_next_selected(search_options->get_root());
while (item) {
- files.push_back("res://"+item->get_text(0));
+ files.push_back("res://" + item->get_text(0));
item = search_options->get_next_selected(item);
}
@@ -71,16 +71,16 @@ Vector<String> EditorQuickOpen::get_selected_files() const {
return files;
}
-void EditorQuickOpen::_text_changed(const String& p_newtext) {
+void EditorQuickOpen::_text_changed(const String &p_newtext) {
_update_search();
}
-void EditorQuickOpen::_sbox_input(const InputEvent& p_ie) {
+void EditorQuickOpen::_sbox_input(const InputEvent &p_ie) {
- if (p_ie.type==InputEvent::KEY) {
+ if (p_ie.type == InputEvent::KEY) {
- switch(p_ie.key.scancode) {
+ switch (p_ie.key.scancode) {
case KEY_UP:
case KEY_DOWN:
case KEY_PAGEUP:
@@ -106,7 +106,6 @@ void EditorQuickOpen::_sbox_input(const InputEvent& p_ie) {
} break;
}
}
-
}
float EditorQuickOpen::_path_cmp(String search, String path) const {
@@ -120,10 +119,10 @@ float EditorQuickOpen::_path_cmp(String search, String path) const {
return path.to_lower().similarity(search.to_lower());
}
-void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< String, Ref<Texture> > > &list) {
+void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture> > > &list) {
if (!add_directories) {
- for(int i=0;i<efsd->get_subdir_count();i++) {
+ for (int i = 0; i < efsd->get_subdir_count(); i++) {
_parse_fs(efsd->get_subdir(i), list);
}
@@ -134,11 +133,11 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< S
if (add_directories) {
String path = efsd->get_path();
if (!path.ends_with("/"))
- path+="/";
- if (path!="res://") {
- path=path.substr(6,path.length());
+ path += "/";
+ if (path != "res://") {
+ path = path.substr(6, path.length());
if (search_text.is_subsequence_ofi(path)) {
- Pair< String, Ref<Texture> > pair;
+ Pair<String, Ref<Texture> > pair;
pair.first = path;
pair.second = get_icon("folder", "FileDialog");
@@ -161,13 +160,13 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< S
}
}
}
- for(int i=0;i<efsd->get_file_count();i++) {
+ for (int i = 0; i < efsd->get_file_count(); i++) {
String file = efsd->get_file_path(i);
- file=file.substr(6,file.length());
+ file = file.substr(6, file.length());
- if (ClassDB::is_parent_class(efsd->get_file_type(i),base_type) && (search_text.is_subsequence_ofi(file))) {
- Pair< String, Ref<Texture> > pair;
+ if (ClassDB::is_parent_class(efsd->get_file_type(i), base_type) && (search_text.is_subsequence_ofi(file))) {
+ Pair<String, Ref<Texture> > pair;
pair.first = file;
pair.second = get_icon((has_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei);
@@ -191,14 +190,12 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< S
}
}
-
if (add_directories) {
- for(int i=0;i<efsd->get_subdir_count();i++) {
+ for (int i = 0; i < efsd->get_subdir_count(); i++) {
_parse_fs(efsd->get_subdir(i), list);
}
}
-
}
void EditorQuickOpen::_update_search() {
@@ -206,7 +203,7 @@ void EditorQuickOpen::_update_search() {
search_options->clear();
TreeItem *root = search_options->create_item();
EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem();
- Vector< Pair< String, Ref<Texture> > > list;
+ Vector<Pair<String, Ref<Texture> > > list;
_parse_fs(efsd, list);
@@ -223,8 +220,7 @@ void EditorQuickOpen::_update_search() {
ti->set_as_cursor(0);
}
- get_ok()->set_disabled(root->get_children()==NULL);
-
+ get_ok()->set_disabled(root->get_children() == NULL);
}
void EditorQuickOpen::_confirmed() {
@@ -238,13 +234,12 @@ void EditorQuickOpen::_confirmed() {
void EditorQuickOpen::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- connect("confirmed",this,"_confirmed");
+ connect("confirmed", this, "_confirmed");
}
}
-
StringName EditorQuickOpen::get_base_type() const {
return base_type;
@@ -252,34 +247,31 @@ StringName EditorQuickOpen::get_base_type() const {
void EditorQuickOpen::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_text_changed"),&EditorQuickOpen::_text_changed);
- ClassDB::bind_method(D_METHOD("_confirmed"),&EditorQuickOpen::_confirmed);
- ClassDB::bind_method(D_METHOD("_sbox_input"),&EditorQuickOpen::_sbox_input);
+ ClassDB::bind_method(D_METHOD("_text_changed"), &EditorQuickOpen::_text_changed);
+ ClassDB::bind_method(D_METHOD("_confirmed"), &EditorQuickOpen::_confirmed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"), &EditorQuickOpen::_sbox_input);
ADD_SIGNAL(MethodInfo("quick_open"));
-
}
-
EditorQuickOpen::EditorQuickOpen() {
-
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
//set_child_rect(vbc);
- search_box = memnew( LineEdit );
- vbc->add_margin_child(TTR("Search:"),search_box);
- search_box->connect("text_changed",this,"_text_changed");
- search_box->connect("gui_input",this,"_sbox_input");
- search_options = memnew( Tree );
- vbc->add_margin_child(TTR("Matches:"),search_options,true);
+ search_box = memnew(LineEdit);
+ vbc->add_margin_child(TTR("Search:"), search_box);
+ search_box->connect("text_changed", this, "_text_changed");
+ search_box->connect("gui_input", this, "_sbox_input");
+ search_options = memnew(Tree);
+ vbc->add_margin_child(TTR("Matches:"), search_options, true);
get_ok()->set_text(TTR("Open"));
get_ok()->set_disabled(true);
register_text_enter(search_box);
set_hide_on_ok(false);
- search_options->connect("item_activated",this,"_confirmed");
+ search_options->connect("item_activated", this, "_confirmed");
search_options->set_hide_root(true);
- ei="EditorIcons";
- ot="Object";
- add_directories=false;
+ ei = "EditorIcons";
+ ot = "Object";
+ add_directories = false;
}
diff --git a/editor/quick_open.h b/editor/quick_open.h
index ef91d910b1..bcb0842c49 100644
--- a/editor/quick_open.h
+++ b/editor/quick_open.h
@@ -29,13 +29,13 @@
#ifndef EDITOR_QUICK_OPEN_H
#define EDITOR_QUICK_OPEN_H
-#include "scene/gui/dialogs.h"
-#include "scene/gui/tree.h"
#include "editor_file_system.h"
#include "pair.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/tree.h"
class EditorQuickOpen : public ConfirmationDialog {
- GDCLASS(EditorQuickOpen,ConfirmationDialog )
+ GDCLASS(EditorQuickOpen, ConfirmationDialog)
LineEdit *search_box;
Tree *search_options;
@@ -44,29 +44,26 @@ class EditorQuickOpen : public ConfirmationDialog {
StringName ot;
bool add_directories;
-
void _update_search();
- void _sbox_input(const InputEvent& p_ie);
- void _parse_fs(EditorFileSystemDirectory *efsd, Vector< Pair< String,Ref <Texture> > > &list);
+ void _sbox_input(const InputEvent &p_ie);
+ void _parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture> > > &list);
float _path_cmp(String search, String path) const;
-
void _confirmed();
- void _text_changed(const String& p_newtext);
+ void _text_changed(const String &p_newtext);
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
StringName get_base_type() const;
String get_selected() const;
Vector<String> get_selected_files() const;
- void popup(const StringName& p_base,bool p_enable_multi=false,bool p_add_dirs=false,bool p_dontclear=false);
+ void popup(const StringName &p_base, bool p_enable_multi = false, bool p_add_dirs = false, bool p_dontclear = false);
EditorQuickOpen();
};
diff --git a/editor/register_exporters.h b/editor/register_exporters.h
index 30ec522a00..d6afd1459a 100644
--- a/editor/register_exporters.h
+++ b/editor/register_exporters.h
@@ -29,7 +29,6 @@
#ifndef REGISTER_EXPORTERS_H
#define REGISTER_EXPORTERS_H
-
void register_exporters();
#endif
diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp
index c5b74d9006..3305c1642a 100644
--- a/editor/reparent_dialog.cpp
+++ b/editor/reparent_dialog.cpp
@@ -28,23 +28,23 @@
/*************************************************************************/
#include "reparent_dialog.h"
-#include "scene/gui/label.h"
-#include "scene/gui/box_container.h"
#include "print_string.h"
+#include "scene/gui/box_container.h"
+#include "scene/gui/label.h"
void ReparentDialog::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- connect("confirmed", this,"_reparent");
+ connect("confirmed", this, "_reparent");
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
- disconnect("confirmed", this,"_reparent");
+ disconnect("confirmed", this, "_reparent");
}
- 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()));
@@ -54,67 +54,60 @@ void ReparentDialog::_notification(int p_what) {
void ReparentDialog::_cancel() {
hide();
-
}
void ReparentDialog::_reparent() {
if (tree->get_selected()) {
- emit_signal("reparent",tree->get_selected()->get_path(),keep_transform->is_pressed());
+ emit_signal("reparent", tree->get_selected()->get_path(), keep_transform->is_pressed());
hide();
}
}
-void ReparentDialog::set_current(const Set<Node*>& p_selection) {
+void ReparentDialog::set_current(const Set<Node *> &p_selection) {
- tree->set_marked(p_selection,false,false);
+ tree->set_marked(p_selection, false, false);
//tree->set_selected(p_node->get_parent());
}
void ReparentDialog::_bind_methods() {
- ClassDB::bind_method("_reparent",&ReparentDialog::_reparent);
- ClassDB::bind_method("_cancel",&ReparentDialog::_cancel);
+ ClassDB::bind_method("_reparent", &ReparentDialog::_reparent);
+ ClassDB::bind_method("_cancel", &ReparentDialog::_cancel);
- ADD_SIGNAL( MethodInfo("reparent",PropertyInfo(Variant::NODE_PATH,"path"),PropertyInfo(Variant::BOOL,"keep_global_xform")));
+ ADD_SIGNAL(MethodInfo("reparent", PropertyInfo(Variant::NODE_PATH, "path"), PropertyInfo(Variant::BOOL, "keep_global_xform")));
}
-
ReparentDialog::ReparentDialog() {
set_title(TTR("Reparent Node"));
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
//set_child_rect(vbc);
- tree = memnew( SceneTreeEditor(false) );
+ tree = memnew(SceneTreeEditor(false));
tree->set_show_enabled_subscene(true);
- vbc->add_margin_child(TTR("Reparent Location (Select new Parent):"),tree,true);
+ vbc->add_margin_child(TTR("Reparent Location (Select new Parent):"), tree, true);
- tree->get_scene_tree()->connect("item_activated",this,"_reparent");
+ tree->get_scene_tree()->connect("item_activated", this, "_reparent");
//Label *label = memnew( Label );
//label->set_pos( Point2( 15,8) );
//label->set_text("Reparent Location (Select new Parent):");
- keep_transform = memnew( CheckBox );
+ keep_transform = memnew(CheckBox);
keep_transform->set_text(TTR("Keep Global Transform"));
keep_transform->set_pressed(true);
vbc->add_child(keep_transform);
-
//vbc->add_margin_child("Options:",node_only);
//cancel->connect("pressed", this,"_cancel");
get_ok()->set_text(TTR("Reparent"));
-
}
-
-ReparentDialog::~ReparentDialog()
-{
+ReparentDialog::~ReparentDialog() {
}
-
diff --git a/editor/reparent_dialog.h b/editor/reparent_dialog.h
index 200760314c..c66963e298 100644
--- a/editor/reparent_dialog.h
+++ b/editor/reparent_dialog.h
@@ -29,40 +29,36 @@
#ifndef REPARENT_DIALOG_H
#define REPARENT_DIALOG_H
-#include "scene/gui/dialogs.h"
+#include "editor/scene_tree_editor.h"
#include "scene/gui/button.h"
-#include "scene/gui/check_button.h"
#include "scene/gui/check_box.h"
-#include "editor/scene_tree_editor.h"
+#include "scene/gui/check_button.h"
+#include "scene/gui/dialogs.h"
#include "scene/gui/line_edit.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class ReparentDialog : public ConfirmationDialog {
- GDCLASS( ReparentDialog, ConfirmationDialog );
+ GDCLASS(ReparentDialog, ConfirmationDialog);
SceneTreeEditor *tree;
CheckBox *keep_transform;
-
void update_tree();
void _reparent();
void _cancel();
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_current(const Set<Node*>& p_selection);
+public:
+ void set_current(const Set<Node *> &p_selection);
String get_selected_type();
ReparentDialog();
~ReparentDialog();
-
};
#endif
diff --git a/editor/resources_dock.cpp b/editor/resources_dock.cpp
index 8648361bae..c5f141562a 100644
--- a/editor/resources_dock.cpp
+++ b/editor/resources_dock.cpp
@@ -28,20 +28,19 @@
/*************************************************************************/
#include "resources_dock.h"
+#include "editor_file_system.h"
#include "editor_node.h"
+#include "editor_settings.h"
+#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
-#include "editor_settings.h"
#include "project_settings.h"
-#include "global_config.h"
-#include "editor_file_system.h"
-
void ResourcesDock::_tool_selected(int p_tool) {
- current_action=p_tool;
+ current_action = p_tool;
- switch(p_tool) {
+ switch (p_tool) {
case TOOL_NEW: {
@@ -58,8 +57,7 @@ void ResourcesDock::_tool_selected(int p_tool) {
break;
Ref<Resource> current_res = ti->get_metadata(0);
-
- if (current_res->get_path()!="" && current_res->get_path().find("::")==-1) {
+ if (current_res->get_path() != "" && current_res->get_path().find("::") == -1) {
_file_action(current_res->get_path());
break;
};
@@ -73,7 +71,6 @@ void ResourcesDock::_tool_selected(int p_tool) {
save_resource_as(ti->get_metadata(0));
-
} break;
case TOOL_MAKE_LOCAL: {
@@ -97,93 +94,84 @@ void ResourcesDock::_tool_selected(int p_tool) {
add_resource(EditorSettings::get_singleton()->get_resource_clipboard());
} break;
-
}
}
-
-
void ResourcesDock::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- button_new->set_icon(get_icon("New","EditorIcons"));
- button_open->set_icon(get_icon("Folder","EditorIcons"));
- button_save->set_icon(get_icon("Save","EditorIcons"));
- button_tools->set_icon(get_icon("Tools","EditorIcons"));
-
+ button_new->set_icon(get_icon("New", "EditorIcons"));
+ button_open->set_icon(get_icon("Folder", "EditorIcons"));
+ button_save->set_icon(get_icon("Save", "EditorIcons"));
+ button_tools->set_icon(get_icon("Tools", "EditorIcons"));
} break;
}
-
}
-
-void ResourcesDock::save_resource(const String& p_path,const Ref<Resource>& p_resource) {
+void ResourcesDock::save_resource(const String &p_path, const Ref<Resource> &p_resource) {
editor->get_editor_data().apply_changes_in_editors();
- int flg=0;
+ int flg = 0;
if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources"))
- flg|=ResourceSaver::FLAG_COMPRESS;
+ flg |= ResourceSaver::FLAG_COMPRESS;
/*
if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative"))
flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
*/
String path = GlobalConfig::get_singleton()->localize_path(p_path);
- Error err = ResourceSaver::save(path,p_resource,flg|ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
+ Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
- if (err!=OK) {
+ if (err != OK) {
accept->set_text(TTR("Error saving resource!"));
accept->popup_centered_minsize();
- return;
+ return;
}
//EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
- ((Resource*)p_resource.ptr())->set_path(path);
- editor->emit_signal("resource_saved",p_resource);
-
+ ((Resource *)p_resource.ptr())->set_path(path);
+ editor->emit_signal("resource_saved", p_resource);
}
-void ResourcesDock::save_resource_as(const Ref<Resource>& p_resource) {
+void ResourcesDock::save_resource_as(const Ref<Resource> &p_resource) {
- current_action=TOOL_SAVE_AS;
+ current_action = TOOL_SAVE_AS;
RES res(p_resource);
List<String> extensions;
- ResourceSaver::get_recognized_extensions(res,&extensions);
+ ResourceSaver::get_recognized_extensions(res, &extensions);
file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
- if (p_resource->get_path()!="" && p_resource->get_path().find("::")==-1) {
+ if (p_resource->get_path() != "" && p_resource->get_path().find("::") == -1) {
file->set_current_path(p_resource->get_path());
} else {
String existing;
if (extensions.size()) {
- existing="new_"+res->get_class().to_lower()+"."+extensions.front()->get().to_lower();
+ existing = "new_" + res->get_class().to_lower() + "." + extensions.front()->get().to_lower();
}
file->set_current_file(existing);
}
file->clear_filters();
- for(int i=0;i<extensions.size();i++) {
+ for (int i = 0; i < extensions.size(); i++) {
- file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+ file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
file->popup_centered_ratio();
-
}
-void ResourcesDock::_file_action(const String& p_path) {
+void ResourcesDock::_file_action(const String &p_path) {
-
- switch(current_action) {
+ switch (current_action) {
case TOOL_OPEN: {
@@ -198,12 +186,11 @@ void ResourcesDock::_file_action(const String& p_path) {
RES res(current_res);
- save_resource(p_path,res);
+ save_resource(p_path, res);
_update_name(ti);
} break;
-
}
}
@@ -211,39 +198,34 @@ void ResourcesDock::_update_name(TreeItem *item) {
Ref<Resource> res = item->get_metadata(0);
-
- if (res->get_name()!="")
- item->set_text(0,res->get_name());
- else if (res->get_path()!="" && res->get_path().find("::")==-1)
- item->set_text(0,res->get_path().get_file());
+ if (res->get_name() != "")
+ item->set_text(0, res->get_name());
+ else if (res->get_path() != "" && res->get_path().find("::") == -1)
+ item->set_text(0, res->get_path().get_file());
else
- item->set_text(0,res->get_class()+" ("+itos(res->get_instance_ID())+")");
-
+ item->set_text(0, res->get_class() + " (" + itos(res->get_instance_ID()) + ")");
}
-
-void ResourcesDock::remove_resource(const Ref<Resource>& p_resource) {
+void ResourcesDock::remove_resource(const Ref<Resource> &p_resource) {
TreeItem *root = resources->get_root();
ERR_FAIL_COND(!root);
- TreeItem *existing=root->get_children();
+ TreeItem *existing = root->get_children();
- while(existing) {
+ while (existing) {
Ref<Resource> r = existing->get_metadata(0);
- if (r==p_resource) {
+ if (r == p_resource) {
//existing->move_to_top();
memdelete(existing);
return;
}
- existing=existing->get_next();
+ existing = existing->get_next();
}
-
-
}
-void ResourcesDock::add_resource(const Ref<Resource>& p_resource) {
+void ResourcesDock::add_resource(const Ref<Resource> &p_resource) {
if (block_add)
return;
@@ -253,33 +235,32 @@ void ResourcesDock::add_resource(const Ref<Resource>& p_resource) {
TreeItem *root = resources->get_root();
ERR_FAIL_COND(!root);
- TreeItem *existing=root->get_children();
+ TreeItem *existing = root->get_children();
- while(existing) {
+ while (existing) {
Ref<Resource> r = existing->get_metadata(0);
- if (r==p_resource) {
+ if (r == p_resource) {
//existing->move_to_top();
existing->select(0);
resources->ensure_cursor_is_visible();
return; // existing
}
- existing=existing->get_next();
+ existing = existing->get_next();
}
TreeItem *res = resources->create_item(root);
- res->set_metadata(0,p_resource);
+ res->set_metadata(0, p_resource);
- if (has_icon(p_resource->get_class(),"EditorIcons")) {
- res->set_icon(0,get_icon(p_resource->get_class(),"EditorIcons"));
+ if (has_icon(p_resource->get_class(), "EditorIcons")) {
+ res->set_icon(0, get_icon(p_resource->get_class(), "EditorIcons"));
}
_update_name(res);
- res->add_button(0,get_icon("Del","EditorIcons"));
+ res->add_button(0, get_icon("Del", "EditorIcons"));
res->move_to_top();
res->select(0);
resources->ensure_cursor_is_visible();
-
}
void ResourcesDock::_resource_selected() {
@@ -287,23 +268,20 @@ void ResourcesDock::_resource_selected() {
TreeItem *sel = resources->get_selected();
ERR_FAIL_COND(!sel);
-
Ref<Resource> r = sel->get_metadata(0);
if (r.is_null())
return;
- block_add=true;
+ block_add = true;
editor->push_item(r.ptr());
- block_add=false;
+ block_add = false;
}
-void ResourcesDock::_delete(Object* p_item, int p_column, int p_id) {
+void ResourcesDock::_delete(Object *p_item, int p_column, int p_id) {
TreeItem *ti = p_item->cast_to<TreeItem>();
ERR_FAIL_COND(!ti);
-
- call_deferred("remove_resource",ti->get_metadata(0));
-
+ call_deferred("remove_resource", ti->get_metadata(0));
}
void ResourcesDock::_create() {
@@ -314,96 +292,86 @@ void ResourcesDock::_create() {
Resource *r = c->cast_to<Resource>();
ERR_FAIL_COND(!r);
- REF res( r );
+ REF res(r);
editor->push_item(c);
-
}
void ResourcesDock::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_tool_selected"),&ResourcesDock::_tool_selected);
- ClassDB::bind_method(D_METHOD("_create"),&ResourcesDock::_create);
- ClassDB::bind_method(D_METHOD("_resource_selected"),&ResourcesDock::_resource_selected);
- ClassDB::bind_method(D_METHOD("_delete"),&ResourcesDock::_delete);
- ClassDB::bind_method(D_METHOD("remove_resource"),&ResourcesDock::remove_resource);
- ClassDB::bind_method(D_METHOD("_file_action"),&ResourcesDock::_file_action);
-
-
-
+ ClassDB::bind_method(D_METHOD("_tool_selected"), &ResourcesDock::_tool_selected);
+ ClassDB::bind_method(D_METHOD("_create"), &ResourcesDock::_create);
+ ClassDB::bind_method(D_METHOD("_resource_selected"), &ResourcesDock::_resource_selected);
+ ClassDB::bind_method(D_METHOD("_delete"), &ResourcesDock::_delete);
+ ClassDB::bind_method(D_METHOD("remove_resource"), &ResourcesDock::remove_resource);
+ ClassDB::bind_method(D_METHOD("_file_action"), &ResourcesDock::_file_action);
}
void ResourcesDock::cleanup() {
-
resources->clear();
resources->create_item(); //root
-
}
-
ResourcesDock::ResourcesDock(EditorNode *p_editor) {
- editor=p_editor;
+ editor = p_editor;
VBoxContainer *vbc = this;
- HBoxContainer *hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
vbc->add_child(hbc);
-
Button *b;
- b = memnew( ToolButton );
+ b = memnew(ToolButton);
b->set_tooltip(TTR("Create New Resource"));
- b->connect("pressed",this,"_tool_selected",make_binds(TOOL_NEW));
- hbc->add_child( b );
- button_new=b;
+ b->connect("pressed", this, "_tool_selected", make_binds(TOOL_NEW));
+ hbc->add_child(b);
+ button_new = b;
- b = memnew( ToolButton );
+ b = memnew(ToolButton);
b->set_tooltip(TTR("Open Resource"));
- b->connect("pressed",this,"_tool_selected",make_binds(TOOL_OPEN));
- hbc->add_child( b );
- button_open=b;
+ b->connect("pressed", this, "_tool_selected", make_binds(TOOL_OPEN));
+ hbc->add_child(b);
+ button_open = b;
- MenuButton *mb = memnew( MenuButton );
+ MenuButton *mb = memnew(MenuButton);
mb->set_tooltip(TTR("Save Resource"));
- mb->get_popup()->add_item(TTR("Save Resource"),TOOL_SAVE);
- mb->get_popup()->add_item(TTR("Save Resource As.."),TOOL_SAVE_AS);
- mb->get_popup()->connect("id_pressed",this,"_tool_selected" );
- hbc->add_child( mb );
- button_save=mb;
+ mb->get_popup()->add_item(TTR("Save Resource"), TOOL_SAVE);
+ mb->get_popup()->add_item(TTR("Save Resource As.."), TOOL_SAVE_AS);
+ mb->get_popup()->connect("id_pressed", this, "_tool_selected");
+ hbc->add_child(mb);
+ button_save = mb;
hbc->add_spacer();
- mb = memnew( MenuButton );
+ mb = memnew(MenuButton);
mb->set_tooltip(TTR("Resource Tools"));
- mb->get_popup()->add_item(TTR("Make Local"),TOOL_MAKE_LOCAL);
- mb->get_popup()->add_item(TTR("Copy"),TOOL_COPY);
- mb->get_popup()->add_item(TTR("Paste"),TOOL_PASTE);
- mb->get_popup()->connect("id_pressed",this,"_tool_selected" );
- hbc->add_child( mb );
- button_tools=mb;
-
- resources = memnew( Tree );
+ mb->get_popup()->add_item(TTR("Make Local"), TOOL_MAKE_LOCAL);
+ mb->get_popup()->add_item(TTR("Copy"), TOOL_COPY);
+ mb->get_popup()->add_item(TTR("Paste"), TOOL_PASTE);
+ mb->get_popup()->connect("id_pressed", this, "_tool_selected");
+ hbc->add_child(mb);
+ button_tools = mb;
+
+ resources = memnew(Tree);
vbc->add_child(resources);
resources->set_v_size_flags(SIZE_EXPAND_FILL);
resources->create_item(); //root
resources->set_hide_root(true);
- resources->connect("cell_selected",this,"_resource_selected");
- resources->connect("button_pressed",this,"_delete");
+ resources->connect("cell_selected", this, "_resource_selected");
+ resources->connect("button_pressed", this, "_delete");
- create_dialog = memnew( CreateDialog );
+ create_dialog = memnew(CreateDialog);
add_child(create_dialog);
create_dialog->set_base_type("Resource");
- create_dialog->connect("create",this,"_create");
- accept = memnew (AcceptDialog);
+ create_dialog->connect("create", this, "_create");
+ accept = memnew(AcceptDialog);
add_child(accept);
- file = memnew( EditorFileDialog );
+ file = memnew(EditorFileDialog);
add_child(file);
- file->connect("file_selected",this,"_file_action");
+ file->connect("file_selected", this, "_file_action");
-
- block_add=false;
+ block_add = false;
}
-
diff --git a/editor/resources_dock.h b/editor/resources_dock.h
index e225786583..15437f981f 100644
--- a/editor/resources_dock.h
+++ b/editor/resources_dock.h
@@ -29,23 +29,22 @@
#ifndef RESOURCES_DOCK_H
#define RESOURCES_DOCK_H
+#include "create_dialog.h"
+#include "editor_file_dialog.h"
+#include "scene/gui/box_container.h"
+#include "scene/gui/button.h"
#include "scene/gui/control.h"
-#include "scene/gui/tree.h"
+#include "scene/gui/file_dialog.h"
#include "scene/gui/label.h"
-#include "scene/gui/button.h"
-#include "scene/gui/tool_button.h"
-#include "scene/gui/box_container.h"
#include "scene/gui/menu_button.h"
-#include "scene/gui/file_dialog.h"
-#include "create_dialog.h"
-#include "editor_file_dialog.h"
-
+#include "scene/gui/tool_button.h"
+#include "scene/gui/tree.h"
class EditorNode;
class ResourcesDock : public VBoxContainer {
- GDCLASS( ResourcesDock, VBoxContainer );
+ GDCLASS(ResourcesDock, VBoxContainer);
enum {
TOOL_NEW,
@@ -58,7 +57,6 @@ class ResourcesDock : public VBoxContainer {
TOOL_MAX
};
-
EditorNode *editor;
Button *button_new;
@@ -74,32 +72,23 @@ class ResourcesDock : public VBoxContainer {
bool block_add;
int current_action;
+ void _file_action(const String &p_action);
-
-
-
- void _file_action(const String& p_action);
-
-
-
- void _delete(Object* p_item, int p_column, int p_id);
+ void _delete(Object *p_item, int p_column, int p_id);
void _resource_selected();
void _update_name(TreeItem *item);
void _tool_selected(int p_tool);
void _create();
protected:
-
void _notification(int p_what);
static void _bind_methods();
public:
-
- void add_resource(const Ref<Resource>& p_resource);
- void remove_resource(const Ref<Resource>& p_resource);
- void save_resource(const String& p_path,const Ref<Resource>& p_resource);
- void save_resource_as(const Ref<Resource>& p_resource);
-
+ void add_resource(const Ref<Resource> &p_resource);
+ void remove_resource(const Ref<Resource> &p_resource);
+ void save_resource(const String &p_path, const Ref<Resource> &p_resource);
+ void save_resource_as(const Ref<Resource> &p_resource);
void cleanup();
diff --git a/editor/run_settings_dialog.cpp b/editor/run_settings_dialog.cpp
index 4d69c7ad84..35cbb6c410 100644
--- a/editor/run_settings_dialog.cpp
+++ b/editor/run_settings_dialog.cpp
@@ -28,14 +28,12 @@
/*************************************************************************/
#include "run_settings_dialog.h"
-
void RunSettingsDialog::popup_run_settings() {
- popup_centered(Size2( 300, 150 ));
+ popup_centered(Size2(300, 150));
}
-void RunSettingsDialog::set_custom_arguments(const String& p_arguments) {
-
+void RunSettingsDialog::set_custom_arguments(const String &p_arguments) {
arguments->set_text(p_arguments);
}
@@ -44,16 +42,15 @@ String RunSettingsDialog::get_custom_arguments() const {
return arguments->get_text();
}
-
void RunSettingsDialog::_bind_methods() {
- ClassDB::bind_method("_run_mode_changed",&RunSettingsDialog::_run_mode_changed);
+ ClassDB::bind_method("_run_mode_changed", &RunSettingsDialog::_run_mode_changed);
//ClassDB::bind_method("_browse_selected_file",&RunSettingsDialog::_browse_selected_file);
}
void RunSettingsDialog::_run_mode_changed(int idx) {
- if (idx==0)
+ if (idx == 0)
arguments->set_editable(false);
else
arguments->set_editable(true);
@@ -74,17 +71,17 @@ RunSettingsDialog::RunSettingsDialog() {
/* SNAP DIALOG */
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
//set_child_rect(vbc);
- run_mode = memnew( OptionButton );
- vbc->add_margin_child(TTR("Run Mode:"),run_mode);
+ run_mode = memnew(OptionButton);
+ vbc->add_margin_child(TTR("Run Mode:"), run_mode);
run_mode->add_item(TTR("Current Scene"));
run_mode->add_item(TTR("Main Scene"));
- run_mode->connect("item_selected",this,"_run_mode_changed");
- arguments = memnew( LineEdit );
- vbc->add_margin_child(TTR("Main Scene Arguments:"),arguments);
+ run_mode->connect("item_selected", this, "_run_mode_changed");
+ arguments = memnew(LineEdit);
+ vbc->add_margin_child(TTR("Main Scene Arguments:"), arguments);
arguments->set_editable(false);
get_ok()->set_text(TTR("Close"));
@@ -93,6 +90,4 @@ RunSettingsDialog::RunSettingsDialog() {
arguments->set_text("-l $scene");
set_title(TTR("Scene Run Settings"));
-
-
}
diff --git a/editor/run_settings_dialog.h b/editor/run_settings_dialog.h
index 2efc18e43f..98d0368344 100644
--- a/editor/run_settings_dialog.h
+++ b/editor/run_settings_dialog.h
@@ -29,34 +29,35 @@
#ifndef RUN_SETTINGS_DIALOG_H
#define RUN_SETTINGS_DIALOG_H
-#include "scene/gui/dialogs.h"
-#include "scene/gui/line_edit.h"
#include "scene/gui/check_button.h"
+#include "scene/gui/dialogs.h"
#include "scene/gui/file_dialog.h"
+#include "scene/gui/line_edit.h"
class RunSettingsDialog : public AcceptDialog {
- GDCLASS( RunSettingsDialog, AcceptDialog);
+ GDCLASS(RunSettingsDialog, AcceptDialog);
+
public:
enum RunMode {
RUN_LOCAL_SCENE,
RUN_MAIN_SCENE,
};
-private:
+private:
OptionButton *run_mode;
LineEdit *arguments;
void _run_mode_changed(int idx);
-protected:
+protected:
static void _bind_methods();
-public:
+public:
int get_run_mode() const;
void set_run_mode(int p_run_mode);
- void set_custom_arguments(const String& p_arguments);
+ void set_custom_arguments(const String &p_arguments);
String get_custom_arguments() const;
void popup_run_settings();
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 47eb84ab79..04b10959ef 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -28,36 +28,33 @@
/*************************************************************************/
#include "scene_tree_dock.h"
+#include "animation_editor.h"
+#include "core/io/resource_saver.h"
+#include "editor/plugins/animation_player_editor_plugin.h"
+#include "editor/plugins/canvas_item_editor_plugin.h"
+#include "editor/plugins/script_editor_plugin.h"
+#include "editor/plugins/spatial_editor_plugin.h"
#include "editor_node.h"
+#include "editor_settings.h"
#include "global_config.h"
+#include "multi_node_edit.h"
#include "os/keyboard.h"
+#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
-#include "editor_settings.h"
-#include "editor/plugins/canvas_item_editor_plugin.h"
-#include "editor/plugins/spatial_editor_plugin.h"
#include "script_editor_debugger.h"
-#include "editor/plugins/script_editor_plugin.h"
-#include "core/io/resource_saver.h"
-#include "multi_node_edit.h"
-#include "editor/plugins/animation_player_editor_plugin.h"
-#include "animation_editor.h"
-#include "scene/main/viewport.h"
-
void SceneTreeDock::_nodes_drag_begin() {
-
if (restore_script_editor_on_drag) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
- restore_script_editor_on_drag=false;
+ restore_script_editor_on_drag = false;
}
-
}
void SceneTreeDock::_input(InputEvent p_event) {
- if (p_event.type==InputEvent::MOUSE_BUTTON && !p_event.mouse_button.pressed && p_event.mouse_button.button_index==BUTTON_LEFT) {
- restore_script_editor_on_drag=false; //lost chance
+ if (p_event.type == InputEvent::MOUSE_BUTTON && !p_event.mouse_button.pressed && p_event.mouse_button.button_index == BUTTON_LEFT) {
+ restore_script_editor_on_drag = false; //lost chance
}
}
@@ -71,54 +68,41 @@ void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
if (ED_IS_SHORTCUT("scene_tree/add_child_node", p_event)) {
_tool_selected(TOOL_NEW);
- }
- else if (ED_IS_SHORTCUT("scene_tree/instance_scene", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/instance_scene", p_event)) {
_tool_selected(TOOL_INSTANCE);
- }
- else if (ED_IS_SHORTCUT("scene_tree/change_node_type", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/change_node_type", p_event)) {
_tool_selected(TOOL_REPLACE);
- }
- else if (ED_IS_SHORTCUT("scene_tree/duplicate", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/duplicate", p_event)) {
_tool_selected(TOOL_DUPLICATE);
- }
- else if (ED_IS_SHORTCUT("scene_tree/attach_script", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/attach_script", p_event)) {
_tool_selected(TOOL_ATTACH_SCRIPT);
- }
- else if(ED_IS_SHORTCUT("scene_tree/clear_script", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/clear_script", p_event)) {
_tool_selected(TOOL_CLEAR_SCRIPT);
- }
- else if (ED_IS_SHORTCUT("scene_tree/move_up", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/move_up", p_event)) {
_tool_selected(TOOL_MOVE_UP);
- }
- else if (ED_IS_SHORTCUT("scene_tree/move_down", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/move_down", p_event)) {
_tool_selected(TOOL_MOVE_DOWN);
- }
- else if (ED_IS_SHORTCUT("scene_tree/reparent", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/reparent", p_event)) {
_tool_selected(TOOL_REPARENT);
- }
- else if (ED_IS_SHORTCUT("scene_tree/merge_from_scene", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/merge_from_scene", p_event)) {
_tool_selected(TOOL_MERGE_FROM_SCENE);
- }
- else if (ED_IS_SHORTCUT("scene_tree/save_branch_as_scene", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/save_branch_as_scene", p_event)) {
_tool_selected(TOOL_NEW_SCENE_FROM);
- }
- else if (ED_IS_SHORTCUT("scene_tree/delete_no_confirm", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/delete_no_confirm", p_event)) {
_tool_selected(TOOL_ERASE, true);
- }
- else if(ED_IS_SHORTCUT("scene_tree/copy_node_path", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/copy_node_path", p_event)) {
_tool_selected(TOOL_COPY_NODE_PATH);
- }
- else if (ED_IS_SHORTCUT("scene_tree/delete", p_event)) {
+ } else if (ED_IS_SHORTCUT("scene_tree/delete", p_event)) {
_tool_selected(TOOL_ERASE);
}
}
-void SceneTreeDock::instance(const String& p_file) {
+void SceneTreeDock::instance(const String &p_file) {
Node *parent = scene_tree->get_selected();
if (!parent || !edited_scene) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("OK :("));
accept->set_text(TTR("No parent to instance a child at."));
@@ -130,11 +114,10 @@ void SceneTreeDock::instance(const String& p_file) {
Vector<String> scenes;
scenes.push_back(p_file);
- _perform_instance_scenes(scenes,parent,-1);
-
+ _perform_instance_scenes(scenes, parent, -1);
}
-void SceneTreeDock::instance_scenes(const Vector<String>& p_files, Node *p_parent) {
+void SceneTreeDock::instance_scenes(const Vector<String> &p_files, Node *p_parent) {
Node *parent = p_parent;
@@ -153,111 +136,102 @@ void SceneTreeDock::instance_scenes(const Vector<String>& p_files, Node *p_paren
_perform_instance_scenes(p_files, parent, -1);
}
-void SceneTreeDock::_perform_instance_scenes(const Vector<String>& p_files,Node* parent,int p_pos) {
-
-
+void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node *parent, int p_pos) {
ERR_FAIL_COND(!parent);
+ Vector<Node *> instances;
- Vector<Node*> instances;
-
- bool error=false;
+ bool error = false;
- for(int i=0;i<p_files.size();i++) {
+ for (int i = 0; i < p_files.size(); i++) {
Ref<PackedScene> sdata = ResourceLoader::load(p_files[i]);
if (!sdata.is_valid()) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
- accept->set_text(vformat(TTR("Error loading scene from %s"),p_files[i]));
+ accept->set_text(vformat(TTR("Error loading scene from %s"), p_files[i]));
accept->popup_centered_minsize();
- error=true;
+ error = true;
break;
-
}
- Node*instanced_scene=sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!instanced_scene) {
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("Ugh"));
- accept->set_text(vformat(TTR("Error instancing scene from %s"),p_files[i]));
+ accept->set_text(vformat(TTR("Error instancing scene from %s"), p_files[i]));
accept->popup_centered_minsize();
- error=true;
+ error = true;
break;
-
}
- if (edited_scene->get_filename()!="") {
+ if (edited_scene->get_filename() != "") {
if (_cyclical_dependency_exists(edited_scene->get_filename(), instanced_scene)) {
accept->get_ok()->set_text(TTR("Ok"));
- accept->set_text(vformat(TTR("Cannot instance the scene '%s' because the current scene exists within one of its nodes."),p_files[i]));
+ accept->set_text(vformat(TTR("Cannot instance the scene '%s' because the current scene exists within one of its nodes."), p_files[i]));
accept->popup_centered_minsize();
- error=true;
+ error = true;
break;
}
}
- instanced_scene->set_filename( GlobalConfig::get_singleton()->localize_path(p_files[i]) );
+ instanced_scene->set_filename(GlobalConfig::get_singleton()->localize_path(p_files[i]));
instances.push_back(instanced_scene);
}
if (error) {
- for(int i=0;i<instances.size();i++) {
+ for (int i = 0; i < instances.size(); i++) {
memdelete(instances[i]);
}
return;
}
-
-
//instanced_scene->generate_instance_state();
editor_data->get_undo_redo().create_action(TTR("Instance Scene(s)"));
- for(int i=0;i<instances.size();i++) {
+ for (int i = 0; i < instances.size(); i++) {
- Node* instanced_scene=instances[i];
+ Node *instanced_scene = instances[i];
- editor_data->get_undo_redo().add_do_method(parent,"add_child",instanced_scene);
- if (p_pos>=0) {
- editor_data->get_undo_redo().add_do_method(parent,"move_child",instanced_scene,p_pos+i);
+ editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene);
+ if (p_pos >= 0) {
+ editor_data->get_undo_redo().add_do_method(parent, "move_child", instanced_scene, p_pos + i);
}
- editor_data->get_undo_redo().add_do_method(instanced_scene,"set_owner",edited_scene);
- editor_data->get_undo_redo().add_do_method(editor_selection,"clear");
- editor_data->get_undo_redo().add_do_method(editor_selection,"add_node",instanced_scene);
+ editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", edited_scene);
+ editor_data->get_undo_redo().add_do_method(editor_selection, "clear");
+ editor_data->get_undo_redo().add_do_method(editor_selection, "add_node", instanced_scene);
editor_data->get_undo_redo().add_do_reference(instanced_scene);
- editor_data->get_undo_redo().add_undo_method(parent,"remove_child",instanced_scene);
+ editor_data->get_undo_redo().add_undo_method(parent, "remove_child", instanced_scene);
String new_name = parent->validate_child_name(instanced_scene);
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
- editor_data->get_undo_redo().add_do_method(sed,"live_debug_instance_node",edited_scene->get_path_to(parent),p_files[i],new_name);
- editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+new_name));
+ editor_data->get_undo_redo().add_do_method(sed, "live_debug_instance_node", edited_scene->get_path_to(parent), p_files[i], new_name);
+ editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + new_name));
}
editor_data->get_undo_redo().commit_action();
-
-
}
-void SceneTreeDock::_replace_with_branch_scene(const String& p_file,Node* base) {
+void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base) {
Ref<PackedScene> sdata = ResourceLoader::load(p_file);
if (!sdata.is_valid()) {
accept->get_ok()->set_text(TTR("Ugh"));
- accept->set_text(vformat(TTR("Error loading scene from %s"),p_file));
+ accept->set_text(vformat(TTR("Error loading scene from %s"), p_file));
accept->popup_centered_minsize();
return;
}
- Node *instanced_scene=sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
if (!instanced_scene) {
accept->get_ok()->set_text(TTR("Ugh"));
- accept->set_text(vformat(TTR("Error instancing scene from %s"),p_file));
+ accept->set_text(vformat(TTR("Error instancing scene from %s"), p_file));
accept->popup_centered_minsize();
return;
}
@@ -273,17 +247,17 @@ void SceneTreeDock::_replace_with_branch_scene(const String& p_file,Node* base)
scene_tree->set_selected(instanced_scene);
}
-bool SceneTreeDock::_cyclical_dependency_exists(const String& p_target_scene_path, Node* p_desired_node) {
+bool SceneTreeDock::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
int childCount = p_desired_node->get_child_count();
- if (p_desired_node->get_filename()==p_target_scene_path) {
+ if (p_desired_node->get_filename() == p_target_scene_path) {
return true;
}
- for (int i=0;i<childCount;i++) {
- Node* child=p_desired_node->get_child(i);
+ for (int i = 0; i < childCount; i++) {
+ Node *child = p_desired_node->get_child(i);
- if(_cyclical_dependency_exists(p_target_scene_path,child)) {
+ if (_cyclical_dependency_exists(p_target_scene_path, child)) {
return true;
}
}
@@ -291,12 +265,11 @@ bool SceneTreeDock::_cyclical_dependency_exists(const String& p_target_scene_pat
return false;
}
-
void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
- current_option=p_tool;
+ current_option = p_tool;
- switch(p_tool) {
+ switch (p_tool) {
case TOOL_NEW: {
/*
@@ -330,11 +303,11 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
List<String> extensions;
- ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions);
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
file->clear_filters();
- for(int i=0;i<extensions.size();i++) {
+ for (int i = 0; i < extensions.size(); i++) {
- file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+ file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
//file->set_current_path(current_path);
@@ -387,20 +360,19 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor->push_item(existing.ptr());
else {
String path = selected->get_filename();
- script_create_dialog->config(selected->get_class(),path);
- script_create_dialog->popup_centered(Size2(300,290));
+ script_create_dialog->config(selected->get_class(), path);
+ script_create_dialog->popup_centered(Size2(300, 290));
//script_create_dialog->popup_centered_minsize();
-
}
} break;
case TOOL_CLEAR_SCRIPT: {
Node *selected = scene_tree->get_selected();
- if(!selected)
+ if (!selected)
break;
Ref<Script> existing = selected->get_script();
- if(existing.is_valid()) {
+ if (existing.is_valid()) {
const RefPtr empty;
selected->set_script(empty);
button_create_script->show();
@@ -414,11 +386,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (!scene_tree->get_selected())
break;
+ if (scene_tree->get_selected() == edited_scene) {
- if (scene_tree->get_selected()==edited_scene) {
-
-
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation can't be done on the tree root."));
@@ -426,7 +396,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
break;
}
-
if (!_validate_no_foreign())
break;
@@ -434,14 +403,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
bool MOVING_UP = !MOVING_DOWN;
Node *common_parent = scene_tree->get_selected()->get_parent();
- List<Node*> selection = editor_selection->get_selected_node_list();
- selection.sort_custom<Node::Comparator>(); // sort by index
+ List<Node *> selection = editor_selection->get_selected_node_list();
+ selection.sort_custom<Node::Comparator>(); // sort by index
if (MOVING_DOWN)
selection.invert();
int lowest_id = common_parent->get_child_count() - 1;
int highest_id = 0;
- for (List<Node*>::Element *E = selection.front(); E; E = E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
int index = E->get()->get_index();
if (index > highest_id) highest_id = index;
@@ -479,11 +448,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (!edited_scene)
break;
-
if (editor_selection->is_selected(edited_scene)) {
-
- current_option=-1;
+ current_option = -1;
//accept->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation can't be done on the tree root."));
@@ -494,54 +461,53 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (!_validate_no_foreign())
break;
- List<Node*> selection = editor_selection->get_selected_node_list();
- if (selection.size()==0)
+ List<Node *> selection = editor_selection->get_selected_node_list();
+ if (selection.size() == 0)
break;
- List<Node*> reselect;
+ List<Node *> reselect;
editor_data->get_undo_redo().create_action(TTR("Duplicate Node(s)"));
- editor_data->get_undo_redo().add_do_method(editor_selection,"clear");
-
- Node *dupsingle=NULL;
+ editor_data->get_undo_redo().add_do_method(editor_selection, "clear");
+ Node *dupsingle = NULL;
- for (List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Node *node = E->get();
Node *parent = node->get_parent();
- List<Node*> owned;
- node->get_owned_by(node->get_owner(),&owned);
+ List<Node *> owned;
+ node->get_owned_by(node->get_owner(), &owned);
- Map<Node*,Node*> duplimap;
- Node * dup = _duplicate(node,duplimap);
+ Map<Node *, Node *> duplimap;
+ Node *dup = _duplicate(node, duplimap);
ERR_CONTINUE(!dup);
- if (selection.size()==1)
- dupsingle=dup;
+ if (selection.size() == 1)
+ dupsingle = dup;
dup->set_name(parent->validate_child_name(dup));
- editor_data->get_undo_redo().add_do_method(parent,"_add_child_below_node",node, dup);
- for (List<Node*>::Element *F=owned.front();F;F=F->next()) {
+ editor_data->get_undo_redo().add_do_method(parent, "_add_child_below_node", node, dup);
+ for (List<Node *>::Element *F = owned.front(); F; F = F->next()) {
if (!duplimap.has(F->get())) {
continue;
}
- Node *d=duplimap[F->get()];
- editor_data->get_undo_redo().add_do_method(d,"set_owner",node->get_owner());
+ Node *d = duplimap[F->get()];
+ editor_data->get_undo_redo().add_do_method(d, "set_owner", node->get_owner());
}
- editor_data->get_undo_redo().add_do_method(editor_selection,"add_node",dup);
- editor_data->get_undo_redo().add_undo_method(parent,"remove_child",dup);
+ editor_data->get_undo_redo().add_do_method(editor_selection, "add_node", dup);
+ editor_data->get_undo_redo().add_undo_method(parent, "remove_child", dup);
editor_data->get_undo_redo().add_do_reference(dup);
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
- editor_data->get_undo_redo().add_do_method(sed,"live_debug_duplicate_node",edited_scene->get_path_to(node),dup->get_name());
- editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+dup->get_name()));
+ editor_data->get_undo_redo().add_do_method(sed, "live_debug_duplicate_node", edited_scene->get_path_to(node), dup->get_name());
+ editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + dup->get_name()));
//parent->add_child(dup);
//reselect.push_back(dup);
@@ -552,22 +518,15 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (dupsingle)
editor->push_item(dupsingle);
-
-
-
-
} break;
case TOOL_REPARENT: {
-
if (!scene_tree->get_selected())
break;
-
if (editor_selection->is_selected(edited_scene)) {
-
- current_option=-1;
+ current_option = -1;
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation can't be done on the tree root."));
@@ -578,23 +537,23 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (!_validate_no_foreign())
break;
- List<Node*> nodes = editor_selection->get_selected_node_list();
- Set<Node*> nodeset;
- for(List<Node*>::Element *E=nodes.front();E;E=E->next()) {
+ List<Node *> nodes = editor_selection->get_selected_node_list();
+ Set<Node *> nodeset;
+ for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) {
nodeset.insert(E->get());
}
reparent_dialog->popup_centered_ratio();
- reparent_dialog->set_current( nodeset );
+ reparent_dialog->set_current(nodeset);
} break;
case TOOL_MULTI_EDIT: {
- Node*root=EditorNode::get_singleton()->get_edited_scene();
+ Node *root = EditorNode::get_singleton()->get_edited_scene();
if (!root)
break;
- Ref<MultiNodeEdit> mne = memnew( MultiNodeEdit );
- for (const Map<Node*,Object*>::Element *E=EditorNode::get_singleton()->get_editor_selection()->get_selection().front();E;E=E->next()) {
+ Ref<MultiNodeEdit> mne = memnew(MultiNodeEdit);
+ for (const Map<Node *, Object *>::Element *E = EditorNode::get_singleton()->get_editor_selection()->get_selection().front(); E; E = E->next()) {
mne->add_node(root->get_path_to(E->key()));
}
@@ -604,7 +563,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
case TOOL_ERASE: {
- List<Node*> remove_list = editor_selection->get_selected_node_list();
+ List<Node *> remove_list = editor_selection->get_selected_node_list();
if (remove_list.empty())
return;
@@ -640,9 +599,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
break;
}
- List<Node*> selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.size()!=1) {
+ if (selection.size() != 1) {
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation requires a single selected node."));
accept->popup_centered_minsize();
@@ -651,14 +610,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *tocopy = selection.front()->get();
- if (tocopy==scene){
+ if (tocopy == scene) {
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Can not perform with the root node."));
accept->popup_centered_minsize();
break;
}
- if (tocopy!=editor_data->get_edited_scene_root() && tocopy->get_filename()!="") {
+ if (tocopy != editor_data->get_edited_scene_root() && tocopy->get_filename() != "") {
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation can't be done on instanced scenes."));
accept->popup_centered_minsize();
@@ -668,17 +627,17 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
new_scene_from_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
List<String> extensions;
- Ref<PackedScene> sd = memnew( PackedScene );
- ResourceSaver::get_recognized_extensions(sd,&extensions);
+ Ref<PackedScene> sd = memnew(PackedScene);
+ ResourceSaver::get_recognized_extensions(sd, &extensions);
new_scene_from_dialog->clear_filters();
- for(int i=0;i<extensions.size();i++) {
- new_scene_from_dialog->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+ for (int i = 0; i < extensions.size(); i++) {
+ new_scene_from_dialog->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
}
String existing;
if (extensions.size()) {
String root_name(tocopy->get_name());
- existing=root_name+"."+extensions.front()->get().to_lower();
+ existing = root_name + "." + extensions.front()->get().to_lower();
}
new_scene_from_dialog->set_current_path(existing);
@@ -686,11 +645,11 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
new_scene_from_dialog->set_title(TTR("Save New Scene As.."));
} break;
- case TOOL_COPY_NODE_PATH: {
- List<Node*> selection = editor_selection->get_selected_node_list();
+ case TOOL_COPY_NODE_PATH: {
+ List<Node *> selection = editor_selection->get_selected_node_list();
- if(List<Node*>::Element *e = selection.front()) {
- if(Node *node = e->get()) {
+ if (List<Node *>::Element *e = selection.front()) {
+ if (Node *node = e->get()) {
Node *root = EditorNode::get_singleton()->get_edited_scene();
NodePath path = root->get_path().rel_path_to(node->get_path());
OS::get_singleton()->set_clipboard(path);
@@ -698,54 +657,50 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
}
-
}
void SceneTreeDock::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
if (!first_enter)
break;
- first_enter=false;
+ first_enter = false;
- CanvasItemEditorPlugin *canvas_item_plugin = editor_data->get_editor("2D")->cast_to<CanvasItemEditorPlugin>();
+ CanvasItemEditorPlugin *canvas_item_plugin = editor_data->get_editor("2D")->cast_to<CanvasItemEditorPlugin>();
if (canvas_item_plugin) {
canvas_item_plugin->get_canvas_item_editor()->connect("item_lock_status_changed", scene_tree, "_update_tree");
canvas_item_plugin->get_canvas_item_editor()->connect("item_group_status_changed", scene_tree, "_update_tree");
scene_tree->connect("node_changed", canvas_item_plugin->get_canvas_item_editor()->get_viewport_control(), "update");
}
- button_add->set_icon(get_icon("Add","EditorIcons"));
- button_instance->set_icon(get_icon("Instance","EditorIcons"));
- button_create_script->set_icon(get_icon("ScriptCreate","EditorIcons"));
+ button_add->set_icon(get_icon("Add", "EditorIcons"));
+ button_instance->set_icon(get_icon("Instance", "EditorIcons"));
+ button_create_script->set_icon(get_icon("ScriptCreate", "EditorIcons"));
button_clear_script->set_icon(get_icon("ScriptRemove", "EditorIcons"));
+ filter_icon->set_texture(get_icon("Zoom", "EditorIcons"));
- filter_icon->set_texture(get_icon("Zoom","EditorIcons"));
-
- EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed",this,"_selection_changed");
+ EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", this, "_selection_changed");
} break;
}
}
-
-void SceneTreeDock::_load_request(const String& p_path) {
+void SceneTreeDock::_load_request(const String &p_path) {
editor->open_request(p_path);
}
-void SceneTreeDock::_script_open_request(const Ref<Script>& p_script) {
+void SceneTreeDock::_script_open_request(const Ref<Script> &p_script) {
editor->edit_resource(p_script);
}
void SceneTreeDock::_node_selected() {
-
- Node *node=scene_tree->get_selected();
+ Node *node = scene_tree->get_selected();
if (!node) {
@@ -754,12 +709,10 @@ void SceneTreeDock::_node_selected() {
}
if (ScriptEditor::get_singleton()->is_visible_in_tree()) {
- restore_script_editor_on_drag=true;
+ restore_script_editor_on_drag = true;
}
editor->push_item(node);
-
-
}
void SceneTreeDock::_node_renamed() {
@@ -767,61 +720,57 @@ void SceneTreeDock::_node_renamed() {
_node_selected();
}
-Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node*,Node*> &duplimap) {
+Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node *, Node *> &duplimap) {
- Node *node=NULL;
+ Node *node = NULL;
- if (p_node->get_filename()!="") { //an instance
+ if (p_node->get_filename() != "") { //an instance
- Ref<PackedScene> sd = ResourceLoader::load( p_node->get_filename() );
- ERR_FAIL_COND_V(!sd.is_valid(),NULL);
+ Ref<PackedScene> sd = ResourceLoader::load(p_node->get_filename());
+ ERR_FAIL_COND_V(!sd.is_valid(), NULL);
node = sd->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
- ERR_FAIL_COND_V(!node,NULL);
+ ERR_FAIL_COND_V(!node, NULL);
node->set_scene_instance_load_placeholder(p_node->get_scene_instance_load_placeholder());
//node->generate_instance_state();
} else {
Object *obj = ClassDB::instance(p_node->get_class());
- 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);
}
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))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
- node->set( name, p_node->get(name) );
-
+ node->set(name, p_node->get(name));
}
-
List<Node::GroupInfo> group_info;
p_node->get_groups(&group_info);
- for (List<Node::GroupInfo>::Element *E=group_info.front();E;E=E->next()) {
+ for (List<Node::GroupInfo>::Element *E = group_info.front(); E; E = E->next()) {
if (E->get().persistent)
- node->add_to_group(E->get().name,true);
+ node->add_to_group(E->get().name, true);
}
-
node->set_name(p_node->get_name());
- duplimap[p_node]=node;
+ duplimap[p_node] = node;
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
Node *child = p_node->get_child(i);
- if (p_node->get_owner()!=child->get_owner())
+ if (p_node->get_owner() != child->get_owner())
continue; //don't bother with not in-scene nodes.
- Node *dup = _duplicate(child,duplimap);
+ Node *dup = _duplicate(child, duplimap);
if (!dup) {
memdelete(node);
return NULL;
@@ -831,131 +780,121 @@ Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node*,Node*> &duplimap) {
}
return node;
-
}
+void SceneTreeDock::_set_owners(Node *p_owner, const Array &p_nodes) {
-void SceneTreeDock::_set_owners(Node *p_owner, const Array& p_nodes) {
-
- for(int i=0;i<p_nodes.size();i++) {
+ for (int i = 0; i < p_nodes.size(); i++) {
- Object *obj=p_nodes[i];
+ Object *obj = p_nodes[i];
if (!obj)
continue;
- Node *n=obj->cast_to<Node>();
+ Node *n = obj->cast_to<Node>();
if (!n)
continue;
n->set_owner(p_owner);
}
}
-
-void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path,Vector<StringName> new_base_path,Node * p_node, List<Pair<NodePath,NodePath> > *p_renames) {
+void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath> > *p_renames) {
base_path.push_back(p_node->get_name());
if (new_base_path.size())
new_base_path.push_back(p_node->get_name());
- NodePath from( base_path,true );
+ NodePath from(base_path, true);
NodePath to;
if (new_base_path.size())
- to=NodePath( new_base_path,true );
+ to = NodePath(new_base_path, true);
- Pair<NodePath,NodePath> npp;
- npp.first=from;
- npp.second=to;
+ Pair<NodePath, NodePath> npp;
+ npp.first = from;
+ npp.second = to;
p_renames->push_back(npp);
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- _fill_path_renames(base_path,new_base_path,p_node->get_child(i),p_renames);
+ _fill_path_renames(base_path, new_base_path, p_node->get_child(i), p_renames);
}
-
-
}
-void SceneTreeDock::fill_path_renames(Node* p_node, Node *p_new_parent, List<Pair<NodePath,NodePath> > *p_renames) {
+void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath> > *p_renames) {
- if (!bool(EDITOR_DEF("editors/animation/autorename_animation_tracks",true)))
+ if (!bool(EDITOR_DEF("editors/animation/autorename_animation_tracks", true)))
return;
-
Vector<StringName> base_path;
Node *n = p_node->get_parent();
- while(n) {
+ while (n) {
base_path.push_back(n->get_name());
- n=n->get_parent();
+ n = n->get_parent();
}
base_path.invert();
Vector<StringName> new_base_path;
if (p_new_parent) {
n = p_new_parent;
- while(n) {
+ while (n) {
new_base_path.push_back(n->get_name());
- n=n->get_parent();
+ n = n->get_parent();
}
new_base_path.invert();
}
- _fill_path_renames(base_path,new_base_path,p_node,p_renames);
+ _fill_path_renames(base_path, new_base_path, p_node, p_renames);
}
-void SceneTreeDock::perform_node_renames(Node* p_base,List<Pair<NodePath,NodePath> > *p_renames, Map<Ref<Animation>, Set<int> > *r_rem_anims) {
+void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath> > *p_renames, Map<Ref<Animation>, Set<int> > *r_rem_anims) {
Map<Ref<Animation>, Set<int> > rem_anims;
if (!r_rem_anims)
- r_rem_anims=&rem_anims;
+ r_rem_anims = &rem_anims;
- if (!bool(EDITOR_DEF("editors/animation/autorename_animation_tracks",true)))
+ if (!bool(EDITOR_DEF("editors/animation/autorename_animation_tracks", true)))
return;
if (!p_base) {
- p_base=edited_scene;
+ p_base = edited_scene;
}
if (!p_base)
return;
-
if (p_base->cast_to<AnimationPlayer>()) {
- AnimationPlayer *ap=p_base->cast_to<AnimationPlayer>();
+ AnimationPlayer *ap = p_base->cast_to<AnimationPlayer>();
List<StringName> anims;
ap->get_animation_list(&anims);
Node *root = ap->get_node(ap->get_root());
-
if (root) {
+ NodePath root_path = root->get_path();
+ NodePath new_root_path = root_path;
- NodePath root_path=root->get_path();
- NodePath new_root_path=root_path;
+ for (List<Pair<NodePath, NodePath> >::Element *E = p_renames->front(); E; E = E->next()) {
-
- for(List<Pair<NodePath,NodePath> >::Element* E=p_renames->front();E;E=E->next()) {
-
- if (E->get().first==root_path) {
- new_root_path=E->get().second;
+ if (E->get().first == root_path) {
+ new_root_path = E->get().second;
break;
}
}
- if (new_root_path!=NodePath()) {
+ if (new_root_path != NodePath()) {
//will not be erased
- for(List<StringName>::Element *E=anims.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = anims.front(); E; E = E->next()) {
- Ref<Animation> anim=ap->get_animation(E->get());
+ Ref<Animation> anim = ap->get_animation(E->get());
if (!r_rem_anims->has(anim)) {
- r_rem_anims->insert(anim,Set<int>());
+ r_rem_anims->insert(anim, Set<int>());
Set<int> &ran = r_rem_anims->find(anim)->get();
- for(int i=0;i<anim->get_track_count();i++)
+ for (int i = 0; i < anim->get_track_count(); i++)
ran.insert(i);
}
@@ -964,9 +903,9 @@ void SceneTreeDock::perform_node_renames(Node* p_base,List<Pair<NodePath,NodePat
if (anim.is_null())
continue;
- for(int i=0;i<anim->get_track_count();i++) {
+ for (int i = 0; i < anim->get_track_count(); i++) {
- NodePath track_np=anim->track_get_path(i);
+ NodePath track_np = anim->track_get_path(i);
Node *n = root->get_node(track_np);
if (!n) {
continue;
@@ -977,31 +916,29 @@ void SceneTreeDock::perform_node_renames(Node* p_base,List<Pair<NodePath,NodePat
if (!ran.has(i))
continue; //channel was removed
- for(List<Pair<NodePath,NodePath> >::Element* E=p_renames->front();E;E=E->next()) {
-
- if (E->get().first==old_np) {
+ for (List<Pair<NodePath, NodePath> >::Element *E = p_renames->front(); E; E = E->next()) {
+ if (E->get().first == old_np) {
- if (E->get().second==NodePath()) {
+ if (E->get().second == NodePath()) {
//will be erased
- int idx=0;
- Set<int>::Element *EI=ran.front();
+ int idx = 0;
+ Set<int>::Element *EI = ran.front();
ERR_FAIL_COND(!EI); //bug
- while(EI->get()!=i) {
+ while (EI->get() != i) {
idx++;
- EI=EI->next();
+ EI = EI->next();
ERR_FAIL_COND(!EI); //another bug
-
}
- editor_data->get_undo_redo().add_do_method(anim.ptr(),"remove_track",idx);
- editor_data->get_undo_redo().add_undo_method(anim.ptr(),"add_track",anim->track_get_type(i),idx);
- editor_data->get_undo_redo().add_undo_method(anim.ptr(),"track_set_path",idx,track_np);
- editor_data->get_undo_redo().add_undo_method(anim.ptr(),"track_set_interpolation_type",idx,anim->track_get_interpolation_type(i));
- for(int j=0;j<anim->track_get_key_count(i);j++) {
+ editor_data->get_undo_redo().add_do_method(anim.ptr(), "remove_track", idx);
+ editor_data->get_undo_redo().add_undo_method(anim.ptr(), "add_track", anim->track_get_type(i), idx);
+ editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", idx, track_np);
+ editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_interpolation_type", idx, anim->track_get_interpolation_type(i));
+ for (int j = 0; j < anim->track_get_key_count(i); j++) {
- editor_data->get_undo_redo().add_undo_method(anim.ptr(),"track_insert_key",idx,anim->track_get_key_time(i,j),anim->track_get_key_value(i,j),anim->track_get_key_transition(i,j));
+ editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_insert_key", idx, anim->track_get_key_time(i, j), anim->track_get_key_value(i, j), anim->track_get_key_transition(i, j));
}
ran.erase(i); //byebye channel
@@ -1010,11 +947,11 @@ void SceneTreeDock::perform_node_renames(Node* p_base,List<Pair<NodePath,NodePat
//will be renamed
NodePath rel_path = new_root_path.rel_path_to(E->get().second);
- NodePath new_path = NodePath( rel_path.get_names(), track_np.get_subnames(), false, track_np.get_property() );
- if (new_path==track_np)
+ NodePath new_path = NodePath(rel_path.get_names(), track_np.get_subnames(), false, track_np.get_property());
+ if (new_path == track_np)
continue; //bleh
- editor_data->get_undo_redo().add_do_method(anim.ptr(),"track_set_path",i,new_path);
- editor_data->get_undo_redo().add_undo_method(anim.ptr(),"track_set_path",i,track_np);
+ editor_data->get_undo_redo().add_do_method(anim.ptr(), "track_set_path", i, new_path);
+ editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", i, track_np);
}
}
}
@@ -1024,120 +961,106 @@ void SceneTreeDock::perform_node_renames(Node* p_base,List<Pair<NodePath,NodePat
}
}
-
- for(int i=0;i<p_base->get_child_count();i++)
- perform_node_renames(p_base->get_child(i),p_renames,r_rem_anims);
-
+ for (int i = 0; i < p_base->get_child_count(); i++)
+ perform_node_renames(p_base->get_child(i), p_renames, r_rem_anims);
}
+void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) {
-void SceneTreeDock::_node_prerenamed(Node* p_node, const String& p_new_name) {
-
-
- List<Pair<NodePath,NodePath> > path_renames;
+ List<Pair<NodePath, NodePath> > path_renames;
Vector<StringName> base_path;
Node *n = p_node->get_parent();
- while(n) {
+ while (n) {
base_path.push_back(n->get_name());
- n=n->get_parent();
+ n = n->get_parent();
}
base_path.invert();
-
- Vector<StringName> new_base_path=base_path;
+ Vector<StringName> new_base_path = base_path;
base_path.push_back(p_node->get_name());
new_base_path.push_back(p_new_name);
- Pair<NodePath,NodePath> npp;
- npp.first = NodePath(base_path,true);
- npp.second = NodePath(new_base_path,true);
+ Pair<NodePath, NodePath> npp;
+ npp.first = NodePath(base_path, true);
+ npp.second = NodePath(new_base_path, true);
path_renames.push_back(npp);
+ for (int i = 0; i < p_node->get_child_count(); i++)
+ _fill_path_renames(base_path, new_base_path, p_node->get_child(i), &path_renames);
- for(int i=0;i<p_node->get_child_count();i++)
- _fill_path_renames(base_path,new_base_path,p_node->get_child(i),&path_renames);
-
- perform_node_renames(NULL,&path_renames);
-
+ perform_node_renames(NULL, &path_renames);
}
bool SceneTreeDock::_validate_no_foreign() {
- List<Node*> selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
- for (List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
- if (E->get()!=edited_scene && E->get()->get_owner()!=edited_scene) {
+ if (E->get() != edited_scene && E->get()->get_owner() != edited_scene) {
accept->get_ok()->set_text(TTR("Makes Sense!"));
accept->set_text(TTR("Can't operate on nodes from a foreign scene!"));
accept->popup_centered_minsize();
return false;
-
}
- if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get()))>=0) {
+ if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get())) >= 0) {
accept->get_ok()->set_text(TTR("Makes Sense!"));
accept->set_text(TTR("Can't operate on nodes the current scene inherits from!"));
accept->popup_centered_minsize();
return false;
-
}
-
}
return true;
}
-void SceneTreeDock::_node_reparent(NodePath p_path,bool p_keep_global_xform) {
-
+void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) {
Node *new_parent = scene_root->get_node(p_path);
ERR_FAIL_COND(!new_parent);
//ok all valid
- List<Node*> selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.empty())
return; //nothing to reparent
- Vector<Node*> nodes;
+ Vector<Node *> nodes;
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
nodes.push_back(E->get());
}
- _do_reparent(new_parent,-1,nodes,p_keep_global_xform);
-
+ _do_reparent(new_parent, -1, nodes, p_keep_global_xform);
}
-
-void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vector<Node*> p_nodes,bool p_keep_global_xform) {
-
+void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, Vector<Node *> p_nodes, bool p_keep_global_xform) {
Node *new_parent = p_new_parent;
ERR_FAIL_COND(!new_parent);
- Node *validate=new_parent;
- while(validate) {
+ Node *validate = new_parent;
+ while (validate) {
- if (p_nodes.find(validate)!=-1) {
+ if (p_nodes.find(validate) != -1) {
ERR_EXPLAIN("Selection changed at some point.. can't reparent");
ERR_FAIL();
return;
}
- validate=validate->get_parent();
+ validate = validate->get_parent();
}
//ok all valid
- List<Node*> selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
- if (p_nodes.size()==0)
+ if (p_nodes.size() == 0)
return; //nothing to reparent
//sort by tree order, so re-adding is easy
@@ -1145,103 +1068,96 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec
editor_data->get_undo_redo().create_action(TTR("Reparent Node"));
- List<Pair<NodePath,NodePath> > path_renames;
+ List<Pair<NodePath, NodePath> > path_renames;
Vector<StringName> former_names;
- int inc=0;
+ int inc = 0;
- for(int ni=0;ni<p_nodes.size();ni++) {
+ for (int ni = 0; ni < p_nodes.size(); ni++) {
//no undo for now, sorry
Node *node = p_nodes[ni];
- fill_path_renames(node,new_parent,&path_renames);
+ fill_path_renames(node, new_parent, &path_renames);
former_names.push_back(node->get_name());
- List<Node*> owned;
- node->get_owned_by(node->get_owner(),&owned);
+ List<Node *> owned;
+ node->get_owned_by(node->get_owner(), &owned);
Array owners;
- for(List<Node*>::Element *E=owned.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = owned.front(); E; E = E->next()) {
owners.push_back(E->get());
}
-
- if (new_parent==node->get_parent() && node->get_index() < p_position_in_parent+ni) {
+ if (new_parent == node->get_parent() && node->get_index() < p_position_in_parent + ni) {
//if child will generate a gap when moved, adjust
inc--;
}
- editor_data->get_undo_redo().add_do_method(node->get_parent(),"remove_child",node);
- editor_data->get_undo_redo().add_do_method(new_parent,"add_child",node);
+ editor_data->get_undo_redo().add_do_method(node->get_parent(), "remove_child", node);
+ editor_data->get_undo_redo().add_do_method(new_parent, "add_child", node);
- if (p_position_in_parent>=0)
- editor_data->get_undo_redo().add_do_method(new_parent,"move_child",node,p_position_in_parent+inc);
+ if (p_position_in_parent >= 0)
+ editor_data->get_undo_redo().add_do_method(new_parent, "move_child", node, p_position_in_parent + inc);
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
String new_name = new_parent->validate_child_name(node);
- editor_data->get_undo_redo().add_do_method(sed,"live_debug_reparent_node",edited_scene->get_path_to(node),edited_scene->get_path_to(new_parent),new_name,-1);
- editor_data->get_undo_redo().add_undo_method(sed,"live_debug_reparent_node",NodePath(String(edited_scene->get_path_to(new_parent))+"/"+new_name),edited_scene->get_path_to(node->get_parent()),node->get_name(),node->get_index());
+ editor_data->get_undo_redo().add_do_method(sed, "live_debug_reparent_node", edited_scene->get_path_to(node), edited_scene->get_path_to(new_parent), new_name, -1);
+ editor_data->get_undo_redo().add_undo_method(sed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)) + "/" + new_name), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index());
if (p_keep_global_xform) {
if (node->cast_to<Node2D>())
- editor_data->get_undo_redo().add_do_method(node,"set_global_transform",node->cast_to<Node2D>()->get_global_transform());
+ editor_data->get_undo_redo().add_do_method(node, "set_global_transform", node->cast_to<Node2D>()->get_global_transform());
if (node->cast_to<Spatial>())
- editor_data->get_undo_redo().add_do_method(node,"set_global_transform",node->cast_to<Spatial>()->get_global_transform());
+ editor_data->get_undo_redo().add_do_method(node, "set_global_transform", node->cast_to<Spatial>()->get_global_transform());
if (node->cast_to<Control>())
- editor_data->get_undo_redo().add_do_method(node,"set_global_pos",node->cast_to<Control>()->get_global_pos());
+ editor_data->get_undo_redo().add_do_method(node, "set_global_pos", node->cast_to<Control>()->get_global_pos());
}
- editor_data->get_undo_redo().add_do_method(this,"_set_owners",edited_scene,owners);
+ editor_data->get_undo_redo().add_do_method(this, "_set_owners", edited_scene, owners);
- if (AnimationPlayerEditor::singleton->get_key_editor()->get_root()==node)
- editor_data->get_undo_redo().add_do_method(AnimationPlayerEditor::singleton->get_key_editor(),"set_root",node);
+ if (AnimationPlayerEditor::singleton->get_key_editor()->get_root() == node)
+ editor_data->get_undo_redo().add_do_method(AnimationPlayerEditor::singleton->get_key_editor(), "set_root", node);
- editor_data->get_undo_redo().add_undo_method(new_parent,"remove_child",node);
- editor_data->get_undo_redo().add_undo_method(node,"set_name",former_names[ni]);
+ editor_data->get_undo_redo().add_undo_method(new_parent, "remove_child", node);
+ editor_data->get_undo_redo().add_undo_method(node, "set_name", former_names[ni]);
inc++;
-
}
//add and move in a second step.. (so old order is preserved)
-
-
- for(int ni=0;ni<p_nodes.size();ni++) {
+ for (int ni = 0; ni < p_nodes.size(); ni++) {
Node *node = p_nodes[ni];
- List<Node*> owned;
- node->get_owned_by(node->get_owner(),&owned);
+ List<Node *> owned;
+ node->get_owned_by(node->get_owner(), &owned);
Array owners;
- for(List<Node*>::Element *E=owned.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = owned.front(); E; E = E->next()) {
owners.push_back(E->get());
}
int child_pos = node->get_position_in_parent();
- editor_data->get_undo_redo().add_undo_method(node->get_parent(),"add_child",node);
- editor_data->get_undo_redo().add_undo_method(node->get_parent(),"move_child",node,child_pos);
- editor_data->get_undo_redo().add_undo_method(this,"_set_owners",edited_scene,owners);
- if (AnimationPlayerEditor::singleton->get_key_editor()->get_root()==node)
- editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_key_editor(),"set_root",node);
+ editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node);
+ editor_data->get_undo_redo().add_undo_method(node->get_parent(), "move_child", node, child_pos);
+ editor_data->get_undo_redo().add_undo_method(this, "_set_owners", edited_scene, owners);
+ if (AnimationPlayerEditor::singleton->get_key_editor()->get_root() == node)
+ editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_key_editor(), "set_root", node);
if (p_keep_global_xform) {
if (node->cast_to<Node2D>())
- editor_data->get_undo_redo().add_undo_method(node,"set_transform",node->cast_to<Node2D>()->get_transform());
+ editor_data->get_undo_redo().add_undo_method(node, "set_transform", node->cast_to<Node2D>()->get_transform());
if (node->cast_to<Spatial>())
- editor_data->get_undo_redo().add_undo_method(node,"set_transform",node->cast_to<Spatial>()->get_transform());
+ editor_data->get_undo_redo().add_undo_method(node, "set_transform", node->cast_to<Spatial>()->get_transform());
if (node->cast_to<Control>())
- editor_data->get_undo_redo().add_undo_method(node,"set_pos",node->cast_to<Control>()->get_pos());
+ editor_data->get_undo_redo().add_undo_method(node, "set_pos", node->cast_to<Control>()->get_pos());
}
-
-
-
}
- perform_node_renames(NULL,&path_renames);
+ perform_node_renames(NULL, &path_renames);
editor_data->get_undo_redo().commit_action();
//node->set_owner(owner);
@@ -1256,109 +1172,94 @@ void SceneTreeDock::_script_created(Ref<Script> p_script) {
editor->push_item(p_script.operator->());
button_create_script->hide();
button_clear_script->show();
-
}
-
void SceneTreeDock::_delete_confirm() {
- List<Node*> remove_list = editor_selection->get_selected_node_list();
+ List<Node *> remove_list = editor_selection->get_selected_node_list();
if (remove_list.empty())
return;
-
editor->get_editor_plugins_over()->make_visible(false);
editor_data->get_undo_redo().create_action(TTR("Remove Node(s)"));
- bool entire_scene=false;
+ bool entire_scene = false;
- for(List<Node*>::Element *E=remove_list.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) {
- if (E->get()==edited_scene) {
- entire_scene=true;
+ if (E->get() == edited_scene) {
+ entire_scene = true;
}
}
if (entire_scene) {
- editor_data->get_undo_redo().add_do_method(editor,"set_edited_scene",(Object*)NULL);
- editor_data->get_undo_redo().add_undo_method(editor,"set_edited_scene",edited_scene);
- editor_data->get_undo_redo().add_undo_method(edited_scene,"set_owner",edited_scene->get_owner());
+ editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", (Object *)NULL);
+ editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", edited_scene);
+ editor_data->get_undo_redo().add_undo_method(edited_scene, "set_owner", edited_scene->get_owner());
editor_data->get_undo_redo().add_undo_reference(edited_scene);
} else {
remove_list.sort_custom<Node::Comparator>(); //sort nodes to keep positions
- List<Pair<NodePath,NodePath> > path_renames;
-
+ List<Pair<NodePath, NodePath> > path_renames;
//delete from animation
- for(List<Node*>::Element *E=remove_list.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) {
Node *n = E->get();
if (!n->is_inside_tree() || !n->get_parent())
continue;
- fill_path_renames(n,NULL,&path_renames);
-
+ fill_path_renames(n, NULL, &path_renames);
}
- perform_node_renames(NULL,&path_renames);
+ perform_node_renames(NULL, &path_renames);
//delete for read
- for(List<Node*>::Element *E=remove_list.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) {
Node *n = E->get();
if (!n->is_inside_tree() || !n->get_parent())
continue;
- List<Node*> owned;
- n->get_owned_by(n->get_owner(),&owned);
+ List<Node *> owned;
+ n->get_owned_by(n->get_owner(), &owned);
Array owners;
- for(List<Node*>::Element *E=owned.front();E;E=E->next()) {
+ for (List<Node *>::Element *E = owned.front(); E; E = E->next()) {
owners.push_back(E->get());
}
-
- editor_data->get_undo_redo().add_do_method(n->get_parent(),"remove_child",n);
- editor_data->get_undo_redo().add_undo_method(n->get_parent(),"add_child",n);
- editor_data->get_undo_redo().add_undo_method(n->get_parent(),"move_child",n,n->get_index());
- if (AnimationPlayerEditor::singleton->get_key_editor()->get_root()==n)
- editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_key_editor(),"set_root",n);
- editor_data->get_undo_redo().add_undo_method(this,"_set_owners",edited_scene,owners);
+ editor_data->get_undo_redo().add_do_method(n->get_parent(), "remove_child", n);
+ editor_data->get_undo_redo().add_undo_method(n->get_parent(), "add_child", n);
+ editor_data->get_undo_redo().add_undo_method(n->get_parent(), "move_child", n, n->get_index());
+ if (AnimationPlayerEditor::singleton->get_key_editor()->get_root() == n)
+ editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::singleton->get_key_editor(), "set_root", n);
+ editor_data->get_undo_redo().add_undo_method(this, "_set_owners", edited_scene, owners);
//editor_data->get_undo_redo().add_undo_method(n,"set_owner",n->get_owner());
editor_data->get_undo_redo().add_undo_reference(n);
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
- editor_data->get_undo_redo().add_do_method(sed,"live_debug_remove_and_keep_node",edited_scene->get_path_to(n),n->get_instance_ID());
- editor_data->get_undo_redo().add_undo_method(sed,"live_debug_restore_node",n->get_instance_ID(),edited_scene->get_path_to(n->get_parent()),n->get_index());
-
+ editor_data->get_undo_redo().add_do_method(sed, "live_debug_remove_and_keep_node", edited_scene->get_path_to(n), n->get_instance_ID());
+ editor_data->get_undo_redo().add_undo_method(sed, "live_debug_restore_node", n->get_instance_ID(), edited_scene->get_path_to(n->get_parent()), n->get_index());
}
-
-
}
editor_data->get_undo_redo().commit_action();
-
-
}
-
-
-
void SceneTreeDock::_selection_changed() {
int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size();
- if (selection_size>1) {
+ if (selection_size > 1) {
//automatically turn on multi-edit
_tool_selected(TOOL_MULTI_EDIT);
}
- if (selection_size==1) {
- if(EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) {
+ if (selection_size == 1) {
+ if (EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) {
button_create_script->show();
button_clear_script->hide();
- }
- else {
+ } else {
button_create_script->hide();
button_clear_script->show();
}
@@ -1368,22 +1269,18 @@ void SceneTreeDock::_selection_changed() {
}
//tool_buttons[TOOL_MULTI_EDIT]->set_disabled(EditorNode::get_singleton()->get_editor_selection()->get_selection().size()<2);
-
}
-
void SceneTreeDock::_create() {
+ if (current_option == TOOL_NEW) {
- if (current_option==TOOL_NEW) {
-
- Node *parent=NULL;
-
+ Node *parent = NULL;
if (edited_scene) {
// If root exists in edited scene
parent = scene_tree->get_selected();
- if( !parent )
+ if (!parent)
parent = edited_scene;
} else {
@@ -1395,32 +1292,30 @@ void SceneTreeDock::_create() {
Object *c = create_dialog->instance_selected();
ERR_FAIL_COND(!c);
- Node *child=c->cast_to<Node>();
+ Node *child = c->cast_to<Node>();
ERR_FAIL_COND(!child);
editor_data->get_undo_redo().create_action(TTR("Create Node"));
if (edited_scene) {
- editor_data->get_undo_redo().add_do_method(parent,"add_child",child);
- editor_data->get_undo_redo().add_do_method(child,"set_owner",edited_scene);
- editor_data->get_undo_redo().add_do_method(editor_selection,"clear");
- editor_data->get_undo_redo().add_do_method(editor_selection,"add_node",child);
+ editor_data->get_undo_redo().add_do_method(parent, "add_child", child);
+ editor_data->get_undo_redo().add_do_method(child, "set_owner", edited_scene);
+ editor_data->get_undo_redo().add_do_method(editor_selection, "clear");
+ editor_data->get_undo_redo().add_do_method(editor_selection, "add_node", child);
editor_data->get_undo_redo().add_do_reference(child);
- editor_data->get_undo_redo().add_undo_method(parent,"remove_child",child);
-
+ editor_data->get_undo_redo().add_undo_method(parent, "remove_child", child);
String new_name = parent->validate_child_name(child);
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
- editor_data->get_undo_redo().add_do_method(sed,"live_debug_create_node",edited_scene->get_path_to(parent),child->get_class(),new_name);
- editor_data->get_undo_redo().add_undo_method(sed,"live_debug_remove_node",NodePath(String(edited_scene->get_path_to(parent))+"/"+new_name));
+ editor_data->get_undo_redo().add_do_method(sed, "live_debug_create_node", edited_scene->get_path_to(parent), child->get_class(), new_name);
+ editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + new_name));
} else {
- editor_data->get_undo_redo().add_do_method(editor,"set_edited_scene",child);
+ editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", child);
editor_data->get_undo_redo().add_do_reference(child);
- editor_data->get_undo_redo().add_undo_method(editor,"set_edited_scene",(Object*)NULL);
-
+ editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)NULL);
}
editor_data->get_undo_redo().commit_action();
@@ -1431,31 +1326,30 @@ void SceneTreeDock::_create() {
Control *ct = c->cast_to<Control>();
Size2 ms = ct->get_minimum_size();
- if (ms.width<4)
- ms.width=40;
- if (ms.height<4)
- ms.height=40;
+ if (ms.width < 4)
+ ms.width = 40;
+ if (ms.height < 4)
+ ms.height = 40;
ct->set_size(ms);
}
-
- } else if (current_option==TOOL_REPLACE) {
- Node * n = scene_tree->get_selected();
+ } else if (current_option == TOOL_REPLACE) {
+ Node *n = scene_tree->get_selected();
ERR_FAIL_COND(!n);
Object *c = create_dialog->instance_selected();
ERR_FAIL_COND(!c);
- Node *newnode=c->cast_to<Node>();
+ Node *newnode = c->cast_to<Node>();
ERR_FAIL_COND(!newnode);
List<PropertyInfo> pinfo;
n->get_property_list(&pinfo);
- for(List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
- if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
- newnode->set(E->get().name,n->get(E->get().name));
+ newnode->set(E->get().name, n->get(E->get().name));
}
editor->push_item(NULL);
@@ -1464,41 +1358,40 @@ void SceneTreeDock::_create() {
List<MethodInfo> sl;
n->get_signal_list(&sl);
- for (List<MethodInfo>::Element *E=sl.front();E;E=E->next()) {
+ for (List<MethodInfo>::Element *E = sl.front(); E; E = E->next()) {
List<Object::Connection> cl;
- n->get_signal_connection_list(E->get().name,&cl);
+ n->get_signal_connection_list(E->get().name, &cl);
- for(List<Object::Connection>::Element *F=cl.front();F;F=F->next()) {
+ for (List<Object::Connection>::Element *F = cl.front(); F; F = F->next()) {
- Object::Connection &c=F->get();
- if (!(c.flags&Object::CONNECT_PERSIST))
+ Object::Connection &c = F->get();
+ if (!(c.flags & Object::CONNECT_PERSIST))
continue;
- newnode->connect(c.signal,c.target,c.method,varray(),Object::CONNECT_PERSIST);
+ newnode->connect(c.signal, c.target, c.method, varray(), Object::CONNECT_PERSIST);
}
-
}
- String newname=n->get_name();
+ String newname = n->get_name();
- List<Node*> to_erase;
- for(int i=0;i<n->get_child_count();i++) {
- if (n->get_child(i)->get_owner()==NULL && n->is_owned_by_parent()) {
+ List<Node *> to_erase;
+ for (int i = 0; i < n->get_child_count(); i++) {
+ if (n->get_child(i)->get_owner() == NULL && n->is_owned_by_parent()) {
to_erase.push_back(n->get_child(i));
}
}
- n->replace_by(newnode,true);
+ n->replace_by(newnode, true);
- if (n==edited_scene) {
- edited_scene=newnode;
+ if (n == edited_scene) {
+ edited_scene = newnode;
editor->set_edited_scene(newnode);
newnode->set_editable_instances(n->get_editable_instances());
}
//small hack to make collisionshapes and other kind of nodes to work
- for(int i=0;i<newnode->get_child_count();i++) {
- Node *c=newnode->get_child(i);
- c->call("set_transform", c->call("get_transform") );
+ for (int i = 0; i < newnode->get_child_count(); i++) {
+ Node *c = newnode->get_child(i);
+ c->call("set_transform", c->call("get_transform"));
}
editor_data->get_undo_redo().clear_history();
newnode->set_name(newname);
@@ -1507,27 +1400,21 @@ void SceneTreeDock::_create() {
memdelete(n);
- while(to_erase.front()) {
+ while (to_erase.front()) {
memdelete(to_erase.front()->get());
to_erase.pop_front();
}
-
-
-
}
-
}
+void SceneTreeDock::set_edited_scene(Node *p_scene) {
-void SceneTreeDock::set_edited_scene(Node* p_scene) {
-
- edited_scene=p_scene;
+ edited_scene = p_scene;
}
-void SceneTreeDock::set_selected(Node *p_node, bool p_emit_selected ) {
-
- scene_tree->set_selected(p_node,p_emit_selected);
+void SceneTreeDock::set_selected(Node *p_node, bool p_emit_selected) {
+ scene_tree->set_selected(p_node, p_emit_selected);
}
void SceneTreeDock::import_subscene() {
@@ -1537,17 +1424,16 @@ void SceneTreeDock::import_subscene() {
void SceneTreeDock::_import_subscene() {
- Node* parent = scene_tree->get_selected();
+ Node *parent = scene_tree->get_selected();
if (!parent) {
parent = editor_data->get_edited_scene_root();
ERR_FAIL_COND(!parent);
}
- import_subscene_dialog->move(parent,edited_scene);
+ import_subscene_dialog->move(parent, edited_scene);
editor_data->get_undo_redo().clear_history(); //no undo for now..
-
-/*
+ /*
editor_data->get_undo_redo().create_action("Import Subscene");
editor_data->get_undo_redo().add_do_method(parent,"add_child",ss);
//editor_data->get_undo_redo().add_do_method(editor_selection,"clear");
@@ -1560,9 +1446,9 @@ void SceneTreeDock::_import_subscene() {
void SceneTreeDock::_new_scene_from(String p_file) {
- List<Node*> selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.size()!=1) {
+ if (selection.size() != 1) {
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation requires a single selected node."));
accept->popup_centered_minsize();
@@ -1571,33 +1457,32 @@ void SceneTreeDock::_new_scene_from(String p_file) {
Node *base = selection.front()->get();
- Map<Node*,Node*> reown;
- reown[editor_data->get_edited_scene_root()]=base;
+ Map<Node *, Node *> reown;
+ reown[editor_data->get_edited_scene_root()] = base;
Node *copy = base->duplicate_and_reown(reown);
if (copy) {
- Ref<PackedScene> sdata = memnew( PackedScene );
+ Ref<PackedScene> sdata = memnew(PackedScene);
Error err = sdata->pack(copy);
memdelete(copy);
- if (err!=OK) {
+ if (err != OK) {
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Couldn't save new scene. Likely dependencies (instances) couldn't be satisfied."));
accept->popup_centered_minsize();
return;
}
- int flg=0;
+ int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
- flg|=ResourceSaver::FLAG_COMPRESS;
+ flg |= ResourceSaver::FLAG_COMPRESS;
/*
if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
*/
-
- err = ResourceSaver::save(p_file,sdata,flg);
- if (err!=OK) {
+ err = ResourceSaver::save(p_file, sdata, flg);
+ if (err != OK) {
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("Error saving scene."));
accept->popup_centered_minsize();
@@ -1610,29 +1495,27 @@ void SceneTreeDock::_new_scene_from(String p_file) {
accept->popup_centered_minsize();
return;
}
-
}
-static bool _is_node_visible(Node* p_node) {
+static bool _is_node_visible(Node *p_node) {
if (!p_node->get_owner())
return false;
- if (p_node->get_owner()!=EditorNode::get_singleton()->get_edited_scene() && !EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node->get_owner()))
+ if (p_node->get_owner() != EditorNode::get_singleton()->get_edited_scene() && !EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node->get_owner()))
return false;
return true;
-
}
-static bool _has_visible_children(Node* p_node) {
+static bool _has_visible_children(Node *p_node) {
bool collapsed = p_node->is_displayed_folded();
if (collapsed)
return false;
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- Node* child = p_node->get_child(i);
+ Node *child = p_node->get_child(i);
if (!_is_node_visible(child))
continue;
@@ -1640,87 +1523,76 @@ static bool _has_visible_children(Node* p_node) {
}
return false;
-
}
+static Node *_find_last_visible(Node *p_node) {
-
-static Node* _find_last_visible(Node* p_node) {
-
- Node* last=NULL;
+ Node *last = NULL;
bool collapsed = p_node->is_displayed_folded();
- if (!collapsed) {
- for(int i=0;i<p_node->get_child_count();i++) {
+ if (!collapsed) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
if (_is_node_visible(p_node->get_child(i))) {
- last=p_node->get_child(i);
+ last = p_node->get_child(i);
}
}
}
if (last) {
- Node* lastc=_find_last_visible(last);
+ Node *lastc = _find_last_visible(last);
if (lastc)
- last=lastc;
-
+ last = lastc;
} else {
- last=p_node;
+ last = p_node;
}
return last;
}
+void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) {
-void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos, int p_type) {
-
- to_pos=-1;
+ to_pos = -1;
- if (p_type==-1) {
+ if (p_type == -1) {
//drop at above selected node
- if (to_node==EditorNode::get_singleton()->get_edited_scene()) {
- to_node=NULL;
+ if (to_node == EditorNode::get_singleton()->get_edited_scene()) {
+ to_node = NULL;
ERR_EXPLAIN("Cannot perform drop above the root node!");
ERR_FAIL();
}
- to_pos=to_node->get_index();
- to_node=to_node->get_parent();
-
- } else if (p_type==1) {
- //drop at below selected node
- if (to_node==EditorNode::get_singleton()->get_edited_scene()) {
- //if at lower sibling of root node
- to_pos=0; //just insert at begining of root node
- return;
- }
-
-
- Node* lower_sibling=NULL;
-
+ to_pos = to_node->get_index();
+ to_node = to_node->get_parent();
+ } else if (p_type == 1) {
+ //drop at below selected node
+ if (to_node == EditorNode::get_singleton()->get_edited_scene()) {
+ //if at lower sibling of root node
+ to_pos = 0; //just insert at begining of root node
+ return;
+ }
- if (_has_visible_children(to_node) ) {
- to_pos=0;
- } else {
+ Node *lower_sibling = NULL;
+ if (_has_visible_children(to_node)) {
+ to_pos = 0;
+ } else {
- for(int i=to_node->get_index()+1;i<to_node->get_parent()->get_child_count();i++) {
- Node *c =to_node->get_parent()->get_child(i);
- if (_is_node_visible(c)) {
- lower_sibling=c;
- break;
- }
- }
- if (lower_sibling) {
- to_pos=lower_sibling->get_index();
+ for (int i = to_node->get_index() + 1; i < to_node->get_parent()->get_child_count(); i++) {
+ Node *c = to_node->get_parent()->get_child(i);
+ if (_is_node_visible(c)) {
+ lower_sibling = c;
+ break;
}
-
- to_node=to_node->get_parent();
-
-
}
+ if (lower_sibling) {
+ to_pos = lower_sibling->get_index();
+ }
+
+ to_node = to_node->get_parent();
+ }
#if 0
//quite complicated, look for next visible in tree
upper_sibling=_find_last_visible(upper_sibling);
@@ -1741,19 +1613,17 @@ void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos, int p_type) {
to_node=to_node->get_parent();
}
#endif
-
}
-
}
-void SceneTreeDock::_files_dropped(Vector<String> p_files,NodePath p_to,int p_type) {
+void SceneTreeDock::_files_dropped(Vector<String> p_files, NodePath p_to, int p_type) {
Node *node = get_node(p_to);
ERR_FAIL_COND(!node);
- int to_pos=-1;
- _normalize_drop(node,to_pos,p_type);
- _perform_instance_scenes(p_files,node,to_pos);
+ int to_pos = -1;
+ _normalize_drop(node, to_pos, p_type);
+ _perform_instance_scenes(p_files, node, to_pos);
}
void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) {
@@ -1765,58 +1635,56 @@ void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) {
}
}
-void SceneTreeDock::_nodes_dragged(Array p_nodes,NodePath p_to,int p_type) {
+void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) {
- Vector<Node*> nodes;
+ Vector<Node *> nodes;
Node *to_node;
- for(int i=0;i<p_nodes.size();i++) {
- Node *n=get_node((p_nodes[i]));
+ for (int i = 0; i < p_nodes.size(); i++) {
+ Node *n = get_node((p_nodes[i]));
if (n) {
nodes.push_back(n);
}
}
- if (nodes.size()==0)
+ if (nodes.size() == 0)
return;
- to_node=get_node(p_to);
+ to_node = get_node(p_to);
if (!to_node)
return;
- int to_pos=-1;
-
- _normalize_drop(to_node,to_pos,p_type);
- _do_reparent(to_node,to_pos,nodes,true);
+ int to_pos = -1;
+ _normalize_drop(to_node, to_pos, p_type);
+ _do_reparent(to_node, to_pos, nodes, true);
}
-void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) {
+void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (!EditorNode::get_singleton()->get_edited_scene()) {
menu->clear();
- menu->add_icon_shortcut(get_icon("Add","EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
- menu->add_icon_shortcut(get_icon("Instance","EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
+ menu->add_icon_shortcut(get_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
+ menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
- menu->set_size(Size2(1,1));
+ menu->set_size(Size2(1, 1));
menu->set_pos(p_menu_pos);
menu->popup();
return;
}
- List<Node*> selection = editor_selection->get_selected_node_list();
+ List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.size()==0)
+ if (selection.size() == 0)
return;
menu->clear();
-
- if (selection.size()==1) {
- menu->add_icon_shortcut(get_icon("Add","EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
- menu->add_icon_shortcut(get_icon("Instance","EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
+ if (selection.size() == 1) {
+ menu->add_icon_shortcut(get_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
+ menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
menu->add_separator();
- menu->add_icon_shortcut(get_icon("Reload","EditorIcons"),ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE);
+ menu->add_icon_shortcut(get_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE);
//menu->add_separator(); moved to their own dock
//menu->add_icon_item(get_icon("Groups","EditorIcons"),TTR("Edit Groups"),TOOL_GROUP);
//menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT);
@@ -1826,28 +1694,26 @@ void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) {
menu->add_separator();
}
- menu->add_icon_shortcut(get_icon("Up","EditorIcons"),ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP);
- menu->add_icon_shortcut(get_icon("Down","EditorIcons"),ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN);
- menu->add_icon_shortcut(get_icon("Duplicate","EditorIcons"),ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE);
- menu->add_icon_shortcut(get_icon("Reparent","EditorIcons"),ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT);
+ menu->add_icon_shortcut(get_icon("Up", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP);
+ menu->add_icon_shortcut(get_icon("Down", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN);
+ menu->add_icon_shortcut(get_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE);
+ menu->add_icon_shortcut(get_icon("Reparent", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT);
- if (selection.size()==1) {
+ if (selection.size() == 1) {
menu->add_separator();
- menu->add_icon_shortcut(get_icon("Blend","EditorIcons"),ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE);
- menu->add_icon_shortcut(get_icon("CreateNewSceneFrom","EditorIcons"),ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM);
+ menu->add_icon_shortcut(get_icon("Blend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE);
+ menu->add_icon_shortcut(get_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM);
menu->add_separator();
- menu->add_icon_shortcut(get_icon("CopyNodePath","EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH);
+ menu->add_icon_shortcut(get_icon("CopyNodePath", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH);
}
menu->add_separator();
- menu->add_icon_shortcut(get_icon("Remove","EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE);
- menu->set_size(Size2(1,1));
+ menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE);
+ menu->set_size(Size2(1, 1));
menu->set_pos(p_menu_pos);
menu->popup();
-
}
-
-void SceneTreeDock::_filter_changed(const String& p_filter) {
+void SceneTreeDock::_filter_changed(const String &p_filter) {
scene_tree->set_filter(p_filter);
}
@@ -1857,13 +1723,12 @@ String SceneTreeDock::get_filter() {
return filter->get_text();
}
-void SceneTreeDock::set_filter(const String& p_filter){
+void SceneTreeDock::set_filter(const String &p_filter) {
filter->set_text(p_filter);
scene_tree->set_filter(p_filter);
}
-
void SceneTreeDock::_focus_node() {
Node *node = scene_tree->get_selected();
@@ -1878,105 +1743,99 @@ void SceneTreeDock::_focus_node() {
}
}
-void SceneTreeDock::open_script_dialog(Node* p_for_node) {
+void SceneTreeDock::open_script_dialog(Node *p_for_node) {
- scene_tree->set_selected(p_for_node,false);
+ scene_tree->set_selected(p_for_node, false);
_tool_selected(TOOL_ATTACH_SCRIPT);
}
void SceneTreeDock::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_tool_selected"),&SceneTreeDock::_tool_selected,DEFVAL(false));
- ClassDB::bind_method(D_METHOD("_create"),&SceneTreeDock::_create);
+ ClassDB::bind_method(D_METHOD("_tool_selected"), &SceneTreeDock::_tool_selected, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("_create"), &SceneTreeDock::_create);
//ClassDB::bind_method(D_METHOD("_script_created"),&SceneTreeDock::_script_created);
- ClassDB::bind_method(D_METHOD("_node_reparent"),&SceneTreeDock::_node_reparent);
- ClassDB::bind_method(D_METHOD("_set_owners"),&SceneTreeDock::_set_owners);
- ClassDB::bind_method(D_METHOD("_node_selected"),&SceneTreeDock::_node_selected);
- ClassDB::bind_method(D_METHOD("_node_renamed"),&SceneTreeDock::_node_renamed);
- ClassDB::bind_method(D_METHOD("_script_created"),&SceneTreeDock::_script_created);
- ClassDB::bind_method(D_METHOD("_load_request"),&SceneTreeDock::_load_request);
- ClassDB::bind_method(D_METHOD("_script_open_request"),&SceneTreeDock::_script_open_request);
- ClassDB::bind_method(D_METHOD("_unhandled_key_input"),&SceneTreeDock::_unhandled_key_input);
- ClassDB::bind_method(D_METHOD("_input"),&SceneTreeDock::_input);
- ClassDB::bind_method(D_METHOD("_nodes_drag_begin"),&SceneTreeDock::_nodes_drag_begin);
- ClassDB::bind_method(D_METHOD("_delete_confirm"),&SceneTreeDock::_delete_confirm);
- ClassDB::bind_method(D_METHOD("_node_prerenamed"),&SceneTreeDock::_node_prerenamed);
- ClassDB::bind_method(D_METHOD("_import_subscene"),&SceneTreeDock::_import_subscene);
- ClassDB::bind_method(D_METHOD("_selection_changed"),&SceneTreeDock::_selection_changed);
- ClassDB::bind_method(D_METHOD("_new_scene_from"),&SceneTreeDock::_new_scene_from);
- ClassDB::bind_method(D_METHOD("_nodes_dragged"),&SceneTreeDock::_nodes_dragged);
- ClassDB::bind_method(D_METHOD("_files_dropped"),&SceneTreeDock::_files_dropped);
- ClassDB::bind_method(D_METHOD("_script_dropped"),&SceneTreeDock::_script_dropped);
- ClassDB::bind_method(D_METHOD("_tree_rmb"),&SceneTreeDock::_tree_rmb);
- ClassDB::bind_method(D_METHOD("_filter_changed"),&SceneTreeDock::_filter_changed);
- ClassDB::bind_method(D_METHOD("_focus_node"),&SceneTreeDock::_focus_node);
-
-
- ClassDB::bind_method(D_METHOD("instance"),&SceneTreeDock::instance);
+ ClassDB::bind_method(D_METHOD("_node_reparent"), &SceneTreeDock::_node_reparent);
+ ClassDB::bind_method(D_METHOD("_set_owners"), &SceneTreeDock::_set_owners);
+ ClassDB::bind_method(D_METHOD("_node_selected"), &SceneTreeDock::_node_selected);
+ ClassDB::bind_method(D_METHOD("_node_renamed"), &SceneTreeDock::_node_renamed);
+ ClassDB::bind_method(D_METHOD("_script_created"), &SceneTreeDock::_script_created);
+ ClassDB::bind_method(D_METHOD("_load_request"), &SceneTreeDock::_load_request);
+ ClassDB::bind_method(D_METHOD("_script_open_request"), &SceneTreeDock::_script_open_request);
+ ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &SceneTreeDock::_unhandled_key_input);
+ ClassDB::bind_method(D_METHOD("_input"), &SceneTreeDock::_input);
+ ClassDB::bind_method(D_METHOD("_nodes_drag_begin"), &SceneTreeDock::_nodes_drag_begin);
+ ClassDB::bind_method(D_METHOD("_delete_confirm"), &SceneTreeDock::_delete_confirm);
+ ClassDB::bind_method(D_METHOD("_node_prerenamed"), &SceneTreeDock::_node_prerenamed);
+ ClassDB::bind_method(D_METHOD("_import_subscene"), &SceneTreeDock::_import_subscene);
+ ClassDB::bind_method(D_METHOD("_selection_changed"), &SceneTreeDock::_selection_changed);
+ ClassDB::bind_method(D_METHOD("_new_scene_from"), &SceneTreeDock::_new_scene_from);
+ ClassDB::bind_method(D_METHOD("_nodes_dragged"), &SceneTreeDock::_nodes_dragged);
+ ClassDB::bind_method(D_METHOD("_files_dropped"), &SceneTreeDock::_files_dropped);
+ ClassDB::bind_method(D_METHOD("_script_dropped"), &SceneTreeDock::_script_dropped);
+ ClassDB::bind_method(D_METHOD("_tree_rmb"), &SceneTreeDock::_tree_rmb);
+ ClassDB::bind_method(D_METHOD("_filter_changed"), &SceneTreeDock::_filter_changed);
+ ClassDB::bind_method(D_METHOD("_focus_node"), &SceneTreeDock::_focus_node);
+
+ ClassDB::bind_method(D_METHOD("instance"), &SceneTreeDock::instance);
}
+SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSelection *p_editor_selection, EditorData &p_editor_data) {
-
-SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelection *p_editor_selection,EditorData &p_editor_data) {
-
- editor=p_editor;
- edited_scene=NULL;
- editor_data=&p_editor_data;
- editor_selection=p_editor_selection;
- scene_root=p_scene_root;
+ editor = p_editor;
+ edited_scene = NULL;
+ editor_data = &p_editor_data;
+ editor_selection = p_editor_selection;
+ scene_root = p_scene_root;
VBoxContainer *vbc = this;
- HBoxContainer *filter_hbc = memnew( HBoxContainer );
+ HBoxContainer *filter_hbc = memnew(HBoxContainer);
ToolButton *tb;
- ED_SHORTCUT("scene_tree/add_child_node",TTR("Add Child Node"), KEY_MASK_CMD|KEY_A);
- ED_SHORTCUT("scene_tree/instance_scene",TTR("Instance Child Scene"));
+ ED_SHORTCUT("scene_tree/add_child_node", TTR("Add Child Node"), KEY_MASK_CMD | KEY_A);
+ ED_SHORTCUT("scene_tree/instance_scene", TTR("Instance Child Scene"));
ED_SHORTCUT("scene_tree/change_node_type", TTR("Change Type"));
ED_SHORTCUT("scene_tree/attach_script", TTR("Attach Script"));
ED_SHORTCUT("scene_tree/clear_script", TTR("Clear Script"));
ED_SHORTCUT("scene_tree/move_up", TTR("Move Up"), KEY_MASK_CMD | KEY_UP);
ED_SHORTCUT("scene_tree/move_down", TTR("Move Down"), KEY_MASK_CMD | KEY_DOWN);
- ED_SHORTCUT("scene_tree/duplicate", TTR("Duplicate"),KEY_MASK_CMD | KEY_D);
+ ED_SHORTCUT("scene_tree/duplicate", TTR("Duplicate"), KEY_MASK_CMD | KEY_D);
ED_SHORTCUT("scene_tree/reparent", TTR("Reparent"));
ED_SHORTCUT("scene_tree/merge_from_scene", TTR("Merge From Scene"));
ED_SHORTCUT("scene_tree/save_branch_as_scene", TTR("Save Branch as Scene"));
- ED_SHORTCUT("scene_tree/copy_node_path", TTR("Copy Node Path"), KEY_MASK_CMD|KEY_C);
- ED_SHORTCUT("scene_tree/delete_no_confirm", TTR("Delete (No Confirm)"), KEY_MASK_SHIFT|KEY_DELETE);
+ ED_SHORTCUT("scene_tree/copy_node_path", TTR("Copy Node Path"), KEY_MASK_CMD | KEY_C);
+ ED_SHORTCUT("scene_tree/delete_no_confirm", TTR("Delete (No Confirm)"), KEY_MASK_SHIFT | KEY_DELETE);
ED_SHORTCUT("scene_tree/delete", TTR("Delete"), KEY_DELETE);
- tb = memnew( ToolButton );
- tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_NEW, false));
+ tb = memnew(ToolButton);
+ tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_NEW, false));
tb->set_tooltip(TTR("Add/Create a New Node"));
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/add_child_node"));
filter_hbc->add_child(tb);
- button_add=tb;
+ button_add = tb;
- tb = memnew( ToolButton );
- tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_INSTANCE, false));
+ tb = memnew(ToolButton);
+ tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_INSTANCE, false));
tb->set_tooltip(TTR("Instance a scene file as a Node. Creates an inherited scene if no root node exists."));
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/instance_scene"));
filter_hbc->add_child(tb);
- button_instance=tb;
-
-
+ button_instance = tb;
vbc->add_child(filter_hbc);
- filter = memnew( LineEdit );
+ filter = memnew(LineEdit);
filter->set_h_size_flags(SIZE_EXPAND_FILL);
filter_hbc->add_child(filter);
- filter_icon = memnew( TextureRect );
+ filter_icon = memnew(TextureRect);
filter_hbc->add_child(filter_icon);
filter_icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
- filter->connect("text_changed",this,"_filter_changed");
+ filter->connect("text_changed", this, "_filter_changed");
-
- tb = memnew( ToolButton );
- tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_ATTACH_SCRIPT, false));
+ tb = memnew(ToolButton);
+ tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_ATTACH_SCRIPT, false));
tb->set_tooltip(TTR("Attach a new or existing script for the selected node."));
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script"));
filter_hbc->add_child(tb);
- button_create_script=tb;
+ button_create_script = tb;
tb = memnew(ToolButton);
tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_CLEAR_SCRIPT, false));
@@ -1985,32 +1844,30 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
filter_hbc->add_child(tb);
button_clear_script = tb;
-
- scene_tree = memnew( SceneTreeEditor(false,true,true ));
+ scene_tree = memnew(SceneTreeEditor(false, true, true));
vbc->add_child(scene_tree);
- scene_tree->set_v_size_flags(SIZE_EXPAND|SIZE_FILL);
- scene_tree->connect("rmb_pressed",this,"_tree_rmb");
-
- scene_tree->connect("node_selected", this,"_node_selected",varray(),CONNECT_DEFERRED);
- scene_tree->connect("node_renamed", this,"_node_renamed",varray(),CONNECT_DEFERRED);
- scene_tree->connect("node_prerename", this,"_node_prerenamed");
- scene_tree->connect("open",this,"_load_request");
- scene_tree->connect("open_script",this,"_script_open_request");
- scene_tree->connect("nodes_rearranged",this,"_nodes_dragged");
- scene_tree->connect("files_dropped",this,"_files_dropped");
- scene_tree->connect("script_dropped",this,"_script_dropped");
- scene_tree->connect("nodes_dragged",this,"_nodes_drag_begin");
+ scene_tree->set_v_size_flags(SIZE_EXPAND | SIZE_FILL);
+ scene_tree->connect("rmb_pressed", this, "_tree_rmb");
+
+ scene_tree->connect("node_selected", this, "_node_selected", varray(), CONNECT_DEFERRED);
+ scene_tree->connect("node_renamed", this, "_node_renamed", varray(), CONNECT_DEFERRED);
+ scene_tree->connect("node_prerename", this, "_node_prerenamed");
+ scene_tree->connect("open", this, "_load_request");
+ scene_tree->connect("open_script", this, "_script_open_request");
+ scene_tree->connect("nodes_rearranged", this, "_nodes_dragged");
+ scene_tree->connect("files_dropped", this, "_files_dropped");
+ scene_tree->connect("script_dropped", this, "_script_dropped");
+ scene_tree->connect("nodes_dragged", this, "_nodes_drag_begin");
scene_tree->get_scene_tree()->connect("item_double_clicked", this, "_focus_node");
scene_tree->set_undo_redo(&editor_data->get_undo_redo());
scene_tree->set_editor_selection(editor_selection);
-
- create_dialog = memnew( CreateDialog );
+ create_dialog = memnew(CreateDialog);
create_dialog->set_base_type("Node");
add_child(create_dialog);
- create_dialog->connect("create",this,"_create");
+ create_dialog->connect("create", this, "_create");
//groups_editor = memnew( GroupsEditor );
//add_child(groups_editor);
@@ -2020,42 +1877,41 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
//add_child(connect_dialog);
//connect_dialog->set_undoredo(&editor_data->get_undo_redo());
- script_create_dialog = memnew( ScriptCreateDialog );
+ script_create_dialog = memnew(ScriptCreateDialog);
add_child(script_create_dialog);
- script_create_dialog->connect("script_created",this,"_script_created");
+ script_create_dialog->connect("script_created", this, "_script_created");
- reparent_dialog = memnew( ReparentDialog );
+ reparent_dialog = memnew(ReparentDialog);
add_child(reparent_dialog);
- reparent_dialog->connect("reparent",this,"_node_reparent");
+ reparent_dialog->connect("reparent", this, "_node_reparent");
- accept = memnew( AcceptDialog );
+ accept = memnew(AcceptDialog);
add_child(accept);
- file = memnew( EditorFileDialog );
+ file = memnew(EditorFileDialog);
add_child(file);
- file->connect("file_selected",this,"instance");
+ file->connect("file_selected", this, "instance");
set_process_unhandled_key_input(true);
- delete_dialog = memnew( ConfirmationDialog );
+ delete_dialog = memnew(ConfirmationDialog);
add_child(delete_dialog);
- delete_dialog->connect("confirmed",this,"_delete_confirm");
+ delete_dialog->connect("confirmed", this, "_delete_confirm");
- import_subscene_dialog = memnew( EditorSubScene );
+ import_subscene_dialog = memnew(EditorSubScene);
add_child(import_subscene_dialog);
- import_subscene_dialog->connect("subscene_selected",this,"_import_subscene");
+ import_subscene_dialog->connect("subscene_selected", this, "_import_subscene");
- new_scene_from_dialog = memnew( EditorFileDialog );
+ new_scene_from_dialog = memnew(EditorFileDialog);
new_scene_from_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
add_child(new_scene_from_dialog);
- new_scene_from_dialog->connect("file_selected",this,"_new_scene_from");
-
+ new_scene_from_dialog->connect("file_selected", this, "_new_scene_from");
- menu = memnew( PopupMenu );
+ menu = memnew(PopupMenu);
add_child(menu);
- menu->connect("id_pressed",this,"_tool_selected");
- first_enter=true;
- restore_script_editor_on_drag=false;
+ menu->connect("id_pressed", this, "_tool_selected");
+ first_enter = true;
+ restore_script_editor_on_drag = false;
- vbc->add_constant_override("separation",4);
+ vbc->add_constant_override("separation", 4);
set_process_input(true);
}
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index 2ee7ba3d06..b43a6ea9b1 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -29,27 +29,27 @@
#ifndef SCENE_TREE_DOCK_H
#define SCENE_TREE_DOCK_H
-#include "scene/gui/control.h"
-#include "scene/gui/tree.h"
-#include "scene/gui/label.h"
-#include "scene/gui/button.h"
-#include "scene/gui/tool_button.h"
-#include "scene/gui/box_container.h"
-#include "scene/gui/popup_menu.h"
-#include "scene_tree_editor.h"
+#include "connections_dialog.h"
#include "create_dialog.h"
#include "editor_data.h"
+#include "editor_sub_scene.h"
#include "groups_editor.h"
-#include "connections_dialog.h"
-#include "script_create_dialog.h"
#include "reparent_dialog.h"
#include "scene/animation/animation_player.h"
-#include "editor_sub_scene.h"
+#include "scene/gui/box_container.h"
+#include "scene/gui/button.h"
+#include "scene/gui/control.h"
+#include "scene/gui/label.h"
+#include "scene/gui/popup_menu.h"
+#include "scene/gui/tool_button.h"
+#include "scene/gui/tree.h"
+#include "scene_tree_editor.h"
+#include "script_create_dialog.h"
class EditorNode;
class SceneTreeDock : public VBoxContainer {
- GDCLASS( SceneTreeDock, VBoxContainer );
+ GDCLASS(SceneTreeDock, VBoxContainer);
enum Tool {
@@ -72,7 +72,6 @@ class SceneTreeDock : public VBoxContainer {
TOOL_BUTTON_MAX
};
-
bool restore_script_editor_on_drag;
int current_option;
@@ -105,7 +104,7 @@ class SceneTreeDock : public VBoxContainer {
LineEdit *filter;
TextureRect *filter_icon;
- PopupMenu * menu;
+ PopupMenu *menu;
bool first_enter;
@@ -114,15 +113,15 @@ class SceneTreeDock : public VBoxContainer {
Node *edited_scene;
EditorNode *editor;
- Node *_duplicate(Node *p_node, Map<Node*,Node*> &duplimap);
+ Node *_duplicate(Node *p_node, Map<Node *, Node *> &duplimap);
void _node_reparent(NodePath p_path, bool p_keep_global_xform);
- void _do_reparent(Node* p_new_parent, int p_position_in_parent, Vector<Node*> p_nodes, bool p_keep_global_xform);
+ void _do_reparent(Node *p_new_parent, int p_position_in_parent, Vector<Node *> p_nodes, bool p_keep_global_xform);
- void _set_owners(Node *p_owner, const Array& p_nodes);
- void _load_request(const String& p_path);
- void _script_open_request(const Ref<Script>& p_script);
+ void _set_owners(Node *p_owner, const Array &p_nodes);
+ void _load_request(const String &p_path);
+ void _script_open_request(const Ref<Script> &p_script);
- bool _cyclical_dependency_exists(const String& p_target_scene_path, Node* p_desired_node);
+ bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
void _node_selected();
void _node_renamed();
@@ -130,8 +129,7 @@ class SceneTreeDock : public VBoxContainer {
void _delete_confirm();
-
- void _node_prerenamed(Node* p_node, const String& p_new_name);
+ void _node_prerenamed(Node *p_node, const String &p_new_name);
void _nodes_drag_begin();
void _input(InputEvent p_event);
@@ -144,45 +142,45 @@ class SceneTreeDock : public VBoxContainer {
bool _validate_no_foreign();
void _selection_changed();
- void _fill_path_renames(Vector<StringName> base_path,Vector<StringName> new_base_path,Node * p_node, List<Pair<NodePath,NodePath> > *p_renames);
+ void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath> > *p_renames);
- void _normalize_drop(Node*& to_node, int &to_pos, int p_type);
+ void _normalize_drop(Node *&to_node, int &to_pos, int p_type);
- void _nodes_dragged(Array p_nodes,NodePath p_to,int p_type);
- void _files_dropped(Vector<String> p_files,NodePath p_to,int p_type);
+ void _nodes_dragged(Array p_nodes, NodePath p_to, int p_type);
+ void _files_dropped(Vector<String> p_files, NodePath p_to, int p_type);
void _script_dropped(String p_file, NodePath p_to);
- void _tree_rmb(const Vector2& p_menu_pos);
+ void _tree_rmb(const Vector2 &p_menu_pos);
- void _filter_changed(const String& p_filter);
+ void _filter_changed(const String &p_filter);
- void _perform_instance_scenes(const Vector<String>& p_files,Node* parent,int p_pos);
- void _replace_with_branch_scene(const String& p_file,Node* base);
+ void _perform_instance_scenes(const Vector<String> &p_files, Node *parent, int p_pos);
+ void _replace_with_branch_scene(const String &p_file, Node *base);
void _file_selected(String p_file);
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
String get_filter();
- void set_filter(const String& p_filter);
+ void set_filter(const String &p_filter);
void _focus_node();
void import_subscene();
- void set_edited_scene(Node* p_scene);
- void instance(const String& p_path);
- void instance_scenes(const Vector<String>& p_files, Node *p_parent=NULL);
- void set_selected(Node *p_node, bool p_emit_selected=false);
- void fill_path_renames(Node* p_node, Node *p_new_parent, List<Pair<NodePath,NodePath> > *p_renames);
- void perform_node_renames(Node* p_base,List<Pair<NodePath,NodePath> > *p_renames, Map<Ref<Animation>, Set<int> > *r_rem_anims=NULL);
+ void set_edited_scene(Node *p_scene);
+ void instance(const String &p_path);
+ void instance_scenes(const Vector<String> &p_files, Node *p_parent = NULL);
+ void set_selected(Node *p_node, bool p_emit_selected = false);
+ void fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath> > *p_renames);
+ void perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath> > *p_renames, Map<Ref<Animation>, Set<int> > *r_rem_anims = NULL);
SceneTreeEditor *get_tree_editor() { return scene_tree; }
EditorData *get_editor_data() { return editor_data; }
- void open_script_dialog(Node* p_for_node);
- SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelection *p_editor_selection,EditorData &p_editor_data);
+ void open_script_dialog(Node *p_for_node);
+ SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSelection *p_editor_selection, EditorData &p_editor_data);
};
#endif // SCENE_TREE_DOCK_H
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index fb21747ebb..3310405ae9 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -28,22 +28,21 @@
/*************************************************************************/
#include "scene_tree_editor.h"
-#include "scene/gui/label.h"
+#include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor_node.h"
-#include "print_string.h"
#include "message_queue.h"
+#include "print_string.h"
+#include "scene/gui/label.h"
#include "scene/main/viewport.h"
-#include "editor/plugins/canvas_item_editor_plugin.h"
#include "scene/resources/packed_scene.h"
Node *SceneTreeEditor::get_scene_node() {
- ERR_FAIL_COND_V(!is_inside_tree(),NULL);
+ ERR_FAIL_COND_V(!is_inside_tree(), NULL);
return get_tree()->get_edited_scene_root();
}
-
void SceneTreeEditor::_subscene_option(int p_idx) {
Object *obj = ObjectDB::get_instance(instance_node);
@@ -53,7 +52,7 @@ void SceneTreeEditor::_subscene_option(int p_idx) {
if (!node)
return;
- switch(p_idx) {
+ switch (p_idx) {
case SCENE_MENU_EDITABLE_CHILDREN: {
@@ -61,11 +60,11 @@ void SceneTreeEditor::_subscene_option(int p_idx) {
editable = !editable;
//node->set_instance_children_editable(editable);
- EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node,editable);
- instance_menu->set_item_checked(0,editable);
+ EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, editable);
+ instance_menu->set_item_checked(0, editable);
if (editable) {
node->set_scene_instance_load_placeholder(false);
- instance_menu->set_item_checked(1,false);
+ instance_menu->set_item_checked(1, false);
}
_update_tree();
@@ -78,48 +77,46 @@ void SceneTreeEditor::_subscene_option(int p_idx) {
//node->set_instance_children_editable(editable);
if (placeholder) {
- EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node,false);
+ EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, false);
}
node->set_scene_instance_load_placeholder(placeholder);
- instance_menu->set_item_checked(0,false);
- instance_menu->set_item_checked(1,placeholder);
+ instance_menu->set_item_checked(0, false);
+ instance_menu->set_item_checked(1, placeholder);
_update_tree();
} break;
case SCENE_MENU_OPEN: {
- emit_signal("open",node->get_filename());
+ emit_signal("open", node->get_filename());
} break;
case SCENE_MENU_CLEAR_INHERITANCE: {
clear_inherit_confirm->popup_centered_minsize();
} break;
case SCENE_MENU_CLEAR_INSTANCING: {
- Node*root=EditorNode::get_singleton()->get_edited_scene();
+ Node *root = EditorNode::get_singleton()->get_edited_scene();
if (!root)
break;
-
- ERR_FAIL_COND(node->get_filename()==String());
+ ERR_FAIL_COND(node->get_filename() == String());
undo_redo->create_action("Discard Instancing");
- undo_redo->add_do_method(node,"set_filename","");
- undo_redo->add_undo_method(node,"set_filename",node->get_filename());
+ undo_redo->add_do_method(node, "set_filename", "");
+ undo_redo->add_undo_method(node, "set_filename", node->get_filename());
- _node_replace_owner(node,node,root);
+ _node_replace_owner(node, node, root);
- undo_redo->add_do_method(this,"update_tree");
- undo_redo->add_undo_method(this,"update_tree");
+ undo_redo->add_do_method(this, "update_tree");
+ undo_redo->add_undo_method(this, "update_tree");
undo_redo->commit_action();
-
} break;
case SCENE_MENU_OPEN_INHERITED: {
if (node && node->get_scene_inherited_state().is_valid()) {
- emit_signal("open",node->get_scene_inherited_state()->get_path());
+ emit_signal("open", node->get_scene_inherited_state()->get_path());
}
} break;
case SCENE_MENU_CLEAR_INHERITANCE_CONFIRM: {
@@ -130,100 +127,94 @@ void SceneTreeEditor::_subscene_option(int p_idx) {
}
} break;
-
-
}
-
}
+void SceneTreeEditor::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root) {
-void SceneTreeEditor::_node_replace_owner(Node* p_base,Node* p_node,Node* p_root) {
+ if (p_base != p_node) {
- if (p_base!=p_node) {
+ if (p_node->get_owner() == p_base) {
- if (p_node->get_owner()==p_base) {
-
- undo_redo->add_do_method(p_node,"set_owner",p_root);
- undo_redo->add_undo_method(p_node,"set_owner",p_base);
+ undo_redo->add_do_method(p_node, "set_owner", p_root);
+ undo_redo->add_undo_method(p_node, "set_owner", p_base);
}
}
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- _node_replace_owner(p_base,p_node->get_child(i),p_root);
+ _node_replace_owner(p_base, p_node->get_child(i), p_root);
}
}
+void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) {
-void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) {
-
- TreeItem *item=p_item->cast_to<TreeItem>();
+ TreeItem *item = p_item->cast_to<TreeItem>();
ERR_FAIL_COND(!item);
NodePath np = item->get_metadata(0);
- Node *n=get_node(np);
+ Node *n = get_node(np);
ERR_FAIL_COND(!n);
- if (p_id==BUTTON_SUBSCENE) {
+ if (p_id == BUTTON_SUBSCENE) {
//open scene request
- Rect2 item_rect = tree->get_item_rect(item,0);
- item_rect.pos.y-=tree->get_scroll().y;
- item_rect.pos+=tree->get_global_pos();
+ Rect2 item_rect = tree->get_item_rect(item, 0);
+ item_rect.pos.y -= tree->get_scroll().y;
+ item_rect.pos += tree->get_global_pos();
- if (n==get_scene_node()) {
- inheritance_menu->set_pos(item_rect.pos+Vector2(0,item_rect.size.y));
- inheritance_menu->set_size(Vector2(item_rect.size.x,0));
+ if (n == get_scene_node()) {
+ inheritance_menu->set_pos(item_rect.pos + Vector2(0, item_rect.size.y));
+ inheritance_menu->set_size(Vector2(item_rect.size.x, 0));
inheritance_menu->popup();
- instance_node=n->get_instance_ID();
+ instance_node = n->get_instance_ID();
} else {
- instance_menu->set_pos(item_rect.pos+Vector2(0,item_rect.size.y));
- instance_menu->set_size(Vector2(item_rect.size.x,0));
+ instance_menu->set_pos(item_rect.pos + Vector2(0, item_rect.size.y));
+ instance_menu->set_size(Vector2(item_rect.size.x, 0));
if (EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(n))
- instance_menu->set_item_checked(0,true);
+ instance_menu->set_item_checked(0, true);
else
- instance_menu->set_item_checked(0,false);
+ instance_menu->set_item_checked(0, false);
- if (n->get_owner()==get_scene_node()) {
- instance_menu->set_item_checked(1,n->get_scene_instance_load_placeholder());
- instance_menu->set_item_disabled(1,false);
+ if (n->get_owner() == get_scene_node()) {
+ instance_menu->set_item_checked(1, n->get_scene_instance_load_placeholder());
+ instance_menu->set_item_disabled(1, false);
} else {
- instance_menu->set_item_checked(1,false);
- instance_menu->set_item_disabled(1,true);
+ instance_menu->set_item_checked(1, false);
+ instance_menu->set_item_disabled(1, true);
}
instance_menu->popup();
- instance_node=n->get_instance_ID();
+ instance_node = n->get_instance_ID();
}
//emit_signal("open",n->get_filename());
- } else if (p_id==BUTTON_SCRIPT) {
- RefPtr script=n->get_script();
+ } else if (p_id == BUTTON_SCRIPT) {
+ RefPtr script = n->get_script();
if (!script.is_null())
- emit_signal("open_script",script);
-
- } else if (p_id==BUTTON_VISIBILITY) {
+ emit_signal("open_script", script);
+ } else if (p_id == BUTTON_VISIBILITY) {
if (n->is_class("Spatial")) {
bool v = bool(n->call("is_visible"));
undo_redo->create_action(TTR("Toggle Spatial Visible"));
- undo_redo->add_do_method(n,"set_visible",!v);
- undo_redo->add_undo_method(n,"set_visible",v);
+ undo_redo->add_do_method(n, "set_visible", !v);
+ undo_redo->add_undo_method(n, "set_visible", v);
undo_redo->commit_action();
} else if (n->is_class("CanvasItem")) {
bool v = bool(n->call("is_visible"));
undo_redo->create_action(TTR("Toggle CanvasItem Visible"));
- undo_redo->add_do_method(n,v?"hide":"show");
- undo_redo->add_undo_method(n,v?"show":"hide");
+ undo_redo->add_do_method(n, v ? "hide" : "show");
+ undo_redo->add_undo_method(n, v ? "show" : "hide");
undo_redo->commit_action();
}
- } else if (p_id==BUTTON_LOCK) {
+ } else if (p_id == BUTTON_LOCK) {
if (n->is_class("CanvasItem")) {
n->set_meta("_edit_lock_", Variant());
@@ -231,44 +222,44 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id)
emit_signal("node_changed");
}
- } else if (p_id==BUTTON_GROUP) {
+ } else if (p_id == BUTTON_GROUP) {
if (n->is_class("CanvasItem")) {
n->set_meta("_edit_group_", Variant());
_update_tree();
emit_signal("node_changed");
}
- } else if (p_id==BUTTON_WARNING) {
+ } else if (p_id == BUTTON_WARNING) {
String config_err = n->get_configuration_warning();
- if (config_err==String())
+ if (config_err == String())
return;
- config_err=config_err.word_wrap(80);
+ config_err = config_err.word_wrap(80);
warning->set_text(config_err);
warning->popup_centered_minsize();
- } else if (p_id==BUTTON_SIGNALS) {
+ } else if (p_id == BUTTON_SIGNALS) {
editor_selection->clear();
editor_selection->add_node(n);
set_selected(n);
- NodeDock::singleton->get_parent()->call("set_current_tab",NodeDock::singleton->get_index());
+ NodeDock::singleton->get_parent()->call("set_current_tab", NodeDock::singleton->get_index());
NodeDock::singleton->show_connections();
- } else if (p_id==BUTTON_GROUPS) {
+ } else if (p_id == BUTTON_GROUPS) {
editor_selection->clear();
editor_selection->add_node(n);
set_selected(n);
- NodeDock::singleton->get_parent()->call("set_current_tab",NodeDock::singleton->get_index());
+ NodeDock::singleton->get_parent()->call("set_current_tab", NodeDock::singleton->get_index());
NodeDock::singleton->show_groups();
}
}
-bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
+bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
if (!p_node)
return false;
@@ -276,34 +267,34 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
// only owned nodes are editable, since nodes can create their own (manually owned) child nodes,
// which the editor needs not to know about.
- bool part_of_subscene=false;
+ bool part_of_subscene = false;
- if (!display_foreign && p_node->get_owner()!=get_scene_node() && p_node!=get_scene_node()) {
+ if (!display_foreign && p_node->get_owner() != get_scene_node() && p_node != get_scene_node()) {
if ((show_enabled_subscene || can_open_instance) && p_node->get_owner() && (get_scene_node()->is_editable_instance(p_node->get_owner()))) {
- part_of_subscene=true;
+ part_of_subscene = true;
//allow
} else {
return false;
}
} else {
- part_of_subscene = p_node!=get_scene_node() && get_scene_node()->get_scene_inherited_state().is_valid() && get_scene_node()->get_scene_inherited_state()->find_node_by_path(get_scene_node()->get_path_to(p_node))>=0;
+ part_of_subscene = p_node != get_scene_node() && get_scene_node()->get_scene_inherited_state().is_valid() && get_scene_node()->get_scene_inherited_state()->find_node_by_path(get_scene_node()->get_path_to(p_node)) >= 0;
}
TreeItem *item = tree->create_item(p_parent);
- item->set_text(0, p_node->get_name() );
+ item->set_text(0, p_node->get_name());
if (can_rename && !part_of_subscene /*(p_node->get_owner() == get_scene_node() || p_node==get_scene_node())*/)
item->set_editable(0, true);
- item->set_selectable(0,true);
+ item->set_selectable(0, true);
if (can_rename) {
#ifdef ENABLE_DEPRECATED
if (p_node->has_meta("_editor_collapsed")) {
//remove previous way of storing folding, which did not get along with scene inheritance and instancing
if ((bool)p_node->get_meta("_editor_collapsed"))
p_node->set_display_folded(true);
- p_node->set_meta("_editor_collapsed",Variant());
+ p_node->set_meta("_editor_collapsed", Variant());
}
#endif
bool collapsed = p_node->is_displayed_folded();
@@ -313,111 +304,107 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
Ref<Texture> icon;
if (p_node->has_meta("_editor_icon"))
- icon=p_node->get_meta("_editor_icon");
+ icon = p_node->get_meta("_editor_icon");
else
- icon=get_icon( (has_icon(p_node->get_class(),"EditorIcons")?p_node->get_class():String("Object")),"EditorIcons");
- item->set_icon(0, icon );
- item->set_metadata( 0,p_node->get_path() );
+ icon = get_icon((has_icon(p_node->get_class(), "EditorIcons") ? p_node->get_class() : String("Object")), "EditorIcons");
+ item->set_icon(0, icon);
+ item->set_metadata(0, p_node->get_path());
if (part_of_subscene) {
//item->set_selectable(0,marked_selectable);
- item->set_custom_color(0,Color(0.8,0.4,0.20));
+ item->set_custom_color(0, Color(0.8, 0.4, 0.20));
} else if (marked.has(p_node)) {
- item->set_selectable(0,marked_selectable);
- item->set_custom_color(0,Color(0.8,0.1,0.10));
+ item->set_selectable(0, marked_selectable);
+ item->set_custom_color(0, Color(0.8, 0.1, 0.10));
} else if (!marked_selectable && !marked_children_selectable) {
- Node *node=p_node;
- while(node) {
+ Node *node = p_node;
+ while (node) {
if (marked.has(node)) {
- item->set_selectable(0,false);
- item->set_custom_color(0,Color(0.8,0.1,0.10));
+ item->set_selectable(0, false);
+ item->set_custom_color(0, Color(0.8, 0.1, 0.10));
break;
}
- node=node->get_parent();
+ node = node->get_parent();
}
}
-
-
if (can_rename) { //should be can edit..
String warning = p_node->get_configuration_warning();
- if (warning!=String()) {
- item->add_button(0,get_icon("NodeWarning","EditorIcons"),BUTTON_WARNING);
+ if (warning != String()) {
+ item->add_button(0, get_icon("NodeWarning", "EditorIcons"), BUTTON_WARNING);
}
bool has_connections = p_node->has_persistent_signal_connections();
bool has_groups = p_node->has_persistent_groups();
if (has_connections && has_groups) {
- item->add_button(0,get_icon("ConnectionAndGroups","EditorIcons"),BUTTON_SIGNALS);
+ item->add_button(0, get_icon("ConnectionAndGroups", "EditorIcons"), BUTTON_SIGNALS);
} else if (has_connections) {
- item->add_button(0,get_icon("Connect","EditorIcons"),BUTTON_SIGNALS);
+ item->add_button(0, get_icon("Connect", "EditorIcons"), BUTTON_SIGNALS);
} else if (has_groups) {
- item->add_button(0,get_icon("Groups","EditorIcons"),BUTTON_GROUPS);
+ item->add_button(0, get_icon("Groups", "EditorIcons"), BUTTON_GROUPS);
}
}
- if (p_node==get_scene_node() && p_node->get_scene_inherited_state().is_valid()) {
- item->add_button(0,get_icon("InstanceOptions","EditorIcons"),BUTTON_SUBSCENE);
- item->set_tooltip(0,TTR("Inherits:")+" "+p_node->get_scene_inherited_state()->get_path()+"\n"+TTR("Type:")+" "+p_node->get_class());
- } else if (p_node!=get_scene_node() && p_node->get_filename()!="" && can_open_instance) {
+ if (p_node == get_scene_node() && p_node->get_scene_inherited_state().is_valid()) {
+ item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE);
+ item->set_tooltip(0, TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class());
+ } else if (p_node != get_scene_node() && p_node->get_filename() != "" && can_open_instance) {
- item->add_button(0,get_icon("InstanceOptions","EditorIcons"),BUTTON_SUBSCENE);
- item->set_tooltip(0,TTR("Instance:")+" "+p_node->get_filename()+"\n"+TTR("Type:")+" "+p_node->get_class());
+ item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE);
+ item->set_tooltip(0, TTR("Instance:") + " " + p_node->get_filename() + "\n" + TTR("Type:") + " " + p_node->get_class());
} else {
- item->set_tooltip(0,String(p_node->get_name())+"\n"+TTR("Type:")+" "+p_node->get_class());
+ item->set_tooltip(0, String(p_node->get_name()) + "\n" + TTR("Type:") + " " + p_node->get_class());
}
if (can_open_instance) {
- if (!p_node->is_connected("script_changed",this,"_node_script_changed"))
- p_node->connect("script_changed",this,"_node_script_changed",varray(p_node));
-
+ if (!p_node->is_connected("script_changed", this, "_node_script_changed"))
+ p_node->connect("script_changed", this, "_node_script_changed", varray(p_node));
if (!p_node->get_script().is_null()) {
- item->add_button(0,get_icon("Script","EditorIcons"),BUTTON_SCRIPT);
+ item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT);
}
if (p_node->is_class("CanvasItem")) {
- bool is_locked = p_node->has_meta("_edit_lock_");//_edit_group_
+ bool is_locked = p_node->has_meta("_edit_lock_"); //_edit_group_
if (is_locked)
- item->add_button(0,get_icon("Lock", "EditorIcons"), BUTTON_LOCK);
+ item->add_button(0, get_icon("Lock", "EditorIcons"), BUTTON_LOCK);
bool is_grouped = p_node->has_meta("_edit_group_");
if (is_grouped)
- item->add_button(0,get_icon("Group", "EditorIcons"), BUTTON_GROUP);
+ item->add_button(0, get_icon("Group", "EditorIcons"), BUTTON_GROUP);
bool v = p_node->call("is_visible");
if (v)
- item->add_button(0,get_icon("Visible","EditorIcons"),BUTTON_VISIBILITY);
+ item->add_button(0, get_icon("Visible", "EditorIcons"), BUTTON_VISIBILITY);
else
- item->add_button(0,get_icon("Hidden","EditorIcons"),BUTTON_VISIBILITY);
+ item->add_button(0, get_icon("Hidden", "EditorIcons"), BUTTON_VISIBILITY);
- if (!p_node->is_connected("visibility_changed",this,"_node_visibility_changed"))
- p_node->connect("visibility_changed",this,"_node_visibility_changed",varray(p_node));
+ if (!p_node->is_connected("visibility_changed", this, "_node_visibility_changed"))
+ p_node->connect("visibility_changed", this, "_node_visibility_changed", varray(p_node));
_update_visibility_color(p_node, item);
} else if (p_node->is_class("Spatial")) {
bool v = p_node->call("is_visible");
if (v)
- item->add_button(0,get_icon("Visible","EditorIcons"),BUTTON_VISIBILITY);
+ item->add_button(0, get_icon("Visible", "EditorIcons"), BUTTON_VISIBILITY);
else
- item->add_button(0,get_icon("Hidden","EditorIcons"),BUTTON_VISIBILITY);
+ item->add_button(0, get_icon("Hidden", "EditorIcons"), BUTTON_VISIBILITY);
- if (!p_node->is_connected("visibility_changed",this,"_node_visibility_changed"))
- p_node->connect("visibility_changed",this,"_node_visibility_changed",varray(p_node));
+ if (!p_node->is_connected("visibility_changed", this, "_node_visibility_changed"))
+ p_node->connect("visibility_changed", this, "_node_visibility_changed", varray(p_node));
_update_visibility_color(p_node, item);
}
-
}
if (editor_selection) {
@@ -427,20 +414,19 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
}
}
- if (selected==p_node) {
+ if (selected == p_node) {
if (!editor_selection)
item->select(0);
item->set_as_cursor(0);
}
- bool keep= (filter.is_subsequence_ofi(String(p_node->get_name())));
+ bool keep = (filter.is_subsequence_ofi(String(p_node->get_name())));
- for (int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- bool child_keep = _add_nodes(p_node->get_child(i),item);
+ bool child_keep = _add_nodes(p_node->get_child(i), item);
keep = keep || child_keep;
-
}
if (!keep) {
@@ -449,26 +435,23 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
} else {
return true;
}
-
}
-
void SceneTreeEditor::_node_visibility_changed(Node *p_node) {
-
- if (p_node!=get_scene_node() && !p_node->get_owner()) {
+ if (p_node != get_scene_node() && !p_node->get_owner()) {
return;
}
- TreeItem* item=p_node?_find(tree->get_root(),p_node->get_path()):NULL;
+ TreeItem *item = p_node ? _find(tree->get_root(), p_node->get_path()) : NULL;
if (!item) {
return;
}
- int idx=item->get_button_by_id(0,BUTTON_VISIBILITY);
- ERR_FAIL_COND(idx==-1);
+ int idx = item->get_button_by_id(0, BUTTON_VISIBILITY);
+ ERR_FAIL_COND(idx == -1);
- bool visible=false;
+ bool visible = false;
if (p_node->is_class("CanvasItem")) {
visible = p_node->call("is_visible");
@@ -478,22 +461,22 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) {
}
if (visible)
- item->set_button(0,idx,get_icon("Visible","EditorIcons"));
+ item->set_button(0, idx, get_icon("Visible", "EditorIcons"));
else
- item->set_button(0,idx,get_icon("Hidden","EditorIcons"));
+ item->set_button(0, idx, get_icon("Hidden", "EditorIcons"));
_update_visibility_color(p_node, item);
}
void SceneTreeEditor::_update_visibility_color(Node *p_node, TreeItem *p_item) {
if (p_node->is_class("CanvasItem") || p_node->is_class("Spatial")) {
- Color color(1,1,1,1);
+ Color color(1, 1, 1, 1);
bool visible_on_screen = p_node->call("is_visible");
if (!visible_on_screen) {
- color = Color(0.6,0.6,0.6,1);
+ color = Color(0.6, 0.6, 0.6, 1);
}
- int idx=p_item->get_button_by_id(0,BUTTON_VISIBILITY);
- p_item->set_button_color(0,idx,color);
+ int idx = p_item->get_button_by_id(0, BUTTON_VISIBILITY);
+ p_item->set_button_color(0, idx, color);
}
}
@@ -515,7 +498,6 @@ void SceneTreeEditor::_node_script_changed(Node *p_node) {
item->add_button(0,get_icon("Script","EditorIcons"),2);
}*/
-
}
void SceneTreeEditor::_node_removed(Node *p_node) {
@@ -523,75 +505,69 @@ void SceneTreeEditor::_node_removed(Node *p_node) {
if (EditorNode::get_singleton()->is_exiting())
return; //speed up exit
- if (p_node->is_connected("script_changed",this,"_node_script_changed"))
- p_node->disconnect("script_changed",this,"_node_script_changed");
+ if (p_node->is_connected("script_changed", this, "_node_script_changed"))
+ p_node->disconnect("script_changed", this, "_node_script_changed");
if (p_node->is_class("Spatial") || p_node->is_class("CanvasItem")) {
- if (p_node->is_connected("visibility_changed",this,"_node_visibility_changed"))
- p_node->disconnect("visibility_changed",this,"_node_visibility_changed");
+ if (p_node->is_connected("visibility_changed", this, "_node_visibility_changed"))
+ p_node->disconnect("visibility_changed", this, "_node_visibility_changed");
}
- if (p_node==selected) {
- selected=NULL;
+ if (p_node == selected) {
+ selected = NULL;
emit_signal("node_selected");
}
-
-
}
void SceneTreeEditor::_update_tree() {
-
if (!is_inside_tree()) {
- tree_dirty=false;
+ tree_dirty = false;
return;
}
- updating_tree=true;
+ updating_tree = true;
tree->clear();
if (get_scene_node()) {
- _add_nodes( get_scene_node(), NULL );
+ _add_nodes(get_scene_node(), NULL);
last_hash = hash_djb2_one_64(0);
- _compute_hash(get_scene_node(),last_hash);
-
+ _compute_hash(get_scene_node(), last_hash);
}
- updating_tree=false;
-
- tree_dirty=false;
+ updating_tree = false;
+ tree_dirty = false;
}
-void SceneTreeEditor::_compute_hash(Node *p_node,uint64_t &hash) {
+void SceneTreeEditor::_compute_hash(Node *p_node, uint64_t &hash) {
- hash=hash_djb2_one_64(p_node->get_instance_ID(),hash);
+ hash = hash_djb2_one_64(p_node->get_instance_ID(), hash);
if (p_node->get_parent())
- hash=hash_djb2_one_64(p_node->get_parent()->get_instance_ID(),hash); //so a reparent still produces a different hash
-
+ hash = hash_djb2_one_64(p_node->get_parent()->get_instance_ID(), hash); //so a reparent still produces a different hash
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- _compute_hash(p_node->get_child(i),hash);
+ _compute_hash(p_node->get_child(i), hash);
}
}
void SceneTreeEditor::_test_update_tree() {
- pending_test_update=false;
+ pending_test_update = false;
if (!is_inside_tree())
return;
- if(tree_dirty)
+ if (tree_dirty)
return; // don't even bother
uint64_t hash = hash_djb2_one_64(0);
if (get_scene_node())
- _compute_hash(get_scene_node(),hash);
+ _compute_hash(get_scene_node(), hash);
//test hash
- if (hash==last_hash)
+ if (hash == last_hash)
return; // did not change
- MessageQueue::get_singleton()->push_call(this,"_update_tree");
- tree_dirty=true;
+ MessageQueue::get_singleton()->push_call(this, "_update_tree");
+ tree_dirty = true;
}
void SceneTreeEditor::_tree_changed() {
@@ -603,43 +579,36 @@ void SceneTreeEditor::_tree_changed() {
if (tree_dirty)
return;
- MessageQueue::get_singleton()->push_call(this,"_test_update_tree");
- pending_test_update=true;
-
+ MessageQueue::get_singleton()->push_call(this, "_test_update_tree");
+ pending_test_update = true;
}
void SceneTreeEditor::_selected_changed() {
-
TreeItem *s = tree->get_selected();
ERR_FAIL_COND(!s);
NodePath np = s->get_metadata(0);
- Node *n=get_node(np);
+ Node *n = get_node(np);
-
- if (n==selected)
+ if (n == selected)
return;
-
selected = get_node(np);
blocked++;
emit_signal("node_selected");
blocked--;
-
-
}
-
-void SceneTreeEditor::_cell_multi_selected(Object *p_object,int p_cell,bool p_selected) {
+void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_selected) {
TreeItem *item = p_object->cast_to<TreeItem>();
ERR_FAIL_COND(!item);
NodePath np = item->get_metadata(0);
- Node *n=get_node(np);
+ Node *n = get_node(np);
if (!n)
return;
@@ -652,187 +621,174 @@ void SceneTreeEditor::_cell_multi_selected(Object *p_object,int p_cell,bool p_se
} else {
editor_selection->remove_node(n);
-
}
-
}
void SceneTreeEditor::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
-
- get_tree()->connect("tree_changed",this,"_tree_changed");
- get_tree()->connect("node_removed",this,"_node_removed");
- get_tree()->connect("node_configuration_warning_changed",this,"_warning_changed");
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- instance_menu->set_item_icon(5,get_icon("Load","EditorIcons"));
- tree->connect("item_collapsed",this,"_cell_collapsed");
- inheritance_menu->set_item_icon(2,get_icon("Load","EditorIcons"));
- clear_inherit_confirm->connect("confirmed",this,"_subscene_option",varray(SCENE_MENU_CLEAR_INHERITANCE_CONFIRM));
+ get_tree()->connect("tree_changed", this, "_tree_changed");
+ get_tree()->connect("node_removed", this, "_node_removed");
+ get_tree()->connect("node_configuration_warning_changed", this, "_warning_changed");
- EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");
+ instance_menu->set_item_icon(5, get_icon("Load", "EditorIcons"));
+ tree->connect("item_collapsed", this, "_cell_collapsed");
+ inheritance_menu->set_item_icon(2, get_icon("Load", "EditorIcons"));
+ clear_inherit_confirm->connect("confirmed", this, "_subscene_option", varray(SCENE_MENU_CLEAR_INHERITANCE_CONFIRM));
+ EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
//get_scene()->connect("tree_changed",this,"_tree_changed",Vector<Variant>(),CONNECT_DEFERRED);
//get_scene()->connect("node_removed",this,"_node_removed",Vector<Variant>(),CONNECT_DEFERRED);
_update_tree();
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
-
- get_tree()->disconnect("tree_changed",this,"_tree_changed");
- get_tree()->disconnect("node_removed",this,"_node_removed");
- tree->disconnect("item_collapsed",this,"_cell_collapsed");
- clear_inherit_confirm->disconnect("confirmed",this,"_subscene_option");
- get_tree()->disconnect("node_configuration_warning_changed",this,"_warning_changed");
- EditorSettings::get_singleton()->disconnect("settings_changed",this,"_editor_settings_changed");
+ if (p_what == NOTIFICATION_EXIT_TREE) {
+
+ get_tree()->disconnect("tree_changed", this, "_tree_changed");
+ get_tree()->disconnect("node_removed", this, "_node_removed");
+ tree->disconnect("item_collapsed", this, "_cell_collapsed");
+ clear_inherit_confirm->disconnect("confirmed", this, "_subscene_option");
+ get_tree()->disconnect("node_configuration_warning_changed", this, "_warning_changed");
+ EditorSettings::get_singleton()->disconnect("settings_changed", this, "_editor_settings_changed");
}
-
}
-
-TreeItem* SceneTreeEditor::_find(TreeItem *p_node,const NodePath& p_path) {
+TreeItem *SceneTreeEditor::_find(TreeItem *p_node, const NodePath &p_path) {
if (!p_node)
return NULL;
- NodePath np=p_node->get_metadata(0);
- if (np==p_path)
+ NodePath np = p_node->get_metadata(0);
+ if (np == p_path)
return p_node;
- TreeItem *children=p_node->get_children();
- while(children) {
+ TreeItem *children = p_node->get_children();
+ while (children) {
- TreeItem *n=_find(children,p_path);
+ TreeItem *n = _find(children, p_path);
if (n)
return n;
- children=children->get_next();
+ children = children->get_next();
}
return NULL;
}
-void SceneTreeEditor::set_selected(Node *p_node,bool p_emit_selected) {
+void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) {
- ERR_FAIL_COND(blocked>0);
+ ERR_FAIL_COND(blocked > 0);
if (pending_test_update)
_test_update_tree();
if (tree_dirty)
_update_tree();
- if (selected==p_node)
+ if (selected == p_node)
return;
-
- TreeItem* item=p_node?_find(tree->get_root(),p_node->get_path()):NULL;
+ TreeItem *item = p_node ? _find(tree->get_root(), p_node->get_path()) : NULL;
if (item) {
// make visible when it's collapsed
- TreeItem* node=item->get_parent();
- while (node && node!=tree->get_root()) {
+ TreeItem *node = item->get_parent();
+ while (node && node != tree->get_root()) {
node->set_collapsed(false);
- node=node->get_parent();
+ node = node->get_parent();
}
item->select(0);
item->set_as_cursor(0);
- selected=p_node;
+ selected = p_node;
tree->ensure_cursor_is_visible();
} else {
if (!p_node)
- selected=NULL;
+ selected = NULL;
_update_tree();
- selected=p_node;
+ selected = p_node;
if (p_emit_selected)
emit_signal("node_selected");
}
-
}
-void SceneTreeEditor::_rename_node(ObjectID p_node,const String& p_name) {
+void SceneTreeEditor::_rename_node(ObjectID p_node, const String &p_name) {
Object *o = ObjectDB::get_instance(p_node);
ERR_FAIL_COND(!o);
Node *n = o->cast_to<Node>();
ERR_FAIL_COND(!n);
- TreeItem* item=_find(tree->get_root(),n->get_path());
+ TreeItem *item = _find(tree->get_root(), n->get_path());
ERR_FAIL_COND(!item);
- n->set_name( p_name );
- item->set_metadata(0,n->get_path());
- item->set_text(0,p_name);
+ n->set_name(p_name);
+ item->set_metadata(0, n->get_path());
+ item->set_text(0, p_name);
emit_signal("node_renamed");
if (!tree_dirty) {
- MessageQueue::get_singleton()->push_call(this,"_update_tree");
- tree_dirty=true;
+ MessageQueue::get_singleton()->push_call(this, "_update_tree");
+ tree_dirty = true;
}
-
-
}
-
void SceneTreeEditor::_renamed() {
- TreeItem *which=tree->get_edited();
+ TreeItem *which = tree->get_edited();
ERR_FAIL_COND(!which);
NodePath np = which->get_metadata(0);
- Node *n=get_node(np);
+ Node *n = get_node(np);
ERR_FAIL_COND(!n);
- String new_name=which->get_text(0);
+ String new_name = which->get_text(0);
if (new_name.find(".") != -1 || new_name.find("/") != -1) {
- error->set_text(TTR("Invalid node name, the following characters are not allowed:")+"\n \".\", \"/\"");
+ error->set_text(TTR("Invalid node name, the following characters are not allowed:") + "\n \".\", \"/\"");
error->popup_centered_minsize();
- new_name=n->get_name();
+ new_name = n->get_name();
}
- if (new_name==n->get_name())
+ if (new_name == n->get_name())
return;
if (!undo_redo) {
- n->set_name( new_name );
- which->set_metadata(0,n->get_path());
+ n->set_name(new_name);
+ which->set_metadata(0, n->get_path());
emit_signal("node_renamed");
} else {
undo_redo->create_action(TTR("Rename Node"));
- emit_signal("node_prerename",n,new_name);
- undo_redo->add_do_method(this,"_rename_node",n->get_instance_ID(),new_name);
- undo_redo->add_undo_method(this,"_rename_node",n->get_instance_ID(),n->get_name());
+ emit_signal("node_prerename", n, new_name);
+ undo_redo->add_do_method(this, "_rename_node", n->get_instance_ID(), new_name);
+ undo_redo->add_undo_method(this, "_rename_node", n->get_instance_ID(), n->get_name());
undo_redo->commit_action();
}
}
-
Node *SceneTreeEditor::get_selected() {
return selected;
}
-void SceneTreeEditor::set_marked(const Set<Node*>& p_marked,bool p_selectable,bool p_children_selectable) {
+void SceneTreeEditor::set_marked(const Set<Node *> &p_marked, bool p_selectable, bool p_children_selectable) {
if (tree_dirty)
_update_tree();
- marked=p_marked;
- marked_selectable=p_selectable;
- marked_children_selectable=p_children_selectable;
+ marked = p_marked;
+ marked_selectable = p_selectable;
+ marked_children_selectable = p_children_selectable;
_update_tree();
}
-void SceneTreeEditor::set_marked(Node *p_marked,bool p_selectable,bool p_children_selectable) {
+void SceneTreeEditor::set_marked(Node *p_marked, bool p_selectable, bool p_children_selectable) {
- Set<Node*> s;
+ Set<Node *> s;
if (p_marked)
s.insert(p_marked);
- set_marked(s,p_selectable,p_children_selectable);
-
-
+ set_marked(s, p_selectable, p_children_selectable);
}
-void SceneTreeEditor::set_filter(const String& p_filter) {
+void SceneTreeEditor::set_filter(const String &p_filter) {
- filter=p_filter;
+ filter = p_filter;
_update_tree();
}
@@ -841,10 +797,9 @@ String SceneTreeEditor::get_filter() const {
return filter;
}
-
void SceneTreeEditor::set_display_foreign_nodes(bool p_display) {
- display_foreign=p_display;
+ display_foreign = p_display;
_update_tree();
}
bool SceneTreeEditor::get_display_foreign_nodes() const {
@@ -854,10 +809,10 @@ bool SceneTreeEditor::get_display_foreign_nodes() const {
void SceneTreeEditor::set_editor_selection(EditorSelection *p_selection) {
- editor_selection=p_selection;
+ editor_selection = p_selection;
tree->set_select_mode(Tree::SELECT_MULTI);
tree->set_cursor_can_exit_tree(false);
- editor_selection->connect("selection_changed",this,"_selection_changed");
+ editor_selection->connect("selection_changed", this, "_selection_changed");
}
void SceneTreeEditor::_update_selection(TreeItem *item) {
@@ -869,7 +824,7 @@ void SceneTreeEditor::_update_selection(TreeItem *item) {
if (!has_node(np))
return;
- Node *n=get_node(np);
+ Node *n = get_node(np);
if (!n)
return;
@@ -879,13 +834,12 @@ void SceneTreeEditor::_update_selection(TreeItem *item) {
else
item->deselect(0);
- TreeItem *c=item->get_children();
+ TreeItem *c = item->get_children();
-
- while(c) {
+ while (c) {
_update_selection(c);
- c=c->get_next();
+ c = c->get_next();
}
}
@@ -894,7 +848,7 @@ void SceneTreeEditor::_selection_changed() {
if (!editor_selection)
return;
- TreeItem *root=tree->get_root();
+ TreeItem *root = tree->get_root();
if (!root)
return;
@@ -908,60 +862,59 @@ void SceneTreeEditor::_cell_collapsed(Object *p_obj) {
if (!can_rename)
return;
- TreeItem *ti=p_obj->cast_to<TreeItem>();
+ TreeItem *ti = p_obj->cast_to<TreeItem>();
if (!ti)
return;
- bool collapsed=ti->is_collapsed();
+ bool collapsed = ti->is_collapsed();
NodePath np = ti->get_metadata(0);
- Node *n=get_node(np);
+ Node *n = get_node(np);
ERR_FAIL_COND(!n);
n->set_display_folded(collapsed);
-
}
-Variant SceneTreeEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) {
+Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
if (!can_rename)
return Variant(); //not editable tree
- Vector<Node*> selected;
+ Vector<Node *> selected;
Vector<Ref<Texture> > icons;
- TreeItem *next=tree->get_next_selected(NULL);
+ TreeItem *next = tree->get_next_selected(NULL);
while (next) {
NodePath np = next->get_metadata(0);
- Node *n=get_node(np);
+ Node *n = get_node(np);
if (n) {
selected.push_back(n);
icons.push_back(next->get_icon(0));
}
- next=tree->get_next_selected(next);
+ next = tree->get_next_selected(next);
}
if (selected.empty())
return Variant();
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
Array objs;
int list_max = 10;
float opacity_step = 1.0f / list_max;
float opacity_item = 1.0f;
- for(int i=0;i<selected.size();i++) {
+ for (int i = 0; i < selected.size(); i++) {
- if (i<list_max){
- HBoxContainer *hb = memnew( HBoxContainer );
+ if (i < list_max) {
+ HBoxContainer *hb = memnew(HBoxContainer);
TextureRect *tf = memnew(TextureRect);
tf->set_texture(icons[i]);
hb->add_child(tf);
- Label *label = memnew( Label( selected[i]->get_name() ) );
+ Label *label = memnew(Label(selected[i]->get_name()));
hb->add_child(label);
vb->add_child(hb);
- hb->set_modulate(Color(1,1,1,opacity_item));
+ hb->set_modulate(Color(1, 1, 1, opacity_item));
opacity_item -= opacity_step;
}
NodePath p = selected[i]->get_path();
@@ -970,10 +923,10 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2& p_point,Control* p_from)
set_drag_preview(vb);
Dictionary drag_data;
- drag_data["type"]="nodes";
- drag_data["nodes"]=objs;
+ drag_data["type"] = "nodes";
+ drag_data["nodes"] = objs;
- tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN|Tree::DROP_MODE_ON_ITEM);
+ tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM);
emit_signal("nodes_dragged");
return drag_data;
@@ -983,15 +936,14 @@ bool SceneTreeEditor::_is_script_type(const StringName &p_type) const {
return (script_types->find(p_type));
}
-bool SceneTreeEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const {
+bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
if (!can_rename)
return false; //not editable tree
- if (filter!=String())
+ if (filter != String())
return false; //can't rearrange tree with filter turned on
-
- Dictionary d=p_data;
+ Dictionary d = p_data;
if (!d.has("type"))
return false;
@@ -1000,14 +952,14 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_da
return false;
int section = tree->get_drop_section_at_pos(p_point);
- if (section<-1 || (section==-1 && !item->get_parent()))
+ if (section < -1 || (section == -1 && !item->get_parent()))
return false;
- if (String(d["type"])=="files") {
+ if (String(d["type"]) == "files") {
Vector<String> files = d["files"];
- if (files.size()==0)
+ if (files.size() == 0)
return false; //weird
if (_is_script_type(EditorFileSystem::get_singleton()->get_file_type(files[0]))) {
@@ -1015,112 +967,103 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_da
return true;
}
- for(int i=0;i<files.size();i++) {
+ for (int i = 0; i < files.size(); i++) {
String file = files[i];
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
- if (ftype!="PackedScene")
+ if (ftype != "PackedScene")
return false;
}
- tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN|Tree::DROP_MODE_ON_ITEM); //so it works..
+ tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM); //so it works..
return true;
}
-
- if (String(d["type"])=="nodes") {
+ if (String(d["type"]) == "nodes") {
return true;
}
return false;
}
-void SceneTreeEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) {
+void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
- if (!can_drop_data_fw(p_point,p_data,p_from))
+ if (!can_drop_data_fw(p_point, p_data, p_from))
return;
TreeItem *item = tree->get_item_at_pos(p_point);
if (!item)
return;
int section = tree->get_drop_section_at_pos(p_point);
- if (section<-1)
+ if (section < -1)
return;
NodePath np = item->get_metadata(0);
- Node *n=get_node(np);
+ Node *n = get_node(np);
if (!n)
return;
- Dictionary d=p_data;
+ Dictionary d = p_data;
- if (String(d["type"])=="nodes") {
- Array nodes=d["nodes"];
- emit_signal("nodes_rearranged",nodes,np,section);
+ if (String(d["type"]) == "nodes") {
+ Array nodes = d["nodes"];
+ emit_signal("nodes_rearranged", nodes, np, section);
}
- if (String(d["type"])=="files") {
+ if (String(d["type"]) == "files") {
Vector<String> files = d["files"];
-
String ftype = EditorFileSystem::get_singleton()->get_file_type(files[0]);
if (_is_script_type(ftype)) {
- emit_signal("script_dropped", files[0],np);
+ emit_signal("script_dropped", files[0], np);
} else {
- emit_signal("files_dropped",files,np,section);
+ emit_signal("files_dropped", files, np, section);
}
}
-
}
-void SceneTreeEditor::_rmb_select(const Vector2& p_pos) {
+void SceneTreeEditor::_rmb_select(const Vector2 &p_pos) {
- emit_signal("rmb_pressed",tree->get_global_transform().xform(p_pos));
+ emit_signal("rmb_pressed", tree->get_global_transform().xform(p_pos));
}
-
-void SceneTreeEditor::_warning_changed(Node* p_for_node) {
+void SceneTreeEditor::_warning_changed(Node *p_for_node) {
//should use a timer
update_timer->start();
//print_line("WARNING CHANGED "+String(p_for_node->get_name()));
-
}
-
void SceneTreeEditor::_editor_settings_changed() {
bool enable_rl = EditorSettings::get_singleton()->get("docks/scene_tree/draw_relationship_lines");
Color rl_color = EditorSettings::get_singleton()->get("docks/scene_tree/relationship_line_color");
if (enable_rl) {
- tree->add_constant_override("draw_relationship_lines",1);
+ tree->add_constant_override("draw_relationship_lines", 1);
tree->add_color_override("relationship_line_color", rl_color);
- }
- else
- tree->add_constant_override("draw_relationship_lines",0);
-
+ } else
+ tree->add_constant_override("draw_relationship_lines", 0);
}
-
void SceneTreeEditor::_bind_methods() {
- ClassDB::bind_method("_tree_changed",&SceneTreeEditor::_tree_changed);
- ClassDB::bind_method("_update_tree",&SceneTreeEditor::_update_tree);
- ClassDB::bind_method("_node_removed",&SceneTreeEditor::_node_removed);
- ClassDB::bind_method("_selected_changed",&SceneTreeEditor::_selected_changed);
- ClassDB::bind_method("_renamed",&SceneTreeEditor::_renamed);
- ClassDB::bind_method("_rename_node",&SceneTreeEditor::_rename_node);
- ClassDB::bind_method("_test_update_tree",&SceneTreeEditor::_test_update_tree);
- ClassDB::bind_method("_cell_multi_selected",&SceneTreeEditor::_cell_multi_selected);
- ClassDB::bind_method("_selection_changed",&SceneTreeEditor::_selection_changed);
- ClassDB::bind_method("_cell_button_pressed",&SceneTreeEditor::_cell_button_pressed);
- ClassDB::bind_method("_cell_collapsed",&SceneTreeEditor::_cell_collapsed);
- ClassDB::bind_method("_subscene_option",&SceneTreeEditor::_subscene_option);
- ClassDB::bind_method("_rmb_select",&SceneTreeEditor::_rmb_select);
- ClassDB::bind_method("_warning_changed",&SceneTreeEditor::_warning_changed);
-
- ClassDB::bind_method("_node_script_changed",&SceneTreeEditor::_node_script_changed);
- ClassDB::bind_method("_node_visibility_changed",&SceneTreeEditor::_node_visibility_changed);
+ ClassDB::bind_method("_tree_changed", &SceneTreeEditor::_tree_changed);
+ ClassDB::bind_method("_update_tree", &SceneTreeEditor::_update_tree);
+ ClassDB::bind_method("_node_removed", &SceneTreeEditor::_node_removed);
+ ClassDB::bind_method("_selected_changed", &SceneTreeEditor::_selected_changed);
+ ClassDB::bind_method("_renamed", &SceneTreeEditor::_renamed);
+ ClassDB::bind_method("_rename_node", &SceneTreeEditor::_rename_node);
+ ClassDB::bind_method("_test_update_tree", &SceneTreeEditor::_test_update_tree);
+ ClassDB::bind_method("_cell_multi_selected", &SceneTreeEditor::_cell_multi_selected);
+ ClassDB::bind_method("_selection_changed", &SceneTreeEditor::_selection_changed);
+ ClassDB::bind_method("_cell_button_pressed", &SceneTreeEditor::_cell_button_pressed);
+ ClassDB::bind_method("_cell_collapsed", &SceneTreeEditor::_cell_collapsed);
+ ClassDB::bind_method("_subscene_option", &SceneTreeEditor::_subscene_option);
+ ClassDB::bind_method("_rmb_select", &SceneTreeEditor::_rmb_select);
+ ClassDB::bind_method("_warning_changed", &SceneTreeEditor::_warning_changed);
+
+ ClassDB::bind_method("_node_script_changed", &SceneTreeEditor::_node_script_changed);
+ ClassDB::bind_method("_node_visibility_changed", &SceneTreeEditor::_node_visibility_changed);
ClassDB::bind_method("_editor_settings_changed", &SceneTreeEditor::_editor_settings_changed);
@@ -1130,187 +1073,166 @@ void SceneTreeEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("update_tree"), &SceneTreeEditor::update_tree);
- ADD_SIGNAL( MethodInfo("node_selected") );
- ADD_SIGNAL( MethodInfo("node_renamed") );
- ADD_SIGNAL( MethodInfo("node_prerename") );
- ADD_SIGNAL( MethodInfo("node_changed") );
- ADD_SIGNAL( MethodInfo("nodes_dragged") );
- ADD_SIGNAL( MethodInfo("nodes_rearranged",PropertyInfo(Variant::ARRAY,"paths"),PropertyInfo(Variant::NODE_PATH,"to_path"),PropertyInfo(Variant::INT,"type") ) );
- ADD_SIGNAL( MethodInfo("files_dropped",PropertyInfo(Variant::POOL_STRING_ARRAY,"files"),PropertyInfo(Variant::NODE_PATH,"to_path"),PropertyInfo(Variant::INT,"type") ) );
- ADD_SIGNAL( MethodInfo("script_dropped",PropertyInfo(Variant::STRING,"file"),PropertyInfo(Variant::NODE_PATH,"to_path")));
- ADD_SIGNAL( MethodInfo("rmb_pressed",PropertyInfo(Variant::VECTOR2,"pos")) ) ;
-
- ADD_SIGNAL( MethodInfo("open") );
- ADD_SIGNAL( MethodInfo("open_script") );
-
-
+ ADD_SIGNAL(MethodInfo("node_selected"));
+ ADD_SIGNAL(MethodInfo("node_renamed"));
+ ADD_SIGNAL(MethodInfo("node_prerename"));
+ ADD_SIGNAL(MethodInfo("node_changed"));
+ ADD_SIGNAL(MethodInfo("nodes_dragged"));
+ ADD_SIGNAL(MethodInfo("nodes_rearranged", PropertyInfo(Variant::ARRAY, "paths"), PropertyInfo(Variant::NODE_PATH, "to_path"), PropertyInfo(Variant::INT, "type")));
+ ADD_SIGNAL(MethodInfo("files_dropped", PropertyInfo(Variant::POOL_STRING_ARRAY, "files"), PropertyInfo(Variant::NODE_PATH, "to_path"), PropertyInfo(Variant::INT, "type")));
+ ADD_SIGNAL(MethodInfo("script_dropped", PropertyInfo(Variant::STRING, "file"), PropertyInfo(Variant::NODE_PATH, "to_path")));
+ ADD_SIGNAL(MethodInfo("rmb_pressed", PropertyInfo(Variant::VECTOR2, "pos")));
+
+ ADD_SIGNAL(MethodInfo("open"));
+ ADD_SIGNAL(MethodInfo("open_script"));
}
+SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_open_instance) {
-SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open_instance) {
+ undo_redo = NULL;
+ tree_dirty = true;
+ selected = NULL;
-
- undo_redo=NULL;
- tree_dirty=true;
- selected=NULL;
-
- marked_selectable=false;
- marked_children_selectable=false;
- can_rename=p_can_rename;
- can_open_instance=p_can_open_instance;
- display_foreign=false;
- editor_selection=NULL;
+ marked_selectable = false;
+ marked_children_selectable = false;
+ can_rename = p_can_rename;
+ can_open_instance = p_can_open_instance;
+ display_foreign = false;
+ editor_selection = NULL;
if (p_label) {
- Label *label = memnew( Label );
- label->set_pos( Point2(10, 0));
+ Label *label = memnew(Label);
+ label->set_pos(Point2(10, 0));
label->set_text(TTR("Scene Tree (Nodes):"));
add_child(label);
}
- tree = memnew( Tree );
- tree->set_anchor( MARGIN_RIGHT, ANCHOR_END );
- tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
- tree->set_begin( Point2(0,p_label?18:0 ));
- tree->set_end( Point2(0,0 ));
+ tree = memnew(Tree);
+ tree->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ tree->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
+ tree->set_begin(Point2(0, p_label ? 18 : 0));
+ tree->set_end(Point2(0, 0));
- add_child( tree );
+ add_child(tree);
tree->set_drag_forwarding(this);
if (p_can_rename) {
tree->set_allow_rmb_select(true);
- tree->connect("item_rmb_selected",this,"_rmb_select");
- tree->connect("empty_tree_rmb_selected",this,"_rmb_select");
+ tree->connect("item_rmb_selected", this, "_rmb_select");
+ tree->connect("empty_tree_rmb_selected", this, "_rmb_select");
}
- tree->connect("cell_selected", this,"_selected_changed");
- tree->connect("item_edited", this,"_renamed",varray(),CONNECT_DEFERRED);
- tree->connect("multi_selected",this,"_cell_multi_selected");
- tree->connect("button_pressed",this,"_cell_button_pressed");
+ tree->connect("cell_selected", this, "_selected_changed");
+ tree->connect("item_edited", this, "_renamed", varray(), CONNECT_DEFERRED);
+ tree->connect("multi_selected", this, "_cell_multi_selected");
+ tree->connect("button_pressed", this, "_cell_button_pressed");
//tree->connect("item_edited", this,"_renamed",Vector<Variant>(),true);
- error = memnew( AcceptDialog );
+ error = memnew(AcceptDialog);
add_child(error);
- warning = memnew( AcceptDialog );
+ warning = memnew(AcceptDialog);
add_child(warning);
warning->set_title("Node Configuration Warning!");
+ show_enabled_subscene = false;
- show_enabled_subscene=false;
+ last_hash = 0;
+ pending_test_update = false;
+ updating_tree = false;
+ blocked = 0;
- last_hash=0;
- pending_test_update=false;
- updating_tree=false;
- blocked=0;
-
- instance_menu = memnew( PopupMenu );
- instance_menu->add_check_item(TTR("Editable Children"),SCENE_MENU_EDITABLE_CHILDREN);
- instance_menu->add_check_item(TTR("Load As Placeholder"),SCENE_MENU_USE_PLACEHOLDER);
+ instance_menu = memnew(PopupMenu);
+ instance_menu->add_check_item(TTR("Editable Children"), SCENE_MENU_EDITABLE_CHILDREN);
+ instance_menu->add_check_item(TTR("Load As Placeholder"), SCENE_MENU_USE_PLACEHOLDER);
instance_menu->add_separator();
- instance_menu->add_item(TTR("Discard Instancing"),SCENE_MENU_CLEAR_INSTANCING);
+ instance_menu->add_item(TTR("Discard Instancing"), SCENE_MENU_CLEAR_INSTANCING);
instance_menu->add_separator();
- instance_menu->add_item(TTR("Open in Editor"),SCENE_MENU_OPEN);
- instance_menu->connect("id_pressed",this,"_subscene_option");
+ instance_menu->add_item(TTR("Open in Editor"), SCENE_MENU_OPEN);
+ instance_menu->connect("id_pressed", this, "_subscene_option");
add_child(instance_menu);
- inheritance_menu = memnew( PopupMenu );
- inheritance_menu->add_item(TTR("Clear Inheritance"),SCENE_MENU_CLEAR_INHERITANCE);
+ inheritance_menu = memnew(PopupMenu);
+ inheritance_menu->add_item(TTR("Clear Inheritance"), SCENE_MENU_CLEAR_INHERITANCE);
inheritance_menu->add_separator();
- inheritance_menu->add_item(TTR("Open in Editor"),SCENE_MENU_OPEN_INHERITED);
- inheritance_menu->connect("id_pressed",this,"_subscene_option");
+ inheritance_menu->add_item(TTR("Open in Editor"), SCENE_MENU_OPEN_INHERITED);
+ inheritance_menu->connect("id_pressed", this, "_subscene_option");
add_child(inheritance_menu);
- clear_inherit_confirm = memnew( ConfirmationDialog );
+ clear_inherit_confirm = memnew(ConfirmationDialog);
clear_inherit_confirm->set_text(TTR("Clear Inheritance? (No Undo!)"));
clear_inherit_confirm->get_ok()->set_text(TTR("Clear!"));
add_child(clear_inherit_confirm);
update_timer = memnew(Timer);
- update_timer->connect("timeout",this,"_update_tree");
+ update_timer->connect("timeout", this, "_update_tree");
update_timer->set_one_shot(true);
update_timer->set_wait_time(0.5);
add_child(update_timer);
script_types = memnew(List<StringName>);
ClassDB::get_inheriters_from_class("Script", script_types);
-
}
-
-
SceneTreeEditor::~SceneTreeEditor() {
memdelete(script_types);
}
-
/******** DIALOG *********/
void SceneTreeDialog::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
- connect("confirmed", this,"_select");
-
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ connect("confirmed", this, "_select");
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
- disconnect("confirmed", this,"_select");
-
+ if (p_what == NOTIFICATION_EXIT_TREE) {
+ disconnect("confirmed", this, "_select");
}
- 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()));
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED && is_visible_in_tree()) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED && is_visible_in_tree()) {
tree->update_tree();
}
-
-
}
void SceneTreeDialog::_cancel() {
hide();
-
-
-
}
void SceneTreeDialog::_select() {
if (tree->get_selected()) {
- emit_signal("selected",tree->get_selected()->get_path());
+ emit_signal("selected", tree->get_selected()->get_path());
hide();
}
}
void SceneTreeDialog::_bind_methods() {
- ClassDB::bind_method("_select",&SceneTreeDialog::_select);
- ClassDB::bind_method("_cancel",&SceneTreeDialog::_cancel);
- ADD_SIGNAL( MethodInfo("selected",PropertyInfo(Variant::NODE_PATH,"path")));
-
+ ClassDB::bind_method("_select", &SceneTreeDialog::_select);
+ ClassDB::bind_method("_cancel", &SceneTreeDialog::_cancel);
+ ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::NODE_PATH, "path")));
}
-
SceneTreeDialog::SceneTreeDialog() {
set_title(TTR("Select a Node"));
- tree = memnew( SceneTreeEditor(false,false) );
+ tree = memnew(SceneTreeEditor(false, false));
add_child(tree);
//set_child_rect(tree);
- tree->get_scene_tree()->connect("item_activated",this,"_select");
-
+ tree->get_scene_tree()->connect("item_activated", this, "_select");
}
-
-SceneTreeDialog::~SceneTreeDialog()
-{
+SceneTreeDialog::~SceneTreeDialog() {
}
diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h
index 5586f02c00..22ef492379 100644
--- a/editor/scene_tree_editor.h
+++ b/editor/scene_tree_editor.h
@@ -29,30 +29,30 @@
#ifndef SCENE_TREE_EDITOR_H
#define SCENE_TREE_EDITOR_H
-#include "scene/gui/tree.h"
+#include "editor_data.h"
+#include "editor_settings.h"
#include "scene/gui/button.h"
#include "scene/gui/dialogs.h"
+#include "scene/gui/tree.h"
#include "undo_redo.h"
-#include "editor_data.h"
-#include "editor_settings.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class SceneTreeEditor : public Control {
- GDCLASS( SceneTreeEditor, Control );
+ GDCLASS(SceneTreeEditor, Control);
EditorSelection *editor_selection;
enum {
- BUTTON_SUBSCENE=0,
- BUTTON_VISIBILITY=1,
- BUTTON_SCRIPT=2,
- BUTTON_LOCK=3,
- BUTTON_GROUP=4,
- BUTTON_WARNING=5,
- BUTTON_SIGNALS=6,
- BUTTON_GROUPS=7,
+ BUTTON_SUBSCENE = 0,
+ BUTTON_VISIBILITY = 1,
+ BUTTON_SCRIPT = 2,
+ BUTTON_LOCK = 3,
+ BUTTON_GROUP = 4,
+ BUTTON_WARNING = 5,
+ BUTTON_SIGNALS = 6,
+ BUTTON_GROUPS = 7,
};
enum {
@@ -79,18 +79,18 @@ class SceneTreeEditor : public Control {
int blocked;
- void _compute_hash(Node *p_node,uint64_t &hash);
+ void _compute_hash(Node *p_node, uint64_t &hash);
- bool _add_nodes(Node *p_node,TreeItem *p_parent);
+ bool _add_nodes(Node *p_node, TreeItem *p_parent);
void _test_update_tree();
void _update_tree();
void _tree_changed();
void _node_removed(Node *p_node);
- TreeItem* _find(TreeItem *p_node,const NodePath& p_path);
+ TreeItem *_find(TreeItem *p_node, const NodePath &p_path);
void _notification(int p_what);
void _selected_changed();
- void _rename_node(ObjectID p_node,const String& p_name);
+ void _rename_node(ObjectID p_node, const String &p_name);
void _cell_collapsed(Object *p_obj);
@@ -104,7 +104,7 @@ class SceneTreeEditor : public Control {
void _renamed();
UndoRedo *undo_redo;
- Set<Node*> marked;
+ Set<Node *> marked;
bool marked_selectable;
bool marked_children_selectable;
bool display_foreign;
@@ -112,67 +112,62 @@ class SceneTreeEditor : public Control {
bool pending_test_update;
static void _bind_methods();
- void _cell_button_pressed(Object *p_item,int p_column,int p_id);
- void _cell_multi_selected(Object *p_object,int p_cel,bool p_selected);
+ void _cell_button_pressed(Object *p_item, int p_column, int p_id);
+ void _cell_multi_selected(Object *p_object, int p_cel, bool p_selected);
void _update_selection(TreeItem *item);
void _node_script_changed(Node *p_node);
void _node_visibility_changed(Node *p_node);
void _update_visibility_color(Node *p_node, TreeItem *p_item);
void _subscene_option(int p_idx);
- void _node_replace_owner(Node* p_base,Node* p_node,Node* p_root);
-
+ void _node_replace_owner(Node *p_base, Node *p_node, Node *p_root);
void _selection_changed();
Node *get_scene_node();
- Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
- bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
- void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
+ Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
+ bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
+ void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
- void _rmb_select(const Vector2& p_pos);
+ void _rmb_select(const Vector2 &p_pos);
- void _warning_changed(Node* p_for_node);
+ void _warning_changed(Node *p_for_node);
void _editor_settings_changed();
- Timer* update_timer;
+ Timer *update_timer;
List<StringName> *script_types;
bool _is_script_type(const StringName &p_type) const;
public:
-
- void set_filter(const String& p_filter);
+ void set_filter(const String &p_filter);
String get_filter() const;
- void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; };
+ void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; };
void set_display_foreign_nodes(bool p_display);
bool get_display_foreign_nodes() const;
- void set_marked(const Set<Node*>& p_marked,bool p_selectable=false,bool p_children_selectable=true);
- void set_marked(Node *p_marked,bool p_selectable=false,bool p_children_selectable=true);
- void set_selected(Node *p_node,bool p_emit_selected=true);
+ void set_marked(const Set<Node *> &p_marked, bool p_selectable = false, bool p_children_selectable = true);
+ void set_marked(Node *p_marked, bool p_selectable = false, bool p_children_selectable = true);
+ void set_selected(Node *p_node, bool p_emit_selected = true);
Node *get_selected();
- void set_can_rename(bool p_can_rename) { can_rename=p_can_rename; }
+ void set_can_rename(bool p_can_rename) { can_rename = p_can_rename; }
void set_editor_selection(EditorSelection *p_selection);
- void set_show_enabled_subscene(bool p_show) { show_enabled_subscene=p_show; }
+ void set_show_enabled_subscene(bool p_show) { show_enabled_subscene = p_show; }
void update_tree() { _update_tree(); }
+ Tree *get_scene_tree() { return tree; }
- Tree* get_scene_tree() { return tree; }
-
- SceneTreeEditor(bool p_label=true,bool p_can_rename=false, bool p_can_open_instance=false);
+ SceneTreeEditor(bool p_label = true, bool p_can_rename = false, bool p_can_open_instance = false);
~SceneTreeEditor();
-
};
-
class SceneTreeDialog : public ConfirmationDialog {
- GDCLASS( SceneTreeDialog, ConfirmationDialog );
+ GDCLASS(SceneTreeDialog, ConfirmationDialog);
SceneTreeEditor *tree;
//Button *select;
@@ -182,18 +177,14 @@ class SceneTreeDialog : public ConfirmationDialog {
void _select();
void _cancel();
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
SceneTreeEditor *get_scene_tree() { return tree; }
SceneTreeDialog();
~SceneTreeDialog();
-
};
-
#endif
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index dfaa1f645c..d1a8aa62e5 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -28,84 +28,81 @@
/*************************************************************************/
#include "script_create_dialog.h"
-#include "script_language.h"
+#include "editor_file_system.h"
#include "global_config.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
-#include "editor_file_system.h"
+#include "script_language.h"
-void ScriptCreateDialog::config(const String& p_base_name,const String&p_base_path) {
+void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_path) {
class_name->set_text("");
parent_name->set_text(p_base_name);
- if (p_base_path!="") {
- initial_bp=p_base_path.get_basename();
- file_path->set_text(initial_bp+"."+ScriptServer::get_language( language_menu->get_selected() )->get_extension());
+ if (p_base_path != "") {
+ initial_bp = p_base_path.get_basename();
+ file_path->set_text(initial_bp + "." + ScriptServer::get_language(language_menu->get_selected())->get_extension());
} else {
- initial_bp="";
+ initial_bp = "";
file_path->set_text("");
}
_class_name_changed("");
_path_changed(file_path->get_text());
}
-bool ScriptCreateDialog::_validate(const String& p_string) {
+bool ScriptCreateDialog::_validate(const String &p_string) {
- if (p_string.length()==0)
+ if (p_string.length() == 0)
return false;
+ for (int i = 0; i < p_string.length(); i++) {
- for(int i=0;i<p_string.length();i++) {
-
- if (i==0) {
- if (p_string[0]>='0' && p_string[0]<='9')
+ if (i == 0) {
+ if (p_string[0] >= '0' && p_string[0] <= '9')
return false; // no start with number plz
}
- bool valid_char = (p_string[i]>='0' && p_string[i]<='9') || (p_string[i]>='a' && p_string[i]<='z') || (p_string[i]>='A' && p_string[i]<='Z') || p_string[i]=='_';
+ bool valid_char = (p_string[i] >= '0' && p_string[i] <= '9') || (p_string[i] >= 'a' && p_string[i] <= 'z') || (p_string[i] >= 'A' && p_string[i] <= 'Z') || p_string[i] == '_';
if (!valid_char)
return false;
-
}
return true;
}
-void ScriptCreateDialog::_class_name_changed(const String& p_name) {
+void ScriptCreateDialog::_class_name_changed(const String &p_name) {
if (!_validate(parent_name->get_text())) {
error_label->set_text(TTR("Invalid parent class name"));
- error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
+ error_label->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8));
} else if (class_name->is_editable()) {
- if (class_name->get_text()=="") {
- error_label->set_text(TTR("Valid chars:")+" a-z A-Z 0-9 _");
- error_label->add_color_override("font_color",Color(1,1,1,0.6));
+ if (class_name->get_text() == "") {
+ error_label->set_text(TTR("Valid chars:") + " a-z A-Z 0-9 _");
+ error_label->add_color_override("font_color", Color(1, 1, 1, 0.6));
} else if (!_validate(class_name->get_text())) {
error_label->set_text(TTR("Invalid class name"));
- error_label->add_color_override("font_color",Color(1,0.2,0.2,0.8));
+ error_label->add_color_override("font_color", Color(1, 0.2, 0.2, 0.8));
} else {
error_label->set_text(TTR("Valid name"));
- error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));
+ error_label->add_color_override("font_color", Color(0, 1.0, 0.8, 0.8));
}
} else {
error_label->set_text(TTR("N/A"));
- error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));
+ error_label->add_color_override("font_color", Color(0, 1.0, 0.8, 0.8));
}
}
void ScriptCreateDialog::ok_pressed() {
- if (create_new){
+ if (create_new) {
_create_new();
} else {
_load_exist();
}
- create_new=true;
+ create_new = true;
_update_controls();
-
}
void ScriptCreateDialog::_create_new() {
@@ -123,14 +120,14 @@ void ScriptCreateDialog::_create_new() {
String cname;
if (class_name->is_editable())
- cname=class_name->get_text();
+ cname = class_name->get_text();
- Ref<Script> scr = ScriptServer::get_language( language_menu->get_selected() )->get_template(cname,parent_name->get_text());
+ Ref<Script> scr = ScriptServer::get_language(language_menu->get_selected())->get_template(cname, parent_name->get_text());
String selected_language = language_menu->get_item_text(language_menu->get_selected());
editor_settings->set_project_metadata("script_setup", "last_selected_language", selected_language);
- if (cname!="")
+ if (cname != "")
scr->set_name(cname);
if (!internal->is_pressed()) {
@@ -141,8 +138,8 @@ void ScriptCreateDialog::_create_new() {
alert->popup_centered_minsize();
return;
}
- Error err = ResourceSaver::save(lpath,scr,ResourceSaver::FLAG_CHANGE_PATH);
- if (err!=OK) {
+ Error err = ResourceSaver::save(lpath, scr, ResourceSaver::FLAG_CHANGE_PATH);
+ if (err != OK) {
alert->set_text(TTR("Could not create script in filesystem."));
alert->popup_centered_minsize();
return;
@@ -150,13 +147,12 @@ void ScriptCreateDialog::_create_new() {
}
hide();
- emit_signal("script_created",scr);
-
+ emit_signal("script_created", scr);
}
void ScriptCreateDialog::_load_exist() {
- String path=file_path->get_text();
+ String path = file_path->get_text();
RES p_script = ResourceLoader::load(path, "Script");
if (p_script.is_null()) {
alert->get_ok()->set_text(TTR("Ugh"));
@@ -166,41 +162,40 @@ void ScriptCreateDialog::_load_exist() {
}
hide();
- emit_signal("script_created",p_script.get_ref_ptr());
-
+ emit_signal("script_created", p_script.get_ref_ptr());
}
void ScriptCreateDialog::_lang_changed(int l) {
- l=language_menu->get_selected();
- if (ScriptServer::get_language( l )->has_named_classes()) {
+ l = language_menu->get_selected();
+ if (ScriptServer::get_language(l)->has_named_classes()) {
class_name->set_editable(true);
} else {
class_name->set_editable(false);
}
- String selected_ext="."+ScriptServer::get_language( l )->get_extension();
- String path=file_path->get_text();
- String extension="";
- if (path.find(".")>=0) {
- extension=path.get_extension();
+ String selected_ext = "." + ScriptServer::get_language(l)->get_extension();
+ String path = file_path->get_text();
+ String extension = "";
+ if (path.find(".") >= 0) {
+ extension = path.get_extension();
}
- if (extension.length()==0) {
+ if (extension.length() == 0) {
// add extension if none
- path+=selected_ext;
+ path += selected_ext;
_path_changed(path);
} else {
// change extension by selected language
List<String> extensions;
// get all possible extensions for script
- for (int l=0;l<language_menu->get_item_count();l++) {
- ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ for (int l = 0; l < language_menu->get_item_count(); l++) {
+ ScriptServer::get_language(l)->get_recognized_extensions(&extensions);
}
- for(List<String>::Element *E=extensions.front();E;E=E->next()) {
- if (E->get().nocasecmp_to(extension)==0) {
- path=path.get_basename()+selected_ext;
+ for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
+ if (E->get().nocasecmp_to(extension) == 0) {
+ path = path.get_basename() + selected_ext;
_path_changed(path);
break;
}
@@ -208,7 +203,6 @@ void ScriptCreateDialog::_lang_changed(int l) {
}
file_path->set_text(path);
_class_name_changed(class_name->get_text());
-
}
void ScriptCreateDialog::_built_in_pressed() {
@@ -218,7 +212,6 @@ void ScriptCreateDialog::_built_in_pressed() {
} else {
path_vb->show();
}
-
}
void ScriptCreateDialog::_browse_path() {
@@ -229,80 +222,76 @@ void ScriptCreateDialog::_browse_path() {
List<String> extensions;
// get all possible extensions for script
- for (int l=0;l<language_menu->get_item_count();l++) {
- ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ for (int l = 0; l < language_menu->get_item_count(); l++) {
+ ScriptServer::get_language(l)->get_recognized_extensions(&extensions);
}
- for(List<String>::Element *E=extensions.front();E;E=E->next()) {
- file_browse->add_filter("*."+E->get());
+ for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
+ file_browse->add_filter("*." + E->get());
}
file_browse->set_current_path(file_path->get_text());
file_browse->popup_centered_ratio();
-
}
-void ScriptCreateDialog::_file_selected(const String& p_file) {
+void ScriptCreateDialog::_file_selected(const String &p_file) {
String p = GlobalConfig::get_singleton()->localize_path(p_file);
file_path->set_text(p);
_path_changed(p);
-
}
-void ScriptCreateDialog::_path_changed(const String& p_path) {
+void ScriptCreateDialog::_path_changed(const String &p_path) {
- path_valid=false;
- String p =p_path;
+ path_valid = false;
+ String p = p_path;
- if (p=="") {
+ if (p == "") {
path_error_label->set_text(TTR("Path is empty"));
- path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
+ path_error_label->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8));
return;
-
}
p = GlobalConfig::get_singleton()->localize_path(p);
if (!p.begins_with("res://")) {
path_error_label->set_text(TTR("Path is not local"));
- path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
+ path_error_label->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8));
return;
}
if (p.find("/") || p.find("\\")) {
DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- if (d->change_dir(p.get_base_dir())!=OK) {
+ if (d->change_dir(p.get_base_dir()) != OK) {
path_error_label->set_text(TTR("Invalid base path"));
- path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
+ path_error_label->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8));
memdelete(d);
return;
-
}
memdelete(d);
}
FileAccess *f = FileAccess::create(FileAccess::ACCESS_RESOURCES);
- create_new=!f->file_exists(p);
+ create_new = !f->file_exists(p);
memdelete(f);
- String extension=p.get_extension();
+ String extension = p.get_extension();
List<String> extensions;
// get all possible extensions for script
- for (int l=0;l<language_menu->get_item_count();l++) {
- ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
+ for (int l = 0; l < language_menu->get_item_count(); l++) {
+ ScriptServer::get_language(l)->get_recognized_extensions(&extensions);
}
- bool found=false;
- int index=0;
- for(List<String>::Element *E=extensions.front();E;E=E->next()) {
- if (E->get().nocasecmp_to(extension)==0) {
+ bool found = false;
+ int index = 0;
+ for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
+ if (E->get().nocasecmp_to(extension) == 0) {
language_menu->select(index); // change Language option by extension
- found=true;
+ found = true;
break;
}
index++;
@@ -310,16 +299,15 @@ void ScriptCreateDialog::_path_changed(const String& p_path) {
if (!found) {
path_error_label->set_text(TTR("Invalid extension"));
- path_error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
+ path_error_label->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8));
return;
}
_update_controls();
- path_error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));
-
- path_valid=true;
+ path_error_label->add_color_override("font_color", Color(0, 1.0, 0.8, 0.8));
+ path_valid = true;
}
void ScriptCreateDialog::_update_controls() {
@@ -333,48 +321,45 @@ void ScriptCreateDialog::_update_controls() {
}
parent_name->set_editable(create_new);
internal->set_disabled(!create_new);
-
}
-
void ScriptCreateDialog::_bind_methods() {
- ClassDB::bind_method("_class_name_changed",&ScriptCreateDialog::_class_name_changed);
- ClassDB::bind_method("_lang_changed",&ScriptCreateDialog::_lang_changed);
- ClassDB::bind_method("_built_in_pressed",&ScriptCreateDialog::_built_in_pressed);
- ClassDB::bind_method("_browse_path",&ScriptCreateDialog::_browse_path);
- ClassDB::bind_method("_file_selected",&ScriptCreateDialog::_file_selected);
- ClassDB::bind_method("_path_changed",&ScriptCreateDialog::_path_changed);
- ADD_SIGNAL(MethodInfo("script_created",PropertyInfo(Variant::OBJECT,"script",PROPERTY_HINT_RESOURCE_TYPE,"Script")));
+ ClassDB::bind_method("_class_name_changed", &ScriptCreateDialog::_class_name_changed);
+ ClassDB::bind_method("_lang_changed", &ScriptCreateDialog::_lang_changed);
+ ClassDB::bind_method("_built_in_pressed", &ScriptCreateDialog::_built_in_pressed);
+ ClassDB::bind_method("_browse_path", &ScriptCreateDialog::_browse_path);
+ ClassDB::bind_method("_file_selected", &ScriptCreateDialog::_file_selected);
+ ClassDB::bind_method("_path_changed", &ScriptCreateDialog::_path_changed);
+ ADD_SIGNAL(MethodInfo("script_created", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script")));
}
ScriptCreateDialog::ScriptCreateDialog() {
/* SNAP DIALOG */
- VBoxContainer *vb = memnew( VBoxContainer );
+ VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
//set_child_rect(vb);
-
- class_name = memnew( LineEdit );
- VBoxContainer *vb2 = memnew( VBoxContainer );
+ class_name = memnew(LineEdit);
+ VBoxContainer *vb2 = memnew(VBoxContainer);
vb2->add_child(class_name);
- class_name->connect("text_changed", this,"_class_name_changed");
+ class_name->connect("text_changed", this, "_class_name_changed");
error_label = memnew(Label);
error_label->set_text("valid chars: a-z A-Z 0-9 _");
error_label->set_align(Label::ALIGN_CENTER);
vb2->add_child(error_label);
- vb->add_margin_child(TTR("Class Name:"),vb2);
+ vb->add_margin_child(TTR("Class Name:"), vb2);
- parent_name = memnew( LineEdit );
- vb->add_margin_child(TTR("Inherits:"),parent_name);
- parent_name->connect("text_changed", this,"_class_name_changed");
+ parent_name = memnew(LineEdit);
+ vb->add_margin_child(TTR("Inherits:"), parent_name);
+ parent_name->connect("text_changed", this, "_class_name_changed");
- language_menu = memnew( OptionButton );
- vb->add_margin_child(TTR("Language"),language_menu);
+ language_menu = memnew(OptionButton);
+ vb->add_margin_child(TTR("Language"), language_menu);
- for(int i=0;i<ScriptServer::get_language_count();i++) {
+ for (int i = 0; i < ScriptServer::get_language_count(); i++) {
language_menu->add_item(ScriptServer::get_language(i)->get_name());
}
@@ -383,55 +368,53 @@ ScriptCreateDialog::ScriptCreateDialog() {
String last_selected_language = editor_settings->get_project_metadata("script_setup", "last_selected_language", "");
if (last_selected_language != "")
for (int i = 0; i < language_menu->get_item_count(); i++)
- if (language_menu->get_item_text(i) == last_selected_language)
- {
+ if (language_menu->get_item_text(i) == last_selected_language) {
language_menu->select(i);
break;
- }
- else language_menu->select(0);
+ } else
+ language_menu->select(0);
- language_menu->connect("item_selected",this,"_lang_changed");
+ language_menu->connect("item_selected", this, "_lang_changed");
//parent_name->set_text();
- vb2 = memnew( VBoxContainer );
- path_vb = memnew( VBoxContainer );
+ vb2 = memnew(VBoxContainer);
+ path_vb = memnew(VBoxContainer);
vb2->add_child(path_vb);
- HBoxContainer *hbc = memnew( HBoxContainer );
- file_path = memnew( LineEdit );
- file_path->connect("text_changed",this,"_path_changed");
+ HBoxContainer *hbc = memnew(HBoxContainer);
+ file_path = memnew(LineEdit);
+ file_path->connect("text_changed", this, "_path_changed");
hbc->add_child(file_path);
file_path->set_h_size_flags(SIZE_EXPAND_FILL);
- Button *b = memnew( Button );
+ Button *b = memnew(Button);
b->set_text(" .. ");
- b->connect("pressed",this,"_browse_path");
+ b->connect("pressed", this, "_browse_path");
hbc->add_child(b);
path_vb->add_child(hbc);
- path_error_label = memnew( Label );
- path_vb->add_child( path_error_label );
+ path_error_label = memnew(Label);
+ path_vb->add_child(path_error_label);
path_error_label->set_text(TTR("Error!"));
path_error_label->set_align(Label::ALIGN_CENTER);
-
- internal = memnew( CheckButton );
+ internal = memnew(CheckButton);
internal->set_text(TTR("Built-In Script"));
vb2->add_child(internal);
- internal->connect("pressed",this,"_built_in_pressed");
+ internal->connect("pressed", this, "_built_in_pressed");
- vb->add_margin_child(TTR("Path:"),vb2);
+ vb->add_margin_child(TTR("Path:"), vb2);
- set_size(Size2(200,150));
+ set_size(Size2(200, 150));
set_hide_on_ok(false);
set_title(TTR("Attach Node Script"));
- file_browse = memnew( EditorFileDialog );
- file_browse->connect("file_selected",this,"_file_selected");
+ file_browse = memnew(EditorFileDialog);
+ file_browse->connect("file_selected", this, "_file_selected");
add_child(file_browse);
get_ok()->set_text(TTR("Create"));
- alert = memnew( AcceptDialog );
+ alert = memnew(AcceptDialog);
add_child(alert);
_lang_changed(0);
- create_new=true;
+ create_new = true;
}
diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h
index ad9616c071..a3ad06dbbf 100644
--- a/editor/script_create_dialog.h
+++ b/editor/script_create_dialog.h
@@ -29,15 +29,15 @@
#ifndef SCRIPT_CREATE_DIALOG_H
#define SCRIPT_CREATE_DIALOG_H
-#include "scene/gui/dialogs.h"
-#include "scene/gui/line_edit.h"
-#include "scene/gui/option_button.h"
#include "editor/editor_file_dialog.h"
#include "editor/editor_settings.h"
#include "scene/gui/check_button.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/line_edit.h"
+#include "scene/gui/option_button.h"
class ScriptCreateDialog : public ConfirmationDialog {
- GDCLASS(ScriptCreateDialog,ConfirmationDialog);
+ GDCLASS(ScriptCreateDialog, ConfirmationDialog);
LineEdit *class_name;
Label *error_label;
@@ -54,24 +54,23 @@ class ScriptCreateDialog : public ConfirmationDialog {
String initial_bp;
EditorSettings *editor_settings;
-
- void _path_changed(const String& p_path=String());
- void _lang_changed(int l=0);
+ void _path_changed(const String &p_path = String());
+ void _lang_changed(int l = 0);
void _built_in_pressed();
- bool _validate(const String& p_strin);
- void _class_name_changed(const String& p_name);
+ bool _validate(const String &p_strin);
+ void _class_name_changed(const String &p_name);
void _browse_path();
- void _file_selected(const String& p_file);
+ void _file_selected(const String &p_file);
virtual void ok_pressed();
void _create_new();
void _load_exist();
void _update_controls();
-protected:
+protected:
static void _bind_methods();
-public:
- void config(const String& p_base_name,const String&p_base_path);
+public:
+ void config(const String &p_base_name, const String &p_base_path);
ScriptCreateDialog();
};
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index fa33ffe5c7..b7a904c255 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -28,150 +28,134 @@
/*************************************************************************/
#include "script_editor_debugger.h"
-#include "scene/gui/separator.h"
-#include "scene/gui/label.h"
-#include "scene/gui/split_container.h"
-#include "scene/gui/tree.h"
-#include "scene/gui/texture_button.h"
-#include "scene/gui/tab_container.h"
-#include "scene/gui/line_edit.h"
-#include "scene/gui/dialogs.h"
-#include "scene/gui/rich_text_label.h"
-#include "scene/gui/margin_container.h"
-#include "property_editor.h"
-#include "global_config.h"
#include "editor_node.h"
-#include "main/performance.h"
#include "editor_profiler.h"
#include "editor_settings.h"
+#include "global_config.h"
+#include "main/performance.h"
+#include "property_editor.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/label.h"
+#include "scene/gui/line_edit.h"
+#include "scene/gui/margin_container.h"
+#include "scene/gui/rich_text_label.h"
+#include "scene/gui/separator.h"
+#include "scene/gui/split_container.h"
+#include "scene/gui/tab_container.h"
+#include "scene/gui/texture_button.h"
+#include "scene/gui/tree.h"
class ScriptEditorDebuggerVariables : public Object {
- GDCLASS( ScriptEditorDebuggerVariables, Object );
+ GDCLASS(ScriptEditorDebuggerVariables, Object);
List<PropertyInfo> props;
- Map<StringName,Variant> values;
-protected:
+ Map<StringName, Variant> values;
- bool _set(const StringName& p_name, const Variant& p_value) {
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value) {
return false;
}
- bool _get(const StringName& p_name,Variant &r_ret) const {
+ bool _get(const StringName &p_name, Variant &r_ret) const {
if (!values.has(p_name))
return false;
- r_ret=values[p_name];
+ r_ret = values[p_name];
return true;
}
- void _get_property_list( List<PropertyInfo> *p_list) const {
+ void _get_property_list(List<PropertyInfo> *p_list) const {
- for(const List<PropertyInfo>::Element *E=props.front();E;E=E->next() )
+ for (const List<PropertyInfo>::Element *E = props.front(); E; E = E->next())
p_list->push_back(E->get());
}
-
public:
-
-
void clear() {
props.clear();
values.clear();
}
- String get_var_value(const String& p_var) const {
+ String get_var_value(const String &p_var) const {
- for(Map<StringName,Variant>::Element *E=values.front();E;E=E->next()) {
- String v = E->key().operator String().get_slice("/",1);
- if (v==p_var)
+ for (Map<StringName, Variant>::Element *E = values.front(); E; E = E->next()) {
+ String v = E->key().operator String().get_slice("/", 1);
+ if (v == p_var)
return E->get();
}
return "";
}
- void add_property(const String &p_name, const Variant& p_value) {
+ void add_property(const String &p_name, const Variant &p_value) {
PropertyInfo pinfo;
- pinfo.name=p_name;
- pinfo.type=p_value.get_type();
+ pinfo.name = p_name;
+ pinfo.type = p_value.get_type();
props.push_back(pinfo);
- values[p_name]=p_value;
-
+ values[p_name] = p_value;
}
void update() {
_change_notify();
}
-
ScriptEditorDebuggerVariables() {
-
}
};
-
class ScriptEditorDebuggerInspectedObject : public Object {
- GDCLASS( ScriptEditorDebuggerInspectedObject, Object);
-
-
-
+ GDCLASS(ScriptEditorDebuggerInspectedObject, Object);
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value) {
+ bool _set(const StringName &p_name, const Variant &p_value) {
if (!prop_values.has(p_name))
return false;
- emit_signal("value_edited",p_name,p_value);
- prop_values[p_name]=p_value;
+ emit_signal("value_edited", p_name, p_value);
+ prop_values[p_name] = p_value;
return true;
}
- bool _get(const StringName& p_name,Variant &r_ret) const {
+ bool _get(const StringName &p_name, Variant &r_ret) const {
if (!prop_values.has(p_name))
return false;
- r_ret=prop_values[p_name];
+ r_ret = prop_values[p_name];
return true;
-
}
- void _get_property_list( List<PropertyInfo> *p_list) const {
+ void _get_property_list(List<PropertyInfo> *p_list) const {
p_list->clear(); //sorry, no want category
- for (const List<PropertyInfo>::Element *E=prop_list.front();E;E=E->next()) {
+ for (const List<PropertyInfo>::Element *E = prop_list.front(); E; E = E->next()) {
p_list->push_back(E->get());
}
}
-
static void _bind_methods() {
ADD_SIGNAL(MethodInfo("value_edited"));
}
public:
-
ObjectID last_edited_id;
List<PropertyInfo> prop_list;
- Map<StringName,Variant> prop_values;
+ Map<StringName, Variant> prop_values;
void update() {
_change_notify();
}
- void update_single(const char* p_prop) {
+ void update_single(const char *p_prop) {
_change_notify(p_prop);
}
- ScriptEditorDebuggerInspectedObject() { last_edited_id=0; }
-
-
+ ScriptEditorDebuggerInspectedObject() { last_edited_id = 0; }
};
void ScriptEditorDebugger::debug_next() {
@@ -184,7 +168,6 @@ void ScriptEditorDebugger::debug_next() {
ppeer->put_var(msg);
stack_dump->clear();
inspector->edit(NULL);
-
}
void ScriptEditorDebugger::debug_step() {
@@ -208,7 +191,6 @@ void ScriptEditorDebugger::debug_break() {
Array msg;
msg.push_back("break");
ppeer->put_var(msg);
-
}
void ScriptEditorDebugger::debug_continue() {
@@ -222,18 +204,15 @@ void ScriptEditorDebugger::debug_continue() {
Array msg;
msg.push_back("continue");
ppeer->put_var(msg);
-
-
}
-void ScriptEditorDebugger::_scene_tree_folded(Object* obj) {
-
+void ScriptEditorDebugger::_scene_tree_folded(Object *obj) {
if (updating_scene_tree) {
return;
}
- TreeItem *item=obj->cast_to<TreeItem>();
+ TreeItem *item = obj->cast_to<TreeItem>();
if (!item)
return;
@@ -244,13 +223,10 @@ void ScriptEditorDebugger::_scene_tree_folded(Object* obj) {
} else {
unfold_cache.insert(id);
}
-
-
}
void ScriptEditorDebugger::_scene_tree_selected() {
-
if (updating_scene_tree) {
return;
@@ -267,11 +243,9 @@ void ScriptEditorDebugger::_scene_tree_selected() {
msg.push_back("inspect_object");
msg.push_back(inspected_object_id);
ppeer->put_var(msg);
-
}
-void ScriptEditorDebugger::_scene_tree_property_value_edited(const String& p_prop,const Variant& p_value) {
-
+void ScriptEditorDebugger::_scene_tree_property_value_edited(const String &p_prop, const Variant &p_value) {
Array msg;
msg.push_back("set_object_property");
@@ -279,17 +253,16 @@ void ScriptEditorDebugger::_scene_tree_property_value_edited(const String& p_pro
msg.push_back(p_prop);
msg.push_back(p_value);
ppeer->put_var(msg);
- inspect_edited_object_timeout=0.7; //avoid annoyance, don't request soon after editing
+ inspect_edited_object_timeout = 0.7; //avoid annoyance, don't request soon after editing
}
void ScriptEditorDebugger::_scene_tree_property_select_object(ObjectID p_object) {
- inspected_object_id=p_object;
+ inspected_object_id = p_object;
Array msg;
msg.push_back("inspect_object");
msg.push_back(inspected_object_id);
ppeer->put_var(msg);
-
}
void ScriptEditorDebugger::_scene_tree_request() {
@@ -300,7 +273,6 @@ void ScriptEditorDebugger::_scene_tree_request() {
Array msg;
msg.push_back("request_scene_tree");
ppeer->put_var(msg);
-
}
void ScriptEditorDebugger::_video_mem_request() {
@@ -311,38 +283,34 @@ void ScriptEditorDebugger::_video_mem_request() {
Array msg;
msg.push_back("request_video_mem");
ppeer->put_var(msg);
-
}
Size2 ScriptEditorDebugger::get_minimum_size() const {
Size2 ms = Control::get_minimum_size();
- ms.y = MAX(ms.y , 250 );
+ ms.y = MAX(ms.y, 250);
return ms;
-
}
-void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_data) {
+void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_data) {
-
-
- if (p_msg=="debug_enter") {
+ if (p_msg == "debug_enter") {
Array msg;
msg.push_back("get_stack_dump");
ppeer->put_var(msg);
- ERR_FAIL_COND(p_data.size()!=2);
- bool can_continue=p_data[0];
+ ERR_FAIL_COND(p_data.size() != 2);
+ bool can_continue = p_data[0];
String error = p_data[1];
step->set_disabled(!can_continue);
next->set_disabled(!can_continue);
reason->set_text(error);
reason->set_tooltip(error);
- breaked=true;
+ breaked = true;
dobreak->set_disabled(true);
docontinue->set_disabled(false);
- emit_signal("breaked",true,can_continue);
+ emit_signal("breaked", true, can_continue);
OS::get_singleton()->move_window_to_foreground();
- if (error!="") {
+ if (error != "") {
tabs->set_current_tab(0);
}
@@ -350,12 +318,11 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
EditorNode::get_singleton()->get_pause_button()->set_pressed(true);
-
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
- } else if (p_msg=="debug_exit") {
+ } else if (p_msg == "debug_exit") {
- breaked=false;
+ breaked = false;
step->set_disabled(true);
next->set_disabled(true);
reason->set_text("");
@@ -364,47 +331,45 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
forward->set_disabled(true);
dobreak->set_disabled(false);
docontinue->set_disabled(true);
- emit_signal("breaked",false,false,Variant());
+ emit_signal("breaked", false, false, Variant());
//tabs->set_current_tab(0);
profiler->set_enabled(true);
profiler->disable_seeking();
EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
-
- } else if (p_msg=="message:click_ctrl") {
+ } else if (p_msg == "message:click_ctrl") {
clicked_ctrl->set_text(p_data[0]);
clicked_ctrl_type->set_text(p_data[1]);
- } else if (p_msg=="message:scene_tree") {
+ } else if (p_msg == "message:scene_tree") {
inspect_scene_tree->clear();
- Map<int,TreeItem*> lv;
+ Map<int, TreeItem *> lv;
- updating_scene_tree=true;
+ updating_scene_tree = true;
- for(int i=0;i<p_data.size();i+=4) {
+ for (int i = 0; i < p_data.size(); i += 4) {
TreeItem *p;
int level = p_data[i];
- if (level==0) {
+ if (level == 0) {
p = NULL;
} else {
- ERR_CONTINUE(!lv.has(level-1));
- p=lv[level-1];
+ ERR_CONTINUE(!lv.has(level - 1));
+ p = lv[level - 1];
}
-
TreeItem *it = inspect_scene_tree->create_item(p);
- ObjectID id = ObjectID(p_data[i+3]);
+ ObjectID id = ObjectID(p_data[i + 3]);
- it->set_text(0,p_data[i+1]);
- if (has_icon(p_data[i+2],"EditorIcons"))
- it->set_icon(0,get_icon(p_data[i+2],"EditorIcons"));
- it->set_metadata(0,id);
- if (id==inspected_object_id) {
+ it->set_text(0, p_data[i + 1]);
+ if (has_icon(p_data[i + 2], "EditorIcons"))
+ it->set_icon(0, get_icon(p_data[i + 2], "EditorIcons"));
+ it->set_metadata(0, id);
+ if (id == inspected_object_id) {
it->select(0);
}
@@ -417,100 +382,93 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
it->set_collapsed(true);
}
}
- lv[level]=it;
+ lv[level] = it;
}
- updating_scene_tree=false;
+ updating_scene_tree = false;
le_clear->set_disabled(false);
le_set->set_disabled(false);
- } else if (p_msg=="message:inspect_object") {
-
+ } else if (p_msg == "message:inspect_object") {
ObjectID id = p_data[0];
String type = p_data[1];
Variant path = p_data[2]; //what to do yet, i don't know
- int prop_count=p_data[3];
+ int prop_count = p_data[3];
- int idx=4;
+ int idx = 4;
-
- if (inspected_object->last_edited_id!=id) {
+ if (inspected_object->last_edited_id != id) {
inspected_object->prop_list.clear();
inspected_object->prop_values.clear();
}
- for(int i=0;i<prop_count;i++) {
+ for (int i = 0; i < prop_count; i++) {
PropertyInfo pinfo;
- pinfo.name=p_data[idx++];
- pinfo.type=Variant::Type(int(p_data[idx++]));
- pinfo.hint=PropertyHint(int(p_data[idx++]));
- pinfo.hint_string=p_data[idx++];
+ pinfo.name = p_data[idx++];
+ pinfo.type = Variant::Type(int(p_data[idx++]));
+ pinfo.hint = PropertyHint(int(p_data[idx++]));
+ pinfo.hint_string = p_data[idx++];
if (pinfo.name.begins_with("*")) {
- pinfo.name=pinfo.name.substr(1,pinfo.name.length());
- pinfo.usage=PROPERTY_USAGE_CATEGORY;
+ pinfo.name = pinfo.name.substr(1, pinfo.name.length());
+ pinfo.usage = PROPERTY_USAGE_CATEGORY;
} else {
- pinfo.usage=PROPERTY_USAGE_EDITOR;
+ pinfo.usage = PROPERTY_USAGE_EDITOR;
}
- if (inspected_object->last_edited_id!=id) {
+ if (inspected_object->last_edited_id != id) {
//don't update.. it's the same, instead refresh
inspected_object->prop_list.push_back(pinfo);
}
+ inspected_object->prop_values[pinfo.name] = p_data[idx++];
- inspected_object->prop_values[pinfo.name]=p_data[idx++];
-
- if (inspected_object->last_edited_id==id) {
+ if (inspected_object->last_edited_id == id) {
//same, just update value, don't rebuild
inspected_object->update_single(pinfo.name.ascii().get_data());
}
-
}
-
-
- if (inspected_object->last_edited_id!=id) {
+ if (inspected_object->last_edited_id != id) {
//only if different
inspected_object->update();
}
- inspected_object->last_edited_id=id;
-
+ inspected_object->last_edited_id = id;
inspect_properties->edit(inspected_object);
- } else if (p_msg=="message:video_mem") {
+ } else if (p_msg == "message:video_mem") {
vmem_tree->clear();
- TreeItem* root=vmem_tree->create_item();
+ TreeItem *root = vmem_tree->create_item();
- int total=0;
+ int total = 0;
- for(int i=0;i<p_data.size();i+=4) {
+ for (int i = 0; i < p_data.size(); i += 4) {
TreeItem *it = vmem_tree->create_item(root);
- String type=p_data[i+1];
- int bytes=p_data[i+3].operator int();
- it->set_text(0,p_data[i+0]); //path
- it->set_text(1,type); //type
- it->set_text(2,p_data[i+2]); //type
- it->set_text(3,String::humanize_size(bytes)); //type
- total+=bytes;
-
- if (has_icon(type,"EditorIcons"))
- it->set_icon(0,get_icon(type,"EditorIcons"));
+ String type = p_data[i + 1];
+ int bytes = p_data[i + 3].operator int();
+ it->set_text(0, p_data[i + 0]); //path
+ it->set_text(1, type); //type
+ it->set_text(2, p_data[i + 2]); //type
+ it->set_text(3, String::humanize_size(bytes)); //type
+ total += bytes;
+
+ if (has_icon(type, "EditorIcons"))
+ it->set_icon(0, get_icon(type, "EditorIcons"));
}
- vmem_total->set_tooltip(TTR("Bytes:")+" "+itos(total));
+ vmem_total->set_tooltip(TTR("Bytes:") + " " + itos(total));
vmem_total->set_text(String::humanize_size(total));
- } else if (p_msg=="stack_dump") {
+ } else if (p_msg == "stack_dump") {
stack_dump->clear();
TreeItem *r = stack_dump->create_item();
- for(int i=0;i<p_data.size();i++) {
+ for (int i = 0; i < p_data.size(); i++) {
Dictionary d = p_data[i];
ERR_CONTINUE(!d.has("function"));
@@ -518,65 +476,61 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
ERR_CONTINUE(!d.has("line"));
ERR_CONTINUE(!d.has("id"));
TreeItem *s = stack_dump->create_item(r);
- d["frame"]=i;
- s->set_metadata(0,d);
+ d["frame"] = i;
+ s->set_metadata(0, d);
//String line = itos(i)+" - "+String(d["file"])+":"+itos(d["line"])+" - at func: "+d["function"];
- String line = itos(i)+" - "+String(d["file"])+":"+itos(d["line"]);
- s->set_text(0,line);
+ String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]);
+ s->set_text(0, line);
- if (i==0)
+ if (i == 0)
s->select(0);
}
- } else if (p_msg=="stack_frame_vars") {
-
+ } else if (p_msg == "stack_frame_vars") {
variables->clear();
-
-
- int ofs =0;
+ int ofs = 0;
int mcount = p_data[ofs];
ofs++;
- for(int i=0;i<mcount;i++) {
+ for (int i = 0; i < mcount; i++) {
- String n = p_data[ofs+i*2+0];
- Variant v = p_data[ofs+i*2+1];
+ String n = p_data[ofs + i * 2 + 0];
+ Variant v = p_data[ofs + i * 2 + 1];
if (n.begins_with("*")) {
- n=n.substr(1,n.length());
+ n = n.substr(1, n.length());
}
- variables->add_property("members/"+n,v);
+ variables->add_property("members/" + n, v);
}
- ofs+=mcount*2;
+ ofs += mcount * 2;
mcount = p_data[ofs];
ofs++;
- for(int i=0;i<mcount;i++) {
+ for (int i = 0; i < mcount; i++) {
- String n = p_data[ofs+i*2+0];
- Variant v = p_data[ofs+i*2+1];
+ String n = p_data[ofs + i * 2 + 0];
+ Variant v = p_data[ofs + i * 2 + 1];
if (n.begins_with("*")) {
- n=n.substr(1,n.length());
+ n = n.substr(1, n.length());
}
-
- variables->add_property("locals/"+n,v);
+ variables->add_property("locals/" + n, v);
}
variables->update();
inspector->edit(variables);
- } else if (p_msg=="output") {
+ } else if (p_msg == "output") {
//OUT
- for(int i=0;i<p_data.size();i++) {
+ for (int i = 0; i < p_data.size(); i++) {
String t = p_data[i];
//LOG
@@ -587,26 +541,24 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
}
}
EditorNode::get_log()->add_message(t);
-
}
- } else if (p_msg=="performance") {
+ } else if (p_msg == "performance") {
Array arr = p_data[0];
Vector<float> p;
p.resize(arr.size());
- for(int i=0;i<arr.size();i++) {
- p[i]=arr[i];
- if (i<perf_items.size()) {
- perf_items[i]->set_text(1,rtos(p[i]));
- if (p[i]>perf_max[i])
- perf_max[i]=p[i];
+ for (int i = 0; i < arr.size(); i++) {
+ p[i] = arr[i];
+ if (i < perf_items.size()) {
+ perf_items[i]->set_text(1, rtos(p[i]));
+ if (p[i] > perf_max[i])
+ perf_max[i] = p[i];
}
-
}
perf_history.push_front(p);
perf_draw->update();
- } else if (p_msg=="error") {
+ } else if (p_msg == "error") {
Array err = p_data[0];
@@ -618,30 +570,28 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
bool warning = err[9];
bool e;
- String time = String("%d:%02d:%02d:%04d").sprintf(vals,&e);
- String txt=time+" - "+(err[8].is_zero()?String(err[7]):String(err[8]));
-
- String tooltip=TTR("Type:")+String(warning?TTR("Warning"):TTR("Error"));
- tooltip+="\n"+TTR("Description:")+" "+String(err[8]);
- tooltip+="\n"+TTR("Time:")+" "+time;
- tooltip+="\nC "+TTR("Error:")+" "+String(err[7]);
- tooltip+="\nC "+TTR("Source:")+" "+String(err[5])+":"+String(err[6]);
- tooltip+="\nC "+TTR("Function:")+" "+String(err[4]);
-
+ String time = String("%d:%02d:%02d:%04d").sprintf(vals, &e);
+ String txt = time + " - " + (err[8].is_zero() ? String(err[7]) : String(err[8]));
+ String tooltip = TTR("Type:") + String(warning ? TTR("Warning") : TTR("Error"));
+ tooltip += "\n" + TTR("Description:") + " " + String(err[8]);
+ tooltip += "\n" + TTR("Time:") + " " + time;
+ tooltip += "\nC " + TTR("Error:") + " " + String(err[7]);
+ tooltip += "\nC " + TTR("Source:") + " " + String(err[5]) + ":" + String(err[6]);
+ tooltip += "\nC " + TTR("Function:") + " " + String(err[4]);
- error_list->add_item(txt,EditorNode::get_singleton()->get_gui_base()->get_icon(warning?"Warning":"Error","EditorIcons"));
- error_list->set_item_tooltip( error_list->get_item_count() -1,tooltip );
+ error_list->add_item(txt, EditorNode::get_singleton()->get_gui_base()->get_icon(warning ? "Warning" : "Error", "EditorIcons"));
+ error_list->set_item_tooltip(error_list->get_item_count() - 1, tooltip);
int scc = p_data[1];
Array stack;
stack.resize(scc);
- for(int i=0;i<scc;i++) {
- stack[i]=p_data[2+i];
+ for (int i = 0; i < scc; i++) {
+ stack[i] = p_data[2 + i];
}
- error_list->set_item_metadata( error_list->get_item_count() -1,stack );
+ error_list->set_item_metadata(error_list->get_item_count() - 1, stack);
error_count++;
/*
@@ -664,252 +614,230 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
packet_peer_stream->put_var(oe.callstack);
*/
- } else if (p_msg=="profile_sig") {
+ } else if (p_msg == "profile_sig") {
//cache a signature
- print_line("SIG: "+String(Variant(p_data)));
- profiler_signature[p_data[1]]=p_data[0];
+ print_line("SIG: " + String(Variant(p_data)));
+ profiler_signature[p_data[1]] = p_data[0];
- } else if (p_msg=="profile_frame" || p_msg=="profile_total") {
+ } else if (p_msg == "profile_frame" || p_msg == "profile_total") {
EditorProfiler::Metric metric;
- metric.valid=true;
- metric.frame_number=p_data[0];
- metric.frame_time=p_data[1];
- metric.idle_time=p_data[2];
- metric.fixed_time=p_data[3];
- metric.fixed_frame_time=p_data[4];
+ metric.valid = true;
+ metric.frame_number = p_data[0];
+ metric.frame_time = p_data[1];
+ metric.idle_time = p_data[2];
+ metric.fixed_time = p_data[3];
+ metric.fixed_frame_time = p_data[4];
int frame_data_amount = p_data[6];
int frame_function_amount = p_data[7];
-
if (frame_data_amount) {
EditorProfiler::Metric::Category frame_time;
- frame_time.signature="category_frame_time";
- frame_time.name="Frame Time";
- frame_time.total_time=metric.frame_time;
+ frame_time.signature = "category_frame_time";
+ frame_time.name = "Frame Time";
+ frame_time.total_time = metric.frame_time;
EditorProfiler::Metric::Category::Item item;
- item.calls=1;
- item.line=0;
- item.name="Fixed Time";
- item.total=metric.fixed_time;
- item.self=item.total;
- item.signature="fixed_time";
-
+ item.calls = 1;
+ item.line = 0;
+ item.name = "Fixed Time";
+ item.total = metric.fixed_time;
+ item.self = item.total;
+ item.signature = "fixed_time";
frame_time.items.push_back(item);
- item.name="Idle Time";
- item.total=metric.idle_time;
- item.self=item.total;
- item.signature="idle_time";
+ item.name = "Idle Time";
+ item.total = metric.idle_time;
+ item.self = item.total;
+ item.signature = "idle_time";
frame_time.items.push_back(item);
- item.name="Fixed Frame Time";
- item.total=metric.fixed_frame_time;
- item.self=item.total;
- item.signature="fixed_frame_time";
+ item.name = "Fixed Frame Time";
+ item.total = metric.fixed_frame_time;
+ item.self = item.total;
+ item.signature = "fixed_frame_time";
frame_time.items.push_back(item);
metric.categories.push_back(frame_time);
-
}
-
-
- int idx=8;
- for(int i=0;i<frame_data_amount;i++) {
+ int idx = 8;
+ for (int i = 0; i < frame_data_amount; i++) {
EditorProfiler::Metric::Category c;
- String name=p_data[idx++];
- Array values=p_data[idx++];
- c.name=name.capitalize();
- c.items.resize(values.size()/2);
- c.total_time=0;
- c.signature="categ::"+name;
- for(int i=0;i<values.size();i+=2) {
+ String name = p_data[idx++];
+ Array values = p_data[idx++];
+ c.name = name.capitalize();
+ c.items.resize(values.size() / 2);
+ c.total_time = 0;
+ c.signature = "categ::" + name;
+ for (int i = 0; i < values.size(); i += 2) {
EditorProfiler::Metric::Category::Item item;
- item.name=values[i];
- item.calls=1;
- item.self=values[i+1];
- item.total=item.self;
- item.signature="categ::"+name+"::"+item.name;
- item.name=item.name.capitalize();
- c.total_time+=item.total;
- c.items[i/2]=item;
-
-
+ item.name = values[i];
+ item.calls = 1;
+ item.self = values[i + 1];
+ item.total = item.self;
+ item.signature = "categ::" + name + "::" + item.name;
+ item.name = item.name.capitalize();
+ c.total_time += item.total;
+ c.items[i / 2] = item;
}
metric.categories.push_back(c);
}
EditorProfiler::Metric::Category funcs;
- funcs.total_time=p_data[5]; //script time
+ funcs.total_time = p_data[5]; //script time
funcs.items.resize(frame_function_amount);
- funcs.name="Script Functions";
- funcs.signature="script_functions";
- for(int i=0;i<frame_function_amount;i++) {
+ funcs.name = "Script Functions";
+ funcs.signature = "script_functions";
+ for (int i = 0; i < frame_function_amount; i++) {
int signature = p_data[idx++];
int calls = p_data[idx++];
float total = p_data[idx++];
float self = p_data[idx++];
-
-
EditorProfiler::Metric::Category::Item item;
if (profiler_signature.has(signature)) {
- item.signature=profiler_signature[signature];
+ item.signature = profiler_signature[signature];
String name = profiler_signature[signature];
Vector<String> strings = name.split("::");
- if (strings.size()==3) {
- item.name=strings[2];
- item.script=strings[0];
- item.line=strings[1].to_int();
+ if (strings.size() == 3) {
+ item.name = strings[2];
+ item.script = strings[0];
+ item.line = strings[1].to_int();
}
} else {
- item.name="SigErr "+itos(signature);
+ item.name = "SigErr " + itos(signature);
}
-
-
-
- item.calls=calls;
- item.self=self;
- item.total=total;
- funcs.items[i]=item;
-
+ item.calls = calls;
+ item.self = self;
+ item.total = total;
+ funcs.items[i] = item;
}
metric.categories.push_back(funcs);
- if (p_msg=="profile_frame")
- profiler->add_frame_metric(metric,false);
+ if (p_msg == "profile_frame")
+ profiler->add_frame_metric(metric, false);
else
- profiler->add_frame_metric(metric,true);
+ profiler->add_frame_metric(metric, true);
- } else if (p_msg=="kill_me") {
+ } else if (p_msg == "kill_me") {
editor->call_deferred("stop_child_process");
}
-
}
-
-void ScriptEditorDebugger::_performance_select(Object*,int,bool) {
+void ScriptEditorDebugger::_performance_select(Object *, int, bool) {
perf_draw->update();
-
}
void ScriptEditorDebugger::_performance_draw() {
-
Vector<int> which;
- for(int i=0;i<perf_items.size();i++) {
-
+ for (int i = 0; i < perf_items.size(); i++) {
if (perf_items[i]->is_selected(0))
which.push_back(i);
}
-
- if(which.empty())
+ if (which.empty())
return;
- Ref<StyleBox> graph_sb = get_stylebox("normal","TextEdit");
- Ref<Font> graph_font = get_font("font","TextEdit");
+ Ref<StyleBox> graph_sb = get_stylebox("normal", "TextEdit");
+ Ref<Font> graph_font = get_font("font", "TextEdit");
int cols = Math::ceil(Math::sqrt((float)which.size()));
- int rows = (which.size()+1)/cols;
- if (which.size()==1)
- rows=1;
-
-
- int margin =3;
- int point_sep=5;
- Size2i s = Size2i(perf_draw->get_size())/Size2i(cols,rows);
- for(int i=0;i<which.size();i++) {
-
- Point2i p(i%cols,i/cols);
- Rect2i r(p*s,s);
- r.pos+=Point2(margin,margin);
- r.size-=Point2(margin,margin)*2.0;
- perf_draw->draw_style_box(graph_sb,r);
- r.pos+=graph_sb->get_offset();
- r.size-=graph_sb->get_minimum_size();
- int pi=which[i];
- Color c = Color(0.7,0.9,0.5);
- c.set_hsv(Math::fmod(c.get_h()+pi*0.7654,1),c.get_s(),c.get_v());
-
- c.a=0.8;
- perf_draw->draw_string(graph_font,r.pos+Point2(0,graph_font->get_ascent()),perf_items[pi]->get_text(0),c,r.size.x);
- c.a=0.6;
- perf_draw->draw_string(graph_font,r.pos+Point2(graph_font->get_char_size('X').width,graph_font->get_ascent()+graph_font->get_height()),perf_items[pi]->get_text(1),c,r.size.y);
-
- float spacing=point_sep/float(cols);
+ int rows = (which.size() + 1) / cols;
+ if (which.size() == 1)
+ rows = 1;
+
+ int margin = 3;
+ int point_sep = 5;
+ Size2i s = Size2i(perf_draw->get_size()) / Size2i(cols, rows);
+ for (int i = 0; i < which.size(); i++) {
+
+ Point2i p(i % cols, i / cols);
+ Rect2i r(p * s, s);
+ r.pos += Point2(margin, margin);
+ r.size -= Point2(margin, margin) * 2.0;
+ perf_draw->draw_style_box(graph_sb, r);
+ r.pos += graph_sb->get_offset();
+ r.size -= graph_sb->get_minimum_size();
+ int pi = which[i];
+ Color c = Color(0.7, 0.9, 0.5);
+ c.set_hsv(Math::fmod(c.get_h() + pi * 0.7654, 1), c.get_s(), c.get_v());
+
+ c.a = 0.8;
+ perf_draw->draw_string(graph_font, r.pos + Point2(0, graph_font->get_ascent()), perf_items[pi]->get_text(0), c, r.size.x);
+ c.a = 0.6;
+ perf_draw->draw_string(graph_font, r.pos + Point2(graph_font->get_char_size('X').width, graph_font->get_ascent() + graph_font->get_height()), perf_items[pi]->get_text(1), c, r.size.y);
+
+ float spacing = point_sep / float(cols);
float from = r.size.width;
- List<Vector<float> >::Element *E=perf_history.front();
- float prev=-1;
- while(from>=0 && E) {
+ List<Vector<float> >::Element *E = perf_history.front();
+ float prev = -1;
+ while (from >= 0 && E) {
float m = perf_max[pi];
- if (m==0)
- m=0.00001;
- float h = E->get()[pi]/m;
- h=(1.0-h)*r.size.y;
-
- c.a=0.7;
- if (E!=perf_history.front())
- perf_draw->draw_line(r.pos+Point2(from,h),r.pos+Point2(from+spacing,prev),c,2.0);
- prev=h;
- E=E->next();
- from-=spacing;
+ if (m == 0)
+ m = 0.00001;
+ float h = E->get()[pi] / m;
+ h = (1.0 - h) * r.size.y;
+
+ c.a = 0.7;
+ if (E != perf_history.front())
+ perf_draw->draw_line(r.pos + Point2(from, h), r.pos + Point2(from + spacing, prev), c, 2.0);
+ prev = h;
+ E = E->next();
+ from -= spacing;
}
-
}
-
}
void ScriptEditorDebugger::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
inspector->edit(variables);
- step->set_icon( get_icon("DebugStep","EditorIcons"));
- next->set_icon( get_icon("DebugNext","EditorIcons"));
- back->set_icon( get_icon("Back","EditorIcons"));
- forward->set_icon( get_icon("Forward","EditorIcons"));
- dobreak->set_icon( get_icon("Pause","EditorIcons"));
- docontinue->set_icon( get_icon("DebugContinue","EditorIcons"));
+ step->set_icon(get_icon("DebugStep", "EditorIcons"));
+ next->set_icon(get_icon("DebugNext", "EditorIcons"));
+ back->set_icon(get_icon("Back", "EditorIcons"));
+ forward->set_icon(get_icon("Forward", "EditorIcons"));
+ dobreak->set_icon(get_icon("Pause", "EditorIcons"));
+ docontinue->set_icon(get_icon("DebugContinue", "EditorIcons"));
//scene_tree_refresh->set_icon( get_icon("Reload","EditorIcons"));
- le_set->connect("pressed",this,"_live_edit_set");
- le_clear->connect("pressed",this,"_live_edit_clear");
- error_list->connect("item_selected",this,"_error_selected");
- error_stack->connect("item_selected",this,"_error_stack_selected");
- vmem_refresh->set_icon( get_icon("Reload","EditorIcons"));
+ le_set->connect("pressed", this, "_live_edit_set");
+ le_clear->connect("pressed", this, "_live_edit_clear");
+ error_list->connect("item_selected", this, "_error_selected");
+ error_stack->connect("item_selected", this, "_error_stack_selected");
+ vmem_refresh->set_icon(get_icon("Reload", "EditorIcons"));
} break;
case NOTIFICATION_PROCESS: {
if (connection.is_valid()) {
- inspect_scene_tree_timeout-=get_process_delta_time();
- if (inspect_scene_tree_timeout<0) {
- inspect_scene_tree_timeout=EditorSettings::get_singleton()->get("debugger/scene_tree_refresh_interval");
+ inspect_scene_tree_timeout -= get_process_delta_time();
+ if (inspect_scene_tree_timeout < 0) {
+ inspect_scene_tree_timeout = EditorSettings::get_singleton()->get("debugger/scene_tree_refresh_interval");
if (inspect_scene_tree->is_visible_in_tree()) {
_scene_tree_request();
- if (inspected_object_id!=0) {
+ if (inspected_object_id != 0) {
//take the chance and re-inspect selected object
Array msg;
msg.push_back("inspect_object");
@@ -919,9 +847,9 @@ void ScriptEditorDebugger::_notification(int p_what) {
}
}
- inspect_edited_object_timeout-=get_process_delta_time();
- if (inspect_edited_object_timeout<0) {
- inspect_edited_object_timeout=EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
+ inspect_edited_object_timeout -= get_process_delta_time();
+ if (inspect_edited_object_timeout < 0) {
+ inspect_edited_object_timeout = EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
if (inspect_scene_tree->is_visible_in_tree() && inspected_object_id) {
//take the chance and re-inspect selected object
Array msg;
@@ -932,20 +860,20 @@ void ScriptEditorDebugger::_notification(int p_what) {
}
}
- if (error_count!=last_error_count) {
+ if (error_count != last_error_count) {
- if (error_count==0) {
+ if (error_count == 0) {
error_split->set_name(TTR("Errors"));
debugger_button->set_text(TTR("Debugger"));
debugger_button->set_icon(Ref<Texture>());
- tabs->set_tab_icon(error_split->get_index(),Ref<Texture>());
+ tabs->set_tab_icon(error_split->get_index(), Ref<Texture>());
} else {
- error_split->set_name(TTR("Errors")+" ("+itos(error_count)+")");
- debugger_button->set_text(TTR("Debugger")+" ("+itos(error_count)+")");
- debugger_button->set_icon(get_icon("Error","EditorIcons"));
- tabs->set_tab_icon(error_split->get_index(),get_icon("Error","EditorIcons"));
+ error_split->set_name(TTR("Errors") + " (" + itos(error_count) + ")");
+ debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count) + ")");
+ debugger_button->set_icon(get_icon("Error", "EditorIcons"));
+ tabs->set_tab_icon(error_split->get_index(), get_icon("Error", "EditorIcons"));
}
- last_error_count=error_count;
+ last_error_count = error_count;
}
if (connection.is_null()) {
@@ -975,7 +903,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
le_clear->set_disabled(false);
error_list->clear();
error_stack->clear();
- error_count=0;
+ error_count = 0;
profiler_signature.clear();
//live_edit_root->set_text("/root");
@@ -987,7 +915,6 @@ void ScriptEditorDebugger::_notification(int p_what) {
_profiler_activate(true);
}
-
} else {
break;
@@ -1004,86 +931,76 @@ void ScriptEditorDebugger::_notification(int p_what) {
break;
};
- while(ppeer->get_available_packet_count() > 0) {
+ while (ppeer->get_available_packet_count() > 0) {
if (pending_in_queue) {
- int todo = MIN( ppeer->get_available_packet_count(), pending_in_queue );
+ int todo = MIN(ppeer->get_available_packet_count(), pending_in_queue);
- for(int i=0;i<todo;i++) {
+ for (int i = 0; i < todo; i++) {
Variant cmd;
Error ret = ppeer->get_var(cmd);
- if (ret!=OK) {
+ if (ret != OK) {
stop();
- ERR_FAIL_COND(ret!=OK);
+ ERR_FAIL_COND(ret != OK);
}
message.push_back(cmd);
pending_in_queue--;
}
-
- if (pending_in_queue==0) {
- _parse_message(message_type,message);
+ if (pending_in_queue == 0) {
+ _parse_message(message_type, message);
message.clear();
-
}
-
} else {
- if (ppeer->get_available_packet_count()>=2) {
-
+ if (ppeer->get_available_packet_count() >= 2) {
Variant cmd;
Error ret = ppeer->get_var(cmd);
- if (ret!=OK) {
+ if (ret != OK) {
stop();
- ERR_FAIL_COND(ret!=OK);
+ ERR_FAIL_COND(ret != OK);
}
- if (cmd.get_type()!=Variant::STRING) {
+ if (cmd.get_type() != Variant::STRING) {
stop();
- ERR_FAIL_COND(cmd.get_type()!=Variant::STRING);
+ ERR_FAIL_COND(cmd.get_type() != Variant::STRING);
}
- message_type=cmd;
+ message_type = cmd;
//print_line("GOT: "+message_type);
ret = ppeer->get_var(cmd);
- if (ret!=OK) {
+ if (ret != OK) {
stop();
- ERR_FAIL_COND(ret!=OK);
+ ERR_FAIL_COND(ret != OK);
}
- if (cmd.get_type()!=Variant::INT) {
+ if (cmd.get_type() != Variant::INT) {
stop();
- ERR_FAIL_COND(cmd.get_type()!=Variant::INT);
+ ERR_FAIL_COND(cmd.get_type() != Variant::INT);
}
- pending_in_queue=cmd;
+ pending_in_queue = cmd;
- if (pending_in_queue==0) {
- _parse_message(message_type,Array());
+ if (pending_in_queue == 0) {
+ _parse_message(message_type, Array());
message.clear();
}
} else {
-
break;
}
-
}
}
-
-
} break;
}
-
}
-
void ScriptEditorDebugger::start() {
stop();
@@ -1094,28 +1011,22 @@ void ScriptEditorDebugger::start() {
uint16_t port = GLOBAL_GET("network/debug/remote_port");
perf_history.clear();
- for(int i=0;i<Performance::MONITOR_MAX;i++) {
+ for (int i = 0; i < Performance::MONITOR_MAX; i++) {
- perf_max[i]=0;
+ perf_max[i] = 0;
}
server->listen(port);
set_process(true);
-
}
-void ScriptEditorDebugger::pause(){
-
-
+void ScriptEditorDebugger::pause() {
}
-void ScriptEditorDebugger::unpause(){
-
-
+void ScriptEditorDebugger::unpause() {
}
-void ScriptEditorDebugger::stop(){
-
+void ScriptEditorDebugger::stop() {
set_process(false);
@@ -1128,7 +1039,7 @@ void ScriptEditorDebugger::stop(){
connection.unref();
}
- pending_in_queue=0;
+ pending_in_queue = 0;
message.clear();
node_path_cache.clear();
@@ -1144,14 +1055,11 @@ void ScriptEditorDebugger::stop(){
EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
EditorNode::get_singleton()->get_pause_button()->set_disabled(true);
-
-
if (hide_on_stop) {
if (is_visible_in_tree())
EditorNode::get_singleton()->hide_bottom_panel();
- emit_signal("show_debugger",false);
+ emit_signal("show_debugger", false);
}
-
}
void ScriptEditorDebugger::_profiler_activate(bool p_enable) {
@@ -1159,13 +1067,12 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable) {
if (!connection.is_valid())
return;
-
if (p_enable) {
profiler_signature.clear();
Array msg;
msg.push_back("start_profiling");
int max_funcs = EditorSettings::get_singleton()->get("debugger/profiler_frame_max_functions");
- max_funcs = CLAMP(max_funcs,16,512);
+ max_funcs = CLAMP(max_funcs, 16, 512);
msg.push_back(max_funcs);
ppeer->put_var(msg);
@@ -1177,9 +1084,7 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable) {
ppeer->put_var(msg);
print_line("END PROFILING!");
-
}
-
}
void ScriptEditorDebugger::_profiler_seeked() {
@@ -1192,18 +1097,16 @@ void ScriptEditorDebugger::_profiler_seeked() {
debug_break();
}
-
void ScriptEditorDebugger::_stack_dump_frame_selected() {
TreeItem *ti = stack_dump->get_selected();
if (!ti)
return;
-
Dictionary d = ti->get_metadata(0);
Ref<Script> s = ResourceLoader::load(d["file"]);
- emit_signal("goto_script_line",s,int(d["line"])-1);
+ emit_signal("goto_script_line", s, int(d["line"]) - 1);
ERR_FAIL_COND(connection.is_null());
ERR_FAIL_COND(!connection->is_connected_to_host());
@@ -1213,23 +1116,21 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() {
msg.push_back("get_stack_frame_vars");
msg.push_back(d["frame"]);
ppeer->put_var(msg);
-
}
void ScriptEditorDebugger::_output_clear() {
//output->clear();
//output->push_color(Color(0,0,0));
-
}
-String ScriptEditorDebugger::get_var_value(const String& p_var) const {
+String ScriptEditorDebugger::get_var_value(const String &p_var) const {
if (!breaked)
return String();
return variables->get_var_value(p_var);
}
-int ScriptEditorDebugger::_get_node_path_cache(const NodePath& p_path) {
+int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) {
const int *r = node_path_cache.getptr(p_path);
if (r)
@@ -1237,38 +1138,36 @@ int ScriptEditorDebugger::_get_node_path_cache(const NodePath& p_path) {
last_path_id++;
- node_path_cache[p_path]=last_path_id;
+ node_path_cache[p_path] = last_path_id;
Array msg;
msg.push_back("live_node_path");
msg.push_back(p_path);
msg.push_back(last_path_id);
ppeer->put_var(msg);
-
return last_path_id;
}
-int ScriptEditorDebugger::_get_res_path_cache(const String& p_path) {
+int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) {
- Map<String,int>::Element *E=res_path_cache.find(p_path);
+ Map<String, int>::Element *E = res_path_cache.find(p_path);
if (E)
return E->get();
last_path_id++;
- res_path_cache[p_path]=last_path_id;
+ res_path_cache[p_path] = last_path_id;
Array msg;
msg.push_back("live_res_path");
msg.push_back(p_path);
msg.push_back(last_path_id);
ppeer->put_var(msg);
-
return last_path_id;
}
-void ScriptEditorDebugger::_method_changed(Object*p_base,const StringName& p_name,VARIANT_ARG_DECLARE) {
+void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) {
if (!p_base || !live_debug || !connection.is_valid() || !editor->get_edited_scene())
return;
@@ -1277,9 +1176,9 @@ void ScriptEditorDebugger::_method_changed(Object*p_base,const StringName& p_nam
VARIANT_ARGPTRS
- for(int i=0;i<VARIANT_ARG_MAX;i++) {
+ for (int i = 0; i < VARIANT_ARG_MAX; i++) {
//no pointers, sorry
- if (argptr[i] && (argptr[i]->get_type()==Variant::OBJECT || argptr[i]->get_type()==Variant::_RID))
+ if (argptr[i] && (argptr[i]->get_type() == Variant::OBJECT || argptr[i]->get_type() == Variant::_RID))
return;
}
@@ -1288,25 +1187,22 @@ void ScriptEditorDebugger::_method_changed(Object*p_base,const StringName& p_nam
NodePath path = editor->get_edited_scene()->get_path_to(node);
int pathid = _get_node_path_cache(path);
-
-
Array msg;
msg.push_back("live_node_call");
msg.push_back(pathid);
msg.push_back(p_name);
- for(int i=0;i<VARIANT_ARG_MAX;i++) {
+ for (int i = 0; i < VARIANT_ARG_MAX; i++) {
//no pointers, sorry
msg.push_back(*argptr[i]);
}
ppeer->put_var(msg);
return;
-
}
Resource *res = p_base->cast_to<Resource>();
- if (res && res->get_path()!=String()) {
+ if (res && res->get_path() != String()) {
String respath = res->get_path();
int pathid = _get_res_path_cache(respath);
@@ -1315,7 +1211,7 @@ void ScriptEditorDebugger::_method_changed(Object*p_base,const StringName& p_nam
msg.push_back("live_res_call");
msg.push_back(pathid);
msg.push_back(p_name);
- for(int i=0;i<VARIANT_ARG_MAX;i++) {
+ for (int i = 0; i < VARIANT_ARG_MAX; i++) {
//no pointers, sorry
msg.push_back(*argptr[i]);
}
@@ -1327,7 +1223,7 @@ void ScriptEditorDebugger::_method_changed(Object*p_base,const StringName& p_nam
//print_line("method");
}
-void ScriptEditorDebugger::_property_changed(Object*p_base,const StringName& p_property,const Variant& p_value){
+void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p_property, const Variant &p_value) {
if (!p_base || !live_debug || !connection.is_valid() || !editor->get_edited_scene())
return;
@@ -1339,10 +1235,9 @@ void ScriptEditorDebugger::_property_changed(Object*p_base,const StringName& p_p
NodePath path = editor->get_edited_scene()->get_path_to(node);
int pathid = _get_node_path_cache(path);
-
if (p_value.is_ref()) {
Ref<Resource> res = p_value;
- if (res.is_valid() && res->get_path()!=String()) {
+ if (res.is_valid() && res->get_path() != String()) {
Array msg;
msg.push_back("live_node_prop_res");
@@ -1361,22 +1256,19 @@ void ScriptEditorDebugger::_property_changed(Object*p_base,const StringName& p_p
ppeer->put_var(msg);
}
-
return;
-
}
Resource *res = p_base->cast_to<Resource>();
- if (res && res->get_path()!=String()) {
+ if (res && res->get_path() != String()) {
String respath = res->get_path();
int pathid = _get_res_path_cache(respath);
-
if (p_value.is_ref()) {
Ref<Resource> res = p_value;
- if (res.is_valid() && res->get_path()!=String()) {
+ if (res.is_valid() && res->get_path() != String()) {
Array msg;
msg.push_back("live_res_prop_res");
@@ -1395,32 +1287,27 @@ void ScriptEditorDebugger::_property_changed(Object*p_base,const StringName& p_p
ppeer->put_var(msg);
}
-
return;
}
-
//print_line("prop");
}
-void ScriptEditorDebugger::_method_changeds(void *p_ud,Object*p_base,const StringName& p_name,VARIANT_ARG_DECLARE) {
-
- ScriptEditorDebugger *sed = (ScriptEditorDebugger*)p_ud;
- sed->_method_changed(p_base,p_name,VARIANT_ARG_PASS);
-
+void ScriptEditorDebugger::_method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) {
+ ScriptEditorDebugger *sed = (ScriptEditorDebugger *)p_ud;
+ sed->_method_changed(p_base, p_name, VARIANT_ARG_PASS);
}
-void ScriptEditorDebugger::_property_changeds(void *p_ud,Object*p_base,const StringName& p_property,const Variant& p_value){
-
- ScriptEditorDebugger *sed = (ScriptEditorDebugger*)p_ud;
- sed->_property_changed(p_base,p_property,p_value);
+void ScriptEditorDebugger::_property_changeds(void *p_ud, Object *p_base, const StringName &p_property, const Variant &p_value) {
+ ScriptEditorDebugger *sed = (ScriptEditorDebugger *)p_ud;
+ sed->_property_changed(p_base, p_property, p_value);
}
void ScriptEditorDebugger::set_live_debugging(bool p_enable) {
- live_debug=p_enable;
+ live_debug = p_enable;
}
void ScriptEditorDebugger::_live_edit_set() {
@@ -1428,16 +1315,15 @@ void ScriptEditorDebugger::_live_edit_set() {
if (!connection.is_valid())
return;
- TreeItem* ti = inspect_scene_tree->get_selected();
+ TreeItem *ti = inspect_scene_tree->get_selected();
if (!ti)
return;
String path;
- while(ti) {
- String lp=ti->get_text(0);
- path="/"+lp+path;
- ti=ti->get_parent();
-
+ while (ti) {
+ String lp = ti->get_text(0);
+ path = "/" + lp + path;
+ ti = ti->get_parent();
}
NodePath np = path;
@@ -1445,8 +1331,6 @@ void ScriptEditorDebugger::_live_edit_set() {
editor->get_editor_data().set_edited_scene_live_edit_root(np);
update_live_edit_root();
-
-
}
void ScriptEditorDebugger::_live_edit_clear() {
@@ -1455,7 +1339,6 @@ void ScriptEditorDebugger::_live_edit_clear() {
editor->get_editor_data().set_edited_scene_live_edit_root(np);
update_live_edit_root();
-
}
void ScriptEditorDebugger::update_live_edit_root() {
@@ -1473,10 +1356,9 @@ void ScriptEditorDebugger::update_live_edit_root() {
ppeer->put_var(msg);
}
live_edit_root->set_text(np);
-
}
-void ScriptEditorDebugger::live_debug_create_node(const NodePath& p_parent,const String& p_type,const String& p_name) {
+void ScriptEditorDebugger::live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name) {
if (live_debug && connection.is_valid()) {
Array msg;
@@ -1488,7 +1370,7 @@ void ScriptEditorDebugger::live_debug_create_node(const NodePath& p_parent,const
}
}
-void ScriptEditorDebugger::live_debug_instance_node(const NodePath& p_parent,const String& p_path,const String& p_name){
+void ScriptEditorDebugger::live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name) {
if (live_debug && connection.is_valid()) {
Array msg;
@@ -1498,9 +1380,8 @@ void ScriptEditorDebugger::live_debug_instance_node(const NodePath& p_parent,con
msg.push_back(p_name);
ppeer->put_var(msg);
}
-
}
-void ScriptEditorDebugger::live_debug_remove_node(const NodePath& p_at){
+void ScriptEditorDebugger::live_debug_remove_node(const NodePath &p_at) {
if (live_debug && connection.is_valid()) {
Array msg;
@@ -1508,9 +1389,8 @@ void ScriptEditorDebugger::live_debug_remove_node(const NodePath& p_at){
msg.push_back(p_at);
ppeer->put_var(msg);
}
-
}
-void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath& p_at,ObjectID p_keep_id) {
+void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id) {
if (live_debug && connection.is_valid()) {
Array msg;
@@ -1519,9 +1399,8 @@ void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath& p_at,
msg.push_back(p_keep_id);
ppeer->put_var(msg);
}
-
}
-void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath& p_at, int p_at_pos){
+void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos) {
if (live_debug && connection.is_valid()) {
Array msg;
@@ -1531,9 +1410,8 @@ void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath
msg.push_back(p_at_pos);
ppeer->put_var(msg);
}
-
}
-void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath& p_at,const String& p_new_name){
+void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name) {
if (live_debug && connection.is_valid()) {
Array msg;
@@ -1542,9 +1420,8 @@ void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath& p_at,const
msg.push_back(p_new_name);
ppeer->put_var(msg);
}
-
}
-void ScriptEditorDebugger::live_debug_reparent_node(const NodePath& p_at, const NodePath& p_new_place, const String &p_new_name, int p_at_pos){
+void ScriptEditorDebugger::live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) {
if (live_debug && connection.is_valid()) {
Array msg;
@@ -1555,67 +1432,62 @@ void ScriptEditorDebugger::live_debug_reparent_node(const NodePath& p_at, const
msg.push_back(p_at_pos);
ppeer->put_var(msg);
}
-
}
-void ScriptEditorDebugger::set_breakpoint(const String& p_path,int p_line,bool p_enabled) {
+void ScriptEditorDebugger::set_breakpoint(const String &p_path, int p_line, bool p_enabled) {
if (connection.is_valid()) {
- Array msg;
- msg.push_back("breakpoint");
- msg.push_back(p_path);
- msg.push_back(p_line);
- msg.push_back(p_enabled);
- ppeer->put_var(msg);
- }
+ Array msg;
+ msg.push_back("breakpoint");
+ msg.push_back(p_path);
+ msg.push_back(p_line);
+ msg.push_back(p_enabled);
+ ppeer->put_var(msg);
+ }
}
-
void ScriptEditorDebugger::reload_scripts() {
if (connection.is_valid()) {
- Array msg;
- msg.push_back("reload_scripts");
- ppeer->put_var(msg);
- }
+ Array msg;
+ msg.push_back("reload_scripts");
+ ppeer->put_var(msg);
+ }
}
-
void ScriptEditorDebugger::_error_selected(int p_idx) {
error_stack->clear();
- Array st=error_list->get_item_metadata(p_idx);
- for(int i=0;i<st.size();i+=2) {
+ Array st = error_list->get_item_metadata(p_idx);
+ for (int i = 0; i < st.size(); i += 2) {
- String script=st[i];
- int line=st[i+1];
+ String script = st[i];
+ int line = st[i + 1];
Array md;
md.push_back(st[i]);
- md.push_back(st[i+1]);
+ md.push_back(st[i + 1]);
- String str = script.get_file()+":"+itos(line);
+ String str = script.get_file() + ":" + itos(line);
error_stack->add_item(str);
- error_stack->set_item_metadata(error_stack->get_item_count()-1,md);
- error_stack->set_item_tooltip(error_stack->get_item_count()-1,TTR("File:")+" "+String(st[i])+"\n"+TTR("Line:")+" "+itos(line));
+ error_stack->set_item_metadata(error_stack->get_item_count() - 1, md);
+ error_stack->set_item_tooltip(error_stack->get_item_count() - 1, TTR("File:") + " " + String(st[i]) + "\n" + TTR("Line:") + " " + itos(line));
}
}
-void ScriptEditorDebugger:: _error_stack_selected(int p_idx){
+void ScriptEditorDebugger::_error_stack_selected(int p_idx) {
Array arr = error_stack->get_item_metadata(p_idx);
- if (arr.size()!=2)
+ if (arr.size() != 2)
return;
-
Ref<Script> s = ResourceLoader::load(arr[0]);
- emit_signal("goto_script_line",s,int(arr[1])-1);
-
+ emit_signal("goto_script_line", s, int(arr[1]) - 1);
}
void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) {
- hide_on_stop=p_hide;
+ hide_on_stop = p_hide;
}
void ScriptEditorDebugger::_paused() {
@@ -1630,180 +1502,169 @@ void ScriptEditorDebugger::_paused() {
if (breaked && !EditorNode::get_singleton()->get_pause_button()->is_pressed()) {
debug_continue();
}
-
}
void ScriptEditorDebugger::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"),&ScriptEditorDebugger::_stack_dump_frame_selected);
- ClassDB::bind_method(D_METHOD("debug_next"),&ScriptEditorDebugger::debug_next);
- ClassDB::bind_method(D_METHOD("debug_step"),&ScriptEditorDebugger::debug_step);
- ClassDB::bind_method(D_METHOD("debug_break"),&ScriptEditorDebugger::debug_break);
- ClassDB::bind_method(D_METHOD("debug_continue"),&ScriptEditorDebugger::debug_continue);
- ClassDB::bind_method(D_METHOD("_output_clear"),&ScriptEditorDebugger::_output_clear);
- ClassDB::bind_method(D_METHOD("_performance_draw"),&ScriptEditorDebugger::_performance_draw);
- ClassDB::bind_method(D_METHOD("_performance_select"),&ScriptEditorDebugger::_performance_select);
- ClassDB::bind_method(D_METHOD("_scene_tree_request"),&ScriptEditorDebugger::_scene_tree_request);
- ClassDB::bind_method(D_METHOD("_video_mem_request"),&ScriptEditorDebugger::_video_mem_request);
- ClassDB::bind_method(D_METHOD("_live_edit_set"),&ScriptEditorDebugger::_live_edit_set);
- ClassDB::bind_method(D_METHOD("_live_edit_clear"),&ScriptEditorDebugger::_live_edit_clear);
-
- ClassDB::bind_method(D_METHOD("_error_selected"),&ScriptEditorDebugger::_error_selected);
- ClassDB::bind_method(D_METHOD("_error_stack_selected"),&ScriptEditorDebugger::_error_stack_selected);
- ClassDB::bind_method(D_METHOD("_profiler_activate"),&ScriptEditorDebugger::_profiler_activate);
- ClassDB::bind_method(D_METHOD("_profiler_seeked"),&ScriptEditorDebugger::_profiler_seeked);
-
- ClassDB::bind_method(D_METHOD("_paused"),&ScriptEditorDebugger::_paused);
-
- ClassDB::bind_method(D_METHOD("_scene_tree_selected"),&ScriptEditorDebugger::_scene_tree_selected);
- ClassDB::bind_method(D_METHOD("_scene_tree_folded"),&ScriptEditorDebugger::_scene_tree_folded);
-
-
- ClassDB::bind_method(D_METHOD("live_debug_create_node"),&ScriptEditorDebugger::live_debug_create_node);
- ClassDB::bind_method(D_METHOD("live_debug_instance_node"),&ScriptEditorDebugger::live_debug_instance_node);
- ClassDB::bind_method(D_METHOD("live_debug_remove_node"),&ScriptEditorDebugger::live_debug_remove_node);
- ClassDB::bind_method(D_METHOD("live_debug_remove_and_keep_node"),&ScriptEditorDebugger::live_debug_remove_and_keep_node);
- ClassDB::bind_method(D_METHOD("live_debug_restore_node"),&ScriptEditorDebugger::live_debug_restore_node);
- ClassDB::bind_method(D_METHOD("live_debug_duplicate_node"),&ScriptEditorDebugger::live_debug_duplicate_node);
- ClassDB::bind_method(D_METHOD("live_debug_reparent_node"),&ScriptEditorDebugger::live_debug_reparent_node);
- ClassDB::bind_method(D_METHOD("_scene_tree_property_select_object"),&ScriptEditorDebugger::_scene_tree_property_select_object);
- ClassDB::bind_method(D_METHOD("_scene_tree_property_value_edited"),&ScriptEditorDebugger::_scene_tree_property_value_edited);
+ ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected);
+ ClassDB::bind_method(D_METHOD("debug_next"), &ScriptEditorDebugger::debug_next);
+ ClassDB::bind_method(D_METHOD("debug_step"), &ScriptEditorDebugger::debug_step);
+ ClassDB::bind_method(D_METHOD("debug_break"), &ScriptEditorDebugger::debug_break);
+ ClassDB::bind_method(D_METHOD("debug_continue"), &ScriptEditorDebugger::debug_continue);
+ ClassDB::bind_method(D_METHOD("_output_clear"), &ScriptEditorDebugger::_output_clear);
+ ClassDB::bind_method(D_METHOD("_performance_draw"), &ScriptEditorDebugger::_performance_draw);
+ ClassDB::bind_method(D_METHOD("_performance_select"), &ScriptEditorDebugger::_performance_select);
+ ClassDB::bind_method(D_METHOD("_scene_tree_request"), &ScriptEditorDebugger::_scene_tree_request);
+ ClassDB::bind_method(D_METHOD("_video_mem_request"), &ScriptEditorDebugger::_video_mem_request);
+ ClassDB::bind_method(D_METHOD("_live_edit_set"), &ScriptEditorDebugger::_live_edit_set);
+ ClassDB::bind_method(D_METHOD("_live_edit_clear"), &ScriptEditorDebugger::_live_edit_clear);
+
+ ClassDB::bind_method(D_METHOD("_error_selected"), &ScriptEditorDebugger::_error_selected);
+ ClassDB::bind_method(D_METHOD("_error_stack_selected"), &ScriptEditorDebugger::_error_stack_selected);
+ ClassDB::bind_method(D_METHOD("_profiler_activate"), &ScriptEditorDebugger::_profiler_activate);
+ ClassDB::bind_method(D_METHOD("_profiler_seeked"), &ScriptEditorDebugger::_profiler_seeked);
+
+ ClassDB::bind_method(D_METHOD("_paused"), &ScriptEditorDebugger::_paused);
+
+ ClassDB::bind_method(D_METHOD("_scene_tree_selected"), &ScriptEditorDebugger::_scene_tree_selected);
+ ClassDB::bind_method(D_METHOD("_scene_tree_folded"), &ScriptEditorDebugger::_scene_tree_folded);
+
+ ClassDB::bind_method(D_METHOD("live_debug_create_node"), &ScriptEditorDebugger::live_debug_create_node);
+ ClassDB::bind_method(D_METHOD("live_debug_instance_node"), &ScriptEditorDebugger::live_debug_instance_node);
+ ClassDB::bind_method(D_METHOD("live_debug_remove_node"), &ScriptEditorDebugger::live_debug_remove_node);
+ ClassDB::bind_method(D_METHOD("live_debug_remove_and_keep_node"), &ScriptEditorDebugger::live_debug_remove_and_keep_node);
+ ClassDB::bind_method(D_METHOD("live_debug_restore_node"), &ScriptEditorDebugger::live_debug_restore_node);
+ ClassDB::bind_method(D_METHOD("live_debug_duplicate_node"), &ScriptEditorDebugger::live_debug_duplicate_node);
+ ClassDB::bind_method(D_METHOD("live_debug_reparent_node"), &ScriptEditorDebugger::live_debug_reparent_node);
+ ClassDB::bind_method(D_METHOD("_scene_tree_property_select_object"), &ScriptEditorDebugger::_scene_tree_property_select_object);
+ ClassDB::bind_method(D_METHOD("_scene_tree_property_value_edited"), &ScriptEditorDebugger::_scene_tree_property_value_edited);
ADD_SIGNAL(MethodInfo("goto_script_line"));
- ADD_SIGNAL(MethodInfo("breaked",PropertyInfo(Variant::BOOL,"reallydid"),PropertyInfo(Variant::BOOL,"can_debug")));
- ADD_SIGNAL(MethodInfo("show_debugger",PropertyInfo(Variant::BOOL,"reallydid")));
+ ADD_SIGNAL(MethodInfo("breaked", PropertyInfo(Variant::BOOL, "reallydid"), PropertyInfo(Variant::BOOL, "can_debug")));
+ ADD_SIGNAL(MethodInfo("show_debugger", PropertyInfo(Variant::BOOL, "reallydid")));
}
-ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
-
-
+ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
- ppeer = Ref<PacketPeerStream>( memnew( PacketPeerStream ) );
- editor=p_editor;
+ ppeer = Ref<PacketPeerStream>(memnew(PacketPeerStream));
+ editor = p_editor;
- tabs = memnew( TabContainer );
+ tabs = memnew(TabContainer);
tabs->set_v_size_flags(SIZE_EXPAND_FILL);
tabs->set_area_as_parent_rect();
add_child(tabs);
-
{ //debugger
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
vbc->set_name(TTR("Debugger"));
//tabs->add_child(vbc);
- Control *dbg=vbc;
+ Control *dbg = vbc;
- HBoxContainer *hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
vbc->add_child(hbc);
-
- reason = memnew( LineEdit );
+ reason = memnew(LineEdit);
reason->set_text("");
reason->set_editable(false);
hbc->add_child(reason);
- reason->add_color_override("font_color",Color(1,0.4,0.0,0.8));
+ reason->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8));
reason->set_h_size_flags(SIZE_EXPAND_FILL);
//reason->set_clip_text(true);
- hbc->add_child( memnew( VSeparator) );
+ hbc->add_child(memnew(VSeparator));
- step = memnew( Button );
+ step = memnew(Button);
hbc->add_child(step);
step->set_tooltip(TTR("Step Into"));
- step->connect("pressed",this,"debug_step");
+ step->connect("pressed", this, "debug_step");
- next = memnew( Button );
+ next = memnew(Button);
hbc->add_child(next);
next->set_tooltip(TTR("Step Over"));
- next->connect("pressed",this,"debug_next");
+ next->connect("pressed", this, "debug_next");
- hbc->add_child( memnew( VSeparator) );
+ hbc->add_child(memnew(VSeparator));
- dobreak = memnew( Button );
+ dobreak = memnew(Button);
hbc->add_child(dobreak);
dobreak->set_tooltip(TTR("Break"));
- dobreak->connect("pressed",this,"debug_break");
+ dobreak->connect("pressed", this, "debug_break");
- docontinue = memnew( Button );
+ docontinue = memnew(Button);
hbc->add_child(docontinue);
docontinue->set_tooltip(TTR("Continue"));
- docontinue->connect("pressed",this,"debug_continue");
+ docontinue->connect("pressed", this, "debug_continue");
//hbc->add_child( memnew( VSeparator) );
- back = memnew( Button );
+ back = memnew(Button);
hbc->add_child(back);
back->set_tooltip(TTR("Inspect Previous Instance"));
back->hide();
- forward = memnew( Button );
+ forward = memnew(Button);
hbc->add_child(forward);
forward->set_tooltip(TTR("Inspect Next Instance"));
forward->hide();
-
- HSplitContainer *sc = memnew( HSplitContainer );
+ HSplitContainer *sc = memnew(HSplitContainer);
vbc->add_child(sc);
sc->set_v_size_flags(SIZE_EXPAND_FILL);
- stack_dump = memnew( Tree );
+ stack_dump = memnew(Tree);
stack_dump->set_columns(1);
stack_dump->set_column_titles_visible(true);
- stack_dump->set_column_title(0,TTR("Stack Frames"));
+ stack_dump->set_column_title(0, TTR("Stack Frames"));
stack_dump->set_h_size_flags(SIZE_EXPAND_FILL);
stack_dump->set_hide_root(true);
- stack_dump->connect("cell_selected",this,"_stack_dump_frame_selected");
+ stack_dump->connect("cell_selected", this, "_stack_dump_frame_selected");
sc->add_child(stack_dump);
- inspector = memnew( PropertyEditor );
+ inspector = memnew(PropertyEditor);
inspector->set_h_size_flags(SIZE_EXPAND_FILL);
inspector->hide_top_label();
- inspector->get_scene_tree()->set_column_title(0,TTR("Variable"));
+ inspector->get_scene_tree()->set_column_title(0, TTR("Variable"));
inspector->set_capitalize_paths(false);
inspector->set_read_only(true);
sc->add_child(inspector);
server = TCP_Server::create_ref();
- pending_in_queue=0;
+ pending_in_queue = 0;
- variables = memnew( ScriptEditorDebuggerVariables );
+ variables = memnew(ScriptEditorDebuggerVariables);
- breaked=false;
+ breaked = false;
tabs->add_child(dbg);
//tabs->move_child(vbc,0);
- hbc = memnew( HBoxContainer );
+ hbc = memnew(HBoxContainer);
vbc->add_child(hbc);
-
}
- { //errors
-
+ { //errors
- error_split = memnew( HSplitContainer );
- VBoxContainer *errvb = memnew( VBoxContainer );
+ error_split = memnew(HSplitContainer);
+ VBoxContainer *errvb = memnew(VBoxContainer);
errvb->set_h_size_flags(SIZE_EXPAND_FILL);
- error_list = memnew( ItemList );
- errvb->add_margin_child(TTR("Errors:"),error_list,true);
+ error_list = memnew(ItemList);
+ errvb->add_margin_child(TTR("Errors:"), error_list, true);
error_split->add_child(errvb);
- errvb = memnew( VBoxContainer );
+ errvb = memnew(VBoxContainer);
errvb->set_h_size_flags(SIZE_EXPAND_FILL);
- error_stack = memnew( ItemList );
- errvb->add_margin_child(TTR("Stack Trace (if applicable):"),error_stack,true);
+ error_stack = memnew(ItemList);
+ errvb->add_margin_child(TTR("Stack Trace (if applicable):"), error_stack, true);
error_split->add_child(errvb);
error_split->set_name(TTR("Errors"));
tabs->add_child(error_split);
}
-
{ // inquire
-
- inspect_info = memnew( HSplitContainer );
+ inspect_info = memnew(HSplitContainer);
inspect_info->set_name(TTR("Remote Inspector"));
tabs->add_child(inspect_info);
@@ -1811,10 +1672,10 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
info_left->set_h_size_flags(SIZE_EXPAND_FILL);
inspect_info->add_child(info_left);
- inspect_scene_tree = memnew( Tree );
- info_left->add_margin_child(TTR("Live Scene Tree:"),inspect_scene_tree,true);
- inspect_scene_tree->connect("cell_selected",this,"_scene_tree_selected");
- inspect_scene_tree->connect("item_collapsed",this,"_scene_tree_folded");
+ inspect_scene_tree = memnew(Tree);
+ info_left->add_margin_child(TTR("Live Scene Tree:"), inspect_scene_tree, true);
+ inspect_scene_tree->connect("cell_selected", this, "_scene_tree_selected");
+ inspect_scene_tree->connect("item_collapsed", this, "_scene_tree_folded");
//
@@ -1822,95 +1683,93 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
info_right->set_h_size_flags(SIZE_EXPAND_FILL);
inspect_info->add_child(info_right);
- inspect_properties = memnew( PropertyEditor );
+ inspect_properties = memnew(PropertyEditor);
inspect_properties->hide_top_label();
inspect_properties->set_show_categories(true);
- inspect_properties->connect("object_id_selected",this,"_scene_tree_property_select_object");
+ inspect_properties->connect("object_id_selected", this, "_scene_tree_property_select_object");
- info_right->add_margin_child(TTR("Remote Object Properties: "),inspect_properties,true);
+ info_right->add_margin_child(TTR("Remote Object Properties: "), inspect_properties, true);
- inspect_scene_tree_timeout=EDITOR_DEF("debugger/scene_tree_refresh_interval",1.0);
- inspect_edited_object_timeout=EDITOR_DEF("debugger/remote_inspect_refresh_interval",0.2);
- inspected_object_id=0;
- updating_scene_tree=false;
+ inspect_scene_tree_timeout = EDITOR_DEF("debugger/scene_tree_refresh_interval", 1.0);
+ inspect_edited_object_timeout = EDITOR_DEF("debugger/remote_inspect_refresh_interval", 0.2);
+ inspected_object_id = 0;
+ updating_scene_tree = false;
- inspected_object = memnew( ScriptEditorDebuggerInspectedObject );
- inspected_object->connect("value_edited",this,"_scene_tree_property_value_edited");
+ inspected_object = memnew(ScriptEditorDebuggerInspectedObject);
+ inspected_object->connect("value_edited", this, "_scene_tree_property_value_edited");
}
{ //profiler
- profiler = memnew( EditorProfiler );
+ profiler = memnew(EditorProfiler);
profiler->set_name(TTR("Profiler"));
tabs->add_child(profiler);
- profiler->connect("enable_profiling",this,"_profiler_activate");
- profiler->connect("break_request",this,"_profiler_seeked");
+ profiler->connect("enable_profiling", this, "_profiler_activate");
+ profiler->connect("break_request", this, "_profiler_seeked");
}
-
{ //monitors
- HSplitContainer *hsp = memnew( HSplitContainer );
+ HSplitContainer *hsp = memnew(HSplitContainer);
perf_monitors = memnew(Tree);
perf_monitors->set_columns(2);
- perf_monitors->set_column_title(0,TTR("Monitor"));
- perf_monitors->set_column_title(1,TTR("Value"));
+ perf_monitors->set_column_title(0, TTR("Monitor"));
+ perf_monitors->set_column_title(1, TTR("Value"));
perf_monitors->set_column_titles_visible(true);
hsp->add_child(perf_monitors);
perf_monitors->set_select_mode(Tree::SELECT_MULTI);
- perf_monitors->connect("multi_selected",this,"_performance_select");
- perf_draw = memnew( Control );
- perf_draw->connect("draw",this,"_performance_draw");
+ perf_monitors->connect("multi_selected", this, "_performance_select");
+ perf_draw = memnew(Control);
+ perf_draw->connect("draw", this, "_performance_draw");
hsp->add_child(perf_draw);
hsp->set_name(TTR("Monitors"));
hsp->set_split_offset(300);
tabs->add_child(hsp);
perf_max.resize(Performance::MONITOR_MAX);
- Map<String,TreeItem*> bases;
- TreeItem *root=perf_monitors->create_item();
+ Map<String, TreeItem *> bases;
+ TreeItem *root = perf_monitors->create_item();
perf_monitors->set_hide_root(true);
- for(int i=0;i<Performance::MONITOR_MAX;i++) {
+ for (int i = 0; i < Performance::MONITOR_MAX; i++) {
String n = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
- String base = n.get_slice("/",0);
- String name = n.get_slice("/",1);
+ String base = n.get_slice("/", 0);
+ String name = n.get_slice("/", 1);
if (!bases.has(base)) {
TreeItem *b = perf_monitors->create_item(root);
- b->set_text(0,base.capitalize());
- b->set_editable(0,false);
- b->set_selectable(0,false);
- bases[base]=b;
+ b->set_text(0, base.capitalize());
+ b->set_editable(0, false);
+ b->set_selectable(0, false);
+ bases[base] = b;
}
TreeItem *it = perf_monitors->create_item(bases[base]);
- it->set_editable(0,false);
- it->set_selectable(0,true);
- it->set_text(0,name.capitalize());
+ it->set_editable(0, false);
+ it->set_selectable(0, true);
+ it->set_text(0, name.capitalize());
perf_items.push_back(it);
- perf_max[i]=0;
-
+ perf_max[i] = 0;
}
}
{ //vmem inspect
- VBoxContainer *vmem_vb = memnew( VBoxContainer );
- HBoxContainer *vmem_hb = memnew( HBoxContainer );
- Label *vmlb = memnew(Label(TTR("List of Video Memory Usage by Resource:")+" ") );
+ VBoxContainer *vmem_vb = memnew(VBoxContainer);
+ HBoxContainer *vmem_hb = memnew(HBoxContainer);
+ Label *vmlb = memnew(Label(TTR("List of Video Memory Usage by Resource:") + " "));
vmlb->set_h_size_flags(SIZE_EXPAND_FILL);
- vmem_hb->add_child( vmlb );
- vmem_hb->add_child( memnew(Label(TTR("Total:")+" ")) );
- vmem_total = memnew( LineEdit );
+ vmem_hb->add_child(vmlb);
+ vmem_hb->add_child(memnew(Label(TTR("Total:") + " ")));
+ vmem_total = memnew(LineEdit);
vmem_total->set_editable(false);
- vmem_total->set_custom_minimum_size(Size2(100,1)*EDSCALE);
+ vmem_total->set_custom_minimum_size(Size2(100, 1) * EDSCALE);
vmem_hb->add_child(vmem_total);
- vmem_refresh = memnew( Button );
+ vmem_refresh = memnew(Button);
vmem_hb->add_child(vmem_refresh);
vmem_vb->add_child(vmem_hb);
- vmem_refresh->connect("pressed",this,"_video_mem_request");
+ vmem_refresh->connect("pressed", this, "_video_mem_request");
- MarginContainer *vmmc = memnew( MarginContainer );
- vmem_tree = memnew( Tree );
+ MarginContainer *vmmc = memnew(MarginContainer);
+ vmem_tree = memnew(Tree);
vmem_tree->set_v_size_flags(SIZE_EXPAND_FILL);
vmem_tree->set_h_size_flags(SIZE_EXPAND_FILL);
vmmc->add_child(vmem_tree);
@@ -1920,69 +1779,64 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
vmem_vb->set_name(TTR("Video Mem"));
vmem_tree->set_columns(4);
vmem_tree->set_column_titles_visible(true);
- vmem_tree->set_column_title(0,TTR("Resource Path"));
- vmem_tree->set_column_expand(0,true);
- vmem_tree->set_column_expand(1,false);
- vmem_tree->set_column_title(1,TTR("Type"));
- vmem_tree->set_column_min_width(1,100);
- vmem_tree->set_column_expand(2,false);
- vmem_tree->set_column_title(2,TTR("Format"));
- vmem_tree->set_column_min_width(2,150);
- vmem_tree->set_column_expand(3,false);
- vmem_tree->set_column_title(3,TTR("Usage"));
- vmem_tree->set_column_min_width(3,80);
+ vmem_tree->set_column_title(0, TTR("Resource Path"));
+ vmem_tree->set_column_expand(0, true);
+ vmem_tree->set_column_expand(1, false);
+ vmem_tree->set_column_title(1, TTR("Type"));
+ vmem_tree->set_column_min_width(1, 100);
+ vmem_tree->set_column_expand(2, false);
+ vmem_tree->set_column_title(2, TTR("Format"));
+ vmem_tree->set_column_min_width(2, 150);
+ vmem_tree->set_column_expand(3, false);
+ vmem_tree->set_column_title(3, TTR("Usage"));
+ vmem_tree->set_column_min_width(3, 80);
vmem_tree->set_hide_root(true);
tabs->add_child(vmem_vb);
}
{ // misc
- VBoxContainer *info_left = memnew( VBoxContainer );
+ VBoxContainer *info_left = memnew(VBoxContainer);
info_left->set_h_size_flags(SIZE_EXPAND_FILL);
info_left->set_name(TTR("Misc"));
tabs->add_child(info_left);
- clicked_ctrl = memnew( LineEdit );
- info_left->add_margin_child(TTR("Clicked Control:"),clicked_ctrl);
- clicked_ctrl_type = memnew( LineEdit );
- info_left->add_margin_child(TTR("Clicked Control Type:"),clicked_ctrl_type);
+ clicked_ctrl = memnew(LineEdit);
+ info_left->add_margin_child(TTR("Clicked Control:"), clicked_ctrl);
+ clicked_ctrl_type = memnew(LineEdit);
+ info_left->add_margin_child(TTR("Clicked Control Type:"), clicked_ctrl_type);
- live_edit_root = memnew( LineEdit );
+ live_edit_root = memnew(LineEdit);
{
- HBoxContainer *lehb = memnew( HBoxContainer );
- Label *l = memnew( Label(TTR("Live Edit Root:")) );
+ HBoxContainer *lehb = memnew(HBoxContainer);
+ Label *l = memnew(Label(TTR("Live Edit Root:")));
lehb->add_child(l);
l->set_h_size_flags(SIZE_EXPAND_FILL);
- le_set = memnew( Button(TTR("Set From Tree")) );
+ le_set = memnew(Button(TTR("Set From Tree")));
lehb->add_child(le_set);
- le_clear = memnew( Button(TTR("Clear")) );
+ le_clear = memnew(Button(TTR("Clear")));
lehb->add_child(le_clear);
info_left->add_child(lehb);
- MarginContainer *mc = memnew( MarginContainer );
+ MarginContainer *mc = memnew(MarginContainer);
mc->add_child(live_edit_root);
info_left->add_child(mc);
le_set->set_disabled(true);
le_clear->set_disabled(true);
}
-
}
-
-
- msgdialog = memnew( AcceptDialog );
+ msgdialog = memnew(AcceptDialog);
add_child(msgdialog);
- p_editor->get_undo_redo()->set_method_notify_callback(_method_changeds,this);
- p_editor->get_undo_redo()->set_property_notify_callback(_property_changeds,this);
- live_debug=false;
- last_path_id=false;
- error_count=0;
- hide_on_stop=true;
- last_error_count=0;
-
- EditorNode::get_singleton()->get_pause_button()->connect("pressed",this,"_paused");
-
+ p_editor->get_undo_redo()->set_method_notify_callback(_method_changeds, this);
+ p_editor->get_undo_redo()->set_property_notify_callback(_property_changeds, this);
+ live_debug = false;
+ last_path_id = false;
+ error_count = 0;
+ hide_on_stop = true;
+ last_error_count = 0;
+ EditorNode::get_singleton()->get_pause_button()->connect("pressed", this, "_paused");
}
ScriptEditorDebugger::~ScriptEditorDebugger() {
@@ -1994,5 +1848,4 @@ ScriptEditorDebugger::~ScriptEditorDebugger() {
server->stop();
memdelete(inspected_object);
-
}
diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h
index a02934bbaf..74fbbf8f4b 100644
--- a/editor/script_editor_debugger.h
+++ b/editor/script_editor_debugger.h
@@ -29,11 +29,11 @@
#ifndef SCRIPT_EDITOR_DEBUGGER_H
#define SCRIPT_EDITOR_DEBUGGER_H
-#include "scene/gui/box_container.h"
-#include "scene/gui/button.h"
-#include "core/io/tcp_server.h"
#include "core/io/packet_peer.h"
+#include "core/io/tcp_server.h"
#include "property_editor.h"
+#include "scene/gui/box_container.h"
+#include "scene/gui/button.h"
class Tree;
class PropertyEditor;
@@ -49,17 +49,14 @@ class HSplitContainer;
class ItemList;
class EditorProfiler;
-
-
class ScriptEditorDebuggerInspectedObject;
class ScriptEditorDebugger : public Control {
- GDCLASS( ScriptEditorDebugger, Control );
+ GDCLASS(ScriptEditorDebugger, Control);
AcceptDialog *msgdialog;
-
Button *debugger_button;
LineEdit *clicked_ctrl;
@@ -68,8 +65,6 @@ class ScriptEditorDebugger : public Control {
Button *le_set;
Button *le_clear;
-
-
Tree *inspect_scene_tree;
HSplitContainer *inspect_info;
PropertyEditor *inspect_properties;
@@ -80,8 +75,6 @@ class ScriptEditorDebugger : public Control {
bool updating_scene_tree;
Set<ObjectID> unfold_cache;
-
-
HSplitContainer *error_split;
ItemList *error_list;
ItemList *error_stack;
@@ -91,8 +84,6 @@ class ScriptEditorDebugger : public Control {
bool hide_on_stop;
-
-
TabContainer *tabs;
LineEdit *reason;
@@ -107,9 +98,9 @@ class ScriptEditorDebugger : public Control {
List<Vector<float> > perf_history;
Vector<float> perf_max;
- Vector<TreeItem*> perf_items;
+ Vector<TreeItem *> perf_items;
- Map<int,String> profiler_signature;
+ Map<int, String> profiler_signature;
Tree *perf_monitors;
Control *perf_draw;
@@ -129,9 +120,9 @@ class ScriptEditorDebugger : public Control {
Array message;
int pending_in_queue;
- HashMap<NodePath,int> node_path_cache;
+ HashMap<NodePath, int> node_path_cache;
int last_path_id;
- Map<String,int> res_path_cache;
+ Map<String, int> res_path_cache;
EditorProfiler *profiler;
@@ -146,28 +137,27 @@ class ScriptEditorDebugger : public Control {
void _stack_dump_frame_selected();
void _output_clear();
-
- void _scene_tree_folded(Object* obj);
+ void _scene_tree_folded(Object *obj);
void _scene_tree_selected();
void _scene_tree_request();
- void _parse_message(const String& p_msg,const Array& p_data);
+ void _parse_message(const String &p_msg, const Array &p_data);
void _scene_tree_property_select_object(ObjectID p_object);
- void _scene_tree_property_value_edited(const String& p_prop,const Variant& p_value);
+ void _scene_tree_property_value_edited(const String &p_prop, const Variant &p_value);
void _video_mem_request();
- int _get_node_path_cache(const NodePath& p_path);
+ int _get_node_path_cache(const NodePath &p_path);
- int _get_res_path_cache(const String& p_path);
+ int _get_res_path_cache(const String &p_path);
void _live_edit_set();
void _live_edit_clear();
- void _method_changed(Object*p_base,const StringName& p_name,VARIANT_ARG_DECLARE);
- void _property_changed(Object*p_base,const StringName& p_property,const Variant& p_value);
+ void _method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE);
+ void _property_changed(Object *p_base, const StringName &p_property, const Variant &p_value);
- static void _method_changeds(void *p_ud,Object*p_base,const StringName& p_name,VARIANT_ARG_DECLARE);
- static void _property_changeds(void *p_ud,Object*p_base,const StringName& p_property,const Variant& p_value);
+ static void _method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE);
+ static void _property_changeds(void *p_ud, Object *p_base, const StringName &p_property, const Variant &p_value);
void _error_selected(int p_idx);
void _error_stack_selected(int p_idx);
@@ -175,17 +165,13 @@ class ScriptEditorDebugger : public Control {
void _profiler_activate(bool p_enable);
void _profiler_seeked();
-
-
void _paused();
protected:
-
void _notification(int p_what);
static void _bind_methods();
public:
-
void start();
void pause();
void unpause();
@@ -196,30 +182,30 @@ public:
void debug_break();
void debug_continue();
- String get_var_value(const String& p_var) const;
+ String get_var_value(const String &p_var) const;
void set_live_debugging(bool p_enable);
- void live_debug_create_node(const NodePath& p_parent,const String& p_type,const String& p_name);
- void live_debug_instance_node(const NodePath& p_parent,const String& p_path,const String& p_name);
- void live_debug_remove_node(const NodePath& p_at);
- void live_debug_remove_and_keep_node(const NodePath& p_at,ObjectID p_keep_id);
- void live_debug_restore_node(ObjectID p_id,const NodePath& p_at,int p_at_pos);
- void live_debug_duplicate_node(const NodePath& p_at,const String& p_new_name);
- void live_debug_reparent_node(const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name,int p_at_pos);
+ void live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name);
+ void live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name);
+ void live_debug_remove_node(const NodePath &p_at);
+ void live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id);
+ void live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos);
+ void live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name);
+ void live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos);
- void set_breakpoint(const String& p_path,int p_line,bool p_enabled);
+ void set_breakpoint(const String &p_path, int p_line, bool p_enabled);
void update_live_edit_root();
void set_hide_on_stop(bool p_hide);
- void set_tool_button(Button *p_tb) { debugger_button=p_tb; }
+ void set_tool_button(Button *p_tb) { debugger_button = p_tb; }
void reload_scripts();
virtual Size2 get_minimum_size() const;
- ScriptEditorDebugger(EditorNode *p_editor=NULL);
+ ScriptEditorDebugger(EditorNode *p_editor = NULL);
~ScriptEditorDebugger();
};
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index 7d8d6ffcec..909ed99da6 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -28,12 +28,12 @@
/*************************************************************************/
#include "settings_config_dialog.h"
-#include "editor_settings.h"
-#include "scene/gui/margin_container.h"
-#include "global_config.h"
#include "editor_file_system.h"
#include "editor_node.h"
+#include "editor_settings.h"
+#include "global_config.h"
#include "os/keyboard.h"
+#include "scene/gui/margin_container.h"
void EditorSettingsDialog::ok_pressed() {
@@ -42,7 +42,6 @@ void EditorSettingsDialog::ok_pressed() {
_settings_save();
timer->stop();
-
}
void EditorSettingsDialog::_settings_changed() {
@@ -50,7 +49,7 @@ void EditorSettingsDialog::_settings_changed() {
timer->start();
}
-void EditorSettingsDialog::_settings_property_edited(const String& p_name) {
+void EditorSettingsDialog::_settings_property_edited(const String &p_name) {
String full_name = property_editor->get_full_item_path(p_name);
@@ -63,10 +62,8 @@ void EditorSettingsDialog::_settings_property_edited(const String& p_name) {
void EditorSettingsDialog::_settings_save() {
-
EditorSettings::get_singleton()->notify_changes();
EditorSettings::get_singleton()->save();
-
}
void EditorSettingsDialog::cancel_pressed() {
@@ -75,10 +72,8 @@ void EditorSettingsDialog::cancel_pressed() {
return;
EditorSettings::get_singleton()->notify_changes();
-
}
-
void EditorSettingsDialog::popup_edit_settings() {
if (!EditorSettings::get_singleton())
@@ -104,7 +99,7 @@ void EditorSettingsDialog::popup_edit_settings() {
void EditorSettingsDialog::_clear_search_box() {
- if (search_box->get_text()=="")
+ if (search_box->get_text() == "")
return;
search_box->clear();
@@ -112,13 +107,13 @@ void EditorSettingsDialog::_clear_search_box() {
}
void EditorSettingsDialog::_clear_shortcut_search_box() {
- if (shortcut_search_box->get_text()=="")
+ if (shortcut_search_box->get_text() == "")
return;
shortcut_search_box->clear();
}
-void EditorSettingsDialog::_filter_shortcuts(const String& p_filter) {
+void EditorSettingsDialog::_filter_shortcuts(const String &p_filter) {
shortcut_filter = p_filter;
_update_shortcuts();
}
@@ -136,7 +131,6 @@ void EditorSettingsDialog::_notification(int p_what) {
}
}
-
void EditorSettingsDialog::_update_shortcuts() {
shortcuts->clear();
@@ -145,9 +139,9 @@ void EditorSettingsDialog::_update_shortcuts() {
EditorSettings::get_singleton()->get_shortcut_list(&slist);
TreeItem *root = shortcuts->create_item();
- Map<String,TreeItem*> sections;
+ Map<String, TreeItem *> sections;
- for(List<String>::Element *E=slist.front();E;E=E->next()) {
+ for (List<String>::Element *E = slist.front(); E; E = E->next()) {
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(E->get());
if (!sc->has_meta("original"))
@@ -155,38 +149,38 @@ void EditorSettingsDialog::_update_shortcuts() {
InputEvent original = sc->get_meta("original");
- String section_name = E->get().get_slice("/",0);
+ String section_name = E->get().get_slice("/", 0);
TreeItem *section;
if (sections.has(section_name)) {
- section=sections[section_name];
+ section = sections[section_name];
} else {
section = shortcuts->create_item(root);
- section->set_text(0,section_name.capitalize());
+ section->set_text(0, section_name.capitalize());
- sections[section_name]=section;
- section->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
- section->set_custom_bg_color(1,get_color("prop_subsection","Editor"));
+ sections[section_name] = section;
+ section->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
+ section->set_custom_bg_color(1, get_color("prop_subsection", "Editor"));
}
if (shortcut_filter.is_subsequence_ofi(sc->get_name())) {
TreeItem *item = shortcuts->create_item(section);
- item->set_text(0,sc->get_name());
- item->set_text(1,sc->get_as_text());
- if (!sc->is_shortcut(original) && !(sc->get_shortcut().type==InputEvent::NONE && original.type==InputEvent::NONE)) {
- item->add_button(1,get_icon("Reload","EditorIcons"),2);
+ item->set_text(0, sc->get_name());
+ item->set_text(1, sc->get_as_text());
+ if (!sc->is_shortcut(original) && !(sc->get_shortcut().type == InputEvent::NONE && original.type == InputEvent::NONE)) {
+ item->add_button(1, get_icon("Reload", "EditorIcons"), 2);
}
- item->add_button(1,get_icon("Edit","EditorIcons"),0);
- item->add_button(1,get_icon("Close","EditorIcons"),1);
- item->set_tooltip(0,E->get());
- item->set_metadata(0,E->get());
+ item->add_button(1, get_icon("Edit", "EditorIcons"), 0);
+ item->add_button(1, get_icon("Close", "EditorIcons"), 1);
+ item->set_tooltip(0, E->get());
+ item->set_metadata(0, E->get());
}
}
// remove sections with no shortcuts
- for(Map<String,TreeItem*>::Element *E=sections.front();E;E=E->next()) {
+ for (Map<String, TreeItem *>::Element *E = sections.front(); E; E = E->next()) {
TreeItem *section = E->get();
if (section->get_children() == NULL) {
root->remove_child(section);
@@ -194,37 +188,37 @@ void EditorSettingsDialog::_update_shortcuts() {
}
}
-void EditorSettingsDialog::_shortcut_button_pressed(Object* p_item,int p_column,int p_idx) {
+void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column, int p_idx) {
- TreeItem *ti=p_item->cast_to<TreeItem>();
+ TreeItem *ti = p_item->cast_to<TreeItem>();
ERR_FAIL_COND(!ti);
String item = ti->get_metadata(0);
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(item);
- if (p_idx==0) {
+ if (p_idx == 0) {
press_a_key_label->set_text(TTR("Press a Key.."));
- last_wait_for_key=InputEvent();
- press_a_key->popup_centered(Size2(250,80)*EDSCALE);
+ last_wait_for_key = InputEvent();
+ press_a_key->popup_centered(Size2(250, 80) * EDSCALE);
press_a_key->grab_focus();
press_a_key->get_ok()->set_focus_mode(FOCUS_NONE);
press_a_key->get_cancel()->set_focus_mode(FOCUS_NONE);
- shortcut_configured=item;
+ shortcut_configured = item;
- } else if (p_idx==1) {//erase
+ } else if (p_idx == 1) { //erase
if (!sc.is_valid())
return; //pointless, there is nothing
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Erase Shortcut");
- ur->add_do_method(sc.ptr(),"set_shortcut",InputEvent());
- ur->add_undo_method(sc.ptr(),"set_shortcut",sc->get_shortcut());
- ur->add_do_method(this,"_update_shortcuts");
- ur->add_undo_method(this,"_update_shortcuts");
- ur->add_do_method(this,"_settings_changed");
- ur->add_undo_method(this,"_settings_changed");
+ ur->add_do_method(sc.ptr(), "set_shortcut", InputEvent());
+ ur->add_undo_method(sc.ptr(), "set_shortcut", sc->get_shortcut());
+ ur->add_do_method(this, "_update_shortcuts");
+ ur->add_undo_method(this, "_update_shortcuts");
+ ur->add_do_method(this, "_settings_changed");
+ ur->add_undo_method(this, "_settings_changed");
ur->commit_action();
- } else if (p_idx==2) {//revert to original
+ } else if (p_idx == 2) { //revert to original
if (!sc.is_valid())
return; //pointless, there is nothing
@@ -232,82 +226,71 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object* p_item,int p_column,
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action("Restore Shortcut");
- ur->add_do_method(sc.ptr(),"set_shortcut",original);
- ur->add_undo_method(sc.ptr(),"set_shortcut",sc->get_shortcut());
- ur->add_do_method(this,"_update_shortcuts");
- ur->add_undo_method(this,"_update_shortcuts");
- ur->add_do_method(this,"_settings_changed");
- ur->add_undo_method(this,"_settings_changed");
+ ur->add_do_method(sc.ptr(), "set_shortcut", original);
+ ur->add_undo_method(sc.ptr(), "set_shortcut", sc->get_shortcut());
+ ur->add_do_method(this, "_update_shortcuts");
+ ur->add_undo_method(this, "_update_shortcuts");
+ ur->add_do_method(this, "_settings_changed");
+ ur->add_undo_method(this, "_settings_changed");
ur->commit_action();
}
}
+void EditorSettingsDialog::_wait_for_key(const InputEvent &p_event) {
-void EditorSettingsDialog::_wait_for_key(const InputEvent& p_event) {
-
+ if (p_event.type == InputEvent::KEY && p_event.key.pressed && p_event.key.scancode != 0) {
- if (p_event.type==InputEvent::KEY && p_event.key.pressed && p_event.key.scancode!=0) {
-
- last_wait_for_key=p_event;
- String str=keycode_get_string(p_event.key.scancode).capitalize();
+ last_wait_for_key = p_event;
+ String str = keycode_get_string(p_event.key.scancode).capitalize();
if (p_event.key.mod.meta)
- str=TTR("Meta+")+str;
+ str = TTR("Meta+") + str;
if (p_event.key.mod.shift)
- str=TTR("Shift+")+str;
+ str = TTR("Shift+") + str;
if (p_event.key.mod.alt)
- str=TTR("Alt+")+str;
+ str = TTR("Alt+") + str;
if (p_event.key.mod.control)
- str=TTR("Control+")+str;
-
+ str = TTR("Control+") + str;
press_a_key_label->set_text(str);
press_a_key->accept_event();
-
}
}
-
-
-
void EditorSettingsDialog::_press_a_key_confirm() {
- if (last_wait_for_key.type!=InputEvent::KEY)
+ if (last_wait_for_key.type != InputEvent::KEY)
return;
InputEvent ie;
- ie.type=InputEvent::KEY;
- ie.key.scancode=last_wait_for_key.key.scancode;
- ie.key.mod=last_wait_for_key.key.mod;
+ ie.type = InputEvent::KEY;
+ ie.key.scancode = last_wait_for_key.key.scancode;
+ ie.key.mod = last_wait_for_key.key.mod;
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(shortcut_configured);
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
- ur->create_action("Change Shortcut '"+shortcut_configured+"'");
- ur->add_do_method(sc.ptr(),"set_shortcut",ie);
- ur->add_undo_method(sc.ptr(),"set_shortcut",sc->get_shortcut());
- ur->add_do_method(this,"_update_shortcuts");
- ur->add_undo_method(this,"_update_shortcuts");
- ur->add_do_method(this,"_settings_changed");
- ur->add_undo_method(this,"_settings_changed");
+ ur->create_action("Change Shortcut '" + shortcut_configured + "'");
+ ur->add_do_method(sc.ptr(), "set_shortcut", ie);
+ ur->add_undo_method(sc.ptr(), "set_shortcut", sc->get_shortcut());
+ ur->add_do_method(this, "_update_shortcuts");
+ ur->add_undo_method(this, "_update_shortcuts");
+ ur->add_do_method(this, "_settings_changed");
+ ur->add_undo_method(this, "_settings_changed");
ur->commit_action();
-
-
-
}
void EditorSettingsDialog::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_settings_save"),&EditorSettingsDialog::_settings_save);
- ClassDB::bind_method(D_METHOD("_settings_changed"),&EditorSettingsDialog::_settings_changed);
- ClassDB::bind_method(D_METHOD("_settings_property_edited"),&EditorSettingsDialog::_settings_property_edited);
- ClassDB::bind_method(D_METHOD("_clear_search_box"),&EditorSettingsDialog::_clear_search_box);
- ClassDB::bind_method(D_METHOD("_clear_shortcut_search_box"),&EditorSettingsDialog::_clear_shortcut_search_box);
- ClassDB::bind_method(D_METHOD("_shortcut_button_pressed"),&EditorSettingsDialog::_shortcut_button_pressed);
- ClassDB::bind_method(D_METHOD("_filter_shortcuts"),&EditorSettingsDialog::_filter_shortcuts);
- ClassDB::bind_method(D_METHOD("_update_shortcuts"),&EditorSettingsDialog::_update_shortcuts);
- ClassDB::bind_method(D_METHOD("_press_a_key_confirm"),&EditorSettingsDialog::_press_a_key_confirm);
- ClassDB::bind_method(D_METHOD("_wait_for_key"),&EditorSettingsDialog::_wait_for_key);
-
+ ClassDB::bind_method(D_METHOD("_settings_save"), &EditorSettingsDialog::_settings_save);
+ ClassDB::bind_method(D_METHOD("_settings_changed"), &EditorSettingsDialog::_settings_changed);
+ ClassDB::bind_method(D_METHOD("_settings_property_edited"), &EditorSettingsDialog::_settings_property_edited);
+ ClassDB::bind_method(D_METHOD("_clear_search_box"), &EditorSettingsDialog::_clear_search_box);
+ ClassDB::bind_method(D_METHOD("_clear_shortcut_search_box"), &EditorSettingsDialog::_clear_shortcut_search_box);
+ ClassDB::bind_method(D_METHOD("_shortcut_button_pressed"), &EditorSettingsDialog::_shortcut_button_pressed);
+ ClassDB::bind_method(D_METHOD("_filter_shortcuts"), &EditorSettingsDialog::_filter_shortcuts);
+ ClassDB::bind_method(D_METHOD("_update_shortcuts"), &EditorSettingsDialog::_update_shortcuts);
+ ClassDB::bind_method(D_METHOD("_press_a_key_confirm"), &EditorSettingsDialog::_press_a_key_confirm);
+ ClassDB::bind_method(D_METHOD("_wait_for_key"), &EditorSettingsDialog::_wait_for_key);
}
EditorSettingsDialog::EditorSettingsDialog() {
@@ -315,31 +298,31 @@ EditorSettingsDialog::EditorSettingsDialog() {
set_title(TTR("Editor Settings"));
set_resizable(true);
- tabs = memnew( TabContainer );
+ tabs = memnew(TabContainer);
add_child(tabs);
//set_child_rect(tabs);
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
tabs->add_child(vbc);
vbc->set_name(TTR("General"));
- HBoxContainer *hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(hbc);
- Label *l = memnew( Label );
- l->set_text(TTR("Search:")+" ");
+ Label *l = memnew(Label);
+ l->set_text(TTR("Search:") + " ");
hbc->add_child(l);
- search_box = memnew( LineEdit );
+ search_box = memnew(LineEdit);
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->add_child(search_box);
- clear_button = memnew( ToolButton );
+ clear_button = memnew(ToolButton);
hbc->add_child(clear_button);
- clear_button->connect("pressed",this,"_clear_search_box");
+ clear_button->connect("pressed", this, "_clear_search_box");
- property_editor = memnew( SectionedPropertyEditor );
+ property_editor = memnew(SectionedPropertyEditor);
//property_editor->hide_top_label();
property_editor->get_property_editor()->set_use_filter(true);
property_editor->get_property_editor()->register_text_enter(search_box);
@@ -347,69 +330,67 @@ EditorSettingsDialog::EditorSettingsDialog() {
vbc->add_child(property_editor);
property_editor->get_property_editor()->connect("property_edited", this, "_settings_property_edited");
- vbc = memnew( VBoxContainer );
+ vbc = memnew(VBoxContainer);
tabs->add_child(vbc);
vbc->set_name(TTR("Shortcuts"));
- hbc = memnew( HBoxContainer );
+ hbc = memnew(HBoxContainer);
hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(hbc);
- l = memnew( Label );
- l->set_text(TTR("Search:")+" ");
+ l = memnew(Label);
+ l->set_text(TTR("Search:") + " ");
hbc->add_child(l);
- shortcut_search_box = memnew( LineEdit );
+ shortcut_search_box = memnew(LineEdit);
shortcut_search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hbc->add_child(shortcut_search_box);
shortcut_search_box->connect("text_changed", this, "_filter_shortcuts");
- shortcut_clear_button = memnew( ToolButton );
+ shortcut_clear_button = memnew(ToolButton);
hbc->add_child(shortcut_clear_button);
- shortcut_clear_button->connect("pressed",this,"_clear_shortcut_search_box");
+ shortcut_clear_button->connect("pressed", this, "_clear_shortcut_search_box");
- shortcuts = memnew( Tree );
- vbc->add_margin_child("Shortcut List:",shortcuts,true);
+ shortcuts = memnew(Tree);
+ vbc->add_margin_child("Shortcut List:", shortcuts, true);
shortcuts->set_columns(2);
shortcuts->set_hide_root(true);
//shortcuts->set_hide_folding(true);
shortcuts->set_column_titles_visible(true);
- shortcuts->set_column_title(0,"Name");
- shortcuts->set_column_title(1,"Binding");
- shortcuts->connect("button_pressed",this,"_shortcut_button_pressed");
+ shortcuts->set_column_title(0, "Name");
+ shortcuts->set_column_title(1, "Binding");
+ shortcuts->connect("button_pressed", this, "_shortcut_button_pressed");
- press_a_key = memnew( ConfirmationDialog );
+ press_a_key = memnew(ConfirmationDialog);
press_a_key->set_focus_mode(FOCUS_ALL);
add_child(press_a_key);
- l = memnew( Label );
+ l = memnew(Label);
l->set_text(TTR("Press a Key.."));
l->set_area_as_parent_rect();
l->set_align(Label::ALIGN_CENTER);
- l->set_margin(MARGIN_TOP,20);
- l->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_BEGIN,30);
- press_a_key_label=l;
+ l->set_margin(MARGIN_TOP, 20);
+ l->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 30);
+ press_a_key_label = l;
press_a_key->add_child(l);
- press_a_key->connect("gui_input",this,"_wait_for_key");
- press_a_key->connect("confirmed",this,"_press_a_key_confirm");
+ press_a_key->connect("gui_input", this, "_wait_for_key");
+ press_a_key->connect("confirmed", this, "_press_a_key_confirm");
//Button *load = memnew( Button );
//load->set_text("Load..");
//hbc->add_child(load);
-
//get_ok()->set_text("Apply");
set_hide_on_ok(true);
//get_cancel()->set_text("Close");
- timer = memnew( Timer );
+ timer = memnew(Timer);
timer->set_wait_time(1.5);
- timer->connect("timeout",this,"_settings_save");
+ timer->connect("timeout", this, "_settings_save");
timer->set_one_shot(true);
add_child(timer);
- EditorSettings::get_singleton()->connect("settings_changed",this,"_settings_changed");
+ EditorSettings::get_singleton()->connect("settings_changed", this, "_settings_changed");
get_ok()->set_text(TTR("Close"));
- updating=false;
-
+ updating = false;
}
diff --git a/editor/settings_config_dialog.h b/editor/settings_config_dialog.h
index 17a05c27d3..ff6a831fe3 100644
--- a/editor/settings_config_dialog.h
+++ b/editor/settings_config_dialog.h
@@ -29,16 +29,13 @@
#ifndef SETTINGS_CONFIG_DIALOG_H
#define SETTINGS_CONFIG_DIALOG_H
-
#include "property_editor.h"
-#include "scene/gui/tab_container.h"
#include "scene/gui/rich_text_label.h"
+#include "scene/gui/tab_container.h"
class EditorSettingsDialog : public AcceptDialog {
- GDCLASS(EditorSettingsDialog,AcceptDialog);
-
-
+ GDCLASS(EditorSettingsDialog, AcceptDialog);
bool updating;
@@ -64,28 +61,26 @@ class EditorSettingsDialog : public AcceptDialog {
virtual void ok_pressed();
void _settings_changed();
- void _settings_property_edited(const String& p_name);
+ void _settings_property_edited(const String &p_name);
void _settings_save();
void _notification(int p_what);
-
void _press_a_key_confirm();
- void _wait_for_key(const InputEvent& p_event);
+ void _wait_for_key(const InputEvent &p_event);
void _clear_shortcut_search_box();
void _clear_search_box();
- void _filter_shortcuts(const String& p_filter);
+ void _filter_shortcuts(const String &p_filter);
void _update_shortcuts();
- void _shortcut_button_pressed(Object* p_item,int p_column,int p_idx);
+ void _shortcut_button_pressed(Object *p_item, int p_column, int p_idx);
protected:
-
static void _bind_methods();
-public:
+public:
void popup_edit_settings();
EditorSettingsDialog();
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index 825db5356b..8a24ed2b2f 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -29,36 +29,32 @@
#include "spatial_editor_gizmos.h"
#include "geometry.h"
+#include "quick_hull.h"
#include "scene/3d/camera.h"
-#include "scene/resources/surface_tool.h"
-#include "scene/resources/sphere_shape.h"
#include "scene/resources/box_shape.h"
#include "scene/resources/capsule_shape.h"
-#include "scene/resources/ray_shape.h"
#include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/plane_shape.h"
-#include "quick_hull.h"
+#include "scene/resources/ray_shape.h"
+#include "scene/resources/sphere_shape.h"
+#include "scene/resources/surface_tool.h"
// Keep small children away from this file.
// It's so ugly it will eat them alive
-
-
#define HANDLE_HALF_SIZE 0.05
void EditorSpatialGizmo::clear() {
- for(int i=0;i<instances.size();i++) {
+ for (int i = 0; i < instances.size(); i++) {
if (instances[i].instance.is_valid())
VS::get_singleton()->free(instances[i].instance);
-
-
}
- billboard_handle=false;
+ billboard_handle = false;
collision_segments.clear();
- collision_mesh=Ref<TriangleMesh>();
+ collision_mesh = Ref<TriangleMesh>();
instances.clear();
handles.clear();
secondary_handles.clear();
@@ -68,168 +64,155 @@ void EditorSpatialGizmo::redraw() {
if (get_script_instance() && get_script_instance()->has_method("redraw"))
get_script_instance()->call("redraw");
-
-
}
void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base) {
- instance = VS::get_singleton()->instance_create2(mesh->get_rid(),p_base->get_world()->get_scenario());
- VS::get_singleton()->instance_attach_object_instance_ID(instance,p_base->get_instance_ID());
+ instance = VS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world()->get_scenario());
+ VS::get_singleton()->instance_attach_object_instance_ID(instance, p_base->get_instance_ID());
if (billboard)
- VS::get_singleton()->instance_geometry_set_flag(instance,VS::INSTANCE_FLAG_BILLBOARD,true);
+ VS::get_singleton()->instance_geometry_set_flag(instance, VS::INSTANCE_FLAG_BILLBOARD, true);
if (unscaled)
- VS::get_singleton()->instance_geometry_set_flag(instance,VS::INSTANCE_FLAG_DEPH_SCALE,true);
+ VS::get_singleton()->instance_geometry_set_flag(instance, VS::INSTANCE_FLAG_DEPH_SCALE, true);
if (skeleton.is_valid())
- VS::get_singleton()->instance_attach_skeleton(instance,skeleton);
+ VS::get_singleton()->instance_attach_skeleton(instance, skeleton);
if (extra_margin)
- VS::get_singleton()->instance_set_extra_visibility_margin(instance,1);
- VS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance,VS::SHADOW_CASTING_SETTING_OFF);
- VS::get_singleton()->instance_set_layer_mask(instance,1<<SpatialEditorViewport::GIZMO_EDIT_LAYER); //gizmos are 26
+ VS::get_singleton()->instance_set_extra_visibility_margin(instance, 1);
+ VS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, VS::SHADOW_CASTING_SETTING_OFF);
+ VS::get_singleton()->instance_set_layer_mask(instance, 1 << SpatialEditorViewport::GIZMO_EDIT_LAYER); //gizmos are 26
}
-
-
-void EditorSpatialGizmo::add_mesh(const Ref<Mesh>& p_mesh,bool p_billboard, const RID &p_skeleton) {
+void EditorSpatialGizmo::add_mesh(const Ref<Mesh> &p_mesh, bool p_billboard, const RID &p_skeleton) {
ERR_FAIL_COND(!spatial_node);
Instance ins;
- ins.billboard=p_billboard;
- ins.mesh=p_mesh;
- ins.skeleton=p_skeleton;
+ ins.billboard = p_billboard;
+ ins.mesh = p_mesh;
+ ins.skeleton = p_skeleton;
if (valid) {
ins.create_instance(spatial_node);
- VS::get_singleton()->instance_set_transform(ins.instance,spatial_node->get_global_transform());
+ VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
}
instances.push_back(ins);
-
}
-void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material,bool p_billboard){
+void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard) {
ERR_FAIL_COND(!spatial_node);
Instance ins;
- Ref<Mesh> mesh = memnew( Mesh );
+ Ref<Mesh> mesh = memnew(Mesh);
Array a;
a.resize(Mesh::ARRAY_MAX);
- a[Mesh::ARRAY_VERTEX]=p_lines;
+ a[Mesh::ARRAY_VERTEX] = p_lines;
PoolVector<Color> color;
color.resize(p_lines.size());
{
PoolVector<Color>::Write w = color.write();
- for(int i=0;i<p_lines.size();i++) {
+ for (int i = 0; i < p_lines.size(); i++) {
if (is_selected())
- w[i]=Color(1,1,1,0.6);
+ w[i] = Color(1, 1, 1, 0.6);
else
- w[i]=Color(1,1,1,0.25);
+ w[i] = Color(1, 1, 1, 0.25);
}
-
}
- a[Mesh::ARRAY_COLOR]=color;
-
+ a[Mesh::ARRAY_COLOR] = color;
- mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES,a);
- mesh->surface_set_material(0,p_material);
+ mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, a);
+ mesh->surface_set_material(0, p_material);
if (p_billboard) {
- float md=0;
- for(int i=0;i<p_lines.size();i++) {
-
- md=MAX(0,p_lines[i].length());
+ float md = 0;
+ for (int i = 0; i < p_lines.size(); i++) {
+ md = MAX(0, p_lines[i].length());
}
if (md) {
- mesh->set_custom_aabb(Rect3(Vector3(-md,-md,-md),Vector3(md,md,md)*2.0));
+ mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0));
}
}
- ins.billboard=p_billboard;
- ins.mesh=mesh;
+ ins.billboard = p_billboard;
+ ins.mesh = mesh;
if (valid) {
ins.create_instance(spatial_node);
- VS::get_singleton()->instance_set_transform(ins.instance,spatial_node->get_global_transform());
+ VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
}
instances.push_back(ins);
-
}
-void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material>& p_material,float p_scale) {
+void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, float p_scale) {
ERR_FAIL_COND(!spatial_node);
Instance ins;
- Vector<Vector3 > vs;
- Vector<Vector2 > uv;
+ Vector<Vector3> vs;
+ Vector<Vector2> uv;
- vs.push_back(Vector3(-p_scale,p_scale,0));
- vs.push_back(Vector3(p_scale,p_scale,0));
- vs.push_back(Vector3(p_scale,-p_scale,0));
- vs.push_back(Vector3(-p_scale,-p_scale,0));
+ vs.push_back(Vector3(-p_scale, p_scale, 0));
+ vs.push_back(Vector3(p_scale, p_scale, 0));
+ vs.push_back(Vector3(p_scale, -p_scale, 0));
+ vs.push_back(Vector3(-p_scale, -p_scale, 0));
- uv.push_back(Vector2(1,0));
- uv.push_back(Vector2(0,0));
- uv.push_back(Vector2(0,1));
- uv.push_back(Vector2(1,1));
+ uv.push_back(Vector2(1, 0));
+ uv.push_back(Vector2(0, 0));
+ uv.push_back(Vector2(0, 1));
+ uv.push_back(Vector2(1, 1));
- Ref<Mesh> mesh = memnew( Mesh );
+ Ref<Mesh> mesh = memnew(Mesh);
Array a;
a.resize(Mesh::ARRAY_MAX);
- a[Mesh::ARRAY_VERTEX]=vs;
- a[Mesh::ARRAY_TEX_UV]=uv;
- mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLE_FAN,a);
- mesh->surface_set_material(0,p_material);
+ a[Mesh::ARRAY_VERTEX] = vs;
+ a[Mesh::ARRAY_TEX_UV] = uv;
+ mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLE_FAN, a);
+ mesh->surface_set_material(0, p_material);
if (true) {
- float md=0;
- for(int i=0;i<vs.size();i++) {
-
- md=MAX(0,vs[i].length());
+ float md = 0;
+ for (int i = 0; i < vs.size(); i++) {
+ md = MAX(0, vs[i].length());
}
if (md) {
- mesh->set_custom_aabb(Rect3(Vector3(-md,-md,-md),Vector3(md,md,md)*2.0));
+ mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0));
}
}
- ins.mesh=mesh;
- ins.unscaled=true;
- ins.billboard=true;
+ ins.mesh = mesh;
+ ins.unscaled = true;
+ ins.billboard = true;
if (valid) {
ins.create_instance(spatial_node);
- VS::get_singleton()->instance_set_transform(ins.instance,spatial_node->get_global_transform());
+ VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
}
instances.push_back(ins);
-
-
}
-void EditorSpatialGizmo::add_collision_triangles(const Ref<TriangleMesh>& p_tmesh) {
+void EditorSpatialGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh) {
- collision_mesh=p_tmesh;
+ collision_mesh = p_tmesh;
}
void EditorSpatialGizmo::add_collision_segments(const Vector<Vector3> &p_lines) {
- int from=collision_segments.size();
- collision_segments.resize(from+p_lines.size());
- for(int i=0;i<p_lines.size();i++) {
+ int from = collision_segments.size();
+ collision_segments.resize(from + p_lines.size());
+ for (int i = 0; i < p_lines.size(); i++) {
- collision_segments[from+i]=p_lines[i];
+ collision_segments[from + i] = p_lines[i];
}
}
+void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_billboard, bool p_secondary) {
-void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_billboard,bool p_secondary){
-
- billboard_handle=p_billboard;
+ billboard_handle = p_billboard;
if (!is_selected())
return;
@@ -239,82 +222,75 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi
ERR_FAIL_COND(!spatial_node);
Instance ins;
-
- Ref<Mesh> mesh = memnew( Mesh );
+ Ref<Mesh> mesh = memnew(Mesh);
#if 1
Array a;
a.resize(VS::ARRAY_MAX);
- a[VS::ARRAY_VERTEX]=p_handles;
- print_line("handles?: "+itos(p_handles.size()));
+ a[VS::ARRAY_VERTEX] = p_handles;
+ print_line("handles?: " + itos(p_handles.size()));
PoolVector<Color> colors;
{
colors.resize(p_handles.size());
- PoolVector<Color>::Write w=colors.write();
- for(int i=0;i<p_handles.size();i++) {
+ PoolVector<Color>::Write w = colors.write();
+ for (int i = 0; i < p_handles.size(); i++) {
- Color col(1,1,1,1);
- if (SpatialEditor::get_singleton()->get_over_gizmo_handle()!=i)
- col=Color(0.9,0.9,0.9,0.9);
- w[i]=col;
+ Color col(1, 1, 1, 1);
+ if (SpatialEditor::get_singleton()->get_over_gizmo_handle() != i)
+ col = Color(0.9, 0.9, 0.9, 0.9);
+ w[i] = col;
}
-
}
- a[VS::ARRAY_COLOR]=colors;
- mesh->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS,a);
- mesh->surface_set_material(0,SpatialEditorGizmos::singleton->handle2_material);
+ a[VS::ARRAY_COLOR] = colors;
+ mesh->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS, a);
+ mesh->surface_set_material(0, SpatialEditorGizmos::singleton->handle2_material);
if (p_billboard) {
- float md=0;
- for(int i=0;i<p_handles.size();i++) {
-
- md=MAX(0,p_handles[i].length());
+ float md = 0;
+ for (int i = 0; i < p_handles.size(); i++) {
+ md = MAX(0, p_handles[i].length());
}
if (md) {
- mesh->set_custom_aabb(Rect3(Vector3(-md,-md,-md),Vector3(md,md,md)*2.0));
+ mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0));
}
}
-
-
#else
- for(int ih=0;ih<p_handles.size();ih++) {
-
+ for (int ih = 0; ih < p_handles.size(); ih++) {
Vector<Vector3> vertices;
Vector<Vector3> normals;
- int vtx_idx=0;
+ int vtx_idx = 0;
-#define ADD_VTX(m_idx) \
- vertices.push_back( (face_points[m_idx]*HANDLE_HALF_SIZE+p_handles[ih]) );\
- normals.push_back( normal_points[m_idx] );\
- vtx_idx++;\
-
- for (int i=0;i<6;i++) {
+#define ADD_VTX(m_idx) \
+ vertices.push_back((face_points[m_idx] * HANDLE_HALF_SIZE + p_handles[ih])); \
+ normals.push_back(normal_points[m_idx]); \
+ vtx_idx++;
+ for (int i = 0; i < 6; i++) {
Vector3 face_points[4];
Vector3 normal_points[4];
- float uv_points[8]={0,0,0,1,1,1,1,0};
+ float uv_points[8] = { 0, 0, 0, 1, 1, 1, 1, 0 };
- for (int j=0;j<4;j++) {
+ for (int j = 0; j < 4; j++) {
float v[3];
- v[0]=1.0;
- v[1]=1-2*((j>>1)&1);
- v[2]=v[1]*(1-2*(j&1));
+ v[0] = 1.0;
+ v[1] = 1 - 2 * ((j >> 1) & 1);
+ v[2] = v[1] * (1 - 2 * (j & 1));
- for (int k=0;k<3;k++) {
+ for (int k = 0; k < 3; k++) {
- if (i<3)
- face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
+ if (i < 3)
+ face_points[j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1);
else
- face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
+ face_points[3 - j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1);
}
- normal_points[j]=Vector3();
- normal_points[j][i%3]=(i>=3?-1:1);
+ normal_points[j] = Vector3();
+ normal_points[j][i % 3] = (i >= 3 ? -1 : 1);
}
//tri 1
ADD_VTX(0);
@@ -324,81 +300,72 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi
ADD_VTX(2);
ADD_VTX(3);
ADD_VTX(0);
-
}
-
Array d;
d.resize(VS::ARRAY_MAX);
- d[VisualServer::ARRAY_NORMAL]= normals ;
- d[VisualServer::ARRAY_VERTEX]= vertices ;
-
- mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,d);
- mesh->surface_set_material(ih,SpatialEditorGizmos::singleton->handle_material);
-
+ d[VisualServer::ARRAY_NORMAL] = normals;
+ d[VisualServer::ARRAY_VERTEX] = vertices;
+ mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, d);
+ mesh->surface_set_material(ih, SpatialEditorGizmos::singleton->handle_material);
}
#endif
- ins.mesh=mesh;
- ins.billboard=p_billboard;
- ins.extra_margin=true;
+ ins.mesh = mesh;
+ ins.billboard = p_billboard;
+ ins.extra_margin = true;
if (valid) {
ins.create_instance(spatial_node);
- VS::get_singleton()->instance_set_transform(ins.instance,spatial_node->get_global_transform());
+ VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform());
}
instances.push_back(ins);
if (!p_secondary) {
- int chs=handles.size();
- handles.resize(chs+p_handles.size());
- for(int i=0;i<p_handles.size();i++) {
- handles[i+chs]=p_handles[i];
+ int chs = handles.size();
+ handles.resize(chs + p_handles.size());
+ for (int i = 0; i < p_handles.size(); i++) {
+ handles[i + chs] = p_handles[i];
}
} else {
- int chs=secondary_handles.size();
- secondary_handles.resize(chs+p_handles.size());
- for(int i=0;i<p_handles.size();i++) {
- secondary_handles[i+chs]=p_handles[i];
+ int chs = secondary_handles.size();
+ secondary_handles.resize(chs + p_handles.size());
+ for (int i = 0; i < p_handles.size(); i++) {
+ secondary_handles[i + chs] = p_handles[i];
}
-
}
-
}
-
-void EditorSpatialGizmo::set_spatial_node(Spatial *p_node){
+void EditorSpatialGizmo::set_spatial_node(Spatial *p_node) {
ERR_FAIL_NULL(p_node);
- spatial_node=p_node;
-
+ spatial_node = p_node;
}
-bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera,const Vector<Plane> &p_frustum) {
+bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum) {
- ERR_FAIL_COND_V(!spatial_node,false);
- ERR_FAIL_COND_V(!valid,false);
+ ERR_FAIL_COND_V(!spatial_node, false);
+ ERR_FAIL_COND_V(!valid, false);
if (collision_segments.size()) {
- const Plane *p=p_frustum.ptr();
- int fc=p_frustum.size();
+ const Plane *p = p_frustum.ptr();
+ int fc = p_frustum.size();
- int vc=collision_segments.size();
- const Vector3* vptr=collision_segments.ptr();
+ int vc = collision_segments.size();
+ const Vector3 *vptr = collision_segments.ptr();
Transform t = spatial_node->get_global_transform();
- for(int i=0;i<vc/2;i++) {
+ for (int i = 0; i < vc / 2; i++) {
+ Vector3 a = t.xform(vptr[i * 2 + 0]);
+ Vector3 b = t.xform(vptr[i * 2 + 1]);
- Vector3 a=t.xform(vptr[i*2+0]);
- Vector3 b=t.xform(vptr[i*2+1]);
+ bool any_out = false;
+ for (int j = 0; j < fc; j++) {
- bool any_out=false;
- for(int j=0;j<fc;j++) {
+ if (p[j].distance_to(a) > 0 && p[j].distance_to(b) > 0) {
- if (p[j].distance_to(a) > 0 && p[j].distance_to(b) >0) {
-
- any_out=true;
+ any_out = true;
break;
}
}
@@ -413,305 +380,276 @@ bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera,const Vector<P
return false;
}
+bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle, bool p_sec_first) {
-bool EditorSpatialGizmo::intersect_ray(const Camera *p_camera,const Point2& p_point, Vector3& r_pos, Vector3& r_normal,int *r_gizmo_handle,bool p_sec_first) {
-
- ERR_FAIL_COND_V(!spatial_node,false);
- ERR_FAIL_COND_V(!valid,false);
+ ERR_FAIL_COND_V(!spatial_node, false);
+ ERR_FAIL_COND_V(!valid, false);
if (r_gizmo_handle) {
Transform t = spatial_node->get_global_transform();
t.orthonormalize();
if (billboard_handle) {
- t.set_look_at(t.origin,t.origin+p_camera->get_transform().basis.get_axis(2),p_camera->get_transform().basis.get_axis(1));
+ t.set_look_at(t.origin, t.origin + p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1));
}
- float min_d=1e20;
- int idx=-1;
+ float min_d = 1e20;
+ int idx = -1;
- for(int i=0;i<secondary_handles.size();i++) {
+ for (int i = 0; i < secondary_handles.size(); i++) {
Vector3 hpos = t.xform(secondary_handles[i]);
Vector2 p = p_camera->unproject_position(hpos);
- if (p.distance_to(p_point)<SpatialEditorGizmos::singleton->handle_t->get_width()*0.6) {
-
+ if (p.distance_to(p_point) < SpatialEditorGizmos::singleton->handle_t->get_width() * 0.6) {
real_t dp = p_camera->get_transform().origin.distance_to(hpos);
- if (dp<min_d) {
-
- r_pos=t.xform(hpos);
- r_normal=p_camera->get_transform().basis.get_axis(2);
- min_d=dp;
- idx=i+handles.size();
+ if (dp < min_d) {
+ r_pos = t.xform(hpos);
+ r_normal = p_camera->get_transform().basis.get_axis(2);
+ min_d = dp;
+ idx = i + handles.size();
}
}
}
- if (p_sec_first && idx!=-1) {
+ if (p_sec_first && idx != -1) {
- *r_gizmo_handle=idx;
+ *r_gizmo_handle = idx;
return true;
}
- min_d=1e20;
+ min_d = 1e20;
- for(int i=0;i<handles.size();i++) {
+ for (int i = 0; i < handles.size(); i++) {
Vector3 hpos = t.xform(handles[i]);
Vector2 p = p_camera->unproject_position(hpos);
- if (p.distance_to(p_point)<SpatialEditorGizmos::singleton->handle_t->get_width()*0.6) {
-
+ if (p.distance_to(p_point) < SpatialEditorGizmos::singleton->handle_t->get_width() * 0.6) {
real_t dp = p_camera->get_transform().origin.distance_to(hpos);
- if (dp<min_d) {
-
- r_pos=t.xform(hpos);
- r_normal=p_camera->get_transform().basis.get_axis(2);
- min_d=dp;
- idx=i;
+ if (dp < min_d) {
+ r_pos = t.xform(hpos);
+ r_normal = p_camera->get_transform().basis.get_axis(2);
+ min_d = dp;
+ idx = i;
}
}
}
- if (idx>=0) {
- *r_gizmo_handle=idx;
+ if (idx >= 0) {
+ *r_gizmo_handle = idx;
return true;
}
-
-
}
if (collision_segments.size()) {
- Plane camp(p_camera->get_transform().origin,(-p_camera->get_transform().basis.get_axis(2)).normalized());
+ Plane camp(p_camera->get_transform().origin, (-p_camera->get_transform().basis.get_axis(2)).normalized());
- int vc=collision_segments.size();
- const Vector3* vptr=collision_segments.ptr();
+ int vc = collision_segments.size();
+ const Vector3 *vptr = collision_segments.ptr();
Transform t = spatial_node->get_global_transform();
if (billboard_handle) {
- t.set_look_at(t.origin,t.origin+p_camera->get_transform().basis.get_axis(2),p_camera->get_transform().basis.get_axis(1));
+ t.set_look_at(t.origin, t.origin + p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1));
}
Vector3 cp;
- float cpd=1e20;
-
- for(int i=0;i<vc/2;i++) {
+ float cpd = 1e20;
+ for (int i = 0; i < vc / 2; i++) {
- Vector3 a=t.xform(vptr[i*2+0]);
- Vector3 b=t.xform(vptr[i*2+1]);
+ Vector3 a = t.xform(vptr[i * 2 + 0]);
+ Vector3 b = t.xform(vptr[i * 2 + 1]);
Vector2 s[2];
s[0] = p_camera->unproject_position(a);
s[1] = p_camera->unproject_position(b);
-
- Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point,s);
+ Vector2 p = Geometry::get_closest_point_to_segment_2d(p_point, s);
float pd = p.distance_to(p_point);
- if (pd<cpd) {
-
+ if (pd < cpd) {
float d = s[0].distance_to(s[1]);
Vector3 tcp;
- if (d>0) {
+ if (d > 0) {
- float d2=s[0].distance_to(p)/d;
- tcp = a+(b-a)*d2;
+ float d2 = s[0].distance_to(p) / d;
+ tcp = a + (b - a) * d2;
} else {
- tcp=a;
-
+ tcp = a;
}
- if (camp.distance_to(tcp)<p_camera->get_znear())
+ if (camp.distance_to(tcp) < p_camera->get_znear())
continue;
- cp=tcp;
- cpd=pd;
+ cp = tcp;
+ cpd = pd;
}
}
- if (cpd<8) {
+ if (cpd < 8) {
- r_pos=cp;
- r_normal=-p_camera->project_ray_normal(p_point);
+ r_pos = cp;
+ r_normal = -p_camera->project_ray_normal(p_point);
return true;
}
return false;
}
-
if (collision_mesh.is_valid()) {
Transform gt = spatial_node->get_global_transform();
if (billboard_handle) {
- gt.set_look_at(gt.origin,gt.origin+p_camera->get_transform().basis.get_axis(2),p_camera->get_transform().basis.get_axis(1));
+ gt.set_look_at(gt.origin, gt.origin + p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1));
}
- Transform ai=gt.affine_inverse();
+ Transform ai = gt.affine_inverse();
Vector3 ray_from = ai.xform(p_camera->project_ray_origin(p_point));
- Vector3 ray_dir=ai.basis.xform(p_camera->project_ray_normal(p_point)).normalized();
- Vector3 rpos,rnorm;
-
+ Vector3 ray_dir = ai.basis.xform(p_camera->project_ray_normal(p_point)).normalized();
+ Vector3 rpos, rnorm;
- if (collision_mesh->intersect_ray(ray_from,ray_dir,rpos,rnorm)) {
+ if (collision_mesh->intersect_ray(ray_from, ray_dir, rpos, rnorm)) {
- r_pos=gt.xform(rpos);
- r_normal=gt.basis.xform(rnorm).normalized();
+ r_pos = gt.xform(rpos);
+ r_normal = gt.basis.xform(rnorm).normalized();
return true;
}
}
return false;
-
}
-
-
void EditorSpatialGizmo::create() {
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(valid);
- valid=true;
+ valid = true;
- for(int i=0;i<instances.size();i++) {
+ for (int i = 0; i < instances.size(); i++) {
instances[i].create_instance(spatial_node);
}
transform();
-
}
-void EditorSpatialGizmo::transform(){
+void EditorSpatialGizmo::transform() {
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid);
- for(int i=0;i<instances.size();i++) {
- VS::get_singleton()->instance_set_transform(instances[i].instance,spatial_node->get_global_transform());
+ for (int i = 0; i < instances.size(); i++) {
+ VS::get_singleton()->instance_set_transform(instances[i].instance, spatial_node->get_global_transform());
}
-
}
-
-void EditorSpatialGizmo::free(){
+void EditorSpatialGizmo::free() {
ERR_FAIL_COND(!spatial_node);
ERR_FAIL_COND(!valid);
- for(int i=0;i<instances.size();i++) {
+ for (int i = 0; i < instances.size(); i++) {
if (instances[i].instance.is_valid())
VS::get_singleton()->free(instances[i].instance);
- instances[i].instance=RID();
+ instances[i].instance = RID();
}
- valid=false;
-
-
+ valid = false;
}
-
void EditorSpatialGizmo::_bind_methods() {
- ClassDB::bind_method(D_METHOD("add_lines","lines","material:Material","billboard"),&EditorSpatialGizmo::add_lines,DEFVAL(false));
- ClassDB::bind_method(D_METHOD("add_mesh","mesh:Mesh","billboard","skeleton"),&EditorSpatialGizmo::add_mesh,DEFVAL(false),DEFVAL(RID()));
- ClassDB::bind_method(D_METHOD("add_collision_segments","segments"),&EditorSpatialGizmo::add_collision_segments);
- ClassDB::bind_method(D_METHOD("add_collision_triangles","triangles:TriangleMesh"),&EditorSpatialGizmo::add_collision_triangles);
- ClassDB::bind_method(D_METHOD("add_unscaled_billboard","material:Material","default_scale"),&EditorSpatialGizmo::add_unscaled_billboard,DEFVAL(1));
- ClassDB::bind_method(D_METHOD("add_handles","handles","billboard","secondary"),&EditorSpatialGizmo::add_handles,DEFVAL(false),DEFVAL(false));
- ClassDB::bind_method(D_METHOD("set_spatial_node","node:Spatial"),&EditorSpatialGizmo::_set_spatial_node);
- ClassDB::bind_method(D_METHOD("clear"),&EditorSpatialGizmo::clear);
-
- BIND_VMETHOD( MethodInfo("redraw"));
- BIND_VMETHOD( MethodInfo(Variant::STRING,"get_handle_name",PropertyInfo(Variant::INT,"index")));
- BIND_VMETHOD( MethodInfo("get_handle_value:Variant",PropertyInfo(Variant::INT,"index")));
- BIND_VMETHOD( MethodInfo("set_handle",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::OBJECT,"camera:Camera"),PropertyInfo(Variant::VECTOR2,"point")));
- MethodInfo cm = MethodInfo("commit_handle",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::NIL,"restore:Variant"),PropertyInfo(Variant::BOOL,"cancel"));
+ ClassDB::bind_method(D_METHOD("add_lines", "lines", "material:Material", "billboard"), &EditorSpatialGizmo::add_lines, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("add_mesh", "mesh:Mesh", "billboard", "skeleton"), &EditorSpatialGizmo::add_mesh, DEFVAL(false), DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorSpatialGizmo::add_collision_segments);
+ ClassDB::bind_method(D_METHOD("add_collision_triangles", "triangles:TriangleMesh"), &EditorSpatialGizmo::add_collision_triangles);
+ ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material:Material", "default_scale"), &EditorSpatialGizmo::add_unscaled_billboard, DEFVAL(1));
+ ClassDB::bind_method(D_METHOD("add_handles", "handles", "billboard", "secondary"), &EditorSpatialGizmo::add_handles, DEFVAL(false), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("set_spatial_node", "node:Spatial"), &EditorSpatialGizmo::_set_spatial_node);
+ ClassDB::bind_method(D_METHOD("clear"), &EditorSpatialGizmo::clear);
+
+ BIND_VMETHOD(MethodInfo("redraw"));
+ BIND_VMETHOD(MethodInfo(Variant::STRING, "get_handle_name", PropertyInfo(Variant::INT, "index")));
+ BIND_VMETHOD(MethodInfo("get_handle_value:Variant", PropertyInfo(Variant::INT, "index")));
+ BIND_VMETHOD(MethodInfo("set_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera:Camera"), PropertyInfo(Variant::VECTOR2, "point")));
+ MethodInfo cm = MethodInfo("commit_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "restore:Variant"), PropertyInfo(Variant::BOOL, "cancel"));
cm.default_arguments.push_back(false);
- BIND_VMETHOD( cm );
+ BIND_VMETHOD(cm);
}
EditorSpatialGizmo::EditorSpatialGizmo() {
- valid=false;
- billboard_handle=false;
- base=NULL;
- spatial_node=NULL;
+ valid = false;
+ billboard_handle = false;
+ base = NULL;
+ spatial_node = NULL;
}
-EditorSpatialGizmo::~EditorSpatialGizmo(){
+EditorSpatialGizmo::~EditorSpatialGizmo() {
clear();
}
Vector3 EditorSpatialGizmo::get_handle_pos(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,handles.size(),Vector3());
+ ERR_FAIL_INDEX_V(p_idx, handles.size(), Vector3());
return handles[p_idx];
-
}
//// light gizmo
-
String LightSpatialGizmo::get_handle_name(int p_idx) const {
- if (p_idx==0)
+ if (p_idx == 0)
return "Radius";
else
return "Aperture";
}
+Variant LightSpatialGizmo::get_handle_value(int p_idx) const {
-Variant LightSpatialGizmo::get_handle_value(int p_idx) const{
-
- if (p_idx==0)
+ if (p_idx == 0)
return light->get_param(Light::PARAM_RANGE);
- if (p_idx==1)
+ if (p_idx == 1)
return light->get_param(Light::PARAM_SPOT_ANGLE);
return Variant();
}
-
-static float _find_closest_angle_to_half_pi_arc(const Vector3& p_from, const Vector3& p_to, float p_arc_radius,const Transform& p_arc_xform) {
+static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vector3 &p_to, float p_arc_radius, const Transform &p_arc_xform) {
//bleh, discrete is simpler
- static const int arc_test_points=64;
+ static const int arc_test_points = 64;
float min_d = 1e20;
Vector3 min_p;
+ for (int i = 0; i < arc_test_points; i++) {
- for(int i=0;i<arc_test_points;i++) {
+ float a = i * Math_PI * 0.5 / arc_test_points;
+ float an = (i + 1) * Math_PI * 0.5 / arc_test_points;
+ Vector3 p = Vector3(Math::cos(a), 0, -Math::sin(a)) * p_arc_radius;
+ Vector3 n = Vector3(Math::cos(an), 0, -Math::sin(an)) * p_arc_radius;
- float a = i*Math_PI*0.5/arc_test_points;
- float an = (i+1)*Math_PI*0.5/arc_test_points;
- Vector3 p=Vector3( Math::cos(a), 0, -Math::sin(a) )*p_arc_radius;
- Vector3 n=Vector3( Math::cos(an), 0,- Math::sin(an) )*p_arc_radius;
-
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(p,n,p_from,p_to,ra,rb);
+ Vector3 ra, rb;
+ Geometry::get_closest_points_between_segments(p, n, p_from, p_to, ra, rb);
float d = ra.distance_to(rb);
- if (d<min_d) {
- min_d=d;
- min_p=ra;
+ if (d < min_d) {
+ min_d = d;
+ min_p = ra;
}
-
}
//min_p = p_arc_xform.affine_inverse().xform(min_p);
- float a = Vector2(min_p.x,-min_p.z).angle();
- return a*180.0/Math_PI;
+ float a = Vector2(min_p.x, -min_p.z).angle();
+ return a * 180.0 / Math_PI;
}
-
-void LightSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point) {
+void LightSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
Transform gt = light->get_global_transform();
gt.orthonormalize();
@@ -720,152 +658,135 @@ void LightSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_p
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
- Vector3 s[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*4096)};
- if (p_idx==0) {
+ Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
+ if (p_idx == 0) {
if (light->cast_to<SpotLight>()) {
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(),Vector3(0,0,-4096),s[0],s[1],ra,rb);
+ Vector3 ra, rb;
+ Geometry::get_closest_points_between_segments(Vector3(), Vector3(0, 0, -4096), s[0], s[1], ra, rb);
float d = -ra.z;
- if (d<0)
- d=0;
+ if (d < 0)
+ d = 0;
- light->set_param(Light::PARAM_RANGE,d);
+ light->set_param(Light::PARAM_RANGE, d);
} else if (light->cast_to<OmniLight>()) {
- Plane cp=Plane( gt.origin, p_camera->get_transform().basis.get_axis(2));
+ Plane cp = Plane(gt.origin, p_camera->get_transform().basis.get_axis(2));
Vector3 inters;
- if (cp.intersects_ray(ray_from,ray_dir,&inters)) {
+ if (cp.intersects_ray(ray_from, ray_dir, &inters)) {
float r = inters.distance_to(gt.origin);
- light->set_param(Light::PARAM_RANGE,r);
+ light->set_param(Light::PARAM_RANGE, r);
}
-
}
- } else if (p_idx==1) {
+ } else if (p_idx == 1) {
- float a = _find_closest_angle_to_half_pi_arc(s[0],s[1],light->get_param(Light::PARAM_RANGE),gt);
- light->set_param(Light::PARAM_SPOT_ANGLE,CLAMP(a,0.01,89.99));
+ float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], light->get_param(Light::PARAM_RANGE), gt);
+ light->set_param(Light::PARAM_SPOT_ANGLE, CLAMP(a, 0.01, 89.99));
}
}
-void LightSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
+void LightSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
if (p_cancel) {
- light->set_param(p_idx==0?Light::PARAM_RANGE:Light::PARAM_SPOT_ANGLE,p_restore);
+ light->set_param(p_idx == 0 ? Light::PARAM_RANGE : Light::PARAM_SPOT_ANGLE, p_restore);
- } else if (p_idx==0) {
+ } else if (p_idx == 0) {
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Light Radius"));
- ur->add_do_method(light,"set_param",Light::PARAM_RANGE,light->get_param(Light::PARAM_RANGE));
- ur->add_undo_method(light,"set_param",Light::PARAM_RANGE,p_restore);
+ ur->add_do_method(light, "set_param", Light::PARAM_RANGE, light->get_param(Light::PARAM_RANGE));
+ ur->add_undo_method(light, "set_param", Light::PARAM_RANGE, p_restore);
ur->commit_action();
- } else if (p_idx==1) {
+ } else if (p_idx == 1) {
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Light Radius"));
- ur->add_do_method(light,"set_param",Light::PARAM_SPOT_ANGLE,light->get_param(Light::PARAM_SPOT_ANGLE));
- ur->add_undo_method(light,"set_param",Light::PARAM_SPOT_ANGLE,p_restore);
+ ur->add_do_method(light, "set_param", Light::PARAM_SPOT_ANGLE, light->get_param(Light::PARAM_SPOT_ANGLE));
+ ur->add_undo_method(light, "set_param", Light::PARAM_SPOT_ANGLE, p_restore);
ur->commit_action();
-
}
}
-
-
void LightSpatialGizmo::redraw() {
-
if (light->cast_to<DirectionalLight>()) {
-
-
- 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;
+ int arrow_sides = 4;
Vector<Vector3> lines;
+ for (int i = 0; i < arrow_sides; i++) {
- for(int i = 0; i < arrow_sides ; i++) {
-
+ Basis ma(Vector3(0, 0, 1), Math_PI * 2 * float(i) / arrow_sides);
+ Basis mb(Vector3(0, 0, 1), Math_PI * 2 * float(i + 1) / arrow_sides);
- Basis ma(Vector3(0,0,1),Math_PI*2*float(i)/arrow_sides);
- Basis mb(Vector3(0,0,1),Math_PI*2*float(i+1)/arrow_sides);
+ for (int j = 1; j < arrow_points - 1; j++) {
-
- for(int j=1;j<arrow_points-1;j++) {
-
- if (j!=2) {
+ if (j != 2) {
lines.push_back(ma.xform(arrow[j]));
- lines.push_back(ma.xform(arrow[j+1]));
+ lines.push_back(ma.xform(arrow[j + 1]));
}
- if (j<arrow_points-1) {
+ if (j < arrow_points - 1) {
lines.push_back(ma.xform(arrow[j]));
lines.push_back(mb.xform(arrow[j]));
}
-
}
}
- add_lines(lines,SpatialEditorGizmos::singleton->light_material);
+ add_lines(lines, SpatialEditorGizmos::singleton->light_material);
add_collision_segments(lines);
- add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_directional_icon,0.05);
-
+ add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_directional_icon, 0.05);
}
if (light->cast_to<OmniLight>()) {
clear();
-
OmniLight *on = light->cast_to<OmniLight>();
float r = on->get_param(Light::PARAM_RANGE);
Vector<Vector3> points;
- for(int i=0;i<=360;i++) {
+ for (int i = 0; i <= 360; i++) {
- float ra=Math::deg2rad((float)i);
- float rb=Math::deg2rad((float)i+1);
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
+ float ra = Math::deg2rad((float)i);
+ float rb = Math::deg2rad((float)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));
-
+ points.push_back(Vector3(a.x, a.y, 0));
+ points.push_back(Vector3(b.x, b.y, 0));
}
- add_lines(points,SpatialEditorGizmos::singleton->light_material,true);
+ add_lines(points, SpatialEditorGizmos::singleton->light_material, true);
add_collision_segments(points);
- add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_omni_icon,0.05);
+ add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_omni_icon, 0.05);
Vector<Vector3> handles;
- handles.push_back(Vector3(r,0,0));
- add_handles(handles,true);
-
-
+ handles.push_back(Vector3(r, 0, 0));
+ add_handles(handles, true);
}
-
if (light->cast_to<SpotLight>()) {
clear();
@@ -874,108 +795,97 @@ void LightSpatialGizmo::redraw() {
SpotLight *on = light->cast_to<SpotLight>();
float r = on->get_param(Light::PARAM_RANGE);
- float w = r*Math::sin(Math::deg2rad(on->get_param(Light::PARAM_SPOT_ANGLE)));
- float d = r*Math::cos(Math::deg2rad(on->get_param(Light::PARAM_SPOT_ANGLE)));
-
+ float w = r * Math::sin(Math::deg2rad(on->get_param(Light::PARAM_SPOT_ANGLE)));
+ float d = r * Math::cos(Math::deg2rad(on->get_param(Light::PARAM_SPOT_ANGLE)));
+ for (int i = 0; i < 360; i++) {
- for(int i=0;i<360;i++) {
-
- float ra=Math::deg2rad((float)i);
- float rb=Math::deg2rad((float)i+1);
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*w;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*w;
+ float ra = Math::deg2rad((float)i);
+ float rb = Math::deg2rad((float)i + 1);
+ Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w;
+ Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * w;
/*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,-d));
- points.push_back(Vector3(b.x,b.y,-d));
+ points.push_back(Vector3(a.x, a.y, -d));
+ points.push_back(Vector3(b.x, b.y, -d));
- if (i%90==0) {
+ if (i % 90 == 0) {
- points.push_back(Vector3(a.x,a.y,-d));
+ points.push_back(Vector3(a.x, a.y, -d));
points.push_back(Vector3());
-
}
-
-
}
- points.push_back(Vector3(0,0,-r));
+ points.push_back(Vector3(0, 0, -r));
points.push_back(Vector3());
- add_lines(points,SpatialEditorGizmos::singleton->light_material);
+ add_lines(points, SpatialEditorGizmos::singleton->light_material);
Vector<Vector3> handles;
- handles.push_back(Vector3(0,0,-r));
+ handles.push_back(Vector3(0, 0, -r));
Vector<Vector3> collision_segments;
- for(int i=0;i<64;i++) {
+ for (int i = 0; i < 64; i++) {
- float ra=i*Math_PI*2.0/64.0;
- float rb=(i+1)*Math_PI*2.0/64.0;
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*w;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*w;
+ float ra = i * Math_PI * 2.0 / 64.0;
+ float rb = (i + 1) * Math_PI * 2.0 / 64.0;
+ Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w;
+ Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * w;
- collision_segments.push_back(Vector3(a.x,a.y,-d));
- collision_segments.push_back(Vector3(b.x,b.y,-d));
+ collision_segments.push_back(Vector3(a.x, a.y, -d));
+ collision_segments.push_back(Vector3(b.x, b.y, -d));
- if (i%16==0) {
+ if (i % 16 == 0) {
- collision_segments.push_back(Vector3(a.x,a.y,-d));
+ collision_segments.push_back(Vector3(a.x, a.y, -d));
collision_segments.push_back(Vector3());
-
}
- if (i==16) {
+ if (i == 16) {
- handles.push_back(Vector3(a.x,a.y,-d));
+ handles.push_back(Vector3(a.x, a.y, -d));
}
-
}
- collision_segments.push_back(Vector3(0,0,-r));
+ collision_segments.push_back(Vector3(0, 0, -r));
collision_segments.push_back(Vector3());
-
add_handles(handles);
add_collision_segments(collision_segments);
- add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_omni_icon,0.05);
-
+ add_unscaled_billboard(SpatialEditorGizmos::singleton->light_material_omni_icon, 0.05);
}
-
}
-LightSpatialGizmo::LightSpatialGizmo(Light* p_light){
+LightSpatialGizmo::LightSpatialGizmo(Light *p_light) {
- light=p_light;
+ light = p_light;
set_spatial_node(p_light);
-
}
//////
String CameraSpatialGizmo::get_handle_name(int p_idx) const {
- if (camera->get_projection()==Camera::PROJECTION_PERSPECTIVE) {
+ if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
return "FOV";
} else {
return "Size";
}
}
-Variant CameraSpatialGizmo::get_handle_value(int p_idx) const{
+Variant CameraSpatialGizmo::get_handle_value(int p_idx) const {
- if (camera->get_projection()==Camera::PROJECTION_PERSPECTIVE) {
+ if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
return camera->get_fov();
} else {
return camera->get_size();
}
}
-void CameraSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point){
+void CameraSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
Transform gt = camera->get_global_transform();
gt.orthonormalize();
@@ -984,36 +894,35 @@ void CameraSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
- Vector3 s[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*4096)};
+ Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
- if (camera->get_projection()==Camera::PROJECTION_PERSPECTIVE) {
- Transform gt=camera->get_global_transform();
- float a = _find_closest_angle_to_half_pi_arc(s[0],s[1],1.0,gt);
- camera->set("fov",a);
+ if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
+ Transform gt = camera->get_global_transform();
+ float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], 1.0, gt);
+ camera->set("fov", a);
} else {
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(0,0,-1),Vector3(4096,0,-1),s[0],s[1],ra,rb);
+ Vector3 ra, rb;
+ Geometry::get_closest_points_between_segments(Vector3(0, 0, -1), Vector3(4096, 0, -1), s[0], s[1], ra, rb);
float d = ra.x * 2.0;
- if (d<0)
- d=0;
+ if (d < 0)
+ d = 0;
- camera->set("size",d);
+ camera->set("size", d);
}
-
}
-void CameraSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
+void CameraSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
- if (camera->get_projection()==Camera::PROJECTION_PERSPECTIVE) {
+ if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) {
if (p_cancel) {
- camera->set("fov",p_restore);
+ camera->set("fov", p_restore);
} else {
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Camera FOV"));
- ur->add_do_property(camera,"fov",camera->get_fov());
- ur->add_undo_property(camera,"fov",p_restore);
+ ur->add_do_property(camera, "fov", camera->get_fov());
+ ur->add_undo_property(camera, "fov", p_restore);
ur->commit_action();
}
@@ -1021,111 +930,102 @@ void CameraSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p
if (p_cancel) {
- camera->set("size",p_restore);
+ camera->set("size", p_restore);
} else {
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Camera Size"));
- ur->add_do_property(camera,"size",camera->get_size());
- ur->add_undo_property(camera,"size",p_restore);
+ ur->add_do_property(camera, "size", camera->get_size());
+ ur->add_undo_property(camera, "size", p_restore);
ur->commit_action();
}
-
}
-
}
-void CameraSpatialGizmo::redraw(){
+void CameraSpatialGizmo::redraw() {
clear();
Vector<Vector3> lines;
Vector<Vector3> handles;
-
- switch(camera->get_projection()) {
+ switch (camera->get_projection()) {
case Camera::PROJECTION_PERSPECTIVE: {
float fov = camera->get_fov();
- 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);
-
+ 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)\
-{\
- lines.push_back(m_a);\
- lines.push_back(m_b);\
- lines.push_back(m_b);\
- lines.push_back(m_c);\
- lines.push_back(m_c);\
- lines.push_back(m_a);\
-}
+#define ADD_TRIANGLE(m_a, m_b, m_c) \
+ { \
+ lines.push_back(m_a); \
+ lines.push_back(m_b); \
+ lines.push_back(m_b); \
+ lines.push_back(m_c); \
+ lines.push_back(m_c); \
+ lines.push_back(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);
handles.push_back(side);
- 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 Camera::PROJECTION_ORTHOGONAL: {
-#define ADD_QUAD( m_a, m_b, m_c, m_d)\
-{\
- lines.push_back(m_a);\
- lines.push_back(m_b);\
- lines.push_back(m_b);\
- lines.push_back(m_c);\
- lines.push_back(m_c);\
- lines.push_back(m_d);\
- lines.push_back(m_d);\
- lines.push_back(m_a);\
-}
+#define ADD_QUAD(m_a, m_b, m_c, m_d) \
+ { \
+ lines.push_back(m_a); \
+ lines.push_back(m_b); \
+ lines.push_back(m_b); \
+ lines.push_back(m_c); \
+ lines.push_back(m_c); \
+ lines.push_back(m_d); \
+ lines.push_back(m_d); \
+ lines.push_back(m_a); \
+ }
float size = camera->get_size();
- 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);
- handles.push_back(right+back);
+ 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);
+ handles.push_back(right + back);
- 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;
-
}
- add_lines(lines,SpatialEditorGizmos::singleton->camera_material);
+ add_lines(lines, SpatialEditorGizmos::singleton->camera_material);
add_collision_segments(lines);
add_handles(handles);
}
+CameraSpatialGizmo::CameraSpatialGizmo(Camera *p_camera) {
-CameraSpatialGizmo::CameraSpatialGizmo(Camera* p_camera){
-
- camera=p_camera;
+ camera = p_camera;
set_spatial_node(camera);
}
-
-
-
//////
void MeshInstanceSpatialGizmo::redraw() {
@@ -1139,47 +1039,42 @@ void MeshInstanceSpatialGizmo::redraw() {
add_collision_triangles(tm);
}
-MeshInstanceSpatialGizmo::MeshInstanceSpatialGizmo(MeshInstance* p_mesh) {
+MeshInstanceSpatialGizmo::MeshInstanceSpatialGizmo(MeshInstance *p_mesh) {
- mesh=p_mesh;
+ mesh = p_mesh;
set_spatial_node(p_mesh);
}
/////
-
void Position3DSpatialGizmo::redraw() {
clear();
add_mesh(SpatialEditorGizmos::singleton->pos3d_mesh);
Vector<Vector3> cursor_points;
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_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));
add_collision_segments(cursor_points);
-
}
+Position3DSpatialGizmo::Position3DSpatialGizmo(Position3D *p_p3d) {
-Position3DSpatialGizmo::Position3DSpatialGizmo(Position3D* p_p3d) {
-
- p3d=p_p3d;
+ p3d = p_p3d;
set_spatial_node(p3d);
}
-
/////
void SkeletonSpatialGizmo::redraw() {
clear();
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
+ Ref<SurfaceTool> surface_tool(memnew(SurfaceTool));
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(SpatialEditorGizmos::singleton->skeleton_material);
@@ -1191,77 +1086,75 @@ void SkeletonSpatialGizmo::redraw() {
bones.resize(4);
weights.resize(4);
- for(int i=0;i<4;i++) {
- bones[i]=0;
- weights[i]=0;
+ for (int i = 0; i < 4; i++) {
+ bones[i] = 0;
+ weights[i] = 0;
}
- weights[0]=1;
-
+ weights[0] = 1;
Rect3 aabb;
- Color bonecolor = Color(1.0,0.4,0.4,0.3);
- Color rootcolor = Color(0.4,1.0,0.4,0.1);
+ Color bonecolor = Color(1.0, 0.4, 0.4, 0.3);
+ Color rootcolor = Color(0.4, 1.0, 0.4, 0.1);
- for (int i=0;i<skel->get_bone_count();i++) {
+ for (int i = 0; i < skel->get_bone_count(); i++) {
int parent = skel->get_bone_parent(i);
- if (parent>=0) {
- grests[i]=grests[parent] * skel->get_bone_rest(i);
+ if (parent >= 0) {
+ grests[i] = grests[parent] * skel->get_bone_rest(i);
Vector3 v0 = grests[parent].origin;
Vector3 v1 = grests[i].origin;
- Vector3 d = (v1-v0).normalized();
+ Vector3 d = (v1 - v0).normalized();
float dist = v0.distance_to(v1);
//find closest axis
- int closest=-1;
+ int closest = -1;
float closest_d = 0.0;
- for(int j=0;j<3;j++) {
+ for (int j = 0; j < 3; j++) {
float dp = Math::abs(grests[parent].basis[j].normalized().dot(d));
- if (j==0 || dp>closest_d)
- closest=j;
+ if (j == 0 || dp > closest_d)
+ closest = j;
}
//find closest other
Vector3 first;
Vector3 points[4];
- int pointidx=0;
- for(int j=0;j<3;j++) {
+ int pointidx = 0;
+ for (int j = 0; j < 3; j++) {
- bones[0]=parent;
+ bones[0] = parent;
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
surface_tool->add_color(rootcolor);
- surface_tool->add_vertex(v0-grests[parent].basis[j].normalized()*dist*0.05);
+ surface_tool->add_vertex(v0 - grests[parent].basis[j].normalized() * dist * 0.05);
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
surface_tool->add_color(rootcolor);
- surface_tool->add_vertex(v0+grests[parent].basis[j].normalized()*dist*0.05);
+ surface_tool->add_vertex(v0 + grests[parent].basis[j].normalized() * dist * 0.05);
- if (j==closest)
+ if (j == closest)
continue;
Vector3 axis;
- if (first==Vector3()) {
+ if (first == Vector3()) {
axis = d.cross(d.cross(grests[parent].basis[j])).normalized();
- first=axis;
+ first = axis;
} else {
axis = d.cross(first).normalized();
}
- for(int k=0;k<2;k++) {
-
- if (k==1)
- axis=-axis;
- Vector3 point = v0+d*dist*0.2;
- point+=axis*dist*0.1;
+ for (int k = 0; k < 2; k++) {
+ if (k == 1)
+ axis = -axis;
+ Vector3 point = v0 + d * dist * 0.2;
+ point += axis * dist * 0.1;
- bones[0]=parent;
+ bones[0] = parent;
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
surface_tool->add_color(bonecolor);
@@ -1271,27 +1164,24 @@ void SkeletonSpatialGizmo::redraw() {
surface_tool->add_color(bonecolor);
surface_tool->add_vertex(point);
- bones[0]=parent;
+ bones[0] = parent;
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
surface_tool->add_color(bonecolor);
surface_tool->add_vertex(point);
- bones[0]=i;
+ bones[0] = i;
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
surface_tool->add_color(bonecolor);
surface_tool->add_vertex(v1);
- points[pointidx++]=point;
-
+ points[pointidx++] = point;
}
-
}
- SWAP( points[1],points[2] );
- for(int j=0;j<4;j++) {
+ SWAP(points[1], points[2]);
+ for (int j = 0; j < 4; j++) {
-
- bones[0]=parent;
+ bones[0] = parent;
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
surface_tool->add_color(bonecolor);
@@ -1299,11 +1189,10 @@ void SkeletonSpatialGizmo::redraw() {
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
surface_tool->add_color(bonecolor);
- surface_tool->add_vertex(points[(j+1)%4]);
+ surface_tool->add_vertex(points[(j + 1) % 4]);
}
-
-/*
+ /*
bones[0]=parent;
surface_tool->add_bones(bones);
surface_tool->add_weights(weights);
@@ -1317,10 +1206,10 @@ void SkeletonSpatialGizmo::redraw() {
*/
} else {
- grests[i]=skel->get_bone_rest(i);
- bones[0]=i;
+ grests[i] = skel->get_bone_rest(i);
+ bones[0] = i;
}
-/*
+ /*
Transform t = grests[i];
t.orthonormalize();
@@ -1361,18 +1250,15 @@ void SkeletonSpatialGizmo::redraw() {
}
Ref<Mesh> m = surface_tool->commit();
- add_mesh(m,false,skel->get_skeleton());
-
+ add_mesh(m, false, skel->get_skeleton());
}
-SkeletonSpatialGizmo::SkeletonSpatialGizmo(Skeleton* p_skel) {
+SkeletonSpatialGizmo::SkeletonSpatialGizmo(Skeleton *p_skel) {
- skel=p_skel;
+ skel = p_skel;
set_spatial_node(p_skel);
}
-
-
void RoomSpatialGizmo::redraw() {
clear();
@@ -1382,194 +1268,178 @@ void RoomSpatialGizmo::redraw() {
PoolVector<Face3> faces = roomie->get_geometry_hint();
Vector<Vector3> lines;
- int fc=faces.size();
- PoolVector<Face3>::Read r =faces.read();
+ int fc = faces.size();
+ PoolVector<Face3>::Read r = faces.read();
- Map<_EdgeKey,Vector3> edge_map;
+ Map<_EdgeKey, Vector3> edge_map;
- for(int i=0;i<fc;i++) {
+ for (int i = 0; i < fc; i++) {
Vector3 fn = r[i].get_plane().normal;
- for(int j=0;j<3;j++) {
+ for (int j = 0; j < 3; j++) {
_EdgeKey ek;
- ek.from=r[i].vertex[j].snapped(CMP_EPSILON);
- ek.to=r[i].vertex[(j+1)%3].snapped(CMP_EPSILON);
- if (ek.from<ek.to)
- SWAP(ek.from,ek.to);
+ ek.from = r[i].vertex[j].snapped(CMP_EPSILON);
+ ek.to = r[i].vertex[(j + 1) % 3].snapped(CMP_EPSILON);
+ if (ek.from < ek.to)
+ SWAP(ek.from, ek.to);
- Map<_EdgeKey,Vector3>::Element *E=edge_map.find(ek);
+ Map<_EdgeKey, Vector3>::Element *E = edge_map.find(ek);
if (E) {
- if (E->get().dot(fn) >0.9) {
+ if (E->get().dot(fn) > 0.9) {
- E->get()=Vector3();
+ E->get() = Vector3();
}
} else {
- edge_map[ek]=fn;
+ edge_map[ek] = fn;
}
-
}
}
- for(Map<_EdgeKey,Vector3>::Element *E=edge_map.front();E;E=E->next()) {
+ for (Map<_EdgeKey, Vector3>::Element *E = edge_map.front(); E; E = E->next()) {
- if (E->get()!=Vector3()) {
+ if (E->get() != Vector3()) {
lines.push_back(E->key().from);
lines.push_back(E->key().to);
}
}
- add_lines(lines,SpatialEditorGizmos::singleton->room_material);
+ add_lines(lines, SpatialEditorGizmos::singleton->room_material);
add_collision_segments(lines);
-
}
-RoomSpatialGizmo::RoomSpatialGizmo(Room* p_room){
+RoomSpatialGizmo::RoomSpatialGizmo(Room *p_room) {
set_spatial_node(p_room);
- room=p_room;
+ room = p_room;
}
/////
-
void PortalSpatialGizmo::redraw() {
clear();
Vector<Point2> points = portal->get_shape();
- if (points.size()==0) {
+ if (points.size() == 0) {
return;
}
Vector<Vector3> lines;
Vector3 center;
- for(int i=0;i<points.size();i++) {
+ for (int i = 0; i < points.size(); i++) {
Vector3 f;
- f.x=points[i].x;
- f.y=points[i].y;
+ f.x = points[i].x;
+ f.y = points[i].y;
Vector3 fn;
- fn.x=points[(i+1)%points.size()].x;
- fn.y=points[(i+1)%points.size()].y;
- center+=f;
+ fn.x = points[(i + 1) % points.size()].x;
+ fn.y = points[(i + 1) % points.size()].y;
+ center += f;
lines.push_back(f);
lines.push_back(fn);
}
- center/=points.size();
+ center /= points.size();
lines.push_back(center);
- lines.push_back(center+Vector3(0,0,1));
+ lines.push_back(center + Vector3(0, 0, 1));
- add_lines(lines,SpatialEditorGizmos::singleton->portal_material);
+ add_lines(lines, SpatialEditorGizmos::singleton->portal_material);
add_collision_segments(lines);
-
}
-PortalSpatialGizmo::PortalSpatialGizmo(Portal* p_portal){
+PortalSpatialGizmo::PortalSpatialGizmo(Portal *p_portal) {
set_spatial_node(p_portal);
- portal=p_portal;
+ portal = p_portal;
}
/////
-
void RayCastSpatialGizmo::redraw() {
clear();
-
Vector<Vector3> lines;
lines.push_back(Vector3());
lines.push_back(raycast->get_cast_to());
- add_lines(lines,SpatialEditorGizmos::singleton->raycast_material);
+ add_lines(lines, SpatialEditorGizmos::singleton->raycast_material);
add_collision_segments(lines);
-
}
-RayCastSpatialGizmo::RayCastSpatialGizmo(RayCast* p_raycast) {
+RayCastSpatialGizmo::RayCastSpatialGizmo(RayCast *p_raycast) {
set_spatial_node(p_raycast);
- raycast=p_raycast;
+ raycast = p_raycast;
}
-
-
/////
-
void VehicleWheelSpatialGizmo::redraw() {
clear();
-
Vector<Vector3> points;
float r = car_wheel->get_radius();
- const int skip=10;
- for(int i=0;i<=360;i+=skip) {
+ const int skip = 10;
+ for (int i = 0; i <= 360; i += skip) {
- float ra=Math::deg2rad((float)i);
- float rb=Math::deg2rad((float)i+skip);
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
+ float ra = Math::deg2rad((float)i);
+ float rb = Math::deg2rad((float)i + skip);
+ Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
+ Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * r;
- points.push_back(Vector3(0,a.x,a.y));
- points.push_back(Vector3(0,b.x,b.y));
+ points.push_back(Vector3(0, a.x, a.y));
+ points.push_back(Vector3(0, b.x, b.y));
- const int springsec=4;
+ const int springsec = 4;
- for(int j=0;j<springsec;j++) {
- float t = car_wheel->get_suspension_rest_length()*5;
- points.push_back(Vector3(a.x,i/360.0*t/springsec+j*(t/springsec),a.y)*0.2);
- points.push_back(Vector3(b.x,(i+skip)/360.0*t/springsec+j*(t/springsec),b.y)*0.2);
+ for (int j = 0; j < springsec; j++) {
+ float t = car_wheel->get_suspension_rest_length() * 5;
+ points.push_back(Vector3(a.x, i / 360.0 * t / springsec + j * (t / springsec), a.y) * 0.2);
+ points.push_back(Vector3(b.x, (i + skip) / 360.0 * t / springsec + j * (t / springsec), b.y) * 0.2);
}
-
-
}
//travel
- points.push_back(Vector3(0,0,0));
- points.push_back(Vector3(0,car_wheel->get_suspension_rest_length(),0));
+ points.push_back(Vector3(0, 0, 0));
+ points.push_back(Vector3(0, car_wheel->get_suspension_rest_length(), 0));
//axis
- points.push_back(Vector3(r*0.2,car_wheel->get_suspension_rest_length(),0));
- points.push_back(Vector3(-r*0.2,car_wheel->get_suspension_rest_length(),0));
+ points.push_back(Vector3(r * 0.2, car_wheel->get_suspension_rest_length(), 0));
+ points.push_back(Vector3(-r * 0.2, car_wheel->get_suspension_rest_length(), 0));
//axis
- points.push_back(Vector3(r*0.2,0,0));
- points.push_back(Vector3(-r*0.2,0,0));
+ points.push_back(Vector3(r * 0.2, 0, 0));
+ points.push_back(Vector3(-r * 0.2, 0, 0));
//forward line
- points.push_back(Vector3(0,-r,0));
- points.push_back(Vector3(0,-r,r*2));
- points.push_back(Vector3(0,-r,r*2));
- points.push_back(Vector3(r*2*0.2,-r,r*2*0.8));
- points.push_back(Vector3(0,-r,r*2));
- points.push_back(Vector3(-r*2*0.2,-r,r*2*0.8));
-
- add_lines(points,SpatialEditorGizmos::singleton->car_wheel_material);
+ points.push_back(Vector3(0, -r, 0));
+ points.push_back(Vector3(0, -r, r * 2));
+ points.push_back(Vector3(0, -r, r * 2));
+ points.push_back(Vector3(r * 2 * 0.2, -r, r * 2 * 0.8));
+ points.push_back(Vector3(0, -r, r * 2));
+ points.push_back(Vector3(-r * 2 * 0.2, -r, r * 2 * 0.8));
+
+ add_lines(points, SpatialEditorGizmos::singleton->car_wheel_material);
add_collision_segments(points);
-
}
-VehicleWheelSpatialGizmo::VehicleWheelSpatialGizmo(VehicleWheel* p_car_wheel){
+VehicleWheelSpatialGizmo::VehicleWheelSpatialGizmo(VehicleWheel *p_car_wheel) {
set_spatial_node(p_car_wheel);
- car_wheel=p_car_wheel;
+ car_wheel = p_car_wheel;
}
-
-
///
void TestCubeSpatialGizmo::redraw() {
@@ -1578,20 +1448,14 @@ void TestCubeSpatialGizmo::redraw() {
add_collision_triangles(SpatialEditorGizmos::singleton->test_cube_tm);
}
-TestCubeSpatialGizmo::TestCubeSpatialGizmo(TestCube* p_tc) {
+TestCubeSpatialGizmo::TestCubeSpatialGizmo(TestCube *p_tc) {
- tc=p_tc;
+ tc = p_tc;
set_spatial_node(p_tc);
}
-
///////////
-
-
-
-
-
String CollisionShapeSpatialGizmo::get_handle_name(int p_idx) const {
Ref<Shape> s = cs->get_shape();
@@ -1610,7 +1474,7 @@ String CollisionShapeSpatialGizmo::get_handle_name(int p_idx) const {
if (s->cast_to<CapsuleShape>()) {
- return p_idx==0?"Radius":"Height";
+ return p_idx == 0 ? "Radius" : "Height";
}
if (s->cast_to<RayShape>()) {
@@ -1620,7 +1484,7 @@ String CollisionShapeSpatialGizmo::get_handle_name(int p_idx) const {
return "";
}
-Variant CollisionShapeSpatialGizmo::get_handle_value(int p_idx) const{
+Variant CollisionShapeSpatialGizmo::get_handle_value(int p_idx) const {
Ref<Shape> s = cs->get_shape();
if (s.is_null())
@@ -1641,7 +1505,7 @@ Variant CollisionShapeSpatialGizmo::get_handle_value(int p_idx) const{
if (s->cast_to<CapsuleShape>()) {
Ref<CapsuleShape> cs = s;
- return p_idx==0?cs->get_radius():cs->get_height();
+ return p_idx == 0 ? cs->get_radius() : cs->get_height();
}
if (s->cast_to<RayShape>()) {
@@ -1652,7 +1516,7 @@ Variant CollisionShapeSpatialGizmo::get_handle_value(int p_idx) const{
return Variant();
}
-void CollisionShapeSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point){
+void CollisionShapeSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
Ref<Shape> s = cs->get_shape();
if (s.is_null())
return;
@@ -1664,16 +1528,16 @@ void CollisionShapeSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Po
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
- Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*4096)};
+ Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
if (s->cast_to<SphereShape>()) {
Ref<SphereShape> ss = s;
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(),Vector3(4096,0,0),sg[0],sg[1],ra,rb);
+ Vector3 ra, rb;
+ Geometry::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb);
float d = ra.x;
- if (d<0.001)
- d=0.001;
+ if (d < 0.001)
+ d = 0.001;
ss->set_radius(d);
}
@@ -1681,62 +1545,58 @@ void CollisionShapeSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Po
if (s->cast_to<RayShape>()) {
Ref<RayShape> rs = s;
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(),Vector3(0,0,4096),sg[0],sg[1],ra,rb);
+ Vector3 ra, rb;
+ Geometry::get_closest_points_between_segments(Vector3(), Vector3(0, 0, 4096), sg[0], sg[1], ra, rb);
float d = ra.z;
- if (d<0.001)
- d=0.001;
+ if (d < 0.001)
+ d = 0.001;
rs->set_length(d);
}
-
if (s->cast_to<BoxShape>()) {
Vector3 axis;
- axis[p_idx]=1.0;
+ axis[p_idx] = 1.0;
Ref<BoxShape> bs = s;
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(),axis*4096,sg[0],sg[1],ra,rb);
+ Vector3 ra, rb;
+ Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (d<0.001)
- d=0.001;
+ if (d < 0.001)
+ d = 0.001;
Vector3 he = bs->get_extents();
- he[p_idx]=d;
+ he[p_idx] = d;
bs->set_extents(he);
-
}
if (s->cast_to<CapsuleShape>()) {
Vector3 axis;
- axis[p_idx==0?0:2]=1.0;
+ axis[p_idx == 0 ? 0 : 2] = 1.0;
Ref<CapsuleShape> cs = s;
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(),axis*4096,sg[0],sg[1],ra,rb);
+ Vector3 ra, rb;
+ Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
- if (p_idx==1)
- d-=cs->get_radius();
- if (d<0.001)
- d=0.001;
+ if (p_idx == 1)
+ d -= cs->get_radius();
+ if (d < 0.001)
+ d = 0.001;
- if (p_idx==0)
+ if (p_idx == 0)
cs->set_radius(d);
- else if (p_idx==1)
- cs->set_height(d*2.0);
-
+ else if (p_idx == 1)
+ cs->set_height(d * 2.0);
}
-
}
-void CollisionShapeSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
+void CollisionShapeSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
Ref<Shape> s = cs->get_shape();
if (s.is_null())
return;
if (s->cast_to<SphereShape>()) {
- Ref<SphereShape> ss=s;
+ Ref<SphereShape> ss = s;
if (p_cancel) {
ss->set_radius(p_restore);
return;
@@ -1744,15 +1604,14 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx,const Variant& p_restor
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Sphere Shape Radius"));
- ur->add_do_method(ss.ptr(),"set_radius",ss->get_radius());
- ur->add_undo_method(ss.ptr(),"set_radius",p_restore);
+ ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius());
+ ur->add_undo_method(ss.ptr(), "set_radius", p_restore);
ur->commit_action();
-
}
if (s->cast_to<BoxShape>()) {
- Ref<BoxShape> ss=s;
+ Ref<BoxShape> ss = s;
if (p_cancel) {
ss->set_extents(p_restore);
return;
@@ -1760,16 +1619,16 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx,const Variant& p_restor
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Box Shape Extents"));
- ur->add_do_method(ss.ptr(),"set_extents",ss->get_extents());
- ur->add_undo_method(ss.ptr(),"set_extents",p_restore);
+ ur->add_do_method(ss.ptr(), "set_extents", ss->get_extents());
+ ur->add_undo_method(ss.ptr(), "set_extents", p_restore);
ur->commit_action();
}
if (s->cast_to<CapsuleShape>()) {
- Ref<CapsuleShape> ss=s;
+ Ref<CapsuleShape> ss = s;
if (p_cancel) {
- if (p_idx==0)
+ if (p_idx == 0)
ss->set_radius(p_restore);
else
ss->set_height(p_restore);
@@ -1777,24 +1636,22 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx,const Variant& p_restor
}
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
- if (p_idx==0) {
+ if (p_idx == 0) {
ur->create_action(TTR("Change Capsule Shape Radius"));
- ur->add_do_method(ss.ptr(),"set_radius",ss->get_radius());
- ur->add_undo_method(ss.ptr(),"set_radius",p_restore);
+ ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius());
+ ur->add_undo_method(ss.ptr(), "set_radius", p_restore);
} else {
ur->create_action(TTR("Change Capsule Shape Height"));
- ur->add_do_method(ss.ptr(),"set_height",ss->get_height());
- ur->add_undo_method(ss.ptr(),"set_height",p_restore);
-
+ ur->add_do_method(ss.ptr(), "set_height", ss->get_height());
+ ur->add_undo_method(ss.ptr(), "set_height", p_restore);
}
ur->commit_action();
-
}
if (s->cast_to<RayShape>()) {
- Ref<RayShape> ss=s;
+ Ref<RayShape> ss = s;
if (p_cancel) {
ss->set_length(p_restore);
return;
@@ -1802,14 +1659,12 @@ void CollisionShapeSpatialGizmo::commit_handle(int p_idx,const Variant& p_restor
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Ray Shape Length"));
- ur->add_do_method(ss.ptr(),"set_length",ss->get_length());
- ur->add_undo_method(ss.ptr(),"set_length",p_restore);
+ ur->add_do_method(ss.ptr(), "set_length", ss->get_length());
+ ur->add_undo_method(ss.ptr(), "set_length", p_restore);
ur->commit_action();
-
}
-
}
-void CollisionShapeSpatialGizmo::redraw(){
+void CollisionShapeSpatialGizmo::redraw() {
clear();
@@ -1819,176 +1674,168 @@ void CollisionShapeSpatialGizmo::redraw(){
if (s->cast_to<SphereShape>()) {
- Ref<SphereShape> sp= s;
- float r=sp->get_radius();
+ Ref<SphereShape> sp = s;
+ float r = sp->get_radius();
Vector<Vector3> points;
- for(int i=0;i<=360;i++) {
+ for (int i = 0; i <= 360; i++) {
- float ra=Math::deg2rad((float)i);
- float rb=Math::deg2rad((float)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((float)i);
+ float rb = Math::deg2rad((float)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));
}
Vector<Vector3> collision_segments;
- for(int i=0;i<64;i++) {
+ for (int i = 0; i < 64; i++) {
- float ra=i*Math_PI*2.0/64.0;
- float rb=(i+1)*Math_PI*2.0/64.0;
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
+ float ra = i * Math_PI * 2.0 / 64.0;
+ float rb = (i + 1) * Math_PI * 2.0 / 64.0;
+ Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
+ Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * r;
- collision_segments.push_back(Vector3(a.x,0,a.y));
- collision_segments.push_back(Vector3(b.x,0,b.y));
- collision_segments.push_back(Vector3(0,a.x,a.y));
- collision_segments.push_back(Vector3(0,b.x,b.y));
- collision_segments.push_back(Vector3(a.x,a.y,0));
- collision_segments.push_back(Vector3(b.x,b.y,0));
+ collision_segments.push_back(Vector3(a.x, 0, a.y));
+ collision_segments.push_back(Vector3(b.x, 0, b.y));
+ collision_segments.push_back(Vector3(0, a.x, a.y));
+ collision_segments.push_back(Vector3(0, b.x, b.y));
+ collision_segments.push_back(Vector3(a.x, a.y, 0));
+ collision_segments.push_back(Vector3(b.x, b.y, 0));
}
- add_lines(points,SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, SpatialEditorGizmos::singleton->shape_material);
add_collision_segments(collision_segments);
Vector<Vector3> handles;
- handles.push_back(Vector3(r,0,0));
+ handles.push_back(Vector3(r, 0, 0));
add_handles(handles);
-
}
if (s->cast_to<BoxShape>()) {
- Ref<BoxShape> bs=s;
+ Ref<BoxShape> bs = s;
Vector<Vector3> lines;
Rect3 aabb;
- aabb.pos=-bs->get_extents();
- aabb.size=aabb.pos*-2;
+ aabb.pos = -bs->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);
}
Vector<Vector3> handles;
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
Vector3 ax;
- ax[i]=bs->get_extents()[i];
+ ax[i] = bs->get_extents()[i];
handles.push_back(ax);
}
- add_lines(lines,SpatialEditorGizmos::singleton->shape_material);
+ add_lines(lines, SpatialEditorGizmos::singleton->shape_material);
add_collision_segments(lines);
add_handles(handles);
-
}
if (s->cast_to<CapsuleShape>()) {
- Ref<CapsuleShape> cs=s;
+ Ref<CapsuleShape> cs = s;
float radius = cs->get_radius();
float height = cs->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((float)i);
- float rb=Math::deg2rad((float)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((float)i);
+ float rb = Math::deg2rad((float)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);
}
- add_lines(points,SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, SpatialEditorGizmos::singleton->shape_material);
Vector<Vector3> collision_segments;
- for(int i=0;i<64;i++) {
+ for (int i = 0; i < 64; i++) {
- float ra=i*Math_PI*2.0/64.0;
- float rb=(i+1)*Math_PI*2.0/64.0;
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*radius;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*radius;
+ float ra = i * Math_PI * 2.0 / 64.0;
+ float rb = (i + 1) * Math_PI * 2.0 / 64.0;
+ Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
+ Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius;
- collision_segments.push_back(Vector3(a.x,a.y,0)+d);
- collision_segments.push_back(Vector3(b.x,b.y,0)+d);
+ collision_segments.push_back(Vector3(a.x, a.y, 0) + d);
+ collision_segments.push_back(Vector3(b.x, b.y, 0) + d);
- collision_segments.push_back(Vector3(a.x,a.y,0)-d);
- collision_segments.push_back(Vector3(b.x,b.y,0)-d);
+ collision_segments.push_back(Vector3(a.x, a.y, 0) - d);
+ collision_segments.push_back(Vector3(b.x, b.y, 0) - d);
- if (i%16==0) {
+ if (i % 16 == 0) {
- collision_segments.push_back(Vector3(a.x,a.y,0)+d);
- collision_segments.push_back(Vector3(a.x,a.y,0)-d);
+ collision_segments.push_back(Vector3(a.x, a.y, 0) + d);
+ collision_segments.push_back(Vector3(a.x, a.y, 0) - d);
}
- Vector3 dud = i<32?d:-d;
-
- collision_segments.push_back(Vector3(0,a.y,a.x)+dud);
- collision_segments.push_back(Vector3(0,b.y,b.x)+dud);
- collision_segments.push_back(Vector3(a.y,0,a.x)+dud);
- collision_segments.push_back(Vector3(b.y,0,b.x)+dud);
+ Vector3 dud = i < 32 ? d : -d;
+ collision_segments.push_back(Vector3(0, a.y, a.x) + dud);
+ collision_segments.push_back(Vector3(0, b.y, b.x) + dud);
+ collision_segments.push_back(Vector3(a.y, 0, a.x) + dud);
+ collision_segments.push_back(Vector3(b.y, 0, b.x) + dud);
}
add_collision_segments(collision_segments);
Vector<Vector3> handles;
- handles.push_back(Vector3(cs->get_radius(),0,0));
- handles.push_back(Vector3(0,0,cs->get_height()*0.5+cs->get_radius()));
+ handles.push_back(Vector3(cs->get_radius(), 0, 0));
+ handles.push_back(Vector3(0, 0, cs->get_height() * 0.5 + cs->get_radius()));
add_handles(handles);
-
-
}
if (s->cast_to<PlaneShape>()) {
- Ref<PlaneShape> ps=s;
+ Ref<PlaneShape> ps = s;
Plane p = ps->get_plane();
Vector<Vector3> points;
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]);
@@ -1999,106 +1846,92 @@ void CollisionShapeSpatialGizmo::redraw(){
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);
- add_lines(points,SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, SpatialEditorGizmos::singleton->shape_material);
add_collision_segments(points);
-
}
-
if (s->cast_to<ConvexPolygonShape>()) {
PoolVector<Vector3> points = s->cast_to<ConvexPolygonShape>()->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> points;
- points.resize(md.edges.size()*2);
- for(int i=0;i<md.edges.size();i++) {
- points[i*2+0]=md.vertices[md.edges[i].a];
- points[i*2+1]=md.vertices[md.edges[i].b];
+ points.resize(md.edges.size() * 2);
+ for (int i = 0; i < md.edges.size(); i++) {
+ points[i * 2 + 0] = md.vertices[md.edges[i].a];
+ points[i * 2 + 1] = md.vertices[md.edges[i].b];
}
-
- add_lines(points,SpatialEditorGizmos::singleton->shape_material);
+ add_lines(points, SpatialEditorGizmos::singleton->shape_material);
add_collision_segments(points);
-
}
}
-
}
-
if (s->cast_to<RayShape>()) {
- Ref<RayShape> rs=s;
+ Ref<RayShape> rs = s;
Vector<Vector3> points;
points.push_back(Vector3());
- points.push_back(Vector3(0,0,rs->get_length()));
- add_lines(points,SpatialEditorGizmos::singleton->shape_material);
+ points.push_back(Vector3(0, 0, rs->get_length()));
+ add_lines(points, SpatialEditorGizmos::singleton->shape_material);
add_collision_segments(points);
Vector<Vector3> handles;
- handles.push_back(Vector3(0,0,rs->get_length()));
+ handles.push_back(Vector3(0, 0, rs->get_length()));
add_handles(handles);
-
-
}
-
}
-CollisionShapeSpatialGizmo::CollisionShapeSpatialGizmo(CollisionShape* p_cs) {
+CollisionShapeSpatialGizmo::CollisionShapeSpatialGizmo(CollisionShape *p_cs) {
- cs=p_cs;
+ cs = p_cs;
set_spatial_node(p_cs);
}
-
-
/////
-
void CollisionPolygonSpatialGizmo::redraw() {
clear();
Vector<Vector2> points = polygon->get_polygon();
- float depth = polygon->get_depth()*0.5;
+ float depth = polygon->get_depth() * 0.5;
Vector<Vector3> lines;
- for(int i=0;i<points.size();i++) {
-
- int n = (i+1)%points.size();
- lines.push_back(Vector3(points[i].x,points[i].y,depth));
- lines.push_back(Vector3(points[n].x,points[n].y,depth));
- lines.push_back(Vector3(points[i].x,points[i].y,-depth));
- lines.push_back(Vector3(points[n].x,points[n].y,-depth));
- lines.push_back(Vector3(points[i].x,points[i].y,depth));
- lines.push_back(Vector3(points[i].x,points[i].y,-depth));
+ for (int i = 0; i < points.size(); i++) {
+ int n = (i + 1) % points.size();
+ lines.push_back(Vector3(points[i].x, points[i].y, depth));
+ lines.push_back(Vector3(points[n].x, points[n].y, depth));
+ lines.push_back(Vector3(points[i].x, points[i].y, -depth));
+ lines.push_back(Vector3(points[n].x, points[n].y, -depth));
+ lines.push_back(Vector3(points[i].x, points[i].y, depth));
+ lines.push_back(Vector3(points[i].x, points[i].y, -depth));
}
- add_lines(lines,SpatialEditorGizmos::singleton->shape_material);
+ add_lines(lines, SpatialEditorGizmos::singleton->shape_material);
add_collision_segments(lines);
}
-CollisionPolygonSpatialGizmo::CollisionPolygonSpatialGizmo(CollisionPolygon* p_polygon){
+CollisionPolygonSpatialGizmo::CollisionPolygonSpatialGizmo(CollisionPolygon *p_polygon) {
set_spatial_node(p_polygon);
- polygon=p_polygon;
+ polygon = p_polygon;
}
///
-
String VisibilityNotifierGizmo::get_handle_name(int p_idx) const {
- switch(p_idx) {
+ switch (p_idx) {
case 0: return "X";
case 1: return "Y";
case 2: return "Z";
@@ -2106,12 +1939,11 @@ String VisibilityNotifierGizmo::get_handle_name(int p_idx) const {
return "";
}
-Variant VisibilityNotifierGizmo::get_handle_value(int p_idx) const{
+Variant VisibilityNotifierGizmo::get_handle_value(int p_idx) const {
return notifier->get_aabb();
}
-void VisibilityNotifierGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point){
-
+void VisibilityNotifierGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
Transform gt = notifier->get_global_transform();
//gt.orthonormalize();
@@ -2121,25 +1953,24 @@ void VisibilityNotifierGizmo::set_handle(int p_idx,Camera *p_camera, const Point
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
- Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*4096)};
- Vector3 ofs = aabb.pos+aabb.size*0.5;
+ Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) };
+ Vector3 ofs = aabb.pos + aabb.size * 0.5;
Vector3 axis;
- axis[p_idx]=1.0;
+ axis[p_idx] = 1.0;
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(ofs,ofs+axis*4096,sg[0],sg[1],ra,rb);
+ Vector3 ra, rb;
+ Geometry::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (d<0.001)
- d=0.001;
+ if (d < 0.001)
+ d = 0.001;
- aabb.pos[p_idx]=(aabb.pos[p_idx]+aabb.size[p_idx]*0.5)-d;
- aabb.size[p_idx]=d*2;
+ aabb.pos[p_idx] = (aabb.pos[p_idx] + aabb.size[p_idx] * 0.5) - d;
+ aabb.size[p_idx] = d * 2;
notifier->set_aabb(aabb);
}
-void VisibilityNotifierGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
-
+void VisibilityNotifierGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
if (p_cancel) {
notifier->set_aabb(p_restore);
@@ -2148,57 +1979,52 @@ void VisibilityNotifierGizmo::commit_handle(int p_idx,const Variant& p_restore,b
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Notifier Extents"));
- ur->add_do_method(notifier,"set_aabb",notifier->get_aabb());
- ur->add_undo_method(notifier,"set_aabb",p_restore);
+ ur->add_do_method(notifier, "set_aabb", notifier->get_aabb());
+ ur->add_undo_method(notifier, "set_aabb", p_restore);
ur->commit_action();
-
}
-void VisibilityNotifierGizmo::redraw(){
+void VisibilityNotifierGizmo::redraw() {
clear();
Vector<Vector3> lines;
Rect3 aabb = notifier->get_aabb();
- 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);
}
Vector<Vector3> handles;
-
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
Vector3 ax;
- ax[i]=aabb.pos[i]+aabb.size[i];
+ ax[i] = aabb.pos[i] + aabb.size[i];
handles.push_back(ax);
}
- add_lines(lines,SpatialEditorGizmos::singleton->visibility_notifier_material);
+ add_lines(lines, SpatialEditorGizmos::singleton->visibility_notifier_material);
//add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05);
add_collision_segments(lines);
add_handles(handles);
-
}
-VisibilityNotifierGizmo::VisibilityNotifierGizmo(VisibilityNotifier* p_notifier){
+VisibilityNotifierGizmo::VisibilityNotifierGizmo(VisibilityNotifier *p_notifier) {
- notifier=p_notifier;
+ notifier = p_notifier;
set_spatial_node(p_notifier);
}
////////
-
///
-
String ReflectionProbeGizmo::get_handle_name(int p_idx) const {
- switch(p_idx) {
+ switch (p_idx) {
case 0: return "Extents X";
case 1: return "Extents Y";
case 2: return "Extents Z";
@@ -2209,63 +2035,61 @@ String ReflectionProbeGizmo::get_handle_name(int p_idx) const {
return "";
}
-Variant ReflectionProbeGizmo::get_handle_value(int p_idx) const{
+Variant ReflectionProbeGizmo::get_handle_value(int p_idx) const {
- return Rect3(probe->get_extents(),probe->get_origin_offset());
+ return Rect3(probe->get_extents(), probe->get_origin_offset());
}
-void ReflectionProbeGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point){
+void ReflectionProbeGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
Transform gt = probe->get_global_transform();
//gt.orthonormalize();
Transform gi = gt.affine_inverse();
-
- if (p_idx<3) {
+ if (p_idx < 3) {
Vector3 extents = probe->get_extents();
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
- Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*16384)};
+ Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) };
Vector3 axis;
- axis[p_idx]=1.0;
+ axis[p_idx] = 1.0;
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(),axis*16384,sg[0],sg[1],ra,rb);
+ Vector3 ra, rb;
+ Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (d<0.001)
- d=0.001;
+ if (d < 0.001)
+ d = 0.001;
- extents[p_idx]=d;
+ extents[p_idx] = d;
probe->set_extents(extents);
} else {
- p_idx-=3;
+ p_idx -= 3;
Vector3 origin = probe->get_origin_offset();
- origin[p_idx]=0;
+ origin[p_idx] = 0;
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
- Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*16384)};
+ Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) };
Vector3 axis;
- axis[p_idx]=1.0;
+ axis[p_idx] = 1.0;
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(origin-axis*16384,origin+axis*16384,sg[0],sg[1],ra,rb);
+ Vector3 ra, rb;
+ Geometry::get_closest_points_between_segments(origin - axis * 16384, origin + axis * 16384, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- d+=0.25;
+ d += 0.25;
- origin[p_idx]=d;
+ origin[p_idx] = d;
probe->set_origin_offset(origin);
-
}
}
-void ReflectionProbeGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
+void ReflectionProbeGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
Rect3 restore = p_restore;
@@ -2277,15 +2101,14 @@ void ReflectionProbeGizmo::commit_handle(int p_idx,const Variant& p_restore,bool
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Probe Extents"));
- ur->add_do_method(probe,"set_extents",probe->get_extents());
- ur->add_do_method(probe,"set_origin_offset",probe->get_origin_offset());
- ur->add_undo_method(probe,"set_extents",restore.pos);
- ur->add_undo_method(probe,"set_origin_offset",restore.size);
+ ur->add_do_method(probe, "set_extents", probe->get_extents());
+ ur->add_do_method(probe, "set_origin_offset", probe->get_origin_offset());
+ ur->add_undo_method(probe, "set_extents", restore.pos);
+ ur->add_undo_method(probe, "set_origin_offset", restore.size);
ur->commit_action();
-
}
-void ReflectionProbeGizmo::redraw(){
+void ReflectionProbeGizmo::redraw() {
clear();
@@ -2294,69 +2117,61 @@ void ReflectionProbeGizmo::redraw(){
Vector3 extents = probe->get_extents();
Rect3 aabb;
- aabb.pos=-extents;
- aabb.size=extents*2;
+ aabb.pos = -extents;
+ aabb.size = extents * 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);
}
- for(int i=0;i<8;i++) {
+ for (int i = 0; i < 8; i++) {
Vector3 ep = aabb.get_endpoint(i);
internal_lines.push_back(probe->get_origin_offset());
internal_lines.push_back(ep);
-
-
}
Vector<Vector3> handles;
-
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
Vector3 ax;
- ax[i]=aabb.pos[i]+aabb.size[i];
+ ax[i] = aabb.pos[i] + aabb.size[i];
handles.push_back(ax);
}
- for(int i=0;i<3;i++) {
-
+ for (int i = 0; i < 3; i++) {
- Vector3 orig_handle=probe->get_origin_offset();
- orig_handle[i]-=0.25;
+ Vector3 orig_handle = probe->get_origin_offset();
+ orig_handle[i] -= 0.25;
lines.push_back(orig_handle);
handles.push_back(orig_handle);
- orig_handle[i]+=0.5;
+ orig_handle[i] += 0.5;
lines.push_back(orig_handle);
}
- add_lines(lines,SpatialEditorGizmos::singleton->reflection_probe_material);
- add_lines(internal_lines,SpatialEditorGizmos::singleton->reflection_probe_material_internal);
+ add_lines(lines, SpatialEditorGizmos::singleton->reflection_probe_material);
+ add_lines(internal_lines, SpatialEditorGizmos::singleton->reflection_probe_material_internal);
//add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05);
add_collision_segments(lines);
add_handles(handles);
-
}
-ReflectionProbeGizmo::ReflectionProbeGizmo(ReflectionProbe* p_probe){
+ReflectionProbeGizmo::ReflectionProbeGizmo(ReflectionProbe *p_probe) {
- probe=p_probe;
+ probe = p_probe;
set_spatial_node(p_probe);
}
////////
-
-
///
-
String GIProbeGizmo::get_handle_name(int p_idx) const {
- switch(p_idx) {
+ switch (p_idx) {
case 0: return "Extents X";
case 1: return "Extents Y";
case 2: return "Extents Z";
@@ -2364,39 +2179,37 @@ String GIProbeGizmo::get_handle_name(int p_idx) const {
return "";
}
-Variant GIProbeGizmo::get_handle_value(int p_idx) const{
+Variant GIProbeGizmo::get_handle_value(int p_idx) const {
return probe->get_extents();
}
-void GIProbeGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point){
+void GIProbeGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
Transform gt = probe->get_global_transform();
//gt.orthonormalize();
Transform gi = gt.affine_inverse();
-
Vector3 extents = probe->get_extents();
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
- Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*16384)};
+ Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) };
Vector3 axis;
- axis[p_idx]=1.0;
+ axis[p_idx] = 1.0;
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(),axis*16384,sg[0],sg[1],ra,rb);
+ Vector3 ra, rb;
+ Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb);
float d = ra[p_idx];
- if (d<0.001)
- d=0.001;
+ if (d < 0.001)
+ d = 0.001;
- extents[p_idx]=d;
+ extents[p_idx] = d;
probe->set_extents(extents);
-
}
-void GIProbeGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
+void GIProbeGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
Vector3 restore = p_restore;
@@ -2407,108 +2220,97 @@ void GIProbeGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cance
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
ur->create_action(TTR("Change Probe Extents"));
- ur->add_do_method(probe,"set_extents",probe->get_extents());
- ur->add_undo_method(probe,"set_extents",restore);
+ ur->add_do_method(probe, "set_extents", probe->get_extents());
+ ur->add_undo_method(probe, "set_extents", restore);
ur->commit_action();
-
}
-void GIProbeGizmo::redraw(){
+void GIProbeGizmo::redraw() {
clear();
Vector<Vector3> lines;
Vector3 extents = probe->get_extents();
- static const int subdivs[GIProbe::SUBDIV_MAX]={64,128,256,512};
+ static const int subdivs[GIProbe::SUBDIV_MAX] = { 64, 128, 256, 512 };
- Rect3 aabb = Rect3(-extents,extents*2);
+ Rect3 aabb = Rect3(-extents, extents * 2);
int subdiv = subdivs[probe->get_subdiv()];
- float cell_size = aabb.get_longest_axis_size()/subdiv;
+ float cell_size = aabb.get_longest_axis_size() / subdiv;
-
- 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);
}
- add_lines(lines,SpatialEditorGizmos::singleton->gi_probe_material);
+ add_lines(lines, SpatialEditorGizmos::singleton->gi_probe_material);
add_collision_segments(lines);
lines.clear();
- for(int i=1;i<subdiv;i++) {
-
- for(int j=0;j<3;j++) {
-
+ for (int i = 1; i < subdiv; i++) {
+ for (int j = 0; j < 3; j++) {
- if (cell_size*i>aabb.size[j]) {
+ if (cell_size * i > aabb.size[j]) {
continue;
}
Vector2 dir;
- dir[j]=1.0;
- Vector2 ta,tb;
- int j_n1=(j+1)%3;
- int j_n2=(j+2)%3;
- ta[j_n1]=1.0;
- tb[j_n2]=1.0;
+ dir[j] = 1.0;
+ Vector2 ta, tb;
+ int j_n1 = (j + 1) % 3;
+ int j_n2 = (j + 2) % 3;
+ ta[j_n1] = 1.0;
+ tb[j_n2] = 1.0;
+ for (int k = 0; k < 4; k++) {
- for(int k=0;k<4;k++) {
+ Vector3 from = aabb.pos, to = aabb.pos;
+ from[j] += cell_size * i;
+ to[j] += cell_size * i;
- Vector3 from=aabb.pos,to=aabb.pos;
- from[j]+= cell_size*i;
- to[j]+=cell_size*i;
-
- if (k&1) {
- to[j_n1]+=aabb.size[j_n1];
+ if (k & 1) {
+ to[j_n1] += aabb.size[j_n1];
} else {
- to[j_n2]+=aabb.size[j_n2];
+ to[j_n2] += aabb.size[j_n2];
}
- if (k&2) {
- from[j_n1]+=aabb.size[j_n1];
- from[j_n2]+=aabb.size[j_n2];
+ if (k & 2) {
+ from[j_n1] += aabb.size[j_n1];
+ from[j_n2] += aabb.size[j_n2];
}
lines.push_back(from);
lines.push_back(to);
}
-
}
-
}
- add_lines(lines,SpatialEditorGizmos::singleton->gi_probe_material_internal);
+ add_lines(lines, SpatialEditorGizmos::singleton->gi_probe_material_internal);
Vector<Vector3> handles;
-
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
Vector3 ax;
- ax[i]=aabb.pos[i]+aabb.size[i];
+ ax[i] = aabb.pos[i] + aabb.size[i];
handles.push_back(ax);
}
-
add_handles(handles);
-
}
-GIProbeGizmo::GIProbeGizmo(GIProbe* p_probe){
+GIProbeGizmo::GIProbeGizmo(GIProbe *p_probe) {
- probe=p_probe;
+ probe = p_probe;
set_spatial_node(p_probe);
}
////////
-
void NavigationMeshSpatialGizmo::redraw() {
clear();
@@ -2517,16 +2319,16 @@ void NavigationMeshSpatialGizmo::redraw() {
return;
PoolVector<Vector3> vertices = navmeshie->get_vertices();
- PoolVector<Vector3>::Read vr=vertices.read();
+ PoolVector<Vector3>::Read vr = vertices.read();
List<Face3> faces;
- for(int i=0;i<navmeshie->get_polygon_count();i++) {
+ for (int i = 0; i < navmeshie->get_polygon_count(); i++) {
Vector<int> p = navmeshie->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);
}
@@ -2535,45 +2337,43 @@ void NavigationMeshSpatialGizmo::redraw() {
if (faces.empty())
return;
- Map<_EdgeKey,bool> edge_map;
+ Map<_EdgeKey, bool> edge_map;
PoolVector<Vector3> tmeshfaces;
- tmeshfaces.resize(faces.size()*3);
+ tmeshfaces.resize(faces.size() * 3);
{
- PoolVector<Vector3>::Write tw=tmeshfaces.write();
- int tidx=0;
+ PoolVector<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;
}
-
}
}
}
Vector<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);
@@ -2581,55 +2381,50 @@ void NavigationMeshSpatialGizmo::redraw() {
}
}
- Ref<TriangleMesh> tmesh = memnew( TriangleMesh );
+ Ref<TriangleMesh> tmesh = memnew(TriangleMesh);
tmesh->create(tmeshfaces);
if (lines.size())
- add_lines(lines,navmesh->is_enabled()?SpatialEditorGizmos::singleton->navmesh_edge_material:SpatialEditorGizmos::singleton->navmesh_edge_material_disabled);
+ add_lines(lines, navmesh->is_enabled() ? SpatialEditorGizmos::singleton->navmesh_edge_material : SpatialEditorGizmos::singleton->navmesh_edge_material_disabled);
add_collision_triangles(tmesh);
- Ref<Mesh> m = memnew( Mesh );
+ Ref<Mesh> m = memnew(Mesh);
Array a;
a.resize(Mesh::ARRAY_MAX);
- a[0]=tmeshfaces;
- m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES,a);
- m->surface_set_material(0,navmesh->is_enabled()?SpatialEditorGizmos::singleton->navmesh_solid_material:SpatialEditorGizmos::singleton->navmesh_solid_material_disabled);
+ a[0] = tmeshfaces;
+ m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a);
+ m->surface_set_material(0, navmesh->is_enabled() ? SpatialEditorGizmos::singleton->navmesh_solid_material : SpatialEditorGizmos::singleton->navmesh_solid_material_disabled);
add_mesh(m);
add_collision_segments(lines);
-
}
-NavigationMeshSpatialGizmo::NavigationMeshSpatialGizmo(NavigationMeshInstance *p_navmesh){
+NavigationMeshSpatialGizmo::NavigationMeshSpatialGizmo(NavigationMeshInstance *p_navmesh) {
set_spatial_node(p_navmesh);
- navmesh=p_navmesh;
+ navmesh = p_navmesh;
}
//////
///
///
-
-
void PinJointSpatialGizmo::redraw() {
clear();
Vector<Vector3> cursor_points;
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_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));
add_collision_segments(cursor_points);
- add_lines(cursor_points,SpatialEditorGizmos::singleton->joint_material);
-
+ add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
}
+PinJointSpatialGizmo::PinJointSpatialGizmo(PinJoint *p_p3d) {
-PinJointSpatialGizmo::PinJointSpatialGizmo(PinJoint* p_p3d) {
-
- p3d=p_p3d;
+ p3d = p_p3d;
set_spatial_node(p3d);
}
@@ -2644,71 +2439,63 @@ void HingeJointSpatialGizmo::redraw() {
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*2));
- cursor_points.push_back(Vector3(0,0,-cs*2));
+ cursor_points.push_back(Vector3(0, 0, +cs * 2));
+ cursor_points.push_back(Vector3(0, 0, -cs * 2));
float ll = p3d->get_param(HingeJoint::PARAM_LIMIT_LOWER);
float ul = p3d->get_param(HingeJoint::PARAM_LIMIT_UPPER);
- if (p3d->get_flag(HingeJoint::FLAG_USE_LIMIT) && ll<ul) {
+ if (p3d->get_flag(HingeJoint::FLAG_USE_LIMIT) && ll < ul) {
const int points = 32;
- for(int i=0;i<points;i++) {
+ for (int i = 0; i < points; i++) {
- float s = ll+i*(ul-ll)/points;
- float n = ll+(i+1)*(ul-ll)/points;
+ float s = ll + i * (ul - ll) / points;
+ float n = ll + (i + 1) * (ul - ll) / points;
- Vector3 from=Vector3( -Math::sin(s),Math::cos(s), 0 )*cs;
- Vector3 to=Vector3( -Math::sin(n),Math::cos(n), 0 )*cs;
+ Vector3 from = Vector3(-Math::sin(s), Math::cos(s), 0) * cs;
+ Vector3 to = Vector3(-Math::sin(n), Math::cos(n), 0) * cs;
- if (i==points-1) {
+ if (i == points - 1) {
cursor_points.push_back(to);
cursor_points.push_back(Vector3());
}
- if (i==0) {
+ if (i == 0) {
cursor_points.push_back(from);
cursor_points.push_back(Vector3());
}
-
cursor_points.push_back(from);
cursor_points.push_back(to);
-
-
}
- cursor_points.push_back(Vector3(0,cs*1.5,0));
+ cursor_points.push_back(Vector3(0, cs * 1.5, 0));
cursor_points.push_back(Vector3());
} else {
-
const int points = 32;
- for(int i=0;i<points;i++) {
+ for (int i = 0; i < points; i++) {
- float s = ll+i*(Math_PI*2.0)/points;
- float n = ll+(i+1)*(Math_PI*2.0)/points;
+ float s = ll + i * (Math_PI * 2.0) / points;
+ float n = ll + (i + 1) * (Math_PI * 2.0) / points;
- Vector3 from=Vector3( -Math::sin(s),Math::cos(s), 0 )*cs;
- Vector3 to=Vector3( -Math::sin(n),Math::cos(n), 0 )*cs;
+ Vector3 from = Vector3(-Math::sin(s), Math::cos(s), 0) * cs;
+ Vector3 to = Vector3(-Math::sin(n), Math::cos(n), 0) * cs;
cursor_points.push_back(from);
cursor_points.push_back(to);
-
}
-
}
add_collision_segments(cursor_points);
- add_lines(cursor_points,SpatialEditorGizmos::singleton->joint_material);
-
+ add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
}
+HingeJointSpatialGizmo::HingeJointSpatialGizmo(HingeJoint *p_p3d) {
-HingeJointSpatialGizmo::HingeJointSpatialGizmo(HingeJoint* p_p3d) {
-
- p3d=p_p3d;
+ p3d = p_p3d;
set_spatial_node(p3d);
}
@@ -2725,105 +2512,94 @@ void SliderJointSpatialGizmo::redraw() {
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*2));
- cursor_points.push_back(Vector3(0,0,-cs*2));
+ cursor_points.push_back(Vector3(0, 0, +cs * 2));
+ cursor_points.push_back(Vector3(0, 0, -cs * 2));
float ll = p3d->get_param(SliderJoint::PARAM_ANGULAR_LIMIT_LOWER);
float ul = p3d->get_param(SliderJoint::PARAM_ANGULAR_LIMIT_UPPER);
float lll = -p3d->get_param(SliderJoint::PARAM_LINEAR_LIMIT_LOWER);
float lul = -p3d->get_param(SliderJoint::PARAM_LINEAR_LIMIT_UPPER);
- if (lll>lul) {
-
- cursor_points.push_back(Vector3(lul,0,0));
- cursor_points.push_back(Vector3(lll,0,0));
-
- cursor_points.push_back(Vector3(lul,-cs,-cs));
- cursor_points.push_back(Vector3(lul,-cs,cs));
- cursor_points.push_back(Vector3(lul,-cs,cs));
- cursor_points.push_back(Vector3(lul,cs,cs));
- cursor_points.push_back(Vector3(lul,cs,cs));
- cursor_points.push_back(Vector3(lul,cs,-cs));
- cursor_points.push_back(Vector3(lul,cs,-cs));
- cursor_points.push_back(Vector3(lul,-cs,-cs));
-
-
- cursor_points.push_back(Vector3(lll,-cs,-cs));
- cursor_points.push_back(Vector3(lll,-cs,cs));
- cursor_points.push_back(Vector3(lll,-cs,cs));
- cursor_points.push_back(Vector3(lll,cs,cs));
- cursor_points.push_back(Vector3(lll,cs,cs));
- cursor_points.push_back(Vector3(lll,cs,-cs));
- cursor_points.push_back(Vector3(lll,cs,-cs));
- cursor_points.push_back(Vector3(lll,-cs,-cs));
-
+ if (lll > lul) {
+
+ cursor_points.push_back(Vector3(lul, 0, 0));
+ cursor_points.push_back(Vector3(lll, 0, 0));
+
+ cursor_points.push_back(Vector3(lul, -cs, -cs));
+ cursor_points.push_back(Vector3(lul, -cs, cs));
+ cursor_points.push_back(Vector3(lul, -cs, cs));
+ cursor_points.push_back(Vector3(lul, cs, cs));
+ cursor_points.push_back(Vector3(lul, cs, cs));
+ cursor_points.push_back(Vector3(lul, cs, -cs));
+ cursor_points.push_back(Vector3(lul, cs, -cs));
+ cursor_points.push_back(Vector3(lul, -cs, -cs));
+
+ cursor_points.push_back(Vector3(lll, -cs, -cs));
+ cursor_points.push_back(Vector3(lll, -cs, cs));
+ cursor_points.push_back(Vector3(lll, -cs, cs));
+ cursor_points.push_back(Vector3(lll, cs, cs));
+ cursor_points.push_back(Vector3(lll, cs, cs));
+ cursor_points.push_back(Vector3(lll, cs, -cs));
+ cursor_points.push_back(Vector3(lll, cs, -cs));
+ cursor_points.push_back(Vector3(lll, -cs, -cs));
} else {
- cursor_points.push_back(Vector3(+cs*2,0,0));
- cursor_points.push_back(Vector3(-cs*2,0,0));
-
+ cursor_points.push_back(Vector3(+cs * 2, 0, 0));
+ cursor_points.push_back(Vector3(-cs * 2, 0, 0));
}
- if (ll<ul) {
+ if (ll < ul) {
const int points = 32;
- for(int i=0;i<points;i++) {
+ for (int i = 0; i < points; i++) {
- float s = ll+i*(ul-ll)/points;
- float n = ll+(i+1)*(ul-ll)/points;
+ float s = ll + i * (ul - ll) / points;
+ float n = ll + (i + 1) * (ul - ll) / points;
- Vector3 from=Vector3(0, Math::cos(s), -Math::sin(s) )*cs;
- Vector3 to=Vector3(0,Math::cos(n), -Math::sin(n) )*cs;
+ Vector3 from = Vector3(0, Math::cos(s), -Math::sin(s)) * cs;
+ Vector3 to = Vector3(0, Math::cos(n), -Math::sin(n)) * cs;
- if (i==points-1) {
+ if (i == points - 1) {
cursor_points.push_back(to);
cursor_points.push_back(Vector3());
}
- if (i==0) {
+ if (i == 0) {
cursor_points.push_back(from);
cursor_points.push_back(Vector3());
}
-
cursor_points.push_back(from);
cursor_points.push_back(to);
-
-
}
- cursor_points.push_back(Vector3(0,cs*1.5,0));
+ cursor_points.push_back(Vector3(0, cs * 1.5, 0));
cursor_points.push_back(Vector3());
} else {
-
const int points = 32;
- for(int i=0;i<points;i++) {
+ for (int i = 0; i < points; i++) {
- float s = ll+i*(Math_PI*2.0)/points;
- float n = ll+(i+1)*(Math_PI*2.0)/points;
+ float s = ll + i * (Math_PI * 2.0) / points;
+ float n = ll + (i + 1) * (Math_PI * 2.0) / points;
- Vector3 from=Vector3(0,Math::cos(s),-Math::sin(s) )*cs;
- Vector3 to=Vector3( 0,Math::cos(n),-Math::sin(n) )*cs;
+ Vector3 from = Vector3(0, Math::cos(s), -Math::sin(s)) * cs;
+ Vector3 to = Vector3(0, Math::cos(n), -Math::sin(n)) * cs;
cursor_points.push_back(from);
cursor_points.push_back(to);
-
}
-
}
add_collision_segments(cursor_points);
- add_lines(cursor_points,SpatialEditorGizmos::singleton->joint_material);
-
+ add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
}
+SliderJointSpatialGizmo::SliderJointSpatialGizmo(SliderJoint *p_p3d) {
-SliderJointSpatialGizmo::SliderJointSpatialGizmo(SliderJoint* p_p3d) {
-
- p3d=p_p3d;
+ p3d = p_p3d;
set_spatial_node(p3d);
}
@@ -2837,72 +2613,65 @@ void ConeTwistJointSpatialGizmo::redraw() {
Vector<Vector3> points;
float r = 1.0;
- float w = r*Math::sin(p3d->get_param(ConeTwistJoint::PARAM_SWING_SPAN));
- float d = r*Math::cos(p3d->get_param(ConeTwistJoint::PARAM_SWING_SPAN));
-
+ float w = r * Math::sin(p3d->get_param(ConeTwistJoint::PARAM_SWING_SPAN));
+ float d = r * Math::cos(p3d->get_param(ConeTwistJoint::PARAM_SWING_SPAN));
//swing
- for(int i=0;i<360;i+=10) {
+ for (int i = 0; i < 360; i += 10) {
- float ra=Math::deg2rad((float)i);
- float rb=Math::deg2rad((float)i+10);
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*w;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*w;
+ float ra = Math::deg2rad((float)i);
+ float rb = Math::deg2rad((float)i + 10);
+ Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w;
+ Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * w;
/*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(d,a.x,a.y));
- points.push_back(Vector3(d,b.x,b.y));
+ points.push_back(Vector3(d, a.x, a.y));
+ points.push_back(Vector3(d, b.x, b.y));
- if (i%90==0) {
+ if (i % 90 == 0) {
- points.push_back(Vector3(d,a.x,a.y));
+ points.push_back(Vector3(d, a.x, a.y));
points.push_back(Vector3());
-
}
}
points.push_back(Vector3());
- points.push_back(Vector3(1,0,0));
+ points.push_back(Vector3(1, 0, 0));
//twist
/*
*/
- float ts=Math::rad2deg(p3d->get_param(ConeTwistJoint::PARAM_TWIST_SPAN));
- ts=MIN(ts,720);
-
+ float ts = Math::rad2deg(p3d->get_param(ConeTwistJoint::PARAM_TWIST_SPAN));
+ ts = MIN(ts, 720);
- for(int i=0;i<int(ts);i+=5) {
+ for (int i = 0; i < int(ts); i += 5) {
- float ra=Math::deg2rad((float)i);
- float rb=Math::deg2rad((float)i+5);
- float c = i/720.0;
- float cn = (i+5)/720.0;
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*w*c;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*w*cn;
+ float ra = Math::deg2rad((float)i);
+ float rb = Math::deg2rad((float)i + 5);
+ float c = i / 720.0;
+ float cn = (i + 5) / 720.0;
+ Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w * c;
+ Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * w * cn;
/*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(c,a.x,a.y));
- points.push_back(Vector3(cn,b.x,b.y));
-
+ points.push_back(Vector3(c, a.x, a.y));
+ points.push_back(Vector3(cn, b.x, b.y));
}
-
add_collision_segments(points);
- add_lines(points,SpatialEditorGizmos::singleton->joint_material);
-
+ add_lines(points, SpatialEditorGizmos::singleton->joint_material);
}
+ConeTwistJointSpatialGizmo::ConeTwistJointSpatialGizmo(ConeTwistJoint *p_p3d) {
-ConeTwistJointSpatialGizmo::ConeTwistJointSpatialGizmo(ConeTwistJoint* p_p3d) {
-
- p3d=p_p3d;
+ p3d = p_p3d;
set_spatial_node(p3d);
}
@@ -2919,7 +2688,7 @@ void Generic6DOFJointSpatialGizmo::redraw() {
Vector<Vector3> cursor_points;
float cs = 0.25;
- for(int ax=0;ax<3;ax++) {
+ for (int ax = 0; ax < 3; ax++) {
/*cursor_points.push_back(Vector3(+cs,0,0));
cursor_points.push_back(Vector3(-cs,0,0));
cursor_points.push_back(Vector3(0,+cs,0));
@@ -2932,11 +2701,11 @@ void Generic6DOFJointSpatialGizmo::redraw() {
float lll;
float lul;
- int a1,a2,a3;
+ int a1, a2, a3;
bool enable_ang;
bool enable_lin;
- switch(ax) {
+ switch (ax) {
case 0:
ll = p3d->get_param_x(Generic6DOFJoint::PARAM_ANGULAR_LOWER_LIMIT);
ul = p3d->get_param_x(Generic6DOFJoint::PARAM_ANGULAR_UPPER_LIMIT);
@@ -2944,10 +2713,10 @@ void Generic6DOFJointSpatialGizmo::redraw() {
lul = -p3d->get_param_x(Generic6DOFJoint::PARAM_LINEAR_UPPER_LIMIT);
enable_ang = p3d->get_flag_x(Generic6DOFJoint::FLAG_ENABLE_ANGULAR_LIMIT);
enable_lin = p3d->get_flag_x(Generic6DOFJoint::FLAG_ENABLE_LINEAR_LIMIT);
- a1=0;
- a2=1;
- a3=2;
- break;
+ a1 = 0;
+ a2 = 1;
+ a3 = 2;
+ break;
case 1:
ll = p3d->get_param_y(Generic6DOFJoint::PARAM_ANGULAR_LOWER_LIMIT);
ul = p3d->get_param_y(Generic6DOFJoint::PARAM_ANGULAR_UPPER_LIMIT);
@@ -2955,10 +2724,10 @@ void Generic6DOFJointSpatialGizmo::redraw() {
lul = -p3d->get_param_y(Generic6DOFJoint::PARAM_LINEAR_UPPER_LIMIT);
enable_ang = p3d->get_flag_y(Generic6DOFJoint::FLAG_ENABLE_ANGULAR_LIMIT);
enable_lin = p3d->get_flag_y(Generic6DOFJoint::FLAG_ENABLE_LINEAR_LIMIT);
- a1=2;
- a2=0;
- a3=1;
- break;
+ a1 = 2;
+ a2 = 0;
+ a3 = 1;
+ break;
case 2:
ll = p3d->get_param_z(Generic6DOFJoint::PARAM_ANGULAR_LOWER_LIMIT);
ul = p3d->get_param_z(Generic6DOFJoint::PARAM_ANGULAR_UPPER_LIMIT);
@@ -2967,125 +2736,113 @@ void Generic6DOFJointSpatialGizmo::redraw() {
enable_ang = p3d->get_flag_z(Generic6DOFJoint::FLAG_ENABLE_ANGULAR_LIMIT);
enable_lin = p3d->get_flag_z(Generic6DOFJoint::FLAG_ENABLE_LINEAR_LIMIT);
- a1=1;
- a2=2;
- a3=0;
- break;
- }
-
-#define ADD_VTX(x,y,z)\
- {\
- Vector3 v;\
- v[a1]=(x);\
- v[a2]=(y);\
- v[a3]=(z);\
- cursor_points.push_back(v);\
- }
-
-#define SET_VTX(what,x,y,z)\
- {\
- Vector3 v;\
- v[a1]=(x);\
- v[a2]=(y);\
- v[a3]=(z);\
- what=v;\
+ a1 = 1;
+ a2 = 2;
+ a3 = 0;
+ break;
}
-
-
-
- if (enable_lin && lll>=lul) {
-
- ADD_VTX(lul,0,0);
- ADD_VTX(lll,0,0);
-
- ADD_VTX(lul,-cs,-cs);
- ADD_VTX(lul,-cs,cs);
- ADD_VTX(lul,-cs,cs);
- ADD_VTX(lul,cs,cs);
- ADD_VTX(lul,cs,cs);
- ADD_VTX(lul,cs,-cs);
- ADD_VTX(lul,cs,-cs);
- ADD_VTX(lul,-cs,-cs);
-
-
- ADD_VTX(lll,-cs,-cs);
- ADD_VTX(lll,-cs,cs);
- ADD_VTX(lll,-cs,cs);
- ADD_VTX(lll,cs,cs);
- ADD_VTX(lll,cs,cs);
- ADD_VTX(lll,cs,-cs);
- ADD_VTX(lll,cs,-cs);
- ADD_VTX(lll,-cs,-cs);
-
+#define ADD_VTX(x, y, z) \
+ { \
+ Vector3 v; \
+ v[a1] = (x); \
+ v[a2] = (y); \
+ v[a3] = (z); \
+ cursor_points.push_back(v); \
+ }
+
+#define SET_VTX(what, x, y, z) \
+ { \
+ Vector3 v; \
+ v[a1] = (x); \
+ v[a2] = (y); \
+ v[a3] = (z); \
+ what = v; \
+ }
+
+ if (enable_lin && lll >= lul) {
+
+ ADD_VTX(lul, 0, 0);
+ ADD_VTX(lll, 0, 0);
+
+ ADD_VTX(lul, -cs, -cs);
+ ADD_VTX(lul, -cs, cs);
+ ADD_VTX(lul, -cs, cs);
+ ADD_VTX(lul, cs, cs);
+ ADD_VTX(lul, cs, cs);
+ ADD_VTX(lul, cs, -cs);
+ ADD_VTX(lul, cs, -cs);
+ ADD_VTX(lul, -cs, -cs);
+
+ ADD_VTX(lll, -cs, -cs);
+ ADD_VTX(lll, -cs, cs);
+ ADD_VTX(lll, -cs, cs);
+ ADD_VTX(lll, cs, cs);
+ ADD_VTX(lll, cs, cs);
+ ADD_VTX(lll, cs, -cs);
+ ADD_VTX(lll, cs, -cs);
+ ADD_VTX(lll, -cs, -cs);
} else {
- ADD_VTX(+cs*2,0,0);
- ADD_VTX(-cs*2,0,0);
-
+ ADD_VTX(+cs * 2, 0, 0);
+ ADD_VTX(-cs * 2, 0, 0);
}
- if (enable_ang && ll<=ul) {
+ if (enable_ang && ll <= ul) {
const int points = 32;
- for(int i=0;i<points;i++) {
+ for (int i = 0; i < points; i++) {
- float s = ll+i*(ul-ll)/points;
- float n = ll+(i+1)*(ul-ll)/points;
+ float s = ll + i * (ul - ll) / points;
+ float n = ll + (i + 1) * (ul - ll) / points;
Vector3 from;
- SET_VTX(from,0, Math::cos(s), -Math::sin(s) );
- from*=cs;
+ SET_VTX(from, 0, Math::cos(s), -Math::sin(s));
+ from *= cs;
Vector3 to;
- SET_VTX(to,0,Math::cos(n), -Math::sin(n));
- to*=cs;
+ SET_VTX(to, 0, Math::cos(n), -Math::sin(n));
+ to *= cs;
- if (i==points-1) {
+ if (i == points - 1) {
cursor_points.push_back(to);
cursor_points.push_back(Vector3());
}
- if (i==0) {
+ if (i == 0) {
cursor_points.push_back(from);
cursor_points.push_back(Vector3());
}
-
cursor_points.push_back(from);
cursor_points.push_back(to);
-
-
}
- ADD_VTX(0,cs*1.5,0);
+ ADD_VTX(0, cs * 1.5, 0);
cursor_points.push_back(Vector3());
} else {
-
const int points = 32;
- for(int i=0;i<points;i++) {
+ for (int i = 0; i < points; i++) {
- float s = ll+i*(Math_PI*2.0)/points;
- float n = ll+(i+1)*(Math_PI*2.0)/points;
+ float s = ll + i * (Math_PI * 2.0) / points;
+ float n = ll + (i + 1) * (Math_PI * 2.0) / points;
//Vector3 from=Vector3(0,Math::cos(s),-Math::sin(s) )*cs;
//Vector3 to=Vector3( 0,Math::cos(n),-Math::sin(n) )*cs;
Vector3 from;
- SET_VTX(from,0, Math::cos(s), -Math::sin(s) );
- from*=cs;
+ SET_VTX(from, 0, Math::cos(s), -Math::sin(s));
+ from *= cs;
Vector3 to;
- SET_VTX(to,0,Math::cos(n), -Math::sin(n));
- to*=cs;
+ SET_VTX(to, 0, Math::cos(n), -Math::sin(n));
+ to *= cs;
cursor_points.push_back(from);
cursor_points.push_back(to);
-
}
-
}
}
@@ -3093,14 +2850,12 @@ void Generic6DOFJointSpatialGizmo::redraw() {
#undef SET_VTX
add_collision_segments(cursor_points);
- add_lines(cursor_points,SpatialEditorGizmos::singleton->joint_material);
-
+ add_lines(cursor_points, SpatialEditorGizmos::singleton->joint_material);
}
+Generic6DOFJointSpatialGizmo::Generic6DOFJointSpatialGizmo(Generic6DOFJoint *p_p3d) {
-Generic6DOFJointSpatialGizmo::Generic6DOFJointSpatialGizmo(Generic6DOFJoint* p_p3d) {
-
- p3d=p_p3d;
+ p3d = p_p3d;
set_spatial_node(p3d);
}
@@ -3108,147 +2863,140 @@ Generic6DOFJointSpatialGizmo::Generic6DOFJointSpatialGizmo(Generic6DOFJoint* p_p
///
////
-
-SpatialEditorGizmos *SpatialEditorGizmos::singleton=NULL;
+SpatialEditorGizmos *SpatialEditorGizmos::singleton = NULL;
Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
if (p_spatial->cast_to<Light>()) {
- Ref<LightSpatialGizmo> lsg = memnew( LightSpatialGizmo(p_spatial->cast_to<Light>()) );
+ Ref<LightSpatialGizmo> lsg = memnew(LightSpatialGizmo(p_spatial->cast_to<Light>()));
return lsg;
}
-
-
if (p_spatial->cast_to<Camera>()) {
- Ref<CameraSpatialGizmo> lsg = memnew( CameraSpatialGizmo(p_spatial->cast_to<Camera>()) );
+ Ref<CameraSpatialGizmo> lsg = memnew(CameraSpatialGizmo(p_spatial->cast_to<Camera>()));
return lsg;
}
if (p_spatial->cast_to<Skeleton>()) {
- Ref<SkeletonSpatialGizmo> lsg = memnew( SkeletonSpatialGizmo(p_spatial->cast_to<Skeleton>()) );
+ Ref<SkeletonSpatialGizmo> lsg = memnew(SkeletonSpatialGizmo(p_spatial->cast_to<Skeleton>()));
return lsg;
}
-
if (p_spatial->cast_to<Position3D>()) {
- Ref<Position3DSpatialGizmo> lsg = memnew( Position3DSpatialGizmo(p_spatial->cast_to<Position3D>()) );
+ Ref<Position3DSpatialGizmo> lsg = memnew(Position3DSpatialGizmo(p_spatial->cast_to<Position3D>()));
return lsg;
}
if (p_spatial->cast_to<MeshInstance>()) {
- Ref<MeshInstanceSpatialGizmo> misg = memnew( MeshInstanceSpatialGizmo(p_spatial->cast_to<MeshInstance>()) );
+ Ref<MeshInstanceSpatialGizmo> misg = memnew(MeshInstanceSpatialGizmo(p_spatial->cast_to<MeshInstance>()));
return misg;
}
if (p_spatial->cast_to<Room>()) {
- Ref<RoomSpatialGizmo> misg = memnew( RoomSpatialGizmo(p_spatial->cast_to<Room>()) );
+ Ref<RoomSpatialGizmo> misg = memnew(RoomSpatialGizmo(p_spatial->cast_to<Room>()));
return misg;
}
if (p_spatial->cast_to<NavigationMeshInstance>()) {
- Ref<NavigationMeshSpatialGizmo> misg = memnew( NavigationMeshSpatialGizmo(p_spatial->cast_to<NavigationMeshInstance>()) );
+ Ref<NavigationMeshSpatialGizmo> misg = memnew(NavigationMeshSpatialGizmo(p_spatial->cast_to<NavigationMeshInstance>()));
return misg;
}
if (p_spatial->cast_to<RayCast>()) {
- Ref<RayCastSpatialGizmo> misg = memnew( RayCastSpatialGizmo(p_spatial->cast_to<RayCast>()) );
+ Ref<RayCastSpatialGizmo> misg = memnew(RayCastSpatialGizmo(p_spatial->cast_to<RayCast>()));
return misg;
}
if (p_spatial->cast_to<Portal>()) {
- Ref<PortalSpatialGizmo> misg = memnew( PortalSpatialGizmo(p_spatial->cast_to<Portal>()) );
+ Ref<PortalSpatialGizmo> misg = memnew(PortalSpatialGizmo(p_spatial->cast_to<Portal>()));
return misg;
}
-
if (p_spatial->cast_to<TestCube>()) {
- Ref<TestCubeSpatialGizmo> misg = memnew( TestCubeSpatialGizmo(p_spatial->cast_to<TestCube>()) );
+ Ref<TestCubeSpatialGizmo> misg = memnew(TestCubeSpatialGizmo(p_spatial->cast_to<TestCube>()));
return misg;
}
if (p_spatial->cast_to<CollisionShape>()) {
- Ref<CollisionShapeSpatialGizmo> misg = memnew( CollisionShapeSpatialGizmo(p_spatial->cast_to<CollisionShape>()) );
+ Ref<CollisionShapeSpatialGizmo> misg = memnew(CollisionShapeSpatialGizmo(p_spatial->cast_to<CollisionShape>()));
return misg;
}
if (p_spatial->cast_to<VisibilityNotifier>()) {
- Ref<VisibilityNotifierGizmo> misg = memnew( VisibilityNotifierGizmo(p_spatial->cast_to<VisibilityNotifier>()) );
+ Ref<VisibilityNotifierGizmo> misg = memnew(VisibilityNotifierGizmo(p_spatial->cast_to<VisibilityNotifier>()));
return misg;
}
if (p_spatial->cast_to<ReflectionProbe>()) {
- Ref<ReflectionProbeGizmo> misg = memnew( ReflectionProbeGizmo(p_spatial->cast_to<ReflectionProbe>()) );
+ Ref<ReflectionProbeGizmo> misg = memnew(ReflectionProbeGizmo(p_spatial->cast_to<ReflectionProbe>()));
return misg;
}
if (p_spatial->cast_to<GIProbe>()) {
- Ref<GIProbeGizmo> misg = memnew( GIProbeGizmo(p_spatial->cast_to<GIProbe>()) );
+ Ref<GIProbeGizmo> misg = memnew(GIProbeGizmo(p_spatial->cast_to<GIProbe>()));
return misg;
}
if (p_spatial->cast_to<VehicleWheel>()) {
- Ref<VehicleWheelSpatialGizmo> misg = memnew( VehicleWheelSpatialGizmo(p_spatial->cast_to<VehicleWheel>()) );
+ Ref<VehicleWheelSpatialGizmo> misg = memnew(VehicleWheelSpatialGizmo(p_spatial->cast_to<VehicleWheel>()));
return misg;
}
if (p_spatial->cast_to<PinJoint>()) {
- Ref<PinJointSpatialGizmo> misg = memnew( PinJointSpatialGizmo(p_spatial->cast_to<PinJoint>()) );
+ Ref<PinJointSpatialGizmo> misg = memnew(PinJointSpatialGizmo(p_spatial->cast_to<PinJoint>()));
return misg;
}
if (p_spatial->cast_to<HingeJoint>()) {
- Ref<HingeJointSpatialGizmo> misg = memnew( HingeJointSpatialGizmo(p_spatial->cast_to<HingeJoint>()) );
+ Ref<HingeJointSpatialGizmo> misg = memnew(HingeJointSpatialGizmo(p_spatial->cast_to<HingeJoint>()));
return misg;
}
if (p_spatial->cast_to<SliderJoint>()) {
- Ref<SliderJointSpatialGizmo> misg = memnew( SliderJointSpatialGizmo(p_spatial->cast_to<SliderJoint>()) );
+ Ref<SliderJointSpatialGizmo> misg = memnew(SliderJointSpatialGizmo(p_spatial->cast_to<SliderJoint>()));
return misg;
}
if (p_spatial->cast_to<ConeTwistJoint>()) {
- Ref<ConeTwistJointSpatialGizmo> misg = memnew( ConeTwistJointSpatialGizmo(p_spatial->cast_to<ConeTwistJoint>()) );
+ Ref<ConeTwistJointSpatialGizmo> misg = memnew(ConeTwistJointSpatialGizmo(p_spatial->cast_to<ConeTwistJoint>()));
return misg;
}
if (p_spatial->cast_to<Generic6DOFJoint>()) {
- Ref<Generic6DOFJointSpatialGizmo> misg = memnew( Generic6DOFJointSpatialGizmo(p_spatial->cast_to<Generic6DOFJoint>()) );
+ Ref<Generic6DOFJointSpatialGizmo> misg = memnew(Generic6DOFJointSpatialGizmo(p_spatial->cast_to<Generic6DOFJoint>()));
return misg;
}
if (p_spatial->cast_to<CollisionPolygon>()) {
- Ref<CollisionPolygonSpatialGizmo> misg = memnew( CollisionPolygonSpatialGizmo(p_spatial->cast_to<CollisionPolygon>()) );
+ Ref<CollisionPolygonSpatialGizmo> misg = memnew(CollisionPolygonSpatialGizmo(p_spatial->cast_to<CollisionPolygon>()));
return misg;
}
-
return Ref<SpatialEditorGizmo>();
}
+Ref<FixedSpatialMaterial> SpatialEditorGizmos::create_line_material(const Color &p_base_color) {
-Ref<FixedSpatialMaterial> SpatialEditorGizmos::create_line_material(const Color& p_base_color) {
-
- Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+ Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
line_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
line_material->set_line_width(3.0);
line_material->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
@@ -3257,112 +3005,108 @@ Ref<FixedSpatialMaterial> SpatialEditorGizmos::create_line_material(const Color&
line_material->set_albedo(p_base_color);
return line_material;
-
}
-Ref<FixedSpatialMaterial> SpatialEditorGizmos::create_solid_material(const Color& p_base_color) {
+Ref<FixedSpatialMaterial> SpatialEditorGizmos::create_solid_material(const Color &p_base_color) {
- Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+ Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
line_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
line_material->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
line_material->set_albedo(p_base_color);
return line_material;
-
}
SpatialEditorGizmos::SpatialEditorGizmos() {
- singleton=this;
+ singleton = this;
- handle_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+ handle_material = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
handle_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
- handle_material->set_albedo(Color(0.8,0.8,0.8));
+ handle_material->set_albedo(Color(0.8, 0.8, 0.8));
- handle2_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+ handle2_material = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
handle2_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
handle2_material->set_flag(FixedSpatialMaterial::FLAG_USE_POINT_SIZE, true);
- handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle","EditorIcons");
+ handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons");
handle2_material->set_point_size(handle_t->get_width());
- handle2_material->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,handle_t);
- handle2_material->set_albedo(Color(1,1,1));
+ handle2_material->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO, handle_t);
+ handle2_material->set_albedo(Color(1, 1, 1));
handle2_material->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
handle2_material->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
handle2_material->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- light_material = create_line_material(Color(1,1,0.2));
+ light_material = create_line_material(Color(1, 1, 0.2));
- light_material_omni_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+ light_material_omni_icon = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
light_material_omni_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
light_material_omni_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
light_material_omni_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
light_material_omni_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
- light_material_omni_icon->set_albedo(Color(1,1,1,0.9));
- light_material_omni_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoLight","EditorIcons"));
-
+ light_material_omni_icon->set_albedo(Color(1, 1, 1, 0.9));
+ light_material_omni_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoLight", "EditorIcons"));
- light_material_directional_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+ light_material_directional_icon = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
light_material_directional_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
light_material_directional_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
light_material_directional_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
light_material_directional_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
- light_material_directional_icon->set_albedo(Color(1,1,1,0.9));
- light_material_directional_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight","EditorIcons"));
+ light_material_directional_icon->set_albedo(Color(1, 1, 1, 0.9));
+ light_material_directional_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight", "EditorIcons"));
- camera_material = create_line_material(Color(1.0,0.5,1.0));
+ camera_material = create_line_material(Color(1.0, 0.5, 1.0));
-
- navmesh_edge_material = create_line_material(Color(0.1,0.8,1.0));
- navmesh_solid_material = create_solid_material(Color(0.1,0.8,1.0,0.4));
+ navmesh_edge_material = create_line_material(Color(0.1, 0.8, 1.0));
+ navmesh_solid_material = create_solid_material(Color(0.1, 0.8, 1.0, 0.4));
navmesh_edge_material->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, false);
navmesh_edge_material->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, false);
navmesh_solid_material->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
- navmesh_edge_material_disabled = create_line_material(Color(1.0,0.8,0.1));
- navmesh_solid_material_disabled = create_solid_material(Color(1.0,0.8,0.1,0.4));
+ navmesh_edge_material_disabled = create_line_material(Color(1.0, 0.8, 0.1));
+ navmesh_solid_material_disabled = create_solid_material(Color(1.0, 0.8, 0.1, 0.4));
navmesh_edge_material_disabled->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, false);
navmesh_edge_material_disabled->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, false);
navmesh_solid_material_disabled->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
- skeleton_material = create_line_material(Color(0.6,1.0,0.3));
+ skeleton_material = create_line_material(Color(0.6, 1.0, 0.3));
skeleton_material->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
- skeleton_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
- skeleton_material->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true);
+ skeleton_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
+ skeleton_material->set_flag(FixedSpatialMaterial::FLAG_ONTOP, true);
skeleton_material->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
//position 3D Shared mesh
- pos3d_mesh = Ref<Mesh>( memnew( Mesh ) );
+ pos3d_mesh = Ref<Mesh>(memnew(Mesh));
{
PoolVector<Vector3> cursor_points;
PoolVector<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,0.7));
- cursor_colors.push_back(Color(1,0.5,0.5,0.7));
- cursor_colors.push_back(Color(0.5,1,0.5,0.7));
- cursor_colors.push_back(Color(0.5,1,0.5,0.7));
- cursor_colors.push_back(Color(0.5,0.5,1,0.7));
- cursor_colors.push_back(Color(0.5,0.5,1,0.7));
-
- Ref<FixedSpatialMaterial> mat = memnew( FixedSpatialMaterial );
- mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
- mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
- mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
- mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
+ 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, 0.7));
+ cursor_colors.push_back(Color(1, 0.5, 0.5, 0.7));
+ cursor_colors.push_back(Color(0.5, 1, 0.5, 0.7));
+ cursor_colors.push_back(Color(0.5, 1, 0.5, 0.7));
+ cursor_colors.push_back(Color(0.5, 0.5, 1, 0.7));
+ cursor_colors.push_back(Color(0.5, 0.5, 1, 0.7));
+
+ Ref<FixedSpatialMaterial> mat = memnew(FixedSpatialMaterial);
+ mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
+ mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
mat->set_line_width(3);
Array d;
d.resize(VS::ARRAY_MAX);
- d[Mesh::ARRAY_VERTEX]=cursor_points;
- d[Mesh::ARRAY_COLOR]=cursor_colors;
- pos3d_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES,d);
- pos3d_mesh->surface_set_material(0,mat);
+ d[Mesh::ARRAY_VERTEX] = cursor_points;
+ d[Mesh::ARRAY_COLOR] = cursor_colors;
+ pos3d_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, d);
+ pos3d_mesh->surface_set_material(0, mat);
}
listener_line_mesh = Ref<Mesh>(memnew(Mesh));
@@ -3389,48 +3133,47 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
listener_line_mesh->surface_set_material(0, mat);
}
-
- sample_player_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+ sample_player_icon = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
sample_player_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
sample_player_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
sample_player_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
sample_player_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
- sample_player_icon->set_albedo(Color(1,1,1,0.9));
- sample_player_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer","EditorIcons"));
-
- room_material = create_line_material(Color(1.0,0.6,0.9));
- portal_material = create_line_material(Color(1.0,0.8,0.6));
- raycast_material = create_line_material(Color(1.0,0.8,0.6));
- car_wheel_material = create_line_material(Color(0.6,0.8,1.0));
- visibility_notifier_material = create_line_material(Color(1.0,0.5,1.0));
- reflection_probe_material = create_line_material(Color(0.5,1.0,0.7));
- reflection_probe_material_internal = create_line_material(Color(0.3,0.8,0.5,0.15));
- gi_probe_material = create_line_material(Color(0.7,1.0,0.5));
- gi_probe_material_internal = create_line_material(Color(0.5,0.8,0.3,0.1));
- joint_material = create_line_material(Color(0.6,0.8,1.0));
-
- stream_player_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+ sample_player_icon->set_albedo(Color(1, 1, 1, 0.9));
+ sample_player_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer", "EditorIcons"));
+
+ room_material = create_line_material(Color(1.0, 0.6, 0.9));
+ portal_material = create_line_material(Color(1.0, 0.8, 0.6));
+ raycast_material = create_line_material(Color(1.0, 0.8, 0.6));
+ car_wheel_material = create_line_material(Color(0.6, 0.8, 1.0));
+ visibility_notifier_material = create_line_material(Color(1.0, 0.5, 1.0));
+ reflection_probe_material = create_line_material(Color(0.5, 1.0, 0.7));
+ reflection_probe_material_internal = create_line_material(Color(0.3, 0.8, 0.5, 0.15));
+ gi_probe_material = create_line_material(Color(0.7, 1.0, 0.5));
+ gi_probe_material_internal = create_line_material(Color(0.5, 0.8, 0.3, 0.1));
+ joint_material = create_line_material(Color(0.6, 0.8, 1.0));
+
+ stream_player_icon = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
stream_player_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
stream_player_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
stream_player_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
stream_player_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
- stream_player_icon->set_albedo(Color(1,1,1,0.9));
- stream_player_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoSpatialStreamPlayer","EditorIcons"));
+ stream_player_icon->set_albedo(Color(1, 1, 1, 0.9));
+ stream_player_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoSpatialStreamPlayer", "EditorIcons"));
- visibility_notifier_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
+ visibility_notifier_icon = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
visibility_notifier_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
visibility_notifier_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
visibility_notifier_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
visibility_notifier_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
- visibility_notifier_icon->set_albedo(Color(1,1,1,0.9));
- visibility_notifier_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("Visible","EditorIcons"));
+ visibility_notifier_icon->set_albedo(Color(1, 1, 1, 0.9));
+ visibility_notifier_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("Visible", "EditorIcons"));
listener_icon = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
listener_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
listener_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
listener_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
listener_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
- listener_icon->set_albedo( Color(1, 1, 1, 0.9));
+ listener_icon->set_albedo(Color(1, 1, 1, 0.9));
listener_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoListener", "EditorIcons"));
{
@@ -3439,26 +3182,25 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
#undef ADD_VTX
#define ADD_VTX(m_idx) \
- vertices.push_back( face_points[m_idx] );
-
- for (int i=0;i<6;i++) {
+ vertices.push_back(face_points[m_idx]);
+ for (int i = 0; i < 6; i++) {
Vector3 face_points[4];
- for (int j=0;j<4;j++) {
+ for (int j = 0; j < 4; j++) {
float v[3];
- v[0]=1.0;
- v[1]=1-2*((j>>1)&1);
- v[2]=v[1]*(1-2*(j&1));
+ v[0] = 1.0;
+ v[1] = 1 - 2 * ((j >> 1) & 1);
+ v[2] = v[1] * (1 - 2 * (j & 1));
- for (int k=0;k<3;k++) {
+ for (int k = 0; k < 3; k++) {
- if (i<3)
- face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
+ if (i < 3)
+ face_points[j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1);
else
- face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
+ face_points[3 - j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1);
}
}
//tri 1
@@ -3469,15 +3211,11 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
ADD_VTX(2);
ADD_VTX(3);
ADD_VTX(0);
-
}
- test_cube_tm = Ref<TriangleMesh>( memnew( TriangleMesh ) );
+ test_cube_tm = Ref<TriangleMesh>(memnew(TriangleMesh));
test_cube_tm->create(vertices);
}
- shape_material = create_line_material(Color(0.2,1,1.0));
-
-
+ shape_material = create_line_material(Color(0.2, 1, 1.0));
}
-
diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h
index c44a987144..76564c5a99 100644
--- a/editor/spatial_editor_gizmos.h
+++ b/editor/spatial_editor_gizmos.h
@@ -29,35 +29,33 @@
#ifndef SPATIAL_EDITOR_GIZMOS_H
#define SPATIAL_EDITOR_GIZMOS_H
-
#include "editor/plugins/spatial_editor_plugin.h"
+#include "scene/3d/body_shape.h"
+#include "scene/3d/camera.h"
+#include "scene/3d/gi_probe.h"
#include "scene/3d/light.h"
#include "scene/3d/listener.h"
-#include "scene/3d/camera.h"
-#include "scene/3d/position_3d.h"
-#include "scene/3d/test_cube.h"
#include "scene/3d/mesh_instance.h"
-#include "scene/3d/body_shape.h"
-#include "scene/3d/room_instance.h"
-#include "scene/3d/visibility_notifier.h"
+#include "scene/3d/navigation_mesh.h"
#include "scene/3d/portal.h"
+#include "scene/3d/position_3d.h"
#include "scene/3d/ray_cast.h"
-#include "scene/3d/navigation_mesh.h"
#include "scene/3d/reflection_probe.h"
-#include "scene/3d/gi_probe.h"
+#include "scene/3d/room_instance.h"
+#include "scene/3d/test_cube.h"
+#include "scene/3d/visibility_notifier.h"
-#include "scene/3d/vehicle_body.h"
#include "scene/3d/collision_polygon.h"
#include "scene/3d/physics_joint.h"
-
+#include "scene/3d/vehicle_body.h"
class Camera;
-class EditorSpatialGizmo : public SpatialEditorGizmo {
+class EditorSpatialGizmo : public SpatialEditorGizmo {
- GDCLASS(EditorSpatialGizmo,SpatialGizmo);
+ GDCLASS(EditorSpatialGizmo, SpatialGizmo);
- struct Instance{
+ struct Instance {
RID instance;
Ref<Mesh> mesh;
@@ -68,14 +66,13 @@ class EditorSpatialGizmo : public SpatialEditorGizmo {
bool extra_margin;
Instance() {
- billboard=false;
- unscaled=false;
- can_intersect=false;
- extra_margin=false;
+ billboard = false;
+ unscaled = false;
+ can_intersect = false;
+ extra_margin = false;
}
void create_instance(Spatial *p_base);
-
};
Vector<Vector3> collision_segments;
@@ -96,22 +93,23 @@ class EditorSpatialGizmo : public SpatialEditorGizmo {
Spatial *spatial_node;
void _set_spatial_node(Node *p_node) { set_spatial_node(p_node->cast_to<Spatial>()); }
+
protected:
- void add_lines(const Vector<Vector3> &p_lines,const Ref<Material>& p_material,bool p_billboard=false);
- void add_mesh(const Ref<Mesh>& p_mesh,bool p_billboard=false,const RID& p_skeleton=RID());
+ void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false);
+ void add_mesh(const Ref<Mesh> &p_mesh, bool p_billboard = false, const RID &p_skeleton = RID());
void add_collision_segments(const Vector<Vector3> &p_lines);
- void add_collision_triangles(const Ref<TriangleMesh>& p_tmesh);
- void add_unscaled_billboard(const Ref<Material>& p_material,float p_scale=1);
- void add_handles(const Vector<Vector3> &p_handles,bool p_billboard=false,bool p_secondary=false);
+ void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh);
+ void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1);
+ void add_handles(const Vector<Vector3> &p_handles, bool p_billboard = false, bool p_secondary = false);
void set_spatial_node(Spatial *p_node);
static void _bind_methods();
-public:
+public:
virtual Vector3 get_handle_pos(int p_idx) const;
- virtual bool intersect_frustum(const Camera *p_camera,const Vector<Plane> &p_frustum);
- virtual bool intersect_ray(const Camera *p_camera,const Point2& p_point, Vector3& r_pos, Vector3& r_normal,int *r_gizmo_handle=NULL,bool p_sec_first=false);
+ virtual bool intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum);
+ virtual bool intersect_ray(const Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = NULL, bool p_sec_first = false);
void clear();
void create();
@@ -123,358 +121,286 @@ public:
~EditorSpatialGizmo();
};
+class LightSpatialGizmo : public EditorSpatialGizmo {
+ GDCLASS(LightSpatialGizmo, EditorSpatialGizmo);
-class LightSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(LightSpatialGizmo,EditorSpatialGizmo);
-
- Light* light;
+ Light *light;
public:
-
-
virtual String get_handle_name(int p_idx) const;
virtual Variant get_handle_value(int p_idx) const;
- virtual void set_handle(int p_idx,Camera *p_camera, const Point2& p_point);
- virtual void commit_handle(int p_idx,const Variant& p_restore,bool p_cancel=false);
+ virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
void redraw();
- LightSpatialGizmo(Light* p_light=NULL);
-
+ LightSpatialGizmo(Light *p_light = NULL);
};
-class CameraSpatialGizmo : public EditorSpatialGizmo {
+class CameraSpatialGizmo : public EditorSpatialGizmo {
- GDCLASS(CameraSpatialGizmo,EditorSpatialGizmo);
+ GDCLASS(CameraSpatialGizmo, EditorSpatialGizmo);
- Camera* camera;
+ Camera *camera;
public:
-
-
virtual String get_handle_name(int p_idx) const;
virtual Variant get_handle_value(int p_idx) const;
- virtual void set_handle(int p_idx,Camera *p_camera, const Point2& p_point);
- virtual void commit_handle(int p_idx,const Variant& p_restore,bool p_cancel=false);
+ virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
void redraw();
- CameraSpatialGizmo(Camera* p_camera=NULL);
-
+ CameraSpatialGizmo(Camera *p_camera = NULL);
};
+class MeshInstanceSpatialGizmo : public EditorSpatialGizmo {
+ GDCLASS(MeshInstanceSpatialGizmo, EditorSpatialGizmo);
-class MeshInstanceSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(MeshInstanceSpatialGizmo,EditorSpatialGizmo);
-
- MeshInstance* mesh;
+ MeshInstance *mesh;
public:
-
void redraw();
- MeshInstanceSpatialGizmo(MeshInstance* p_mesh=NULL);
-
+ MeshInstanceSpatialGizmo(MeshInstance *p_mesh = NULL);
};
-class Position3DSpatialGizmo : public EditorSpatialGizmo {
+class Position3DSpatialGizmo : public EditorSpatialGizmo {
- GDCLASS(Position3DSpatialGizmo,EditorSpatialGizmo);
+ GDCLASS(Position3DSpatialGizmo, EditorSpatialGizmo);
- Position3D* p3d;
+ Position3D *p3d;
public:
-
void redraw();
- Position3DSpatialGizmo(Position3D* p_p3d=NULL);
-
+ Position3DSpatialGizmo(Position3D *p_p3d = NULL);
};
-class SkeletonSpatialGizmo : public EditorSpatialGizmo {
+class SkeletonSpatialGizmo : public EditorSpatialGizmo {
- GDCLASS(SkeletonSpatialGizmo,EditorSpatialGizmo);
+ GDCLASS(SkeletonSpatialGizmo, EditorSpatialGizmo);
- Skeleton* skel;
+ Skeleton *skel;
public:
-
void redraw();
- SkeletonSpatialGizmo(Skeleton* p_skel=NULL);
-
+ SkeletonSpatialGizmo(Skeleton *p_skel = NULL);
};
+class TestCubeSpatialGizmo : public EditorSpatialGizmo {
-class TestCubeSpatialGizmo : public EditorSpatialGizmo {
+ GDCLASS(TestCubeSpatialGizmo, EditorSpatialGizmo);
- GDCLASS(TestCubeSpatialGizmo,EditorSpatialGizmo);
-
- TestCube* tc;
+ TestCube *tc;
public:
void redraw();
- TestCubeSpatialGizmo(TestCube* p_tc=NULL);
-
+ TestCubeSpatialGizmo(TestCube *p_tc = NULL);
};
+class RoomSpatialGizmo : public EditorSpatialGizmo {
-class RoomSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(RoomSpatialGizmo,EditorSpatialGizmo);
-
+ GDCLASS(RoomSpatialGizmo, EditorSpatialGizmo);
struct _EdgeKey {
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; }
};
-
-
- Room* room;
+ Room *room;
public:
-
void redraw();
- RoomSpatialGizmo(Room* p_room=NULL);
-
+ RoomSpatialGizmo(Room *p_room = NULL);
};
+class PortalSpatialGizmo : public EditorSpatialGizmo {
-class PortalSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(PortalSpatialGizmo,EditorSpatialGizmo);
+ GDCLASS(PortalSpatialGizmo, EditorSpatialGizmo);
- Portal* portal;
+ Portal *portal;
public:
-
void redraw();
- PortalSpatialGizmo(Portal* p_portal=NULL);
-
+ PortalSpatialGizmo(Portal *p_portal = NULL);
};
+class VisibilityNotifierGizmo : public EditorSpatialGizmo {
-class VisibilityNotifierGizmo : public EditorSpatialGizmo {
-
- GDCLASS(VisibilityNotifierGizmo ,EditorSpatialGizmo);
+ GDCLASS(VisibilityNotifierGizmo, EditorSpatialGizmo);
-
- VisibilityNotifier* notifier;
+ VisibilityNotifier *notifier;
public:
-
virtual String get_handle_name(int p_idx) const;
virtual Variant get_handle_value(int p_idx) const;
- virtual void set_handle(int p_idx,Camera *p_camera, const Point2& p_point);
- virtual void commit_handle(int p_idx,const Variant& p_restore,bool p_cancel=false);
+ virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
void redraw();
- VisibilityNotifierGizmo(VisibilityNotifier* p_notifier=NULL);
-
+ VisibilityNotifierGizmo(VisibilityNotifier *p_notifier = NULL);
};
+class ReflectionProbeGizmo : public EditorSpatialGizmo {
-class ReflectionProbeGizmo : public EditorSpatialGizmo {
+ GDCLASS(ReflectionProbeGizmo, EditorSpatialGizmo);
- GDCLASS(ReflectionProbeGizmo ,EditorSpatialGizmo);
-
-
- ReflectionProbe* probe;
+ ReflectionProbe *probe;
public:
-
virtual String get_handle_name(int p_idx) const;
virtual Variant get_handle_value(int p_idx) const;
- virtual void set_handle(int p_idx,Camera *p_camera, const Point2& p_point);
- virtual void commit_handle(int p_idx,const Variant& p_restore,bool p_cancel=false);
+ virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
void redraw();
- ReflectionProbeGizmo(ReflectionProbe* p_notifier=NULL);
-
+ ReflectionProbeGizmo(ReflectionProbe *p_notifier = NULL);
};
-class GIProbeGizmo : public EditorSpatialGizmo {
-
- GDCLASS(GIProbeGizmo ,EditorSpatialGizmo);
+class GIProbeGizmo : public EditorSpatialGizmo {
+ GDCLASS(GIProbeGizmo, EditorSpatialGizmo);
- GIProbe* probe;
+ GIProbe *probe;
public:
-
virtual String get_handle_name(int p_idx) const;
virtual Variant get_handle_value(int p_idx) const;
- virtual void set_handle(int p_idx,Camera *p_camera, const Point2& p_point);
- virtual void commit_handle(int p_idx,const Variant& p_restore,bool p_cancel=false);
+ virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
void redraw();
- GIProbeGizmo(GIProbe* p_notifier=NULL);
-
+ GIProbeGizmo(GIProbe *p_notifier = NULL);
};
+class CollisionShapeSpatialGizmo : public EditorSpatialGizmo {
-class CollisionShapeSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(CollisionShapeSpatialGizmo,EditorSpatialGizmo);
+ GDCLASS(CollisionShapeSpatialGizmo, EditorSpatialGizmo);
- CollisionShape* cs;
+ CollisionShape *cs;
public:
virtual String get_handle_name(int p_idx) const;
virtual Variant get_handle_value(int p_idx) const;
- virtual void set_handle(int p_idx,Camera *p_camera, const Point2& p_point);
- virtual void commit_handle(int p_idx,const Variant& p_restore,bool p_cancel=false);
+ virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
+ virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
void redraw();
- CollisionShapeSpatialGizmo(CollisionShape* p_cs=NULL);
-
+ CollisionShapeSpatialGizmo(CollisionShape *p_cs = NULL);
};
+class CollisionPolygonSpatialGizmo : public EditorSpatialGizmo {
-class CollisionPolygonSpatialGizmo : public EditorSpatialGizmo {
+ GDCLASS(CollisionPolygonSpatialGizmo, EditorSpatialGizmo);
- GDCLASS(CollisionPolygonSpatialGizmo,EditorSpatialGizmo);
-
- CollisionPolygon* polygon;
+ CollisionPolygon *polygon;
public:
-
void redraw();
- CollisionPolygonSpatialGizmo(CollisionPolygon* p_polygon=NULL);
-
+ CollisionPolygonSpatialGizmo(CollisionPolygon *p_polygon = NULL);
};
+class RayCastSpatialGizmo : public EditorSpatialGizmo {
+ GDCLASS(RayCastSpatialGizmo, EditorSpatialGizmo);
-class RayCastSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(RayCastSpatialGizmo,EditorSpatialGizmo);
-
- RayCast* raycast;
+ RayCast *raycast;
public:
-
void redraw();
- RayCastSpatialGizmo(RayCast* p_raycast=NULL);
-
+ RayCastSpatialGizmo(RayCast *p_raycast = NULL);
};
+class VehicleWheelSpatialGizmo : public EditorSpatialGizmo {
+ GDCLASS(VehicleWheelSpatialGizmo, EditorSpatialGizmo);
-class VehicleWheelSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(VehicleWheelSpatialGizmo,EditorSpatialGizmo);
-
- VehicleWheel* car_wheel;
+ VehicleWheel *car_wheel;
public:
-
void redraw();
- VehicleWheelSpatialGizmo(VehicleWheel* p_car_wheel=NULL);
-
+ VehicleWheelSpatialGizmo(VehicleWheel *p_car_wheel = NULL);
};
+class NavigationMeshSpatialGizmo : public EditorSpatialGizmo {
-class NavigationMeshSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(NavigationMeshSpatialGizmo,EditorSpatialGizmo);
-
+ GDCLASS(NavigationMeshSpatialGizmo, EditorSpatialGizmo);
struct _EdgeKey {
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; }
};
-
-
- NavigationMeshInstance* navmesh;
+ NavigationMeshInstance *navmesh;
public:
-
void redraw();
- NavigationMeshSpatialGizmo(NavigationMeshInstance* p_navmesh=NULL);
-
+ NavigationMeshSpatialGizmo(NavigationMeshInstance *p_navmesh = NULL);
};
+class PinJointSpatialGizmo : public EditorSpatialGizmo {
-class PinJointSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(PinJointSpatialGizmo,EditorSpatialGizmo);
+ GDCLASS(PinJointSpatialGizmo, EditorSpatialGizmo);
- PinJoint* p3d;
+ PinJoint *p3d;
public:
-
void redraw();
- PinJointSpatialGizmo(PinJoint* p_p3d=NULL);
-
+ PinJointSpatialGizmo(PinJoint *p_p3d = NULL);
};
+class HingeJointSpatialGizmo : public EditorSpatialGizmo {
-class HingeJointSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(HingeJointSpatialGizmo,EditorSpatialGizmo);
+ GDCLASS(HingeJointSpatialGizmo, EditorSpatialGizmo);
- HingeJoint* p3d;
+ HingeJoint *p3d;
public:
-
void redraw();
- HingeJointSpatialGizmo(HingeJoint* p_p3d=NULL);
-
+ HingeJointSpatialGizmo(HingeJoint *p_p3d = NULL);
};
-class SliderJointSpatialGizmo : public EditorSpatialGizmo {
+class SliderJointSpatialGizmo : public EditorSpatialGizmo {
- GDCLASS(SliderJointSpatialGizmo,EditorSpatialGizmo);
+ GDCLASS(SliderJointSpatialGizmo, EditorSpatialGizmo);
- SliderJoint* p3d;
+ SliderJoint *p3d;
public:
-
void redraw();
- SliderJointSpatialGizmo(SliderJoint* p_p3d=NULL);
-
+ SliderJointSpatialGizmo(SliderJoint *p_p3d = NULL);
};
-class ConeTwistJointSpatialGizmo : public EditorSpatialGizmo {
+class ConeTwistJointSpatialGizmo : public EditorSpatialGizmo {
- GDCLASS(ConeTwistJointSpatialGizmo,EditorSpatialGizmo);
+ GDCLASS(ConeTwistJointSpatialGizmo, EditorSpatialGizmo);
- ConeTwistJoint* p3d;
+ ConeTwistJoint *p3d;
public:
-
void redraw();
- ConeTwistJointSpatialGizmo(ConeTwistJoint* p_p3d=NULL);
-
+ ConeTwistJointSpatialGizmo(ConeTwistJoint *p_p3d = NULL);
};
+class Generic6DOFJointSpatialGizmo : public EditorSpatialGizmo {
-class Generic6DOFJointSpatialGizmo : public EditorSpatialGizmo {
+ GDCLASS(Generic6DOFJointSpatialGizmo, EditorSpatialGizmo);
- GDCLASS(Generic6DOFJointSpatialGizmo,EditorSpatialGizmo);
-
- Generic6DOFJoint* p3d;
+ Generic6DOFJoint *p3d;
public:
-
void redraw();
- Generic6DOFJointSpatialGizmo(Generic6DOFJoint* p_p3d=NULL);
-
+ Generic6DOFJointSpatialGizmo(Generic6DOFJoint *p_p3d = NULL);
};
-
-class SpatialEditorGizmos {
+class SpatialEditorGizmos {
public:
-
- Ref<FixedSpatialMaterial> create_line_material(const Color& p_base_color);
- Ref<FixedSpatialMaterial> create_solid_material(const Color& p_base_color);
+ Ref<FixedSpatialMaterial> create_line_material(const Color &p_base_color);
+ Ref<FixedSpatialMaterial> create_solid_material(const Color &p_base_color);
Ref<FixedSpatialMaterial> handle2_material;
Ref<FixedSpatialMaterial> handle_material;
Ref<FixedSpatialMaterial> light_material;
@@ -513,7 +439,6 @@ public:
Ref<TriangleMesh> test_cube_tm;
-
Ref<SpatialEditorGizmo> get_gizmo(Spatial *p_spatial);
SpatialEditorGizmos();