Пример #1
0
void EditorHelp::_help_callback(const String& p_topic) {

	String what = p_topic.get_slice(":",0);
	String clss = p_topic.get_slice(":",1);
	String name;
	if (p_topic.get_slice_count(":")==3)
		name=p_topic.get_slice(":",2);

	_request_help(clss); //first go to class

	int line=0;

	if (what=="class_desc") {
		line=description_line;
	} else if (what=="class_signal") {
		if (signal_line.has(name))
			line=signal_line[name];
	} else if (what=="class_method" || what=="class_method_desc") {
		if (method_line.has(name))
			line=method_line[name];
	} else if (what=="class_property") {

		if (property_line.has(name))
			line=property_line[name];
	} else if (what=="class_constant") {

		if (constant_line.has(name))
			line=constant_line[name];
	}

	class_desc->scroll_to_line(line);

}
bool ItemListPlugin::_set(const StringName &p_name, const Variant &p_value) {

	String name = p_name;
	int idx = name.get_slice("/", 0).to_int();
	String what = name.get_slice("/", 1);

	if (what == "text")
		set_item_text(idx, p_value);
	else if (what == "icon")
		set_item_icon(idx, p_value);
	else if (what == "checkable") {
		// This keeps compatibility to/from versions where this property was a boolean, before radio buttons
		switch ((int)p_value) {
			case 0:
			case 1:
				set_item_checkable(idx, p_value);
				break;
			case 2:
				set_item_radio_checkable(idx, true);
				break;
		}
	} else if (what == "checked")
		set_item_checked(idx, p_value);
	else if (what == "id")
		set_item_id(idx, p_value);
	else if (what == "enabled")
		set_item_enabled(idx, p_value);
	else if (what == "separator")
		set_item_separator(idx, p_value);
	else
		return false;

	return true;
}
Пример #3
0
Variant Shader::_get(const String& p_name) const {

	if (p_name.begins_with("nodes/")) {
		int idx=p_name.get_slice("/",1).to_int();
		Dictionary data;
		data["type"]=VisualServer::shader_node_get_type_info((VS::ShaderNodeType)node_get_type(idx)).name;
		data["pos"]=node_get_pos(idx);
		data["param"]=node_get_param(idx);
		return data;
	}
	if (p_name.begins_with("conns/")) {
		int idx=p_name.get_slice("/",1).to_int();
		Dictionary data;

		List<Connection> connections;
		get_connections(&connections);
		ERR_FAIL_INDEX_V( idx,connections.size(), Variant() );
		Connection c = connections[idx];

		data["src_id"]=c.src_id;
		data["src_slot"]=c.src_slot;
		data["dst_id"]=c.dst_id;
		data["dst_slot"]=c.dst_slot;
		return data;
	}

	return Variant();
}
bool ItemListPlugin::_get(const StringName &p_name, Variant &r_ret) const {

	String name = p_name;
	int idx = name.get_slice("/", 0).to_int();
	String what = name.get_slice("/", 1);

	if (what == "text")
		r_ret = get_item_text(idx);
	else if (what == "icon")
		r_ret = get_item_icon(idx);
	else if (what == "checkable") {
		// This keeps compatibility to/from versions where this property was a boolean, before radio buttons
		if (!is_item_checkable(idx)) {
			r_ret = 0;
		} else {
			r_ret = is_item_radio_checkable(idx) ? 2 : 1;
		}
	} else if (what == "checked")
		r_ret = is_item_checked(idx);
	else if (what == "id")
		r_ret = get_item_id(idx);
	else if (what == "enabled")
		r_ret = is_item_enabled(idx);
	else if (what == "separator")
		r_ret = is_item_separator(idx);
	else
		return false;

	return true;
}
Пример #5
0
void EditorHelp::_class_desc_select(const String& p_select) {



//	print_line("LINK: "+p_select);
	if (p_select.begins_with("#")) {
		//_goto_desc(p_select.substr(1,p_select.length()));
		emit_signal("go_to_help","class_name:"+p_select.substr(1,p_select.length()));
		return;
	} else if (p_select.begins_with("@")) {

		String m = p_select.substr(1,p_select.length());

		if (m.find(".")!=-1) {
			//must go somewhere else

			emit_signal("go_to_help","class_method:"+m.get_slice(".",0)+":"+m.get_slice(".",0));
		} else {

			if (!method_line.has(m))
				return;
			class_desc->scroll_to_line(method_line[m]);
		}

	}


}
Пример #6
0
bool ItemListPlugin::_set(const StringName& p_name, const Variant& p_value) {

	String name = p_name;
	int idx = name.get_slice("/",0).to_int();
	String what=name.get_slice("/",1);

	if (what=="text")
		set_item_text(idx,p_value);
	else if (what=="icon")
		set_item_icon(idx,p_value);
	else if (what=="checkable")
		set_item_checkable(idx,p_value);
	else if (what=="checked")
		set_item_checked(idx,p_value);
	else if (what=="enabled")
		set_item_enabled(idx,p_value);
	else if (what=="accel")
		set_item_accel(idx,p_value);
	else if (what=="id")
		set_item_id(idx,p_value);
	else if (what=="separator")
		set_item_separator(idx,p_value);
	else
		return false;

	return true;
}
bool ItemListPlugin::_get(const StringName& p_name,Variant &r_ret) const {

	String name = p_name;
	int idx = name.get_slice("/",0).to_int();
	String what=name.get_slice("/",1);

	if (what=="text")
		r_ret=get_item_text(idx);
	else if (what=="icon")
		r_ret=get_item_icon(idx);
	else if (what=="checkable")
		r_ret=is_item_checkable(idx);
	else if (what=="checked")
		r_ret=is_item_checked(idx);
	else if (what=="id")
		r_ret=get_item_id(idx);
	else if (what=="enabled")
		r_ret=is_item_enabled(idx);
	else if (what=="separator")
		r_ret=is_item_separator(idx);
	else
		return false;

	return true;
}
void ShaderEditor::_add_node_from_text(const String& p_text) {

	ERR_FAIL_COND( p_text.get_slice_count(" ") != 3 );
	bool input = p_text.get_slice(" ",0)=="In:";
	String name = p_text.get_slice(" ",1);
	bool vec = p_text.get_slice(" ",2)=="(vec3)";

	_node_add( input?
		( vec? VisualServer::NODE_VEC_IN : VisualServer::NODE_IN ) :
		( vec? VisualServer::NODE_VEC_OUT : VisualServer::NODE_OUT ) );

	shader_graph.node_set_param( last_id-1,name );
	_write_shader_graph();
}
Пример #9
0
void Shader::_set(const String& p_name, const Variant& p_value) {

	if (p_name.begins_with("nodes/")) {
		int idx=p_name.get_slice("/",1).to_int();
		Dictionary data=p_value;

		ERR_FAIL_COND(!data.has("type"));
		String type=data["type"];
		VS::ShaderNodeType node_type=VS::NODE_TYPE_MAX;
		for(int i=0;i<NODE_TYPE_MAX;i++) {

			if (type==VisualServer::shader_node_get_type_info((VS::ShaderNodeType)i).name)
				node_type=(VS::ShaderNodeType)i;
		}

		ERR_FAIL_COND(node_type==VS::NODE_TYPE_MAX);

		node_add( (NodeType)node_type, idx );
		if (data.has("param"))
			node_set_param(idx,data["param"]);
		if (data.has("pos"))
			node_set_pos(idx,data["pos"]);
	}

	if (p_name.begins_with("conns/")) {
		Dictionary data=p_value;
		ERR_FAIL_COND( !data.has("src_id") );
		ERR_FAIL_COND( !data.has("src_slot") );
		ERR_FAIL_COND( !data.has("dst_id") );
		ERR_FAIL_COND( !data.has("dst_slot") );

		connect(data["src_id"],data["src_slot"],data["dst_id"],data["dst_slot"]);
	}

}
Пример #10
0
void TileSetEditor::_menu_cbk(int p_option) {

	option=p_option;
	switch(p_option) {

		case MENU_OPTION_ADD_ITEM: {

			tileset->create_tile(tileset->get_last_unused_tile_id());
		} break;
		case MENU_OPTION_REMOVE_ITEM: {

			String p = editor->get_property_editor()->get_selected_path();
			if (p.begins_with("/TileSet") && p.get_slice_count("/")>=2) {

				to_erase = p.get_slice("/",2).to_int();
				cd->set_text("Remove Item "+itos(to_erase)+"?");
				cd->popup_centered(Size2(300,60));
			}
		} break;
		case MENU_OPTION_CREATE_FROM_SCENE: {

			cd->set_text("Create from scene?");
			cd->popup_centered(Size2(300,60));
		} break;
		 case MENU_OPTION_MERGE_FROM_SCENE: {

			 cd->set_text("Merge from scene?");
			 cd->popup_centered(Size2(300,60));
		 } break;
	}
}
void MeshLibraryEditor::_menu_cbk(int p_option) {

	option=p_option;
	switch(p_option) {

		case MENU_OPTION_ADD_ITEM: {

			theme->create_item(theme->get_last_unused_item_id());
		} break;
		case MENU_OPTION_REMOVE_ITEM: {

			String p = editor->get_property_editor()->get_selected_path();
			if (p.begins_with("/MeshLibrary/item") && p.get_slice_count("/")>=3) {

				to_erase = p.get_slice("/",3).to_int();
				cd->set_text("Remove Item "+itos(to_erase)+"?");
				cd->popup_centered(Size2(300,60));
			}
		} break;
		case MENU_OPTION_IMPORT_FROM_SCENE: {

			file->popup_centered_ratio();
		} break;
		 case MENU_OPTION_UPDATE_FROM_SCENE: {

			 cd->set_text("Update from existing scene?:\n"+String(theme->get_meta("_editor_source_scene")));
			 cd->popup_centered(Size2(500,60));
		 } break;
	}
}
Пример #12
0
bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_value) {
	String name = p_name;
	if (name.begins_with("platform/")) {
		set_library_path(name.get_slice("/", 1), p_value);
		return true;
	}
	return false;
}
Пример #13
0
bool GDNativeLibrary::_get(const StringName &p_name, Variant &r_ret) const {
	String name = p_name;
	if (name.begins_with("platform/")) {
		r_ret = get_library_path(name.get_slice("/", 1));
		return true;
	}
	return false;
}
Пример #14
0
bool Skeleton::_set(const StringName& p_path, const Variant& p_value) {

	String path = p_path;

	if (!path.begins_with("bones/"))
		return false;
		
	int which=path.get_slice("/",1).to_int();
	String what=path.get_slice("/",2);


	if (which==bones.size() && what=="name") {
	
		add_bone(p_value);
		return true;
	}
	
	ERR_FAIL_INDEX_V( which, bones.size(), false );
	
	if (what=="parent")
		set_bone_parent(which, p_value );
	else if (what=="rest")
		set_bone_rest(which, p_value);
	else if (what=="enabled")
		set_bone_enabled(which, p_value);
	else if (what=="pose")
		set_bone_pose(which, p_value);
	else if (what=="bound_childs") {
		Array children=p_value;
		
		bones[which].nodes_bound.clear();
		
		for (int i=0;i<children.size();i++) {
		
			NodePath path=children[i];
			ERR_CONTINUE( path.operator String()=="" );
			Node *node = get_node(path);
			ERR_CONTINUE(!node);
			bind_child_node_to_bone(which,node);
		}
	} else {
		return false;
	}

	return true;
}
Пример #15
0
void DependencyEditor::_update_list() {

	List<String> deps;
	ResourceLoader::get_dependencies(editing,&deps,true);

	tree->clear();
	missing.clear();

	TreeItem *root = tree->create_item();

	Ref<Texture> folder = get_icon("folder","FileDialog");

	bool broken=false;

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

		TreeItem *item = tree->create_item(root);

		String n = E->get();
		String path;
		String type;

		if (n.find("::")!=-1) {
			path = n.get_slice("::",0);
			type = n.get_slice("::",1);
		} else {
			path=n;
			type="Resource";
		}
		String name = path.get_file();

		Ref<Texture> icon;
		if (has_icon(type,TTR("EditorIcons"))) {
			icon=get_icon(type,"EditorIcons");
		} else {
			icon=get_icon("Object","EditorIcons");
		}
		item->set_text(0,name);
		item->set_icon(0,icon);
		item->set_metadata(0,type);
		item->set_text(1,path);

		if (!FileAccess::exists(path)) {
			item->set_custom_color(1,Color(1,0.4,0.3));
			missing.push_back(path);
			broken=true;
		}

		item->add_button(1,folder,0);
	}

	fixdeps->set_disabled(!broken);

}
Пример #16
0
bool test_24() {

	OS::get_singleton()->print("\n\nTest 24: Slicing\n");

	String s = "Mars,Jupiter,Saturn,Uranus";

	const char *slices[4] = { "Mars", "Jupiter", "Saturn", "Uranus" };

	OS::get_singleton()->print("\tSlicing \"%ls\" by \"%s\"..\n", s.c_str(), ",");

	for (int i = 0; i < s.get_slice_count(","); i++) {

		OS::get_singleton()->print("\t\t%i- %ls\n", i + 1, s.get_slice(",", i).c_str());

		if (s.get_slice(",", i) != slices[i])
			return false;
	}

	return true;
}
Пример #17
0
/*
Remove parameter bind from connection.
*/
void ConnectDialog::_remove_bind() {

	String st = bind_editor->get_selected_path();
	if (st == "")
		return;
	int idx = st.get_slice("/", 1).to_int() - 1;

	ERR_FAIL_INDEX(idx, cdbinds->params.size());
	cdbinds->params.remove(idx);
	cdbinds->notify_changed();
}
Пример #18
0
void ItemListEditor::_delete_pressed() {

	String p = prop_editor->get_selected_path();

	if (p.find("/")!=-1) {

		if (selected_idx<0 || selected_idx>=item_plugins.size())
			return;

		item_plugins[selected_idx]->erase(p.get_slice("/",0).to_int());;
	}

}
Пример #19
0
	bool _get(const StringName &p_name, Variant &r_ret) const {

		String name = p_name;

		if (name.begins_with("bind/")) {
			int which = name.get_slice("/", 1).to_int() - 1;
			ERR_FAIL_INDEX_V(which, params.size(), false);
			r_ret = params[which];
		} else
			return false;

		return true;
	}
Пример #20
0
	bool _set(const StringName &p_name, const Variant &p_value) {

		String name = p_name;

		if (name.begins_with("bind/")) {
			int which = name.get_slice("/", 1).to_int() - 1;
			ERR_FAIL_INDEX_V(which, params.size(), false);
			params.write[which] = p_value;
		} else
			return false;

		return true;
	}
Пример #21
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);

}
Пример #22
0
void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool p_give_internet) {


	const int CHUNK_AXML_FILE = 0x00080003;
	const int CHUNK_RESOURCEIDS = 0x00080180;
	const int CHUNK_STRINGS = 0x001C0001;
	const int CHUNK_XML_END_NAMESPACE = 0x00100101;
	const int CHUNK_XML_END_TAG = 0x00100103;
	const int CHUNK_XML_START_NAMESPACE = 0x00100100;
	const int CHUNK_XML_START_TAG = 0x00100102;
	const int CHUNK_XML_TEXT = 0x00100104;
	const int UTF8_FLAG = 0x00000100;

	Vector<String> string_table;

	uint32_t ofs=0;


	uint32_t header = decode_uint32(&p_manifest[ofs]);
	uint32_t filesize = decode_uint32(&p_manifest[ofs+4]);
	ofs+=8;

//	print_line("FILESIZE: "+itos(filesize)+" ACTUAL: "+itos(p_manifest.size()));

	uint32_t string_count;
	uint32_t styles_count;
	uint32_t string_flags;
	uint32_t string_data_offset;

	uint32_t styles_offset;
	uint32_t string_table_begins;
	uint32_t string_table_ends;
	Vector<uint8_t> stable_extra;

	while(ofs < p_manifest.size()) {

		uint32_t chunk = decode_uint32(&p_manifest[ofs]);
		uint32_t size = decode_uint32(&p_manifest[ofs+4]);


		switch(chunk) {

			case CHUNK_STRINGS: {


				int iofs=ofs+8;

				string_count=decode_uint32(&p_manifest[iofs]);
				styles_count=decode_uint32(&p_manifest[iofs+4]);
				uint32_t string_flags=decode_uint32(&p_manifest[iofs+8]);
				string_data_offset=decode_uint32(&p_manifest[iofs+12]);
				styles_offset=decode_uint32(&p_manifest[iofs+16]);
/*
				printf("string count: %i\n",string_count);
				printf("flags: %i\n",string_flags);
				printf("sdata ofs: %i\n",string_data_offset);
				printf("styles ofs: %i\n",styles_offset);
*/
				uint32_t st_offset=iofs+20;
				string_table.resize(string_count);
				uint32_t string_end=0;

				string_table_begins=st_offset;


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

					uint32_t string_at = decode_uint32(&p_manifest[st_offset+i*4]);
					string_at+=st_offset+string_count*4;

					ERR_EXPLAIN("Unimplemented, can't read utf8 string table.");
					ERR_FAIL_COND(string_flags&UTF8_FLAG);

					if (string_flags&UTF8_FLAG) {



					} else {
						uint32_t len = decode_uint16(&p_manifest[string_at]);
						Vector<CharType> ucstring;
						ucstring.resize(len+1);
						for(int j=0;j<len;j++) {
							uint16_t c=decode_uint16(&p_manifest[string_at+2+2*j]);
							ucstring[j]=c;
						}
						string_end=MAX(string_at+2+2*len,string_end);
						ucstring[len]=0;
						string_table[i]=ucstring.ptr();
					}


//					print_line("String "+itos(i)+": "+string_table[i]);
				}

				for(int i=string_end;i<(ofs+size);i++) {
					stable_extra.push_back(p_manifest[i]);
				}

//				printf("stable extra: %i\n",int(stable_extra.size()));
				string_table_ends=ofs+size;

//				print_line("STABLE SIZE: "+itos(size)+" ACTUAL: "+itos(string_table_ends));

			} break;
			case CHUNK_XML_START_TAG: {

				int iofs=ofs+8;
				uint32_t line=decode_uint32(&p_manifest[iofs]);
				uint32_t nspace=decode_uint32(&p_manifest[iofs+8]);
				uint32_t name=decode_uint32(&p_manifest[iofs+12]);
				uint32_t check=decode_uint32(&p_manifest[iofs+16]);

				String tname=string_table[name];

//				printf("NSPACE: %i\n",nspace);
				//printf("NAME: %i (%s)\n",name,tname.utf8().get_data());
				//printf("CHECK: %x\n",check);
				uint32_t attrcount=decode_uint32(&p_manifest[iofs+20]);
				iofs+=28;
				//printf("ATTRCOUNT: %x\n",attrcount);
				for(int i=0;i<attrcount;i++) {
					uint32_t attr_nspace=decode_uint32(&p_manifest[iofs]);
					uint32_t attr_name=decode_uint32(&p_manifest[iofs+4]);
					uint32_t attr_value=decode_uint32(&p_manifest[iofs+8]);
					uint32_t attr_flags=decode_uint32(&p_manifest[iofs+12]);
					uint32_t attr_resid=decode_uint32(&p_manifest[iofs+16]);


					String value;
					if (attr_value!=0xFFFFFFFF)
						value=string_table[attr_value];
					else
						value="Res #"+itos(attr_resid);
					String attrname = string_table[attr_name];
					String nspace;
					if (attr_nspace!=0xFFFFFFFF)
						nspace=string_table[attr_nspace];
					else
						nspace="";

					printf("ATTR %i NSPACE: %i\n",i,attr_nspace);
					printf("ATTR %i NAME: %i (%s)\n",i,attr_name,attrname.utf8().get_data());
					printf("ATTR %i VALUE: %i (%s)\n",i,attr_value,value.utf8().get_data());
					printf("ATTR %i FLAGS: %x\n",i,attr_flags);
					printf("ATTR %i RESID: %x\n",i,attr_resid);

					//replace project information
					if (tname=="manifest" && attrname=="package") {

						print_line("FOUND PACKAGE");
						string_table[attr_value]=get_package_name();
					}

					//print_line("tname: "+tname);
					//print_line("nspace: "+nspace);
					//print_line("attrname: "+attrname);
					if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionCode") {

						print_line("FOUND versioncode");
						encode_uint32(version_code,&p_manifest[iofs+16]);
					}


					if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionName") {

						print_line("FOUND versionname");
						if (attr_value==0xFFFFFFFF) {
							WARN_PRINT("Version name in a resource, should be plaintext")
						} else
							string_table[attr_value]=version_name;
					}

					if (tname=="activity" && /*nspace=="android" &&*/ attrname=="screenOrientation") {

						encode_uint32(orientation==0?0:1,&p_manifest[iofs+16]);
						/*
						print_line("FOUND screen orientation");
						if (attr_value==0xFFFFFFFF) {
							WARN_PRINT("Version name in a resource, should be plaintext")
						} else {
							string_table[attr_value]=(orientation==0?"landscape":"portrait");
						}*/
					}

					if (tname=="uses-permission" && /*nspace=="android" &&*/ attrname=="name") {

						if (value.begins_with("godot.custom")) {

							int which = value.get_slice(".",2).to_int();
							if (which>=0 && which<MAX_USER_PERMISSIONS && user_perms[which].strip_edges()!="") {

								string_table[attr_value]=user_perms[which].strip_edges();
							}

						} else if (value.begins_with("godot.")) {
							String perm = value.get_slice(".",1);
							print_line("PERM: "+perm+" HAS: "+itos(perms.has(perm)));

							if (perms.has(perm) || (p_give_internet && perm=="INTERNET")) {

								string_table[attr_value]="android.permission."+perm;
							}

						}
					}

					if (tname=="supports-screens" ) {

						if (attrname=="smallScreens") {

							encode_uint32(screen_support[SCREEN_SMALL]?0xFFFFFFFF:0,&p_manifest[iofs+16]);

						} else if (attrname=="normalScreens") {

							encode_uint32(screen_support[SCREEN_NORMAL]?0xFFFFFFFF:0,&p_manifest[iofs+16]);

						} else if (attrname=="largeScreens") {

							encode_uint32(screen_support[SCREEN_LARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]);

						} else if (attrname=="xlargeScreens") {

							encode_uint32(screen_support[SCREEN_XLARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]);

						}
					}


					iofs+=20;
				}

			} break;
		}
		printf("chunk %x: size: %d\n",chunk,size);

		ofs+=size;
	}
Пример #23
0
ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){



	ppeer = Ref<PacketPeerStream>( memnew( PacketPeerStream ) );
	editor=p_editor;

	tabs = memnew( TabContainer );
	tabs->set_v_size_flags(SIZE_EXPAND_FILL);
	tabs->set_area_as_parent_rect();
	add_child(tabs);


	{ //debugger
		VBoxContainer *vbc = memnew( VBoxContainer );
		vbc->set_name(TTR("Debugger"));
		//tabs->add_child(vbc);
		Control *dbg=vbc;

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


		reason = memnew( LineEdit );
		reason->set_text("");
		reason->set_editable(false);
		hbc->add_child(reason);
		reason->add_color_override("font_color",Color(1,0.4,0.0,0.8));
		reason->set_h_size_flags(SIZE_EXPAND_FILL);
		//reason->set_clip_text(true);

		hbc->add_child( memnew( VSeparator) );

		step = memnew( Button );
		hbc->add_child(step);
		step->set_tooltip(TTR("Step Into"));
		step->connect("pressed",this,"debug_step");

		next = memnew( Button );
		hbc->add_child(next);
		next->set_tooltip(TTR("Step Over"));
		next->connect("pressed",this,"debug_next");

		hbc->add_child( memnew( VSeparator) );

		dobreak = memnew( Button );
		hbc->add_child(dobreak);
		dobreak->set_tooltip(TTR("Break"));
		dobreak->connect("pressed",this,"debug_break");

		docontinue = memnew( Button );
		hbc->add_child(docontinue);
		docontinue->set_tooltip(TTR("Continue"));
		docontinue->connect("pressed",this,"debug_continue");

		//hbc->add_child( memnew( VSeparator) );

		back = memnew( Button );
		hbc->add_child(back);
		back->set_tooltip(TTR("Inspect Previous Instance"));
		back->hide();

		forward = memnew( Button );
		hbc->add_child(forward);
		forward->set_tooltip(TTR("Inspect Next Instance"));
		forward->hide();


		HSplitContainer *sc = memnew( HSplitContainer );
		vbc->add_child(sc);
		sc->set_v_size_flags(SIZE_EXPAND_FILL);

		stack_dump = memnew( Tree );
		stack_dump->set_columns(1);
		stack_dump->set_column_titles_visible(true);
		stack_dump->set_column_title(0,TTR("Stack Frames"));
		stack_dump->set_h_size_flags(SIZE_EXPAND_FILL);
		stack_dump->set_hide_root(true);
		stack_dump->connect("cell_selected",this,"_stack_dump_frame_selected");
		sc->add_child(stack_dump);

		inspector = memnew( PropertyEditor );
		inspector->set_h_size_flags(SIZE_EXPAND_FILL);
		inspector->hide_top_label();
		inspector->get_scene_tree()->set_column_title(0,TTR("Variable"));
		inspector->set_capitalize_paths(false);
		inspector->set_read_only(true);
		sc->add_child(inspector);

		server = TCP_Server::create_ref();

		pending_in_queue=0;

		variables = memnew( ScriptEditorDebuggerVariables );

		breaked=false;

		tabs->add_child(dbg);
		//tabs->move_child(vbc,0);

		hbc = memnew( HBoxContainer );
		vbc->add_child(hbc);

	}

	{  //errors


		error_split = memnew( HSplitContainer );
		VBoxContainer *errvb = memnew( VBoxContainer );
		errvb->set_h_size_flags(SIZE_EXPAND_FILL);
		error_list = memnew( ItemList );
		errvb->add_margin_child(TTR("Errors:"),error_list,true);
		error_split->add_child(errvb);

		errvb = memnew( VBoxContainer );
		errvb->set_h_size_flags(SIZE_EXPAND_FILL);
		error_stack = memnew( ItemList );
		errvb->add_margin_child(TTR("Stack Trace (if applicable):"),error_stack,true);
		error_split->add_child(errvb);

		error_split->set_name(TTR("Errors"));
		tabs->add_child(error_split);
	}


	{ // inquire


		inspect_info = memnew( HSplitContainer );
		inspect_info->set_name(TTR("Remote Inspector"));
		tabs->add_child(inspect_info);

		VBoxContainer *info_left = memnew(VBoxContainer);
		info_left->set_h_size_flags(SIZE_EXPAND_FILL);
		inspect_info->add_child(info_left);

		inspect_scene_tree = memnew( Tree );
		info_left->add_margin_child(TTR("Live Scene Tree:"),inspect_scene_tree,true);
		inspect_scene_tree->connect("cell_selected",this,"_scene_tree_selected");
		inspect_scene_tree->connect("item_collapsed",this,"_scene_tree_folded");

		//

		VBoxContainer *info_right = memnew(VBoxContainer);
		info_right->set_h_size_flags(SIZE_EXPAND_FILL);
		inspect_info->add_child(info_right);

		inspect_properties = memnew( PropertyEditor );
		inspect_properties->hide_top_label();
		inspect_properties->set_show_categories(true);
		inspect_properties->connect("object_id_selected",this,"_scene_tree_property_select_object");

		info_right->add_margin_child(TTR("Remote Object Properties: "),inspect_properties,true);

		inspect_scene_tree_timeout=EDITOR_DEF("debugger/scene_tree_refresh_interval",1.0);
		inspect_edited_object_timeout=EDITOR_DEF("debugger/remote_inspect_refresh_interval",0.2);
		inspected_object_id=0;
		updating_scene_tree=false;

		inspected_object = memnew( ScriptEditorDebuggerInspectedObject );
		inspected_object->connect("value_edited",this,"_scene_tree_property_value_edited");
	}

	{ //profiler
		profiler = memnew( EditorProfiler );
		profiler->set_name(TTR("Profiler"));
		tabs->add_child(profiler);
		profiler->connect("enable_profiling",this,"_profiler_activate");
		profiler->connect("break_request",this,"_profiler_seeked");
	}


	{ //monitors

		HSplitContainer *hsp = memnew( HSplitContainer );

		perf_monitors = memnew(Tree);
		perf_monitors->set_columns(2);
		perf_monitors->set_column_title(0,TTR("Monitor"));
		perf_monitors->set_column_title(1,TTR("Value"));
		perf_monitors->set_column_titles_visible(true);
		hsp->add_child(perf_monitors);
		perf_monitors->set_select_mode(Tree::SELECT_MULTI);
		perf_monitors->connect("multi_selected",this,"_performance_select");
		perf_draw = memnew( Control );
		perf_draw->connect("draw",this,"_performance_draw");
		hsp->add_child(perf_draw);
		hsp->set_name(TTR("Monitors"));
		hsp->set_split_offset(300);
		tabs->add_child(hsp);
		perf_max.resize(Performance::MONITOR_MAX);

		Map<String,TreeItem*> bases;
		TreeItem *root=perf_monitors->create_item();
		perf_monitors->set_hide_root(true);
		for(int i=0;i<Performance::MONITOR_MAX;i++) {

			String n = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i));
			String base = n.get_slice("/",0);
			String name = n.get_slice("/",1);
			if (!bases.has(base)) {
				TreeItem *b = perf_monitors->create_item(root);
				b->set_text(0,base.capitalize());
				b->set_editable(0,false);
				b->set_selectable(0,false);
				bases[base]=b;
			}

			TreeItem *it = perf_monitors->create_item(bases[base]);
			it->set_editable(0,false);
			it->set_selectable(0,true);
			it->set_text(0,name.capitalize());
			perf_items.push_back(it);
			perf_max[i]=0;

		}
	}

	{ //vmem inspect
		VBoxContainer *vmem_vb = memnew( VBoxContainer );
		HBoxContainer *vmem_hb = memnew( HBoxContainer );
		Label *vmlb = memnew(Label(TTR("List of Video Memory Usage by Resource:")+" ") );
		vmlb->set_h_size_flags(SIZE_EXPAND_FILL);
		vmem_hb->add_child( vmlb );
		vmem_hb->add_child( memnew(Label(TTR("Total:")+" ")) );
		vmem_total = memnew( LineEdit );
		vmem_total->set_editable(false);
		vmem_total->set_custom_minimum_size(Size2(100,1)*EDSCALE);
		vmem_hb->add_child(vmem_total);
		vmem_refresh = memnew( Button );
		vmem_hb->add_child(vmem_refresh);
		vmem_vb->add_child(vmem_hb);
		vmem_refresh->connect("pressed",this,"_video_mem_request");

		MarginContainer *vmmc = memnew( MarginContainer );
		vmem_tree = memnew( Tree );
		vmem_tree->set_v_size_flags(SIZE_EXPAND_FILL);
		vmem_tree->set_h_size_flags(SIZE_EXPAND_FILL);
		vmmc->add_child(vmem_tree);
		vmmc->set_v_size_flags(SIZE_EXPAND_FILL);
		vmem_vb->add_child(vmmc);

		vmem_vb->set_name(TTR("Video Mem"));
		vmem_tree->set_columns(4);
		vmem_tree->set_column_titles_visible(true);
		vmem_tree->set_column_title(0,TTR("Resource Path"));
		vmem_tree->set_column_expand(0,true);
		vmem_tree->set_column_expand(1,false);
		vmem_tree->set_column_title(1,TTR("Type"));
		vmem_tree->set_column_min_width(1,100);
		vmem_tree->set_column_expand(2,false);
		vmem_tree->set_column_title(2,TTR("Format"));
		vmem_tree->set_column_min_width(2,150);
		vmem_tree->set_column_expand(3,false);
		vmem_tree->set_column_title(3,TTR("Usage"));
		vmem_tree->set_column_min_width(3,80);
		vmem_tree->set_hide_root(true);

		tabs->add_child(vmem_vb);
	}

	{ // misc
		VBoxContainer *info_left = memnew( VBoxContainer );
		info_left->set_h_size_flags(SIZE_EXPAND_FILL);
		info_left->set_name(TTR("Misc"));
		tabs->add_child(info_left);
		clicked_ctrl = memnew( LineEdit );
		info_left->add_margin_child(TTR("Clicked Control:"),clicked_ctrl);
		clicked_ctrl_type = memnew( LineEdit );
		info_left->add_margin_child(TTR("Clicked Control Type:"),clicked_ctrl_type);

		live_edit_root = memnew( LineEdit );

		{
			HBoxContainer *lehb = memnew( HBoxContainer );
			Label *l = memnew( Label(TTR("Live Edit Root:")) );
			lehb->add_child(l);
			l->set_h_size_flags(SIZE_EXPAND_FILL);
			le_set = memnew( Button(TTR("Set From Tree")) );
			lehb->add_child(le_set);
			le_clear = memnew( Button(TTR("Clear")) );
			lehb->add_child(le_clear);
			info_left->add_child(lehb);
			MarginContainer *mc = memnew( MarginContainer );
			mc->add_child(live_edit_root);
			info_left->add_child(mc);
			le_set->set_disabled(true);
			le_clear->set_disabled(true);
		}

	}



	msgdialog = memnew( AcceptDialog );
	add_child(msgdialog);

	log_forced_visible=false;

	p_editor->get_undo_redo()->set_method_notify_callback(_method_changeds,this);
	p_editor->get_undo_redo()->set_property_notify_callback(_property_changeds,this);
	live_debug=false;
	last_path_id=false;
	error_count=0;
	hide_on_stop=true;
	last_error_count=0;

	EditorNode::get_singleton()->get_pause_button()->connect("pressed",this,"_paused");


}
Пример #24
0
Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func) {
	//figure out paths of files that will be exported
	Set<String> paths;
	Vector<String> path_remaps;

	if (p_preset->get_export_filter() == EditorExportPreset::EXPORT_ALL_RESOURCES) {
		//find stuff
		_export_find_resources(EditorFileSystem::get_singleton()->get_filesystem(), paths);
	} else {
		bool scenes_only = p_preset->get_export_filter() == EditorExportPreset::EXPORT_SELECTED_SCENES;

		Vector<String> files = p_preset->get_files_to_export();
		for (int i = 0; i < files.size(); i++) {
			if (scenes_only && ResourceLoader::get_resource_type(files[i]) != "PackedScene")
				continue;

			_export_find_dependencies(files[i], paths);
		}
	}

	_edit_filter_list(paths, p_preset->get_include_filter(), false);
	_edit_filter_list(paths, p_preset->get_exclude_filter(), true);

	Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
	for (int i = 0; i < export_plugins.size(); i++) {

		export_plugins.write[i]->set_export_preset(p_preset);

		if (p_so_func) {
			for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) {
				p_so_func(p_udata, export_plugins[i]->shared_objects[j]);
			}
		}
		for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) {
			p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, 0, paths.size());
		}

		export_plugins.write[i]->_clear();
	}

	FeatureContainers feature_containers = get_feature_containers(p_preset);
	Set<String> &features = feature_containers.features;
	PoolVector<String> &features_pv = feature_containers.features_pv;

	//store everything in the export medium
	int idx = 0;
	int total = paths.size();

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

		String path = E->get();
		String type = ResourceLoader::get_resource_type(path);

		if (FileAccess::exists(path + ".import")) {
			//file is imported, replace by what it imports
			Ref<ConfigFile> config;
			config.instance();
			Error err = config->load(path + ".import");
			if (err != OK) {
				ERR_PRINTS("Could not parse: '" + path + "', not exported.");
				continue;
			}

			List<String> remaps;
			config->get_section_keys("remap", &remaps);

			Set<String> remap_features;

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

				String remap = F->get();
				String feature = remap.get_slice(".", 1);
				if (features.has(feature)) {
					remap_features.insert(feature);
				}
			}

			if (remap_features.size() > 1) {
				this->resolve_platform_feature_priorities(p_preset, remap_features);
			}

			err = OK;

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

				String remap = F->get();
				if (remap == "path") {
					String remapped_path = config->get_value("remap", remap);
					Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path);
					err = p_func(p_udata, remapped_path, array, idx, total);
				} else if (remap.begins_with("path.")) {
					String feature = remap.get_slice(".", 1);

					if (remap_features.has(feature)) {
						String remapped_path = config->get_value("remap", remap);
						Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path);
						err = p_func(p_udata, remapped_path, array, idx, total);
					}
				}
			}

			if (err != OK) {
				return err;
			}

			//also save the .import file
			Vector<uint8_t> array = FileAccess::get_file_as_array(path + ".import");
			err = p_func(p_udata, path + ".import", array, idx, total);

			if (err != OK) {
				return err;
			}

		} else {

			bool do_export = true;
			for (int i = 0; i < export_plugins.size(); i++) {
				if (export_plugins[i]->get_script_instance()) { //script based
					export_plugins.write[i]->_export_file_script(path, type, features_pv);
				} else {
					export_plugins.write[i]->_export_file(path, type, features);
				}
				if (p_so_func) {
					for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) {
						p_so_func(p_udata, export_plugins[i]->shared_objects[j]);
					}
				}

				for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) {
					p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, idx, total);
					if (export_plugins[i]->extra_files[j].remap) {
						do_export = false; //if remap, do not
						path_remaps.push_back(path);
						path_remaps.push_back(export_plugins[i]->extra_files[j].path);
					}
				}

				if (export_plugins[i]->skipped) {
					do_export = false;
				}
				export_plugins.write[i]->_clear();

				if (!do_export)
					break; //apologies, not exporting
			}
			//just store it as it comes
			if (do_export) {
				Vector<uint8_t> array = FileAccess::get_file_as_array(path);
				p_func(p_udata, path, array, idx, total);
			}
		}

		idx++;
	}

	//save config!

	Vector<String> custom_list;

	if (p_preset->get_custom_features() != String()) {

		Vector<String> tmp_custom_list = p_preset->get_custom_features().split(",");

		for (int i = 0; i < tmp_custom_list.size(); i++) {
			String f = tmp_custom_list[i].strip_edges();
			if (f != String()) {
				custom_list.push_back(f);
			}
		}
	}

	ProjectSettings::CustomMap custom_map;
	if (path_remaps.size()) {
		if (1) { //new remap mode, use always as it's friendlier with multiple .pck exports
			for (int i = 0; i < path_remaps.size(); i += 2) {
				String from = path_remaps[i];
				String to = path_remaps[i + 1];
				String remap_file = "[remap]\n\npath=\"" + to.c_escape() + "\"\n";
				CharString utf8 = remap_file.utf8();
				Vector<uint8_t> new_file;
				new_file.resize(utf8.length());
				for (int j = 0; j < utf8.length(); j++) {
					new_file.write[j] = utf8[j];
				}

				p_func(p_udata, from + ".remap", new_file, idx, total);
			}
		} else {
			//old remap mode, will still work, but it's unused because it's not multiple pck export friendly
			custom_map["path_remap/remapped_paths"] = path_remaps;
		}
	}

	// Store icon and splash images directly, they need to bypass the import system and be loaded as images
	String icon = ProjectSettings::get_singleton()->get("application/config/icon");
	String splash = ProjectSettings::get_singleton()->get("application/boot_splash/image");
	if (icon != String() && FileAccess::exists(icon)) {
		Vector<uint8_t> array = FileAccess::get_file_as_array(icon);
		p_func(p_udata, icon, array, idx, total);
	}
	if (splash != String() && FileAccess::exists(splash) && icon != splash) {
		Vector<uint8_t> array = FileAccess::get_file_as_array(splash);
		p_func(p_udata, splash, array, idx, total);
	}

	String config_file = "project.binary";
	String engine_cfb = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp" + config_file);
	ProjectSettings::get_singleton()->save_custom(engine_cfb, custom_map, custom_list);
	Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb);

	p_func(p_udata, "res://" + config_file, data, idx, total);

	return OK;
}
Пример #25
0
void FileDialog::update_file_list() {

	tree->clear();
	dir_access->list_dir_begin();

	TreeItem *root = tree->create_item();
	Ref<Texture> folder = get_icon("folder");
	List<String> files;
	List<String> dirs;

	bool isdir;
	bool ishidden;
	bool show_hidden = show_hidden_files;
	String item;

	while ((item = dir_access->get_next(&isdir)) != "") {

		if (item == "." || item == "..")
			continue;

		ishidden = dir_access->current_is_hidden();

		if (show_hidden || !ishidden) {
			if (!isdir)
				files.push_back(item);
			else
				dirs.push_back(item);
		}
	}

	dirs.sort_custom<NaturalNoCaseComparator>();
	files.sort_custom<NaturalNoCaseComparator>();

	while (!dirs.empty()) {
		String &dir_name = dirs.front()->get();
		TreeItem *ti = tree->create_item(root);
		ti->set_text(0, dir_name);
		ti->set_icon(0, folder);

		Dictionary d;
		d["name"] = dir_name;
		d["dir"] = true;

		ti->set_metadata(0, d);

		dirs.pop_front();
	}

	dirs.clear();

	List<String> patterns;
	// build filter
	if (filter->get_selected() == filter->get_item_count() - 1) {

		// match all
	} else if (filters.size() > 1 && filter->get_selected() == 0) {
		// match all filters
		for (int i = 0; i < filters.size(); i++) {

			String f = filters[i].get_slice(";", 0);
			for (int j = 0; j < f.get_slice_count(","); j++) {

				patterns.push_back(f.get_slice(",", j).strip_edges());
			}
		}
	} else {
		int idx = filter->get_selected();
		if (filters.size() > 1)
			idx--;

		if (idx >= 0 && idx < filters.size()) {

			String f = filters[idx].get_slice(";", 0);
			for (int j = 0; j < f.get_slice_count(","); j++) {

				patterns.push_back(f.get_slice(",", j).strip_edges());
			}
		}
	}

	String base_dir = dir_access->get_current_dir();

	while (!files.empty()) {

		bool match = patterns.empty();
		String match_str;

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

			if (files.front()->get().matchn(E->get())) {
				match_str = E->get();
				match = true;
				break;
			}
		}

		if (match) {
			TreeItem *ti = tree->create_item(root);
			ti->set_text(0, files.front()->get());

			if (get_icon_func) {

				Ref<Texture> icon = get_icon_func(base_dir.plus_file(files.front()->get()));
				ti->set_icon(0, icon);
			}

			if (mode == MODE_OPEN_DIR) {
				ti->set_custom_color(0, get_color("files_disabled"));
				ti->set_selectable(0, false);
			}
			Dictionary d;
			d["name"] = files.front()->get();
			d["dir"] = false;
			ti->set_metadata(0, d);

			if (file->get_text() == files.front()->get() || match_str == files.front()->get())
				ti->select(0);
		}

		files.pop_front();
	}

	if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected() == NULL)
		tree->get_root()->get_children()->select(0);

	files.clear();
}
Пример #26
0
void FileDialog::_action_pressed() {

	if (mode == MODE_OPEN_FILES) {

		TreeItem *ti = tree->get_next_selected(NULL);
		String fbase = dir_access->get_current_dir();

		PoolVector<String> files;
		while (ti) {

			files.push_back(fbase.plus_file(ti->get_text(0)));
			ti = tree->get_next_selected(ti);
		}

		if (files.size()) {
			emit_signal("files_selected", files);
			hide();
		}

		return;
	}

	String f = dir_access->get_current_dir().plus_file(file->get_text());

	if ((mode == MODE_OPEN_ANY || mode == MODE_OPEN_FILE) && dir_access->file_exists(f)) {
		emit_signal("file_selected", f);
		hide();
	} else if (mode == MODE_OPEN_ANY || mode == MODE_OPEN_DIR) {

		String path = dir_access->get_current_dir();

		path = path.replace("\\", "/");
		TreeItem *item = tree->get_selected();
		if (item) {
			Dictionary d = item->get_metadata(0);
			if (d["dir"] && d["name"] != "..") {
				path = path.plus_file(d["name"]);
			}
		}

		emit_signal("dir_selected", path);
		hide();
	}

	if (mode == MODE_SAVE_FILE) {

		bool valid = false;

		if (filter->get_selected() == filter->get_item_count() - 1) {
			valid = true; // match none
		} else if (filters.size() > 1 && filter->get_selected() == 0) {
			// match all filters
			for (int i = 0; i < filters.size(); i++) {

				String flt = filters[i].get_slice(";", 0);
				for (int j = 0; j < flt.get_slice_count(","); j++) {

					String str = flt.get_slice(",", j).strip_edges();
					if (f.match(str)) {
						valid = true;
						break;
					}
				}
				if (valid)
					break;
			}
		} else {
			int idx = filter->get_selected();
			if (filters.size() > 1)
				idx--;
			if (idx >= 0 && idx < filters.size()) {

				String flt = filters[idx].get_slice(";", 0);
				int filterSliceCount = flt.get_slice_count(",");
				for (int j = 0; j < filterSliceCount; j++) {

					String str = (flt.get_slice(",", j).strip_edges());
					if (f.match(str)) {
						valid = true;
						break;
					}
				}

				if (!valid && filterSliceCount > 0) {
					String str = (flt.get_slice(",", 0).strip_edges());
					f += str.substr(1, str.length() - 1);
					file->set_text(f.get_file());
					valid = true;
				}
			} else {
				valid = true;
			}
		}

		if (!valid) {

			exterr->popup_centered_minsize(Size2(250, 80));
			return;
		}

		if (dir_access->file_exists(f)) {
			confirm_save->set_text(RTR("File Exists, Overwrite?"));
			confirm_save->popup_centered(Size2(200, 80));
		} else {

			emit_signal("file_selected", f);
			hide();
		}
	}
}
Пример #27
0
String VisualScriptInputFilter::get_output_sequence_port_text(int p_port) const {

	String text;

	switch(filters[p_port].type) {
		case InputEvent::NONE: {
			text="None";
		} break;
		case InputEvent::KEY: {

			InputEventKey k = filters[p_port].key;

			if (k.scancode==0 && k.unicode==0) {
				text="No Key";
			} else {
				if (k.scancode!=0) {
					text="KeyCode: "+keycode_get_string(k.scancode);
				} else if (k.unicode!=0) {
					text="Uniode: "+String::chr(k.unicode);
				}

				if (k.pressed)
					text+=", Pressed";
				else
					text+=", Released";

				if (k.echo)
					text+=", Echo";
				if (k.mod.alt)
					text="Alt+"+text;
				if (k.mod.shift)
					text="Shift+"+text;
				if (k.mod.control)
					text="Ctrl+"+text;
				if (k.mod.meta)
					text="Meta+"+text;
			}

		} break;
		case InputEvent::MOUSE_MOTION: {
			InputEventMouseMotion mm = filters[p_port].mouse_motion;
			text="Mouse Motion";

			String b = "Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight";

			for(int i=0;i<7;i++) {
				if (mm.button_mask&(1<<i)) {
					text=b.get_slice(",",i)+"+"+text;
				}
			}
			if (mm.mod.alt)
				text="Alt+"+text;
			if (mm.mod.shift)
				text="Shift+"+text;
			if (mm.mod.control)
				text="Ctrl+"+text;
			if (mm.mod.meta)
				text="Meta+"+text;
		} break;
		case InputEvent::MOUSE_BUTTON: {

			InputEventMouseButton mb = filters[p_port].mouse_button;

			String b = "Any,Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight";

			text=b.get_slice(",",mb.button_index)+" Mouse Button";

			if (mb.pressed)
				text+=", Pressed";
			else
				text+=", Released";

			if (mb.doubleclick)
				text+=", DblClick";
			if (mb.mod.alt)
				text="Alt+"+text;
			if (mb.mod.shift)
				text="Shift+"+text;
			if (mb.mod.control)
				text="Ctrl+"+text;
			if (mb.mod.meta)
				text="Meta+"+text;


		} break;
		case InputEvent::JOYSTICK_MOTION: {

			InputEventJoystickMotion jm = filters[p_port].joy_motion;

			text="JoyMotion Axis "+itos(jm.axis>>1);
			if (jm.axis&1)
				text+=" > "+rtos(jm.axis_value);
			else
				text+=" < "+rtos(-jm.axis_value);

		} break;
		case InputEvent::JOYSTICK_BUTTON: {
			InputEventJoystickButton jb = filters[p_port].joy_button;

			text="JoyButton "+itos(jb.button_index);
			if (jb.pressed)
				text+=", Pressed";
			else
				text+=", Released";
		} break;
		case InputEvent::SCREEN_TOUCH: {
			InputEventScreenTouch sd = filters[p_port].screen_touch;

			text="Touch Finger "+itos(sd.index);
			if (sd.pressed)
				text+=", Pressed";
			else
				text+=", Released";
		} break;
		case InputEvent::SCREEN_DRAG: {
			InputEventScreenDrag sd = filters[p_port].screen_drag;
			text="Drag Finger "+itos(sd.index);
		} break;
		case InputEvent::ACTION: {


			List<PropertyInfo> pinfo;
			Globals::get_singleton()->get_property_list(&pinfo);
			int index=1;

			text="No Action";
			for(List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
				const PropertyInfo &pi=E->get();

				if (!pi.name.begins_with("input/"))
					continue;


				if (filters[p_port].action.action==index) {
					text="Action "+pi.name.substr(pi.name.find("/")+1,pi.name.length());
					break;
				}
				index++;
			}

			if (filters[p_port].action.pressed)
				text+=", Pressed";
			else
				text+=", Released";


		} break;
	}



	return text+" - "+itos(p_port);
}
Пример #28
0
void ScriptDebuggerLocal::debug(ScriptLanguage *p_script,bool p_can_continue) {

	print_line("Debugger Break, Reason: '"+p_script->debug_get_error()+"'");
	print_line("*Frame "+itos(0)+" - "+p_script->debug_get_stack_level_source(0)+":"+itos(p_script->debug_get_stack_level_line(0))+" in function '"+p_script->debug_get_stack_level_function(0)+"'");
	print_line("Enter \"help\" for assistance.");
	int current_frame=0;
	int total_frames=p_script->debug_get_stack_level_count();
	while(true) {

		OS::get_singleton()->print("debug> ");
		String line = OS::get_singleton()->get_stdin_string().strip_edges();

		if (line=="") {
			print_line("Debugger Break, Reason: '"+p_script->debug_get_error()+"'");
			print_line("*Frame "+itos(current_frame)+" - "+p_script->debug_get_stack_level_source(current_frame)+":"+itos(p_script->debug_get_stack_level_line(current_frame))+" in function '"+p_script->debug_get_stack_level_function(current_frame)+"'");
			print_line("Enter \"help\" for assistance.");
		} else if (line=="c" || line=="continue")
			break;
		else if (line=="bt" || line=="breakpoint") {

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

				String cfi=(current_frame==i)?"*":" "; //current frame indicator
				print_line(cfi+"Frame "+itos(i)+" - "+p_script->debug_get_stack_level_source(i)+":"+itos(p_script->debug_get_stack_level_line(i))+" in function '"+p_script->debug_get_stack_level_function(i)+"'");
			}

		} else if (line.begins_with("fr") || line.begins_with("frame")) {

			if (line.get_slice_count(" ")==1) {
				print_line("*Frame "+itos(current_frame)+" - "+p_script->debug_get_stack_level_source(current_frame)+":"+itos(p_script->debug_get_stack_level_line(current_frame))+" in function '"+p_script->debug_get_stack_level_function(current_frame)+"'");
			} else {
				int frame = line.get_slice(" ",1).to_int();
				if (frame<0 || frame >=total_frames) {
					print_line("Error: Invalid frame.");
				} else {
					current_frame=frame;
					print_line("*Frame "+itos(frame)+" - "+p_script->debug_get_stack_level_source(frame)+":"+itos(p_script->debug_get_stack_level_line(frame))+" in function '"+p_script->debug_get_stack_level_function(frame)+"'");
				}
			}

		} else if (line=="lv" || line=="locals") {

			List<String> locals;
			List<Variant> values;
			p_script->debug_get_stack_level_locals(current_frame,&locals, &values);
			List<Variant>::Element* V = values.front();
			for (List<String>::Element *E=locals.front();E;E=E->next()) {
				print_line(E->get() + ": " + String(V->get()));
				V = V->next();
			}

		} else if (line=="gv" || line=="globals") {

			List<String> locals;
			List<Variant> values;
			p_script->debug_get_globals(&locals, &values);
			List<Variant>::Element* V = values.front();
			for (List<String>::Element *E=locals.front();E;E=E->next()) {
				print_line(E->get() + ": " + String(V->get()));
				V = V->next();
			}

		} else if (line=="mv" || line=="members") {

			List<String> locals;
			List<Variant> values;
			p_script->debug_get_stack_level_members(current_frame,&locals, &values);
			List<Variant>::Element* V = values.front();
			for (List<String>::Element *E=locals.front();E;E=E->next()) {
				print_line(E->get() + ": " + String(V->get()));
				V = V->next();
			}

		} else if (line.begins_with("p") || line.begins_with("print")) {

			if (line.get_slice_count(" ")<=1) {
				print_line("Usage: print <expre>");
			} else {

				String expr = line.get_slice(" ",2);
				String res = p_script->debug_parse_stack_level_expression(current_frame,expr);
				print_line(res);
			}

		} else if (line=="s" || line=="step") {

			set_depth(-1);
			set_lines_left(1);
			break;
		} else if (line.begins_with("n") || line.begins_with("next")) {

			set_depth(0);
			set_lines_left(1);
			break;
		} else if (line.begins_with("br") || line.begins_with("break")) {

			if (line.get_slice_count(" ")<=1) {
				//show breakpoints
			} else {


				String bppos=line.get_slice(" ",1);
				String source=bppos.get_slice(":",0).strip_edges();
				int line=bppos.get_slice(":",1).strip_edges().to_int();

				source = breakpoint_find_source(source);

				insert_breakpoint(line,source);

				print_line("BreakPoint at "+source+":"+itos(line));
			}

		} else if (line.begins_with("delete")) {

			if (line.get_slice_count(" ")<=1) {
				clear_breakpoints();
			} else {

				String bppos=line.get_slice(" ",1);
				String source=bppos.get_slice(":",0).strip_edges();
				int line=bppos.get_slice(":",1).strip_edges().to_int();

				source = breakpoint_find_source(source);

				remove_breakpoint(line,source);

				print_line("Removed BreakPoint at "+source+":"+itos(line));

			}

		} else if (line=="h" || line=="help") {

			print_line("Built-In Debugger command list:\n");
			print_line("\tc,continue :\t\t Continue execution.");
			print_line("\tbt,backtrace :\t\t Show stack trace (frames).");
			print_line("\tfr,frame <frame>:\t Change current frame.");
			print_line("\tlv,locals :\t\t Show local variables for current frame.");
			print_line("\tmv,members :\t\t Show member variables for \"this\" in frame.");
			print_line("\tgv,globals :\t\t Show global variables.");
			print_line("\tp,print <expr> :\t Execute and print variable in expression.");
			print_line("\ts,step :\t\t Step to next line.");
			print_line("\tn,next :\t\t Next line.");
			print_line("\tbr,break source:line :\t Place a breakpoint.");
			print_line("\tdelete [source:line]:\t\t Delete one/all breakpoints.");
		} else {
			print_line("Error: Invalid command, enter \"help\" for assistance.");
		}
	}
}
Пример #29
0
void EditorExportPlatformBB10::_device_poll_thread(void *ud) {

	EditorExportPlatformBB10 *ea=(EditorExportPlatformBB10 *)ud;

	while(!ea->quit_request) {

		String bb_deploy=EditorSettings::get_singleton()->get("blackberry/host_tools");
		bb_deploy=bb_deploy.plus_file("blackberry-deploy");
		bool windows = OS::get_singleton()->get_name()=="Windows";
		if (windows)
			bb_deploy+=".bat";

		if (FileAccess::exists(bb_deploy)) {

			Vector<Device> devices;


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

				String host = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/host");
				if (host==String())
					continue;
				String pass = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/password");
				if (pass==String())
					continue;

				List<String> args;
				args.push_back("-listDeviceInfo");
				args.push_back(host);
				args.push_back("-password");
				args.push_back(pass);


				int ec;
				String dp;

				Error err = OS::get_singleton()->execute(bb_deploy,args,true,NULL,&dp,&ec);

				if (err==OK && ec==0) {

					Device dev;
					dev.index=i;
					String descr;
					Vector<String> ls=dp.split("\n");

					for(int i=0;i<ls.size();i++) {

						String l = ls[i].strip_edges();
						if (l.begins_with("modelfullname::")) {
							dev.name=l.get_slice("::",1);
							descr+="Model: "+dev.name+"\n";
						}
						if (l.begins_with("modelnumber::")) {
							String s = l.get_slice("::",1);
							dev.name+=" ("+s+")";
							descr+="Model Number: "+s+"\n";
						}
						if (l.begins_with("scmbundle::"))
							descr+="OS Version: "+l.get_slice("::",1)+"\n";
						if (l.begins_with("[n]debug_token_expiration::"))
							descr+="Debug Token Expires:: "+l.get_slice("::",1)+"\n";

					}

					dev.description=descr;
					devices.push_back(dev);
				}

			}

			bool changed=false;


			ea->device_lock->lock();

			if (ea->devices.size()!=devices.size()) {
				changed=true;
			} else {

				for(int i=0;i<ea->devices.size();i++) {

					if (ea->devices[i].index!=devices[i].index) {
						changed=true;
						break;
					}
				}
			}

			if (changed) {

				ea->devices=devices;
				ea->devices_changed=true;
			}

			ea->device_lock->unlock();
		}


		uint64_t wait = 3000000;
		uint64_t time = OS::get_singleton()->get_ticks_usec();
		while(OS::get_singleton()->get_ticks_usec() - time < wait ) {
			OS::get_singleton()->delay_usec(1000);
			if (ea->quit_request)
				break;
		}
	}

}
Пример #30
0
void ExportTemplateManager::_install_from_file(const String &p_file) {

	FileAccess *fa = NULL;
	zlib_filefunc_def io = zipio_create_io_from_file(&fa);

	unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
	if (!pkg) {

		EditorNode::get_singleton()->show_warning(TTR("Can't open export templates zip."));
		return;
	}
	int ret = unzGoToFirstFile(pkg);

	int fc = 0; //count them and find version
	String version;

	while (ret == UNZ_OK) {

		unz_file_info info;
		char fname[16384];
		ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);

		String file = fname;

		if (file.ends_with("version.txt")) {

			Vector<uint8_t> data;
			data.resize(info.uncompressed_size);

			//read
			unzOpenCurrentFile(pkg);
			ret = unzReadCurrentFile(pkg, data.ptr(), data.size());
			unzCloseCurrentFile(pkg);

			String data_str;
			data_str.parse_utf8((const char *)data.ptr(), data.size());
			data_str = data_str.strip_edges();

			if (data_str.get_slice_count("-") != 2 || data_str.get_slice_count(".") != 2) {
				EditorNode::get_singleton()->show_warning(TTR("Invalid version.txt format inside templates."));
				unzClose(pkg);
				return;
			}

			String ver = data_str.get_slice("-", 0);

			int major = ver.get_slice(".", 0).to_int();
			int minor = ver.get_slice(".", 1).to_int();
			String rev = data_str.get_slice("-", 1);

			if (!rev.is_valid_identifier()) {
				EditorNode::get_singleton()->show_warning(TTR("Invalid version.txt format inside templates. Revision is not a valid identifier."));
				unzClose(pkg);
				return;
			}

			version = itos(major) + "." + itos(minor) + "-" + rev;
		}

		fc++;
		ret = unzGoToNextFile(pkg);
	}

	if (version == String()) {
		EditorNode::get_singleton()->show_warning(TTR("No version.txt found inside templates."));
		unzClose(pkg);
		return;
	}

	String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(version);

	DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
	Error err = d->make_dir_recursive(template_path);
	if (err != OK) {
		EditorNode::get_singleton()->show_warning(TTR("Error creating path for templates:\n") + template_path);
		unzClose(pkg);
		return;
	}

	memdelete(d);

	ret = unzGoToFirstFile(pkg);

	EditorProgress p("ltask", TTR("Extracting Export Templates"), fc);

	fc = 0;

	while (ret == UNZ_OK) {

		//get filename
		unz_file_info info;
		char fname[16384];
		unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);

		String file = fname;

		Vector<uint8_t> data;
		data.resize(info.uncompressed_size);

		//read
		unzOpenCurrentFile(pkg);
		unzReadCurrentFile(pkg, data.ptr(), data.size());
		unzCloseCurrentFile(pkg);

		print_line(fname);
		/*
		for(int i=0;i<512;i++) {
			print_line(itos(data[i]));
		}
		*/

		file = file.get_file();

		p.step(TTR("Importing:") + " " + file, fc);

		FileAccess *f = FileAccess::open(template_path.plus_file(file), FileAccess::WRITE);

		ERR_CONTINUE(!f);
		f->store_buffer(data.ptr(), data.size());

		memdelete(f);

		ret = unzGoToNextFile(pkg);
		fc++;
	}

	unzClose(pkg);

	_update_template_list();
}