diff options
61 files changed, 1056 insertions, 497 deletions
diff --git a/core/image.cpp b/core/image.cpp index 8cd2562bcb..0e1841b021 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1910,6 +1910,10 @@ void Image::unlock() { write_lock = PoolVector<uint8_t>::Write(); } +Color Image::get_pixelv(const Point2 &p_src) const { + return get_pixel(p_src.x, p_src.y); +} + Color Image::get_pixel(int p_x, int p_y) const { uint8_t *ptr = write_lock.ptr(); @@ -2056,6 +2060,10 @@ Color Image::get_pixel(int p_x, int p_y) const { return Color(); } +void Image::set_pixelv(const Point2 &p_dst, const Color &p_color) { + return set_pixel(p_dst.x, p_dst.y, p_color); +} + void Image::set_pixel(int p_x, int p_y, const Color &p_color) { uint8_t *ptr = write_lock.ptr(); @@ -2287,8 +2295,10 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("lock"), &Image::lock); ClassDB::bind_method(D_METHOD("unlock"), &Image::unlock); - ClassDB::bind_method(D_METHOD("set_pixel", "x", "y", "color"), &Image::set_pixel); + ClassDB::bind_method(D_METHOD("get_pixelv", "src"), &Image::get_pixelv); ClassDB::bind_method(D_METHOD("get_pixel", "x", "y"), &Image::get_pixel); + ClassDB::bind_method(D_METHOD("set_pixelv", "dst", "color"), &Image::set_pixelv); + ClassDB::bind_method(D_METHOD("set_pixel", "x", "y", "color"), &Image::set_pixel); ClassDB::bind_method(D_METHOD("load_png_from_buffer", "buffer"), &Image::load_png_from_buffer); ClassDB::bind_method(D_METHOD("load_jpg_from_buffer", "buffer"), &Image::load_jpg_from_buffer); diff --git a/core/image.h b/core/image.h index 3c43e49950..80a0c339dd 100644 --- a/core/image.h +++ b/core/image.h @@ -321,7 +321,9 @@ public: DetectChannels get_detected_channels(); + Color get_pixelv(const Point2 &p_src) const; Color get_pixel(int p_x, int p_y) const; + void set_pixelv(const Point2 &p_dest, const Color &p_color); void set_pixel(int p_x, int p_y, const Color &p_color); void copy_internals_from(const Ref<Image> &p_image) { diff --git a/doc/classes/CanvasItemMaterial.xml b/doc/classes/CanvasItemMaterial.xml index fe7194dcfe..354bc10cd2 100644 --- a/doc/classes/CanvasItemMaterial.xml +++ b/doc/classes/CanvasItemMaterial.xml @@ -36,6 +36,9 @@ <constant name="BLEND_MODE_PREMULT_ALPHA" value="4" enum="BlendMode"> Mix blending mode. Colors are assumed to be premultiplied by the alpha (opacity) value. </constant> + <constant name="BLEND_MODE_DISABLED" value="5" enum="BlendMode"> + Disable blending mode. Colors including alpha are written as is. Only applicable for render targets with a transparent background. No lighting will be applied. + </constant> <constant name="LIGHT_MODE_NORMAL" value="0" enum="LightMode"> Render the material using both light and non-light sensitive material properties. </constant> diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index 99d3a9a45f..a6c63cfb76 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -75,6 +75,13 @@ Returns the number of visible lines. </description> </method> + <method name="get_content_height"> + <return type="int"> + </return> + <description> + Returns the height of the content. + </description> + </method> <method name="newline"> <return type="void"> </return> diff --git a/doc/classes/Timer.xml b/doc/classes/Timer.xml index aba1b78188..c51a52d911 100644 --- a/doc/classes/Timer.xml +++ b/doc/classes/Timer.xml @@ -21,8 +21,10 @@ <method name="start"> <return type="void"> </return> + <argument index="0" name="time_sec" type="float" default="-1"> + </argument> <description> - Starts the timer. This also resets the remaining time to [code]wait_time[/code]. + Starts the timer. Sets [code]wait_time[/code] to [code]time_sec[/code] if [code]time_sec[/code] > 0. This also resets the remaining time to [code]wait_time[/code]. Note: this method will not resume a paused timer. See [method set_paused]. </description> </method> diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index 54e445d3ee..95405cc4f6 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -1,18 +1,20 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="Tween" inherits="Node" category="Core" version="3.1"> <brief_description> - Node useful for animations with unknown start and end points. + Smoothly animates a node's properties over time. </brief_description> <description> - Node useful for animations with unknown start and end points, procedural animations, making one node follow another, and other simple behavior. - Because it is easy to get it wrong, here is a quick usage example: + Tweens are useful for animations requiring a numerical property to be interpolated over a range of values. The name *tween* comes from *in-betweening*, an animation technique where you specify *keyframes* and the computer interpolates the frames that appear between them. + Here is a brief usage example that causes a 2D node to move smoothly between two positions: [codeblock] var tween = get_node("Tween") - tween.interpolate_property(get_node("Node2D_to_move"), "transform/origin", Vector2(0,0), Vector2(100,100), 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) + tween.interpolate_property($Node2D, "position", + Vector2(0, 0), Vector2(100, 100), 1, + Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) tween.start() [/codeblock] - Some of the methods of this class require a property name. You can get the property name by hovering over the property in the inspector of the editor. - Many of the methods accept [code]trans_type[/code] and [code]ease_type[/code]. The first accepts an TRANS_* constant, and refers to the way the timing of the animation is handled (you might want to see [code]http://easings.net/[/code] for some examples). The second accepts an EASE_* constant, and controls the where [code]trans_type[/code] is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different TRANS_* constants with EASE_IN_OUT, and use the one that looks best. + Many methods require a property name, such as "position" above. You can find the correct property name by hovering over the property in the Inspector. + Many of the methods accept [code]trans_type[/code] and [code]ease_type[/code]. The first accepts an [enum TransitionType] constant, and refers to the way the timing of the animation is handled (see [code]http://easings.net/[/code] for some examples). The second accepts an [enum EaseType] constant, and controls the where [code]trans_type[/code] is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different [enum TransitionType] constants with [enum EASE_IN_OUT], and use the one that looks best. </description> <tutorials> </tutorials> @@ -41,8 +43,8 @@ <argument index="8" name="delay" type="float" default="0"> </argument> <description> - Follow [code]method[/code] of [code]object[/code] and apply the returned value on [code]target_method[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] later. Methods are animated by calling them with consequitive values. - [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. + Follows [code]method[/code] of [code]object[/code] and applies the returned value on [code]target_method[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] later. Methods are called with consecutive values. + Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information </description> </method> <method name="follow_property"> @@ -67,15 +69,15 @@ <argument index="8" name="delay" type="float" default="0"> </argument> <description> - Follow [code]property[/code] of [code]object[/code] and apply it on [code]target_property[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Note that [code]target:target_property[/code] would equal [code]object:property[/code] at the end of the tween. - [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. + Follows [code]property[/code] of [code]object[/code] and applies it on [code]target_property[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. + Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information </description> </method> <method name="get_runtime" qualifiers="const"> <return type="float"> </return> <description> - Returns the time needed for all tweens to end in seconds, measured from the start. Thus, if you have two tweens, one ending 10 seconds after the start and the other - 20 seconds, it would return 20 seconds, as by that time all tweens would have finished. + Returns the total time needed for all tweens to end. If you have two tweens, one lasting 10 seconds and the other 20 seconds, it would return 20 seconds, as by that time all tweens would have finished. </description> </method> <method name="interpolate_callback"> @@ -98,7 +100,7 @@ <argument index="7" name="arg5" type="Variant" default="null"> </argument> <description> - Call [code]callback[/code] of [code]object[/code] after [code]duration[/code]. [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback. + Calls [code]callback[/code] of [code]object[/code] after [code]duration[/code]. [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback. </description> </method> <method name="interpolate_deferred_callback"> @@ -121,7 +123,7 @@ <argument index="7" name="arg5" type="Variant" default="null"> </argument> <description> - Call [code]callback[/code] of [code]object[/code] after [code]duration[/code] on the main thread (similar to [method Object.call_deferred]). [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback. + Calls [code]callback[/code] of [code]object[/code] after [code]duration[/code] on the main thread (similar to [method Object.call_deferred]). [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback. </description> </method> <method name="interpolate_method"> @@ -144,8 +146,8 @@ <argument index="7" name="delay" type="float" default="0"> </argument> <description> - Animate [code]method[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are animated by calling them with consecutive values. - [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. + Animates [code]method[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are called with consecutive values. + Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information </description> </method> <method name="interpolate_property"> @@ -168,15 +170,15 @@ <argument index="7" name="delay" type="float" default="0"> </argument> <description> - Animate [code]property[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. - [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. + Animates [code]property[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. + Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information </description> </method> <method name="is_active" qualifiers="const"> <return type="bool"> </return> <description> - Returns true if any tweens are currently running, and false otherwise. Note that this method doesn't consider tweens that have ended. + Returns [code]true[/code] if any tweens are currently running. Note that this method doesn't consider tweens that have ended. </description> </method> <method name="remove"> @@ -187,14 +189,14 @@ <argument index="1" name="key" type="String" default=""""> </argument> <description> - Stop animating and completely remove a tween, given its object and property/method pair. Passing empty String as key will remove all tweens for given object. + Stops animation and removes a tween, given its object and property/method pair. By default, all tweens are removed, unless [code]key[/code] is specified. </description> </method> <method name="remove_all"> <return type="bool"> </return> <description> - Stop animating and completely remove all tweens. + Stops animation and removes all tweens. </description> </method> <method name="reset"> @@ -205,7 +207,7 @@ <argument index="1" name="key" type="String" default=""""> </argument> <description> - Resets a tween to the initial value (the one given, not the one before the tween), given its object and property/method pair. Passing empty String as key will reset all tweens for given object. + Resets a tween to its initial value (the one given, not the one before the tween), given its object and property/method pair. By default, all tweens are removed, unless [code]key[/code] is specified. </description> </method> <method name="reset_all"> @@ -223,14 +225,14 @@ <argument index="1" name="key" type="String" default=""""> </argument> <description> - Continue animating a stopped tween, given its object and property/method pair. Passing empty String as key will resume all tweens for given object. + Continues animating a stopped tween, given its object and property/method pair. By default, all tweens are resumed, unless [code]key[/code] is specified. </description> </method> <method name="resume_all"> <return type="bool"> </return> <description> - Continue animating all stopped tweens. + Continues animating all stopped tweens. </description> </method> <method name="seek"> @@ -239,7 +241,7 @@ <argument index="0" name="time" type="float"> </argument> <description> - Seek the animation to the given [code]time[/code] in seconds. + Sets the interpolation to the given [code]time[/code] in seconds. </description> </method> <method name="set_active"> @@ -248,14 +250,14 @@ <argument index="0" name="active" type="bool"> </argument> <description> - Activate/deactivate the tween. You can use this for pausing animations, though [method stop_all] and [method resume_all] might be more fit for this. + Activates/deactivates the tween. See also [method stop_all] and [method resume_all]. </description> </method> <method name="start"> <return type="bool"> </return> <description> - Start the tween node. You can define tweens both before and after this. + Starts the tween. You can define animations both before and after this. </description> </method> <method name="stop"> @@ -266,14 +268,14 @@ <argument index="1" name="key" type="String" default=""""> </argument> <description> - Stop animating a tween, given its object and property/method pair. Passing empty String as key will stop all tweens for given object. + Stops a tween, given its object and property/method pair. By default, all tweens are stopped, unless [code]key[/code] is specified. </description> </method> <method name="stop_all"> <return type="bool"> </return> <description> - Stop animating all tweens. + Stops animating all tweens. </description> </method> <method name="targeting_method"> @@ -298,8 +300,8 @@ <argument index="8" name="delay" type="float" default="0"> </argument> <description> - Animate [code]method[/code] of [code]object[/code] from the value returned by [code]initial.initial_method[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are animated by calling them with consecutive values. - [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. + Animates [code]method[/code] of [code]object[/code] from the value returned by [code]initial_method[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are animated by calling them with consecutive values. + Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information </description> </method> <method name="targeting_property"> @@ -324,8 +326,8 @@ <argument index="8" name="delay" type="float" default="0"> </argument> <description> - Animate [code]property[/code] of [code]object[/code] from the current value of the [code]initial_val[/code] property of [code]initial[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. - [code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the beginning, the end, or both). You can read more about them in the class description. + Animates [code]property[/code] of [code]object[/code] from the current value of the [code]initial_val[/code] property of [code]initial[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. + Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information </description> </method> <method name="tell" qualifiers="const"> @@ -338,12 +340,13 @@ </methods> <members> <member name="playback_process_mode" type="int" setter="set_tween_process_mode" getter="get_tween_process_mode" enum="Tween.TweenProcessMode"> + The tween's animation process thread. See [enum TweenProcessMode]. Default value: [enum TWEEN_PROCESS_IDLE]. </member> <member name="playback_speed" type="float" setter="set_speed_scale" getter="get_speed_scale"> - The speed multiplier of the tween. Set it to 1 for normal speed, 2 for two times nromal speed, and 0.5 for half of the normal speed. Setting it to 0 would pause the animation, but you might consider using [method set_active] or [method stop_all] and [method resume_all] for this. + The tween's speed multiplier. For example, set it to [code]1.0[/code] for normal speed, [code]2.0[/code] for two times normal speed, or [code]0.5[/code] for half of the normal speed. A value of [code]0[/code] pauses the animation, but see also [method set_active] or [method stop_all] for this. </member> <member name="repeat" type="bool" setter="set_repeat" getter="is_repeat"> - If [code]true[/code], the tween will repeat. + If [code]true[/code] the tween loops. </member> </members> <signals> @@ -353,7 +356,7 @@ <argument index="1" name="key" type="NodePath"> </argument> <description> - This signal is emitted when a tween ends. + Emitted when a tween ends. </description> </signal> <signal name="tween_started"> @@ -362,7 +365,7 @@ <argument index="1" name="key" type="NodePath"> </argument> <description> - This signal is emitted when a tween starts. + Emitted when a tween starts. </description> </signal> <signal name="tween_step"> @@ -375,61 +378,61 @@ <argument index="3" name="value" type="Object"> </argument> <description> - This signal is emitted each step of the tweening. + Emitted at each step of the animation. </description> </signal> </signals> <constants> <constant name="TWEEN_PROCESS_PHYSICS" value="0" enum="TweenProcessMode"> - The [code]Tween[/code] should use [code]_physics_process[/code] for timekeeping when this is enabled. + The tween updates with the [code]_physics_process[/code] callback. </constant> <constant name="TWEEN_PROCESS_IDLE" value="1" enum="TweenProcessMode"> - The [code]Tween[/code] should use [code]_process[/code] for timekeeping when this is enabled (default). + The tween updates with the [code]_process[/code] callback. </constant> <constant name="TRANS_LINEAR" value="0" enum="TransitionType"> - Means that the animation is interpolated linearly. + The animation is interpolated linearly. </constant> <constant name="TRANS_SINE" value="1" enum="TransitionType"> - Means that the animation is interpolated using a sine wave. + The animation is interpolated using a sine function. </constant> <constant name="TRANS_QUINT" value="2" enum="TransitionType"> - Means that the animation is interpolated with a quinary (to the power of 5) function. + The animation is interpolated with a quintic (to the power of 5) function. </constant> <constant name="TRANS_QUART" value="3" enum="TransitionType"> - Means that the animation is interpolated with a quartic (to the power of 4) function. + The animation is interpolated with a quartic (to the power of 4) function. </constant> <constant name="TRANS_QUAD" value="4" enum="TransitionType"> - Means that the animation is interpolated with a quadratic (to the power of 2) function. + The animation is interpolated with a quadratic (to the power of 2) function. </constant> <constant name="TRANS_EXPO" value="5" enum="TransitionType"> - Means that the animation is interpolated with an exponential (some number to the power of x) function. + The animation is interpolated with an exponential (to the power of x) function. </constant> <constant name="TRANS_ELASTIC" value="6" enum="TransitionType"> - Means that the animation is interpolated with elasticity, wiggling around the edges. + The animation is interpolated with elasticity, wiggling around the edges. </constant> <constant name="TRANS_CUBIC" value="7" enum="TransitionType"> - Means that the animation is interpolated with a cubic (to the power of 3) function. + The animation is interpolated with a cubic (to the power of 3) function. </constant> <constant name="TRANS_CIRC" value="8" enum="TransitionType"> - Means that the animation is interpolated with a function using square roots. + The animation is interpolated with a function using square roots. </constant> <constant name="TRANS_BOUNCE" value="9" enum="TransitionType"> - Means that the animation is interpolated by bouncing at, but never surpassing, the end. + The animation is interpolated by bouncing at the end. </constant> <constant name="TRANS_BACK" value="10" enum="TransitionType"> - Means that the animation is interpolated backing out at edges. + The animation is interpolated backing out at ends. </constant> <constant name="EASE_IN" value="0" enum="EaseType"> - Signifies that the interpolation should be focused in the beginning. + The interpolation starts slowly and speeds up towards the end. </constant> <constant name="EASE_OUT" value="1" enum="EaseType"> - Signifies that the interpolation should be focused in the end. + The interpolation starts quickly and slows down towards the end. </constant> <constant name="EASE_IN_OUT" value="2" enum="EaseType"> - Signifies that the interpolation should be focused in both ends. + A combination of EASE_IN and EASE_OUT. The interpolation is slowest at both ends. </constant> <constant name="EASE_OUT_IN" value="3" enum="EaseType"> - Signifies that the interpolation should be focused in both ends, but they should be switched (a bit hard to explain, try it for yourself to be sure). + A combination of EASE_IN and EASE_OUT. The interpolation is fastest at both ends. </constant> </constants> </class> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index a485205736..4878f7d932 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -212,6 +212,9 @@ <member name="hdr" type="bool" setter="set_hdr" getter="get_hdr"> If [code]true[/code] the viewport rendering will receive benefits from High Dynamic Range algorithm. Default value: [code]true[/code]. </member> + <member name="keep_3d_linear" type="bool" setter="set_keep_3d_linear" getter="get_keep_3d_linear"> + If [code]true[/code] the result after 3D rendering will not have a linear to sRGB color conversion applied. This is important when the viewport is used as a render target where the result is used as a texture on a 3D object rendered in another viewport. It is also important if the viewport is used to create data that is not color based (noise, heightmaps, pickmaps, etc.). Do not enable this when the viewport is used as a texture on a 2D object or if the viewport is your final output. + </member> <member name="msaa" type="int" setter="set_msaa" getter="get_msaa" enum="Viewport.MSAA"> The multisample anti-aliasing mode. Default value: [code]MSAA_DISABLED[/code]. </member> diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp index c84469f26f..6e451eabcd 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.cpp +++ b/drivers/coreaudio/audio_driver_coreaudio.cpp @@ -217,13 +217,24 @@ void AudioDriverCoreAudio::start() { if (!active) { OSStatus result = AudioOutputUnitStart(audio_unit); if (result != noErr) { - ERR_PRINT("AudioOutputUnitStart failed"); + ERR_PRINT(("AudioOutputUnitStart failed, code: " + itos(result)).utf8().get_data()); } else { active = true; } } }; +void AudioDriverCoreAudio::stop() { + if (active) { + OSStatus result = AudioOutputUnitStop(audio_unit); + if (result != noErr) { + ERR_PRINT(("AudioOutputUnitStop failed, code: " + itos(result)).utf8().get_data()); + } else { + active = false; + } + } +} + int AudioDriverCoreAudio::get_mix_rate() const { return mix_rate; }; diff --git a/drivers/coreaudio/audio_driver_coreaudio.h b/drivers/coreaudio/audio_driver_coreaudio.h index 9891920263..c44e225521 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.h +++ b/drivers/coreaudio/audio_driver_coreaudio.h @@ -90,6 +90,7 @@ public: virtual void finish(); bool try_lock(); + void stop(); AudioDriverCoreAudio(); ~AudioDriverCoreAudio(); diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index d7e679f596..6e7e1793e1 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -452,6 +452,11 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p texture->mipmaps = mipmaps; } +void RasterizerStorageGLES2::texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, VS::CubeMapSide p_cube_side) { + // TODO + ERR_PRINT("Not implemented (ask Karroffel to do it :p)"); +} + Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, VS::CubeMapSide p_cube_side) const { Texture *texture = texture_owner.getornull(p_texture); diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h index 748bff9b65..b735f2e148 100644 --- a/drivers/gles2/rasterizer_storage_gles2.h +++ b/drivers/gles2/rasterizer_storage_gles2.h @@ -237,6 +237,7 @@ public: virtual RID texture_create(); virtual void texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT); virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT); + virtual void texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT); virtual Ref<Image> texture_get_data(RID p_texture, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) const; virtual void texture_set_flags(RID p_texture, uint32_t p_flags); virtual uint32_t texture_get_flags(RID p_texture) const; diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index b221a41893..ff423bf0d0 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1210,6 +1210,9 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons if (shader_ptr->canvas_item.uses_screen_texture && !state.canvas_texscreen_used) { //copy if not copied before _copy_texscreen(Rect2()); + + // blend mode will have been enabled so make sure we disable it again later on + last_blend_mode = last_blend_mode != RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_DISABLED ? last_blend_mode : -1; } if (shader_ptr != shader_cache) { @@ -1281,14 +1284,30 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons } int blend_mode = shader_cache ? shader_cache->canvas_item.blend_mode : RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX; + if (blend_mode == RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_DISABLED && (!storage->frame.current_rt || !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT])) { + blend_mode = RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX; + } bool unshaded = shader_cache && (shader_cache->canvas_item.light_mode == RasterizerStorageGLES3::Shader::CanvasItem::LIGHT_MODE_UNSHADED || blend_mode != RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX); bool reclip = false; if (last_blend_mode != blend_mode) { + if (last_blend_mode == RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_DISABLED) { + // re-enable it + glEnable(GL_BLEND); + } else if (blend_mode == RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_DISABLED) { + // disable it + glDisable(GL_BLEND); + } switch (blend_mode) { + case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_DISABLED: { + + // nothing to do here + + } break; case RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX: { + glBlendEquation(GL_FUNC_ADD); if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) { glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 5b6b3d44f2..266b6aa670 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -3906,6 +3906,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p state.tonemap_shader.set_conditional(TonemapShaderGLES3::USE_FILMIC_TONEMAPPER, env->tone_mapper == VS::ENV_TONE_MAPPER_FILMIC); state.tonemap_shader.set_conditional(TonemapShaderGLES3::USE_ACES_TONEMAPPER, env->tone_mapper == VS::ENV_TONE_MAPPER_ACES); state.tonemap_shader.set_conditional(TonemapShaderGLES3::USE_REINDHART_TONEMAPPER, env->tone_mapper == VS::ENV_TONE_MAPPER_REINHARDT); + state.tonemap_shader.set_conditional(TonemapShaderGLES3::KEEP_3D_LINEAR, storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_KEEP_3D_LINEAR]); state.tonemap_shader.set_conditional(TonemapShaderGLES3::USE_AUTO_EXPOSURE, env->auto_exposure); state.tonemap_shader.set_conditional(TonemapShaderGLES3::USE_GLOW_FILTER_BICUBIC, env->glow_bicubic_upscale); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 77ac962e37..945df35456 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -828,6 +828,58 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p //texture_set_flags(p_texture,texture->flags); } +// Uploads pixel data to a sub-region of a texture, for the specified mipmap. +// The texture pixels must have been allocated before, because most features seen in texture_set_data() make no sense in a partial update. +// TODO If we want this to be usable without pre-filling pixels with a full image, we have to call glTexImage2D() with null data. +void RasterizerStorageGLES3::texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, VS::CubeMapSide p_cube_side) { + + Texture *texture = texture_owner.get(p_texture); + + ERR_FAIL_COND(!texture); + ERR_FAIL_COND(!texture->active); + ERR_FAIL_COND(texture->render_target); + ERR_FAIL_COND(texture->format != p_image->get_format()); + ERR_FAIL_COND(p_image.is_null()); + ERR_FAIL_COND(src_w <= 0 || src_h <= 0); + ERR_FAIL_COND(src_x < 0 || src_y < 0 || src_x + src_w > p_image->get_width() || src_y + src_h > p_image->get_height()); + ERR_FAIL_COND(dst_x < 0 || dst_y < 0 || dst_x + src_w > texture->alloc_width || dst_y + src_h > texture->alloc_height); + ERR_FAIL_COND(p_dst_mip < 0 || p_dst_mip >= texture->mipmaps); + + GLenum type; + GLenum format; + GLenum internal_format; + bool compressed; + bool srgb; + + // Because OpenGL wants data as a dense array, we have to extract the sub-image if the source rect isn't the full image + Ref<Image> p_sub_img = p_image; + if (src_x > 0 || src_y > 0 || src_w != p_image->get_width() || src_h != p_image->get_height()) { + p_sub_img = p_image->get_rect(Rect2(src_x, src_y, src_w, src_h)); + } + + Ref<Image> img = _get_gl_image_and_format(p_sub_img, p_sub_img->get_format(), texture->flags, format, internal_format, type, compressed, srgb); + + GLenum blit_target = (texture->target == GL_TEXTURE_CUBE_MAP) ? _cube_side_enum[p_cube_side] : GL_TEXTURE_2D; + + PoolVector<uint8_t>::Read read = img->get_data().read(); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(texture->target, texture->tex_id); + + int src_data_size = img->get_data().size(); + int src_ofs = 0; + + if (texture->compressed) { + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glCompressedTexSubImage2D(blit_target, p_dst_mip, dst_x, dst_y, src_w, src_h, internal_format, src_data_size, &read[src_ofs]); + + } else { + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + // `format` has to match the internal_format used when the texture was created + glTexSubImage2D(blit_target, p_dst_mip, dst_x, dst_y, src_w, src_h, format, type, &read[src_ofs]); + } +} + Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, VS::CubeMapSide p_cube_side) const { Texture *texture = texture_owner.get(p_texture); @@ -1615,6 +1667,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const { shaders.actions_canvas.render_mode_values["blend_sub"] = Pair<int *, int>(&p_shader->canvas_item.blend_mode, Shader::CanvasItem::BLEND_MODE_SUB); shaders.actions_canvas.render_mode_values["blend_mul"] = Pair<int *, int>(&p_shader->canvas_item.blend_mode, Shader::CanvasItem::BLEND_MODE_MUL); shaders.actions_canvas.render_mode_values["blend_premul_alpha"] = Pair<int *, int>(&p_shader->canvas_item.blend_mode, Shader::CanvasItem::BLEND_MODE_PMALPHA); + shaders.actions_canvas.render_mode_values["blend_disabled"] = Pair<int *, int>(&p_shader->canvas_item.blend_mode, Shader::CanvasItem::BLEND_MODE_DISABLED); shaders.actions_canvas.render_mode_values["unshaded"] = Pair<int *, int>(&p_shader->canvas_item.light_mode, Shader::CanvasItem::LIGHT_MODE_UNSHADED); shaders.actions_canvas.render_mode_values["light_only"] = Pair<int *, int>(&p_shader->canvas_item.light_mode, Shader::CanvasItem::LIGHT_MODE_LIGHT_ONLY); diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index def6eaa167..6b626cbd00 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -340,6 +340,7 @@ public: virtual RID texture_create(); virtual void texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT); virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT); + virtual void texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT); virtual Ref<Image> texture_get_data(RID p_texture, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) const; virtual void texture_set_flags(RID p_texture, uint32_t p_flags); virtual uint32_t texture_get_flags(RID p_texture) const; @@ -420,6 +421,7 @@ public: BLEND_MODE_SUB, BLEND_MODE_MUL, BLEND_MODE_PMALPHA, + BLEND_MODE_DISABLED, }; int blend_mode; diff --git a/drivers/gles3/shaders/tonemap.glsl b/drivers/gles3/shaders/tonemap.glsl index 2f671158b2..a75871f08e 100644 --- a/drivers/gles3/shaders/tonemap.glsl +++ b/drivers/gles3/shaders/tonemap.glsl @@ -258,9 +258,13 @@ void main() { #endif +#ifdef KEEP_3D_LINEAR + // leave color as is... +#else //regular Linear -> SRGB conversion vec3 a = vec3(0.055); color.rgb = mix( (vec3(1.0)+a)*pow(color.rgb,vec3(1.0/2.4))-a , 12.92*color.rgb , lessThan(color.rgb,vec3(0.0031308))); +#endif #if defined(USING_GLOW) glow = mix( (vec3(1.0)+a)*pow(glow,vec3(1.0/2.4))-a , 12.92*glow , lessThan(glow,vec3(0.0031308))); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 19bcb28fa5..24e86770bf 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -650,12 +650,12 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) { } void CodeTextEditor::_zoom_in() { - font_resize_val += EDSCALE; + font_resize_val += MAX(EDSCALE, 1.0f); _zoom_changed(); } void CodeTextEditor::_zoom_out() { - font_resize_val -= EDSCALE; + font_resize_val -= MAX(EDSCALE, 1.0f); _zoom_changed(); } diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index ef133e2589..7f93917744 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -35,6 +35,7 @@ #include "plugins/script_editor_plugin.h" #include "print_string.h" #include "scene/gui/label.h" +#include "scene/gui/popup_menu.h" class ConnectDialogBinds : public Object { @@ -87,51 +88,12 @@ public: } }; -void ConnectDialog::_notification(int p_what) { - - if (p_what == NOTIFICATION_ENTER_TREE) { - bind_editor->edit(cdbinds); - } -} - -void ConnectDialog::_tree_node_selected() { - - //dst_method_list->get_popup()->clear(); - Node *current = tree->get_selected(); - - if (!current) { - make_callback->hide(); - return; - } - - if (current->get_script().is_null()) - make_callback->hide(); - else - make_callback->show(); - - dst_path->set_text(node->get_path_to(current)); -} - -void ConnectDialog::edit(Node *p_node) { - - node = p_node; - - //dst_method_list->get_popup()->clear(); - - tree->set_selected(NULL); - tree->set_marked(node, true); - dst_path->set_text(""); - dst_method->set_text(""); - deferred->set_pressed(false); - oneshot->set_pressed(false); - cdbinds->params.clear(); - cdbinds->notify_changed(); -} - +/* +Signal automatically called by parent dialog. +*/ void ConnectDialog::ok_pressed() { if (dst_method->get_text() == "") { - error->set_text(TTR("Method in target Node must be specified!")); error->popup_centered_minsize(); return; @@ -147,39 +109,35 @@ void ConnectDialog::ok_pressed() { emit_signal("connected"); hide(); } + void ConnectDialog::_cancel_pressed() { hide(); } -NodePath ConnectDialog::get_dst_path() const { - - return dst_path->get_text(); -} - -bool ConnectDialog::get_deferred() const { - - return deferred->is_pressed(); -} - -bool ConnectDialog::get_oneshot() const { - - return oneshot->is_pressed(); -} +/* +Called each time a target node is selected within the target node tree. +*/ +void ConnectDialog::_tree_node_selected() { -StringName ConnectDialog::get_dst_method() const { + Node *current = tree->get_selected(); - String txt = dst_method->get_text(); - if (txt.find("(") != -1) - txt = txt.left(txt.find("(")).strip_edges(); - return txt; -} + if (!current) { + make_callback->hide(); + return; + } -Vector<Variant> ConnectDialog::get_binds() const { + if (current->get_script().is_null()) + make_callback->hide(); + else + make_callback->show(); - return cdbinds->params; + dst_path->set_text(source->get_path_to(current)); } +/* +Adds a new parameter bind to connection. +*/ void ConnectDialog::_add_bind() { if (cdbinds->params.size() >= VARIANT_ARG_MAX) @@ -189,7 +147,6 @@ void ConnectDialog::_add_bind() { Variant value; switch (vt) { - case Variant::BOOL: value = false; break; case Variant::INT: value = 0; break; case Variant::REAL: value = 0.0; break; @@ -203,7 +160,6 @@ void ConnectDialog::_add_bind() { case Variant::BASIS: value = Basis(); break; case Variant::TRANSFORM: value = Transform(); break; case Variant::COLOR: value = Color(); break; - default: { ERR_FAIL(); } break; } @@ -213,6 +169,9 @@ void ConnectDialog::_add_bind() { cdbinds->notify_changed(); } +/* +Remove parameter bind from connection. +*/ void ConnectDialog::_remove_bind() { String st = bind_editor->get_selected_path(); @@ -225,25 +184,106 @@ void ConnectDialog::_remove_bind() { cdbinds->notify_changed(); } +void ConnectDialog::_notification(int p_what) { + + if (p_what == NOTIFICATION_ENTER_TREE) { + bind_editor->edit(cdbinds); + } +} + +void ConnectDialog::_bind_methods() { + + ClassDB::bind_method("_cancel", &ConnectDialog::_cancel_pressed); + ClassDB::bind_method("_tree_node_selected", &ConnectDialog::_tree_node_selected); + ClassDB::bind_method("_add_bind", &ConnectDialog::_add_bind); + ClassDB::bind_method("_remove_bind", &ConnectDialog::_remove_bind); + + ADD_SIGNAL(MethodInfo("connected")); +} + +Node *ConnectDialog::get_source() const { + + return source; +} + +StringName ConnectDialog::get_signal_name() const { + + return signal; +} + +NodePath ConnectDialog::get_dst_path() const { + + return dst_path->get_text(); +} + void ConnectDialog::set_dst_node(Node *p_node) { tree->set_selected(p_node); } +StringName ConnectDialog::get_dst_method_name() const { + + String txt = dst_method->get_text(); + if (txt.find("(") != -1) + txt = txt.left(txt.find("(")).strip_edges(); + return txt; +} + void ConnectDialog::set_dst_method(const StringName &p_method) { dst_method->set_text(p_method); } -void ConnectDialog::_bind_methods() { +Vector<Variant> ConnectDialog::get_binds() const { - ClassDB::bind_method("_cancel", &ConnectDialog::_cancel_pressed); - ClassDB::bind_method("_tree_node_selected", &ConnectDialog::_tree_node_selected); + return cdbinds->params; +} - ClassDB::bind_method("_add_bind", &ConnectDialog::_add_bind); - ClassDB::bind_method("_remove_bind", &ConnectDialog::_remove_bind); +bool ConnectDialog::get_deferred() const { - ADD_SIGNAL(MethodInfo("connected")); + return deferred->is_pressed(); +} + +bool ConnectDialog::get_oneshot() const { + + return oneshot->is_pressed(); +} + +/* +Returns true if ConnectDialog is being used to edit an existing connection. +*/ +bool ConnectDialog::is_editing() const { + + return bEditMode; +} + +/* +Initialize ConnectDialog and populate fields with expected data. +If creating a connection from scratch, sensible defaults are used. +If editing an existing connection, previous data is retained. +*/ +void ConnectDialog::init(Connection c, bool bEdit) { + + source = static_cast<Node *>(c.source); + signal = c.signal; + + tree->set_selected(NULL); + tree->set_marked(source, true); + + set_dst_node(static_cast<Node *>(c.target)); + set_dst_method(c.method); + + bool bDeferred = (c.flags & CONNECT_DEFERRED) == CONNECT_DEFERRED; + bool bOneshot = (c.flags & CONNECT_ONESHOT) == CONNECT_ONESHOT; + + deferred->set_pressed(bDeferred); + oneshot->set_pressed(bOneshot); + + cdbinds->params.clear(); + cdbinds->params = c.binds; + cdbinds->notify_changed(); + + bEditMode = bEdit; } ConnectDialog::ConnectDialog() { @@ -261,6 +301,8 @@ ConnectDialog::ConnectDialog() { tree = memnew(SceneTreeEditor(false)); tree->get_scene_tree()->connect("item_activated", this, "_ok"); + tree->connect("node_selected", this, "_tree_node_selected"); + vbc_left->add_margin_child(TTR("Connect To Node:"), tree, true); VBoxContainer *vbc_right = memnew(VBoxContainer); @@ -272,12 +314,10 @@ ConnectDialog::ConnectDialog() { type_list = memnew(OptionButton); type_list->set_h_size_flags(SIZE_EXPAND_FILL); add_bind_hb->add_child(type_list); - type_list->add_item("bool", Variant::BOOL); type_list->add_item("int", Variant::INT); type_list->add_item("real", Variant::REAL); type_list->add_item("string", Variant::STRING); - //type_list->add_separator(); type_list->add_item("Vector2", Variant::VECTOR2); type_list->add_item("Rect2", Variant::RECT2); type_list->add_item("Vector3", Variant::VECTOR3); @@ -286,12 +326,10 @@ ConnectDialog::ConnectDialog() { type_list->add_item("AABB", Variant::AABB); type_list->add_item("Basis", Variant::BASIS); type_list->add_item("Transform", Variant::TRANSFORM); - //type_list->add_separator(); type_list->add_item("Color", Variant::COLOR); type_list->select(0); Button *add_bind = memnew(Button); - add_bind->set_text(TTR("Add")); add_bind_hb->add_child(add_bind); add_bind->connect("pressed", this, "_add_bind"); @@ -318,7 +356,8 @@ ConnectDialog::ConnectDialog() { dst_method->set_h_size_flags(SIZE_EXPAND_FILL); dstm_hb->add_child(dst_method); - /*dst_method_list = memnew( MenuButton ); + /* + dst_method_list = memnew( MenuButton ); dst_method_list->set_text("List..."); dst_method_list->set_anchor( MARGIN_RIGHT, ANCHOR_END ); dst_method_list->set_anchor( MARGIN_LEFT, ANCHOR_END ); @@ -327,7 +366,6 @@ ConnectDialog::ConnectDialog() { dst_method_list->set_begin( Point2( 70,59) ); dst_method_list->set_end( Point2( 15,39 ) ); */ - //add_child(dst_method_list); make_callback = memnew(CheckButton); make_callback->set_toggle_mode(true); @@ -343,8 +381,6 @@ ConnectDialog::ConnectDialog() { oneshot->set_text(TTR("Oneshot")); dstm_hb->add_child(oneshot); - tree->connect("node_selected", this, "_tree_node_selected"); - set_as_toplevel(true); cdbinds = memnew(ConnectDialogBinds); @@ -356,134 +392,365 @@ ConnectDialog::ConnectDialog() { } ConnectDialog::~ConnectDialog() { + memdelete(cdbinds); } -void ConnectionsDock::_notification(int p_what) { - - if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - update_tree(); - } -} +//ConnectionsDock ========================== -void ConnectionsDock::_close() { +struct _ConnectionsDockMethodInfoSort { - hide(); -} + _FORCE_INLINE_ bool operator()(const MethodInfo &a, const MethodInfo &b) const { + return a.name < b.name; + } +}; -void ConnectionsDock::_connect() { +/* +Post-ConnectDialog callback for creating/editing connections. +Creates or edits connections based on state of the ConnectDialog when "Connect" is pressed. +*/ +void ConnectionsDock::_make_or_edit_connection() { TreeItem *it = tree->get_selected(); ERR_FAIL_COND(!it); - String signal = it->get_metadata(0).operator Dictionary()["name"]; NodePath dst_path = connect_dialog->get_dst_path(); - Node *target = node->get_node(dst_path); + Node *target = selectedNode->get_node(dst_path); ERR_FAIL_COND(!target); - StringName dst_method = connect_dialog->get_dst_method(); + Connection cToMake; + cToMake.source = connect_dialog->get_source(); + cToMake.target = target; + cToMake.signal = connect_dialog->get_signal_name(); + cToMake.method = connect_dialog->get_dst_method_name(); + cToMake.binds = connect_dialog->get_binds(); bool defer = connect_dialog->get_deferred(); bool oshot = connect_dialog->get_oneshot(); - Vector<Variant> binds = connect_dialog->get_binds(); - PoolStringArray args = it->get_metadata(0).operator Dictionary()["args"]; - int flags = CONNECT_PERSIST | (defer ? CONNECT_DEFERRED : 0) | (oshot ? CONNECT_ONESHOT : 0); + cToMake.flags = CONNECT_PERSIST | (defer ? CONNECT_DEFERRED : 0) | (oshot ? CONNECT_ONESHOT : 0); - undo_redo->create_action(vformat(TTR("Connect '%s' to '%s'"), signal, String(dst_method))); - undo_redo->add_do_method(node, "connect", signal, target, dst_method, binds, flags); - undo_redo->add_undo_method(node, "disconnect", signal, target, dst_method); + if (connect_dialog->is_editing()) { + _disconnect(*it); + _connect(cToMake); + } else { + _connect(cToMake); + } + + if (connect_dialog->get_make_callback()) { + PoolStringArray args = it->get_metadata(0).operator Dictionary()["args"]; + editor->emit_signal("script_add_function_request", target, cToMake.method, args); + hide(); + } + + update_tree(); +} + +/* +Creates single connection w/ undo-redo functionality. +*/ +void ConnectionsDock::_connect(Connection cToMake) { + + Node *source = static_cast<Node *>(cToMake.source); + Node *target = static_cast<Node *>(cToMake.target); + + if (!source || !target) + return; + + undo_redo->create_action(vformat(TTR("Connect '%s' to '%s'"), String(cToMake.signal), String(cToMake.method))); + + undo_redo->add_do_method(source, "connect", cToMake.signal, target, cToMake.method, cToMake.binds, cToMake.flags); + undo_redo->add_undo_method(source, "disconnect", cToMake.signal, target, cToMake.method); undo_redo->add_do_method(this, "update_tree"); undo_redo->add_undo_method(this, "update_tree"); undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree - undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree + undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); undo_redo->commit_action(); +} - if (connect_dialog->get_make_callback()) { +/* +Break single connection w/ undo-redo functionality. +*/ +void ConnectionsDock::_disconnect(TreeItem &item) { - print_line("request connect"); - editor->emit_signal("script_add_function_request", target, dst_method, args); - hide(); + Connection c = item.get_metadata(0); + ERR_FAIL_COND(c.source != selectedNode); //shouldn't happen but...bugcheck + + undo_redo->create_action(vformat(TTR("Disconnect '%s' from '%s'"), c.signal, c.method)); + + undo_redo->add_do_method(selectedNode, "disconnect", c.signal, c.target, c.method); + undo_redo->add_undo_method(selectedNode, "connect", c.signal, c.target, c.method, c.binds, c.flags); + undo_redo->add_do_method(this, "update_tree"); + undo_redo->add_undo_method(this, "update_tree"); + undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree + undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); + + undo_redo->commit_action(); +} + +/* +Break all conections of currently selected signal. +Can undo-redo as a single action. +*/ +void ConnectionsDock::_disconnect_all() { + + TreeItem *item = tree->get_selected(); + + if (!_is_item_signal(*item)) + return; + + TreeItem *child = item->get_children(); + String signalName = item->get_metadata(0).operator Dictionary()["name"]; + undo_redo->create_action(vformat(TTR("Disconnect all from signal: '%s'"), signalName)); + + while (child) { + Connection c = child->get_metadata(0); + undo_redo->add_do_method(selectedNode, "disconnect", c.signal, c.target, c.method); + undo_redo->add_undo_method(selectedNode, "connect", c.signal, c.target, c.method, c.binds, c.flags); + child = child->get_next(); } - update_tree(); + undo_redo->add_do_method(this, "update_tree"); + undo_redo->add_undo_method(this, "update_tree"); + undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); + undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); + + undo_redo->commit_action(); } -void ConnectionsDock::_connect_pressed() { +void ConnectionsDock::_tree_item_selected() { TreeItem *item = tree->get_selected(); - if (!item) { - //no idea how this happened, but disable + if (!item) { //Unlikely. Disable button just in case. + connect_button->set_text(TTR("Connect...")); connect_button->set_disabled(true); + } else if (_is_item_signal(*item)) { + connect_button->set_text(TTR("Connect...")); + connect_button->set_disabled(false); + } else { + connect_button->set_text(TTR("Disconnect")); + connect_button->set_disabled(false); + } +} + +void ConnectionsDock::_tree_item_activated() { //"Activation" on double-click. + + TreeItem *item = tree->get_selected(); + + if (!item) return; + + if (_is_item_signal(*item)) { + _open_connection_dialog(*item); + } else { + _go_to_script(*item); } - if (item->get_parent() == tree->get_root() || item->get_parent()->get_parent() == tree->get_root()) { - //a signal - connect - String signal = item->get_metadata(0).operator Dictionary()["name"]; - String signalname = signal; - String midname = node->get_name(); - for (int i = 0; i < midname.length(); i++) { - CharType c = midname[i]; - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_') { - //all good - } else if (c == ' ') { +} + +bool ConnectionsDock::_is_item_signal(TreeItem &item) { + + return (item.get_parent() == tree->get_root() || item.get_parent()->get_parent() == tree->get_root()); +} + +/* +Open connection dialog with TreeItem data to CREATE a brand-new connection. +*/ +void ConnectionsDock::_open_connection_dialog(TreeItem &item) { + + String signal = item.get_metadata(0).operator Dictionary()["name"]; + String signalname = signal; + String midname = selectedNode->get_name(); + for (int i = 0; i < midname.length(); i++) { //TODO: Regex filter may be cleaner. + CharType c = midname[i]; + if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')) { + if (c == ' ') { + //Replace spaces with underlines. c = '_'; } else { + //Remove any other characters. midname.remove(i); i--; continue; } - - midname[i] = c; } + midname[i] = c; + } + + Node *dst_node = selectedNode->get_owner() ? selectedNode->get_owner() : selectedNode; + StringName dst_method = "_on_" + midname + "_" + signal; + + Connection c; + c.source = selectedNode; + c.signal = StringName(signalname); + c.target = dst_node; + c.method = dst_method; + + connect_dialog->init(c); + connect_dialog->set_title(TTR("Connect Signal: ") + signalname); + connect_dialog->popup_centered_ratio(); +} + +/* +Open connection dialog with Connection data to EDIT an existing connection. +*/ +void ConnectionsDock::_open_connection_dialog(Connection cToEdit) { + + Node *src = static_cast<Node *>(cToEdit.source); + Node *dst = static_cast<Node *>(cToEdit.target); - connect_dialog->edit(node); + if (src && dst) { + connect_dialog->init(cToEdit, true); + connect_dialog->set_title(TTR("Edit Connection: ") + cToEdit.signal); connect_dialog->popup_centered_ratio(); - connect_dialog->set_title(TTR("Connecting Signal:") + " " + signalname); - connect_dialog->set_dst_method("_on_" + midname + "_" + signal); - connect_dialog->set_dst_node(node->get_owner() ? node->get_owner() : node); + } +} + +/* +Open slot method location in script editor. +*/ +void ConnectionsDock::_go_to_script(TreeItem &item) { + + if (_is_item_signal(item)) + return; + + Connection c = item.get_metadata(0); + ERR_FAIL_COND(c.source != selectedNode); //shouldn't happen but...bugcheck + + if (!c.target) + return; + + Ref<Script> script = c.target->get_script(); + + if (script.is_null()) + return; + + if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, c.method)) { + editor->call("_editor_select", EditorNode::EDITOR_SCRIPT); + } +} + +void ConnectionsDock::_handle_signal_menu_option(int option) { + + TreeItem *item = tree->get_selected(); + + if (!item) + return; + + switch (option) { + case CONNECT: { + _open_connection_dialog(*item); + } break; + case DISCONNECT_ALL: { + StringName signalName = item->get_metadata(0).operator Dictionary()["name"]; + disconnect_all_dialog->set_text(TTR("Are you sure you want to remove all connections from the \"") + signalName + "\" signal?"); + disconnect_all_dialog->popup_centered(); + } break; + } +} + +void ConnectionsDock::_handle_slot_menu_option(int option) { + + TreeItem *item = tree->get_selected(); + + if (!item) + return; + + switch (option) { + case EDIT: { + Connection c = item->get_metadata(0); + _open_connection_dialog(c); + } break; + case GO_TO_SCRIPT: { + _go_to_script(*item); + } break; + case DISCONNECT: { + _disconnect(*item); + update_tree(); + } break; + } +} + +void ConnectionsDock::_rmb_pressed(Vector2 position) { + TreeItem *item = tree->get_selected(); + + if (!item) + return; + + Vector2 global_position = tree->get_global_position() + position; + + if (_is_item_signal(*item)) { + signal_menu->set_position(global_position); + signal_menu->popup(); } else { - //a slot- disconnect - Connection c = item->get_metadata(0); - ERR_FAIL_COND(c.source != node); //shouldn't happen but...bugcheck - - undo_redo->create_action(vformat(TTR("Disconnect '%s' from '%s'"), c.signal, c.method)); - undo_redo->add_do_method(node, "disconnect", c.signal, c.target, c.method); - undo_redo->add_undo_method(node, "connect", c.signal, c.target, c.method, Vector<Variant>(), c.flags); - undo_redo->add_do_method(this, "update_tree"); - undo_redo->add_undo_method(this, "update_tree"); - undo_redo->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree - undo_redo->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor(), "update_tree"); //to force redraw of scene tree - undo_redo->commit_action(); - - c.source->disconnect(c.signal, c.target, c.method); + slot_menu->set_position(global_position); + slot_menu->popup(); + } +} + +void ConnectionsDock::_close() { + + hide(); +} + +void ConnectionsDock::_connect_pressed() { + + TreeItem *item = tree->get_selected(); + if (!item) { + connect_button->set_disabled(true); + return; + } + + if (_is_item_signal(*item)) { + _open_connection_dialog(*item); + } else { + _disconnect(*item); update_tree(); } } -struct _ConnectionsDockMethodInfoSort { +void ConnectionsDock::_notification(int p_what) { - _FORCE_INLINE_ bool operator()(const MethodInfo &a, const MethodInfo &b) const { - return a.name < b.name; + if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { + update_tree(); } -}; +} + +void ConnectionsDock::_bind_methods() { + + ClassDB::bind_method("_make_or_edit_connection", &ConnectionsDock::_make_or_edit_connection); + ClassDB::bind_method("_disconnect_all", &ConnectionsDock::_disconnect_all); + ClassDB::bind_method("_tree_item_selected", &ConnectionsDock::_tree_item_selected); + ClassDB::bind_method("_tree_item_activated", &ConnectionsDock::_tree_item_activated); + ClassDB::bind_method("_handle_signal_menu_option", &ConnectionsDock::_handle_signal_menu_option); + ClassDB::bind_method("_handle_slot_menu_option", &ConnectionsDock::_handle_slot_menu_option); + ClassDB::bind_method("_rmb_pressed", &ConnectionsDock::_rmb_pressed); + ClassDB::bind_method("_close", &ConnectionsDock::_close); + ClassDB::bind_method("_connect_pressed", &ConnectionsDock::_connect_pressed); + ClassDB::bind_method("update_tree", &ConnectionsDock::update_tree); +} + +void ConnectionsDock::set_node(Node *p_node) { + + selectedNode = p_node; + update_tree(); +} void ConnectionsDock::update_tree() { tree->clear(); - if (!node) + if (!selectedNode) return; TreeItem *root = tree->create_item(); List<MethodInfo> node_signals; - node->get_signal_list(&node_signals); + selectedNode->get_signal_list(&node_signals); //node_signals.sort_custom<_ConnectionsDockMethodInfoSort>(); bool did_script = false; - StringName base = node->get_class(); + StringName base = selectedNode->get_class(); while (base) { @@ -493,7 +760,7 @@ void ConnectionsDock::update_tree() { if (!did_script) { - Ref<Script> scr = node->get_script(); + Ref<Script> scr = selectedNode->get_script(); if (scr.is_valid()) { scr->get_script_signal_list(&node_signals); if (scr->get_path().is_resource_file()) @@ -563,7 +830,7 @@ void ConnectionsDock::update_tree() { item->set_icon(0, get_icon("Signal", "EditorIcons")); List<Object::Connection> connections; - node->get_signal_connection_list(mi.name, &connections); + selectedNode->get_signal_connection_list(mi.name, &connections); for (List<Object::Connection>::Element *F = connections.front(); F; F = F->next()) { @@ -575,7 +842,7 @@ void ConnectionsDock::update_tree() { if (!target) continue; - String path = String(node->get_path_to(target)) + " :: " + c.method + "()"; + String path = String(selectedNode->get_path_to(target)) + " :: " + c.method + "()"; if (c.flags & CONNECT_DEFERRED) path += " (deferred)"; if (c.flags & CONNECT_ONESHOT) @@ -610,88 +877,6 @@ void ConnectionsDock::update_tree() { connect_button->set_disabled(true); } -void ConnectionsDock::set_node(Node *p_node) { - - node = p_node; - update_tree(); -} - -void ConnectionsDock::_something_selected() { - - TreeItem *item = tree->get_selected(); - if (!item) { - //no idea how this happened, but disable - connect_button->set_text(TTR("Connect...")); - connect_button->set_disabled(true); - - } else if (item->get_parent() == tree->get_root() || item->get_parent()->get_parent() == tree->get_root()) { - //a signal - connect - connect_button->set_text(TTR("Connect...")); - connect_button->set_disabled(false); - - } else { - //a slot- disconnect - connect_button->set_text(TTR("Disconnect")); - connect_button->set_disabled(false); - } -} - -void ConnectionsDock::_something_activated() { - - TreeItem *item = tree->get_selected(); - - if (!item) - return; - - if (item->get_parent() == tree->get_root() || item->get_parent()->get_parent() == tree->get_root()) { - // a signal - connect - String signal = item->get_metadata(0).operator Dictionary()["name"]; - String midname = node->get_name(); - for (int i = 0; i < midname.length(); i++) { - CharType c = midname[i]; - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_') { - //all good - } else if (c == ' ') { - c = '_'; - } else { - midname.remove(i); - i--; - continue; - } - - midname[i] = c; - } - - connect_dialog->edit(node); - connect_dialog->popup_centered_ratio(); - connect_dialog->set_dst_method("_on_" + midname + "_" + signal); - connect_dialog->set_dst_node(node->get_owner() ? node->get_owner() : node); - } else { - // a slot - go to target method - Connection c = item->get_metadata(0); - ERR_FAIL_COND(c.source != node); //shouldn't happen but...bugcheck - - if (!c.target) - return; - - Ref<Script> script = c.target->get_script(); - - if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, c.method)) { - editor->call("_editor_select", EditorNode::EDITOR_SCRIPT); - } - } -} - -void ConnectionsDock::_bind_methods() { - - ClassDB::bind_method("_connect", &ConnectionsDock::_connect); - ClassDB::bind_method("_something_selected", &ConnectionsDock::_something_selected); - ClassDB::bind_method("_something_activated", &ConnectionsDock::_something_activated); - ClassDB::bind_method("_close", &ConnectionsDock::_close); - ClassDB::bind_method("_connect_pressed", &ConnectionsDock::_connect_pressed); - ClassDB::bind_method("update_tree", &ConnectionsDock::update_tree); -} - ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { editor = p_editor; @@ -705,6 +890,7 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { tree->set_hide_root(true); vbc->add_child(tree); tree->set_v_size_flags(SIZE_EXPAND_FILL); + tree->set_allow_rmb_select(true); connect_button = memnew(Button); connect_button->set_text(TTR("Connect")); @@ -713,15 +899,29 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { hb->add_spacer(); hb->add_child(connect_button); connect_button->connect("pressed", this, "_connect_pressed"); - //add_child(tree); connect_dialog = memnew(ConnectDialog); connect_dialog->set_as_toplevel(true); add_child(connect_dialog); - remove_confirm = memnew(ConfirmationDialog); - remove_confirm->set_as_toplevel(true); - add_child(remove_confirm); + disconnect_all_dialog = memnew(ConfirmationDialog); + disconnect_all_dialog->set_as_toplevel(true); + add_child(disconnect_all_dialog); + disconnect_all_dialog->connect("confirmed", this, "_disconnect_all"); + disconnect_all_dialog->set_text(TTR("Are you sure you want to remove all connections from this signal?")); + + signal_menu = memnew(PopupMenu); + add_child(signal_menu); + signal_menu->connect("id_pressed", this, "_handle_signal_menu_option"); + signal_menu->add_item(TTR("Connect..."), CONNECT); + signal_menu->add_item(TTR("Disconnect All"), DISCONNECT_ALL); + + slot_menu = memnew(PopupMenu); + add_child(slot_menu); + slot_menu->connect("id_pressed", this, "_handle_slot_menu_option"); + slot_menu->add_item(TTR("Edit..."), EDIT); + slot_menu->add_item(TTR("Go To Method"), GO_TO_SCRIPT); + slot_menu->add_item(TTR("Disconnect"), DISCONNECT); /* node_only->set_anchor( MARGIN_TOP, ANCHOR_END ); @@ -732,10 +932,10 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { node_only->set_end( Point2( 10,44) ); */ - remove_confirm->connect("confirmed", this, "_remove_confirm"); - connect_dialog->connect("connected", this, "_connect"); - tree->connect("item_selected", this, "_something_selected"); - tree->connect("item_activated", this, "_something_activated"); + connect_dialog->connect("connected", this, "_make_or_edit_connection"); + tree->connect("item_selected", this, "_tree_item_selected"); + tree->connect("item_activated", this, "_tree_item_activated"); + tree->connect("item_rmb_selected", this, "_rmb_pressed"); add_constant_override("separation", 3 * EDSCALE); } diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 5e26e00f67..932ff693e4 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -28,6 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +/** +@author Juan Linietsky <reduzio@gmail.com> +*/ + #ifndef CONNECTIONS_DIALOG_H #define CONNECTIONS_DIALOG_H @@ -42,27 +46,28 @@ #include "scene/gui/tree.h" #include "undo_redo.h" -/** -@author Juan Linietsky <reduzio@gmail.com> -*/ - +class PopupMenu; class ConnectDialogBinds; class ConnectDialog : public ConfirmationDialog { GDCLASS(ConnectDialog, ConfirmationDialog); - ConfirmationDialog *error; + Node *source; + StringName signal; LineEdit *dst_path; LineEdit *dst_method; + ConnectDialogBinds *cdbinds; + bool bEditMode; + SceneTreeEditor *tree; + ConfirmationDialog *error; + PropertyEditor *bind_editor; OptionButton *type_list; CheckButton *deferred; CheckButton *oneshot; CheckButton *make_callback; - PropertyEditor *bind_editor; - Node *node; - ConnectDialogBinds *cdbinds; + void ok_pressed(); void _cancel_pressed(); void _tree_node_selected(); @@ -74,37 +79,71 @@ protected: static void _bind_methods(); public: - bool get_make_callback() { return make_callback->is_visible() && make_callback->is_pressed(); } + Node *get_source() const; + StringName get_signal_name() const; NodePath get_dst_path() const; - StringName get_dst_method() const; + void set_dst_node(Node *p_node); + StringName get_dst_method_name() const; + void set_dst_method(const StringName &p_method); + Vector<Variant> get_binds() const; + + bool get_make_callback() { return make_callback->is_visible() && make_callback->is_pressed(); } bool get_deferred() const; bool get_oneshot() const; - Vector<Variant> get_binds() const; - void set_dst_method(const StringName &p_method); - void set_dst_node(Node *p_node); + bool is_editing() const; - void edit(Node *p_node); + void init(Connection c, bool bEdit = false); ConnectDialog(); ~ConnectDialog(); }; +//======================================== + class ConnectionsDock : public VBoxContainer { GDCLASS(ConnectionsDock, VBoxContainer); - Button *connect_button; - EditorNode *editor; - Node *node; + //Right-click Pop-up Menu Options. + enum SignalMenuOption { + CONNECT, + DISCONNECT_ALL + }; + + enum SlotMenuOption { + EDIT, + GO_TO_SCRIPT, + DISCONNECT + }; + + Node *selectedNode; Tree *tree; - ConfirmationDialog *remove_confirm; + EditorNode *editor; + + ConfirmationDialog *disconnect_all_dialog; ConnectDialog *connect_dialog; + Button *connect_button; + PopupMenu *signal_menu; + PopupMenu *slot_menu; + UndoRedo *undo_redo; + + void _make_or_edit_connection(); + void _connect(Connection cToMake); + void _disconnect(TreeItem &item); + void _disconnect_all(); + void _tree_item_selected(); + void _tree_item_activated(); + bool _is_item_signal(TreeItem &item); + + void _open_connection_dialog(TreeItem &item); + void _open_connection_dialog(Connection cToEdit); + void _go_to_script(TreeItem &item); + + void _handle_signal_menu_option(int option); + void _handle_slot_menu_option(int option); + void _rmb_pressed(Vector2 position); void _close(); - void _connect(); - void _something_selected(); - void _something_activated(); - UndoRedo *undo_redo; protected: void _connect_pressed(); @@ -113,9 +152,7 @@ protected: public: void set_undoredo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; } - void set_node(Node *p_node); - String get_selected_type(); void update_tree(); ConnectionsDock(EditorNode *p_editor = NULL); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 78fb35e354..36978e37a5 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -87,7 +87,14 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode) { if (EditorSettings::get_singleton()->has_setting("interface/dialogs/create_new_node_bounds")) { popup(EditorSettings::get_singleton()->get("interface/dialogs/create_new_node_bounds")); } else { - popup_centered_ratio(); + + Size2 popup_size = Size2(900, 700) * editor_get_scale(); + Size2 window_size = get_viewport_rect().size; + + popup_size.x = MIN(window_size.x * 0.8, popup_size.x); + popup_size.y = MIN(window_size.y * 0.8, popup_size.y); + + popup_centered(popup_size); } if (p_dont_clear) { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 37a35b6ebf..b584107bcb 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -364,6 +364,14 @@ void EditorData::notify_edited_scene_changed() { } } +void EditorData::notify_resource_saved(const Ref<Resource> &p_resource) { + + for (int i = 0; i < editor_plugins.size(); i++) { + + editor_plugins[i]->notify_resource_saved(p_resource); + } +} + void EditorData::clear_editor_states() { for (int i = 0; i < editor_plugins.size(); i++) { diff --git a/editor/editor_data.h b/editor/editor_data.h index 1a498a6150..5a0b58464a 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -204,6 +204,7 @@ public: void save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary &p_custom); Dictionary restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history); void notify_edited_scene_changed(); + void notify_resource_saved(const Ref<Resource> &p_resource); EditorData(); }; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d8c85df83d..23c6ee4c3e 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -631,6 +631,7 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St ((Resource *)p_resource.ptr())->set_path(path); emit_signal("resource_saved", p_resource); + editor_data.notify_resource_saved(p_resource); } void EditorNode::save_resource(const Ref<Resource> &p_resource) { diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 336eaf719c..2e4e887165 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -473,6 +473,10 @@ void EditorPlugin::notify_scene_closed(const String &scene_filepath) { emit_signal("scene_closed", scene_filepath); } +void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) { + emit_signal("resource_saved", p_resource); +} + Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial *p_spatial) { //?? if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) { @@ -757,6 +761,7 @@ void EditorPlugin::_bind_methods() { ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node"))); ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath"))); ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name"))); + ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); BIND_ENUM_CONSTANT(CONTAINER_TOOLBAR); BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 05cc6e07e3..ebc4afdfeb 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -167,6 +167,7 @@ public: void notify_main_screen_changed(const String &screen_name); void notify_scene_changed(const Node *scn_root); void notify_scene_closed(const String &scene_filepath); + void notify_resource_saved(const Ref<Resource> &p_resource); virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial); virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 9f55ae32b0..4a9432780c 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -400,8 +400,17 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("editors/grid_map/pick_distance", 5000.0); - _initial_set("editors/3d/grid_color", Color::html("808080")); - hints["editors/3d/grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/grid_color", PROPERTY_HINT_COLOR_NO_ALPHA, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + _initial_set("editors/3d/primary_grid_color", Color::html("909090")); + hints["editors/3d/primary_grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/primary_grid_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + + _initial_set("editors/3d/secondary_grid_color", Color::html("606060")); + hints["editors/3d/secondary_grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/secondary_grid_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + + _initial_set("editors/3d/grid_size", 50); + hints["editors/3d/grid_size"] = PropertyInfo(Variant::INT, "editors/3d/grid_size", PROPERTY_HINT_RANGE, "1,500,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + + _initial_set("editors/3d/primary_grid_steps", 10); + hints["editors/3d/primary_grid_steps"] = PropertyInfo(Variant::INT, "editors/3d/primary_grid_steps", PROPERTY_HINT_RANGE, "1,100,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("editors/3d/default_fov", 70.0); _initial_set("editors/3d/default_z_near", 0.05); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index e93df835e4..bf7236cc2b 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -912,6 +912,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("shadow_as_outline", "Label", 0 * EDSCALE); theme->set_constant("line_spacing", "Label", 3 * EDSCALE); + // LinkButton + theme->set_stylebox("focus", "LinkButton", style_empty); + theme->set_color("font_color", "LinkButton", font_color); + // TooltipPanel Ref<StyleBoxFlat> style_tooltip = style_popup->duplicate(); style_tooltip->set_bg_color(Color(mono_color.r, mono_color.g, mono_color.b, 0.9)); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 8cad40c9ce..93aeca6632 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -467,32 +467,28 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no const real_t grab_distance = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); - bool locked = p_node->has_meta("_edit_lock_") && p_node->get_meta("_edit_lock_"); - - if (!locked) { - for (int i = p_node->get_child_count() - 1; i >= 0; i--) { - if (canvas_item && !canvas_item->is_set_as_toplevel()) { - _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_limit, p_parent_xform * canvas_item->get_transform(), p_canvas_xform); - } else { - CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); - _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_limit, Transform2D(), cl ? cl->get_transform() : p_canvas_xform); - } - if (p_limit != 0 && r_items.size() >= p_limit) - return; + for (int i = p_node->get_child_count() - 1; i >= 0; i--) { + if (canvas_item && !canvas_item->is_set_as_toplevel()) { + _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_limit, p_parent_xform * canvas_item->get_transform(), p_canvas_xform); + } else { + CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); + _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_limit, Transform2D(), cl ? cl->get_transform() : p_canvas_xform); } + if (p_limit != 0 && r_items.size() >= p_limit) + return; + } - if (canvas_item && canvas_item->is_visible_in_tree()) { - Transform2D xform = (p_parent_xform * p_canvas_xform * canvas_item->get_transform()).affine_inverse(); - const real_t local_grab_distance = xform.basis_xform(Vector2(grab_distance, 0)).length(); - if (canvas_item->_edit_is_selected_on_click(xform.xform(p_pos), local_grab_distance)) { - Node2D *node = Object::cast_to<Node2D>(canvas_item); + if (canvas_item && canvas_item->is_visible_in_tree()) { + Transform2D xform = (p_parent_xform * p_canvas_xform * canvas_item->get_transform()).affine_inverse(); + const real_t local_grab_distance = xform.basis_xform(Vector2(grab_distance, 0)).length(); + if (canvas_item->_edit_is_selected_on_click(xform.xform(p_pos), local_grab_distance)) { + Node2D *node = Object::cast_to<Node2D>(canvas_item); - _SelectResult res; - res.item = canvas_item; - res.z_index = node ? node->get_z_index() : 0; - res.has_z = node; - r_items.push_back(res); - } + _SelectResult res; + res.item = canvas_item; + res.z_index = node ? node->get_z_index() : 0; + res.has_z = node; + r_items.push_back(res); } } @@ -509,14 +505,14 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel for (int i = 0; i < r_items.size(); i++) { Node *node = r_items[i].item; - // Make sure the selected node is in the current scene - while (node && node != scene && node->get_owner() != scene) { + // Make sure the selected node is in the current scene, or editable + while (node && node != get_tree()->get_edited_scene_root() && node->get_owner() != scene && !scene->is_editable_instance(node->get_owner())) { node = node->get_parent(); }; // Replace the node by the group if grouped CanvasItem *canvas_item = Object::cast_to<CanvasItem>(node); - while (node && node != scene) { + while (node && node != scene->get_parent()) { CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node); if (canvas_item_tmp && node->has_meta("_edit_group_")) { canvas_item = canvas_item_tmp; @@ -525,7 +521,7 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel } //Remove the item if invalid - if (!canvas_item || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner()))) { + if (!canvas_item || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || (canvas_item->has_meta("_edit_lock_") && canvas_item->get_meta("_edit_lock_"))) { r_items.remove(i); i--; } else { @@ -541,13 +537,13 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n return; CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); + Node *scene = editor->get_edited_scene(); - bool inherited = p_node != get_tree()->get_edited_scene_root() && p_node->get_filename() != ""; - bool editable = !inherited || EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node); + bool editable = p_node == scene || p_node->get_owner() == scene || scene->is_editable_instance(p_node->get_owner()); bool lock_children = p_node->has_meta("_edit_group_") && p_node->get_meta("_edit_group_"); bool locked = p_node->has_meta("_edit_lock_") && p_node->get_meta("_edit_lock_"); - if (!lock_children && !locked && editable) { + if (!lock_children || !editable) { for (int i = p_node->get_child_count() - 1; i >= 0; i--) { if (canvas_item && !canvas_item->is_set_as_toplevel()) { _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, p_parent_xform * canvas_item->get_transform(), p_canvas_xform); @@ -558,7 +554,7 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n } } - if (canvas_item && canvas_item->is_visible_in_tree() && !canvas_item->has_meta("_edit_lock_")) { + if (canvas_item && canvas_item->is_visible_in_tree() && !locked && editable) { Transform2D xform = p_parent_xform * p_canvas_xform * canvas_item->get_transform(); if (canvas_item->_edit_use_rect()) { @@ -2593,9 +2589,6 @@ void CanvasItemEditor::_draw_bones() { for (Map<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) { - E->get().from = Vector2(); - E->get().to = Vector2(); - Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().from)); Node2D *to_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().to)); @@ -2615,9 +2608,6 @@ void CanvasItemEditor::_draw_bones() { else to = transform.xform(from_node->get_global_transform().xform(Vector2(E->get().length, 0))); - E->get().from = from; - E->get().to = to; - Vector2 rel = to - from; Vector2 relt = rel.tangent().normalized() * bone_width; Vector2 reln = rel.normalized(); @@ -2679,7 +2669,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans ERR_FAIL_COND(!p_node); Node *scene = editor->get_edited_scene(); - if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node)) + if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner())) return; CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); if (canvas_item && !canvas_item->is_visible()) @@ -2805,27 +2795,20 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) { } } - CanvasItem *c = Object::cast_to<CanvasItem>(p_node); - if (!c) { - return false; - } - - Node *p = c->get_parent(); - if (!p) { - return false; - } - - if (!c->is_visible()) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); + Node *scene = editor->get_edited_scene(); + if (!canvas_item || !canvas_item->is_visible() || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner()))) { return false; } - if (Object::cast_to<Bone2D>(c)) { + Node *parent = canvas_item->get_parent(); - if (Object::cast_to<Bone2D>(p)) { - //add as bone->parent relationship + if (Object::cast_to<Bone2D>(canvas_item)) { + if (Object::cast_to<Bone2D>(parent)) { + // Add as bone->parent relationship BoneKey bk; - bk.from = p->get_instance_id(); - bk.to = c->get_instance_id(); + bk.from = parent->get_instance_id(); + bk.to = canvas_item->get_instance_id(); if (!bone_list.has(bk)) { BoneList b; b.length = 0; @@ -2836,8 +2819,9 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) { } if (!has_child_bones) { + // Add a last bone if the Bone2D has no Bone2D child BoneKey bk; - bk.from = c->get_instance_id(); + bk.from = canvas_item->get_instance_id(); bk.to = 0; if (!bone_list.has(bk)) { BoneList b; @@ -2849,11 +2833,12 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) { return true; } - if (c->has_meta("_edit_bone_")) { + if (canvas_item->has_meta("_edit_bone_")) { + // Add a "custom bone" BoneKey bk; - bk.from = c->get_parent()->get_instance_id(); - bk.to = c->get_instance_id(); + bk.from = parent->get_instance_id(); + bk.to = canvas_item->get_instance_id(); if (!bone_list.has(bk)) { BoneList b; b.length = 0; @@ -2938,6 +2923,7 @@ void CanvasItemEditor::_notification(int p_what) { int nb_control = 0; int nb_having_pivot = 0; + // Update the viewport if the canvas_item changes List<CanvasItem *> selection = _get_edited_canvas_items(); for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { CanvasItem *canvas_item = E->get(); @@ -2983,12 +2969,14 @@ void CanvasItemEditor::_notification(int p_what) { nb_having_pivot++; } } + // Activate / Deactivate the pivot tool pivot_button->set_disabled(nb_having_pivot == 0); // Show / Hide the layout button presets_menu->set_visible(nb_control > 0 && nb_control == selection.size()); + // Update the viewport if bones changes for (Map<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) { Object *b = ObjectDB::get_instance(E->key().from); @@ -2999,7 +2987,7 @@ void CanvasItemEditor::_notification(int p_what) { } Node2D *b2 = Object::cast_to<Node2D>(b); - if (!b2) { + if (!b2 || !b2->is_inside_tree()) { continue; } diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index eb3595cae6..a1957b892e 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -266,8 +266,6 @@ class CanvasItemEditor : public VBoxContainer { Transform2D xform; float length; uint64_t last_pass; - Vector2 from; - Vector2 to; }; uint64_t bone_last_frame; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index c872a6f28b..45f5e667fa 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -746,6 +746,8 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c _goto_line(p_row); + result.class_name = result.class_name.trim_prefix("_"); + switch (result.type) { case ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION: { @@ -1007,6 +1009,10 @@ void ScriptTextEditor::_edit_option(int p_op) { } int next_line = to_line + 1; + if (to_line >= tx->get_line_count() - 1) { + tx->set_line(to_line, tx->get_line(to_line) + "\n"); + } + tx->begin_complex_operation(); for (int i = from_line; i <= to_line; i++) { diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index f341b970e2..1e6c736381 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -4598,7 +4598,10 @@ void SpatialEditor::_init_grid() { PoolVector<Color> grid_colors[3]; PoolVector<Vector3> grid_points[3]; - Color grid_color = EditorSettings::get_singleton()->get("editors/3d/grid_color"); + Color primary_grid_color = EditorSettings::get_singleton()->get("editors/3d/primary_grid_color"); + Color secondary_grid_color = EditorSettings::get_singleton()->get("editors/3d/secondary_grid_color"); + int grid_size = EditorSettings::get_singleton()->get("editors/3d/grid_size"); + int primary_grid_steps = EditorSettings::get_singleton()->get("editors/3d/primary_grid_steps"); for (int i = 0; i < 3; i++) { Vector3 axis; @@ -4608,19 +4611,17 @@ void SpatialEditor::_init_grid() { Vector3 axis_n2; axis_n2[(i + 2) % 3] = 1; -#define ORIGIN_GRID_SIZE 50 - - for (int j = -ORIGIN_GRID_SIZE; j <= ORIGIN_GRID_SIZE; j++) { - Vector3 p1 = axis_n1 * j + axis_n2 * -ORIGIN_GRID_SIZE; + for (int j = -grid_size; j <= grid_size; j++) { + Vector3 p1 = axis_n1 * j + axis_n2 * -grid_size; Vector3 p1_dest = p1 * (-axis_n2 + axis_n1); - Vector3 p2 = axis_n2 * j + axis_n1 * -ORIGIN_GRID_SIZE; + Vector3 p2 = axis_n2 * j + axis_n1 * -grid_size; Vector3 p2_dest = p2 * (-axis_n1 + axis_n2); - Color line_color = grid_color; + Color line_color = secondary_grid_color; if (j == 0) { continue; - } else if (j % 10 == 0) { - line_color *= 1.5; + } else if (j % primary_grid_steps == 0) { + line_color = primary_grid_color; } grid_points[i].push_back(p1); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 8b8c756219..9f87fc82b5 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -81,7 +81,14 @@ void ProjectExportDialog::popup_export() { if (EditorSettings::get_singleton()->has_setting("interface/dialogs/export_bounds")) { popup(EditorSettings::get_singleton()->get("interface/dialogs/export_bounds")); } else { - popup_centered_ratio(); + + Size2 popup_size = Size2(900, 700) * editor_get_scale(); + Size2 window_size = get_viewport_rect().size; + + popup_size.x = MIN(window_size.x * 0.8, popup_size.x); + popup_size.y = MIN(window_size.y * 0.8, popup_size.y); + + popup_centered(popup_size); } } diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 21f5e596be..a4265b4e32 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -768,7 +768,14 @@ void ProjectSettingsEditor::popup_project_settings() { if (EditorSettings::get_singleton()->has_setting("interface/dialogs/project_settings_bounds")) { popup(EditorSettings::get_singleton()->get("interface/dialogs/project_settings_bounds")); } else { - popup_centered_ratio(); + + Size2 popup_size = Size2(900, 700) * editor_get_scale(); + Size2 window_size = get_viewport_rect().size; + + popup_size.x = MIN(window_size.x * 0.8, popup_size.x); + popup_size.y = MIN(window_size.y * 0.8, popup_size.y); + + popup_centered(popup_size); } globals_editor->update_category_list(); _update_translations(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 38027a34a7..ba661813d6 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -107,7 +107,12 @@ void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) { void SceneTreeDock::instance(const String &p_file) { Node *parent = scene_tree->get_selected(); - if (!parent || !edited_scene) { + + if (!parent) { + Node *parent = edited_scene; + }; + + if (!edited_scene) { current_option = -1; accept->get_ok()->set_text(TTR("OK :(")); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index f50f9f6f5f..c3e9e4ab62 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -101,7 +101,14 @@ void EditorSettingsDialog::popup_edit_settings() { if (EditorSettings::get_singleton()->has_setting("interface/dialogs/editor_settings_bounds")) { popup(EditorSettings::get_singleton()->get("interface/dialogs/editor_settings_bounds")); } else { - popup_centered_ratio(0.7); + + Size2 popup_size = Size2(900, 700) * editor_get_scale(); + Size2 window_size = get_viewport_rect().size; + + popup_size.x = MIN(window_size.x * 0.8, popup_size.x); + popup_size.y = MIN(window_size.y * 0.8, popup_size.y); + + popup_centered(popup_size); } _focus_current_search_box(); diff --git a/methods.py b/methods.py index 792417866e..7cdc160075 100644 --- a/methods.py +++ b/methods.py @@ -93,7 +93,6 @@ def include_file_in_legacygl_header(filename, header_data, depth): enumbase = ifdefline[:ifdefline.find("_EN_")] ifdefline = ifdefline.replace("_EN_", "_") line = line.replace("_EN_", "_") -# print(enumbase+":"+ifdefline); if (enumbase not in header_data.enums): header_data.enums[enumbase] = [] if (ifdefline not in header_data.enums[enumbase]): @@ -192,9 +191,6 @@ def include_file_in_legacygl_header(filename, header_data, depth): line = line.replace("\r", "") line = line.replace("\n", "") - # line=line.replace("\\","\\\\") - # line=line.replace("\"","\\\"") - # line=line+"\\n\\" if (header_data.reading == "vertex"): header_data.vertex_lines += [line] @@ -224,7 +220,6 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 out_file_base = out_file out_file_base = out_file_base[out_file_base.rfind("/") + 1:] out_file_base = out_file_base[out_file_base.rfind("\\") + 1:] -# print("out file "+out_file+" base " +out_file_base) out_file_ifdef = out_file_base.replace(".", "_").upper() fd.write("#ifndef " + out_file_ifdef + class_suffix + "_120\n") fd.write("#define " + out_file_ifdef + class_suffix + "_120\n") @@ -262,10 +257,6 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int64_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, unsigned long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); - #fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, long p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"); fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n") fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n") fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n") @@ -367,10 +358,8 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 x = header_data.enums[xv] bits = 1 amt = len(x) -# print(x) while(2**bits < amt): bits += 1 -# print("amount: "+str(amt)+" bits "+str(bits)); strs = "{" for i in range(amt): strs += "\"#define " + x[i] + "\\n\"," @@ -658,7 +647,6 @@ def win32_spawn(sh, escape, cmd, args, env): newargs = ' '.join(args[1:]) cmdline = cmd + " " + newargs startupinfo = subprocess.STARTUPINFO() - #startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW for e in env: if type(env[e]) != type(""): env[e] = str(env[e]) @@ -998,7 +986,6 @@ def detect_visual_c_compiler_version(tools_env): # and for VS 2017 and newer we check VCTOOLSINSTALLDIR: if 'VCTOOLSINSTALLDIR' in tools_env: - # print("Checking VCTOOLSINSTALLDIR") # Newer versions have a different path available vc_amd64_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX64\\X64;") @@ -1027,13 +1014,6 @@ def detect_visual_c_compiler_version(tools_env): vc_chosen_compiler_index = vc_x86_amd64_compiler_detection_index vc_chosen_compiler_str = "x86_amd64" - # debug help - # print(vc_amd64_compiler_detection_index) - # print(vc_amd64_x86_compiler_detection_index) - # print(vc_x86_compiler_detection_index) - # print(vc_x86_amd64_compiler_detection_index) - # print("chosen "+str(vc_chosen_compiler_index)+ " | "+str(vc_chosen_compiler_str)) - return vc_chosen_compiler_str def find_visual_c_batch_file(env): @@ -1066,7 +1046,6 @@ def generate_vs_project(env, num_jobs): 'call "' + batch_file + '" !plat!'] result = " ^& ".join(common_build_prefix + [commands]) - # print("Building commandline: ", result) return result env.AddToVSProject(env.core_sources) diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 95bb472c7b..bd76c766a0 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -58,6 +58,10 @@ int NetworkedMultiplayerENet::get_packet_peer() const { Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int p_in_bandwidth, int p_out_bandwidth) { ERR_FAIL_COND_V(active, ERR_ALREADY_IN_USE); + ERR_FAIL_COND_V(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(p_max_clients < 0, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(p_in_bandwidth < 0, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(p_out_bandwidth < 0, ERR_INVALID_PARAMETER); ENetAddress address; @@ -80,8 +84,8 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int host = enet_host_create(&address /* the address to bind the server host to */, p_max_clients /* allow up to 32 clients and/or outgoing connections */, SYSCH_MAX /* allow up to SYSCH_MAX channels to be used */, - p_in_bandwidth /* assume any amount of incoming bandwidth */, - p_out_bandwidth /* assume any amount of outgoing bandwidth */); + p_in_bandwidth /* limit incoming bandwith if > 0 */, + p_out_bandwidth /* limit outgoing bandwith if > 0 */); ERR_FAIL_COND_V(!host, ERR_CANT_CREATE); @@ -93,15 +97,46 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int connection_status = CONNECTION_CONNECTED; return OK; } -Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_port, int p_in_bandwidth, int p_out_bandwidth) { +Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_port, int p_in_bandwidth, int p_out_bandwidth, int p_client_port) { ERR_FAIL_COND_V(active, ERR_ALREADY_IN_USE); + ERR_FAIL_COND_V(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(p_client_port < 0 || p_client_port > 65535, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(p_in_bandwidth < 0, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(p_out_bandwidth < 0, ERR_INVALID_PARAMETER); - host = enet_host_create(NULL /* create a client host */, - 1 /* only allow 1 outgoing connection */, - SYSCH_MAX /* allow up to SYSCH_MAX channels to be used */, - p_in_bandwidth /* limit incoming bandwith if > 0 */, - p_out_bandwidth /* limit outgoing bandwith if > 0 */); + if (p_client_port != 0) { + ENetAddress c_client; + +#ifdef GODOT_ENET + if (bind_ip.is_wildcard()) { + c_client.wildcard = 1; + } else { + enet_address_set_ip(&c_client, bind_ip.get_ipv6(), 16); + } +#else + if (bind_ip.is_wildcard()) { + c_client.host = 0; + } else { + ERR_FAIL_COND_V(!bind_ip.is_ipv4(), ERR_INVALID_PARAMETER); + c_client.host = *(uint32_t *)bind_ip.get_ipv4(); + } +#endif + + c_client.port = p_client_port; + + host = enet_host_create(&c_client /* create a client host */, + 1 /* only allow 1 outgoing connection */, + SYSCH_MAX /* allow up to SYSCH_MAX channels to be used */, + p_in_bandwidth /* limit incoming bandwith if > 0 */, + p_out_bandwidth /* limit outgoing bandwith if > 0 */); + } else { + host = enet_host_create(NULL /* create a client host */, + 1 /* only allow 1 outgoing connection */, + SYSCH_MAX /* allow up to SYSCH_MAX channels to be used */, + p_in_bandwidth /* limit incoming bandwith if > 0 */, + p_out_bandwidth /* limit outgoing bandwith if > 0 */); + } ERR_FAIL_COND_V(!host, ERR_CANT_CREATE); @@ -131,7 +166,7 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por unique_id = _gen_unique_id(); - /* Initiate the connection, allocating the enough channels */ + // Initiate connection, allocating enough channels ENetPeer *peer = enet_host_connect(host, &address, SYSCH_MAX, unique_id); if (peer == NULL) { @@ -173,7 +208,7 @@ void NetworkedMultiplayerENet::poll() { switch (event.type) { case ENET_EVENT_TYPE_CONNECT: { - /* Store any relevant client information here. */ + // Store any relevant client information here. if (server && refuse_connections) { enet_peer_reset(event.peer); @@ -183,7 +218,7 @@ void NetworkedMultiplayerENet::poll() { int *new_id = memnew(int); *new_id = event.data; - if (*new_id == 0) { // Data zero is sent by server (enet won't let you configure this). Server is always 1 + if (*new_id == 0) { // Data zero is sent by server (enet won't let you configure this). Server is always 1. *new_id = 1; } @@ -220,7 +255,7 @@ void NetworkedMultiplayerENet::poll() { } break; case ENET_EVENT_TYPE_DISCONNECT: { - /* Reset the peer's client information. */ + // Reset the peer's client information. int *id = (int *)event.peer->data; @@ -352,7 +387,7 @@ void NetworkedMultiplayerENet::poll() { incoming_packets.push_back(packet); } - // Destroy packet later.. + // Destroy packet later } else { ERR_CONTINUE(true); } @@ -371,10 +406,10 @@ bool NetworkedMultiplayerENet::is_server() const { return server; } -void NetworkedMultiplayerENet::close_connection() { +void NetworkedMultiplayerENet::close_connection(uint32_t wait_usec) { - if (!active) - return; + ERR_FAIL_COND(!active); + ERR_FAIL_COND(wait_usec < 0); _pop_current_packet(); @@ -388,7 +423,10 @@ void NetworkedMultiplayerENet::close_connection() { if (peers_disconnected) { enet_host_flush(host); - OS::get_singleton()->delay_usec(100); // Wait 100ms for disconnection packets to send + + if (wait_usec > 0) { + OS::get_singleton()->delay_usec(wait_usec); // Wait for disconnection packets to send + } } enet_host_destroy(host); @@ -432,6 +470,7 @@ int NetworkedMultiplayerENet::get_available_packet_count() const { return incoming_packets.size(); } + Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { ERR_FAIL_COND_V(incoming_packets.size() == 0, ERR_UNAVAILABLE); @@ -446,6 +485,7 @@ Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer, int &r_buff return OK; } + Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer_size) { ERR_FAIL_COND_V(!active, ERR_UNCONFIGURED); @@ -513,7 +553,7 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer } else { ERR_FAIL_COND_V(!peer_map.has(1), ERR_BUG); - enet_peer_send(peer_map[1], channel, packet); // Send to server for broadcast.. + enet_peer_send(peer_map[1], channel, packet); // Send to server for broadcast } enet_host_flush(host); @@ -722,8 +762,8 @@ int NetworkedMultiplayerENet::get_peer_port(int p_peer_id) const { void NetworkedMultiplayerENet::_bind_methods() { ClassDB::bind_method(D_METHOD("create_server", "port", "max_clients", "in_bandwidth", "out_bandwidth"), &NetworkedMultiplayerENet::create_server, DEFVAL(32), DEFVAL(0), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("create_client", "address", "port", "in_bandwidth", "out_bandwidth"), &NetworkedMultiplayerENet::create_client, DEFVAL(0), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("close_connection"), &NetworkedMultiplayerENet::close_connection); + ClassDB::bind_method(D_METHOD("create_client", "address", "port", "in_bandwidth", "out_bandwidth", "client_port"), &NetworkedMultiplayerENet::create_client, DEFVAL(0), DEFVAL(0), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("close_connection", "wait_usec"), &NetworkedMultiplayerENet::close_connection, DEFVAL(100)); ClassDB::bind_method(D_METHOD("disconnect_peer", "id", "now"), &NetworkedMultiplayerENet::disconnect_peer, DEFVAL(false)); ClassDB::bind_method(D_METHOD("set_compression_mode", "mode"), &NetworkedMultiplayerENet::set_compression_mode); ClassDB::bind_method(D_METHOD("get_compression_mode"), &NetworkedMultiplayerENet::get_compression_mode); @@ -764,7 +804,7 @@ NetworkedMultiplayerENet::~NetworkedMultiplayerENet() { close_connection(); } -// Sets IP for ENet to bind when using create_server +// Sets IP for ENet to bind when using create_server or create_client // if no IP is set, then ENet bind to ENET_HOST_ANY void NetworkedMultiplayerENet::set_bind_ip(const IP_Address &p_ip) { ERR_FAIL_COND(!p_ip.is_valid() && !p_ip.is_wildcard()); diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h index 678ae24135..d481f5d496 100644 --- a/modules/enet/networked_multiplayer_enet.h +++ b/modules/enet/networked_multiplayer_enet.h @@ -119,9 +119,9 @@ public: virtual int get_peer_port(int p_peer_id) const; Error create_server(int p_port, int p_max_clients = 32, int p_in_bandwidth = 0, int p_out_bandwidth = 0); - Error create_client(const String &p_address, int p_port, int p_in_bandwidth = 0, int p_out_bandwidth = 0); + Error create_client(const String &p_address, int p_port, int p_in_bandwidth = 0, int p_out_bandwidth = 0, int p_client_port = 0); - void close_connection(); + void close_connection(uint32_t wait_usec = 100); void disconnect_peer(int p_peer, bool now = false); diff --git a/platform/iphone/app_delegate.h b/platform/iphone/app_delegate.h index f14864b5b7..c34b5053d6 100644 --- a/platform/iphone/app_delegate.h +++ b/platform/iphone/app_delegate.h @@ -37,6 +37,7 @@ @interface AppDelegate : NSObject <UIApplicationDelegate, GLViewDelegate> { //@property (strong, nonatomic) UIWindow *window; ViewController *view_controller; + bool is_focus_out; }; @property(strong, nonatomic) UIWindow *window; diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 9e6bbff1d7..7ed1328b20 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -140,6 +140,42 @@ void _ios_add_joystick(GCController *controller, AppDelegate *delegate) { }; } +static void on_focus_out(ViewController *view_controller, bool *is_focus_out) { + if (!*is_focus_out) { + *is_focus_out = true; + if (OS::get_singleton()->get_main_loop()) + OS::get_singleton()->get_main_loop()->notification( + MainLoop::NOTIFICATION_WM_FOCUS_OUT); + + [view_controller.view stopAnimation]; + if (OS::get_singleton()->native_video_is_playing()) { + OSIPhone::get_singleton()->native_video_focus_out(); + } + + AudioDriverCoreAudio *audio = dynamic_cast<AudioDriverCoreAudio *>(AudioDriverCoreAudio::get_singleton()); + if (audio) + audio->stop(); + } +} + +static void on_focus_in(ViewController *view_controller, bool *is_focus_out) { + if (*is_focus_out) { + *is_focus_out = false; + if (OS::get_singleton()->get_main_loop()) + OS::get_singleton()->get_main_loop()->notification( + MainLoop::NOTIFICATION_WM_FOCUS_IN); + + [view_controller.view startAnimation]; + if (OSIPhone::get_singleton()->native_video_is_playing()) { + OSIPhone::get_singleton()->native_video_unpause(); + } + + AudioDriverCoreAudio *audio = dynamic_cast<AudioDriverCoreAudio *>(AudioDriverCoreAudio::get_singleton()); + if (audio) + audio->start(); + } +} + - (void)controllerWasConnected:(NSNotification *)notification { // create our dictionary if we don't have one yet if (ios_joysticks == nil) { @@ -569,6 +605,8 @@ static int frame_count = 0; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { CGRect rect = [[UIScreen mainScreen] bounds]; + is_focus_out = false; + [application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; // disable idle timer // application.idleTimerDisabled = YES; @@ -628,6 +666,12 @@ static int frame_count = 0; [self initGameControllers]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(onAudioInterruption:) + name:AVAudioSessionInterruptionNotification + object:[AVAudioSession sharedInstance]]; + // OSIPhone::screen_width = rect.size.width - rect.origin.x; // OSIPhone::screen_height = rect.size.height - rect.origin.y; @@ -639,6 +683,18 @@ static int frame_count = 0; return TRUE; }; +- (void)onAudioInterruption:(NSNotification *)notification { + if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) { + if ([[notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey] isEqualToNumber:[NSNumber numberWithInt:AVAudioSessionInterruptionTypeBegan]]) { + NSLog(@"Audio interruption began"); + on_focus_out(view_controller, &is_focus_out); + } else if ([[notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey] isEqualToNumber:[NSNumber numberWithInt:AVAudioSessionInterruptionTypeEnded]]) { + NSLog(@"Audio interruption ended"); + on_focus_in(view_controller, &is_focus_out); + } + } +}; + - (void)applicationWillTerminate:(UIApplication *)application { [self deinitGameControllers]; @@ -656,14 +712,7 @@ static int frame_count = 0; - (void)applicationDidEnterBackground:(UIApplication *)application { ///@TODO maybe add pause motionManager? and where would we unpause it? - if (OS::get_singleton()->get_main_loop()) - OS::get_singleton()->get_main_loop()->notification( - MainLoop::NOTIFICATION_WM_FOCUS_OUT); - - [view_controller.view stopAnimation]; - if (OS::get_singleton()->native_video_is_playing()) { - OSIPhone::get_singleton()->native_video_focus_out(); - }; + on_focus_out(view_controller, &is_focus_out); } - (void)applicationWillEnterForeground:(UIApplication *)application { @@ -678,19 +727,7 @@ static int frame_count = 0; } - (void)applicationDidBecomeActive:(UIApplication *)application { - if (OS::get_singleton()->get_main_loop()) - OS::get_singleton()->get_main_loop()->notification( - MainLoop::NOTIFICATION_WM_FOCUS_IN); - - [view_controller.view - startAnimation]; // FIXME: resume seems to be recommended elsewhere - if (OSIPhone::get_singleton()->native_video_is_playing()) { - OSIPhone::get_singleton()->native_video_unpause(); - }; - - // Fixed audio can not resume if it is interrupted cause by an incoming phone call - if (AudioDriverCoreAudio::get_singleton() != NULL) - AudioDriverCoreAudio::get_singleton()->start(); + on_focus_in(view_controller, &is_focus_out); } - (void)dealloc { diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index a2637f816e..27bdeda4a8 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -94,6 +94,7 @@ void CanvasItemMaterial::_update_shader() { case BLEND_MODE_SUB: code += "blend_sub"; break; case BLEND_MODE_MUL: code += "blend_mul"; break; case BLEND_MODE_PREMULT_ALPHA: code += "blend_premul_alpha"; break; + case BLEND_MODE_DISABLED: code += "blend_disabled"; break; } switch (light_mode) { @@ -1105,6 +1106,7 @@ void CanvasItem::_bind_methods() { BIND_ENUM_CONSTANT(BLEND_MODE_SUB); BIND_ENUM_CONSTANT(BLEND_MODE_MUL); BIND_ENUM_CONSTANT(BLEND_MODE_PREMULT_ALPHA); + BIND_ENUM_CONSTANT(BLEND_MODE_DISABLED); BIND_CONSTANT(NOTIFICATION_TRANSFORM_CHANGED); BIND_CONSTANT(NOTIFICATION_DRAW); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 85de0d2796..10d5082dfc 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -54,7 +54,8 @@ public: BLEND_MODE_ADD, BLEND_MODE_SUB, BLEND_MODE_MUL, - BLEND_MODE_PREMULT_ALPHA + BLEND_MODE_PREMULT_ALPHA, + BLEND_MODE_DISABLED }; enum LightMode { @@ -145,7 +146,8 @@ public: BLEND_MODE_ADD, BLEND_MODE_SUB, BLEND_MODE_MUL, - BLEND_MODE_PREMULT_ALPHA + BLEND_MODE_PREMULT_ALPHA, + BLEND_MODE_DISABLED }; private: diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index eca7caeaf0..eb3954af20 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1208,7 +1208,7 @@ NodePath AnimationPlayer::get_root() const { void AnimationPlayer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { String pf = p_function; - if (p_function == "play" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue") { + if (p_function == "play" || p_function == "play_backwards" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue") { List<StringName> al; get_animation_list(&al); for (List<StringName>::Element *E = al.front(); E; E = E->next()) { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index ffc8a72164..34114ae7db 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -692,9 +692,7 @@ void RichTextLabel::_scroll_changed(double) { void RichTextLabel::_update_scroll() { - int total_height = 0; - if (main->lines.size()) - total_height = main->lines[main->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height; + int total_height = get_content_height(); bool exceeds = total_height > get_size().height && scroll_active; @@ -2058,6 +2056,13 @@ float RichTextLabel::get_percent_visible() const { return percent_visible; } +int RichTextLabel::get_content_height() { + int total_height = 0; + if (main->lines.size()) + total_height = main->lines[main->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height; + return total_height; +} + void RichTextLabel::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &RichTextLabel::_gui_input); @@ -2124,6 +2129,8 @@ void RichTextLabel::_bind_methods() { ClassDB::bind_method(D_METHOD("get_line_count"), &RichTextLabel::get_line_count); ClassDB::bind_method(D_METHOD("get_visible_line_count"), &RichTextLabel::get_visible_line_count); + ClassDB::bind_method(D_METHOD("get_content_height"), &RichTextLabel::get_content_height); + ADD_GROUP("BBCode", "bbcode_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bbcode_enabled"), "set_use_bbcode", "is_using_bbcode"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "bbcode_text", PROPERTY_HINT_MULTILINE_TEXT), "set_bbcode", "get_bbcode"); diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 850638bff3..e054ce3935 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -340,6 +340,8 @@ public: int get_line_count() const; int get_visible_line_count() const; + int get_content_height(); + VScrollBar *get_v_scroll() { return vscroll; } virtual CursorShape get_cursor_shape(const Point2 &p_pos) const; diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index ad2cdbfd0f..c285694dfa 100755 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -107,7 +107,10 @@ bool Timer::has_autostart() const { return autostart; } -void Timer::start() { +void Timer::start(float p_time) { + if (p_time > 0) { + set_wait_time(p_time); + } time_left = wait_time; _set_process(true); } @@ -185,7 +188,7 @@ void Timer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_autostart", "enable"), &Timer::set_autostart); ClassDB::bind_method(D_METHOD("has_autostart"), &Timer::has_autostart); - ClassDB::bind_method(D_METHOD("start"), &Timer::start); + ClassDB::bind_method(D_METHOD("start", "time_sec"), &Timer::start, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("stop"), &Timer::stop); ClassDB::bind_method(D_METHOD("set_paused", "paused"), &Timer::set_paused); diff --git a/scene/main/timer.h b/scene/main/timer.h index 410d985407..2f42252a7e 100755 --- a/scene/main/timer.h +++ b/scene/main/timer.h @@ -64,7 +64,7 @@ public: void set_autostart(bool p_start); bool has_autostart() const; - void start(); + void start(float p_time = -1); void stop(); void set_paused(bool p_paused); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 568a765420..11b663e413 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2477,6 +2477,16 @@ bool Viewport::is_3d_disabled() const { return disable_3d; } +void Viewport::set_keep_3d_linear(bool p_keep_3d_linear) { + keep_3d_linear = p_keep_3d_linear; + VS::get_singleton()->viewport_set_keep_3d_linear(viewport, keep_3d_linear); +} + +bool Viewport::get_keep_3d_linear() const { + + return keep_3d_linear; +} + Variant Viewport::gui_get_drag_data() const { return gui.drag_data; } @@ -2660,6 +2670,9 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_disable_3d", "disable"), &Viewport::set_disable_3d); ClassDB::bind_method(D_METHOD("is_3d_disabled"), &Viewport::is_3d_disabled); + ClassDB::bind_method(D_METHOD("set_keep_3d_linear", "keep_3d_linear"), &Viewport::set_keep_3d_linear); + ClassDB::bind_method(D_METHOD("get_keep_3d_linear"), &Viewport::get_keep_3d_linear); + ClassDB::bind_method(D_METHOD("_gui_show_tooltip"), &Viewport::_gui_show_tooltip); ClassDB::bind_method(D_METHOD("_gui_remove_focus"), &Viewport::_gui_remove_focus); ClassDB::bind_method(D_METHOD("_post_gui_grab_click_focus"), &Viewport::_post_gui_grab_click_focus); @@ -2684,6 +2697,7 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x"), "set_msaa", "get_msaa"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hdr"), "set_hdr", "get_hdr"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_3d"), "set_disable_3d", "is_3d_disabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_3d_linear"), "set_keep_3d_linear", "get_keep_3d_linear"); ADD_PROPERTY(PropertyInfo(Variant::INT, "usage", PROPERTY_HINT_ENUM, "2D,2D No-Sampling,3D,3D No-Effects"), "set_usage", "get_usage"); ADD_PROPERTY(PropertyInfo(Variant::INT, "debug_draw", PROPERTY_HINT_ENUM, "Disabled,Unshaded,Overdraw,Wireframe"), "set_debug_draw", "get_debug_draw"); ADD_GROUP("Render Target", "render_target_"); @@ -2806,6 +2820,7 @@ Viewport::Viewport() { disable_input = false; disable_3d = false; + keep_3d_linear = false; //window tooltip gui.tooltip_timer = -1; diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 94e49033e0..162a902c8a 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -226,6 +226,7 @@ private: void _update_global_transform(); bool disable_3d; + bool keep_3d_linear; UpdateMode update_mode; RID texture_rid; uint32_t texture_flags; @@ -433,6 +434,9 @@ public: void set_disable_3d(bool p_disable); bool is_3d_disabled() const; + void set_keep_3d_linear(bool p_keep_3d_linear); + bool get_keep_3d_linear() const; + void set_attach_to_screen_rect(const Rect2 &p_rect); Rect2 get_attach_to_screen_rect() const; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index c49388436b..8d8e9e693e 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -175,6 +175,7 @@ public: virtual RID texture_create() = 0; virtual void texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT) = 0; virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) = 0; + virtual void texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) = 0; virtual Ref<Image> texture_get_data(RID p_texture, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) const = 0; virtual void texture_set_flags(RID p_texture, uint32_t p_flags) = 0; virtual uint32_t texture_get_flags(RID p_texture) const = 0; @@ -514,6 +515,7 @@ public: RENDER_TARGET_NO_3D, RENDER_TARGET_NO_SAMPLING, RENDER_TARGET_HDR, + RENDER_TARGET_KEEP_3D_LINEAR, RENDER_TARGET_FLAG_MAX }; diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index a4053ad415..2f05f6d477 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -231,6 +231,7 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_sub"); shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_mul"); shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_premul_alpha"); + shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_disabled"); shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("unshaded"); shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("light_only"); diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 5b7ea34cfe..8f19de9f8b 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -148,6 +148,7 @@ public: BIND0R(RID, texture_create) BIND5(texture_allocate, RID, int, int, Image::Format, uint32_t) BIND3(texture_set_data, RID, const Ref<Image> &, CubeMapSide) + BIND10(texture_set_data_partial, RID, const Ref<Image> &, int, int, int, int, int, int, int, CubeMapSide) BIND2RC(Ref<Image>, texture_get_data, RID, CubeMapSide) BIND2(texture_set_flags, RID, uint32_t) BIND1RC(uint32_t, texture_get_flags, RID) @@ -451,6 +452,7 @@ public: BIND2(viewport_set_hide_canvas, RID, bool) BIND2(viewport_set_disable_environment, RID, bool) BIND2(viewport_set_disable_3d, RID, bool) + BIND2(viewport_set_keep_3d_linear, RID, bool) BIND2(viewport_attach_camera, RID, RID) BIND2(viewport_set_scenario, RID, RID) diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp index 83e05f6f25..dcc270ca5e 100644 --- a/servers/visual/visual_server_viewport.cpp +++ b/servers/visual/visual_server_viewport.cpp @@ -178,11 +178,14 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E VSG::rasterizer->restore_render_target(); if (scenario_draw_canvas_bg && canvas_map.front() && canvas_map.front()->key().layer > scenario_canvas_max_layer) { + Ref<ARVRInterface> arvr_interface = ARVRServer::get_singleton()->get_primary_interface(); - if (can_draw_3d) { - VSG::scene->render_camera(p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); - } else { + if (!can_draw_3d) { VSG::scene->render_empty_scene(p_viewport->scenario, p_viewport->shadow_atlas); + } else if (p_viewport->use_arvr && arvr_interface.is_valid()) { + VSG::scene->render_camera(arvr_interface, p_eye, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); + } else { + VSG::scene->render_camera(p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); } scenario_draw_canvas_bg = false; } @@ -210,11 +213,14 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E i++; if (scenario_draw_canvas_bg && E->key().layer >= scenario_canvas_max_layer) { + Ref<ARVRInterface> arvr_interface = ARVRServer::get_singleton()->get_primary_interface(); - if (can_draw_3d) { - VSG::scene->render_camera(p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); - } else { + if (!can_draw_3d) { VSG::scene->render_empty_scene(p_viewport->scenario, p_viewport->shadow_atlas); + } else if (p_viewport->use_arvr && arvr_interface.is_valid()) { + VSG::scene->render_camera(arvr_interface, p_eye, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); + } else { + VSG::scene->render_camera(p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); } scenario_draw_canvas_bg = false; @@ -222,11 +228,14 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E } if (scenario_draw_canvas_bg) { + Ref<ARVRInterface> arvr_interface = ARVRServer::get_singleton()->get_primary_interface(); - if (can_draw_3d) { - VSG::scene->render_camera(p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); - } else { + if (!can_draw_3d) { VSG::scene->render_empty_scene(p_viewport->scenario, p_viewport->shadow_atlas); + } else if (p_viewport->use_arvr && arvr_interface.is_valid()) { + VSG::scene->render_camera(arvr_interface, p_eye, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); + } else { + VSG::scene->render_camera(p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); } scenario_draw_canvas_bg = false; @@ -453,6 +462,15 @@ void VisualServerViewport::viewport_set_disable_3d(RID p_viewport, bool p_disabl //this should be just for disabling rendering of 3D, to actually disable it, set usage } +void VisualServerViewport::viewport_set_keep_3d_linear(RID p_viewport, bool p_keep_3d_linear) { + + Viewport *viewport = viewport_owner.getornull(p_viewport); + ERR_FAIL_COND(!viewport); + + viewport->keep_3d_linear = p_keep_3d_linear; + VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_KEEP_3D_LINEAR, p_keep_3d_linear); +} + void VisualServerViewport::viewport_attach_camera(RID p_viewport, RID p_camera) { Viewport *viewport = viewport_owner.getornull(p_viewport); diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h index 1d28cf22a3..c0c83c0450 100644 --- a/servers/visual/visual_server_viewport.h +++ b/servers/visual/visual_server_viewport.h @@ -64,6 +64,7 @@ public: bool disable_environment; bool disable_3d; bool disable_3d_by_usage; + bool keep_3d_linear; RID shadow_atlas; int shadow_atlas_size; @@ -110,6 +111,7 @@ public: shadow_atlas_size = 0; disable_3d = false; disable_3d_by_usage = false; + keep_3d_linear = false; debug_draw = VS::VIEWPORT_DEBUG_DRAW_DISABLED; for (int i = 0; i < VS::VIEWPORT_RENDER_INFO_MAX; i++) { render_info[i] = 0; @@ -164,6 +166,7 @@ public: void viewport_set_hide_canvas(RID p_viewport, bool p_hide); void viewport_set_disable_environment(RID p_viewport, bool p_disable); void viewport_set_disable_3d(RID p_viewport, bool p_disable); + void viewport_set_keep_3d_linear(RID p_viewport, bool p_keep_3d_linear); void viewport_attach_camera(RID p_viewport, RID p_camera); void viewport_set_scenario(RID p_viewport, RID p_scenario); diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 5b163e4ac9..19bb58f3ad 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -84,6 +84,7 @@ public: FUNCRID(texture) FUNC5(texture_allocate, RID, int, int, Image::Format, uint32_t) FUNC3(texture_set_data, RID, const Ref<Image> &, CubeMapSide) + FUNC10(texture_set_data_partial, RID, const Ref<Image> &, int, int, int, int, int, int, int, CubeMapSide) FUNC2RC(Ref<Image>, texture_get_data, RID, CubeMapSide) FUNC2(texture_set_flags, RID, uint32_t) FUNC1RC(uint32_t, texture_get_flags, RID) @@ -378,6 +379,7 @@ public: FUNC2(viewport_set_hide_canvas, RID, bool) FUNC2(viewport_set_disable_environment, RID, bool) FUNC2(viewport_set_disable_3d, RID, bool) + FUNC2(viewport_set_keep_3d_linear, RID, bool) FUNC2(viewport_attach_camera, RID, RID) FUNC2(viewport_set_scenario, RID, RID) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 59dd1ab495..f8b34f7df9 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -1528,6 +1528,7 @@ void VisualServer::_bind_methods() { ClassDB::bind_method(D_METHOD("texture_create_from_image", "image", "flags"), &VisualServer::texture_create_from_image, DEFVAL(TEXTURE_FLAGS_DEFAULT)); ClassDB::bind_method(D_METHOD("texture_allocate", "texture", "width", "height", "format", "flags"), &VisualServer::texture_allocate, DEFVAL(TEXTURE_FLAGS_DEFAULT)); ClassDB::bind_method(D_METHOD("texture_set_data", "texture", "image", "cube_side"), &VisualServer::texture_set_data, DEFVAL(CUBEMAP_LEFT)); + ClassDB::bind_method(D_METHOD("texture_set_data_partial", "texture", "image", "src_x", "src_y", "src_w", "src_h", "dst_x", "dst_y", "dst_mip", "cube_side"), &VisualServer::texture_set_data_partial, DEFVAL(CUBEMAP_LEFT)); ClassDB::bind_method(D_METHOD("texture_get_data", "texture", "cube_side"), &VisualServer::texture_get_data, DEFVAL(CUBEMAP_LEFT)); ClassDB::bind_method(D_METHOD("texture_set_flags", "texture", "flags"), &VisualServer::texture_set_flags); ClassDB::bind_method(D_METHOD("texture_get_flags", "texture"), &VisualServer::texture_get_flags); diff --git a/servers/visual_server.h b/servers/visual_server.h index a92480f81b..65d0f07a43 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -109,6 +109,7 @@ public: RID texture_create_from_image(const Ref<Image> &p_image, uint32_t p_flags = TEXTURE_FLAGS_DEFAULT); // helper virtual void texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags = TEXTURE_FLAGS_DEFAULT) = 0; virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, CubeMapSide p_cube_side = CUBEMAP_LEFT) = 0; + virtual void texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, CubeMapSide p_cube_side = CUBEMAP_LEFT) = 0; virtual Ref<Image> texture_get_data(RID p_texture, CubeMapSide p_cube_side = CUBEMAP_LEFT) const = 0; virtual void texture_set_flags(RID p_texture, uint32_t p_flags) = 0; virtual uint32_t texture_get_flags(RID p_texture) const = 0; @@ -592,6 +593,7 @@ public: virtual void viewport_set_hide_canvas(RID p_viewport, bool p_hide) = 0; virtual void viewport_set_disable_environment(RID p_viewport, bool p_disable) = 0; virtual void viewport_set_disable_3d(RID p_viewport, bool p_disable) = 0; + virtual void viewport_set_keep_3d_linear(RID p_viewport, bool p_disable) = 0; virtual void viewport_attach_camera(RID p_viewport, RID p_camera) = 0; virtual void viewport_set_scenario(RID p_viewport, RID p_scenario) = 0; diff --git a/thirdparty/README.md b/thirdparty/README.md index 2f765a4000..06084641cc 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -115,7 +115,7 @@ Files extracted from upstream source: ## glad - Upstream: https://github.com/Dav1dde/glad -- Version: 0.1.16a0 +- Version: 0.1.20a0 - License: MIT The files we package are automatically generated. diff --git a/thirdparty/glad/KHR/khrplatform.h b/thirdparty/glad/KHR/khrplatform.h index 1ad3554a76..975bbffed6 100644 --- a/thirdparty/glad/KHR/khrplatform.h +++ b/thirdparty/glad/KHR/khrplatform.h @@ -2,7 +2,7 @@ #define __khrplatform_h_ /* -** Copyright (c) 2008-2009 The Khronos Group Inc. +** Copyright (c) 2008-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -26,18 +26,16 @@ /* Khronos platform-specific types and definitions. * - * $Revision: 32517 $ on $Date: 2016-03-11 02:41:19 -0800 (Fri, 11 Mar 2016) $ + * The master copy of khrplatform.h is maintained in the Khronos EGL + * Registry repository at https://github.com/KhronosGroup/EGL-Registry + * The last semantic modification to khrplatform.h was at commit ID: + * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 * * Adopters may modify this file to suit their platform. Adopters are * encouraged to submit platform specific modifications to the Khronos * group so that they can be included in future versions of this file. - * Please submit changes by sending them to the public Khronos Bugzilla - * (http://khronos.org/bugzilla) by filing a bug against product - * "Khronos (general)" component "Registry". - * - * A predefined template which fills in some of the bug fields can be - * reached using http://tinyurl.com/khrplatform-h-bugreport, but you - * must create a Bugzilla login first. + * Please submit changes by filing pull requests or issues on + * the EGL Registry repository linked above. * * * See the Implementer's Guidelines for information about where this file diff --git a/thirdparty/glad/glad.c b/thirdparty/glad/glad.c index c2aaea2144..8f8b2189ec 100644 --- a/thirdparty/glad/glad.c +++ b/thirdparty/glad/glad.c @@ -1,6 +1,6 @@ /* - OpenGL loader generated by glad 0.1.18a0 on Mon Mar 5 18:43:52 2018. + OpenGL loader generated by glad 0.1.20a0 on Fri May 4 21:44:11 2018. Language/Generator: C/C++ Specification: gl @@ -27,21 +27,40 @@ static void* get_proc(const char *namez); -#ifdef _WIN32 +#if defined(_WIN32) || defined(__CYGWIN__) #include <windows.h> static HMODULE libGL; typedef void* (APIENTRYP PFNWGLGETPROCADDRESSPROC_PRIVATE)(const char*); static PFNWGLGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr; +#ifdef _MSC_VER +#ifdef __has_include + #if __has_include(<winapifamily.h>) + #define HAVE_WINAPIFAMILY 1 + #endif +#elif _MSC_VER >= 1700 && !_USING_V110_SDK71_ + #define HAVE_WINAPIFAMILY 1 +#endif +#endif + +#ifdef HAVE_WINAPIFAMILY + #include <winapifamily.h> + #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) + #define IS_UWP 1 + #endif +#endif + static int open_gl(void) { +#ifndef IS_UWP libGL = LoadLibraryW(L"opengl32.dll"); if(libGL != NULL) { gladGetProcAddressPtr = (PFNWGLGETPROCADDRESSPROC_PRIVATE)GetProcAddress( libGL, "wglGetProcAddress"); return gladGetProcAddressPtr != NULL; } +#endif return 0; } @@ -50,7 +69,7 @@ static void close_gl(void) { if(libGL != NULL) { FreeLibrary((HMODULE) libGL); - libGL = NULL; + libGL = NULL; } } #else @@ -113,7 +132,7 @@ void* get_proc(const char *namez) { } #endif if(result == NULL) { -#ifdef _WIN32 +#if defined(_WIN32) || defined(__CYGWIN__) result = (void*)GetProcAddress((HMODULE) libGL, namez); #else result = dlsym(libGL, namez); diff --git a/thirdparty/glad/glad/glad.h b/thirdparty/glad/glad/glad.h index 9de720fbc2..4eebad4f2f 100644 --- a/thirdparty/glad/glad/glad.h +++ b/thirdparty/glad/glad/glad.h @@ -1,6 +1,6 @@ /* - OpenGL loader generated by glad 0.1.18a0 on Mon Mar 5 18:43:52 2018. + OpenGL loader generated by glad 0.1.20a0 on Fri May 4 21:44:11 2018. Language/Generator: C/C++ Specification: gl @@ -1581,7 +1581,7 @@ GLAPI PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv; typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC)(GLenum cap); GLAPI PFNGLISENABLEDPROC glad_glIsEnabled; #define glIsEnabled glad_glIsEnabled -typedef void (APIENTRYP PFNGLDEPTHRANGEPROC)(GLdouble near, GLdouble far); +typedef void (APIENTRYP PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f); GLAPI PFNGLDEPTHRANGEPROC glad_glDepthRange; #define glDepthRange glad_glDepthRange typedef void (APIENTRYP PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height); |