ItemListEditor::ItemListEditor() {

	selected_idx=-1;

	add_child( memnew( VSeparator ) );

	toolbar_button = memnew( ToolButton );
	toolbar_button->set_text(TTR("Items"));
	add_child(toolbar_button);
	toolbar_button->connect("pressed",this,"_edit_items");

	dialog = memnew( AcceptDialog );
	dialog->set_title(TTR("Item List Editor"));
	add_child( dialog );

	VBoxContainer *vbc = memnew( VBoxContainer );
	dialog->add_child(vbc);
	dialog->set_child_rect(vbc);

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

	add_button = memnew( Button );
	add_button->set_text(TTR("Add"));
	hbc->add_child(add_button);
	add_button->connect("pressed",this,"_add_button");

	hbc->add_spacer();

	del_button = memnew( Button );
	del_button->set_text(TTR("Delete"));
	hbc->add_child(del_button);
	del_button->connect("pressed",this,"_delete_button");

	property_editor = memnew( PropertyEditor );
	property_editor->hide_top_label();
	property_editor->set_subsection_selectable(true);
	vbc->add_child(property_editor);
	property_editor->set_v_size_flags(SIZE_EXPAND_FILL);

	tree = property_editor->get_scene_tree();
}
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;

}
EditorSettingsDialog::EditorSettingsDialog() {

	set_title(TTR("Editor Settings"));
	set_resizable(true);
	undo_redo = memnew(UndoRedo);

	tabs = memnew(TabContainer);
	tabs->set_tab_align(TabContainer::ALIGN_LEFT);
	tabs->connect("tab_changed", this, "_tabs_tab_changed");
	add_child(tabs);
	//set_child_rect(tabs);

	// General Tab

	tab_general = memnew(VBoxContainer);
	tabs->add_child(tab_general);
	tab_general->set_name(TTR("General"));

	HBoxContainer *hbc = memnew(HBoxContainer);
	hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	tab_general->add_child(hbc);

	search_box = memnew(LineEdit);
	search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	hbc->add_child(search_box);

	inspector = memnew(SectionedInspector);
	//inspector->hide_top_label();
	inspector->get_inspector()->set_use_filter(true);
	inspector->register_search_box(search_box);
	inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	inspector->get_inspector()->set_undo_redo(undo_redo);
	tab_general->add_child(inspector);
	inspector->get_inspector()->connect("property_edited", this, "_settings_property_edited");
	inspector->get_inspector()->connect("restart_requested", this, "_editor_restart_request");

	restart_container = memnew(PanelContainer);
	tab_general->add_child(restart_container);
	HBoxContainer *restart_hb = memnew(HBoxContainer);
	restart_container->add_child(restart_hb);
	restart_icon = memnew(TextureRect);
	restart_icon->set_v_size_flags(SIZE_SHRINK_CENTER);
	restart_hb->add_child(restart_icon);
	restart_label = memnew(Label);
	restart_label->set_text(TTR("Editor must be restarted for changes to take effect"));
	restart_hb->add_child(restart_label);
	restart_hb->add_spacer();
	Button *restart_button = memnew(Button);
	restart_button->connect("pressed", this, "_editor_restart");
	restart_hb->add_child(restart_button);
	restart_button->set_text(TTR("Save & Restart"));
	restart_close_button = memnew(ToolButton);
	restart_close_button->connect("pressed", this, "_editor_restart_close");
	restart_hb->add_child(restart_close_button);
	restart_container->hide();

	// Shortcuts Tab

	tab_shortcuts = memnew(VBoxContainer);
	tabs->add_child(tab_shortcuts);
	tab_shortcuts->set_name(TTR("Shortcuts"));

	hbc = memnew(HBoxContainer);
	hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	tab_shortcuts->add_child(hbc);

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

	shortcuts = memnew(Tree);
	tab_shortcuts->add_child(shortcuts, true);
	shortcuts->set_v_size_flags(SIZE_EXPAND_FILL);
	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, TTR("Name"));
	shortcuts->set_column_title(1, TTR("Binding"));
	shortcuts->connect("button_pressed", this, "_shortcut_button_pressed");

	press_a_key = memnew(ConfirmationDialog);
	press_a_key->set_focus_mode(FOCUS_ALL);
	add_child(press_a_key);

	Label *l = memnew(Label);
	l->set_text(TTR("Press a Key..."));
	l->set_anchors_and_margins_preset(Control::PRESET_WIDE);
	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;
	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");

	//get_ok()->set_text("Apply");
	set_hide_on_ok(true);
	//get_cancel()->set_text("Close");

	timer = memnew(Timer);
	timer->set_wait_time(1.5);
	timer->connect("timeout", this, "_settings_save");
	timer->set_one_shot(true);
	add_child(timer);
	EditorSettings::get_singleton()->connect("settings_changed", this, "_settings_changed");
	get_ok()->set_text(TTR("Close"));

	updating = false;
}
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;
}
Beispiel #5
0
GroupDialog::GroupDialog() {

	scene_tree = SceneTree::get_singleton();

	VBoxContainer *vbc = memnew(VBoxContainer);
	add_child(vbc);

	HBoxContainer *hbc = memnew(HBoxContainer);
	vbc->add_child(hbc);
	hbc->set_v_size_flags(SIZE_EXPAND_FILL);

	VBoxContainer *vbc_left = memnew(VBoxContainer);
	hbc->add_child(vbc_left);
	vbc_left->set_h_size_flags(SIZE_EXPAND_FILL);

	Label *group_title = memnew(Label);
	group_title->set_text(TTR("Groups"));
	vbc_left->add_child(group_title);

	groups = memnew(Tree);
	vbc_left->add_child(groups);
	groups->set_hide_root(true);
	groups->set_v_size_flags(SIZE_EXPAND_FILL);
	groups->set_select_mode(Tree::SELECT_SINGLE);
	groups->set_allow_reselect(true);
	groups->set_allow_rmb_select(true);
	groups->connect("item_selected", this, "_group_selected");
	groups->connect("button_pressed", this, "_delete_group_pressed");
	groups->connect("item_edited", this, "_group_renamed");

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

	add_group_text = memnew(LineEdit);
	chbc->add_child(add_group_text);
	add_group_text->set_h_size_flags(SIZE_EXPAND_FILL);

	Button *add_group_button = memnew(Button);
	add_group_button->set_text("Add");
	chbc->add_child(add_group_button);
	add_group_button->connect("pressed", this, "_add_group_pressed");

	VBoxContainer *vbc_add = memnew(VBoxContainer);
	hbc->add_child(vbc_add);
	vbc_add->set_h_size_flags(SIZE_EXPAND_FILL);

	Label *out_of_group_title = memnew(Label);
	out_of_group_title->set_text(TTR("Nodes not in Group"));
	vbc_add->add_child(out_of_group_title);

	nodes_to_add = memnew(Tree);
	vbc_add->add_child(nodes_to_add);
	nodes_to_add->set_hide_root(true);
	nodes_to_add->set_hide_folding(true);
	nodes_to_add->set_v_size_flags(SIZE_EXPAND_FILL);
	nodes_to_add->set_select_mode(Tree::SELECT_MULTI);
	nodes_to_add->connect("item_selected", this, "_nodes_to_add_selected");

	HBoxContainer *add_filter_hbc = memnew(HBoxContainer);
	add_filter_hbc->add_constant_override("separate", 0);
	vbc_add->add_child(add_filter_hbc);

	add_filter = memnew(LineEdit);
	add_filter->set_h_size_flags(SIZE_EXPAND_FILL);
	add_filter->set_placeholder(TTR("Filter nodes"));
	add_filter_hbc->add_child(add_filter);
	add_filter->connect("text_changed", this, "_add_filter_changed");

	VBoxContainer *vbc_buttons = memnew(VBoxContainer);
	hbc->add_child(vbc_buttons);
	vbc_buttons->set_h_size_flags(SIZE_SHRINK_CENTER);
	vbc_buttons->set_v_size_flags(SIZE_SHRINK_CENTER);

	add_button = memnew(ToolButton);
	add_button->set_text(TTR("Add"));
	add_button->connect("pressed", this, "_add_pressed");

	vbc_buttons->add_child(add_button);
	vbc_buttons->add_spacer();
	vbc_buttons->add_spacer();
	vbc_buttons->add_spacer();

	remove_button = memnew(ToolButton);
	remove_button->set_text(TTR("Remove"));
	remove_button->connect("pressed", this, "_removed_pressed");

	vbc_buttons->add_child(remove_button);

	VBoxContainer *vbc_remove = memnew(VBoxContainer);
	hbc->add_child(vbc_remove);
	vbc_remove->set_h_size_flags(SIZE_EXPAND_FILL);

	Label *in_group_title = memnew(Label);
	in_group_title->set_text(TTR("Nodes in Group"));
	vbc_remove->add_child(in_group_title);

	nodes_to_remove = memnew(Tree);
	vbc_remove->add_child(nodes_to_remove);
	nodes_to_remove->set_v_size_flags(SIZE_EXPAND_FILL);
	nodes_to_remove->set_hide_root(true);
	nodes_to_remove->set_hide_folding(true);
	nodes_to_remove->set_select_mode(Tree::SELECT_MULTI);
	nodes_to_remove->connect("item_selected", this, "_node_to_remove_selected");

	HBoxContainer *remove_filter_hbc = memnew(HBoxContainer);
	remove_filter_hbc->add_constant_override("separate", 0);
	vbc_remove->add_child(remove_filter_hbc);

	remove_filter = memnew(LineEdit);
	remove_filter->set_h_size_flags(SIZE_EXPAND_FILL);
	remove_filter->set_placeholder(TTR("Filter nodes"));
	remove_filter_hbc->add_child(remove_filter);
	remove_filter->connect("text_changed", this, "_remove_filter_changed");

	set_title("Group Editor");
	get_cancel()->hide();
	set_as_toplevel(true);

	error = memnew(ConfirmationDialog);
	add_child(error);
	error->get_ok()->set_text(TTR("Close"));
}
Beispiel #6
0
EditorAbout::EditorAbout() {

	set_title(TTR("Thanks from the Godot community!"));
	get_ok()->set_text(TTR("Thanks!"));
	set_hide_on_ok(true);
	set_resizable(true);

	VBoxContainer *vbc = memnew(VBoxContainer);
	HBoxContainer *hbc = memnew(HBoxContainer);
	hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	hbc->set_alignment(BoxContainer::ALIGN_CENTER);
	hbc->add_constant_override("separation", 30 * EDSCALE);
	add_child(vbc);
	vbc->add_child(hbc);

	_logo = memnew(TextureRect);
	hbc->add_child(_logo);

	String hash = String(VERSION_HASH);
	if (hash.length() != 0)
		hash = "." + hash.left(7);

	Label *about_text = memnew(Label);
	about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
	about_text->set_text(VERSION_FULL_NAME + hash + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") +
						 TTR("Godot Engine contributors") + "\n");
	hbc->add_child(about_text);

	TabContainer *tc = memnew(TabContainer);
	tc->set_custom_minimum_size(Size2(630, 240) * EDSCALE);
	tc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	vbc->add_child(tc);

	// Authors

	List<String> dev_sections;
	dev_sections.push_back(TTR("Project Founders"));
	dev_sections.push_back(TTR("Lead Developer"));
	dev_sections.push_back(TTR("Project Manager"));
	dev_sections.push_back(TTR("Developers"));
	const char **dev_src[] = { dev_founders, dev_lead, dev_manager, dev_names };
	tc->add_child(_populate_list(TTR("Authors"), dev_sections, dev_src));

	// Donors

	List<String> donor_sections;
	donor_sections.push_back(TTR("Platinum Sponsors"));
	donor_sections.push_back(TTR("Gold Sponsors"));
	donor_sections.push_back(TTR("Mini Sponsors"));
	donor_sections.push_back(TTR("Gold Donors"));
	donor_sections.push_back(TTR("Silver Donors"));
	donor_sections.push_back(TTR("Bronze Donors"));
	const char **donor_src[] = { donor_s_plat, donor_s_gold, donor_s_mini, donor_gold, donor_silver, donor_bronze };
	tc->add_child(_populate_list(TTR("Donors"), donor_sections, donor_src));

	// License

	TextEdit *license = memnew(TextEdit);
	license->set_name(TTR("License"));
	license->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	license->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	license->set_wrap(true);
	license->set_readonly(true);
	license->set_text(String::utf8(about_license));
	tc->add_child(license);

	// Thirdparty License

	VBoxContainer *license_thirdparty = memnew(VBoxContainer);
	license_thirdparty->set_name(TTR("Thirdparty License"));
	license_thirdparty->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	tc->add_child(license_thirdparty);

	Label *tpl_label = memnew(Label);
	tpl_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	tpl_label->set_autowrap(true);
	tpl_label->set_text(TTR("Godot Engine relies on a number of thirdparty free and open source libraries, all compatible with the terms of its MIT license. The following is an exhaustive list of all such thirdparty components with their respective copyright statements and license terms."));
	license_thirdparty->add_child(tpl_label);

	HSplitContainer *tpl_hbc = memnew(HSplitContainer);
	tpl_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	tpl_hbc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	tpl_hbc->set_split_offset(240 * EDSCALE);
	license_thirdparty->add_child(tpl_hbc);

	_tpl_tree = memnew(Tree);
	_tpl_tree->set_hide_root(true);
	TreeItem *root = _tpl_tree->create_item();
	TreeItem *tpl_ti_all = _tpl_tree->create_item(root);
	tpl_ti_all->set_text(0, TTR("All Components"));
	TreeItem *tpl_ti_tp = _tpl_tree->create_item(root);
	tpl_ti_tp->set_text(0, TTR("Components"));
	tpl_ti_tp->set_selectable(0, false);
	TreeItem *tpl_ti_lc = _tpl_tree->create_item(root);
	tpl_ti_lc->set_text(0, TTR("Licenses"));
	tpl_ti_lc->set_selectable(0, false);
	int read_idx = 0;
	String long_text = "";
	for (int i = 0; i < THIRDPARTY_COUNT; i++) {

		TreeItem *ti = _tpl_tree->create_item(tpl_ti_tp);
		String thirdparty = String(about_thirdparty[i]);
		ti->set_text(0, thirdparty);
		String text = thirdparty + "\n";
		long_text += "- " + thirdparty + "\n\n";
		for (int j = 0; j < about_tp_copyright_count[i]; j++) {

			text += "\n    Files:\n        " + String(about_tp_file[read_idx]).replace("\n", "\n        ") + "\n";
			String copyright = String::utf8("    \u00A9 ") + String::utf8(about_tp_copyright[read_idx]).replace("\n", String::utf8("\n    \u00A9 "));
			text += copyright;
			long_text += copyright;
			String license = "\n    License: " + String(about_tp_license[read_idx]) + "\n";
			text += license;
			long_text += license + "\n";
			read_idx++;
		}
		ti->set_metadata(0, text);
	}
	for (int i = 0; i < LICENSE_COUNT; i++) {

		TreeItem *ti = _tpl_tree->create_item(tpl_ti_lc);
		String licensename = String(about_license_name[i]);
		ti->set_text(0, licensename);
		long_text += "- " + licensename + "\n\n";
		String licensebody = String(about_license_body[i]);
		ti->set_metadata(0, licensebody);
		long_text += "    " + licensebody.replace("\n", "\n    ") + "\n\n";
	}
	tpl_ti_all->set_metadata(0, long_text);
	tpl_hbc->add_child(_tpl_tree);

	_tpl_text = memnew(TextEdit);
	_tpl_text->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	_tpl_text->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	_tpl_text->set_wrap(true);
	_tpl_text->set_readonly(true);
	tpl_hbc->add_child(_tpl_text);

	_tpl_tree->connect("item_selected", this, "_license_tree_selected");
	tpl_ti_all->select(0);
	_tpl_text->set_text(tpl_ti_all->get_metadata(0));
}
EditorSettingsDialog::EditorSettingsDialog() {

	set_title(TTR("Editor Settings"));

	tabs = memnew( TabContainer );
	add_child(tabs);
	set_child_rect(tabs);

	VBoxContainer *vbc = memnew( VBoxContainer );
	tabs->add_child(vbc);
	vbc->set_name(TTR("General"));

	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:")+" ");
	hbc->add_child(l);

	search_box = memnew( LineEdit );
	search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	hbc->add_child(search_box);

	clear_button = memnew( ToolButton );
	hbc->add_child(clear_button);
	clear_button->connect("pressed",this,"_clear_search_box");

	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);
	property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	vbc->add_child(property_editor);
	property_editor->get_property_editor()->connect("property_edited", this, "_settings_property_edited");

	vbc = memnew( VBoxContainer );
	tabs->add_child(vbc);
	vbc->set_name(TTR("Shortcuts"));

	hbc = memnew( HBoxContainer );
	hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	vbc->add_child(hbc);

	l = memnew( Label );
	l->set_text(TTR("Search:")+" ");
	hbc->add_child(l);

	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 );
	hbc->add_child(shortcut_clear_button);
	shortcut_clear_button->connect("pressed",this,"_clear_shortcut_search_box");

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

	press_a_key = memnew( ConfirmationDialog );
	press_a_key->set_focus_mode(FOCUS_ALL);
	add_child(press_a_key);

	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;
	press_a_key->add_child(l);
	press_a_key->connect("input_event",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->set_wait_time(1.5);
	timer->connect("timeout",this,"_settings_save");
	timer->set_one_shot(true);
	add_child(timer);
	EditorSettings::get_singleton()->connect("settings_changed",this,"_settings_changed");
	get_ok()->set_text(TTR("Close"));

	updating=false;

}
Beispiel #8
0
ScriptCreateDialog::ScriptCreateDialog() {

	/* DIALOG */

	/* Main Controls */

	GridContainer *gc = memnew(GridContainer);
	gc->set_columns(2);

	/* Error Messages Field */

	VBoxContainer *vb = memnew(VBoxContainer);

	HBoxContainer *hb = memnew(HBoxContainer);
	Label *l = memnew(Label);
	l->set_text(" - ");
	hb->add_child(l);
	error_label = memnew(Label);
	error_label->set_text(TTR("Error!"));
	error_label->set_align(Label::ALIGN_LEFT);
	hb->add_child(error_label);
	vb->add_child(hb);

	hb = memnew(HBoxContainer);
	l = memnew(Label);
	l->set_text(" - ");
	hb->add_child(l);
	path_error_label = memnew(Label);
	path_error_label->set_text(TTR("Error!"));
	path_error_label->set_align(Label::ALIGN_LEFT);
	hb->add_child(path_error_label);
	vb->add_child(hb);

	PanelContainer *pc = memnew(PanelContainer);
	pc->set_h_size_flags(Control::SIZE_FILL);
	pc->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("bg", "Tree"));
	pc->add_child(vb);

	/* Margins */

	Control *empty_h = memnew(Control);
	empty_h->set_name("empty_h"); //duplicate() doesn't like nodes without a name
	empty_h->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	empty_h->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	empty_h->set_custom_minimum_size(Size2(0, 10 * EDSCALE));
	Control *empty_v = memnew(Control);
	empty_v->set_name("empty_v");
	empty_v->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	empty_v->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	empty_v->set_custom_minimum_size(Size2(10, 0 * EDSCALE));

	vb = memnew(VBoxContainer);
	vb->add_child(empty_h->duplicate());
	vb->add_child(gc);
	vb->add_child(empty_h->duplicate());
	vb->add_child(pc);
	vb->add_child(empty_h->duplicate());
	hb = memnew(HBoxContainer);
	hb->add_child(empty_v->duplicate());
	hb->add_child(vb);
	hb->add_child(empty_v->duplicate());

	memdelete(empty_h);
	memdelete(empty_v);

	add_child(hb);

	/* Language */

	language_menu = memnew(OptionButton);
	language_menu->set_custom_minimum_size(Size2(250, 0) * EDSCALE);
	language_menu->set_h_size_flags(SIZE_EXPAND_FILL);
	l = memnew(Label);
	l->set_text(TTR("Language"));
	l->set_align(Label::ALIGN_RIGHT);
	gc->add_child(l);
	gc->add_child(language_menu);

	int default_lang = 0;
	for (int i = 0; i < ScriptServer::get_language_count(); i++) {

		String lang = ScriptServer::get_language(i)->get_name();
		language_menu->add_item(lang);
		if (lang == "GDScript") {
			default_lang = i;
		}
	}

	String last_selected_language = EditorSettings::get_singleton()->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) {
				language_menu->select(i);
				current_language = i;
				break;
			}
		}
	} else {
		language_menu->select(default_lang);
		current_language = default_lang;
	}

	language_menu->connect("item_selected", this, "_lang_changed");

	/* Inherits */

	hb = memnew(HBoxContainer);
	hb->set_h_size_flags(SIZE_EXPAND_FILL);
	parent_name = memnew(LineEdit);
	parent_name->connect("text_changed", this, "_parent_name_changed");
	parent_name->set_h_size_flags(SIZE_EXPAND_FILL);
	hb->add_child(parent_name);
	parent_browse_button = memnew(Button);
	parent_browse_button->set_flat(true);
	parent_browse_button->connect("pressed", this, "_browse_path", varray(true));
	hb->add_child(parent_browse_button);
	l = memnew(Label);
	l->set_text(TTR("Inherits"));
	l->set_align(Label::ALIGN_RIGHT);
	gc->add_child(l);
	gc->add_child(hb);
	is_browsing_parent = false;

	/* Class Name */

	class_name = memnew(LineEdit);
	class_name->connect("text_changed", this, "_class_name_changed");
	class_name->set_h_size_flags(SIZE_EXPAND_FILL);
	l = memnew(Label);
	l->set_text(TTR("Class Name"));
	l->set_align(Label::ALIGN_RIGHT);
	gc->add_child(l);
	gc->add_child(class_name);

	/* Templates */

	template_menu = memnew(OptionButton);
	l = memnew(Label);
	l->set_text(TTR("Template"));
	l->set_align(Label::ALIGN_RIGHT);
	gc->add_child(l);
	gc->add_child(template_menu);
	template_menu->connect("item_selected", this, "_template_changed");

	/* Built-in Script */

	internal = memnew(CheckButton);
	internal->connect("pressed", this, "_built_in_pressed");
	hb = memnew(HBoxContainer);
	hb->add_child(internal);
	l = memnew(Label);
	l->set_text(TTR("Built-in Script"));
	l->set_align(Label::ALIGN_RIGHT);
	gc->add_child(l);
	gc->add_child(hb);

	/* Path */

	hb = memnew(HBoxContainer);
	file_path = memnew(LineEdit);
	file_path->connect("text_changed", this, "_path_changed");
	file_path->set_h_size_flags(SIZE_EXPAND_FILL);
	hb->add_child(file_path);
	path_button = memnew(Button);
	path_button->set_flat(true);
	path_button->connect("pressed", this, "_browse_path", varray(false));
	hb->add_child(path_button);
	l = memnew(Label);
	l->set_text(TTR("Path"));
	l->set_align(Label::ALIGN_RIGHT);
	gc->add_child(l);
	gc->add_child(hb);

	/* Dialog Setup */

	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->set_as_minsize();
	alert->get_label()->set_autowrap(true);
	alert->get_label()->set_align(Label::ALIGN_CENTER);
	alert->get_label()->set_valign(Label::VALIGN_CENTER);
	alert->get_label()->set_custom_minimum_size(Size2(325, 60) * EDSCALE);
	add_child(alert);

	set_as_minsize();
	set_hide_on_ok(false);
	set_title(TTR("Attach Node Script"));

	is_parent_name_valid = false;
	is_class_name_valid = false;
	is_path_valid = false;

	has_named_classes = false;
	supports_built_in = false;
	can_inherit_from_file = false;
	is_built_in = false;

	is_new_script_created = true;
}