Commit graph

117 commits

Author SHA1 Message Date
Yuri Roubinsky
526390c048 Fix highlight for completion options match (rebased)
Co-authored-by: Gustav Andersson <gvekan@users.noreply.github.com>
2021-12-12 10:39:49 +03:00
Nathan Franke
49403cbfa0
Replace String comparisons with "", String() to is_empty()
Also:
- Adds two stress tests to test_string.h
- Changes to .empty() on std::strings
2021-12-09 04:48:38 -06:00
Gilles Roudière
4fc0fb826a Change gdnative interface so that Godot object initialization should be triggered from the extension side 2021-11-30 16:55:48 +01:00
Ricardo Subtil
93396b3e51 Fix wrong comparison with default values 2021-11-26 14:04:13 +00:00
Lightning_A
e078f970db Rename remove() to remove_at() when removing by index 2021-11-23 18:58:57 -07:00
Xwdit
0bd96bd2cf
Fix the exceptions in signal disconnection
Use the correct method to get SignalData to fix exceptions in signal disconnection
2021-11-17 09:29:29 +01:00
Hugo Locurcio
315e94ee2a
Merge pull request #53710 from CaptainProton42/fix-extension-class-inspector-properties 2021-11-14 22:02:31 +01:00
kobewi
e393c2a734 Add is_built_in() method to Resource 2021-11-04 12:45:58 +01:00
Hugo Locurcio
c012fbc8b2
Rename PROPERTY_USAGE_NOEDITOR to PROPERTY_USAGE_NO_EDITOR
This is consistent with other constants that include `NO`,
such as `PROPERTY_HINT_COLOR_NO_ALPHA`.
2021-11-03 23:06:17 +01:00
Rémi Verschelde
f42ef8d5f9
CI: Update to clang-format 13 using LLVM repo 2021-10-28 17:11:00 +02:00
Rémi Verschelde
3b11e33a09
clang-format: Disable alignment of operands, too unreliable
Sets `AlignOperands` to `DontAlign`.

`clang-format` developers seem to mostly care about space-based indentation and
every other version of clang-format breaks the bad mismatch of tabs and spaces
that it seems to use for operand alignment. So it's better without, so that it
respects our two-tabs `ContinuationIndentWidth`.
2021-10-28 15:19:35 +02:00
Gilles Roudière
a51f92273a Remove ItemList editor and replace it by a property array 2021-10-28 10:16:51 +02:00
Max Hilbrunner
5dc02eb8b0 Save all 64 bits of get_ticks_msec() in more cases 2021-10-26 13:58:58 +02:00
qarmin
343d005e0f Fix memory leak in exported project 2021-10-18 11:19:31 +02:00
Rémi Verschelde
6569635ec0
Merge pull request #53757 from groud/fix_undo 2021-10-13 12:42:07 +02:00
Gilles Roudière
cf7242dd8e Fix undo in inspector not working 2021-10-13 10:45:21 +02:00
Rémi Verschelde
b48c6418fe
Merge pull request #52293 from neikeq/class-db-api-type-bug
Fix ClassDB API type mismatch bug between --editor and player
2021-10-12 22:34:21 +02:00
CaptainProton42
a9aba86943 Fetch extension class props from ClassDB
Extension class properties that have been registered with
ClassDB(`GDNativeInterface::classdb_register_extension_class_property`)
were not fetched previously. (Only  directly providing a property
list using `GDNativeExtensionClassCreationInfo::get_property_list_func`
would work.) This especially caused problems with the C++
bindings since they exclusively rely on ClassDB to register properties.
2021-10-12 18:25:55 +02:00
Gilles Roudière
5504e11fb7 Fix useless debug print 2021-10-12 17:03:39 +02:00
Gilles Roudière
1be00864b7 Add a way to force undo/redo operations to be kept in MERGE_ENDS mode 2021-10-12 14:03:05 +02:00
George Marques
fafa8c7f6e
Enable method type information on release builds
This is needed to ensure GDScript compilation works properly on release
builds and make use of optimized typed instructions.
2021-10-07 16:13:44 -03:00
Maxime Lapointe
29dc8de88b Improve error message when instantiating virtual class 2021-10-05 08:09:35 -04:00
Rémi Verschelde
01cb4d92f3
Merge pull request #47442 from Shatur/fix-connect-reference-counted 2021-10-01 22:41:11 +02:00
Lightning_A
c63b18507d Use range iterators for Map 2021-09-30 15:09:12 -06:00
Fabio Alessandrelli
f9ce9a8e10 [ClassDB] Unify construct/extension retrieval. 2021-09-22 18:33:29 +02:00
Fabio Alessandrelli
f724bd1880 [Core] Add ClassDB functions to retrieve/construct extensions.
Calling the constructor alone is not enough if the class to be
instantiated is not a base class.

This commit adds two functions, one for retrieving the the extension
class reference, the other to construct an instance using the
constructor and the extension class reference.
2021-09-22 17:46:08 +02:00
Max Hilbrunner
acc776f7b6
Merge pull request #52442 from Faless/mp/4.x_rpc_manager
[Net] Move multiplayer classes to own subfolder. Split RPC from MultiplayerAPI.
2021-09-07 18:44:39 +02:00
Fabio Alessandrelli
bf9aae09ba [Net] Move multiplayer to core subdir, split RPCManager.
Move multiplayer classes to "core/multiplayer" subdir.

Move the RPCConfig and enums (TransferMode, RPCMode) to a separate
file (multiplayer.h), and bind them to the global namespace.

Move the RPC handling code to its own class (RPCManager).

Renames "get_rpc_sender_id" to "get_remote_sender_id".
2021-09-07 11:14:30 +02:00
Gilles Roudière
4bd7700e89 Implement properties arrays in the Inspector. 2021-09-07 09:51:28 +02:00
Silc 'Tokage' Renew
facf8f1883 Apply set_read_only() to child classes of EditorProperty elements 2021-09-05 18:22:17 +09:00
Ignacio Roldán Etcheverry
cca26cc83f Fix ClassDB API type mismatch bug between --editor and player
There are two ways a class can be added to ClassDB:

- `A`: When an instance of the class is created for the first time. When
  this happends the class is not registered/exposed to scripts.
- `B`: When calling `GDREGISTER_CLASS(ClassName)` or similar. When this
  happens the class is registered/exposed to scripts.

ClassDB has an API type property to differentiate between the core
and editor APIs. Up until now the API type was determined whenever
the class is added to ClassDB (either `A` or `B`).

The problem comes when a class is instantiated (`A`) before
being registered (`B`).
If at this point the current defined API is not the same as when the
class is later registered, this will result in a mismatch between
`--editor` and non-editor apps.
This is specially bad for C# as it makes the editor player abort.

This was happening with `EditorPaths` which, while being registered
during the editor API classes registrations, it was also being
instantiated earlier when running the editor or the project manager,
via a call to `EditorPaths::create()`. This regression was introduced
in 1074017f04.

This commit fixes this simply by re-assigning the class API type when
the class is registered (`B`).
This is correct because API type describes registered/exposed classes.
It shouldn't cause any regressions as the API type should not be
accessed of classes that are not (or not yet) registered/exposed.

Code locations for reference:
- Method to add a class to ClassDB: `ClassDB::_add_class2`
- Code that adds classes to ClassDB post first initialization (`A`):
  `memnew` macros -> `Object::_postinitialize` ->
  `Object::initialize_class` -> `ClassDB::_add_class2`.
- Code adds class to ClassDB and registers/exposes it to scripts:
  `GDREGISTER_CLASS` macros -> `ClassDB::register_class<T>` ->
  `Object::initialize_class` -> `ClassDB::_add_class2`.
2021-08-31 22:35:32 +02:00
Juan Linietsky
d19b12dbd2
Merge pull request #52107 from timothyqiu/overriden
Fix misspelled "overriden"
2021-08-26 13:07:52 -03:00
Haoyu Qiu
eba7265a1c Fix misspelled "overriden"
In recent GDVIRTUAL PR and SkeletonModification3DJiggle doc.
2021-08-26 01:44:01 +08:00
reduz
96f8254b24 Implement error return documetation
Adds ability to add error return documetation to the binder and class reference.
Usage example:

```C++
void MyClass::_bind_method() {
	[..]
	BIND_METHOD_ERR_RETURN_DOC("load", ERR_FILE_CANT_OPEN, ERR_FILE_UNRECOGNIZED);
}
```

One function of ConfigFile was changed as example.
2021-08-24 15:28:29 -03:00
reduz
44d62a9f4b Implement NativeExtension pointer arguments
* Allows calling into native extensions directly with a pointer
* Makes it easier to implement some APIs more efficiently
* Appears with a "*" in the documentation for the argument.
* Implementing the pointer handling is entirely up to the implementation, although the extension API provides some hint.
* AudioStream has been implemented as an example, allowing to create NativeExtension based AudioStreams.
2021-08-23 19:58:40 -03:00
reduz
5cecdfa8af Entirely removes BIND_VMETHOD in favor of GDVIRTUAL
* `_gui_input`, `_input`, `_unhandled_input` and `_unhandled_key_input` are now regular C++ virutal functions.
* Everything else converted to GDVIRTUAL
* BIND_VMETHOD is gone, always use the new syntax from now on.

Creating `_gui_input` method and using the binder to register events will no longer work, simply override the virtual function now.
2021-08-23 08:10:13 -03:00
reduz
3682978aee Replace BIND_VMETHOD by new GDVIRTUAL syntax
* New syntax is type safe.
* New syntax allows for type safe virtuals in native extensions.
* New syntax permits extremely fast calling.

Note: Everything was replaced where possible except for `_gui_input` `_input` and `_unhandled_input`.
These will require API rework on a separate PR as they work different than the rest of the functions.

Added a new method flag METHOD_FLAG_OBJECT_CORE, used internally. Allows to not dump the core virtuals like `_notification` to the json API, since each language will implement those as it is best fits.
2021-08-22 08:23:58 -03:00
PouleyKetchoupp
645bc94bfc Fix capsule height/radius setters with linked properties
Capsule height and radius setters can modify each other, rather than
using clamping, to avoid cases where values are not set correctly when
loading a scene (depending on the order of properties).

Inspector undo/redo:
Added the possibility to link properties together in the editor, so
they can be undone together, for cases where a property can modify
another one.

Gizmo undo/redo:
Capsule handles pass both radius and height values so they can be undone
together.
2021-08-19 10:31:19 -07:00
Rémi Verschelde
de7b6d13eb
Merge pull request #51627 from mhilbrunner/todo-for-neikeq 2021-08-18 20:13:50 +02:00
George Marques
3b593b596e
Properly set up virtual calls for extensions 2021-08-17 22:11:11 -03:00
Max Hilbrunner
81f7d1890b Namespaces instead of underscore prefix for binds
Thanks to neikeq for the initial work.

Co-authored-by: Ignacio Roldán Etcheverry <neikeq@users.noreply.github.com>
2021-08-17 16:10:09 +02:00
Haoyu Qiu
16c2d4ef22 Improve Undo/Redo menu items
* Make Undo/Redo menu items disabled when clicking it does nothing.
    * Context menu of `TextEdit`
    * Context menu of `LineEdit`
    * Editor's Scene menu
    * Script editor's Edit menu and context menu (for Script and Text)
* Make editor undo/redo log messages translatable.
* Mark `UndoRedo`'s `has_{un,re}do()` methods as `const`.
* Expose `TextEdit`'s `has_{un,re}do()` to scripts since `{un,re}do()` are already available.
2021-08-17 21:11:10 +08:00
Ignacio Roldán Etcheverry
5ea500e599 Fix C# native instance bindings after recent re-write
This was needed after: 4469144891
2021-08-16 17:16:36 +02:00
George Marques
626c0b6905
Add a instance callback for extensions
This sends the Godot object instance back to the extension so they can
keep a pointer for function calls.

Incidentally fix argument order on instance bindings callback for free()
2021-08-05 14:56:13 -03:00
Rémi Verschelde
73b1f5ac79
Merge pull request #48615 from Razoric480/lsp-rename
Implement LSP didSave notification and rename request
2021-08-05 00:18:31 +02:00
Rémi Verschelde
ac3322b0af
Use const references where possible for List range iterators 2021-07-25 12:22:25 +02:00
Rémi Verschelde
2b1e6e303e
Merge pull request #50786 from reduz/implement-resource-uids
Implement Resource UIDs
2021-07-24 17:18:12 +02:00
reduz
32b43cfeb3 Implement Resource UIDs
* Most resource types now have unique identifiers.
* Applies to text, binary and imported resources.
* File formats reference both by text and UID (when available). UID always has priority.
* Resource UIDs are 64 bits for better compatibility with the engine.
* Can be represented and used textually, example `uuid://dapwmgsmnl28u`.
* A special binary cache file is used and exported, containing the mappings.

Example of how it looks:

```GDScript
[gd_scene load_steps=2 format=3 uid="uid://dw86wq31afig2"]

[ext_resource type="PackedScene" uid="uid://bt36ojelx8q6c" path="res://subscene.scn" id="1_t56hs"]
```

GDScript, shaders and other special resource files can't currently provide UIDs, but this should be doable with special keywords on the files.
This will be reserved for future PRs.
2021-07-24 09:16:52 -03:00
Aaron Franke
4e6efd1b07
Use C++ iterators for Lists in many situations 2021-07-23 17:38:28 -04:00
Haoyu Qiu
c3baf83e28 Fix UndoRedo crash when clearing history 2021-07-24 00:53:58 +08:00