Commit graph

4158 commits

Author SHA1 Message Date
Rémi Verschelde
e0d48f87f9
Merge pull request #50782 from timothyqiu/undoredo-ref
Fix UndoRedo crash when clearing history
2021-07-23 19:27:51 +02:00
Rémi Verschelde
eefc67a810
Merge pull request #50747 from bruvzg/move_alert_to_os
Move `alert` function from `DisplayServer` to `OS`.
2021-07-23 19:27:31 +02:00
Haoyu Qiu
c3baf83e28 Fix UndoRedo crash when clearing history 2021-07-24 00:53:58 +08:00
Hugo Locurcio
7f83977f37
Expose an ImportOrder enum in ResourceImporter
This avoids using magic numbers in code.
2021-07-23 12:12:25 +02:00
Aaron Franke
4147c67bb0
Fix Input get_action_raw_strength 2021-07-22 21:05:44 -04:00
Fabio Alessandrelli
1147fa5c19 Make Object "meta" functions take StringName.
The various get_meta, set_meta, has_meta, get_meta_list, remove_meta
functions now uses StringName, allowing further optimizations via the
SNAME macro when used from C++ (this PR does not change the various
usage though).
2021-07-22 22:52:30 +02:00
bruvzg
618eb27e8b Move alert function from DisplayServer to OS. 2021-07-22 21:50:35 +03:00
reduz
75755beeee
Implement textual ext/subresource IDs.
* Friendlier with version control.
* Generates pseudo unique IDs, to minimize conflicts when merging, but still
  user readable (so, not UUID).
* Eventually will also allow to have more precisely named sub-resources in
  imported files.
* This will allow better reloading on changes (including resources already
  loaded) as well as better keeping track of changes on the DCC.
* Keeps backward compatibility with the old formats.
* Binary and text format version incremented to mark breakage in forward
  compatibility.
2021-07-22 19:37:47 +02:00
Rémi Verschelde
6b1886f998
Merge pull request #50319 from nekomatata/optimize-node-path-check
Optimize NodePath update when renaming or deleting nodes in the editor
2021-07-22 12:13:10 +02:00
Gilles Roudière
b2187797df Add min_axis and max_axis to Vector2i 2021-07-21 12:29:51 +02:00
Hugo Locurcio
4bd5e4fd9b
Use the standard C INFINITY and NAN constants directly
The `Math_INF` and `Math_NAN` defines were just aliases for those
constants, so we might as well use them directly.

Some portions of the code were already using `INFINITY` directly.
2021-07-21 10:41:08 +02:00
reduz
cee905f04f Adds ability to debug stringnames
* References (which include hash tables) can be profiled with --debug-stringnames
2021-07-20 17:31:51 -03:00
Rémi Verschelde
693f9b4e20
Merge pull request #50655 from JFonS/sname_opt
Editor StringName and Viewport optimizations
2021-07-20 21:49:32 +02:00
Joan Fons
a6adb58493 Editor StringName and Viewport optimizations
* Added explicit return type to the SNAME macro.
* Add some extra SNAME usages.
* Change some ClassDB methods to use const StringName & arguments.
* Cache the Window parent in Control because it's used in
  is_layout_rtl(), which is called often.
* Only enable internal processing for viewports that need it.
* Change CanvasItem::group to be a StringName because it's only used as
  that.
2021-07-20 20:35:41 +02:00
Fabio Alessandrelli
de4ad63e6f
Merge pull request #49882 from Faless/mp/4.x_rpc_gd
[Net] New `@rpc` annotation, "sync" is no longer part of mode.
2021-07-20 13:55:54 +02:00
Rémi Verschelde
a98677181b
Sync controller mappings DB with SDL2 community repo
Synced with gabomdq/SDL_GameControllerDB@241fed0a44.
2021-07-20 13:08:50 +02:00
Fabio Alessandrelli
ddb68f76ff [Net] Single rpc annotation. "sync" no longer part of mode.
- Move the "sync" property for RPCs to RPCConfig.

- Unify GDScript annotations into a single one:
  - `@rpc(master)` # default
  - `@rpc(puppet)`
  - `@rpc(any)` # former `@remote`

- Implement three additional `@rpc` options:
  - The second parameter is the "sync" option (which also calls the
    function locally when RPCing). One of "sync", "nosync".
  - The third parameter is the transfer mode (reliable, unreliable,
    ordered).
  - The third parameter is the channel (unused for now).
2021-07-20 11:17:59 +02:00
Rémi Verschelde
d022f361d3
Merge pull request #50518 from timothyqiu/locale-az
Fix missing locale names
2021-07-20 11:11:30 +02:00
Rémi Verschelde
b4baec08cf
Merge pull request #50206 from groud/undoredo_increase_args_count
Increase the number of arguments accepted by UndoRedo methods
2021-07-20 09:50:01 +02:00
reduz
6631f66c2a Optimize StringName usage
* Added a new macro SNAME() that constructs and caches a local stringname.
* Subsequent usages use the cached version.
* Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time.
* Replaced all theme usages by this new macro.
* Replace all signal emission usages by this new macro.
* Replace all call_deferred usages by this new macro.

This is part of ongoing work to optimize GUI and the editor.
2021-07-18 21:20:02 -03:00
Fabio Alessandrelli
5717118bcc [HTML5] Add 2 controllers to the godot database.
Sony PlayStation DualShock 4 (054c:05c4 first gen).
Unofficial Switch controller.
2021-07-17 23:51:48 +02:00
Francois Belair
7c5335081c Implement didSave notification and rename request 2021-07-17 11:50:00 -04:00
Fabio Alessandrelli
0e265b047e
Merge pull request #46554 from likeich/is_server_quiet_failure
MultiplayerAPI is_network_server Fails Silently
2021-07-16 20:04:41 +02:00
Hugo Locurcio
523d6b2ae8
Merge pull request #47395 from sygi/shape_idx_collision
Add shape_idx to CollisionObject2D mouse_entered signal
2021-07-16 19:05:08 +02:00
Haoyu Qiu
7eec8334d4 Fix missing locale names 2021-07-16 23:07:07 +08:00
reduz
b5d5d13f56 Add ability to set object instance binding on creation
* Required by binding generators
* Makes it easier to create the bindings on construction.
2021-07-15 11:41:57 -03:00
Joan Fons
cfec291978 Fix equality operators in List's ConstIterator 2021-07-15 10:47:20 +02:00
Rémi Verschelde
06568bbfdf
Misc cleanup of header includes
Was looking for misuse of module headers without checking that the module is
actually enabled and got carried away...
2021-07-15 00:46:43 +02:00
George Marques
7bc52e56c0
Merge pull request #50056 from Blackiris/fix-in-operator
Fix 'in' operator to check if an object member exists
2021-07-13 14:25:42 -03:00
Rémi Verschelde
8747f25653
Merge pull request #50381 from reduz/implement-disable-classes
Implement the ability to disable classes
2021-07-13 15:31:38 +02:00
Rémi Verschelde
b44b277f6f
Merge pull request #50169 from pycbouh/theme-type-variations 2021-07-13 15:13:00 +02:00
reduz
5ad4f26659 Implement the ability to disable classes
* This PR adds the ability to disable classes when building.
* For now it's only possible to do this via command like:
  `scons disable_classes=RayCast2D,Area3D`
* Eventually, a proper UI will be implemented to create a build config file to do this at large scale, as well as detect what is used in the project.
2021-07-13 09:25:14 -03:00
Rémi Verschelde
dd27413907
Merge pull request #50412 from timothyqiu/fastlz-decompress 2021-07-13 12:12:46 +02:00
Faymoon
78ead60372
Let thread func have optional parameter
Fixes #38042.
2021-07-13 10:44:53 +02:00
Haoyu Qiu
ccf292df38 Fix decompression with FastLZ when buffer size is less than 16 bytes 2021-07-13 16:34:45 +08:00
Rémi Verschelde
e2b79e9591
Merge pull request #49291 from NoFr1ends/fix-49262
String::format leave passed values untouched
2021-07-13 09:33:46 +02:00
Rémi Verschelde
a766661f6a
Merge pull request #50304 from timothyqiu/memfree-param
Fix memfree parameter name
2021-07-13 08:29:47 +02:00
Yuri Sizov
4ee0e6ddf5 Add type variations to Theme 2021-07-13 02:26:28 +03:00
Fabio Alessandrelli
88d68346ee [Net] Rename NetworkedMultiplayerPeer to MultiplayerPeer. 2021-07-12 16:36:34 +02:00
Hendrik Brucker
74ab336fe3 Change VSync mode project setting enum type from string to integer 2021-07-12 03:35:51 +02:00
Fabio Alessandrelli
d3ba0aa3e0 [Net] Fix crash when receiving RPC on node without a script. 2021-07-11 10:18:32 +02:00
Rémi Verschelde
a0d800e967
Merge pull request #50362 from timothyqiu/http-eof
Fix unicode invalid skip error in AssetLib
2021-07-11 09:33:51 +02:00
Haoyu Qiu
0caaaf4018 Fix unicode invalid skip error in AssetLib 2021-07-11 12:14:08 +08:00
Haoyu Qiu
293050a919 Handle Z_BUF_ERROR in decompress_dynamic 2021-07-11 11:05:12 +08:00
Hugo Locurcio
a2d5f191d8
Merge pull request #48622 from Geometror/reimplement-disableable-vsync 2021-07-10 01:02:23 +02:00
Rémi Verschelde
ca2fda629f
Merge pull request #50290 from reduz/redo-instance-bindings
Redo how instance bindings work
2021-07-09 23:25:33 +02:00
PouleyKetchoupp
ff40c3f3c8 Optimize NodePath update when renaming or deleting nodes in the editor
Now the process uses a Map to lookup node pointers instead of iterating
over all modified node paths in a list and comparing them for each
property to check.

The process also avoids checking properties with empty node paths and
does an early exit on deleted nodes to avoid checking the node and its
descendants.

Also made a minor change in NodePath::rel_path_to() to avoid resizing a
Vector many times for long paths (with copy-on-write each time). Now
it's down to 2 resize calls in any case.
2021-07-09 11:42:39 -07:00
Haoyu Qiu
542d7d6460 Fix memfree parameter name 2021-07-09 14:41:00 +08:00
reduz
a9c943bef9 Implement Range Iterators
This PR implements range iterators in the base containers (Vector, Map, List, Pair Set).
Given several of these data structures will be replaced by more efficient versions, having a common iterator API will make this simpler.
Iterating can be done as follows (examples):

```C++
//Vector<String>
for(const String& I: vector) {

}
//List<String>
for(const String& I: list) {

}
//Map<String,int>
for(const KeyValue<String,int>&I : map) {
	print_line("key: "+I.key+" value: "+itos(I.value));

}

//if intending to write the elements, reference can be used

//Map<String,int>
for(KeyValue<String,int>& I: map) {
	I.value = 25;
	//this will fail because key is always const
	//I.key = "hello"
}

```

The containers are (for now) not STL compatible, since this would mean changing how they work internally (STL uses a special head/tail allocation for end(), while Godot Map/Set/List do not).
The idea is to change the Godot versions to be more compatible with STL, but this will happen after conversion to new iterators have taken place.
2021-07-08 23:27:27 -03:00
reduz
4469144891 Redo how instance bindings work
* The harcoded 8 slots are no more and impose limits in the new extension system.
* New system is limitless, although it will impose small performance hit with a mutex.
* Use a token to request the instance binding.

**Warning**: Mono will most likely break as a result of this, will need to be modified to use the new system.
2021-07-08 17:08:12 -03:00
reduz
c43f624d44 Unify material parameter update
* Unifies how material parameters are updated.
* Single function, easier to maintain.
* Updates materials properly when textures change.
2021-07-06 18:57:38 -03:00
Gilles Roudière
2f9a0268dd Increase the number of arguments accepted by UndoRedo methods 2021-07-06 18:52:28 +02:00
Hendrik Brucker
043ae91560 Restructure and reimplement vsync options
-Add a v-sync mode setting which allows to choose between DISABLED, ON, ADAPTIVE and MAILBOX
-Removed the V-Sync via Compositor option
2021-07-06 16:34:26 +02:00
Eric M
c2ba7464b6 Added EditorInspectorPlugin to aid in editing InputEvents in resources and shortcuts 2021-07-06 23:50:33 +10:00
bruvzg
eca4d2fccc Fix Variant tags parsing. 2021-07-05 15:46:41 +03:00
Fabio Alessandrelli
a28d25c441 [Crypto] Delete mbedtls ctx in deconstructor.
Would cause memory leak when the context was `start`ed but not
`finish`ed.
2021-07-03 16:12:55 +02:00
sygi
6f3e7f7cb0 Add mouse_shape_entered and mouse_shape_exited signals to CollisionObject2D.
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2021-07-02 20:50:27 +01:00
Nick H
c6f28ed62b Add get_dead_zone() method to InputMap
This commit adds a new method to the `InputMap`, allowing the user to get the value of an action's dead zone as a float.
2021-07-02 03:07:37 -04:00
Rémi Verschelde
97e041e285
Merge pull request #50057 from reduz/force-string-in-dictionary
Force String as Dictionary key instead of StringName
2021-07-01 22:22:47 +02:00
reduz
379b90fd33 Force String as Dictionary key instead of StringName
* Lua table syntax uses named indexing: `{ mykey = myvalue }`
* Python style syntax uses string indexing: `{ "mykey" : myvalue }`
* Both are incompatible since a StringName key wont fetch a String key, hence confusing.
* This PR proposes always using String for indexing at a very minimal performance cost. Always indexing with StringNames will be faster, but they are considerably more expensive to create.
2021-07-01 16:03:37 -03:00
Julien Nguyen
0a823e85d2 Fix 'in' operator to check if an object member exists 2021-07-01 20:59:26 +02:00
Aaron Franke
2508fd0533
Use PROPERTY_USAGE_NONE instead of 0 for no property usage
Also use const more often.
2021-07-01 14:13:27 -04:00
Rémi Verschelde
9f30638d4b
Merge pull request #50044 from akien-mga/localvector-find-noerror
LocalVector: Don't error if `from` >= `count`
2021-07-01 13:13:27 +02:00
Rémi Verschelde
230a24a49d
Merge pull request #50026 from lyuma/callable_is_valid
Add Callable.is_valid() analogous to FuncRef.is_valid() from 3.x
2021-07-01 12:57:14 +02:00
Rémi Verschelde
7b7ccf25b6
LocalVector: Don't error if from >= count
Vector handles this silently by returning -1, and we should do the same here.
Otherwise we get errors when calling `find()` on e.g. a LocalVector of size 0,
while `find()` is expected to always work (if the parameters are invalid then
it doesn't find anything, so -1).

Fixup to #49925.
2021-07-01 12:16:33 +02:00
Lyuma
8f1efa656b Add Callable.is_valid() analogous to FuncRef.is_valid() from 3.x 2021-07-01 02:54:01 -07:00
Rémi Verschelde
3f12d0a883
Merge pull request #50018 from fire/port-false
Network port comparison is always false
2021-07-01 09:42:34 +02:00
reduz
75688772b3 Fix editor suffixes and degrees conversion
* Functions to convert to/from degrees are all gone. Conversion is done by the editor.
* Use PROPERTY_HINT_ANGLE instead of PROPERTY_HINT_RANGE to edit radian angles in degrees.
* Added possibility to add suffixes to range properties, use "min,max[,step][,suffix:<something>]" example "0,100,1,suffix:m"
* In general, can add suffixes for EditorSpinSlider
Not covered by this PR, will have to be addressed by future ones:

* Ability to switch radians/degrees in the inspector for angle properties (if actually wanted).
* Animations previously made will most likely break, need to add a way to make old ones compatible.
* Only added a "px" suffix to 2D position and a "m" one to 3D position, someone needs to go through the rest of the engine and add all remaining suffixes.
* Likely also need to track down usage of EditorSpinSlider outside properties to add suffixes to it too.
2021-06-30 12:38:25 -03:00
K. S. Ernest (iFire) Lee
c1d9170194 Network port comparison is always false
error: comparison is always false due to limited range of data type [-Werror=type-limits]
  ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER, "The local port number must be between 0 and 65535 (inclusive).");
2021-06-30 02:39:17 -07:00
reduz
64c925cca6 Improve RID_Owner memory usage
* Ability to allocate empty objects in RID_Owner, so RID_PtrOwner is not needed in most cases.
* Improves cache usage, as objects are now allocated together
* Should improve performance in 2D rendering
2021-06-29 12:28:08 -03:00
Rémi Verschelde
7f9346b81b
Merge pull request #49925 from RicardRC/FindFromNop
Make use of variable "from" in local_vector find() function.
2021-06-29 14:36:19 +02:00
Ricard Rovira
14d5908057 Use unused from in local vector find function. 2021-06-29 13:37:02 +02:00
Rémi Verschelde
05336adb86
Merge pull request #49905 from pfertyk/issue-46480-image-compress-crashes-godot
Validate image formats, check if resize_to_po2 failed
2021-06-29 12:44:20 +02:00
Gilles Roudière
30a615dd94 Implement painting properties over TileSets 2021-06-29 11:07:46 +02:00
Paweł Fertyk
3dae9993ac Validate image formats, check if resize_to_po2 failed 2021-06-28 21:17:06 +02:00
Haoyu Qiu
0b7ffd4f68 Fix Image.adjust_bcs crash when image format is invalid 2021-06-27 20:52:42 +08:00
reduz
b1d15c51bc Implement native extension system
* Deprecates GDNative in favor of a simpler, lower level interface.
* New extension system allows registering core engine classes.
* Simple header interface in gdnative_interace.h
2021-06-25 17:32:45 -03:00
Rémi Verschelde
f1bcc641dd
Merge pull request #49583 from timothyqiu/texture-crash
Fix crash when freeing GradientTexture and NoiseTexture
2021-06-24 09:40:42 +02:00
Fabio Alessandrelli
b00c4a4360 [Net] Makes HTTPClient a custom instance class. 2021-06-23 14:10:45 +02:00
Fabio Alessandrelli
421e771012 [Net] Unify HTTPClient request and request_raw. 2021-06-23 13:53:43 +02:00
Eric M
f96d9f5ae1 Improved some error messages (from ERR_FAIL_*) in Object. 2021-06-21 20:20:59 +10:00
Aaron Franke
0ce49800ac
Use mouse and joypad enums instead of plain integers
Also MIDIMessage
2021-06-20 11:54:24 -04:00
Aaron Franke
e919d894f8
Move many input enums to their own file 2021-06-20 11:53:01 -04:00
Rémi Verschelde
cca29b78b9
Merge pull request #48359 from Calinou/add-engine-print-error-property 2021-06-20 13:22:08 +02:00
Lightning_A
e28fd07b2b Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
Rémi Verschelde
9b7c963d19
Merge pull request #48804 from EricEzaM/scripting-multi-error-support
Added support for scripts reporting multiple errors to ScriptTextEditor
2021-06-20 00:38:49 +02:00
Rémi Verschelde
bbf6d645fb
Merge pull request #48080 from aaronfranke/real-serialization
Binary serialization for reals
2021-06-20 00:33:30 +02:00
Rémi Verschelde
4effadc0ba
Merge pull request #48696 from madmiraal/fix-48692
Fix `InputMap.action_erase_event()` failing to erase events correctly.
2021-06-20 00:29:42 +02:00
Rémi Verschelde
d88be9b70c
Merge pull request #44806 from madmiraal/consolidate_json
Consolidate JSON, JSONParseResults and JSONParser into JSON
2021-06-19 21:45:34 +02:00
Eric M
d0e78c86d7 Added support for scripts reporting multiple errors to ScriptTextEditor
Scripts can now report multiple errors to the scripting editors in the engine. UI elements were added to support multiple errors.
2021-06-19 22:20:30 +10:00
Marcel Admiraal
2bafcd3422 Consolidate JSON, JSONParseResults and JSONParser into JSON
Renames JSON.parse_string() to parse()
Renames JSON.decode_data() to stringify()
2021-06-19 08:01:40 +01:00
Hugo Locurcio
aa0976f47c
Expose OS data directory getter methods
This can be used by editor plugins and non-game applications to
store data in the correct directories according to the
XDG Base Directory specification.
2021-06-19 08:56:20 +02:00
Rémi Verschelde
a9c53fa599
Merge pull request #49287 from reduz/expose-variant-internal-binders
Make some Variant internal functions public.
2021-06-19 01:11:03 +02:00
Rémi Verschelde
92f20fd70e
Merge pull request #49659 from LightningAA/string-valid-integer-to-int 2021-06-18 16:14:14 +02:00
Rémi Verschelde
7aebb8f81c
Merge pull request #44156 from aaronfranke/quat-angle-to
Add Quaternion angle_to method
2021-06-18 12:35:58 +02:00
Rémi Verschelde
3fc39954ec
Merge pull request #49638 from aaronfranke/multiply-transforms
Allow multiplying Transforms and Basis by numbers
2021-06-18 12:35:14 +02:00
Rémi Verschelde
f6756e2bf5
Merge pull request #49698 from aaronfranke/prop-no-usage
Add PROPERTY_USAGE_NONE and use it
2021-06-18 12:28:05 +02:00
Aaron Franke
93b494d4ae
Add Quaternion angle_to method 2021-06-17 23:57:00 -04:00
Aaron Franke
29706651fe
Binary serialization for reals
Added new "encode_real" methods for handling real_t, and used them for vector types. Types are encoded based on compilation setting.

But for decoding, always check how it was encoded. This way, serialized data is cross-compatible with Godot compiled with singles and Godot compiled with doubles. At least, in theory.
2021-06-17 23:15:34 -04:00
Michael Alexsander Silva Dias
0ff4095b36 Better format arguments in variant parser 2021-06-18 00:06:40 -03:00