mirror of
				https://github.com/godotengine/godot.git
				synced 2025-11-01 06:01:14 +00:00 
			
		
		
		
	Merge pull request #57066 from KoBeWi/in_the_name_of_the_custom
This commit is contained in:
		
						commit
						f425d403fe
					
				
					 6 changed files with 39 additions and 8 deletions
				
			
		|  | @ -51,6 +51,14 @@ protected: | |||
| 	void _setup(uint32_t *p_base_ptr, uint32_t p_ptr_size); | ||||
| 
 | ||||
| public: | ||||
| 	virtual StringName get_method() const { | ||||
| #ifdef DEBUG_METHODS_ENABLED | ||||
| 		return StringName(text); | ||||
| #else | ||||
| 		return StringName(); | ||||
| #endif | ||||
| 	} | ||||
| 
 | ||||
| #ifdef DEBUG_METHODS_ENABLED | ||||
| 	void set_text(const char *p_text) { | ||||
| 		text = p_text; | ||||
|  |  | |||
|  | @ -114,8 +114,9 @@ ObjectID Callable::get_object_id() const { | |||
| } | ||||
| 
 | ||||
| StringName Callable::get_method() const { | ||||
| 	ERR_FAIL_COND_V_MSG(is_custom(), StringName(), | ||||
| 			vformat("Can't get method on CallableCustom \"%s\".", operator String())); | ||||
| 	if (is_custom()) { | ||||
| 		return get_custom()->get_method(); | ||||
| 	} | ||||
| 	return method; | ||||
| } | ||||
| 
 | ||||
|  | @ -310,6 +311,10 @@ Callable::~Callable() { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| StringName CallableCustom::get_method() const { | ||||
| 	ERR_FAIL_V_MSG(StringName(), vformat("Can't get method on CallableCustom \"%s\".", get_as_text())); | ||||
| } | ||||
| 
 | ||||
| void CallableCustom::rpc(int p_peer_id, const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error) const { | ||||
| 	r_call_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; | ||||
| 	r_call_error.argument = 0; | ||||
|  |  | |||
|  | @ -125,6 +125,7 @@ public: | |||
| 	virtual String get_as_text() const = 0; | ||||
| 	virtual CompareEqualFunc get_compare_equal_func() const = 0; | ||||
| 	virtual CompareLessFunc get_compare_less_func() const = 0; | ||||
| 	virtual StringName get_method() const; | ||||
| 	virtual ObjectID get_object() const = 0; //must always be able to provide an object
 | ||||
| 	virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const = 0; | ||||
| 	virtual void rpc(int p_peer_id, const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error) const; | ||||
|  |  | |||
|  | @ -70,12 +70,19 @@ bool CallableCustomBind::_less_func(const CallableCustom *p_a, const CallableCus | |||
| CallableCustom::CompareEqualFunc CallableCustomBind::get_compare_equal_func() const { | ||||
| 	return _equal_func; | ||||
| } | ||||
| 
 | ||||
| CallableCustom::CompareLessFunc CallableCustomBind::get_compare_less_func() const { | ||||
| 	return _less_func; | ||||
| } | ||||
| 
 | ||||
| StringName CallableCustomBind::get_method() const { | ||||
| 	return callable.get_method(); | ||||
| } | ||||
| 
 | ||||
| ObjectID CallableCustomBind::get_object() const { | ||||
| 	return callable.get_object_id(); | ||||
| } | ||||
| 
 | ||||
| const Callable *CallableCustomBind::get_base_comparator() const { | ||||
| 	return &callable; | ||||
| } | ||||
|  | @ -140,12 +147,19 @@ bool CallableCustomUnbind::_less_func(const CallableCustom *p_a, const CallableC | |||
| CallableCustom::CompareEqualFunc CallableCustomUnbind::get_compare_equal_func() const { | ||||
| 	return _equal_func; | ||||
| } | ||||
| 
 | ||||
| CallableCustom::CompareLessFunc CallableCustomUnbind::get_compare_less_func() const { | ||||
| 	return _less_func; | ||||
| } | ||||
| 
 | ||||
| StringName CallableCustomUnbind::get_method() const { | ||||
| 	return callable.get_method(); | ||||
| } | ||||
| 
 | ||||
| ObjectID CallableCustomUnbind::get_object() const { | ||||
| 	return callable.get_object_id(); | ||||
| } | ||||
| 
 | ||||
| const Callable *CallableCustomUnbind::get_base_comparator() const { | ||||
| 	return &callable; | ||||
| } | ||||
|  |  | |||
|  | @ -47,6 +47,7 @@ public: | |||
| 	virtual String get_as_text() const; | ||||
| 	virtual CompareEqualFunc get_compare_equal_func() const; | ||||
| 	virtual CompareLessFunc get_compare_less_func() const; | ||||
| 	virtual StringName get_method() const; | ||||
| 	virtual ObjectID get_object() const; //must always be able to provide an object
 | ||||
| 	virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const; | ||||
| 	virtual const Callable *get_base_comparator() const; | ||||
|  | @ -71,6 +72,7 @@ public: | |||
| 	virtual String get_as_text() const; | ||||
| 	virtual CompareEqualFunc get_compare_equal_func() const; | ||||
| 	virtual CompareLessFunc get_compare_less_func() const; | ||||
| 	virtual StringName get_method() const; | ||||
| 	virtual ObjectID get_object() const; //must always be able to provide an object
 | ||||
| 	virtual void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const; | ||||
| 	virtual const Callable *get_base_comparator() const; | ||||
|  |  | |||
|  | @ -930,21 +930,22 @@ void ScriptTextEditor::_update_connected_methods() { | |||
| 				continue; | ||||
| 			} | ||||
| 
 | ||||
| 			if (methods_found.has(connection.callable.get_method())) { | ||||
| 			const StringName method = connection.callable.get_method(); | ||||
| 			if (methods_found.has(method)) { | ||||
| 				continue; | ||||
| 			} | ||||
| 
 | ||||
| 			if (!ClassDB::has_method(script->get_instance_base_type(), connection.callable.get_method())) { | ||||
| 			if (!ClassDB::has_method(script->get_instance_base_type(), method)) { | ||||
| 				int line = -1; | ||||
| 
 | ||||
| 				for (int j = 0; j < functions.size(); j++) { | ||||
| 					String name = functions[j].get_slice(":", 0); | ||||
| 					if (name == connection.callable.get_method()) { | ||||
| 					if (name == method) { | ||||
| 						line = functions[j].get_slice(":", 1).to_int() - 1; | ||||
| 						text_edit->set_line_gutter_metadata(line, connection_gutter, connection.callable.get_method()); | ||||
| 						text_edit->set_line_gutter_metadata(line, connection_gutter, method); | ||||
| 						text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); | ||||
| 						text_edit->set_line_gutter_clickable(line, connection_gutter, true); | ||||
| 						methods_found.insert(connection.callable.get_method()); | ||||
| 						methods_found.insert(method); | ||||
| 						break; | ||||
| 					} | ||||
| 				} | ||||
|  | @ -957,7 +958,7 @@ void ScriptTextEditor::_update_connected_methods() { | |||
| 				bool found_inherited_function = false; | ||||
| 				Ref<Script> inherited_script = script->get_base_script(); | ||||
| 				while (!inherited_script.is_null()) { | ||||
| 					if (inherited_script->has_method(connection.callable.get_method())) { | ||||
| 					if (inherited_script->has_method(method)) { | ||||
| 						found_inherited_function = true; | ||||
| 						break; | ||||
| 					} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Rémi Verschelde
						Rémi Verschelde