Esempio n. 1
0
EditorLog::EditorLog() {

	VBoxContainer *vb = memnew( VBoxContainer);
	add_child(vb);
	vb->set_v_size_flags(SIZE_EXPAND_FILL);

	HBoxContainer *hb = memnew( HBoxContainer );
	vb->add_child(hb);
	title = memnew( Label );
	title->set_text(" Output:");
	title->set_h_size_flags(SIZE_EXPAND_FILL);
	hb->add_child(title);


	button = memnew( ToolButton );
	button->set_text_align(Button::ALIGN_LEFT);
	button->connect("pressed",this,"_flip_request");
	button->set_focus_mode(FOCUS_NONE);
	button->set_clip_text(true);
	button->set_tooltip("Open/Close output panel.");

	//pd = memnew( PaneDrag );
	//hb->add_child(pd);
	//pd->connect("dragged",this,"_dragged");
	//pd->set_default_cursor_shape(Control::CURSOR_MOVE);

	tb = memnew( TextureButton );
	hb->add_child(tb);
	tb->connect("pressed",this,"_close_request");


	ec = memnew( EmptyControl);
	vb->add_child(ec);
	ec->set_minsize(Size2(0,100));
	ec->set_v_size_flags(SIZE_EXPAND_FILL);


	PanelContainer *pc = memnew( PanelContainer );
	pc->add_style_override("panel",get_stylebox("normal","TextEdit"));
	ec->add_child(pc);
	pc->set_area_as_parent_rect();

	log = memnew( RichTextLabel );
	log->set_scroll_follow(true);
	pc->add_child(log);
	add_message(VERSION_FULL_NAME" (c) 2010-2014 www.fengei.com.");
	//log->add_text("Initialization Complete.\n"); //because it looks cool.
	add_style_override("panel",get_stylebox("panelf","Panel"));

	eh.errfunc=_error_handler;
	eh.userdata=this;
	add_error_handler(&eh);

	current=Thread::get_caller_ID();

	EditorNode::get_undo_redo()->set_commit_notify_callback(_undo_redo_cbk,this);

	hide();

}
Esempio n. 2
0
EditorAssetLibraryItem::EditorAssetLibraryItem() {

	Ref<StyleBoxEmpty> border;
	border.instance();
	/*border->set_default_margin(MARGIN_LEFT,5);
	border->set_default_margin(MARGIN_RIGHT,5);
	border->set_default_margin(MARGIN_BOTTOM,5);
	border->set_default_margin(MARGIN_TOP,5);*/
	add_style_override("panel",border);

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);

	icon = memnew( TextureButton );
	icon->set_default_cursor_shape(CURSOR_POINTING_HAND);
	icon->connect("pressed",this,"_asset_clicked");

	hb->add_child(icon);

	VBoxContainer *vb = memnew( VBoxContainer );

	hb->add_child(vb);
	vb->set_h_size_flags(SIZE_EXPAND_FILL);

	title = memnew( LinkButton );
	title->set_text("My Awesome Addon");
	title->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
	title->connect("pressed",this,"_asset_clicked");
	vb->add_child(title);


	category = memnew( LinkButton );
	category->set_text("Editor Tools");
	category->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
	title->connect("pressed",this,"_category_clicked");
	vb->add_child(category);

	author = memnew( LinkButton );
	author->set_text("Johny Tolengo");
	author->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
	title->connect("pressed",this,"_author_clicked");
	vb->add_child(author);

	HBoxContainer *rating_hb = memnew( HBoxContainer );
	vb->add_child(rating_hb);

	for(int i=0;i<5;i++) {
		stars[i]=memnew(TextureFrame);
		rating_hb->add_child(stars[i]);
	}
	price = memnew( Label );
	price->set_text("Free");
	vb->add_child(price);

	set_custom_minimum_size(Size2(250,100));
	set_h_size_flags(SIZE_EXPAND_FILL);

	set_stop_mouse(false);
}
SampleLibraryEditor::SampleLibraryEditor() {

    player = memnew(SamplePlayer);
    add_child(player);
    add_style_override("panel", get_stylebox("panel","Panel"));


    load = memnew( Button );
    load->set_pos(Point2( 5, 5 ));
    load->set_size( Size2(1,1 ) );
    add_child(load);

    file = memnew( EditorFileDialog );
    add_child(file);
    List<String> extensions;
    ResourceLoader::get_recognized_extensions_for_type("Sample",&extensions);
    for(int i=0; i<extensions.size(); i++)
        file->add_filter("*."+extensions[i]);
    file->set_mode(EditorFileDialog::MODE_OPEN_FILES);

    tree = memnew( Tree );
    tree->set_columns(6);
    add_child(tree);
    tree->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
    tree->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
    tree->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,30);
    tree->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,5);
    tree->set_column_titles_visible(true);
    tree->set_column_title(0,"Name");
    tree->set_column_title(1,"Preview");
    tree->set_column_title(2,"Format");
    tree->set_column_title(3,"dB");
    tree->set_column_title(4,"Pitch");
    tree->set_column_title(5,"");

    tree->set_column_min_width(1,150);
    tree->set_column_min_width(2,100);
    tree->set_column_min_width(3,50);
    tree->set_column_min_width(4,50);
    tree->set_column_min_width(5,32);
    tree->set_column_expand(1,false);
    tree->set_column_expand(2,false);
    tree->set_column_expand(3,false);
    tree->set_column_expand(4,false);
    tree->set_column_expand(5,false);

    dialog = memnew( ConfirmationDialog );
    add_child( dialog );

    tree->connect("button_pressed",this,"_button_pressed");
    load->connect("pressed", this,"_load_pressed");
    file->connect("files_selected", this,"_file_load_request");
    tree->connect("item_edited", this,"_item_edited");


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

}
AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
	editor=p_editor;
	singleton=this;

	updating=false;

	set_focus_mode(FOCUS_ALL);

	player=NULL;
	add_style_override("panel", get_stylebox("panel","Panel"));


	Label * l;

	/*l= memnew( Label );
	l->set_text("Animation Player:");
	add_child(l);*/

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);


	add_anim = memnew( ToolButton );
	add_anim->set_tooltip("Create new animation in player.");

	hb->add_child(add_anim);


	load_anim = memnew( ToolButton );
	load_anim->set_tooltip("Load an animation from disk.");
	hb->add_child(load_anim);

	save_anim = memnew(MenuButton);
	save_anim->set_tooltip("Save the current animation");
	save_anim->get_popup()->add_item("Save", ANIM_SAVE);
	save_anim->get_popup()->add_item("Save As..", ANIM_SAVE_AS);
	save_anim->set_focus_mode(Control::FOCUS_NONE);
	hb->add_child(save_anim);

	accept = memnew(AcceptDialog);
	add_child(accept);
	accept->connect("confirmed", this, "_menu_confirm_current");

	duplicate_anim = memnew( ToolButton );
	hb->add_child(duplicate_anim);
	duplicate_anim->set_tooltip("Duplicate Animation");

	rename_anim = memnew( ToolButton );
	hb->add_child(rename_anim);
	rename_anim->set_tooltip("Rename Animation");

	remove_anim = memnew( ToolButton );

	hb->add_child(remove_anim);
	remove_anim->set_tooltip("Remove Animation");


	animation = memnew( OptionButton );
	hb->add_child(animation);
	animation->set_h_size_flags(SIZE_EXPAND_FILL);
	animation->set_tooltip("Display list of animations in player.");

	autoplay = memnew( ToolButton );
	hb->add_child(autoplay);
	autoplay->set_tooltip("Autoplay On Load");



	blend_anim = memnew( ToolButton );
	hb->add_child(blend_anim);
	blend_anim->set_tooltip("Edit Target Blend Times");

	tool_anim = memnew( MenuButton);
	//tool_anim->set_flat(false);
	tool_anim->set_tooltip("Animation Tools");
	tool_anim->get_popup()->add_item("Copy Animation",TOOL_COPY_ANIM);
	tool_anim->get_popup()->add_item("Paste Animation",TOOL_PASTE_ANIM);
	//tool_anim->get_popup()->add_separator();
	//tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM);
	hb->add_child(tool_anim);


	edit_anim = memnew( ToolButton );
	edit_anim->set_toggle_mode(true);
	hb->add_child(edit_anim);
	edit_anim->set_tooltip("Open animation editor.\nProperty editor will displays all editable keys too.");


	hb = memnew (HBoxContainer);
	add_child(hb);

	play_bw_from = memnew( ToolButton );
	play_bw_from->set_tooltip("Play backwards selected animation from current pos. (A)");
	hb->add_child(play_bw_from);

	play_bw = memnew( ToolButton );
	play_bw->set_tooltip("Play backwards selected animation from end. (Shift+A)");
	hb->add_child(play_bw);

	stop = memnew( ToolButton );
	stop->set_toggle_mode(true);
	hb->add_child(stop);
	stop->set_tooltip("Stop animation playback. (S)");

	play = memnew( ToolButton );
	play->set_tooltip("Play selected animation from start. (Shift+D)");
	hb->add_child(play);


	play_from = memnew( ToolButton );
	play_from->set_tooltip("Play selected animation from current pos. (D)");
	hb->add_child(play_from);



	//pause = memnew( Button );
	//pause->set_toggle_mode(true);
	//hb->add_child(pause);

	seek = memnew( HSlider );
	seek->set_val(0);
	seek->set_step(0.01);
	hb->add_child(seek);
	seek->set_h_size_flags(SIZE_EXPAND_FILL);
	seek->set_stretch_ratio(8);
	seek->set_tooltip("Seek animation (when stopped).");

	frame = memnew( SpinBox );
	hb->add_child(frame);
	frame->set_h_size_flags(SIZE_EXPAND_FILL);
	frame->set_stretch_ratio(2);
	frame->set_tooltip("Animation position (in seconds).");
	seek->share(frame);



	scale = memnew( LineEdit );
	hb->add_child(scale);
	scale->set_h_size_flags(SIZE_EXPAND_FILL);
	scale->set_stretch_ratio(1);
	scale->set_tooltip("Scale animation playback globally for the node.");
	scale->hide();

	resource_edit_anim= memnew( Button );
	hb->add_child(resource_edit_anim);
	resource_edit_anim->hide();


	file = memnew(EditorFileDialog);
	add_child(file);

	name_dialog = memnew( ConfirmationDialog );
	name_dialog->set_title("Create New Animation");
	name_dialog->set_hide_on_ok(false);
	add_child(name_dialog);
	name = memnew( LineEdit );
	name_dialog->add_child(name);
	name->set_pos(Point2(18,30));
	name->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,10);
	name_dialog->register_text_enter(name);


	l = memnew( Label );
	l->set_text("Animation Name:");
	l->set_pos( Point2(10,10) );

	name_dialog->add_child(l);
	name_title=l;

	error_dialog = memnew( ConfirmationDialog );
	error_dialog->get_ok()->set_text("Close");
	//error_dialog->get_cancel()->set_text("Close");
	error_dialog->set_text("Error!");
	add_child(error_dialog);

	name_dialog->connect("confirmed", this,"_animation_name_edited");
	
	blend_editor.dialog = memnew( AcceptDialog );
	add_child(blend_editor.dialog);
	blend_editor.dialog->get_ok()->set_text("Close");
	blend_editor.dialog->set_hide_on_ok(true);
	VBoxContainer *blend_vb = memnew( VBoxContainer);
	blend_editor.dialog->add_child(blend_vb);
	blend_editor.dialog->set_child_rect(blend_vb);
	blend_editor.tree = memnew( Tree );
	blend_editor.tree->set_columns(2);
	blend_vb->add_margin_child("Blend Times: ",blend_editor.tree,true);
	blend_editor.next = memnew( LineEdit );
	blend_vb->add_margin_child("Next (Auto Queue):",blend_editor.next);
	blend_editor.dialog->set_title("Cross-Animation Blend Times");
	updating_blends=false;

	blend_editor.tree->connect("item_edited",this,"_blend_edited");
	

	autoplay->connect("pressed", this,"_autoplay_pressed");
	autoplay->set_toggle_mode(true);
	play->connect("pressed", this,"_play_pressed");
	play_from->connect("pressed", this,"_play_from_pressed");
	play_bw->connect("pressed", this,"_play_bw_pressed");
	play_bw_from->connect("pressed", this,"_play_bw_from_pressed");
	stop->connect("pressed", this,"_stop_pressed");
	//pause->connect("pressed", this,"_pause_pressed");
	add_anim->connect("pressed", this,"_animation_new");
	rename_anim->connect("pressed", this,"_animation_rename");
	load_anim->connect("pressed", this,"_animation_load");
	duplicate_anim->connect("pressed", this,"_animation_duplicate");
	//frame->connect("text_entered", this,"_seek_frame_changed");
	edit_anim->connect("pressed", this,"_animation_edit");
	blend_anim->connect("pressed", this,"_animation_blend");
	remove_anim->connect("pressed", this,"_animation_remove");
	animation->connect("item_selected", this,"_animation_selected",Vector<Variant>(),true);
	resource_edit_anim->connect("pressed", this,"_animation_resource_edit");
	file->connect("file_selected", this,"_dialog_action");
	 seek->connect("value_changed", this, "_seek_value_changed",Vector<Variant>(),true);
	 scale->connect("text_entered", this, "_scale_changed",Vector<Variant>(),true);
	 editor->get_animation_editor()->connect("timeline_changed",this,"_animation_key_editor_seek");
	 editor->get_animation_editor()->connect("animation_len_changed",this,"_animation_key_editor_anim_len_changed");

	 HBoxContainer *ahb = editor->get_animation_panel_hb();
	 nodename = memnew( Label );
	 ahb->add_child(nodename);
	 nodename->set_h_size_flags(SIZE_EXPAND_FILL);
	 nodename->set_opacity(0.5);
	 pin = memnew( TextureButton );
	 pin->set_toggle_mode(true);
	 ahb->add_child(pin);

	renaming=false;
	last_active=false;

	set_process_unhandled_key_input(true);
}