Пример #1
0
void CodeTextEditor::_on_settings_change() {
	
	// FONTS
	String editor_font = EDITOR_DEF("text_editor/font", "");
	bool font_overrode = false;
	if (editor_font!="") {
		Ref<Font> fnt = ResourceLoader::load(editor_font);
		if (fnt.is_valid()) {
			text_editor->add_font_override("font",fnt);
			font_overrode = true;
		}
	}
	if(!font_overrode)
		text_editor->add_font_override("font",get_font("source","Fonts"));
	
	// AUTO BRACE COMPLETION 
	text_editor->set_auto_brace_completion(
		EDITOR_DEF("text_editor/auto_brace_complete", true)
	);

	code_complete_timer->set_wait_time(
		EDITOR_DEF("text_editor/code_complete_delay",.3f)
	);

	enable_complete_timer = EDITOR_DEF("text_editor/enable_code_completion_delay",true);
}
Пример #2
0
void register_windows_exporter() {

	EDITOR_DEF("export/windows/rcedit", "");
	EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/rcedit", PROPERTY_HINT_GLOBAL_FILE, "*.exe"));
#ifndef WINDOWS_ENABLED
	// On non-Windows we need WINE to run rcedit
	EDITOR_DEF("export/windows/wine", "");
	EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/wine", PROPERTY_HINT_GLOBAL_FILE));
#endif

	Ref<EditorExportPlatformWindows> platform;
	platform.instance();

	Ref<Image> img = memnew(Image(_windows_logo));
	Ref<ImageTexture> logo;
	logo.instance();
	logo->create_from_image(img);
	platform->set_logo(logo);
	platform->set_name("Windows Desktop");
	platform->set_extension("exe");
	platform->set_release_32("windows_32_release.exe");
	platform->set_debug_32("windows_32_debug.exe");
	platform->set_release_64("windows_64_release.exe");
	platform->set_debug_64("windows_64_debug.exe");
	platform->set_os_name("Windows");

	EditorExport::get_singleton()->add_export_platform(platform);
}
Пример #3
0
void ShaderTextEditor::_load_theme_settings() {

	get_text_edit()->clear_colors();

	/* keyword color */

	get_text_edit()->set_custom_bg_color(EDITOR_DEF("text_editor/background_color",Color(0,0,0,0)));
	get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0)));
	get_text_edit()->add_color_override("font_selected_color",EDITOR_DEF("text_editor/text_selected_color",Color(1,1,1)));
	get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1)));
	get_text_edit()->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/brace_mismatch_color",Color(1,0.2,0.2)));
	get_text_edit()->add_color_override("current_line_color",EDITOR_DEF("text_editor/current_line_color",Color(0.3,0.5,0.8,0.15)));

	Color keyword_color= EDITOR_DEF("text_editor/keyword_color",Color(0.5,0.0,0.2));

	get_text_edit()->set_syntax_coloring(true);


	List<String> keywords;
	ShaderLanguage::get_keyword_list(type,&keywords);


	for(List<String>::Element *E=keywords.front();E;E=E->next()) {

		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/comment_color",Color::hex(0x797e7eff));

	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));
	/*
	List<String> strings;
	shader->get_shader_mode()->get_string_delimiters(&strings);

	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();
		get_text_edit()->add_color_region(beg,end,string_color,end=="");
	}*/

	//colorize symbols
	Color symbol_color= EDITOR_DEF("text_editor/symbol_color",Color::hex(0x005291ff));
	get_text_edit()->set_symbol_color(symbol_color);

}
Пример #4
0
CodeTextEditor::CodeTextEditor() {

	text_editor = memnew( TextEdit );
	add_child(text_editor);
	text_editor->set_area_as_parent_rect();
	text_editor->set_margin(MARGIN_BOTTOM,20);
	text_editor->add_font_override("font",get_font("source","Fonts"));
	text_editor->set_show_line_numbers(true);
	text_editor->set_brace_matching(true);

	line_col = memnew( Label );
	add_child(line_col);
	line_col->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_END,135);
	line_col->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,20);
	line_col->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,1);
	line_col->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
	//line_col->set_align(Label::ALIGN_RIGHT);
	idle = memnew( Timer );
	add_child(idle);
	idle->set_one_shot(true);
	idle->set_wait_time(EDITOR_DEF("text_editor/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/enable_code_completion_delay",true);

	code_complete_timer->set_wait_time(EDITOR_DEF("text_editor/code_complete_delay",.3f));

	error = memnew( Label );
	add_child(error);
	error->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
	error->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,20);
	error->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,1);
	error->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,130);
	error->hide();
	error->add_color_override("font_color",Color(1,0.7,0.6,0.9));



	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("(");
	text_editor->set_completion(true,cs);
	idle->connect("timeout", this,"_text_changed_idle_timeout");

	code_complete_timer->connect("timeout", this,"_code_complete_timer_timeout");

	EditorSettings::get_singleton()->connect("settings_changed",this,"_on_settings_change");
}
EditorSceneImporterFBXConv::EditorSceneImporterFBXConv() {

	EDITOR_DEF("fbxconv/path","");
#ifndef WINDOWS_ENABLED
	EDITOR_DEF("fbxconv/use_wine","");
	EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"fbxconv/use_wine",PROPERTY_HINT_GLOBAL_FILE));
	EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"fbxconv/path",PROPERTY_HINT_GLOBAL_FILE));
#else
	EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"fbxconv/path",PROPERTY_HINT_GLOBAL_FILE,"exe"));
#endif

}
Пример #6
0
ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {

	editor=p_node;
	script_editor = memnew( ScriptEditor(p_node) );
	editor->get_viewport()->add_child(script_editor);
	script_editor->set_area_as_parent_rect();

	script_editor->hide();

	EDITOR_DEF("external_editor/use_external_editor",false);
	EDITOR_DEF("external_editor/exec_path","");
	EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"external_editor/exec_path",PROPERTY_HINT_GLOBAL_FILE));
	EDITOR_DEF("external_editor/exec_flags","");

}
Пример #7
0
TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) {

	EDITOR_DEF("tile_map/preview_size",64);
	tile_map_editor = memnew( TileMapEditor(p_node) );
	add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE, tile_map_editor);
	tile_map_editor->hide();
}
Пример #8
0
void SceneTreeDock::fill_path_renames(Node* p_node, Node *p_new_parent, List<Pair<NodePath,NodePath> > *p_renames) {

	if (!bool(EDITOR_DEF("animation/autorename_animation_tracks",true)))
		return;


	Vector<StringName> base_path;
	Node *n = p_node->get_parent();
	while(n) {
		base_path.push_back(n->get_name());
		n=n->get_parent();
	}
	base_path.invert();

	Vector<StringName> new_base_path;
	if (p_new_parent) {
		n = p_new_parent;
		while(n) {
			new_base_path.push_back(n->get_name());
			n=n->get_parent();
		}

		new_base_path.invert();
	}

	_fill_path_renames(base_path,new_base_path,p_node,p_renames);
}
Пример #9
0
void ScriptEditorPlugin::save_global_state() {

	if (bool(EDITOR_DEF("text_editor/restore_scripts_on_load",true))) {
		script_editor->_save_files_state();
	}

}
Пример #10
0
SampleEditor::SampleEditor() {

    player = memnew(SamplePlayer);
    add_child(player);
    add_style_override("panel", get_stylebox("panel","Panel"));
    library = Ref<SampleLibrary>(memnew(SampleLibrary));
    player->set_sample_library(library);
    sample_texframe = memnew( TextureFrame );
    add_child(sample_texframe);
    sample_texframe->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
    sample_texframe->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
    sample_texframe->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,30);
    sample_texframe->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,5);

    info_label = memnew( Label );
    sample_texframe->add_child(info_label);
    info_label->set_area_as_parent_rect();
    info_label->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,15);
    info_label->set_margin(MARGIN_BOTTOM,4);
    info_label->set_margin(MARGIN_RIGHT,4);
    info_label->set_align(Label::ALIGN_RIGHT);


    play = memnew( Button );

    play->set_pos(Point2( 5, 5 ));
    play->set_size( Size2(1,1 ) );
    play->set_toggle_mode(true);
    add_child(play);

    stop = memnew( Button );

    stop->set_pos(Point2( 35, 5 ));
    stop->set_size( Size2(1,1 ) );
    stop->set_toggle_mode(true);
    add_child(stop);

    peakdisplay=Ref<ImageTexture>( memnew( ImageTexture) );
    peakdisplay->create( EDITOR_DEF("audio/sample_editor_preview_width",512),EDITOR_DEF("audio/sample_editor_preview_height",128),Image::FORMAT_RGB);
    sample_texframe->set_expand(true);
    sample_texframe->set_texture(peakdisplay);

    play->connect("pressed", this,"_play_pressed");
    stop->connect("pressed", this,"_stop_pressed");

}
Пример #11
0
void CodeTextEditor::_on_settings_change() {

	_update_font();

	// AUTO BRACE COMPLETION
	text_editor->set_auto_brace_completion(
			EDITOR_DEF("text_editor/completion/auto_brace_complete", true));

	code_complete_timer->set_wait_time(
			EDITOR_DEF("text_editor/completion/code_complete_delay", .3f));

	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()));
}
Пример #12
0
MonoReloadNode::MonoReloadNode() {

	singleton = this;

	reload_timer = memnew(Timer);
	add_child(reload_timer);
	reload_timer->set_one_shot(false);
	reload_timer->set_wait_time(EDITOR_DEF("mono/assembly_watch_interval_sec", 0.5));
	reload_timer->connect("timeout", this, "_reload_timer_timeout");
	reload_timer->start();
}
Error EditorSceneImporterFBXConv::_parse_fbx(State& state,const String& p_path) {

	state.base_path=p_path.get_base_dir();

	if (p_path.to_lower().ends_with("g3dj")) {
		return _parse_json(state,p_path.basename()+".g3dj");
	}

	String tool = EDITOR_DEF("fbxconv/path","");
	ERR_FAIL_COND_V( !FileAccess::exists(tool),ERR_UNCONFIGURED);
	String wine = EDITOR_DEF("fbxconv/use_wine","");

	List<String> args;
	String path=p_path;
	if (wine!="") {
		List<String> wpargs;
		wpargs.push_back("-w");
		wpargs.push_back(p_path);
		String pipe; //winepath to convert to windows path
		int wpres;
		Error wperr = OS::get_singleton()->execute(wine+"path",wpargs,true,NULL,&pipe,&wpres);
		ERR_FAIL_COND_V(wperr!=OK,ERR_CANT_CREATE);
		ERR_FAIL_COND_V(wpres!=0,ERR_CANT_CREATE);
		path=pipe.strip_edges();
		args.push_back(tool);
		tool=wine;
	}

	args.push_back("-o");
	args.push_back(TTR("G3DJ"));
	args.push_back(path);

	int res;
	Error err = OS::get_singleton()->execute(tool,args,true,NULL,NULL,&res);
	ERR_FAIL_COND_V(err!=OK,ERR_CANT_CREATE);
	ERR_FAIL_COND_V(res!=0,ERR_CANT_CREATE);

	return _parse_json(state,p_path.basename()+".g3dj");


}
Пример #14
0
EditorHelp::EditorHelp() {

	editor=EditorNode::get_singleton();

	VBoxContainer *vbc = this;

	EDITOR_DEF("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/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 );
		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("input_event",this,"_class_desc_input");
	}

	class_desc->get_v_scroll()->connect("value_changed",this,"_scroll_changed");
	class_desc->set_selection_enabled(true);

	scroll_locked=false;
	select_locked=false;
	set_process_unhandled_key_input(true);
	class_desc->hide();

	search_dialog = memnew( ConfirmationDialog );
	add_child(search_dialog);
	VBoxContainer *search_vb = memnew( VBoxContainer );
	search_dialog->add_child(search_vb);
	search_dialog->set_child_rect(search_vb);
	search = memnew( LineEdit );
	search_dialog->register_text_enter(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->set_hide_on_ok(false);
	search_dialog->set_self_opacity(0.8);


	/*class_search = memnew( EditorHelpSearch(editor) );
	editor->get_gui_base()->add_child(class_search);
	class_search->connect("go_to_help",this,"_help_callback");*/

//	prev_search_page=-1;
}
MeshLibraryEditorPlugin::MeshLibraryEditorPlugin(EditorNode *p_node) {

	EDITOR_DEF("grid_map/preview_size",64);
	theme_editor = memnew( MeshLibraryEditor(p_node) );

	p_node->get_viewport()->add_child(theme_editor);
	theme_editor->set_area_as_parent_rect();
	theme_editor->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
	theme_editor->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_BEGIN );
	theme_editor->set_end( Point2(0,22) );
	theme_editor->hide();	

}
Пример #16
0
String EditorData::get_scene_title(int p_idx) const {
	ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String());
	if (!edited_scene[p_idx].root)
		return TTR("[empty]");
	if (edited_scene[p_idx].root->get_filename() == "")
		return TTR("[unsaved]");
	bool show_ext = EDITOR_DEF("interface/scene_tabs/show_extension", false);
	String name = edited_scene[p_idx].root->get_filename().get_file();
	if (!show_ext) {
		name = name.get_basename();
	}
	return name;
}
Пример #17
0
void CodeTextEditor::_update_font() {

	// FONTS
	String editor_font = EDITOR_DEF("text_editor/font", "");
	bool font_overridden = false;
	if (editor_font!="") {
		Ref<Font> fnt = ResourceLoader::load(editor_font);
		if (fnt.is_valid()) {
			text_editor->add_font_override("font",fnt);
			font_overridden = true;
		}
	}
	if(!font_overridden)
		text_editor->add_font_override("font",get_font("source","EditorFonts"));
}
Пример #18
0
GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) {

	singleton = this;

	monodevel_instance = NULL;

	editor = p_editor;

	error_dialog = memnew(AcceptDialog);
	editor->get_gui_base()->add_child(error_dialog);

	bottom_panel_btn = editor->add_bottom_panel_item("Mono", memnew(MonoBottomPanel(editor)));

	godotsharp_builds = memnew(GodotSharpBuilds);

	editor->add_child(memnew(MonoReloadNode));

	menu_button = memnew(MenuButton);
	menu_button->set_text("Mono");
	menu_popup = menu_button->get_popup();

	String sln_path = GodotSharpDirs::get_project_sln_path();
	String csproj_path = GodotSharpDirs::get_project_csproj_path();

	if (!FileAccess::exists(sln_path) || !FileAccess::exists(csproj_path)) {
		bottom_panel_btn->hide();
		menu_popup->add_item("Create C# solution", MENU_CREATE_SLN);
	}

	menu_popup->connect("id_pressed", this, "_menu_option_pressed");

	if (menu_popup->get_item_count() == 0)
		menu_button->hide();

	editor->get_menu_hb()->add_child(menu_button);

	// External editor settings
	EditorSettings *ed_settings = EditorSettings::get_singleton();
	EDITOR_DEF("mono/editor/external_editor", EDITOR_NONE);
	ed_settings->add_property_hint(PropertyInfo(Variant::INT, "mono/editor/external_editor", PROPERTY_HINT_ENUM, "None,MonoDevelop,Visual Studio Code"));
}
Пример #19
0
TileMapEditor::TileMapEditor(EditorNode *p_editor) {

	node=NULL;
	canvas_item_editor=NULL;
	editor=p_editor;
	undo_redo = editor->get_undo_redo();

	int mw = EDITOR_DEF("tile_map/palette_min_width",80);
	Control *ec = memnew( Control);
	ec->set_custom_minimum_size(Size2(mw,0));
	add_child(ec);

	// Add tile palette
	palette = memnew( Tree );
	palette->set_v_size_flags(SIZE_EXPAND_FILL);
	add_child(palette);

	// Add menu items
	canvas_item_editor_hb = memnew( HBoxContainer );
	CanvasItemEditor::get_singleton()->add_control_to_menu_panel(canvas_item_editor_hb);
	canvas_item_editor_hb->add_child( memnew( VSeparator ));
	mirror_x = memnew( ToolButton );
	mirror_x->set_toggle_mode(true);
	mirror_x->set_tooltip("Mirror X (A)");
	mirror_x->set_focus_mode(FOCUS_NONE);
	canvas_item_editor_hb->add_child(mirror_x);
	mirror_y = memnew( ToolButton );
	mirror_y->set_toggle_mode(true);
	mirror_y->set_tooltip("Mirror Y (S)");
	mirror_y->set_focus_mode(FOCUS_NONE);
	canvas_item_editor_hb->add_child(mirror_y);
	canvas_item_editor_hb->hide();

	tool=TOOL_NONE;
	selection_active=false;
	mouse_over=false;
}
Пример #20
0
PathSpatialGizmoPlugin::PathSpatialGizmoPlugin() {

	Color path_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.8));

	Ref<SpatialMaterial> path_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
	path_color.a = 0.8;
	path_material->set_albedo(path_color);
	path_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
	path_material->set_line_width(3);
	path_material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
	path_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);

	Ref<SpatialMaterial> path_thin_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
	path_color.a = 0.4;
	path_thin_material->set_albedo(path_color);
	path_thin_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
	path_thin_material->set_line_width(1);
	path_thin_material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
	path_thin_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);

	add_material("path_material", path_material);
	add_material("path_thin_material", path_thin_material);
	create_handle_material("handles");
}
bool LightOccluder2DEditor::forward_input_event(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) {
			create_poly->set_text("No OccluderPolygon2D resource on this node.\nCreate and assign one?");
			create_poly->popup_centered_minsize();
		}
		return false;
	}
	switch(p_event.type) {

		case InputEvent::MOUSE_BUTTON: {

			const InputEventMouseButton &mb=p_event.mouse_button;

			Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();


			Vector2 gpoint = Point2(mb.x,mb.y);
			Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
			cpoint=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("poly_editor/point_grab_radius",8);

			switch(mode) {


				case MODE_CREATE: {

					if (mb.button_index==BUTTON_LEFT && mb.pressed) {


						if (!wip_active) {

							wip.clear();
							wip.push_back( cpoint );
							wip_active=true;
							edited_point_pos=cpoint;
							canvas_item_editor->get_viewport_control()->update();
							edited_point=1;
							return true;
						} else {


							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 {

								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) {
						_wip_close(true);
					}



				} break;

				case MODE_EDIT: {

					if (mb.button_index==BUTTON_LEFT) {
						if (mb.pressed) {

							if (mb.mod.control) {


								if (poly.size() < 3) {

									undo_redo->create_action("Edit 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->commit_action();
									return true;
								}

								//search edges
								int closest_idx=-1;
								Vector2 closest_pos;
								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 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 (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);
									node->get_occluder_polygon()->set_polygon(Variant(poly));
									canvas_item_editor->get_viewport_control()->update();
									return true;
								}
							} else {

								//look for points to move

								int closest_idx=-1;
								Vector2 closest_pos;
								real_t closest_dist=1e10;
								for(int i=0;i<poly.size();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 (closest_idx>=0) {

									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) {

								//apply

								ERR_FAIL_INDEX_V(edited_point,poly.size(),false);
								poly[edited_point]=edited_point_pos;
								undo_redo->create_action("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->commit_action();

								edited_point=-1;
								return true;
							}
						}
					} if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {



						int closest_idx=-1;
						Vector2 closest_pos;
						real_t closest_dist=1e10;
						for(int i=0;i<poly.size();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 (closest_idx>=0) {


							undo_redo->create_action("Edit Poly (Remove Point)");
							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->commit_action();
							return true;
						}

					}



				} break;
			}



		} break;
		case InputEvent::MOUSE_MOTION: {

			const InputEventMouseMotion &mm=p_event.mouse_motion;

			if (edited_point!=-1 && (wip_active || mm.button_mask&BUTTON_MASK_LEFT)) {

				Vector2 gpoint = Point2(mm.x,mm.y);
				Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
				cpoint=snap_point(cpoint);
				edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint);

				canvas_item_editor->get_viewport_control()->update();

			}

		} break;
	}

	return false;
}
Пример #22
0
TileMapEditor::TileMapEditor(EditorNode *p_editor) {

	node=NULL;
	canvas_item_editor=NULL;
	editor=p_editor;
	undo_redo=editor->get_undo_redo();

	tool=TOOL_NONE;
	selection_active=false;
	mouse_over=false;

	flip_h=false;
	flip_v=false;
	transpose=false;

	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("input_event", this, "_sbox_input");
	add_child(search_box);

	int mw = EDITOR_DEF("tile_map/palette_min_width", 80);

	// Add tile palette
	palette = memnew( ItemList );
	palette->set_v_size_flags(SIZE_EXPAND_FILL);
	palette->set_custom_minimum_size(Size2(mw,0));
	add_child(palette);

	// Add menu items
	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);

	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);

	PopupMenu *p = options->get_popup();

	p->add_item(TTR("Bucket"), OPTION_BUCKET);
	p->add_separator();
	p->add_item(TTR("Pick Tile"), OPTION_PICK_TILE, KEY_CONTROL);
	p->add_separator();
	p->add_item(TTR("Select"), OPTION_SELECT, KEY_MASK_CMD+KEY_B);
	p->add_item(TTR("Duplicate Selection"), OPTION_DUPLICATE, KEY_MASK_CMD+KEY_D);
	p->add_item(TTR("Erase Selection"), OPTION_ERASE_SELECTION, KEY_DELETE);

	p->connect("item_pressed", this, "_menu_option");

	toolbar->add_child(options);

	toolbar->add_child( memnew( VSeparator ) );

	transp = memnew( ToolButton );
	transp->set_toggle_mode(true);
	transp->set_tooltip(TTR("Transpose"));
	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->set_toggle_mode(true);
	mirror_x->set_tooltip(TTR("Mirror X (A)"));
	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->set_toggle_mode(true);
	mirror_y->set_tooltip(TTR("Mirror Y (S)"));
	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 ) );

	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->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->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->set_toggle_mode(true);
	rotate_270->set_tooltip(TTR("Rotate 270 degrees"));
	rotate_270->set_focus_mode(FOCUS_NONE);
	rotate_270->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_270));
	toolbar->add_child(rotate_270);
	toolbar->hide();

	rotate_0->set_pressed(true);
}
Пример #23
0
void register_bb10_exporter() {

	EDITOR_DEF("blackberry/host_tools","");
	EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"blackberry/host_tools",PROPERTY_HINT_GLOBAL_DIR));
	EDITOR_DEF("blackberry/debug_token","");
	EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"blackberry/debug_token",PROPERTY_HINT_GLOBAL_FILE,"bar"));
	EDITOR_DEF("blackberry/device_1/host","");
	EDITOR_DEF("blackberry/device_1/password","");
	EDITOR_DEF("blackberry/device_2/host","");
	EDITOR_DEF("blackberry/device_2/password","");
	EDITOR_DEF("blackberry/device_3/host","");
	EDITOR_DEF("blackberry/device_3/password","");
	EDITOR_DEF("blackberry/device_4/host","");
	EDITOR_DEF("blackberry/device_4/password","");
	EDITOR_DEF("blackberry/device_5/host","");
	EDITOR_DEF("blackberry/device_5/password","");

	Ref<EditorExportPlatformBB10> exporter = Ref<EditorExportPlatformBB10>( memnew(EditorExportPlatformBB10) );
	EditorImportExport::get_singleton()->add_export_platform(exporter);


}
Пример #24
0
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_force_autohinter(true); //just looks better..i think?

	Ref<DynamicFontData> DroidSansFallback;
	DroidSansFallback.instance();
	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_force_autohinter(true); //just looks better..i think?

	Ref<DynamicFontData> DroidSansArabic;
	DroidSansArabic.instance();
	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_force_autohinter(true); //just looks better..i think?

	Ref<DynamicFontData> DroidSansThai;
	DroidSansThai.instance();
	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);
	//dfd->set_force_autohinter(true); //just looks better..i think?

	MAKE_DROID_SANS(df, int(EditorSettings::get_singleton()->get("interface/font_size")) * EDSCALE);

	p_theme->set_default_theme_font(df);

	//Ref<BitmapFont> doc_font = make_font(_bi_font_doc_font_height,_bi_font_doc_font_ascent,0,_bi_font_doc_font_charcount,_bi_font_doc_font_characters,p_theme->get_icon("DocFont","EditorIcons"));
	//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);

	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_font_data(dfmono);
	MAKE_FALLBACKS(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_font_data(dfmono);
	MAKE_FALLBACKS(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);
}
Пример #25
0
void ScriptTextEditor::_load_theme_settings() {

	TextEdit *text_edit = code_editor->get_text_edit();

	text_edit->clear_colors();

	/* keyword color */


	text_edit->set_custom_bg_color(EDITOR_DEF("text_editor/background_color",Color(0,0,0,0)));
	text_edit->add_color_override("completion_background_color", EDITOR_DEF("text_editor/completion_background_color", Color(0,0,0,0)));
	text_edit->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/completion_selected_color", Color::html("434244")));
	text_edit->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/completion_existing_color", Color::html("21dfdfdf")));
	text_edit->add_color_override("completion_scroll_color", EDITOR_DEF("text_editor/completion_scroll_color", Color::html("ffffff")));
	text_edit->add_color_override("completion_font_color", EDITOR_DEF("text_editor/completion_font_color", Color::html("aaaaaa")));
	text_edit->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0)));
	text_edit->add_color_override("line_number_color",EDITOR_DEF("text_editor/line_number_color",Color(0,0,0)));
	text_edit->add_color_override("caret_color",EDITOR_DEF("text_editor/caret_color",Color(0,0,0)));
	text_edit->add_color_override("caret_background_color",EDITOR_DEF("text_editor/caret_background_color",Color(0,0,0)));
	text_edit->add_color_override("font_selected_color",EDITOR_DEF("text_editor/text_selected_color",Color(1,1,1)));
	text_edit->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1)));
	text_edit->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/brace_mismatch_color",Color(1,0.2,0.2)));
	text_edit->add_color_override("current_line_color",EDITOR_DEF("text_editor/current_line_color",Color(0.3,0.5,0.8,0.15)));
	text_edit->add_color_override("word_highlighted_color",EDITOR_DEF("text_editor/word_highlighted_color",Color(0.8,0.9,0.9,0.15)));
	text_edit->add_color_override("number_color",EDITOR_DEF("text_editor/number_color",Color(0.9,0.6,0.0,2)));
	text_edit->add_color_override("function_color",EDITOR_DEF("text_editor/function_color",Color(0.4,0.6,0.8)));
	text_edit->add_color_override("member_variable_color",EDITOR_DEF("text_editor/member_variable_color",Color(0.9,0.3,0.3)));
	text_edit->add_color_override("mark_color", EDITOR_DEF("text_editor/mark_color", Color(1.0,0.4,0.4,0.4)));
	text_edit->add_color_override("breakpoint_color", EDITOR_DEF("text_editor/breakpoint_color", Color(0.8,0.8,0.4,0.2)));
	text_edit->add_color_override("search_result_color",EDITOR_DEF("text_editor/search_result_color",Color(0.05,0.25,0.05,1)));
	text_edit->add_color_override("search_result_border_color",EDITOR_DEF("text_editor/search_result_border_color",Color(0.1,0.45,0.1,1)));
	text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/line_spacing",4));

	Color keyword_color= EDITOR_DEF("text_editor/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()) {

		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));

	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/engine_type_color",Color(0.0,0.2,0.4));

	List<StringName> types;
	ObjectTypeDB::get_type_list(&types);

	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);
	}

	//colorize comments
	Color comment_color = EDITOR_DEF("text_editor/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()) {

		String comment = E->get();
		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=="");
	}

	//colorize strings
	Color string_color = EDITOR_DEF("text_editor/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()) {

		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=="");
	}

	//colorize symbols
	Color symbol_color= EDITOR_DEF("text_editor/symbol_color",Color::hex(0x005291ff));
	text_edit->set_symbol_color(symbol_color);

}
Пример #26
0
void GridMapEditor::update_pallete()  {
	int selected = theme_pallete->get_current();

	theme_pallete->clear();
	if (display_mode == DISPLAY_THUMBNAIL) {
		theme_pallete->set_max_columns(0);
		theme_pallete->set_icon_mode(ItemList::ICON_MODE_TOP);
	} else if (display_mode == DISPLAY_LIST){
		theme_pallete->set_max_columns(1);
		theme_pallete->set_icon_mode(ItemList::ICON_MODE_LEFT);
	}

	float min_size = EDITOR_DEF("editors/grid_map/preview_size",64);
	theme_pallete->set_fixed_icon_size(Size2(min_size, min_size));
	theme_pallete->set_fixed_column_width(min_size*3/2);
	theme_pallete->set_max_text_lines(2);

	Ref<MeshLibrary> theme = node->get_theme();

	if (theme.is_null()) {
		last_theme=NULL;
		return;
	}

	Vector<int> ids;
	ids = theme->get_item_list();

	List<_CGMEItemSort> il;
	for(int i=0;i<ids.size();i++) {

		_CGMEItemSort is;
		is.id=ids[i];
		is.name=theme->get_item_name(ids[i]);
		il.push_back(is);
	}
	il.sort();

	int item = 0;

	for(List<_CGMEItemSort>::Element *E=il.front();E;E=E->next()) {
		int id = E->get().id;

		theme_pallete->add_item("");

		String name=theme->get_item_name(id);
		Ref<Texture> preview = theme->get_item_preview(id);

		if (!preview.is_null()) {
			theme_pallete->set_item_icon(item, preview);
			theme_pallete->set_item_tooltip(item, name);
		}
		if (name!="") {
			theme_pallete->set_item_text(item,name);
		}
		theme_pallete->set_item_metadata(item, id);

		item++;
	}

	if (selected!=-1) {
		theme_pallete->select(selected);
	}

	last_theme=theme.operator->();
}
Пример #27
0
GridMapEditor::GridMapEditor(EditorNode *p_editor) {


	input_action=INPUT_NONE;
	editor=p_editor;
	undo_redo=p_editor->get_undo_redo();

	int mw = EDITOR_DEF("editors/grid_map/palette_min_width",230);
	Control *ec = memnew( Control);
	ec->set_custom_minimum_size(Size2(mw,0));
	add_child(ec);


	spatial_editor_hb = memnew( HBoxContainer );
	SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
	options = memnew( MenuButton );
	spatial_editor_hb->add_child(options);
	spatial_editor_hb->hide();

	options->set_text("Grid");
	options->get_popup()->add_check_item("Snap View",MENU_OPTION_LOCK_VIEW);
	options->get_popup()->add_separator();
	options->get_popup()->add_item("Prev Level ("+keycode_get_string(KEY_MASK_CMD)+"Down Wheel)",MENU_OPTION_PREV_LEVEL);
	options->get_popup()->add_item("Next Level ("+keycode_get_string(KEY_MASK_CMD)+"Up Wheel)",MENU_OPTION_NEXT_LEVEL);
	options->get_popup()->add_separator();
	options->get_popup()->add_check_item("Clip Disabled",MENU_OPTION_CLIP_DISABLED);
	options->get_popup()->set_item_checked( options->get_popup()->get_item_index(MENU_OPTION_CLIP_DISABLED), true );
	options->get_popup()->add_check_item("Clip Above",MENU_OPTION_CLIP_ABOVE);
	options->get_popup()->add_check_item("Clip Below",MENU_OPTION_CLIP_BELOW);
	options->get_popup()->add_separator();
	options->get_popup()->add_check_item("Edit X Axis",MENU_OPTION_X_AXIS,KEY_Z);
	options->get_popup()->add_check_item("Edit Y Axis",MENU_OPTION_Y_AXIS,KEY_X);
	options->get_popup()->add_check_item("Edit Z Axis",MENU_OPTION_Z_AXIS,KEY_C);
	options->get_popup()->set_item_checked( options->get_popup()->get_item_index(MENU_OPTION_Y_AXIS), true );
	options->get_popup()->add_separator();
	options->get_popup()->add_item("Cursor Rotate X",MENU_OPTION_CURSOR_ROTATE_X,KEY_A);
	options->get_popup()->add_item("Cursor Rotate Y",MENU_OPTION_CURSOR_ROTATE_Y,KEY_S);
	options->get_popup()->add_item("Cursor Rotate Z",MENU_OPTION_CURSOR_ROTATE_Z,KEY_D);
	options->get_popup()->add_item("Cursor Back Rotate X",MENU_OPTION_CURSOR_BACK_ROTATE_X,KEY_MASK_SHIFT+KEY_A);
	options->get_popup()->add_item("Cursor Back Rotate Y",MENU_OPTION_CURSOR_BACK_ROTATE_Y,KEY_MASK_SHIFT+KEY_S);
	options->get_popup()->add_item("Cursor Back Rotate Z",MENU_OPTION_CURSOR_BACK_ROTATE_Z,KEY_MASK_SHIFT+KEY_D);
	options->get_popup()->add_item("Cursor Clear Rotation",MENU_OPTION_CURSOR_CLEAR_ROTATION,KEY_W);
	options->get_popup()->add_separator();
	options->get_popup()->add_check_item("Duplicate Selects",MENU_OPTION_DUPLICATE_SELECTS);
	options->get_popup()->add_separator();
	options->get_popup()->add_item("Create Area",MENU_OPTION_SELECTION_MAKE_AREA,KEY_CONTROL+KEY_C);
	options->get_popup()->add_item("Create Exterior Connector",MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR);
	options->get_popup()->add_item("Erase Area",MENU_OPTION_REMOVE_AREA);
	options->get_popup()->add_separator();
	options->get_popup()->add_item("Selection -> Duplicate",MENU_OPTION_SELECTION_DUPLICATE,KEY_MASK_SHIFT+KEY_INSERT);
	options->get_popup()->add_item("Selection -> Clear",MENU_OPTION_SELECTION_CLEAR,KEY_MASK_SHIFT+KEY_DELETE);
	//options->get_popup()->add_separator();
	//options->get_popup()->add_item("Configure",MENU_OPTION_CONFIGURE);

	options->get_popup()->add_separator();
	options->get_popup()->add_item("Settings", MENU_OPTION_GRIDMAP_SETTINGS);

	settings_dialog = memnew(ConfirmationDialog);
	settings_dialog->set_title("GridMap Settings");
	add_child(settings_dialog);
	settings_vbc = memnew(VBoxContainer);
	settings_vbc->set_custom_minimum_size(Size2(200, 0));
	settings_dialog->add_child(settings_vbc);

	settings_pick_distance = memnew(SpinBox);
	settings_pick_distance->set_max(10000.0f);
	settings_pick_distance->set_min(500.0f);
	settings_pick_distance->set_step(1.0f);
	settings_pick_distance->set_value(EDITOR_DEF("editors/grid_map/pick_distance", 5000.0));
	settings_vbc->add_margin_child("Pick Distance:", settings_pick_distance);

	clip_mode=CLIP_DISABLED;
	options->get_popup()->connect("id_pressed", this,"_menu_option");

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);
	hb->set_h_size_flags(SIZE_EXPAND_FILL);

	edit_mode = memnew(OptionButton);
	edit_mode->set_area_as_parent_rect();
	edit_mode->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_BEGIN,24);
	edit_mode->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,14);
	edit_mode->add_item("Tiles");
	edit_mode->add_item("Areas");
	hb->add_child(edit_mode);
	edit_mode->set_h_size_flags(SIZE_EXPAND_FILL);

	mode_thumbnail = memnew( ToolButton );
	mode_thumbnail->set_toggle_mode(true);
	mode_thumbnail->set_pressed(true);
	mode_thumbnail->set_icon(p_editor->get_gui_base()->get_icon("FileThumbnail","EditorIcons"));
	hb->add_child(mode_thumbnail);
	mode_thumbnail->connect("pressed", this, "_set_display_mode", varray(DISPLAY_THUMBNAIL));

	mode_list = memnew( ToolButton );
	mode_list->set_toggle_mode(true);
	mode_list->set_pressed(false);
	mode_list->set_icon(p_editor->get_gui_base()->get_icon("FileList", "EditorIcons"));
	hb->add_child(mode_list);
	mode_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST));

	EDITOR_DEF("editors/grid_map/preview_size",64)

	display_mode = DISPLAY_THUMBNAIL;
	selected_area=-1;

	theme_pallete = memnew( ItemList );
	add_child(theme_pallete);
	theme_pallete->set_v_size_flags(SIZE_EXPAND_FILL);

	area_list = memnew( Tree );
	add_child(area_list);
	area_list->set_v_size_flags(SIZE_EXPAND_FILL);
	area_list->hide();

	spatial_editor_hb->add_child(memnew(VSeparator));
	Label *fl = memnew(Label);
	fl->set_text("   Floor: ");
	spatial_editor_hb->add_child(fl);

	floor = memnew( SpinBox );
	floor->set_min(-32767);
	floor->set_max(32767);
	floor->set_step(1);
	floor->get_line_edit()->add_constant_override("minimum_spaces",16);

	spatial_editor_hb->add_child(floor);
	floor->connect("value_changed",this,"_floor_changed");


	edit_axis=Vector3::AXIS_Y;
	edit_floor[0]=-1;
	edit_floor[1]=-1;
	edit_floor[2]=-1;

	cursor_visible=false;
	selected_pallete=-1;
	lock_view=false;
	cursor_rot=0;
	last_mouseover=Vector3(-1,-1,-1);

	selection_mesh = VisualServer::get_singleton()->mesh_create();
	duplicate_mesh = VisualServer::get_singleton()->mesh_create();

	{
		//selection mesh create


		PoolVector<Vector3> lines;
		PoolVector<Vector3> triangles;

		for (int i=0;i<6;i++) {


			Vector3 face_points[4];

			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));

				for (int k=0;k<3;k++) {

					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);
				}
			}

			triangles.push_back(face_points[0]*0.5+Vector3(0.5,0.5,0.5));
			triangles.push_back(face_points[1]*0.5+Vector3(0.5,0.5,0.5));
			triangles.push_back(face_points[2]*0.5+Vector3(0.5,0.5,0.5));

			triangles.push_back(face_points[2]*0.5+Vector3(0.5,0.5,0.5));
			triangles.push_back(face_points[3]*0.5+Vector3(0.5,0.5,0.5));
			triangles.push_back(face_points[0]*0.5+Vector3(0.5,0.5,0.5));
		}

		for(int i=0;i<12;i++) {

			Rect3 base(Vector3(0,0,0),Vector3(1,1,1));
			Vector3 a,b;
			base.get_edge(i,a,b);
			lines.push_back(a);
			lines.push_back(b);
		}

		Array d;
		d.resize(VS::ARRAY_MAX);

		inner_mat = VisualServer::get_singleton()->fixed_material_create();
		VisualServer::get_singleton()->fixed_material_set_param(inner_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.3));
		VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_ONTOP,true);
		VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_UNSHADED,true);
		VisualServer::get_singleton()->fixed_material_set_flag( inner_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );


		d[VS::ARRAY_VERTEX]=triangles;
		VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_TRIANGLES,d);
		VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,0,inner_mat);

		outer_mat = VisualServer::get_singleton()->fixed_material_create();
		VisualServer::get_singleton()->fixed_material_set_param(outer_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.8));
		VisualServer::get_singleton()->material_set_line_width(outer_mat,3.0);
		VisualServer::get_singleton()->material_set_flag(outer_mat,VS::MATERIAL_FLAG_ONTOP,true);
		VisualServer::get_singleton()->material_set_flag(outer_mat,VS::MATERIAL_FLAG_UNSHADED,true);
		VisualServer::get_singleton()->fixed_material_set_flag( outer_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );


		d[VS::ARRAY_VERTEX]=lines;
		VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_LINES,d);
		VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,1,outer_mat);


		inner_mat_dup = VisualServer::get_singleton()->fixed_material_create();
		VisualServer::get_singleton()->fixed_material_set_param(inner_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.3));
		VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_ONTOP,true);
		VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_UNSHADED,true);
		VisualServer::get_singleton()->fixed_material_set_flag( inner_mat_dup, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );


		d[VS::ARRAY_VERTEX]=triangles;
		VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_TRIANGLES,d);
		VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,0,inner_mat_dup);

		outer_mat_dup = VisualServer::get_singleton()->fixed_material_create();
		VisualServer::get_singleton()->fixed_material_set_param(outer_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.8));
		VisualServer::get_singleton()->material_set_line_width(outer_mat_dup,3.0);
		VisualServer::get_singleton()->material_set_flag(outer_mat_dup,VS::MATERIAL_FLAG_ONTOP,true);
		VisualServer::get_singleton()->material_set_flag(outer_mat_dup,VS::MATERIAL_FLAG_UNSHADED,true);
		VisualServer::get_singleton()->fixed_material_set_flag( outer_mat_dup, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );


		d[VS::ARRAY_VERTEX]=lines;
		VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_LINES,d);
		VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,1,outer_mat_dup);

	}

	selection.active=false;
	updating=false;

}
bool NavigationPolygonEditor::forward_gui_input(const Ref<InputEvent> &p_event) {

	if (!node)
		return false;

	if (node->get_navigation_polygon().is_null()) {

		Ref<InputEventMouseButton> mb = p_event;

		if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) {
			create_nav->set_text("No NavigationPolygon resource on this node.\nCreate and assign one?");
			create_nav->popup_centered_minsize();
		}
		return (mb.is_valid() && mb->get_button_index() == 1);
	}

	Ref<InputEventMouseButton> mb = p_event;

	if (mb.is_valid()) {

		Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();

		Vector2 gpoint = mb->get_position();
		Vector2 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);

		//first check if a point is to be added (segment split)
		real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8);

		switch (mode) {

			case MODE_CREATE: {

				if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {

					if (!wip_active) {

						wip.clear();
						wip.push_back(cpoint);
						wip_active = true;
						edited_point_pos = cpoint;
						edited_outline = -1;
						canvas_item_editor->get_viewport_control()->update();
						edited_point = 1;
						return true;
					} else {

						if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_threshold) {
							//wip closed
							_wip_close();

							return true;
						} else {

							wip.push_back(cpoint);
							edited_point = wip.size();
							canvas_item_editor->get_viewport_control()->update();
							return true;

							//add wip point
						}
					}
				} else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && wip_active) {
					_wip_close();
				}

			} break;

			case MODE_EDIT: {

				if (mb->get_button_index() == BUTTON_LEFT) {
					if (mb->is_pressed()) {

						if (mb->get_control()) {

							//search edges
							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++) {

								PoolVector<Vector2> points = node->get_navigation_polygon()->get_outline(j);

								int pc = points.size();
								PoolVector<Vector2>::Read poly = points.read();

								for (int i = 0; i < pc; i++) {

									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)
										continue; //not valid to reuse point

									real_t d = cp.distance_to(gpoint);
									if (d < closest_dist && d < grab_threshold) {
										closest_dist = d;
										closest_outline = j;
										closest_pos = cp;
										closest_idx = i;
									}
								}
							}

							if (closest_idx >= 0) {

								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);
								canvas_item_editor->get_viewport_control()->update();
								return true;
							}
						} else {

							//look for points to move
							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++) {

								PoolVector<Vector2> points = node->get_navigation_polygon()->get_outline(j);

								int pc = points.size();
								PoolVector<Vector2>::Read poly = points.read();

								for (int i = 0; i < pc; i++) {

									Vector2 cp = xform.xform(poly[i]);

									real_t d = cp.distance_to(gpoint);
									if (d < closest_dist && d < grab_threshold) {
										closest_dist = d;
										closest_pos = cp;
										closest_outline = j;
										closest_idx = i;
									}
								}
							}

							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);
								canvas_item_editor->get_viewport_control()->update();
								return true;
							}
						}
					} else {

						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);
							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->commit_action();

							edited_point = -1;
							return true;
						}
					}
				} else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && edited_point == -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++) {

						PoolVector<Vector2> points = node->get_navigation_polygon()->get_outline(j);

						int pc = points.size();
						PoolVector<Vector2>::Read poly = points.read();

						for (int i = 0; i < pc; i++) {

							Vector2 cp = xform.xform(poly[i]);

							real_t d = cp.distance_to(gpoint);
							if (d < closest_dist && d < grab_threshold) {
								closest_dist = d;
								closest_pos = cp;
								closest_outline = j;
								closest_idx = i;
							}
						}
					}

					if (closest_idx >= 0) {

						PoolVector<Vector2> poly = node->get_navigation_polygon()->get_outline(closest_outline);

						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);
							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->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);
							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->commit_action();
						}
						return true;
					}
				}

			} break;
		}
	}

	Ref<InputEventMouseMotion> mm = p_event;

	if (mm.is_valid()) {

		if (edited_point != -1 && (wip_active || mm->get_button_mask() & BUTTON_MASK_LEFT)) {

			Vector2 gpoint = mm->get_position();
			Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint);
			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();
		}
	}

	return false;
}
Пример #29
0
TileMapEditor::TileMapEditor(EditorNode *p_editor) {

	node=NULL;
	canvas_item_editor=NULL;
	editor=p_editor;
	undo_redo = editor->get_undo_redo();

	int mw = EDITOR_DEF("tile_map/palette_min_width",80);
	Control *ec = memnew( Control);
	ec->set_custom_minimum_size(Size2(mw,0));
	add_child(ec);

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);
	hb->set_h_size_flags(SIZE_EXPAND_FILL);
	hb->add_spacer(true);

	button_thumbnail = memnew( ToolButton );
	button_thumbnail->set_toggle_mode(true);
	button_thumbnail->set_pressed(true);
	button_thumbnail->set_icon(p_editor->get_gui_base()->get_icon("FileThumbnail","EditorIcons"));
	hb->add_child(button_thumbnail);
	button_thumbnail->connect("pressed", this, "_set_display_mode", varray(DISPLAY_THUMBNAIL));

	button_list = memnew( ToolButton );
	button_list->set_toggle_mode(true);
	button_list->set_pressed(false);
	button_list->set_icon(p_editor->get_gui_base()->get_icon("FileList","EditorIcons"));
	hb->add_child(button_list);
	button_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST));

	// Add tile palette
	palette = memnew( ItemList );
	palette->set_v_size_flags(SIZE_EXPAND_FILL);
	add_child(palette);

	// Add menu items
	canvas_item_editor_hb = memnew( HBoxContainer );
	CanvasItemEditor::get_singleton()->add_control_to_menu_panel(canvas_item_editor_hb);
	canvas_item_editor_hb->add_child( memnew( VSeparator ));
	transpose = memnew( ToolButton );
	transpose->set_toggle_mode(true);
	transpose->set_tooltip("Transpose");
	transpose->set_focus_mode(FOCUS_NONE);
	transpose->connect("pressed", this, "_update_transform_buttons", make_binds(transpose));
	canvas_item_editor_hb->add_child(transpose);
	mirror_x = memnew( ToolButton );
	mirror_x->set_toggle_mode(true);
	mirror_x->set_tooltip("Mirror X (A)");
	mirror_x->set_focus_mode(FOCUS_NONE);
	mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x));
	canvas_item_editor_hb->add_child(mirror_x);
	mirror_y = memnew( ToolButton );
	mirror_y->set_toggle_mode(true);
	mirror_y->set_tooltip("Mirror Y (S)");
	mirror_y->set_focus_mode(FOCUS_NONE);
	mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y));
	canvas_item_editor_hb->add_child(mirror_y);
	canvas_item_editor_hb->add_child(memnew(VSeparator));
	rotate_0 = memnew( ToolButton );
	rotate_0->set_toggle_mode(true);
	rotate_0->set_tooltip("Rotate 0 degrees");
	rotate_0->set_focus_mode(FOCUS_NONE);
	rotate_0->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_0));
	canvas_item_editor_hb->add_child(rotate_0);
	rotate_90 = memnew( ToolButton );
	rotate_90->set_toggle_mode(true);
	rotate_90->set_tooltip("Rotate 90 degrees");
	rotate_90->set_focus_mode(FOCUS_NONE);
	rotate_90->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_90));
	canvas_item_editor_hb->add_child(rotate_90);
	rotate_180 = memnew( ToolButton );
	rotate_180->set_toggle_mode(true);
	rotate_180->set_tooltip("Rotate 180 degrees");
	rotate_180->set_focus_mode(FOCUS_NONE);
	rotate_180->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_180));
	canvas_item_editor_hb->add_child(rotate_180);
	rotate_270 = memnew( ToolButton );
	rotate_270->set_toggle_mode(true);
	rotate_270->set_tooltip("Rotate 270 degrees");
	rotate_270->set_focus_mode(FOCUS_NONE);
	rotate_270->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_270));
	canvas_item_editor_hb->add_child(rotate_270);
	canvas_item_editor_hb->hide();

	rotate_0->set_pressed(true);
	tool=TOOL_NONE;
	selection_active=false;
	mouse_over=false;
}
Пример #30
0
CreateDialog::CreateDialog() {

	is_replace_mode = false;

	set_resizable(true);

	HSplitContainer *hsc = memnew(HSplitContainer);
	add_child(hsc);

	VSplitContainer *vsc = memnew(VSplitContainer);
	hsc->add_child(vsc);

	VBoxContainer *fav_vb = memnew(VBoxContainer);
	vsc->add_child(fav_vb);
	fav_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE);
	fav_vb->set_v_size_flags(SIZE_EXPAND_FILL);

	favorites = memnew(Tree);
	fav_vb->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->set_drag_forwarding(this);

	VBoxContainer *rec_vb = memnew(VBoxContainer);
	vsc->add_child(rec_vb);
	rec_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE);
	rec_vb->set_v_size_flags(SIZE_EXPAND_FILL);

	recent = memnew(Tree);
	rec_vb->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");

	VBoxContainer *vbc = memnew(VBoxContainer);
	hsc->add_child(vbc);
	vbc->set_custom_minimum_size(Size2(300, 0) * EDSCALE);
	vbc->set_h_size_flags(SIZE_EXPAND_FILL);
	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->set_flat(true);
	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);
	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");
	base_type = "Object";
	preferred_search_result_type = "";

	help_bit = memnew(EditorHelpBit);
	vbc->add_margin_child(TTR("Description:"), help_bit);
	help_bit->connect("request_hide", this, "_closed");

	type_blacklist.insert("PluginScript"); // PluginScript must be initialized before use, which is not possible here
	type_blacklist.insert("ScriptCreateDialog"); // This is an exposed editor Node that doesn't have an Editor prefix.

	EDITOR_DEF("interface/editors/derive_script_globals_by_name", true);
}