Răsfoiți Sursa

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

Juan Linietsky 9 ani în urmă
părinte
comite
035bb03331

+ 11 - 0
core/globals.cpp

@@ -1414,6 +1414,7 @@ Globals::Globals() {
 	joyb.joy_button.button_index=JOY_BUTTON_0;
 	va.push_back(joyb);
 	set("input/ui_accept",va);
+	input_presets.push_back("input/ui_accept");
 
 	va=Array();
 	key.key.scancode=KEY_SPACE;
@@ -1421,6 +1422,7 @@ Globals::Globals() {
 	joyb.joy_button.button_index=JOY_BUTTON_3;
 	va.push_back(joyb);
 	set("input/ui_select",va);
+	input_presets.push_back("input/ui_select");
 
 	va=Array();
 	key.key.scancode=KEY_ESCAPE;
@@ -1428,17 +1430,20 @@ Globals::Globals() {
 	joyb.joy_button.button_index=JOY_BUTTON_1;
 	va.push_back(joyb);
 	set("input/ui_cancel",va);
+	input_presets.push_back("input/ui_cancel");
 
 	va=Array();
 	key.key.scancode=KEY_TAB;
 	va.push_back(key);
 	set("input/ui_focus_next",va);
+	input_presets.push_back("input/ui_focus_next");
 
 	va=Array();
 	key.key.scancode=KEY_TAB;
 	key.key.mod.shift=true;
 	va.push_back(key);
 	set("input/ui_focus_prev",va);
+	input_presets.push_back("input/ui_focus_prev");
 	key.key.mod.shift=false;
 
 	va=Array();
@@ -1447,6 +1452,7 @@ Globals::Globals() {
 	joyb.joy_button.button_index=JOY_DPAD_LEFT;
 	va.push_back(joyb);
 	set("input/ui_left",va);
+	input_presets.push_back("input/ui_left");
 
 	va=Array();
 	key.key.scancode=KEY_RIGHT;
@@ -1454,6 +1460,7 @@ Globals::Globals() {
 	joyb.joy_button.button_index=JOY_DPAD_RIGHT;
 	va.push_back(joyb);
 	set("input/ui_right",va);
+	input_presets.push_back("input/ui_right");
 
 	va=Array();
 	key.key.scancode=KEY_UP;
@@ -1461,6 +1468,7 @@ Globals::Globals() {
 	joyb.joy_button.button_index=JOY_DPAD_UP;
 	va.push_back(joyb);
 	set("input/ui_up",va);
+	input_presets.push_back("input/ui_up");
 
 	va=Array();
 	key.key.scancode=KEY_DOWN;
@@ -1468,17 +1476,20 @@ Globals::Globals() {
 	joyb.joy_button.button_index=JOY_DPAD_DOWN;
 	va.push_back(joyb);
 	set("input/ui_down",va);
+	input_presets.push_back("input/ui_down");
 
 
 	va=Array();
 	key.key.scancode=KEY_PAGEUP;
 	va.push_back(key);
 	set("input/ui_page_up",va);
+	input_presets.push_back("input/ui_page_up");
 
 	va=Array();
 	key.key.scancode=KEY_PAGEDOWN;
 	va.push_back(key);
 	set("input/ui_page_down",va);
+	input_presets.push_back("input/ui_page_down");
 
 //	set("display/orientation", "landscape");
 

+ 3 - 0
core/globals.h

@@ -70,6 +70,7 @@ protected:
 	Map<StringName,PropertyInfo> custom_prop_info;
 	bool disable_platform_override;
 	bool using_datapack;
+	List<String> input_presets;
 
 	
 	bool _set(const StringName& p_name, const Variant& p_value);
@@ -124,6 +125,8 @@ public:
 
 	Vector<String> get_optimizer_presets() const;
 
+	List<String> get_input_presets() const { return input_presets; }
+
 	void set_disable_platform_override(bool p_disable);
 	Object* get_singleton_object(const String& p_name) const;
 

+ 106 - 8
modules/gdscript/gd_parser.cpp

@@ -2381,10 +2381,48 @@ void GDParser::_parse_class(ClassNode *p_class) {
 
 										current_export.hint=PROPERTY_HINT_ALL_FLAGS;
 										tokenizer->advance();
-										if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
-											_set_error("Expected ')' in hint.");
+
+										if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE) {
+											break;
+										}
+										if (tokenizer->get_token()!=GDTokenizer::TK_COMMA)
+										{
+											_set_error("Expected ')' or ',' in bit flags hint.");
 											return;
 										}
+
+										current_export.hint=PROPERTY_HINT_FLAGS;
+										tokenizer->advance();
+
+										bool first = true;
+										while(true) {
+
+											if (tokenizer->get_token()!=GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type()!=Variant::STRING) {
+												current_export=PropertyInfo();
+												_set_error("Expected a string constant in named bit flags hint.");
+												return;
+											}
+
+											String c = tokenizer->get_token_constant();
+											if (!first)
+												current_export.hint_string+=",";
+											else
+												first=false;
+
+											current_export.hint_string+=c.xml_escape();
+
+											tokenizer->advance();
+											if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE)
+												break;
+
+											if (tokenizer->get_token()!=GDTokenizer::TK_COMMA) {
+												current_export=PropertyInfo();
+												_set_error("Expected ')' or ',' in named bit flags hint.");
+												return;
+											}
+											tokenizer->advance();
+										}
+
 										break;
 									}
 
@@ -2439,6 +2477,23 @@ void GDParser::_parse_class(ClassNode *p_class) {
 										break;
 									}
 
+									// range
+									if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier()=="EXP") {
+
+										current_export.hint=PROPERTY_HINT_EXP_RANGE;
+										tokenizer->advance();
+
+										if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE)
+											break;
+										else if (tokenizer->get_token()!=GDTokenizer::TK_COMMA) {
+											_set_error("Expected ')' or ',' in exponential range hint.");
+											return;
+										}
+										tokenizer->advance();
+									}
+									else
+										current_export.hint=PROPERTY_HINT_RANGE;
+
 									float sign=1.0;
 
 									if (tokenizer->get_token()==GDTokenizer::TK_OP_SUB) {
@@ -2452,8 +2507,6 @@ void GDParser::_parse_class(ClassNode *p_class) {
 										return;
 
 									}
-										//enumeration
-									current_export.hint=PROPERTY_HINT_RANGE;
 
 									current_export.hint_string=rtos(sign*double(tokenizer->get_token_constant()));
 									tokenizer->advance();
@@ -2556,10 +2609,32 @@ void GDParser::_parse_class(ClassNode *p_class) {
 
 									if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier()=="DIR") {
 
-										current_export.hint=PROPERTY_HINT_DIR;
 										tokenizer->advance();
-										if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
-											_set_error("Expected ')' in hint.");
+
+										if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE)
+											current_export.hint=PROPERTY_HINT_DIR;
+										else if (tokenizer->get_token()==GDTokenizer::TK_COMMA ) {
+
+											tokenizer->advance();
+
+											if (tokenizer->get_token()!=GDTokenizer::TK_IDENTIFIER || !(tokenizer->get_token_identifier()=="GLOBAL")) {
+												_set_error("Expected 'GLOBAL' after comma in directory hint.");
+												return;
+											}
+											if (!p_class->tool) {
+												_set_error("Global filesystem hints may only be used in tool scripts.");
+												return;
+											}
+											current_export.hint=PROPERTY_HINT_GLOBAL_DIR;
+											tokenizer->advance();
+
+											if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
+												_set_error("Expected ')' in hint.");
+												return;
+											}
+										}
+										else {
+											_set_error("Expected ')' or ',' in hint.");
 											return;
 										}
 										break;
@@ -2573,9 +2648,32 @@ void GDParser::_parse_class(ClassNode *p_class) {
 										if (tokenizer->get_token()==GDTokenizer::TK_COMMA) {
 
 											tokenizer->advance();
+
+											if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier()=="GLOBAL") {
+
+												if (!p_class->tool) {
+													_set_error("Global filesystem hints may only be used in tool scripts.");
+													return;
+												}
+												current_export.hint=PROPERTY_HINT_GLOBAL_FILE;
+												tokenizer->advance();
+
+												if (tokenizer->get_token()==GDTokenizer::TK_PARENTHESIS_CLOSE)
+													break;
+												else if (tokenizer->get_token()==GDTokenizer::TK_COMMA)
+													tokenizer->advance();
+												else {
+													_set_error("Expected ')' or ',' in hint.");
+													return;
+												}
+											}
+
 											if (tokenizer->get_token()!=GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type()!=Variant::STRING) {
 
-												_set_error("Expected string constant with filter");
+												if (current_export.hint==PROPERTY_HINT_GLOBAL_FILE)
+													_set_error("Expected string constant with filter");
+												else
+													_set_error("Expected 'GLOBAL' or string constant with filter");
 												return;
 											}
 											current_export.hint_string=tokenizer->get_token_constant();

+ 2 - 0
platform/iphone/os_iphone.cpp

@@ -242,6 +242,8 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_
 		ev.mouse_button.x = ev.mouse_button.global_x = p_x;
 		ev.mouse_button.y = ev.mouse_button.global_y = p_y;
 
+		//mouse_list.pressed[p_idx] = p_pressed;
+
 		input->set_mouse_pos(Point2(ev.mouse_motion.x,ev.mouse_motion.y));
 		ev.mouse_button.button_index = BUTTON_LEFT;
 		ev.mouse_button.doubleclick = p_doubleclick;

+ 1 - 0
platform/osx/SCsub

@@ -6,6 +6,7 @@ files = [
 	'audio_driver_osx.cpp',
 	'sem_osx.cpp',
 #	'context_gl_osx.cpp',
+	'dir_access_osx.mm',
 	]
 
 env.Program('#bin/godot',files)

+ 92 - 0
platform/osx/dir_access_osx.h

@@ -0,0 +1,92 @@
+/*************************************************************************/
+/*  dir_access_unix.h                                                    */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                    http://www.godotengine.org                         */
+/*************************************************************************/
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur.                 */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+#ifndef DIR_ACCESS_OSX_H
+#define DIR_ACCESS_OSX_H
+
+#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+
+#include "os/dir_access.h"
+
+
+/**
+	@author Juan Linietsky <[email protected]>
+*/
+class DirAccessOSX : public DirAccess {
+	
+	DIR *dir_stream;
+	
+	static DirAccess *create_fs();
+	
+	String current_dir;
+	bool _cisdir;
+	bool _cishidden;
+	
+public:
+	
+	virtual bool list_dir_begin(); ///< This starts dir listing
+	virtual String get_next();
+	virtual bool current_is_dir() const;
+	virtual bool current_is_hidden() const;
+	
+	virtual void list_dir_end(); ///< 
+	
+	virtual int get_drive_count();
+	virtual String get_drive(int p_drive);
+	
+	virtual Error change_dir(String p_dir); ///< can be relative or absolute, return false on success
+	virtual String get_current_dir(); ///< return current dir location
+	virtual Error make_dir(String p_dir);
+	
+	virtual bool file_exists(String p_file);
+	virtual bool dir_exists(String p_dir);
+
+	virtual uint64_t get_modified_time(String p_file);
+
+
+		
+	virtual Error rename(String p_from, String p_to);
+	virtual Error remove(String p_name);
+
+	virtual size_t get_space_left();
+	
+	
+	DirAccessOSX();
+	~DirAccessOSX();
+
+};
+
+
+
+#endif //UNIX ENABLED
+#endif

+ 350 - 0
platform/osx/dir_access_osx.mm

@@ -0,0 +1,350 @@
+/*************************************************************************/
+/*  dir_access_unix.cpp                                                  */
+/*************************************************************************/
+/*                       This file is part of:                           */
+/*                           GODOT ENGINE                                */
+/*                    http://www.godotengine.org                         */
+/*************************************************************************/
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur.                 */
+/*                                                                       */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the       */
+/* "Software"), to deal in the Software without restriction, including   */
+/* without limitation the rights to use, copy, modify, merge, publish,   */
+/* distribute, sublicense, and/or sell copies of the Software, and to    */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions:                                             */
+/*                                                                       */
+/* The above copyright notice and this permission notice shall be        */
+/* included in all copies or substantial portions of the Software.       */
+/*                                                                       */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
+/*************************************************************************/
+#include "dir_access_osx.h"
+
+#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
+
+#ifndef ANDROID_ENABLED
+#include <sys/statvfs.h>
+#endif
+
+#include <stdio.h>
+#include "os/memory.h"
+#include "print_string.h"
+#include <errno.h>
+
+#include <Foundation/NSString.h>
+
+DirAccess *DirAccessOSX::create_fs() {
+
+	return memnew( DirAccessOSX );
+}
+
+bool DirAccessOSX::list_dir_begin() {
+	
+	list_dir_end(); //close any previous dir opening!
+	
+
+//	char real_current_dir_name[2048]; //is this enough?!
+	//getcwd(real_current_dir_name,2048);
+	//chdir(curent_path.utf8().get_data());
+	dir_stream = opendir(current_dir.utf8().get_data());
+	//chdir(real_current_dir_name);
+	if (!dir_stream)
+		return true; //error!
+
+	return false;
+}
+
+bool DirAccessOSX::file_exists(String p_file) {
+	
+	GLOBAL_LOCK_FUNCTION
+
+
+	if (p_file.is_rel_path())
+		p_file=current_dir+"/"+p_file;
+	else
+		p_file=fix_path(p_file);
+
+	struct stat flags;
+	bool success = 	(stat(p_file.utf8().get_data(),&flags)==0);
+
+	if (success && S_ISDIR(flags.st_mode)) {
+		success=false;
+	}
+
+	return success;
+
+}
+
+bool DirAccessOSX::dir_exists(String p_dir) {
+
+	GLOBAL_LOCK_FUNCTION
+
+
+	if (p_dir.is_rel_path())
+		p_dir=get_current_dir().plus_file(p_dir);
+	else
+		p_dir=fix_path(p_dir);
+
+	struct stat flags;
+	bool success = 	(stat(p_dir.utf8().get_data(),&flags)==0);
+
+	if (success && S_ISDIR(flags.st_mode))
+		return true;
+
+	return false;
+
+}
+
+uint64_t DirAccessOSX::get_modified_time(String p_file) {
+
+	if (p_file.is_rel_path())
+		p_file=current_dir+"/"+p_file;
+	else
+		p_file=fix_path(p_file);
+
+	struct stat flags;
+	bool success = 	(stat(p_file.utf8().get_data(),&flags)==0);
+
+	if (success) {
+		return flags.st_mtime;
+	} else {
+
+		ERR_FAIL_V(0);
+	};
+	return 0;
+};
+
+
+String DirAccessOSX::get_next() {
+
+	if (!dir_stream)
+		return "";
+	dirent *entry;
+
+	entry=readdir(dir_stream);
+
+	if (entry==NULL) {
+
+		list_dir_end();
+		return "";
+	}
+
+	//typedef struct stat Stat;
+	struct stat flags;
+
+	String fname;
+	NSString* nsstr = [[NSString stringWithUTF8String: entry->d_name] precomposedStringWithCanonicalMapping];
+
+	fname.parse_utf8([nsstr UTF8String]);
+
+	//[nsstr autorelease];
+
+	String f=current_dir+"/"+fname;
+
+	if (stat(f.utf8().get_data(),&flags)==0) {
+
+		if (S_ISDIR(flags.st_mode)) {
+
+			_cisdir=true;
+
+		} else {
+
+			_cisdir=false;
+		}
+
+	} else {
+
+		_cisdir=false;
+
+	}
+
+	_cishidden=(fname!="." && fname!=".." && fname.begins_with("."));
+
+
+
+	return fname;
+
+}
+
+bool DirAccessOSX::current_is_dir() const {
+
+	return _cisdir;
+}
+
+bool DirAccessOSX::current_is_hidden() const {
+
+	return _cishidden;
+}
+
+
+void DirAccessOSX::list_dir_end() {
+
+	if (dir_stream)
+		closedir(dir_stream);
+	dir_stream=0;
+	_cisdir=false;
+}
+
+int DirAccessOSX::get_drive_count() {
+
+	return 0;
+}
+String DirAccessOSX::get_drive(int p_drive) {
+
+	return "";
+}
+
+Error DirAccessOSX::make_dir(String p_dir) {
+
+	GLOBAL_LOCK_FUNCTION
+
+	p_dir=fix_path(p_dir);
+	
+	char real_current_dir_name[2048];
+	getcwd(real_current_dir_name,2048);
+	chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants
+
+	bool success=(mkdir(p_dir.utf8().get_data(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)==0);
+	int err = errno;
+
+	chdir(real_current_dir_name);
+
+	if (success) {
+		return OK;
+	};
+
+	if (err == EEXIST) {
+		return ERR_ALREADY_EXISTS;
+	};
+
+	return ERR_CANT_CREATE;
+}
+
+
+Error DirAccessOSX::change_dir(String p_dir) {
+
+	GLOBAL_LOCK_FUNCTION
+	p_dir=fix_path(p_dir);
+
+
+	char real_current_dir_name[2048];
+	getcwd(real_current_dir_name,2048);
+	String prev_dir;
+	if (prev_dir.parse_utf8(real_current_dir_name))
+		prev_dir=real_current_dir_name; //no utf8, maybe latin?
+
+	chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants
+	bool worked=(chdir(p_dir.utf8().get_data())==0); // we can only give this utf8
+#ifndef IPHONE_ENABLED
+	String base = _get_root_path();
+	if (base!="") {
+
+		getcwd(real_current_dir_name,2048);
+		String new_dir;
+		new_dir.parse_utf8(real_current_dir_name);
+		if (!new_dir.begins_with(base))
+			worked=false;
+	}
+#endif
+	if (worked) {
+
+		getcwd(real_current_dir_name,2048);
+		if (current_dir.parse_utf8(real_current_dir_name))
+			current_dir=real_current_dir_name; //no utf8, maybe latin?
+	}
+
+	chdir(prev_dir.utf8().get_data());
+	return worked?OK:ERR_INVALID_PARAMETER;
+
+}
+
+String DirAccessOSX::get_current_dir() {
+
+	String base = _get_root_path();
+	if (base!="") {
+
+		String bd = current_dir.replace_first(base,"");
+		if (bd.begins_with("/"))
+			return _get_root_string()+bd.substr(1,bd.length());
+		else
+			return _get_root_string()+bd;
+
+	}
+	return current_dir;
+}
+
+Error DirAccessOSX::rename(String p_path,String p_new_path) {
+
+	if (p_path.is_rel_path())
+		p_path=get_current_dir().plus_file(p_path);
+	else
+		p_path=fix_path(p_path);
+
+	if (p_new_path.is_rel_path())
+		p_new_path=get_current_dir().plus_file(p_new_path);
+	else
+		p_new_path=fix_path(p_new_path);
+
+	return ::rename(p_path.utf8().get_data(),p_new_path.utf8().get_data())==0?OK:FAILED;
+}
+Error DirAccessOSX::remove(String p_path)  {
+
+	p_path=fix_path(p_path);
+	
+	struct stat flags;
+	if ((stat(p_path.utf8().get_data(),&flags)!=0))
+		return FAILED;
+
+	if (S_ISDIR(flags.st_mode))
+		return ::rmdir(p_path.utf8().get_data())==0?OK:FAILED;
+	else
+		return ::unlink(p_path.utf8().get_data())==0?OK:FAILED;
+}
+
+
+size_t DirAccessOSX::get_space_left() {
+
+#ifndef NO_STATVFS
+	struct statvfs vfs;
+	if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) {
+
+		return -1;
+	};
+
+	return vfs.f_bfree * vfs.f_bsize;
+#else
+#warning THIS IS BROKEN
+	return 0;
+#endif	
+};
+
+
+
+DirAccessOSX::DirAccessOSX() {
+
+	dir_stream=0;
+	current_dir=".";
+	_cisdir=false;
+
+	/* determine drive count */
+
+	change_dir(current_dir);
+
+}
+
+
+DirAccessOSX::~DirAccessOSX() {
+
+	list_dir_end();
+}
+
+
+#endif //posix_enabled

+ 8 - 2
platform/osx/os_osx.mm

@@ -47,6 +47,7 @@
 #include "servers/visual/visual_server_wrap_mt.h"
 #include "main/main.h"
 #include "os/keyboard.h"
+#include "dir_access_osx.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -838,8 +839,8 @@ const char * OS_OSX::get_video_driver_name(int p_driver) const {
 OS::VideoMode OS_OSX::get_default_video_mode() const {
 
 	VideoMode vm;
-	vm.width=1280;
-	vm.height=720	;
+	vm.width=800;
+	vm.height=600;
 	vm.fullscreen=false;
 	vm.resizable=true;
 	return vm;
@@ -849,6 +850,11 @@ OS::VideoMode OS_OSX::get_default_video_mode() const {
 void OS_OSX::initialize_core() {
 
 	OS_Unix::initialize_core();
+
+	DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_RESOURCES);
+	DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_USERDATA);
+	DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_FILESYSTEM);
+
 	SemaphoreOSX::make_default();
 
 }

+ 36 - 33
scene/animation/animation_tree_player.cpp

@@ -432,7 +432,7 @@ void AnimationTreePlayer::_notification(int p_what) {
 }
 
 
-float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode **r_prev_anim,float p_weight, float p_time, bool p_seek,const HashMap<NodePath,bool> *p_filter, float p_reverse_weight) {
+float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode **r_prev_anim,float p_weight, float p_time, bool switched, bool p_seek,const HashMap<NodePath,bool> *p_filter, float p_reverse_weight) {
 
 	ERR_FAIL_COND_V(!node_map.has(p_node), 0);
 	NodeBase *nb=node_map[p_node];
@@ -445,7 +445,7 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 		case NODE_OUTPUT: {
 
 			NodeOut *on = static_cast<NodeOut*>(nb);
-			return _process_node(on->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek);
+			return _process_node(on->inputs[0].node,r_prev_anim,p_weight,p_time,switched,p_seek);
 
 		} break;
 		case NODE_ANIMATION: {
@@ -479,6 +479,9 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 
 					an->time=anim_size;
 				}
+				if (switched && an->time >= anim_size) {
+					an->time = 0.0;
+				}
 
 				an->skip=true;
 				for (List<AnimationNode::TrackRef>::Element *E=an->tref.front();E;E=E->next()) {
@@ -520,7 +523,7 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 
 			if (!osn->active) {
 				//make it as if this node doesn't exist, pass input 0 by.
-				return _process_node(osn->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek,p_filter,p_reverse_weight);
+				return _process_node(osn->inputs[0].node,r_prev_anim,p_weight,p_time,switched,p_seek,p_filter,p_reverse_weight);
 			}
 
 			if (p_seek)
@@ -551,13 +554,13 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 
 			if (!osn->filter.empty()) {
 
-				main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,p_seek,&osn->filter,p_weight);
-				os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,p_seek,&osn->filter,-1);
+				main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,switched,p_seek,&osn->filter,p_weight);
+				os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,osn->start,p_seek,&osn->filter,-1);
 
 			} else {
 
-				main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,p_seek);
-				os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,p_seek);
+				main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,switched,p_seek);
+				os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,osn->start,p_seek);
 			}
 
 			if (osn->start) {
@@ -578,8 +581,8 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 			MixNode *mn = static_cast<MixNode*>(nb);
 
 
-			float rem = _process_node(mn->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek,p_filter,p_reverse_weight);
-			_process_node(mn->inputs[1].node,r_prev_anim,p_weight*mn->amount,p_time,p_seek,p_filter,p_reverse_weight);
+			float rem = _process_node(mn->inputs[0].node,r_prev_anim,p_weight,p_time,switched,p_seek,p_filter,p_reverse_weight);
+			_process_node(mn->inputs[1].node,r_prev_anim,p_weight*mn->amount,p_time,switched,p_seek,p_filter,p_reverse_weight);
 			return rem;
 
 		} break;
@@ -590,12 +593,12 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 			float rem;
 			if (!bn->filter.empty()) {
 
-				rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value),p_time,p_seek,&bn->filter,p_weight);
-				_process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value,p_time,p_seek,&bn->filter,-1);
+				rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value),p_time,switched,p_seek,&bn->filter,p_weight);
+				_process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value,p_time,switched,p_seek,&bn->filter,-1);
 
 			} else {
-				rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value),p_time,p_seek,p_filter,p_reverse_weight*(1.0-bn->value));
-				_process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value,p_time,p_seek,p_filter,p_reverse_weight*bn->value);
+				rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value),p_time,switched,p_seek,p_filter,p_reverse_weight*(1.0-bn->value));
+				_process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value,p_time,switched,p_seek,p_filter,p_reverse_weight*bn->value);
 			}
 
 			return rem;
@@ -606,16 +609,16 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 			float rem;
 
 			if (bn->value==0) {
-				rem = _process_node(bn->inputs[1].node,r_prev_anim,p_weight,p_time,p_seek,p_filter,p_reverse_weight);
+				rem = _process_node(bn->inputs[1].node,r_prev_anim,p_weight,p_time,switched,p_seek,p_filter,p_reverse_weight);
 			} else if (bn->value>0) {
 
-				rem = _process_node(bn->inputs[1].node,r_prev_anim,p_weight*(1.0-bn->value),p_time,p_seek,p_filter,p_reverse_weight*(1.0-bn->value));
-				_process_node(bn->inputs[2].node,r_prev_anim,p_weight*bn->value,p_time,p_seek,p_filter,p_reverse_weight*bn->value);
+				rem = _process_node(bn->inputs[1].node,r_prev_anim,p_weight*(1.0-bn->value),p_time,switched,p_seek,p_filter,p_reverse_weight*(1.0-bn->value));
+				_process_node(bn->inputs[2].node,r_prev_anim,p_weight*bn->value,p_time,switched,p_seek,p_filter,p_reverse_weight*bn->value);
 
 			} else {
 
-				rem = _process_node(bn->inputs[1].node,r_prev_anim,p_weight*(1.0+bn->value),p_time,p_seek,p_filter,p_reverse_weight*(1.0+bn->value));
-				_process_node(bn->inputs[0].node,r_prev_anim,p_weight*-bn->value,p_time,p_seek,p_filter,p_reverse_weight*-bn->value);
+				rem = _process_node(bn->inputs[1].node,r_prev_anim,p_weight*(1.0+bn->value),p_time,switched,p_seek,p_filter,p_reverse_weight*(1.0+bn->value));
+				_process_node(bn->inputs[0].node,r_prev_anim,p_weight*-bn->value,p_time,switched,p_seek,p_filter,p_reverse_weight*-bn->value);
 			}
 
 			return rem;
@@ -623,10 +626,10 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 		case NODE_BLEND4: {
 			Blend4Node *bn = static_cast<Blend4Node*>(nb);
 
-			float rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value.x),p_time,p_seek,p_filter,p_reverse_weight*(1.0-bn->value.x));
-			_process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value.x,p_time,p_seek,p_filter,p_reverse_weight*bn->value.x);
-			float rem2 = _process_node(bn->inputs[2].node,r_prev_anim,p_weight*(1.0-bn->value.y),p_time,p_seek,p_filter,p_reverse_weight*(1.0-bn->value.y));
-			_process_node(bn->inputs[3].node,r_prev_anim,p_weight*bn->value.y,p_time,p_seek,p_filter,p_reverse_weight*bn->value.y);
+			float rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value.x),p_time,switched,p_seek,p_filter,p_reverse_weight*(1.0-bn->value.x));
+			_process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value.x,p_time,switched,p_seek,p_filter,p_reverse_weight*bn->value.x);
+			float rem2 = _process_node(bn->inputs[2].node,r_prev_anim,p_weight*(1.0-bn->value.y),p_time,switched,p_seek,p_filter,p_reverse_weight*(1.0-bn->value.y));
+			_process_node(bn->inputs[3].node,r_prev_anim,p_weight*bn->value.y,p_time,switched,p_seek,p_filter,p_reverse_weight*bn->value.y);
 
 			return MAX(rem,rem2);
 
@@ -634,9 +637,9 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 		case NODE_TIMESCALE: {
 			TimeScaleNode *tsn = static_cast<TimeScaleNode*>(nb);
 			if (p_seek)
-				return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,true,p_filter,p_reverse_weight);
+				return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,switched,true,p_filter,p_reverse_weight);
 			else
-				return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time*tsn->scale,false,p_filter,p_reverse_weight);
+				return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time*tsn->scale,switched,false,p_filter,p_reverse_weight);
 
 		} break;
 		case NODE_TIMESEEK: {
@@ -644,12 +647,12 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 			TimeSeekNode *tsn = static_cast<TimeSeekNode*>(nb);
 			if (tsn->seek_pos>=0) {
 
-				float res = _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,tsn->seek_pos,true,p_filter,p_reverse_weight);
+				float res = _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,tsn->seek_pos,switched,true,p_filter,p_reverse_weight);
 				tsn->seek_pos=-1;
 				return res;
 
 			} else
-				return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek);
+				return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,switched,p_seek);
 
 		}   break;
 		case NODE_TRANSITION: {
@@ -658,7 +661,7 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 
 			if (tn->prev<0) {
 
-				float rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight,p_time,p_seek,p_filter,p_reverse_weight);
+				float rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight,p_time,switched,p_seek,p_filter,p_reverse_weight);
 				if (p_seek)
 					tn->time=p_time;
 				else
@@ -687,10 +690,10 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 
 				if (!p_seek && tn->switched) { //just switched
 
-					rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight*(1.0-blend),0,true,p_filter,p_reverse_weight*(1.0-blend));
+					rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight*(1.0-blend),0,true,true,p_filter,p_reverse_weight*(1.0-blend));
 				} else {
 
-					rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight*(1.0-blend),p_time,p_seek,p_filter,p_reverse_weight*(1.0-blend));
+					rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight*(1.0-blend),p_time,switched,p_seek,p_filter,p_reverse_weight*(1.0-blend));
 
 				}
 
@@ -700,10 +703,10 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
 
 
 				if (p_seek) {
-					_process_node(tn->inputs[tn->prev].node,r_prev_anim,p_weight*blend,0,false,p_filter,p_reverse_weight*blend);
+					_process_node(tn->inputs[tn->prev].node,r_prev_anim,p_weight*blend,0,true,false,p_filter,p_reverse_weight*blend);
 					tn->time=p_time;
 				} else {
-					_process_node(tn->inputs[tn->prev].node,r_prev_anim,p_weight*blend,p_time,false,p_filter,p_reverse_weight*blend);
+					_process_node(tn->inputs[tn->prev].node,r_prev_anim,p_weight*blend,p_time,switched,false,p_filter,p_reverse_weight*blend);
 					tn->time+=p_time;
 					tn->prev_xfading-=p_time;
 					if (tn->prev_xfading<0) {
@@ -740,10 +743,10 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
 	AnimationNode *prev=NULL;
 
 	if (reset_request) {
-		_process_node(out_name,&prev, 1.0, 0, true );
+		_process_node(out_name,&prev, 1.0, 0, true, true );
 		reset_request=false;
 	} else
-		_process_node(out_name,&prev, 1.0, p_delta, false );
+		_process_node(out_name,&prev, 1.0, p_delta, false, false );
 
 	if (dirty_caches) {
 		//some animation changed.. ignore this pass

+ 1 - 1
scene/animation/animation_tree_player.h

@@ -267,7 +267,7 @@ private:
 	Map<StringName,NodeBase*> node_map;
 
 	// return time left to finish animation
-	float _process_node(const StringName& p_node,AnimationNode **r_prev_anim, float p_weight,float p_step, bool p_seek=false,const HashMap<NodePath,bool> *p_filter=NULL, float p_reverse_weight=0);
+	float _process_node(const StringName& p_node,AnimationNode **r_prev_anim, float p_weight,float p_step, bool switched, bool p_seek=false,const HashMap<NodePath,bool> *p_filter=NULL, float p_reverse_weight=0);
 	void _process_animation(float p_delta);
 	bool reset_request;
 

+ 47 - 17
tools/editor/editor_layout_dialog.cpp → tools/editor/editor_name_dialog.cpp

@@ -1,5 +1,5 @@
 /*************************************************************************/
-/*  editor_node.cpp                                                      */
+/*  editor_name_dialog.cpp                                               */
 /*************************************************************************/
 /*                       This file is part of:                           */
 /*                           GODOT ENGINE                                */
@@ -27,33 +27,63 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
 
-#include "editor_layout_dialog.h"
+#include "editor_name_dialog.h"
 #include "object_type_db.h"
+#include "os/keyboard.h"
 
-void EditorLayoutDialog::clear_layout_name() {
+void EditorNameDialog::_line_input_event(const InputEvent& p_event) {
 
-	layout_name->clear();
+	if (p_event.type == InputEvent::KEY) {
+
+		if (!p_event.key.pressed)
+			return;
+
+		switch (p_event.key.scancode) {
+			case KEY_ENTER:
+			case KEY_RETURN: {
+
+				if (get_hide_on_ok())
+					hide();
+				ok_pressed();
+				accept_event();
+			} break;
+			case KEY_ESCAPE: {
+
+				hide();
+				accept_event();
+			} break;
+		}
+	}
 }
 
-void EditorLayoutDialog::ok_pressed() {
+void EditorNameDialog::_post_popup() {
 
-	if (layout_name->get_text()!="") {
-		emit_signal("layout_selected", layout_name->get_text());
+	ConfirmationDialog::_post_popup();
+	name->clear();
+	name->grab_focus();
+}
+
+void EditorNameDialog::ok_pressed() {
+
+	if (name->get_text()!="") {
+		emit_signal("name_confirmed", name->get_text());
 	}
 }
 
-void EditorLayoutDialog::_bind_methods() {
+void EditorNameDialog::_bind_methods() {
 
-	ADD_SIGNAL(MethodInfo("layout_selected",PropertyInfo( Variant::STRING,"layout_name")));
+	ObjectTypeDB::bind_method("_line_input_event",&EditorNameDialog::_line_input_event);
+
+	ADD_SIGNAL(MethodInfo("name_confirmed",PropertyInfo( Variant::STRING,"name")));
 }
 
-EditorLayoutDialog::EditorLayoutDialog()
+EditorNameDialog::EditorNameDialog()
 {
-
-	layout_name = memnew( LineEdit );
-	layout_name->set_margin(MARGIN_TOP,5);
-	layout_name->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
-	layout_name->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
-	add_child(layout_name);
-	move_child(layout_name, get_label()->get_index()+1);
+	name = memnew( LineEdit );
+	add_child(name);
+	move_child(name, get_label()->get_index()+1);
+	name->set_margin(MARGIN_TOP,5);
+	name->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
+	name->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
+	name->connect("input_event", this, "_line_input_event");
 }

+ 13 - 9
tools/editor/editor_layout_dialog.h → tools/editor/editor_name_dialog.h

@@ -1,5 +1,5 @@
 /*************************************************************************/
-/*  editor_layout_dialog.h                                                        */
+/*  editor_name_dialog.h                                                 */
 /*************************************************************************/
 /*                       This file is part of:                           */
 /*                           GODOT ENGINE                                */
@@ -27,27 +27,31 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
 
-#ifndef EDITOR_LAYOUT_DIALOG_H
-#define EDITOR_LAYOUT_DIALOG_H
+#ifndef EDITOR_NAME_DIALOG_H
+#define EDITOR_NAME_DIALOG_H
 
 #include "scene/gui/dialogs.h"
 #include "scene/gui/line_edit.h"
 
-class EditorLayoutDialog : public ConfirmationDialog {
+class EditorNameDialog : public ConfirmationDialog {
 
-	OBJ_TYPE( EditorLayoutDialog, ConfirmationDialog );
+	OBJ_TYPE( EditorNameDialog, ConfirmationDialog );
 
-	LineEdit *layout_name;
+	LineEdit *name;
+
+	void _line_input_event(const InputEvent& p_event);
 
 protected:
 
 	static void _bind_methods();
 	virtual void ok_pressed();
+	virtual void _post_popup();
 
 public:
-	void clear_layout_name();
 
-	EditorLayoutDialog();
+	LineEdit* get_line_edit() { return name; }
+
+	EditorNameDialog();
 };
 
-#endif // EDITOR_LAYOUT_DIALOG_H
+#endif // EDITOR_NAME_DIALOG_H

+ 3 - 7
tools/editor/editor_node.cpp

@@ -4124,7 +4124,6 @@ void EditorNode::_bind_methods() {
 	ObjectTypeDB::bind_method("_dock_move_right",&EditorNode::_dock_move_right);
 
 	ObjectTypeDB::bind_method("_layout_menu_option",&EditorNode::_layout_menu_option);
-	ObjectTypeDB::bind_method("_layout_dialog_action",&EditorNode::_dialog_action);
 
 	ObjectTypeDB::bind_method("set_current_scene",&EditorNode::set_current_scene);
 	ObjectTypeDB::bind_method("set_current_version",&EditorNode::set_current_version);
@@ -4624,7 +4623,6 @@ void EditorNode::_layout_menu_option(int p_id) {
 		case SETTINGS_LAYOUT_SAVE: {
 
 			current_option=p_id;
-			layout_dialog->clear_layout_name();
 			layout_dialog->set_title("Save Layout");
 			layout_dialog->get_ok()->set_text("Save");
 			layout_dialog->popup_centered();
@@ -4632,7 +4630,6 @@ void EditorNode::_layout_menu_option(int p_id) {
 		case SETTINGS_LAYOUT_DELETE: {
 
 			current_option=p_id;
-			layout_dialog->clear_layout_name();
 			layout_dialog->set_title("Delete Layout");
 			layout_dialog->get_ok()->set_text("Delete");
 			layout_dialog->popup_centered();
@@ -4651,8 +4648,7 @@ void EditorNode::_layout_menu_option(int p_id) {
 				return; //no config
 			}
 
-			int idx=editor_layouts->get_item_index(p_id);
-			_load_docks_from_config(config, editor_layouts->get_item_text(idx));
+			_load_docks_from_config(config, editor_layouts->get_item_text(p_id));
 			_save_docks();
 
 		}
@@ -5428,13 +5424,13 @@ EditorNode::EditorNode() {
 	p->add_separator();
 	p->add_item("About",SETTINGS_ABOUT);
 
-	layout_dialog = memnew( EditorLayoutDialog );
+	layout_dialog = memnew( EditorNameDialog );
 	gui_base->add_child(layout_dialog);
 	layout_dialog->set_hide_on_ok(false);
 	layout_dialog->set_size(Size2(175, 70));
 	confirm_error = memnew( AcceptDialog  );
 	layout_dialog->add_child(confirm_error);
-	layout_dialog->connect("layout_selected", this,"_layout_dialog_action");
+	layout_dialog->connect("name_confirmed", this,"_dialog_action");
 
 	sources_button = memnew( ToolButton );
 	right_menu_hb->add_child(sources_button);

+ 2 - 2
tools/editor/editor_node.h

@@ -76,7 +76,7 @@
 #include "editor_reimport_dialog.h"
 #include "import_settings.h"
 #include "tools/editor/editor_plugin.h"
-#include "tools/editor/editor_layout_dialog.h"
+#include "tools/editor/editor_name_dialog.h"
 
 #include "fileserver/editor_file_server.h"
 #include "editor_resource_preview.h"
@@ -290,7 +290,7 @@ class EditorNode : public Node {
 
 	Ref<ConfigFile> default_theme;
 	PopupMenu *editor_layouts;
-	EditorLayoutDialog *layout_dialog;
+	EditorNameDialog *layout_dialog;
 	AcceptDialog *confirm_error;
 
 	//OptimizedPresetsDialog *optimized_presets;

+ 7 - 0
tools/editor/project_manager.cpp

@@ -348,6 +348,13 @@ struct ProjectItem {
 	_FORCE_INLINE_ bool operator ==(const ProjectItem& l) const { return project==l.project; }
 };
 
+void ProjectManager::_notification(int p_what) {
+
+	if (p_what==NOTIFICATION_ENTER_TREE) {
+
+		get_tree()->set_editor_hint(true);
+	}
+}
 
 void ProjectManager::_panel_draw(Node *p_hb) {
 

+ 1 - 0
tools/editor/project_manager.h

@@ -85,6 +85,7 @@ class ProjectManager : public Control {
 
 protected:
 
+	void _notification(int p_what);
 	static void _bind_methods();
 public:
 	ProjectManager();

+ 60 - 4
tools/editor/project_settings.cpp

@@ -338,6 +338,15 @@ void ProjectSettings::_action_button_pressed(Object* p_obj, int p_column,int p_i
 		add_at="input/"+ti->get_text(0);
 
 	} else if (p_id==2) {
+		//rename
+
+		add_at="input/"+ti->get_text(0);
+		rename_action->popup_centered();
+		rename_action->get_line_edit()->set_text(ti->get_text(0));
+		rename_action->get_line_edit()->set_cursor_pos(ti->get_text(0).length());
+		rename_action->get_line_edit()->select_all();
+
+	} else if (p_id==3) {
 		//remove
 
 		if (ti->get_parent()==input_editor->get_root()) {
@@ -418,7 +427,9 @@ void ProjectSettings::_update_actions() {
 		item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
 		item->set_text(0,name);
 		item->add_button(0,get_icon("Add","EditorIcons"),1);
-		item->add_button(0,get_icon("Remove","EditorIcons"),2);
+		if (!Globals::get_singleton()->get_input_presets().find(pi.name))
+			item->add_button(0,get_icon("Rename","EditorIcons"),2);
+		item->add_button(0,get_icon("Remove","EditorIcons"),3);
 		item->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
 		item->set_editable(0,true);
 		item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED);
@@ -486,7 +497,7 @@ void ProjectSettings::_update_actions() {
 					action->set_icon(0,get_icon("JoyAxis","EditorIcons"));
 				} break;
 			}
-			action->add_button(0,get_icon("Remove","EditorIcons"),2);
+			action->add_button(0,get_icon("Remove","EditorIcons"),3);
 			action->set_metadata(0,i);
 		}
 	}
@@ -616,6 +627,45 @@ void ProjectSettings::_action_add() {
 
 }
 
+void ProjectSettings::_action_rename(const String &p_name) {
+
+
+	if (p_name.find("/")!=-1 || p_name.find(":")!=-1 || p_name=="") {
+		message->set_text("Invalid Action (Anything goes but / or :).");
+		message->popup_centered(Size2(300,100));
+		return;
+	}
+
+	String new_name = "input/"+p_name;
+
+	if (Globals::get_singleton()->has(new_name)) {
+		message->set_text("Action '"+p_name+"' already exists!.");
+		message->popup_centered(Size2(300,100));
+		return;
+	}
+
+	int order = Globals::get_singleton()->get_order(add_at);
+	Array va = Globals::get_singleton()->get(add_at);
+	bool persisting = Globals::get_singleton()->is_persisting(add_at);
+
+	undo_redo->create_action("Rename Input Action Event");
+	undo_redo->add_do_method(Globals::get_singleton(),"clear",add_at);
+	undo_redo->add_do_method(Globals::get_singleton(),"set",new_name,va);
+	undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",new_name,persisting);
+	undo_redo->add_do_method(Globals::get_singleton(),"set_order",new_name,order);
+	undo_redo->add_undo_method(Globals::get_singleton(),"clear",new_name);
+	undo_redo->add_undo_method(Globals::get_singleton(),"set",add_at,va);
+	undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",add_at,persisting);
+	undo_redo->add_undo_method(Globals::get_singleton(),"set_order",add_at,order);
+	undo_redo->add_do_method(this,"_update_actions");
+	undo_redo->add_undo_method(this,"_update_actions");
+	undo_redo->add_do_method(this,"_settings_changed");
+	undo_redo->add_undo_method(this,"_settings_changed");
+	undo_redo->commit_action();
+
+	rename_action->hide();
+}
+
 
 void ProjectSettings::_item_checked(const String& p_item, bool p_check) {
 
@@ -1219,6 +1269,7 @@ void ProjectSettings::_bind_methods() {
 	ObjectTypeDB::bind_method(_MD("_action_adds"),&ProjectSettings::_action_adds);
 	ObjectTypeDB::bind_method(_MD("_action_persist_toggle"),&ProjectSettings::_action_persist_toggle);
 	ObjectTypeDB::bind_method(_MD("_action_button_pressed"),&ProjectSettings::_action_button_pressed);
+	ObjectTypeDB::bind_method(_MD("_action_rename"),&ProjectSettings::_action_rename);
 	ObjectTypeDB::bind_method(_MD("_update_actions"),&ProjectSettings::_update_actions);
 	ObjectTypeDB::bind_method(_MD("_wait_for_key"),&ProjectSettings::_wait_for_key);
 	ObjectTypeDB::bind_method(_MD("_add_item"),&ProjectSettings::_add_item);
@@ -1438,12 +1489,17 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
 	add_child(popup_add);
 	popup_add->connect("item_pressed",this,"_add_item");
 
+	rename_action = memnew( EditorNameDialog );
+	add_child(rename_action);
+	rename_action->set_hide_on_ok(false);
+	rename_action->set_size(Size2(200, 70));
+	rename_action->set_title("Rename Input Action");
+	rename_action->connect("name_confirmed", this,"_action_rename");
+
 	press_a_key = memnew( ConfirmationDialog );
 	press_a_key->set_focus_mode(FOCUS_ALL);
 	add_child(press_a_key);
 
-
-
 	l = memnew( Label );
 	l->set_text("Press a Key..");
 	l->set_area_as_parent_rect();

+ 4 - 0
tools/editor/project_settings.h

@@ -34,6 +34,7 @@
 #include "optimized_save_dialog.h"
 #include "undo_redo.h"
 #include "editor_data.h"
+#include "editor_name_dialog.h"
 //#include "project_export_settings.h"
 
 class ProjectSettings : public AcceptDialog {
@@ -66,6 +67,8 @@ class ProjectSettings : public AcceptDialog {
 	Label *device_index_label;
 	MenuButton *popup_platform;
 
+	EditorNameDialog *rename_action;
+
 	LineEdit *action_name;
 	Tree *input_editor;
 	bool setting;
@@ -106,6 +109,7 @@ class ProjectSettings : public AcceptDialog {
 
 	void _action_adds(String);
 	void _action_add();
+	void _action_rename(const String& p_name);
 	void _device_input_add();
 
 	void _item_checked(const String& p_item, bool p_check);