diff options
-rw-r--r-- | SConstruct | 5 | ||||
-rw-r--r-- | bin/tests/test_math.cpp | 2 | ||||
-rw-r--r-- | core/hashfuncs.h | 5 | ||||
-rw-r--r-- | core/variant_parser.cpp | 8 | ||||
-rw-r--r-- | doc/base/classes.xml | 16 | ||||
-rw-r--r-- | main/input_default.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.cpp | 15 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.h | 1 | ||||
-rw-r--r-- | modules/theora/SCsub | 50 | ||||
-rw-r--r-- | modules/visual_script/visual_script_builtin_funcs.cpp | 17 | ||||
-rw-r--r-- | modules/visual_script/visual_script_builtin_funcs.h | 1 | ||||
-rw-r--r-- | platform/android/detect.py | 19 | ||||
-rw-r--r-- | platform/osx/detect.py | 2 | ||||
-rw-r--r-- | platform/windows/detect.py | 6 | ||||
-rw-r--r-- | platform/x11/detect.py | 2 | ||||
-rw-r--r-- | scene/gui/base_button.cpp | 10 | ||||
-rw-r--r-- | scene/gui/button_array.cpp | 60 | ||||
-rw-r--r-- | scene/gui/button_array.h | 8 | ||||
-rw-r--r-- | scene/gui/dialogs.cpp | 35 | ||||
-rw-r--r-- | tools/editor/io_plugins/editor_scene_import_plugin.cpp | 20 |
20 files changed, 215 insertions, 71 deletions
diff --git a/SConstruct b/SConstruct index 10bf3b3625..14aba28818 100644 --- a/SConstruct +++ b/SConstruct @@ -97,9 +97,8 @@ env_base.__class__.disable_module = methods.disable_module env_base.__class__.add_source_files = methods.add_source_files env_base.__class__.use_windows_spawn_fix = methods.use_windows_spawn_fix -env_base["x86_opt_gcc"]=False -env_base["x86_opt_vc"]=False -env_base["armv7_opt_gcc"]=False +env_base["x86_libtheora_opt_gcc"]=False +env_base["x86_libtheora_opt_vc"]=False customs = ['custom.py'] diff --git a/bin/tests/test_math.cpp b/bin/tests/test_math.cpp index e5667bff64..9329002f76 100644 --- a/bin/tests/test_math.cpp +++ b/bin/tests/test_math.cpp @@ -516,7 +516,7 @@ MainLoop* test() { { - Vector<int32_t> hashes; + Vector<int> hashes; List<StringName> tl; ObjectTypeDB::get_type_list(&tl); diff --git a/core/hashfuncs.h b/core/hashfuncs.h index a917ee5edb..6c029a3458 100644 --- a/core/hashfuncs.h +++ b/core/hashfuncs.h @@ -74,7 +74,10 @@ static inline uint32_t hash_djb2_one_float(float p_in,uint32_t p_prev=5381) { float f; uint32_t i; } u; - u.f=p_in; + + // handle -0 case + if (p_in==0.0f) u.f=0.0f; + else u.f=p_in; return ((p_prev<<5)+p_prev)+u.i; } diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 6b3828a572..5ed2415e36 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -1177,16 +1177,16 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in } else if (id=="IntArray") { - Vector<int32_t> args; - Error err = _parse_construct<int32_t>(p_stream,args,line,r_err_str); + Vector<int> args; + Error err = _parse_construct<int>(p_stream,args,line,r_err_str); if (err) return err; - DVector<int32_t> arr; + DVector<int> arr; { int len=args.size(); arr.resize(len); - DVector<int32_t>::Write w = arr.write(); + DVector<int>::Write w = arr.write(); for(int i=0;i<len;i++) { w[i]=int(args[i]); } diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 0a323d5c8e..4e0ba53f48 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -22262,8 +22262,10 @@ </class> <class name="NetworkedMultiplayerENet" inherits="NetworkedMultiplayerPeer" category="Core"> <brief_description> + PacketPeer implementation using the ENet library. </brief_description> <description> + A connection (or a listening server) that should be passed to [method SceneTree.set_network_peer]. Socket events can be handled by connecting to [SceneTree] signals. </description> <methods> <method name="close_connection"> @@ -22618,6 +22620,7 @@ Nodes can also process input events. When set, the [method _input] function will be called for each input that the program receives. In many cases, this can be overkill (unless used for simple projects), and the [method _unhandled_input] function might be preferred; it is called when the input event was not handled by anyone else (typically, GUI [Control] nodes), ensuring that the node only receives the events that were meant for it. To keep track of the scene hierarchy (especially when instancing scenes into other scenes), an "owner" can be set for the node with [method set_owner]. This keeps track of who instanced what. This is mostly useful when writing editors and tools, though. Finally, when a node is freed with [method free] or [method queue_free], it will also free all its children. + [b]Networking with nodes:[/b] After connecting to a server (or making one, see [NetworkedMultiplayerENet]) it is possible to use the built-in RPC (remote procedure call) system to easily communicate over the network. By calling [method rpc] with a method name, it will be called locally, and in all connected peers (peers = clients and the server that accepts connections), with behaviour varying depending on the network mode ([method set_network_mode]) on the receiving peer. To identify which [Node] receives the RPC call Godot will use it's [NodePath] (make sure node names are the same on all peers). </description> <methods> <method name="_enter_tree" qualifiers="virtual"> @@ -23055,6 +23058,7 @@ <argument index="0" name="method" type="String"> </argument> <description> + Send a remote procedure call request to all peers on the network (and locally), optionally sending additional data as arguments. Call request will be received by nodes with the same [NodePath]. </description> </method> <method name="rpc_config"> @@ -23063,6 +23067,7 @@ <argument index="1" name="mode" type="int"> </argument> <description> + Change the method's RPC mode (one of RPC_MODE_* constants). </description> </method> <method name="rpc_id" qualifiers="vararg"> @@ -23071,12 +23076,14 @@ <argument index="1" name="method" type="String"> </argument> <description> + Send a [method rpc] to a specific peer identified by [i]peer_id[/i]. </description> </method> <method name="rpc_unreliable" qualifiers="vararg"> <argument index="0" name="method" type="String"> </argument> <description> + Send a [method rpc] using an unreliable protocol. </description> </method> <method name="rpc_unreliable_id" qualifiers="vararg"> @@ -23085,6 +23092,7 @@ <argument index="1" name="method" type="String"> </argument> <description> + Send a [method rpc] to a specific peer identified by [i]peer_id[/i] using an unreliable protocol. </description> </method> <method name="rset"> @@ -23093,6 +23101,7 @@ <argument index="1" name="value" type="Variant"> </argument> <description> + Remotely change property's value on other peers (and locally). </description> </method> <method name="rset_config"> @@ -23101,6 +23110,7 @@ <argument index="1" name="mode" type="int"> </argument> <description> + Change the property's RPC mode (one of RPC_MODE_* constants). </description> </method> <method name="rset_id"> @@ -23111,6 +23121,7 @@ <argument index="2" name="value" type="Variant"> </argument> <description> + Remotely change property's value on a specific peer identified by [i]peer_id[/i]. </description> </method> <method name="rset_unreliable"> @@ -23119,6 +23130,7 @@ <argument index="1" name="value" type="Variant"> </argument> <description> + Remotely change property's value on other peers (and locally) using an unreliable protocol. </description> </method> <method name="rset_unreliable_id"> @@ -23129,6 +23141,7 @@ <argument index="2" name="value" type="Variant"> </argument> <description> + Remotely change property's value on a specific peer identified by [i]peer_id[/i] using an unreliable protocol. </description> </method> <method name="set_display_folded"> @@ -23162,6 +23175,7 @@ <argument index="0" name="mode" type="int"> </argument> <description> + Change the networking mode of the [Node], where [i]mode[/i] is one of the constants NETWORK_MODE_*. Master nodes will only call gdscript methods defined as [i]master func[/i] if a RPC call is received (slave nodes will only call [i]slave func[/i]; both will call [i]remote func[/i] if the call is not local, and [i]sync func[/i] in any case). Inherit mode looks at the parent node to determine the value (root node depends on the [SceneTree] having a networking peer set with [method SceneTree.set_network_peer]) </description> </method> <method name="set_owner"> @@ -35261,6 +35275,7 @@ <return type="bool"> </return> <description> + Returns true if this SceneTree's [NetworkedMultiplayerPeer] is in server mode (listening for connections). </description> </method> <method name="is_paused" qualifiers="const"> @@ -35357,6 +35372,7 @@ <argument index="0" name="peer" type="NetworkedMultiplayerPeer"> </argument> <description> + Set the peer object to handle the RPC system (effectively enabling networking). Depending on the peer itself, the SceneTree will become a network server (check with [method is_network_server()]) and will set root node's network mode to master (see NETWORK_MODE_* constants in [Node]), or it will become a regular peer with root node set to slave. All child nodes are set to inherit the network mode by default. Handling of networking-related events (connection, disconnection, new clients) is done by connecting to SceneTree's signals. </description> </method> <method name="set_pause"> diff --git a/main/input_default.cpp b/main/input_default.cpp index 92f4a6fb72..c60fcd2243 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -1050,8 +1050,8 @@ void InputDefault::parse_mapping(String p_mapping) { if (entry[idx] == "") continue; - String from = entry[idx].get_slice(":", 1); - String to = entry[idx].get_slice(":", 0); + String from = entry[idx].get_slice(":", 1).replace(" ", ""); + String to = entry[idx].get_slice(":", 0).replace(" ", ""); JoyEvent to_event = _find_to_event(to); if (to_event.type == -1) diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index e224ce4718..d3f7dcd35f 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -88,6 +88,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "convert", "typeof", "type_exists", + "char", "str", "print", "printt", @@ -538,6 +539,12 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_ret = ObjectTypeDB::type_exists(*p_args[0]); } break; + case TEXT_CHAR: { + VALIDATE_ARG_COUNT(1); + VALIDATE_ARG_NUM(0); + CharType result[2] = {*p_args[0], 0}; + r_ret=String(result); + } break; case TEXT_STR: { String str; @@ -1134,6 +1141,7 @@ bool GDFunctions::is_deterministic(Function p_func) { case TYPE_CONVERT: case TYPE_OF: case TYPE_EXISTS: + case TEXT_CHAR: case TEXT_STR: case COLOR8: // enable for debug only, otherwise not desirable - case GEN_RANGE: @@ -1404,6 +1412,13 @@ MethodInfo GDFunctions::get_info(Function p_func) { return mi; } break; + case TEXT_CHAR: { + + MethodInfo mi("char",PropertyInfo(Variant::INT,"ascii")); + mi.return_val.type=Variant::STRING; + return mi; + + } break; case TEXT_STR: { MethodInfo mi("str",PropertyInfo(Variant::NIL,"what"),PropertyInfo(Variant::NIL,"...")); diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h index c78956fe20..f444bb3b5b 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gd_functions.h @@ -82,6 +82,7 @@ public: TYPE_CONVERT, TYPE_OF, TYPE_EXISTS, + TEXT_CHAR, TEXT_STR, TEXT_PRINT, TEXT_PRINT_TABBED, diff --git a/modules/theora/SCsub b/modules/theora/SCsub index cdb78e955e..cf1a8e6707 100644 --- a/modules/theora/SCsub +++ b/modules/theora/SCsub @@ -7,63 +7,63 @@ env_theora = env_modules.Clone() if (env["libtheora"] != "system"): # builtin thirdparty_dir = "#thirdparty/libtheora/" thirdparty_sources = [ - "analyze.c", - "apiwrapper.c", + #"analyze.c", + #"apiwrapper.c", "bitpack.c", "cpu.c", - "decapiwrapper.c", + #"decapiwrapper.c", "decinfo.c", "decode.c", "dequant.c", - "encapiwrapper.c", - "encfrag.c", - "encinfo.c", - "encode.c", - "encoder_disabled.c", - "enquant.c", - "fdct.c", + #"encapiwrapper.c", + #"encfrag.c", + #"encinfo.c", + #"encode.c", + #"encoder_disabled.c", + #"enquant.c", + #"fdct.c", "fragment.c", "huffdec.c", - "huffenc.c", + #"huffenc.c", "idct.c", "info.c", "internal.c", - "mathops.c", - "mcenc.c", + #"mathops.c", + #"mcenc.c", "quant.c", - "rate.c", + #"rate.c", "state.c", - "tokenize.c", + #"tokenize.c", ] thirdparty_sources_x86 = [ - "x86/mmxencfrag.c", - "x86/mmxfdct.c", + #"x86/mmxencfrag.c", + #"x86/mmxfdct.c", "x86/mmxfrag.c", "x86/mmxidct.c", "x86/mmxstate.c", - "x86/sse2fdct.c", - "x86/x86enc.c", + #"x86/sse2fdct.c", + #"x86/x86enc.c", "x86/x86state.c", ] thirdparty_sources_x86_vc = [ - "x86_vc/mmxencfrag.c", - "x86_vc/mmxfdct.c", + #"x86_vc/mmxencfrag.c", + #"x86_vc/mmxfdct.c", "x86_vc/mmxfrag.c", "x86_vc/mmxidct.c", "x86_vc/mmxstate.c", - "x86_vc/x86enc.c", + #"x86_vc/x86enc.c", "x86_vc/x86state.c", ] - if (env["x86_opt_gcc"]): + if (env["x86_libtheora_opt_gcc"]): thirdparty_sources += thirdparty_sources_x86 - if (env["x86_opt_vc"]): + if (env["x86_libtheora_opt_vc"]): thirdparty_sources += thirdparty_sources_x86_vc - if (env["x86_opt_gcc"] or env["x86_opt_vc"]): + if (env["x86_libtheora_opt_gcc"] or env["x86_libtheora_opt_vc"]): env_theora.Append(CCFLAGS = ["-DOC_X86_ASM"]) thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 24a44d3506..2bfb6bc9ea 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -55,6 +55,7 @@ const char* VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX "convert", "typeof", "type_exists", + "char", "str", "print", "printerr", @@ -141,6 +142,7 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) { case LOGIC_NEAREST_PO2: case OBJ_WEAKREF: case TYPE_OF: + case TEXT_CHAR: case TEXT_STR: case TEXT_PRINT: case TEXT_PRINTERR: @@ -362,6 +364,12 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const return PropertyInfo(Variant::STRING,"type"); } break; + case TEXT_CHAR: { + + return PropertyInfo(Variant::INT,"ascii"); + + + } break; case TEXT_STR: { return PropertyInfo(Variant::NIL,"value"); @@ -517,6 +525,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons t=Variant::BOOL; } break; + case TEXT_CHAR: case TEXT_STR: { t=Variant::STRING; @@ -975,6 +984,13 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp *r_return = ObjectTypeDB::type_exists(*p_inputs[0]); } break; + case VisualScriptBuiltinFunc::TEXT_CHAR: { + + CharType result[2] = {*p_inputs[0], 0}; + + *r_return=String(result); + + } break; case VisualScriptBuiltinFunc::TEXT_STR: { String str = *p_inputs[0]; @@ -1213,6 +1229,7 @@ void register_visual_script_builtin_func_node() { VisualScriptLanguage::singleton->add_register_func("functions/built_in/convert",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_CONVERT>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/typeof",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_OF>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/type_exists",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_EXISTS>); + VisualScriptLanguage::singleton->add_register_func("functions/built_in/char",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_CHAR>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/str",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_STR>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/print",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINT>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/printerr",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTERR>); diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h index 000230d84f..8b0d70c1ea 100644 --- a/modules/visual_script/visual_script_builtin_funcs.h +++ b/modules/visual_script/visual_script_builtin_funcs.h @@ -57,6 +57,7 @@ public: TYPE_CONVERT, TYPE_OF, TYPE_EXISTS, + TEXT_CHAR, TEXT_STR, TEXT_PRINT, TEXT_PRINTERR, diff --git a/platform/android/detect.py b/platform/android/detect.py index 8d56dbcdaa..acf4ce412a 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -96,7 +96,7 @@ def configure(env): if env['android_arch']=='x86': env['NDK_TARGET']=env['NDK_TARGET_X86'] - env["x86_opt_gcc"]=True + env["x86_libtheora_opt_gcc"]=True if env['PLATFORM'] == 'win32': env.Tool('gcc') @@ -122,19 +122,20 @@ def configure(env): gcc_path=env["ANDROID_NDK_ROOT"]+"/toolchains/"+env["NDK_TARGET"]+"/prebuilt/"; - if (sys.platform.find("linux")==0): - if (platform.architecture()[0]=='64bit' or os.path.isdir(gcc_path+"linux-x86_64/bin")): # check was not working + if (sys.platform.startswith("linux")): + if (platform.machine().endswith('64')): gcc_path=gcc_path+"/linux-x86_64/bin" else: gcc_path=gcc_path+"/linux-x86/bin" - elif (sys.platform=="darwin"): - gcc_path=gcc_path+"/darwin-x86_64/bin" #this may be wrong + elif (sys.platform.startswith("darwin")): + gcc_path=gcc_path+"/darwin-x86_64/bin" env['SHLINKFLAGS'][1] = '-shared' env['SHLIBSUFFIX'] = '.so' - elif (os.name=="nt"): - gcc_path=gcc_path+"/windows-x86_64/bin" #this may be wrong - - + elif (os.platform.startswith('win')): + if (platform.machine().endswith('64')): + gcc_path=gcc_path+"/windows-x86_64/bin" + else: + gcc_path=gcc_path+"/windows-x86/bin" env['ENV']['PATH'] = gcc_path+":"+env['ENV']['PATH'] if env['android_arch']=='x86': diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 8d8e882527..f8b2153aee 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -102,4 +102,4 @@ def configure(env): env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) - env["x86_opt_gcc"]=True + env["x86_libtheora_opt_gcc"]=True diff --git a/platform/windows/detect.py b/platform/windows/detect.py index af9a0aca41..a5b26930be 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -279,13 +279,13 @@ def configure(env): # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the propper command prompt # that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with) env["bits"]="32" - env["x86_opt_vc"]=True + env["x86_libtheora_opt_vc"]=True print "Detected MSVC compiler: "+compiler_version_str # If building for 64bit architecture, disable assembly optimisations for 32 bit builds (theora as of writting)... vc compiler for 64bit can not compile _asm if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): env["bits"]="64" - env["x86_opt_vc"]=False + env["x86_libtheora_opt_vc"]=False print "Compiled program architecture will be a 64 bit executable (forcing bits=64)." elif (compiler_version_str=="x86" or compiler_version_str == "amd64_x86"): print "Compiled program architecture will be a 32 bit executable. (forcing bits=32)." @@ -365,7 +365,7 @@ def configure(env): env['AR'] = mingw_prefix+"ar" env['RANLIB'] = mingw_prefix+"ranlib" env['LD'] = mingw_prefix+"g++" - env["x86_opt_gcc"]=True + env["x86_libtheora_opt_gcc"]=True #env['CC'] = "winegcc" #env['CXX'] = "wineg++" diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 92bc58d7b0..eb71ac7409 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -237,5 +237,5 @@ def configure(env): list_of_x86 = ['x86_64', 'x86', 'i386', 'i586'] if any(platform.machine() in s for s in list_of_x86): - env["x86_opt_gcc"]=True + env["x86_libtheora_opt_gcc"]=True diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 6479dd2d02..64d68738b2 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -243,12 +243,22 @@ void BaseButton::_notification(int p_what) { update(); } } + + if (p_what==NOTIFICATION_FOCUS_ENTER) { + + status.hovering=true; + update(); + } if (p_what==NOTIFICATION_FOCUS_EXIT) { if (status.pressing_button && status.press_attempt) { status.press_attempt=false; status.pressing_button=0; + status.hovering=false; + update(); + } else if (status.hovering) { + status.hovering=false; update(); } } diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp index be48296110..df1872380d 100644 --- a/scene/gui/button_array.cpp +++ b/scene/gui/button_array.cpp @@ -60,6 +60,8 @@ bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) { String f = n.get_slicec('/',2); if (f=="text") buttons[idx].text=p_value; + else if (f=="tooltip") + buttons[idx].tooltip=p_value; else if (f=="icon") buttons[idx].icon=p_value; else @@ -95,6 +97,8 @@ bool ButtonArray::_get(const StringName& p_name,Variant &r_ret) const { String f = n.get_slicec('/',2); if (f=="text") r_ret=buttons[idx].text; + else if (f=="tooltip") + r_ret=buttons[idx].tooltip; else if (f=="icon") r_ret=buttons[idx].icon; else @@ -115,6 +119,7 @@ void ButtonArray::_get_property_list( List<PropertyInfo> *p_list) const { for(int i=0;i<buttons.size();i++) { String base="button/"+itos(i)+"/"; p_list->push_back( PropertyInfo( Variant::STRING, base+"text")); + p_list->push_back( PropertyInfo( Variant::STRING, base+"tooltip")); p_list->push_back( PropertyInfo( Variant::OBJECT, base+"icon",PROPERTY_HINT_RESOURCE_TYPE,"Texture")); } if (buttons.size()>0) { @@ -168,8 +173,12 @@ Size2 ButtonArray::get_minimum_size() const { void ButtonArray::_notification(int p_what) { switch(p_what) { + case NOTIFICATION_MOUSE_EXIT:{ + hover=-1; + update(); + }break; case NOTIFICATION_READY:{ - MethodInfo mi; + MethodInfo mi; mi.name="mouse_sub_enter"; add_user_signal(mi); @@ -245,8 +254,12 @@ void ButtonArray::_notification(int p_what) { Ref<Font> f; Color c; + Point2 sbsize; + Point2 sbofs; if (i==selected) { draw_style_box(style_selected,r); + sbsize=style_selected->get_minimum_size(); + sbofs=style_selected->get_offset(); f=font_selected; c=color_selected; if (has_focus()) @@ -256,6 +269,8 @@ void ButtonArray::_notification(int p_what) { draw_style_box(style_hover,r); else draw_style_box(style_normal,r); + sbsize=style_selected->get_minimum_size(); + sbofs=style_normal->get_offset(); f=font_normal; c=color_normal; } @@ -265,7 +280,7 @@ void ButtonArray::_notification(int p_what) { ssize.x+=buttons[i].icon->get_width(); } - Point2 text_ofs=((r.size-ssize)/2.0+Point2(0,f->get_ascent())).floor(); + Point2 text_ofs=((r.size-ssize-sbsize)/2.0+Point2(0,f->get_ascent())).floor()+sbofs; if (buttons[i].icon.is_valid()) { draw_texture(buttons[i].icon,r.pos+Point2(text_ofs.x,Math::floor((r.size.height-buttons[i].icon->get_height())/2.0))); @@ -349,6 +364,18 @@ void ButtonArray::_input_event(const InputEvent& p_event) { } +String ButtonArray::get_tooltip(const Point2& p_pos) const { + + int ofs = orientation==HORIZONTAL ? p_pos.x: p_pos.y; + for(int i=0;i<buttons.size();i++) { + + if (ofs>=buttons[i]._pos_cache && ofs<buttons[i]._pos_cache+buttons[i]._size_cache) + return buttons[i].tooltip; + + } + return Control::get_tooltip(p_pos); +} + void ButtonArray::set_align(Align p_align) { align=p_align; @@ -362,10 +389,11 @@ ButtonArray::Align ButtonArray::get_align() const { } -void ButtonArray::add_button(const String& p_text) { +void ButtonArray::add_button(const String& p_text,const String& p_tooltip) { Button button; button.text=p_text; + button.tooltip=p_tooltip; buttons.push_back(button); update(); @@ -375,11 +403,12 @@ void ButtonArray::add_button(const String& p_text) { minimum_size_changed(); } -void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_text) { +void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_text,const String& p_tooltip) { Button button; button.text=p_text; button.icon=p_icon; + button.tooltip=p_tooltip; buttons.push_back(button); if (selected==-1) selected=0; @@ -397,6 +426,13 @@ void ButtonArray::set_button_text(int p_button, const String& p_text) { } +void ButtonArray::set_button_tooltip(int p_button, const String& p_text) { + + ERR_FAIL_INDEX(p_button,buttons.size()); + buttons[p_button].tooltip=p_text; + +} + void ButtonArray::set_button_icon(int p_button, const Ref<Texture>& p_icon) { ERR_FAIL_INDEX(p_button,buttons.size()); @@ -411,6 +447,12 @@ String ButtonArray::get_button_text(int p_button) const { return buttons[p_button].text; } +String ButtonArray::get_button_tooltip(int p_button) const { + + ERR_FAIL_INDEX_V(p_button,buttons.size(),""); + return buttons[p_button].tooltip; +} + Ref<Texture> ButtonArray::get_button_icon(int p_button) const { ERR_FAIL_INDEX_V(p_button,buttons.size(),Ref<Texture>()); @@ -465,18 +507,22 @@ int ButtonArray::get_button_count() const { void ButtonArray::get_translatable_strings(List<String> *p_strings) const { - for(int i=0;i<buttons.size();i++) + for(int i=0;i<buttons.size();i++) { p_strings->push_back(buttons[i].text); + p_strings->push_back(buttons[i].tooltip); + } } void ButtonArray::_bind_methods() { - ObjectTypeDB::bind_method(_MD("add_button","text"),&ButtonArray::add_button); - ObjectTypeDB::bind_method(_MD("add_icon_button","icon:Texture","text"),&ButtonArray::add_icon_button,DEFVAL("")); + ObjectTypeDB::bind_method(_MD("add_button","text","tooltip"),&ButtonArray::add_button,DEFVAL("")); + ObjectTypeDB::bind_method(_MD("add_icon_button","icon:Texture","text","tooltip"),&ButtonArray::add_icon_button,DEFVAL(""),DEFVAL("")); ObjectTypeDB::bind_method(_MD("set_button_text","button_idx","text"),&ButtonArray::set_button_text); + ObjectTypeDB::bind_method(_MD("set_button_tooltip","button_idx","text"),&ButtonArray::set_button_tooltip); ObjectTypeDB::bind_method(_MD("set_button_icon","button_idx","icon:Texture"),&ButtonArray::set_button_icon); ObjectTypeDB::bind_method(_MD("get_button_text","button_idx"),&ButtonArray::get_button_text); + ObjectTypeDB::bind_method(_MD("get_button_tooltip","button_idx"),&ButtonArray::get_button_tooltip); ObjectTypeDB::bind_method(_MD("get_button_icon:Texture","button_idx"),&ButtonArray::get_button_icon); ObjectTypeDB::bind_method(_MD("get_button_count"),&ButtonArray::get_button_count); ObjectTypeDB::bind_method(_MD("get_selected"),&ButtonArray::get_selected); diff --git a/scene/gui/button_array.h b/scene/gui/button_array.h index c4b9b0c9e3..62997a8e36 100644 --- a/scene/gui/button_array.h +++ b/scene/gui/button_array.h @@ -50,6 +50,7 @@ private: struct Button { String text; + String tooltip; Ref<Texture> icon; mutable int _ms_cache; mutable int _pos_cache; @@ -78,14 +79,16 @@ public: void set_align(Align p_align); Align get_align() const; - void add_button(const String& p_button); - void add_icon_button(const Ref<Texture>& p_icon,const String& p_button=""); + void add_button(const String& p_button,const String& p_tooltip=""); + void add_icon_button(const Ref<Texture>& p_icon,const String& p_button="",const String& p_tooltip=""); void set_button_text(int p_button, const String& p_text); + void set_button_tooltip(int p_button, const String& p_text); void set_button_icon(int p_button, const Ref<Texture>& p_icon); String get_button_text(int p_button) const; + String get_button_tooltip(int p_button) const; Ref<Texture> get_button_icon(int p_button) const; int get_selected() const; @@ -100,6 +103,7 @@ public: virtual Size2 get_minimum_size() const; virtual void get_translatable_strings(List<String> *p_strings) const; + virtual String get_tooltip(const Point2& p_pos) const; ButtonArray(Orientation p_orientation=HORIZONTAL); diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 15ff334c92..b8c5f227c6 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -232,6 +232,8 @@ String AcceptDialog::get_text() const { void AcceptDialog::set_text(String p_text) { label->set_text(p_text); + minimum_size_changed(); + _update_child_rect(); } void AcceptDialog::set_hide_on_ok(bool p_hide) { @@ -253,38 +255,51 @@ void AcceptDialog::register_text_enter(Node *p_line_edit) { void AcceptDialog::_update_child_rect() { - int margin = get_constant("margin","Dialogs"); - Size2 size = get_size(); + const int margin = get_constant("margin","Dialogs"); + const Size2 size = get_size(); Size2 hminsize = hbc->get_combined_minimum_size(); - Vector2 cpos(margin,margin); - Vector2 csize(size.x-margin*2,size.y-margin*3-hminsize.y); + const Size2 max_csize( + size.width - margin * 2, + size.height - margin * 3 - hminsize.height); + hminsize.width = max_csize.width; + + Point2 cpos(margin, margin); + Size2 csize = label->get_combined_minimum_size(); + if(label->get_text().empty()) + csize.y = 0; + csize.x = MIN(csize.width, max_csize.width); + csize.y = MIN(csize.height, max_csize.height); label->set_pos(cpos); label->set_size(csize); - if (child) { + if(child) { + const float child_y_offset = csize.height + (csize.height > 0 ? margin : 0); + cpos.y += child_y_offset; + csize = max_csize; + csize.height -= child_y_offset; child->set_pos(cpos); child->set_size(csize); } - cpos.y+=csize.y+margin; - csize.y=hminsize.y; + cpos.y += csize.height + margin; hbc->set_pos(cpos); - hbc->set_size(csize); - + hbc->set_size(hminsize); } Size2 AcceptDialog::get_minimum_size() const { int margin = get_constant("margin","Dialogs"); Size2 minsize = label->get_combined_minimum_size(); + if(label->get_text().empty()) + minsize.y = 0; if (child) { Size2 cminsize = child->get_combined_minimum_size(); minsize.x=MAX(cminsize.x,minsize.x); - minsize.y=MAX(cminsize.y,minsize.y); + minsize.y += cminsize.y + (minsize.y > 0 ? margin : 0); } Size2 hminsize = hbc->get_combined_minimum_size(); diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index 190b56faba..56af35c6db 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -175,6 +175,7 @@ class EditorSceneImportDialog : public ConfirmationDialog { EditorDirDialog *save_select; OptionButton *texture_action; CreateDialog *root_type_choose; + LineEdit *root_node_name; ConfirmationDialog *confirm_open; @@ -639,6 +640,7 @@ void EditorSceneImportDialog::_choose_file(const String& p_path) { } else { #endif save_path->set_text(""); + root_node_name->set_text(""); //save_path->set_text(p_path.get_file().basename()+".scn"); #if 0 } @@ -656,6 +658,9 @@ void EditorSceneImportDialog::_choose_file(const String& p_path) { import_path->set_text(p_path); + if (root_node_name->get_text().size()==0){ + root_node_name->set_text(import_path->get_text().get_file().basename()); + } } void EditorSceneImportDialog::_choose_save_file(const String& p_path) { @@ -788,6 +793,10 @@ void EditorSceneImportDialog::_import(bool p_and_open) { if (!root_default->is_pressed()) { rim->set_option("root_type",root_type->get_text()); } + if (root_node_name->get_text().size()==0) { + root_node_name->set_text(import_path->get_text().get_file().basename()); + } + rim->set_option("root_name",root_node_name->get_text()); List<String> missing; Error err = plugin->import1(rim,&scene,&missing); @@ -946,7 +955,11 @@ void EditorSceneImportDialog::popup_import(const String &p_from) { root_default->set_pressed(true); root_type->set_disabled(true); } - + if (rimd->has_option("root_name")) { + root_node_name->set_text(rimd->get_option("root_name")); + } else { + root_node_name->set_text(root_type->get_text()); // backward compatibility for 2.1 or before + } script_path->set_text(rimd->get_option("post_import_script")); save_path->set_text(p_from.get_base_dir()); @@ -1241,7 +1254,9 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce root_default->connect("pressed",this,"_root_default_pressed"); custom_root_hb->add_child(root_default); - + root_node_name = memnew( LineEdit ); + root_node_name->set_h_size_flags(SIZE_EXPAND_FILL); + vbc->add_margin_child(TTR("Root Node Name:"),root_node_name); /* this_import = memnew( OptionButton ); this_import->add_item("Overwrite Existing Scene"); @@ -2185,6 +2200,7 @@ Error EditorSceneImportPlugin::import1(const Ref<ResourceImportMetadata>& p_from } } + scene->set_name(from->get_option("root_name")); _tag_import_paths(scene,scene); *r_node=scene; |