Parcourir la source

Merge branch 'master' of https://github.com/okamstudio/godot

Juan Linietsky il y a 10 ans
Parent
commit
4b6225586c

+ 46 - 0
SConstruct

@@ -123,6 +123,7 @@ opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no")
 opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no")
 opts.Add('colored', 'Enable colored output for the compilation (yes/no)', 'no')
 opts.Add('extra_suffix', 'Custom extra suffix added to the base filename of all generated binary files.', '')
+opts.Add('vsproj', 'Generate Visual Studio Project. (yes/no)', 'no')
 
 # add platform specific options
 
@@ -177,6 +178,25 @@ if selected_platform in platform_list:
 	else:
 		env = env_base.Clone()
 
+	if env['vsproj']=="yes":
+		env.vs_incs = []
+		env.vs_srcs = []
+		
+		def AddToVSProject( sources ):
+			for x in sources:
+				if type(x) == type(""):
+					fname = env.File(x).path
+				else:
+					fname = env.File(x)[0].path
+				pieces =  fname.split(".")
+				if len(pieces)>0:
+					basename = pieces[0]
+					basename = basename.replace('\\\\','/')
+					env.vs_srcs = env.vs_srcs + [basename + ".cpp"]
+					env.vs_incs = env.vs_incs + [basename + ".h"]					
+					#print basename	
+		env.AddToVSProject = AddToVSProject				
+		
 	env.extra_suffix=""
 	
 	if env["extra_suffix"] != '' :
@@ -330,6 +350,32 @@ if selected_platform in platform_list:
 	SConscript("main/SCsub")
 
 	SConscript("platform/"+selected_platform+"/SCsub"); # build selected platform
+	
+	# Microsoft Visual Studio Project Generation			
+	if (env['vsproj'])=="yes":		
+	
+		AddToVSProject(env.core_sources)
+		AddToVSProject(env.main_sources)
+		AddToVSProject(env.modules_sources)	
+		AddToVSProject(env.scene_sources)
+		AddToVSProject(env.servers_sources)
+		AddToVSProject(env.tool_sources)
+			
+		debug_variants = ['Debug|Win32']+['Debug|x64']
+		release_variants = ['Release|Win32']+['Release|x64']
+		release_debug_variants = ['Release_Debug|Win32']+['Release_Debug|x64']
+		variants = debug_variants + release_variants + release_debug_variants
+		debug_targets = ['Debug']+['Debug']
+		release_targets = ['Release']+['Release']
+		release_debug_targets = ['ReleaseDebug']+['ReleaseDebug']
+		targets = debug_targets + release_targets + release_debug_targets
+		msvproj = env.MSVSProject(target = ['#godot' + env['MSVSPROJECTSUFFIX'] ],
+								incs = env.vs_incs,
+								srcs = env.vs_srcs, 
+								runfile = targets, 
+								buildtarget = targets, 
+								auto_build_solution=1, 
+								variant = variants) 		
 
 else:
 

+ 21 - 21
core/io/file_access_memory.cpp

@@ -39,7 +39,7 @@ void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) {
 
 	if (!files) {
 		files = memnew((Map<String, Vector<uint8_t> >));
-	};
+	}
 
 	String name;
 	if (Globals::get_singleton())
@@ -49,7 +49,7 @@ void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) {
 	name = DirAccess::normalize_path(name);
 
 	(*files)[name] = p_data;
-};
+}
 
 void FileAccessMemory::cleanup() {
 
@@ -57,13 +57,13 @@ void FileAccessMemory::cleanup() {
 		return;
 
 	memdelete(files);
-};
+}
 
 
 FileAccess* FileAccessMemory::create() {
 
 	return memnew(FileAccessMemory);
-};
+}
 
 bool FileAccessMemory::file_exists(const String& p_name) {
 
@@ -71,7 +71,7 @@ bool FileAccessMemory::file_exists(const String& p_name) {
 	name = DirAccess::normalize_path(name);
 
 	return files && (files->find(name) != NULL);
-};
+}
 
 
 Error FileAccessMemory::_open(const String& p_path, int p_mode_flags) {
@@ -89,57 +89,57 @@ Error FileAccessMemory::_open(const String& p_path, int p_mode_flags) {
 	pos = 0;
 
 	return OK;
-};
+}
 
 void FileAccessMemory::close() {
 
 	data = NULL;
-};
+}
 
 bool FileAccessMemory::is_open() const {
 
 	return data != NULL;
-};
+}
 
 void FileAccessMemory::seek(size_t p_position) {
 
 	ERR_FAIL_COND(!data);
 	pos = p_position;
-};
+}
 
 void FileAccessMemory::seek_end(int64_t p_position) {
 
 	ERR_FAIL_COND(!data);
 	pos = length + p_position;
-};
+}
 
 size_t FileAccessMemory::get_pos() const {
 
 	ERR_FAIL_COND_V(!data, 0);
 	return pos;
-};
+}
 
 size_t FileAccessMemory::get_len() const {
 
 	ERR_FAIL_COND_V(!data, 0);
 	return length;
-};
+}
 
 bool FileAccessMemory::eof_reached() const {
 
 	return pos >= length;
-};
+}
 
 uint8_t FileAccessMemory::get_8() const {
 
-	uint8_t ret;
+	uint8_t ret = 0;
 	if (pos < length) {
 		ret = data[pos];
-	};
+	}
 	++pos;
 
 	return ret;
-};
+}
 
 int FileAccessMemory::get_buffer(uint8_t *p_dst,int p_length) const {
 
@@ -156,19 +156,19 @@ int FileAccessMemory::get_buffer(uint8_t *p_dst,int p_length) const {
 	pos += p_length;
 
 	return read;
-};
+}
 
 Error FileAccessMemory::get_error() const {
 
 	return pos >= length ? ERR_FILE_EOF : OK;
-};
+}
 
 void FileAccessMemory::store_8(uint8_t p_byte) {
 
 	ERR_FAIL_COND(!data);
 	ERR_FAIL_COND(pos >= length);
 	data[pos++] = p_byte;
-};
+}
 
 void FileAccessMemory::store_buffer(const uint8_t *p_src,int p_length) {
 
@@ -176,11 +176,11 @@ void FileAccessMemory::store_buffer(const uint8_t *p_src,int p_length) {
 	int write = MIN(p_length, left);
 	if (write < p_length) {
 		WARN_PRINT("Writing less data than requested");
-	};
+	}
 
 	copymem(&data[pos], p_src, write);
 	pos += p_length;
-};
+}
 
 FileAccessMemory::FileAccessMemory() {
 

+ 1 - 0
demos/2d/isometric_light/engine.cfg

@@ -1,5 +1,6 @@
 [application]
 
+name="Isometric 2D + Lighting"
 main_scene="res://map.scn"
 
 [input]

+ 1 - 0
demos/3d/truck_town/engine.cfg

@@ -1,5 +1,6 @@
 [application]
 
+name="Truck Town"
 main_scene="res://car_select.scn"
 
 [display]

+ 1 - 0
demos/gui/rich_text_bbcode/engine.cfg

@@ -1,3 +1,4 @@
 [application]
 
+name="Rich Text Label (BBCode)"
 main_scene="res://rich_text_bbcode.scn"

+ 1 - 1
demos/misc/window_management/engine.cfg

@@ -1,6 +1,6 @@
 [application]
 
-name="window_management"
+name="Window Management"
 main_scene="res://window_management.scn"
 icon="icon.png"
 

+ 94 - 91
drivers/SCsub

@@ -1,91 +1,94 @@
-Import('env')
-
-env.drivers_sources=[]
-#env.add_source_files(env.drivers_sources,"*.cpp")
-env.Append(CPPPATH=["vorbis"])
-Export('env')
-
-SConscript('unix/SCsub');
-SConscript('alsa/SCsub');
-SConscript('pulseaudio/SCsub');
-SConscript('windows/SCsub');
-SConscript('gles2/SCsub');
-SConscript('gl_context/SCsub');
-SConscript('openssl/SCsub');
-
-if (env["png"]=="yes"):
-	SConscript("png/SCsub");
-if (env["jpg"]=="yes"):
-	SConscript("jpg/SCsub");
-if (env["webp"]=="yes"):
-	SConscript("webp/SCsub");
-SConscript("dds/SCsub");
-SConscript("pvr/SCsub");
-SConscript("etc1/SCsub")
-if (env["builtin_zlib"]=="yes"):
-	SConscript("builtin_zlib/SCsub");
-if (env["openssl"]=="builtin"):
-	SConscript("builtin_openssl2/SCsub");
-
-SConscript("rtaudio/SCsub");
-SConscript("nedmalloc/SCsub");
-SConscript("trex/SCsub");
-SConscript("chibi/SCsub");
-if (env["vorbis"]=="yes" or env["speex"]=="yes" or env["theora"]=="yes"):
-        SConscript("ogg/SCsub");
-if (env["vorbis"]=="yes"):
-        SConscript("vorbis/SCsub");
-if (env["tools"]=="yes"):
-	SConscript("convex_decomp/SCsub");
-
-if env["theora"]=="yes":
-	SConscript("theoraplayer/SCsub")
-if (env["theora"]=="yes"):
-	SConscript("theora/SCsub");
-if (env['speex']=='yes'):
-	SConscript("speex/SCsub");
-if (env['musepack']=='yes'):
-	SConscript("mpc/SCsub");
-if (env["squish"]=="yes" and env["tools"]=="yes"):
-	SConscript("squish/SCsub");
-
-num = 0
-cur_base = ""
-total = len(env.drivers_sources)
-max_src = 64
-list = []
-lib_list = []
-
-import string
-
-for f in env.drivers_sources:
-	fname = ""
-	if type(f) == type(""):
-		fname = env.File(f).path
-	else:
-		fname = env.File(f)[0].path
-	#base = string.join(fname.split("/")[:-1], "/")
-	fname = fname.replace("\\", "/")
-	base = string.join(fname.split("/")[:2], "/")
-	if base != cur_base and len(list) > max_src:
-		lib = env.Library("drivers"+str(num), list)
-		lib_list.append(lib)
-		list = []
-		num = num+1
-	cur_base = base
-	list.append(f)
-
-if len(list) > 0:
-	lib = env.Library("drivers"+str(num), list)
-	lib_list.append(lib)
-
-
-drivers_base=[]
-env.add_source_files(drivers_base,"*.cpp")
-lib_list.insert(0, env.Library("drivers", drivers_base))
-
-env.Prepend(LIBS=lib_list)
-
-#lib = env.Library("drivers",env.drivers_sources)
-#env.Prepend(LIBS=[lib])
-
+Import('env')
+
+env.drivers_sources=[]
+#env.add_source_files(env.drivers_sources,"*.cpp")
+env.Append(CPPPATH=["vorbis"])
+Export('env')
+
+SConscript('unix/SCsub');
+SConscript('alsa/SCsub');
+SConscript('pulseaudio/SCsub');
+SConscript('windows/SCsub');
+SConscript('gles2/SCsub');
+SConscript('gl_context/SCsub');
+SConscript('openssl/SCsub');
+
+if (env["png"]=="yes"):
+	SConscript("png/SCsub");
+if (env["jpg"]=="yes"):
+	SConscript("jpg/SCsub");
+if (env["webp"]=="yes"):
+	SConscript("webp/SCsub");
+SConscript("dds/SCsub");
+SConscript("pvr/SCsub");
+SConscript("etc1/SCsub")
+if (env["builtin_zlib"]=="yes"):
+	SConscript("builtin_zlib/SCsub");
+if (env["openssl"]=="builtin"):
+	SConscript("builtin_openssl2/SCsub");
+
+SConscript("rtaudio/SCsub");
+SConscript("nedmalloc/SCsub");
+SConscript("trex/SCsub");
+SConscript("chibi/SCsub");
+if (env["vorbis"]=="yes" or env["speex"]=="yes" or env["theora"]=="yes"):
+        SConscript("ogg/SCsub");
+if (env["vorbis"]=="yes"):
+        SConscript("vorbis/SCsub");
+if (env["tools"]=="yes"):
+	SConscript("convex_decomp/SCsub");
+
+if env["theora"]=="yes":
+	SConscript("theoraplayer/SCsub")
+if (env["theora"]=="yes"):
+	SConscript("theora/SCsub");
+if (env['speex']=='yes'):
+	SConscript("speex/SCsub");
+if (env['musepack']=='yes'):
+	SConscript("mpc/SCsub");
+if (env["squish"]=="yes" and env["tools"]=="yes"):
+	SConscript("squish/SCsub");
+
+num = 0
+cur_base = ""
+total = len(env.drivers_sources)
+max_src = 64
+list = []
+lib_list = []
+
+import string
+
+if env['vsproj']=="yes":
+	env.AddToVSProject(env.drivers_sources)
+
+for f in env.drivers_sources:
+	fname = ""
+	if type(f) == type(""):
+		fname = env.File(f).path
+	else:
+		fname = env.File(f)[0].path
+	#base = string.join(fname.split("/")[:-1], "/")
+	fname = fname.replace("\\", "/")
+	base = string.join(fname.split("/")[:2], "/")
+	if base != cur_base and len(list) > max_src:
+		lib = env.Library("drivers"+str(num), list)
+		lib_list.append(lib)
+		list = []
+		num = num+1
+	cur_base = base
+	list.append(f)
+
+if len(list) > 0:
+	lib = env.Library("drivers"+str(num), list)
+	lib_list.append(lib)
+
+
+drivers_base=[]
+env.add_source_files(drivers_base,"*.cpp")
+lib_list.insert(0, env.Library("drivers", drivers_base))
+
+env.Prepend(LIBS=lib_list)
+
+#lib = env.Library("drivers",env.drivers_sources)
+#env.Prepend(LIBS=[lib])
+

+ 2 - 2
drivers/chibi/cp_player_data_control.cpp

@@ -233,7 +233,7 @@ int CPPlayer::get_channel_voice(int p_channel) {
 
 const char* CPPlayer::get_voice_sample_name(int p_voice) {
 
-	const char *name;
+	const char *name = NULL;
 
 
 
@@ -302,7 +302,7 @@ const char * CPPlayer::get_voice_instrument_name(int p_voice) {
 
 
 
-	const char *name;
+	const char *name = NULL;
 
 
 

+ 1 - 0
drivers/convex_decomp/b2Polygon.cpp

@@ -970,6 +970,7 @@ int32 DecomposeConvex(b2Polygon* p, b2Polygon* results, int32 maxPolys) {
 		}
 		if (nTri < 1) {
             //Still no luck?  Oh well...
+            delete[] triangulated;
             return -1;
         }
         int32 nPolys = PolygonizeTriangles(triangulated, nTri, results, maxPolys);

+ 1 - 1
platform/android/android_native_app_glue.h

@@ -26,7 +26,7 @@
 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
- * Copyright (C) 2010 The Android Open Source Project
+/* Copyright (C) 2010 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 6 - 0
platform/windows/SCsub

@@ -12,3 +12,9 @@ common_win=[
 ]
 
 env.Program('#bin/godot',['godot_win.cpp']+common_win,PROGSUFFIX=env["PROGSUFFIX"])
+
+# Microsoft Visual Studio Project Generation			
+if (env['vsproj'])=="yes":
+	env.vs_srcs = env.vs_srcs + ["platform/windows/godot_win.cpp"]
+	for x in common_win:
+		env.vs_srcs = env.vs_srcs + ["platform/windows/" + x]

+ 1 - 1
scene/3d/sprite_3d.cpp

@@ -292,7 +292,7 @@ SpriteBase3D::SpriteBase3D() {
 	parent_sprite=NULL;
 	pI=NULL;
 
-	for(int i=0;i<4;i++)
+	for(int i=0;i<FLAG_MAX;i++)
 		flags[i]=i==FLAG_TRANSPARENT;
 
 	axis=Vector3::AXIS_Z;

+ 56 - 32
scene/gui/label.cpp

@@ -99,7 +99,7 @@ void Label::_notification(int p_what) {
 		int chars_total=0;
 
 		int vbegin=0,vsep=0;
-
+		
 		if (lines_total && lines_total < lines_visible) {
 
 
@@ -136,10 +136,9 @@ void Label::_notification(int p_what) {
 		if (!wc)
 			return;
 		
-
+		int c = 0;
 		int line=0;
 		while(wc) {
-			
 		/* handle lines not meant to be drawn quickly */
 			if  (line>line_to)
 				break;
@@ -170,8 +169,8 @@ void Label::_notification(int p_what) {
 			while(to && to->char_pos>=0) {
 				
 				taken+=to->pixel_width;
-				if (to!=from) {
-					spaces++;
+				if (to!=from && to->space_count) {
+					spaces+=to->space_count;
 				}
 				to=to->next;
 			}
@@ -212,15 +211,15 @@ void Label::_notification(int p_what) {
 					ERR_PRINT("BUG");
 					return;
 				}
-				if (from!=wc) {
+				if (from->space_count) {
 				/* spacing */
-					x_ofs+=space_w;
+					x_ofs+=space_w*from->space_count;
 					if (can_fill && align==ALIGN_FILL && spaces) {
-						
+
 						x_ofs+=int((size.width-(taken+space_w*spaces))/spaces);
 					}
-					
-					
+
+
 				}
 				
 				
@@ -253,7 +252,7 @@ void Label::_notification(int p_what) {
 					
 				}
 				for (int i=0;i<from->word_len;i++) {
-					
+
 					if (visible_chars < 0 || chars_total<visible_chars) {
 						CharType c = text[i+pos];
 						CharType n = text[i+pos+1];
@@ -361,11 +360,12 @@ void Label::regenerate_word_cache() {
 	
 	int width=autowrap?get_size().width:get_longest_line_width();
 	Ref<Font> font = get_font("font");
-	
+
 	int current_word_size=0;
 	int word_pos=0;
 	int line_width=0;
-	int last_width=0;
+	int space_count=0;
+	int space_width=font->get_char_size(' ').width;
 	line_count=1;
 	total_char_cache=0;
 	
@@ -374,16 +374,17 @@ void Label::regenerate_word_cache() {
 	for (int i=0;i<text.size()+1;i++) {
 		
 		CharType current=i<text.length()?text[i]:' '; //always a space at the end, so the algo works
-		
+
 		if (uppercase)
 			current=String::char_uppercase(current);
 
+		bool not_latin = current>=33 && (current < 65||current >90) && (current<97||current>122) && (current<48||current>57);
 		bool insert_newline=false;
-		
+		int char_width;
+
 		if (current<33) {
-			
+
 			if (current_word_size>0) {
-				
 				WordCache *wc = memnew( WordCache );
 				if (word_cache) {
 					last->next=wc;
@@ -391,14 +392,16 @@ void Label::regenerate_word_cache() {
 					word_cache=wc;
 				}
 				last=wc;
-				
+
 				wc->pixel_width=current_word_size;
 				wc->char_pos=word_pos;
 				wc->word_len=i-word_pos;
+				wc->space_count = space_count;
 				current_word_size=0;
-				
+				space_count=0;
+
 			}
-			
+
 
 			if (current=='\n') {
 				insert_newline=true;
@@ -408,26 +411,49 @@ void Label::regenerate_word_cache() {
 
 			if (i<text.length() && text[i] == ' ') {
 				total_char_cache--;  // do not count spaces
+				if (line_width > 0 || last==NULL || last->char_pos!=WordCache::CHAR_WRAPLINE) {
+					space_count++;
+					line_width+=space_width;
+				}else {
+					space_count=0;
+				}
 			}
 
 
 		} else {
-			
+			// latin characters
 			if (current_word_size==0) {
-				if (line_width>0) // add a space before the new word if a word existed before
-					line_width+=font->get_char_size(' ').width;
 				word_pos=i;
 			}
 			
-			int char_width=font->get_char_size(current).width;
+			char_width=font->get_char_size(current).width;
 			current_word_size+=char_width;
 			line_width+=char_width;
 			total_char_cache++;
 			
 		}
-		
-		if ((autowrap && line_width>=width && last_width<width) || insert_newline) {
-			
+
+		if ((autowrap && line_width>=width && (last &&  last->char_pos >= 0 || not_latin)) || insert_newline) {
+			if (not_latin) {
+				if (current_word_size>0) {
+					WordCache *wc = memnew( WordCache );
+					if (word_cache) {
+						last->next=wc;
+					} else {
+						word_cache=wc;
+					}
+					last=wc;
+
+					wc->pixel_width=current_word_size-char_width;
+					wc->char_pos=word_pos;
+					wc->word_len=i-word_pos;
+					wc->space_count = space_count;
+					current_word_size=char_width;
+					space_count=0;
+					word_pos=i;
+				}
+			}
+
 			WordCache *wc = memnew( WordCache );
 			if (word_cache) {
 				last->next=wc;
@@ -435,18 +461,16 @@ void Label::regenerate_word_cache() {
 				word_cache=wc;
 			}
 			last=wc;
-			
+
 			wc->pixel_width=0;
 			wc->char_pos=insert_newline?WordCache::CHAR_NEWLINE:WordCache::CHAR_WRAPLINE;
 
 			line_width=current_word_size;
 			line_count++;
+			space_count=0;
 
-			
 		}
 		
-		last_width=line_width;
-		
 	}
 	
 	//total_char_cache -= line_count + 1; // do not count new lines (including the first one)
@@ -465,7 +489,7 @@ void Label::regenerate_word_cache() {
 	set_max(line_count);
 	
 	word_cache_dirty=false;
-		
+
 }
 
 

+ 2 - 1
scene/gui/label.h

@@ -75,8 +75,9 @@ private:
 		int char_pos; // if -1, then newline
 		int word_len;
 		int pixel_width;
+		int space_count;
 		WordCache *next;
-		WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; }
+		WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; space_count=0;}
 	};	
 	
 	bool word_cache_dirty;

+ 1 - 1
scene/gui/text_edit.cpp

@@ -1249,7 +1249,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
 					}
 					
 					
-					if (!mb.doubleclick && (OS::get_singleton()->get_ticks_msec()-last_dblclk)<600) {
+					if (!mb.doubleclick && (OS::get_singleton()->get_ticks_msec()-last_dblclk)<600 && cursor.line==prev_line) {
 						//tripleclick select line
 						select(cursor.line,0,cursor.line,text[cursor.line].length());
 						last_dblclk=0;

+ 2 - 2
scene/resources/animation.cpp

@@ -1216,8 +1216,8 @@ T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time,  Inter
 	
 	if (p_ok)
 		*p_ok=true;
-	
-	int next;
+
+	int next=0;
 	float c=0;	
 	// prepare for all cases of interpolation
 	

+ 1 - 0
tools/editor/editor_node.cpp

@@ -3509,6 +3509,7 @@ EditorNode::EditorNode() {
 	p=file_menu->get_popup();
 	p->add_item("New Scene",FILE_NEW_SCENE);
 	p->add_item("Open Scene..",FILE_OPEN_SCENE,KEY_MASK_CMD+KEY_O);
+	p->add_separator();
 	p->add_item("Save Scene",FILE_SAVE_SCENE,KEY_MASK_CMD+KEY_S);
 	p->add_item("Save Scene As..",FILE_SAVE_AS_SCENE,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S);
 	p->add_separator();