summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/LICENSE.md27
-rw-r--r--doc/base/classes.xml111
-rw-r--r--platform/android/export/export.cpp2
-rw-r--r--platform/bb10/export/export.cpp2
-rw-r--r--platform/javascript/export/export.cpp2
-rw-r--r--platform/osx/export/export.cpp2
-rw-r--r--scene/2d/physics_body_2d.cpp39
-rw-r--r--scene/2d/physics_body_2d.h10
-rw-r--r--scene/animation/animation_tree_player.cpp90
-rw-r--r--scene/animation/animation_tree_player.h8
-rw-r--r--scene/gui/dialogs.cpp2
-rw-r--r--scene/gui/text_edit.cpp54
-rw-r--r--scene/gui/text_edit.h3
-rw-r--r--scene/register_scene_types.cpp6
-rw-r--r--scene/resources/default_theme/default_theme.cpp18
-rw-r--r--scene/resources/font.cpp239
-rw-r--r--scene/resources/font.h74
-rw-r--r--servers/physics_2d/body_2d_sw.cpp17
-rw-r--r--servers/physics_2d/body_2d_sw.h12
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp9
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h2
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.h1
-rw-r--r--servers/physics_2d_server.cpp2
-rw-r--r--servers/physics_2d_server.h5
-rw-r--r--tools/editor/editor_fonts.cpp10
-rw-r--r--tools/editor/editor_import_export.cpp45
-rw-r--r--tools/editor/editor_import_export.h15
-rw-r--r--tools/editor/editor_node.cpp5
-rw-r--r--tools/editor/editor_node.h1
-rw-r--r--tools/editor/icons/icon_bitmap_font.pngbin0 -> 362 bytes
-rw-r--r--tools/editor/io_plugins/editor_font_import_plugin.cpp38
-rw-r--r--tools/editor/io_plugins/editor_font_import_plugin.h2
-rw-r--r--tools/editor/plugins/animation_tree_editor_plugin.cpp52
-rw-r--r--tools/editor/plugins/shader_editor_plugin.cpp38
-rw-r--r--tools/editor/plugins/shader_editor_plugin.h2
-rw-r--r--tools/editor/project_export.cpp11
-rw-r--r--tools/editor/project_export.h1
-rw-r--r--tools/editor/project_settings.cpp42
38 files changed, 710 insertions, 289 deletions
diff --git a/demos/LICENSE.md b/demos/LICENSE.md
new file mode 100644
index 0000000000..2f3e879c8c
--- /dev/null
+++ b/demos/LICENSE.md
@@ -0,0 +1,27 @@
+ GODOT ENGINE
+ http://www.godotengine.org
+
+************************************************************************
+
+ Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+************************************************************************
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 1c555bb944..4929c93438 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -2041,6 +2041,8 @@
<argument index="2" name="action" type="String" default="&quot;&quot;">
</argument>
<description>
+ Add custom button to the dialog and return the created button.
+ The button titled with [i]text[/i] and the [i]action[/i] will be passed to [custom_action] signal when it is pressed.
</description>
</method>
<method name="add_cancel">
@@ -2049,6 +2051,7 @@
<argument index="0" name="name" type="String">
</argument>
<description>
+ Add custom cancel button to the dialog and return the created button.
</description>
</method>
<method name="register_text_enter">
@@ -2202,6 +2205,7 @@
<signals>
<signal name="frame_changed">
<description>
+ Emmited when frame is changed.
</description>
</signal>
</signals>
@@ -3029,6 +3033,16 @@
<description>
</description>
</method>
+ <method name="animation_node_set_filter_path">
+ <argument index="0" name="id" type="String">
+ </argument>
+ <argument index="1" name="path" type="NodePath">
+ </argument>
+ <argument index="2" name="enable" type="bool">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="oneshot_node_set_fadein_time">
<argument index="0" name="id" type="String">
</argument>
@@ -4168,10 +4182,12 @@
</method>
<method name="pop_back">
<description>
+ Remove the last element of the array.
</description>
</method>
<method name="pop_front">
<description>
+ Remove the first element of the array.
</description>
</method>
<method name="push_back">
@@ -4185,6 +4201,7 @@
<argument index="0" name="value" type="var">
</argument>
<description>
+ Add an element at the beginning of the array.
</description>
</method>
<method name="remove">
@@ -5421,12 +5438,14 @@
<methods>
<method name="_pressed" qualifiers="virtual">
<description>
+ Called when button is pressed.
</description>
</method>
<method name="_toggled" qualifiers="virtual">
<argument index="0" name="pressed" type="bool">
</argument>
<description>
+ Called when button is toggled (only if toggle_mode is active).
</description>
</method>
<method name="set_pressed">
@@ -5447,6 +5466,7 @@
<return type="bool">
</return>
<description>
+ Return true if mouse entered the button before it exit.
</description>
</method>
<method name="set_toggle_mode">
@@ -5502,6 +5522,7 @@
<signals>
<signal name="released">
<description>
+ This signal is emitted when the button was released.
</description>
</signal>
<signal name="toggled">
@@ -5519,12 +5540,16 @@
</signals>
<constants>
<constant name="DRAW_NORMAL" value="0">
+ The normal state(Are not pressed, not hovered, not toggled and enabled) of buttons.
</constant>
<constant name="DRAW_PRESSED" value="1">
+ The state of buttons are pressed.
</constant>
<constant name="DRAW_HOVER" value="2">
+ The state of buttons are hovered.
</constant>
<constant name="DRAW_DISABLED" value="3">
+ The state of buttons are disabled.
</constant>
</constants>
</class>
@@ -7005,20 +7030,24 @@
</class>
<class name="CanvasModulate" inherits="Node2D" category="Core">
<brief_description>
+ Tint the entire canvas
</brief_description>
<description>
+ CanvasModulate tints the canvas elements using its asigned color
</description>
<methods>
<method name="set_color">
<argument index="0" name="color" type="Color">
</argument>
<description>
+ Sets the canvas tint color
</description>
</method>
<method name="get_color" qualifiers="const">
<return type="Color">
</return>
<description>
+ Gets the canvas tint color
</description>
</method>
</methods>
@@ -7124,6 +7153,7 @@
<return type="bool">
</return>
<description>
+ Should put children to the top left corner instead of center of the container.
</description>
</method>
</methods>
@@ -7783,6 +7813,7 @@
<argument index="0" name="over" type="Color">
</argument>
<description>
+ Return a new color blended with anothor one.
</description>
</method>
<method name="contrasted">
@@ -7991,30 +8022,35 @@
<argument index="0" name="mode" type="bool">
</argument>
<description>
+ When set to true, every color channel will be represented as a value from 0 to 1, insetead of 0, 255.
</description>
</method>
<method name="is_raw_mode" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns whether this color picker is in raw mode or not
</description>
</method>
<method name="set_edit_alpha">
<argument index="0" name="show" type="bool">
</argument>
<description>
+ Set true if you want the color to have an alpha channel (transparency), or false if you want a solid color.
</description>
</method>
<method name="is_editing_alpha" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns whether the color has transparency or not.
</description>
</method>
<method name="add_preset">
<argument index="0" name="arg0" type="Color">
</argument>
<description>
+ Adds the current selected to color to a list of colors (presets), the presets will be displayed in the color picker and the user will be able to select them, notice that the presets list is only for this color picker.
</description>
</method>
</methods>
@@ -8023,7 +8059,7 @@
<argument index="0" name="color" type="Color">
</argument>
<description>
- Emitted when the color changes.
+ Emitted when the color is changed.
</description>
</signal>
</signals>
@@ -8048,32 +8084,38 @@
</class>
<class name="ColorPickerButton" inherits="Button" category="Core">
<brief_description>
+ Button that pops out a [ColorPicker]
</brief_description>
<description>
+ Encapsulates a [ColorPicker] making it accesible by pressing a button, pressing the button will toggle the [ColorPicker] visibility
</description>
<methods>
<method name="set_color">
<argument index="0" name="color" type="Color">
</argument>
<description>
+ Sets the current color
</description>
</method>
<method name="get_color" qualifiers="const">
<return type="Color">
</return>
<description>
+ Gets the current color
</description>
</method>
<method name="set_edit_alpha">
<argument index="0" name="show" type="bool">
</argument>
<description>
+ See [method ColorPicker.set_edit_alpha]
</description>
</method>
<method name="is_editing_alpha" qualifiers="const">
<return type="bool">
</return>
<description>
+ See [method ColorPicker.is_edit_alpha]
</description>
</method>
</methods>
@@ -8082,6 +8124,7 @@
<argument index="0" name="color" type="Color">
</argument>
<description>
+ Emitted when the color is changed.
</description>
</signal>
</signals>
@@ -9770,6 +9813,7 @@ This approximation makes straight segments between each point, then subdivides t
<argument index="0" name="values" type="Array">
</argument>
<description>
+ Return true if the dictionary has all of the keys in the given array.
</description>
</method>
<method name="hash">
@@ -9792,6 +9836,7 @@ This approximation makes straight segments between each point, then subdivides t
<argument index="0" name="json" type="String">
</argument>
<description>
+ Parse json text to the dictionary. Return OK when successed or the error code when failed.
</description>
</method>
<method name="size">
@@ -9805,6 +9850,7 @@ This approximation makes straight segments between each point, then subdivides t
<return type="String">
</return>
<description>
+ Return the dictionary as json text.
</description>
</method>
</methods>
@@ -12339,6 +12385,7 @@ Returns an empty String "" at the end of the list.
<return type="bool">
</return>
<description>
+ Should put children to the top left corner instead of center of the container.
</description>
</method>
</methods>
@@ -24628,6 +24675,17 @@ This method controls whether the position between two cached points is interpola
<description>
</description>
</method>
+ <method name="body_add_force">
+ <argument index="0" name="body" type="RID">
+ </argument>
+ <argument index="1" name="offset" type="Vector2">
+ </argument>
+ <argument index="2" name="force" type="Vector2">
+ </argument>
+ <description>
+ Add a positioned force to the applied force and torque. As with [method body_apply_impulse], both the force and the offset from the body origin are in global coordinates.
+ </description>
+ </method>
<method name="body_set_axis_velocity">
<argument index="0" name="body" type="RID">
</argument>
@@ -24915,13 +24973,15 @@ This method controls whether the position between two cached points is interpola
</constant>
<constant name="BODY_PARAM_MASS" value="2">
</constant>
- <constant name="BODY_PARAM_GRAVITY_SCALE" value="3">
+ <constant name="BODY_PARAM_INERTIA" value="3">
</constant>
- <constant name="BODY_PARAM_LINEAR_DAMP" value="4">
+ <constant name="BODY_PARAM_GRAVITY_SCALE" value="4">
</constant>
- <constant name="BODY_PARAM_ANGULAR_DAMP" value="5">
+ <constant name="BODY_PARAM_LINEAR_DAMP" value="5">
</constant>
- <constant name="BODY_PARAM_MAX" value="6">
+ <constant name="BODY_PARAM_ANGULAR_DAMP" value="6">
+ </constant>
+ <constant name="BODY_PARAM_MAX" value="7">
</constant>
<constant name="BODY_STATE_TRANSFORM" value="0">
</constant>
@@ -30114,6 +30174,20 @@ This method controls whether the position between two cached points is interpola
Return the body mass.
</description>
</method>
+ <method name="get_inertia" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ Return the body's moment of inertia. This is usually automatically computed from the mass and the shapes. Note that this doesn't seem to work in a [code]_ready[/code] function: it apparently has not been auto-computed yet.
+ </description>
+ </method>
+ <method name="set_inertia">
+ <argument index="0" name="inertia" type="float">
+ </argument>
+ <description>
+ Set the body's moment of inertia. This is like mass, but for rotation: it determines how much torque it takes to rotate the body. The moment of inertia is usually computed automatically from the mass and the shapes, but this function allows you to set a custom value. Set 0 (or negative) inertia to return to automatically computing it.
+ </description>
+ </method>
<method name="set_weight">
<argument index="0" name="weight" type="float">
</argument>
@@ -30291,12 +30365,12 @@ This method controls whether the position between two cached points is interpola
</description>
</method>
<method name="apply_impulse">
- <argument index="0" name="pos" type="Vector2">
+ <argument index="0" name="offset" type="Vector2">
</argument>
<argument index="1" name="impulse" type="Vector2">
</argument>
<description>
- Apply a positioned impulse (which will be affected by the body mass and shape). This is the equivalent of hitting a billiard ball with a cue: a force that is applied once, and only once.
+ Apply a positioned impulse (which will be affected by the body mass and shape). This is the equivalent of hitting a billiard ball with a cue: a force that is applied once, and only once. Both the impulse and the offset from the body origin are in global coordinates.
</description>
</method>
<method name="set_applied_force">
@@ -30313,6 +30387,29 @@ This method controls whether the position between two cached points is interpola
Return the applied force vector.
</description>
</method>
+ <method name="set_applied_torque">
+ <argument index="0" name="torque" type="float">
+ </argument>
+ <description>
+ Set a constant torque which will be applied to this body.
+ </description>
+ </method>
+ <method name="get_applied_torque" qualifiers="const">
+ <return type="float">
+ </return>
+ <description>
+ Return the torque which is being applied to this body.
+ </description>
+ </method>
+ <method name="add_force">
+ <argument index="0" name="offset" type="Vector2">
+ </argument>
+ <argument index="1" name="force" type="Vector2">
+ </argument>
+ <description>
+ Add a positioned force to the applied force and torque. As with [method apply_impulse], both the force and the offset from the body origin are in global coordinates.
+ </description>
+ </method>
<method name="set_sleeping">
<argument index="0" name="sleeping" type="bool">
</argument>
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 60f4e61c68..bd63cadc57 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -251,7 +251,7 @@ public:
virtual String get_device_info(int p_device) const;
virtual Error run(int p_device,int p_flags=0);
- virtual bool requieres_password(bool p_debug) const { return !p_debug; }
+ virtual bool requires_password(bool p_debug) const { return !p_debug; }
virtual String get_binary_extension() const { return "apk"; }
virtual Error export_project(const String& p_path, bool p_debug, int p_flags=0);
diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp
index a17c4cb134..da3a958a56 100644
--- a/platform/bb10/export/export.cpp
+++ b/platform/bb10/export/export.cpp
@@ -69,7 +69,7 @@ public:
virtual String get_device_info(int p_device) const;
virtual Error run(int p_device,int p_flags=0);
- virtual bool requieres_password(bool p_debug) const { return !p_debug; }
+ virtual bool requires_password(bool p_debug) const { return !p_debug; }
virtual String get_binary_extension() const { return "bar"; }
virtual Error export_project(const String& p_path,bool p_debug,int p_flags=0);
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index e055aeea56..de57d770c4 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -86,7 +86,7 @@ public:
virtual String get_device_info(int p_device) const { return "Run exported HTML in the system's default browser."; }
virtual Error run(int p_device,int p_flags=0);
- virtual bool requieres_password(bool p_debug) const { return false; }
+ virtual bool requires_password(bool p_debug) const { return false; }
virtual String get_binary_extension() const { return "html"; }
virtual Error export_project(const String& p_path,bool p_debug,int p_flags=0);
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index 0bece6ec76..3bc4ebdb1a 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -59,7 +59,7 @@ public:
virtual String get_device_info(int p_device) const { return String(); }
virtual Error run(int p_device,int p_flags=0);
- virtual bool requieres_password(bool p_debug) const { return false; }
+ virtual bool requires_password(bool p_debug) const { return false; }
virtual String get_binary_extension() const { return "zip"; }
virtual Error export_project(const String& p_path,bool p_debug,int p_flags=0);
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index dc038f010c..8f0474b765 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -602,6 +602,17 @@ real_t RigidBody2D::get_mass() const{
return mass;
}
+void RigidBody2D::set_inertia(real_t p_inertia) {
+
+ ERR_FAIL_COND(p_inertia<=0);
+ Physics2DServer::get_singleton()->body_set_param(get_rid(),Physics2DServer::BODY_PARAM_INERTIA,p_inertia);
+}
+
+real_t RigidBody2D::get_inertia() const{
+
+ return Physics2DServer::get_singleton()->body_get_param(get_rid(),Physics2DServer::BODY_PARAM_INERTIA);
+}
+
void RigidBody2D::set_weight(real_t p_weight){
set_mass(p_weight/9.8);
@@ -767,9 +778,9 @@ int RigidBody2D::get_max_contacts_reported() const{
return max_contacts_reported;
}
-void RigidBody2D::apply_impulse(const Vector2& p_pos, const Vector2& p_impulse) {
+void RigidBody2D::apply_impulse(const Vector2& p_offset, const Vector2& p_impulse) {
- Physics2DServer::get_singleton()->body_apply_impulse(get_rid(),p_pos,p_impulse);
+ Physics2DServer::get_singleton()->body_apply_impulse(get_rid(),p_offset,p_impulse);
}
void RigidBody2D::set_applied_force(const Vector2& p_force) {
@@ -782,6 +793,20 @@ Vector2 RigidBody2D::get_applied_force() const {
return Physics2DServer::get_singleton()->body_get_applied_force(get_rid());
};
+void RigidBody2D::set_applied_torque(const float p_torque) {
+
+ Physics2DServer::get_singleton()->body_set_applied_torque(get_rid(), p_torque);
+};
+
+float RigidBody2D::get_applied_torque() const {
+
+ return Physics2DServer::get_singleton()->body_get_applied_torque(get_rid());
+};
+
+void RigidBody2D::add_force(const Vector2& p_offset, const Vector2& p_force) {
+
+ Physics2DServer::get_singleton()->body_add_force(get_rid(),p_offset,p_force);
+}
void RigidBody2D::set_continuous_collision_detection_mode(CCDMode p_mode) {
@@ -858,6 +883,9 @@ void RigidBody2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_mass","mass"),&RigidBody2D::set_mass);
ObjectTypeDB::bind_method(_MD("get_mass"),&RigidBody2D::get_mass);
+ ObjectTypeDB::bind_method(_MD("get_inertia"),&RigidBody2D::get_inertia);
+ ObjectTypeDB::bind_method(_MD("set_inertia","inertia"),&RigidBody2D::set_inertia);
+
ObjectTypeDB::bind_method(_MD("set_weight","weight"),&RigidBody2D::set_weight);
ObjectTypeDB::bind_method(_MD("get_weight"),&RigidBody2D::get_weight);
@@ -895,11 +923,16 @@ void RigidBody2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_continuous_collision_detection_mode"),&RigidBody2D::get_continuous_collision_detection_mode);
ObjectTypeDB::bind_method(_MD("set_axis_velocity","axis_velocity"),&RigidBody2D::set_axis_velocity);
- ObjectTypeDB::bind_method(_MD("apply_impulse","pos","impulse"),&RigidBody2D::apply_impulse);
+ ObjectTypeDB::bind_method(_MD("apply_impulse","offset","impulse"),&RigidBody2D::apply_impulse);
ObjectTypeDB::bind_method(_MD("set_applied_force","force"),&RigidBody2D::set_applied_force);
ObjectTypeDB::bind_method(_MD("get_applied_force"),&RigidBody2D::get_applied_force);
+ ObjectTypeDB::bind_method(_MD("set_applied_torque","torque"),&RigidBody2D::set_applied_torque);
+ ObjectTypeDB::bind_method(_MD("get_applied_torque"),&RigidBody2D::get_applied_torque);
+
+ ObjectTypeDB::bind_method(_MD("add_force","offset","force"),&RigidBody2D::add_force);
+
ObjectTypeDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody2D::set_sleeping);
ObjectTypeDB::bind_method(_MD("is_sleeping"),&RigidBody2D::is_sleeping);
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 999e63dd5d..5af65bff33 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -217,6 +217,9 @@ public:
void set_mass(real_t p_mass);
real_t get_mass() const;
+ void set_inertia(real_t p_inertia);
+ real_t get_inertia() const;
+
void set_weight(real_t p_weight);
real_t get_weight() const;
@@ -261,11 +264,16 @@ public:
void set_continuous_collision_detection_mode(CCDMode p_mode);
CCDMode get_continuous_collision_detection_mode() const;
- void apply_impulse(const Vector2& p_pos, const Vector2& p_impulse);
+ void apply_impulse(const Vector2& p_offset, const Vector2& p_impulse);
void set_applied_force(const Vector2& p_force);
Vector2 get_applied_force() const;
+ void set_applied_torque(const float p_torque);
+ float get_applied_torque() const;
+
+ void add_force(const Vector2& p_offset, const Vector2& p_force);
+
Array get_colliding_bodies() const; //function for script
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index c732dd54cf..211c5961b0 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -139,6 +139,11 @@ bool AnimationTreePlayer::_set(const StringName& p_name, const Variant& p_value)
animation_node_set_master_animation(id,node.get_valid("from"));
else
animation_node_set_animation(id,node.get_valid("animation"));
+ Array filters= node.get_valid("filter");
+ for(int i=0;i<filters.size();i++) {
+
+ animation_node_set_filter_path(id,filters[i],true);
+ }
} break;
case NODE_ONESHOT: {
@@ -276,6 +281,15 @@ bool AnimationTreePlayer::_get(const StringName& p_name,Variant &r_ret) const {
} else {
node["animation"]=an->animation;
}
+ Array k;
+ List<NodePath> keys;
+ an->filter.get_key_list(&keys);
+ k.resize(keys.size());
+ int i=0;
+ for(List<NodePath>::Element *E=keys.front();E;E=E->next()) {
+ k[i++]=E->get();
+ }
+ node["filter"]=k;
} break;
case NODE_ONESHOT: {
OneShotNode *osn = static_cast<OneShotNode*>(n);
@@ -439,7 +453,6 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
//transform to seconds...
-
switch(nb->type) {
case NODE_OUTPUT: {
@@ -464,7 +477,7 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
an->time=p_time;
an->step=0;
} else {
- an->time+=p_time;
+ an->time=MAX(0,an->time+p_time);
an->step=p_time;
}
@@ -482,14 +495,12 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
an->skip=true;
for (List<AnimationNode::TrackRef>::Element *E=an->tref.front();E;E=E->next()) {
-
- if (p_filter && p_filter->has(an->animation->track_get_path(E->get().local_track))) {
-
- if (p_reverse_weight<0)
- E->get().weight=0;
- else
- E->get().weight=p_reverse_weight;
-
+ NodePath track_path = an->animation->track_get_path(E->get().local_track);
+ if (p_filter && p_filter->has(track_path)) {
+ E->get().weight = MAX(0, p_reverse_weight);
+ } else if(an->filter.has(track_path)) {
+ E->get().weight = 0;
+ E->get().track->skip = true;
} else {
E->get().weight=p_weight;
}
@@ -552,18 +563,17 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
float main_rem;
float os_rem;
+ float os_reverse_weight = p_reverse_weight;
if (!osn->filter.empty()) {
-
- main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,p_seek,&osn->filter,p_weight);
- os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,os_seek,&osn->filter,-1);
-
- } else {
-
- main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,p_seek);
- os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,os_seek);
+ p_filter = &osn->filter;
+ p_reverse_weight = p_weight;
+ os_reverse_weight = -1;
}
+ main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,p_seek,p_filter,p_reverse_weight);
+ os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,os_seek,p_filter,os_reverse_weight);
+
if (osn->start) {
osn->remaining=os_rem;
osn->start=false;
@@ -768,6 +778,8 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
t.value = t.object->get(t.property);
t.value.zero();
+
+ t.skip = false;
}
@@ -816,16 +828,9 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
if (a->value_track_is_continuous(tr.local_track)) {
Variant value = a->value_track_interpolate(tr.local_track,anim_list->time);
Variant::blend(tr.track->value,value,blend,tr.track->value);
- tr.track->object->set(tr.track->property,tr.track->value);
} else {
-
- List<int> indices;
- a->value_track_get_key_indices(tr.local_track,anim_list->time,anim_list->step,&indices);
- for(List<int>::Element *E=indices.front();E;E=E->next()) {
-
- Variant value = a->track_get_key_value(tr.local_track,E->get());
- tr.track->object->set(tr.track->property,value);
- }
+ int index = a->track_find_key(tr.local_track,anim_list->time);
+ tr.track->value = a->track_get_key_value(tr.local_track, index);
}
} break;
case Animation::TYPE_METHOD: { ///< Call any method on a specific node.
@@ -854,11 +859,13 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
Track &t = E->get();
- if (!t.object)
+ if (t.skip || !t.object)
continue;
- if(t.property) // value track; was applied in step 2
+ if(t.property) { // value track
+ t.object->set(t.property,t.value);
continue;
+ }
Transform xform;
xform.basis=t.rot;
@@ -983,6 +990,24 @@ void AnimationTreePlayer::animation_node_set_master_animation(const StringName&
}
+void AnimationTreePlayer::animation_node_set_filter_path(const StringName& p_node,const NodePath& p_track_path,bool p_filter) {
+
+ GET_NODE( NODE_ANIMATION, AnimationNode );
+
+ if (p_filter)
+ n->filter[p_track_path]=true;
+ else
+ n->filter.erase(p_track_path);
+
+}
+
+void AnimationTreePlayer::animation_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const{
+
+ GET_NODE( NODE_ANIMATION, AnimationNode );
+
+ n->filter.get_key_list(r_paths);
+}
+
void AnimationTreePlayer::oneshot_node_set_fadein_time(const StringName& p_node,float p_time) {
GET_NODE( NODE_ONESHOT, OneShotNode );
@@ -1210,6 +1235,12 @@ String AnimationTreePlayer::animation_node_get_master_animation(const StringName
}
+bool AnimationTreePlayer::animation_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const {
+
+ GET_NODE_V(NODE_ANIMATION, AnimationNode, 0 );
+ return n->filter.has(p_path);
+}
+
float AnimationTreePlayer::oneshot_node_get_fadein_time(const StringName& p_node) const {
@@ -1750,6 +1781,7 @@ void AnimationTreePlayer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("animation_node_set_master_animation","id","source"),&AnimationTreePlayer::animation_node_set_master_animation);
ObjectTypeDB::bind_method(_MD("animation_node_get_master_animation","id"),&AnimationTreePlayer::animation_node_get_master_animation);
+ ObjectTypeDB::bind_method(_MD("animation_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::animation_node_set_filter_path);
ObjectTypeDB::bind_method(_MD("oneshot_node_set_fadein_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadein_time);
ObjectTypeDB::bind_method(_MD("oneshot_node_get_fadein_time","id"),&AnimationTreePlayer::oneshot_node_get_fadein_time);
diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h
index 2e44d69aa1..0e78281e4c 100644
--- a/scene/animation/animation_tree_player.h
+++ b/scene/animation/animation_tree_player.h
@@ -111,6 +111,7 @@ private:
Variant value;
+ bool skip;
};
@@ -162,6 +163,9 @@ private:
float step;
String from;
bool skip;
+
+ HashMap<NodePath,bool> filter;
+
AnimationNode() { type=NODE_ANIMATION; next=NULL; last_version=0; skip=false; }
};
@@ -310,6 +314,10 @@ public:
void animation_node_set_master_animation(const StringName& p_node,const String& p_master_animation);
String animation_node_get_master_animation(const StringName& p_node) const;
+ void animation_node_set_filter_path(const StringName& p_node,const NodePath& p_filter,bool p_enable);
+ void animation_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const;
+ bool animation_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const;
+
/* ONE SHOT NODE */
void oneshot_node_set_fadein_time(const StringName& p_node,float p_time);
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index d00dacd256..51242d89bd 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -285,7 +285,7 @@ Button* AcceptDialog::add_cancel(const String &p_cancel) {
String c = p_cancel;
if (p_cancel=="")
c="Cancel";
- Button *b = swap_ok_cancel ? add_button("Cancel",true) : add_button("Cancel");
+ Button *b = swap_ok_cancel ? add_button(c,true) : add_button(c);
b->connect("pressed",this,"_closed");
return b;
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index f7461a736c..41d546c6f7 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2057,7 +2057,17 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
scancode_handled=false;
break;
}
-#ifdef APPLE_STYLE_KEYS
+#ifndef APPLE_STYLE_KEYS
+ if (k.mod.command) {
+ _scroll_lines_up();
+ break;
+ }
+#else
+ if (k.mod.command && k.mod.alt) {
+ _scroll_lines_up();
+ break;
+ }
+
if (k.mod.command)
cursor_set_line(0);
else
@@ -2084,7 +2094,17 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
scancode_handled=false;
break;
}
-#ifdef APPLE_STYLE_KEYS
+#ifndef APPLE_STYLE_KEYS
+ if (k.mod.command) {
+ _scroll_lines_down();
+ break;
+ }
+#else
+ if (k.mod.command && k.mod.alt) {
+ _scroll_lines_down();
+ break;
+ }
+
if (k.mod.command)
cursor_set_line(text.size()-1);
else
@@ -2498,6 +2518,36 @@ void TextEdit::_post_shift_selection() {
selection.selecting_text=true;
}
+void TextEdit::_scroll_lines_up() {
+ // adjust the vertical scroll
+ if (get_v_scroll() > 0) {
+ set_v_scroll(get_v_scroll() - 1);
+ }
+
+ // adjust the cursor
+ if (cursor_get_line() >= (get_visible_rows() + get_v_scroll()) && !selection.active) {
+ cursor_set_line((get_visible_rows() + get_v_scroll()) - 1, false);
+ }
+}
+
+void TextEdit::_scroll_lines_down() {
+ // calculate the maximum vertical scroll position
+ int max_v_scroll = get_line_count() - 1;
+ if (!scroll_past_end_of_file_enabled) {
+ max_v_scroll -= get_visible_rows() - 1;
+ }
+
+ // adjust the vertical scroll
+ if (get_v_scroll() < max_v_scroll) {
+ set_v_scroll(get_v_scroll() + 1);
+ }
+
+ // adjust the cursor
+ if ((cursor_get_line()) <= get_v_scroll() - 1 && !selection.active) {
+ cursor_set_line(get_v_scroll(), false);
+ }
+}
+
/**** TEXT EDIT CORE API ****/
void TextEdit::_base_insert_text(int p_line, int p_char,const String& p_text,int &r_end_line,int &r_end_column) {
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 09c2a4d729..193dd236d1 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -259,6 +259,9 @@ class TextEdit : public Control {
void _pre_shift_selection();
void _post_shift_selection();
+ void _scroll_lines_up();
+ void _scroll_lines_down();
+
// void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
Size2 get_minimum_size();
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 9930aa07f6..1bcb0d4fba 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -570,13 +570,17 @@ void register_scene_types() {
ObjectTypeDB::register_type<LargeTexture>();
ObjectTypeDB::register_type<CubeMap>();
ObjectTypeDB::register_type<Animation>();
- ObjectTypeDB::register_type<Font>();
+ ObjectTypeDB::register_virtual_type<Font>();
+ ObjectTypeDB::register_type<BitmapFont>();
ObjectTypeDB::register_type<StyleBoxEmpty>();
ObjectTypeDB::register_type<StyleBoxTexture>();
ObjectTypeDB::register_type<StyleBoxFlat>();
ObjectTypeDB::register_type<StyleBoxImageMask>();
ObjectTypeDB::register_type<Theme>();
+ ObjectTypeDB::add_compatibility_type("Font","BitmapFont");
+
+
ObjectTypeDB::register_type<PolygonPathFinder>();
ObjectTypeDB::register_type<BitMap>();
ObjectTypeDB::register_type<ColorRamp>();
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 005a46c0bc..727c8eee29 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -87,10 +87,10 @@ static Ref<Shader> make_shader(const char*vertex_code,const char*fragment_code,c
return shader;
}
-static Ref<Font> make_font(int p_height,int p_ascent, int p_valign, int p_charcount, const int *p_chars,const Ref<Texture> &p_texture) {
+static Ref<BitmapFont> make_font(int p_height,int p_ascent, int p_valign, int p_charcount, const int *p_chars,const Ref<Texture> &p_texture) {
- Ref<Font> font( memnew( Font ) );
+ Ref<BitmapFont> font( memnew( BitmapFont ) );
font->add_texture( p_texture );
for (int i=0;i<p_charcount;i++) {
@@ -117,10 +117,10 @@ static Ref<Font> make_font(int p_height,int p_ascent, int p_valign, int p_charco
return font;
}
-static Ref<Font> make_font2(int p_height,int p_ascent, int p_charcount, const int *p_char_rects,int p_kerning_count,const int *p_kernings,int p_w, int p_h, const unsigned char *p_img) {
+static Ref<BitmapFont> make_font2(int p_height,int p_ascent, int p_charcount, const int *p_char_rects,int p_kerning_count,const int *p_kernings,int p_w, int p_h, const unsigned char *p_img) {
- Ref<Font> font( memnew( Font ) );
+ Ref<BitmapFont> font( memnew( BitmapFont ) );
DVector<uint8_t> img;
img.resize(p_w*p_h*2);
@@ -187,10 +187,10 @@ void make_default_theme() {
Ref<Theme> t( memnew( Theme ) );
- //Ref<Font> default_font = make_font(_bi_font_normal_height,_bi_font_normal_ascent,_bi_font_normal_valign,_bi_font_normal_charcount,_bi_font_normal_characters,make_icon(font_normal_png));
- Ref<Font> default_font=make_font2(_builtin_normal_font_height,_builtin_normal_font_ascent,_builtin_normal_font_charcount,&_builtin_normal_font_charrects[0][0],_builtin_normal_font_kerning_pair_count,&_builtin_normal_font_kerning_pairs[0][0],_builtin_normal_font_img_width,_builtin_normal_font_img_height,_builtin_normal_font_img_data);
- Ref<Font> source_font=make_font2(_builtin_source_font_height,_builtin_source_font_ascent,_builtin_source_font_charcount,&_builtin_source_font_charrects[0][0],_builtin_source_font_kerning_pair_count,&_builtin_source_font_kerning_pairs[0][0],_builtin_source_font_img_width,_builtin_source_font_img_height,_builtin_source_font_img_data);
- Ref<Font> large_font=make_font2(_builtin_large_font_height,_builtin_large_font_ascent,_builtin_large_font_charcount,&_builtin_large_font_charrects[0][0],_builtin_large_font_kerning_pair_count,&_builtin_large_font_kerning_pairs[0][0],_builtin_large_font_img_width,_builtin_large_font_img_height,_builtin_large_font_img_data);
+ //Ref<BitmapFont> default_font = make_font(_bi_font_normal_height,_bi_font_normal_ascent,_bi_font_normal_valign,_bi_font_normal_charcount,_bi_font_normal_characters,make_icon(font_normal_png));
+ Ref<BitmapFont> default_font=make_font2(_builtin_normal_font_height,_builtin_normal_font_ascent,_builtin_normal_font_charcount,&_builtin_normal_font_charrects[0][0],_builtin_normal_font_kerning_pair_count,&_builtin_normal_font_kerning_pairs[0][0],_builtin_normal_font_img_width,_builtin_normal_font_img_height,_builtin_normal_font_img_data);
+ Ref<BitmapFont> source_font=make_font2(_builtin_source_font_height,_builtin_source_font_ascent,_builtin_source_font_charcount,&_builtin_source_font_charrects[0][0],_builtin_source_font_kerning_pair_count,&_builtin_source_font_kerning_pairs[0][0],_builtin_source_font_img_width,_builtin_source_font_img_height,_builtin_source_font_img_data);
+ Ref<BitmapFont> large_font=make_font2(_builtin_large_font_height,_builtin_large_font_ascent,_builtin_large_font_charcount,&_builtin_large_font_charrects[0][0],_builtin_large_font_kerning_pair_count,&_builtin_large_font_kerning_pairs[0][0],_builtin_large_font_img_width,_builtin_large_font_img_height,_builtin_large_font_img_data);
// Font Colors
@@ -939,7 +939,7 @@ void make_default_theme() {
style->set_default_margin( Margin(),8);
}
- Ref<Font> f = make_default_font();
+ Ref<BitmapFont> f = make_default_font();
Theme::set_default( t );
Theme::set_default_icon( texture );
Theme::set_default_style( style );
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index ef5b7a3eb0..0d8d224037 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -31,7 +31,67 @@
#include "core/os/file_access.h"
#include "core/io/resource_loader.h"
-void Font::_set_chars(const DVector<int>& p_chars) {
+
+
+void Font::draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate) const {
+
+ float length=get_string_size(p_text).width;
+ if (length>=p_width) {
+ draw(p_canvas_item,p_pos,p_text,p_modulate,p_width);
+ return;
+ }
+
+ float ofs;
+ switch(p_align) {
+ case HALIGN_LEFT: {
+ ofs=0;
+ } break;
+ case HALIGN_CENTER: {
+ ofs = Math::floor( (p_width-length) / 2.0 );
+ } break;
+ case HALIGN_RIGHT: {
+ ofs=p_width-length;
+ } break;
+ }
+ draw(p_canvas_item,p_pos+Point2(ofs,0),p_text,p_modulate,p_width);
+}
+
+void Font::draw(RID p_canvas_item, const Point2& p_pos, const String& p_text, const Color& p_modulate,int p_clip_w) const {
+
+ Vector2 ofs;
+
+ for (int i=0;i<p_text.length();i++) {
+
+ int width = get_char_size(p_text[i]).width;
+
+ if (p_clip_w>=0 && (ofs.x+width)>p_clip_w)
+ break; //clip
+
+ ofs.x+=draw_char(p_canvas_item,p_pos+ofs,p_text[i],p_text[i+1],p_modulate);
+ }
+}
+
+void Font::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("get_ascent"),&Font::get_ascent);
+ ObjectTypeDB::bind_method(_MD("get_descent"),&Font::get_descent);
+ ObjectTypeDB::bind_method(_MD("get_height"),&Font::get_height);
+ ObjectTypeDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint);
+ ObjectTypeDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size);
+ ObjectTypeDB::bind_method(_MD("draw_char","canvas_item","pos","char","next","modulate"),&Font::draw_char,DEFVAL(-1),DEFVAL(Color(1,1,1)));
+
+}
+
+
+Font::Font() {
+
+
+}
+
+/////////////////////////////////////////////////////////////////
+
+void BitmapFont::_set_chars(const DVector<int>& p_chars) {
int len = p_chars.size();
//char 1 charsize 1 texture, 4 rect, 2 align, advance 1
@@ -50,7 +110,7 @@ void Font::_set_chars(const DVector<int>& p_chars) {
}
-DVector<int> Font::_get_chars() const {
+DVector<int> BitmapFont::_get_chars() const {
DVector<int> chars;
@@ -74,7 +134,7 @@ DVector<int> Font::_get_chars() const {
return chars;
}
-void Font::_set_kernings(const DVector<int>& p_kernings) {
+void BitmapFont::_set_kernings(const DVector<int>& p_kernings) {
int len=p_kernings.size();
ERR_FAIL_COND(len%3);
@@ -89,7 +149,7 @@ void Font::_set_kernings(const DVector<int>& p_kernings) {
}
}
-DVector<int> Font::_get_kernings() const {
+DVector<int> BitmapFont::_get_kernings() const {
DVector<int> kernings;
@@ -104,7 +164,7 @@ DVector<int> Font::_get_kernings() const {
}
-void Font::_set_textures(const Vector<Variant> & p_textures) {
+void BitmapFont::_set_textures(const Vector<Variant> & p_textures) {
for(int i=0;i<p_textures.size();i++) {
Ref<Texture> tex = p_textures[i];
@@ -114,7 +174,7 @@ void Font::_set_textures(const Vector<Variant> & p_textures) {
}
-Vector<Variant> Font::_get_textures() const {
+Vector<Variant> BitmapFont::_get_textures() const {
Vector<Variant> rtextures;
for(int i=0;i<textures.size();i++)
@@ -122,7 +182,7 @@ Vector<Variant> Font::_get_textures() const {
return rtextures;
}
-Error Font::create_from_fnt(const String& p_string) {
+Error BitmapFont::create_from_fnt(const String& p_string) {
//fnt format used by angelcode bmfont
//http://www.angelcode.com/products/bmfont/
@@ -271,51 +331,51 @@ Error Font::create_from_fnt(const String& p_string) {
-void Font::set_height(float p_height) {
+void BitmapFont::set_height(float p_height) {
height=p_height;
}
-float Font::get_height() const{
+float BitmapFont::get_height() const{
return height;
}
-void Font::set_ascent(float p_ascent){
+void BitmapFont::set_ascent(float p_ascent){
ascent=p_ascent;
}
-float Font::get_ascent() const {
+float BitmapFont::get_ascent() const {
return ascent;
}
-float Font::get_descent() const {
+float BitmapFont::get_descent() const {
return height-ascent;
}
-void Font::add_texture(const Ref<Texture>& p_texture) {
+void BitmapFont::add_texture(const Ref<Texture>& p_texture) {
ERR_FAIL_COND( p_texture.is_null());
textures.push_back( p_texture );
}
-int Font::get_texture_count() const {
+int BitmapFont::get_texture_count() const {
return textures.size();
};
-Ref<Texture> Font::get_texture(int p_idx) const {
+Ref<Texture> BitmapFont::get_texture(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, textures.size(), Ref<Texture>());
return textures[p_idx];
};
-int Font::get_character_count() const {
+int BitmapFont::get_character_count() const {
return char_map.size();
};
-Vector<CharType> Font::get_char_keys() const {
+Vector<CharType> BitmapFont::get_char_keys() const {
Vector<CharType> chars;
chars.resize(char_map.size());
@@ -329,7 +389,7 @@ Vector<CharType> Font::get_char_keys() const {
return chars;
};
-Font::Character Font::get_character(CharType p_char) const {
+BitmapFont::Character BitmapFont::get_character(CharType p_char) const {
if (!char_map.has(p_char)) {
ERR_FAIL_V(Character());
@@ -338,7 +398,7 @@ Font::Character Font::get_character(CharType p_char) const {
return char_map[p_char];
};
-void Font::add_char(CharType p_char, int p_texture_idx, const Rect2& p_rect, const Size2& p_align, float p_advance) {
+void BitmapFont::add_char(CharType p_char, int p_texture_idx, const Rect2& p_rect, const Size2& p_align, float p_advance) {
if (p_advance<0)
p_advance=p_rect.size.width;
@@ -353,7 +413,7 @@ void Font::add_char(CharType p_char, int p_texture_idx, const Rect2& p_rect, con
char_map[p_char]=c;
}
-void Font::add_kerning_pair(CharType p_A,CharType p_B,int p_kerning) {
+void BitmapFont::add_kerning_pair(CharType p_A,CharType p_B,int p_kerning) {
KerningPairKey kpk;
@@ -369,10 +429,10 @@ void Font::add_kerning_pair(CharType p_A,CharType p_B,int p_kerning) {
}
}
-Vector<Font::KerningPairKey> Font::get_kerning_pair_keys() const {
+Vector<BitmapFont::KerningPairKey> BitmapFont::get_kerning_pair_keys() const {
- Vector<Font::KerningPairKey> ret;
+ Vector<BitmapFont::KerningPairKey> ret;
ret.resize(kerning_map.size());
int i=0;
@@ -385,7 +445,7 @@ Vector<Font::KerningPairKey> Font::get_kerning_pair_keys() const {
}
-int Font::get_kerning_pair(CharType p_A,CharType p_B) const {
+int BitmapFont::get_kerning_pair(CharType p_A,CharType p_B) const {
KerningPairKey kpk;
kpk.A=p_A;
@@ -398,19 +458,19 @@ int Font::get_kerning_pair(CharType p_A,CharType p_B) const {
return 0;
}
-void Font::set_distance_field_hint(bool p_distance_field) {
+void BitmapFont::set_distance_field_hint(bool p_distance_field) {
distance_field_hint=p_distance_field;
emit_changed();
}
-bool Font::is_distance_field_hint() const{
+bool BitmapFont::is_distance_field_hint() const{
return distance_field_hint;
}
-void Font::clear() {
+void BitmapFont::clear() {
height=1;
ascent=0;
@@ -426,7 +486,7 @@ Size2 Font::get_string_size(const String& p_string) const {
int l = p_string.length();
if (l==0)
- return Size2(0,height);
+ return Size2(0,get_height());
const CharType *sptr = &p_string[0];
for (int i=0;i<l;i++) {
@@ -434,48 +494,19 @@ Size2 Font::get_string_size(const String& p_string) const {
w+=get_char_size(sptr[i],sptr[i+1]).width;
}
- return Size2(w,height);
+ return Size2(w,get_height());
}
+void BitmapFont::set_fallback(const Ref<BitmapFont> &p_fallback) {
-void Font::draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate) const {
-
- float length=get_string_size(p_text).width;
- if (length>=p_width) {
- draw(p_canvas_item,p_pos,p_text,p_modulate,p_width);
- return;
- }
-
- float ofs;
- switch(p_align) {
- case HALIGN_LEFT: {
- ofs=0;
- } break;
- case HALIGN_CENTER: {
- ofs = Math::floor( (p_width-length) / 2.0 );
- } break;
- case HALIGN_RIGHT: {
- ofs=p_width-length;
- } break;
- }
- draw(p_canvas_item,p_pos+Point2(ofs,0),p_text,p_modulate,p_width);
+ fallback=p_fallback;
}
-void Font::draw(RID p_canvas_item, const Point2& p_pos, const String& p_text, const Color& p_modulate,int p_clip_w) const {
+Ref<BitmapFont> BitmapFont::get_fallback() const{
- Vector2 ofs;
-
- for (int i=0;i<p_text.length();i++) {
-
- int width = get_char_size(p_text[i]).width;
-
- if (p_clip_w>=0 && (ofs.x+width)>p_clip_w)
- break; //clip
-
- ofs.x+=draw_char(p_canvas_item,p_pos+ofs,p_text[i],p_text[i+1],p_modulate);
- }
+ return fallback;
}
-float Font::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next,const Color& p_modulate) const {
+float BitmapFont::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next,const Color& p_modulate) const {
const Character * c = char_map.getptr(p_char);
@@ -496,58 +527,70 @@ float Font::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_
return get_char_size(p_char,p_next).width;
}
-void Font::set_fallback(const Ref<Font> &p_fallback) {
- fallback=p_fallback;
-}
+Size2 BitmapFont::get_char_size(CharType p_char,CharType p_next) const {
-Ref<Font> Font::get_fallback() const{
+ const Character * c = char_map.getptr(p_char);
- return fallback;
+ if (!c) {
+ if (fallback.is_valid())
+ return fallback->get_char_size(p_char,p_next);
+ return Size2();
+ }
+
+ Size2 ret(c->advance,c->rect.size.y);
+
+ if (p_next) {
+
+ KerningPairKey kpk;
+ kpk.A=p_char;
+ kpk.B=p_next;
+
+ const Map<KerningPairKey,int>::Element *E=kerning_map.find(kpk);
+ if (E) {
+
+ ret.width-=E->get();
+ }
+ }
+
+ return ret;
}
-void Font::_bind_methods() {
+void BitmapFont::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create_from_fnt","path"),&Font::create_from_fnt);
- ObjectTypeDB::bind_method(_MD("set_height","px"),&Font::set_height);
- ObjectTypeDB::bind_method(_MD("get_height"),&Font::get_height);
+ ObjectTypeDB::bind_method(_MD("create_from_fnt","path"),&BitmapFont::create_from_fnt);
+ ObjectTypeDB::bind_method(_MD("set_height","px"),&BitmapFont::set_height);
- ObjectTypeDB::bind_method(_MD("set_ascent","px"),&Font::set_ascent);
- ObjectTypeDB::bind_method(_MD("get_ascent"),&Font::get_ascent);
- ObjectTypeDB::bind_method(_MD("get_descent"),&Font::get_descent);
+ ObjectTypeDB::bind_method(_MD("set_ascent","px"),&BitmapFont::set_ascent);
- ObjectTypeDB::bind_method(_MD("add_kerning_pair","char_a","char_b","kerning"),&Font::add_kerning_pair);
- ObjectTypeDB::bind_method(_MD("get_kerning_pair","char_a","char_b"),&Font::get_kerning_pair);
+ ObjectTypeDB::bind_method(_MD("add_kerning_pair","char_a","char_b","kerning"),&BitmapFont::add_kerning_pair);
+ ObjectTypeDB::bind_method(_MD("get_kerning_pair","char_a","char_b"),&BitmapFont::get_kerning_pair);
- ObjectTypeDB::bind_method(_MD("add_texture","texture:Texture"),&Font::add_texture);
- ObjectTypeDB::bind_method(_MD("add_char","character","texture","rect","align","advance"),&Font::add_char,DEFVAL(Point2()),DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("add_texture","texture:Texture"),&BitmapFont::add_texture);
+ ObjectTypeDB::bind_method(_MD("add_char","character","texture","rect","align","advance"),&BitmapFont::add_char,DEFVAL(Point2()),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("get_texture_count"),&Font::get_texture_count);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture","idx"),&Font::get_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture_count"),&BitmapFont::get_texture_count);
+ ObjectTypeDB::bind_method(_MD("get_texture:Texture","idx"),&BitmapFont::get_texture);
- ObjectTypeDB::bind_method(_MD("get_char_size","char","next"),&Font::get_char_size,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size);
+ ObjectTypeDB::bind_method(_MD("get_char_size","char","next"),&BitmapFont::get_char_size,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("set_distance_field_hint","enable"),&Font::set_distance_field_hint);
- ObjectTypeDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint);
+ ObjectTypeDB::bind_method(_MD("set_distance_field_hint","enable"),&BitmapFont::set_distance_field_hint);
- ObjectTypeDB::bind_method(_MD("clear"),&Font::clear);
+ ObjectTypeDB::bind_method(_MD("clear"),&BitmapFont::clear);
- ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("draw_char","canvas_item","pos","char","next","modulate"),&Font::draw_char,DEFVAL(-1),DEFVAL(Color(1,1,1)));
- ObjectTypeDB::bind_method(_MD("_set_chars"),&Font::_set_chars);
- ObjectTypeDB::bind_method(_MD("_get_chars"),&Font::_get_chars);
+ ObjectTypeDB::bind_method(_MD("_set_chars"),&BitmapFont::_set_chars);
+ ObjectTypeDB::bind_method(_MD("_get_chars"),&BitmapFont::_get_chars);
- ObjectTypeDB::bind_method(_MD("_set_kernings"),&Font::_set_kernings);
- ObjectTypeDB::bind_method(_MD("_get_kernings"),&Font::_get_kernings);
+ ObjectTypeDB::bind_method(_MD("_set_kernings"),&BitmapFont::_set_kernings);
+ ObjectTypeDB::bind_method(_MD("_get_kernings"),&BitmapFont::_get_kernings);
- ObjectTypeDB::bind_method(_MD("_set_textures"),&Font::_set_textures);
- ObjectTypeDB::bind_method(_MD("_get_textures"),&Font::_get_textures);
+ ObjectTypeDB::bind_method(_MD("_set_textures"),&BitmapFont::_set_textures);
+ ObjectTypeDB::bind_method(_MD("_get_textures"),&BitmapFont::_get_textures);
- ObjectTypeDB::bind_method(_MD("set_fallback","fallback"),&Font::set_fallback);
- ObjectTypeDB::bind_method(_MD("get_fallback"),&Font::get_fallback);
+ ObjectTypeDB::bind_method(_MD("set_fallback","fallback"),&BitmapFont::set_fallback);
+ ObjectTypeDB::bind_method(_MD("get_fallback"),&BitmapFont::get_fallback);
ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "textures", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_textures"), _SCS("_get_textures") );
ADD_PROPERTY( PropertyInfo( Variant::INT_ARRAY, "chars", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_chars"), _SCS("_get_chars") );
@@ -556,11 +599,11 @@ void Font::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_height"), _SCS("get_height") );
ADD_PROPERTY( PropertyInfo( Variant::REAL, "ascent", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_ascent"), _SCS("get_ascent") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "distance_field" ), _SCS("set_distance_field_hint"), _SCS("is_distance_field_hint") );
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "fallback", PROPERTY_HINT_RESOURCE_TYPE,"Font" ), _SCS("set_fallback"), _SCS("get_fallback") );
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "fallback", PROPERTY_HINT_RESOURCE_TYPE,"BitmapFont" ), _SCS("set_fallback"), _SCS("get_fallback") );
}
-Font::Font() {
+BitmapFont::BitmapFont() {
clear();
@@ -569,7 +612,7 @@ Font::Font() {
}
-Font::~Font() {
+BitmapFont::~BitmapFont() {
clear();
}
diff --git a/scene/resources/font.h b/scene/resources/font.h
index 03b1ec5191..91f4874932 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -35,9 +35,40 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
+
+
class Font : public Resource {
OBJ_TYPE( Font, Resource );
+
+protected:
+
+ static void _bind_methods();
+
+public:
+
+ virtual float get_height() const=0;
+
+ virtual float get_ascent() const=0;
+ virtual float get_descent() const=0;
+
+ virtual Size2 get_char_size(CharType p_char,CharType p_next=0) const=0;
+ Size2 get_string_size(const String& p_string) const;
+
+ virtual bool is_distance_field_hint() const=0;
+
+ void draw(RID p_canvas_item, const Point2& p_pos, const String& p_text,const Color& p_modulate=Color(1,1,1),int p_clip_w=-1) const;
+ void draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate=Color(1,1,1)) const;
+ virtual float draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next=0,const Color& p_modulate=Color(1,1,1)) const=0;
+
+ Font();
+
+};
+
+
+class BitmapFont : public Font {
+
+ OBJ_TYPE( BitmapFont, Font );
RES_BASE_EXTENSION("fnt");
Vector< Ref<Texture> > textures;
@@ -84,7 +115,7 @@ private:
void _set_textures(const Vector<Variant> & p_textures);
Vector<Variant> _get_textures() const;
- Ref<Font> fallback;
+ Ref<BitmapFont> fallback;
protected:
static void _bind_methods();
@@ -114,54 +145,23 @@ public:
int get_kerning_pair(CharType p_A,CharType p_B) const;
Vector<KerningPairKey> get_kerning_pair_keys() const;
- inline Size2 get_char_size(CharType p_char,CharType p_next=0) const;
- Size2 get_string_size(const String& p_string) const;
-
+ Size2 get_char_size(CharType p_char,CharType p_next=0) const;
- void set_fallback(const Ref<Font> &p_fallback);
- Ref<Font> get_fallback() const;
+ void set_fallback(const Ref<BitmapFont> &p_fallback);
+ Ref<BitmapFont> get_fallback() const;
void clear();
void set_distance_field_hint(bool p_distance_field);
bool is_distance_field_hint() const;
- void draw(RID p_canvas_item, const Point2& p_pos, const String& p_text,const Color& p_modulate=Color(1,1,1),int p_clip_w=-1) const;
- void draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate=Color(1,1,1)) const;
float draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next=0,const Color& p_modulate=Color(1,1,1)) const;
- Font();
- ~Font();
+ BitmapFont();
+ ~BitmapFont();
};
-Size2 Font::get_char_size(CharType p_char,CharType p_next) const {
-
- const Character * c = char_map.getptr(p_char);
-
- if (!c) {
- if (fallback.is_valid())
- return fallback->get_char_size(p_char,p_next);
- return Size2();
- }
-
- Size2 ret(c->advance,c->rect.size.y);
-
- if (p_next) {
-
- KerningPairKey kpk;
- kpk.A=p_char;
- kpk.B=p_next;
-
- const Map<KerningPairKey,int>::Element *E=kerning_map.find(kpk);
- if (E) {
-
- ret.width-=E->get();
- }
- }
-
- return ret;
-}
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index ab1c7ef66f..12ac0bd1ca 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -33,7 +33,7 @@
void Body2DSW::_update_inertia() {
- if (get_space() && !inertia_update_list.in_list())
+ if (!user_inertia && get_space() && !inertia_update_list.in_list())
get_space()->body_add_to_inertia_update_list(&inertia_update_list);
}
@@ -48,6 +48,8 @@ void Body2DSW::update_inertias() {
case Physics2DServer::BODY_MODE_RIGID: {
+ if(user_inertia) break;
+
//update tensor for allshapes, not the best way but should be somehow OK. (inspired from bullet)
float total_area=0;
@@ -157,6 +159,15 @@ void Body2DSW::set_param(Physics2DServer::BodyParameter p_param, float p_value)
_update_inertia();
} break;
+ case Physics2DServer::BODY_PARAM_INERTIA: {
+ if(p_value<=0) {
+ user_inertia = false;
+ _update_inertia();
+ } else {
+ user_inertia = true;
+ _inv_inertia = 1.0 / p_value;
+ }
+ } break;
case Physics2DServer::BODY_PARAM_GRAVITY_SCALE: {
gravity_scale=p_value;
} break;
@@ -186,6 +197,9 @@ float Body2DSW::get_param(Physics2DServer::BodyParameter p_param) const {
case Physics2DServer::BODY_PARAM_MASS: {
return mass;
} break;
+ case Physics2DServer::BODY_PARAM_INERTIA: {
+ return _inv_inertia==0 ? 0 : 1.0 / _inv_inertia;
+ } break;
case Physics2DServer::BODY_PARAM_GRAVITY_SCALE: {
return gravity_scale;
} break;
@@ -665,6 +679,7 @@ Body2DSW::Body2DSW() : CollisionObject2DSW(TYPE_BODY), active_list(this), inerti
angular_velocity=0;
biased_angular_velocity=0;
mass=1;
+ user_inertia=false;
_inv_inertia=0;
_inv_mass=1;
bounce=0;
diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h
index b7f3ab01db..ed98017629 100644
--- a/servers/physics_2d/body_2d_sw.h
+++ b/servers/physics_2d/body_2d_sw.h
@@ -57,6 +57,7 @@ class Body2DSW : public CollisionObject2DSW {
real_t _inv_mass;
real_t _inv_inertia;
+ bool user_inertia;
Vector2 gravity;
real_t area_linear_damp;
@@ -204,10 +205,10 @@ public:
_FORCE_INLINE_ real_t get_biased_angular_velocity() const { return biased_angular_velocity; }
- _FORCE_INLINE_ void apply_impulse(const Vector2& p_pos, const Vector2& p_j) {
+ _FORCE_INLINE_ void apply_impulse(const Vector2& p_offset, const Vector2& p_impulse) {
- linear_velocity += p_j * _inv_mass;
- angular_velocity += _inv_inertia * p_pos.cross(p_j);
+ linear_velocity += p_impulse * _inv_mass;
+ angular_velocity += _inv_inertia * p_offset.cross(p_impulse);
}
_FORCE_INLINE_ void apply_bias_impulse(const Vector2& p_pos, const Vector2& p_j) {
@@ -243,6 +244,11 @@ public:
void set_applied_torque(real_t p_torque) { applied_torque=p_torque; }
real_t get_applied_torque() const { return applied_torque; }
+ _FORCE_INLINE_ void add_force(const Vector2& p_force, const Vector2& p_offset) {
+
+ applied_force += p_force;
+ applied_torque += p_offset.cross(p_force);
+ }
_FORCE_INLINE_ void set_continuous_collision_detection_mode(Physics2DServer::CCDMode p_mode) { continuous_cd_mode=p_mode; }
_FORCE_INLINE_ Physics2DServer::CCDMode get_continuous_collision_detection_mode() const { return continuous_cd_mode; }
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index c571331498..3796ddd961 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -860,6 +860,15 @@ void Physics2DServerSW::body_apply_impulse(RID p_body, const Vector2& p_pos, con
body->wakeup();
};
+void Physics2DServerSW::body_add_force(RID p_body, const Vector2& p_offset, const Vector2& p_force) {
+
+ Body2DSW *body = body_owner.get(p_body);
+ ERR_FAIL_COND(!body);
+
+ body->add_force(p_force,p_offset);
+ body->wakeup();
+};
+
void Physics2DServerSW::body_set_axis_velocity(RID p_body, const Vector2& p_axis_velocity) {
Body2DSW *body = body_owner.get(p_body);
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index cd4dfc1a8b..6415786803 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -205,6 +205,8 @@ public:
virtual void body_set_applied_torque(RID p_body, float p_torque);
virtual float body_get_applied_torque(RID p_body) const;
+ virtual void body_add_force(RID p_body, const Vector2& p_offset, const Vector2& p_force);
+
virtual void body_apply_impulse(RID p_body, const Vector2& p_pos, const Vector2& p_impulse);
virtual void body_set_axis_velocity(RID p_body, const Vector2& p_axis_velocity);
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h
index 60f8a4c879..891c45addf 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.h
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.h
@@ -205,6 +205,7 @@ public:
FUNC2(body_set_applied_torque,RID,float);
FUNC1RC(float,body_get_applied_torque,RID);
+ FUNC3(body_add_force,RID,const Vector2&,const Vector2&);
FUNC3(body_apply_impulse,RID,const Vector2&,const Vector2&);
FUNC2(body_set_axis_velocity,RID,const Vector2&);
diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp
index 2d267a5749..a85fefe5ad 100644
--- a/servers/physics_2d_server.cpp
+++ b/servers/physics_2d_server.cpp
@@ -597,6 +597,7 @@ void Physics2DServer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("body_get_state","body","state"),&Physics2DServer::body_get_state);
ObjectTypeDB::bind_method(_MD("body_apply_impulse","body","pos","impulse"),&Physics2DServer::body_apply_impulse);
+ ObjectTypeDB::bind_method(_MD("body_add_force","body","offset","force"),&Physics2DServer::body_add_force);
ObjectTypeDB::bind_method(_MD("body_set_axis_velocity","body","axis_velocity"),&Physics2DServer::body_set_axis_velocity);
ObjectTypeDB::bind_method(_MD("body_add_collision_exception","body","excepted_body"),&Physics2DServer::body_add_collision_exception);
@@ -677,6 +678,7 @@ void Physics2DServer::_bind_methods() {
BIND_CONSTANT( BODY_PARAM_BOUNCE );
BIND_CONSTANT( BODY_PARAM_FRICTION );
BIND_CONSTANT( BODY_PARAM_MASS );
+ BIND_CONSTANT( BODY_PARAM_INERTIA );
BIND_CONSTANT( BODY_PARAM_GRAVITY_SCALE );
BIND_CONSTANT( BODY_PARAM_LINEAR_DAMP);
BIND_CONSTANT( BODY_PARAM_ANGULAR_DAMP);
diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h
index 25875f16d3..dd04f0f6b8 100644
--- a/servers/physics_2d_server.h
+++ b/servers/physics_2d_server.h
@@ -421,6 +421,7 @@ public:
BODY_PARAM_BOUNCE,
BODY_PARAM_FRICTION,
BODY_PARAM_MASS, ///< unused for static, always infinite
+ BODY_PARAM_INERTIA, // read-only: computed from mass & shapes
BODY_PARAM_GRAVITY_SCALE,
BODY_PARAM_LINEAR_DAMP,
BODY_PARAM_ANGULAR_DAMP,
@@ -450,7 +451,9 @@ public:
virtual void body_set_applied_torque(RID p_body, float p_torque)=0;
virtual float body_get_applied_torque(RID p_body) const=0;
- virtual void body_apply_impulse(RID p_body, const Vector2& p_pos, const Vector2& p_impulse)=0;
+ virtual void body_add_force(RID p_body, const Vector2& p_offset, const Vector2& p_force)=0;
+
+ virtual void body_apply_impulse(RID p_body, const Vector2& p_offset, const Vector2& p_impulse)=0;
virtual void body_set_axis_velocity(RID p_body, const Vector2& p_axis_velocity)=0;
//fix
diff --git a/tools/editor/editor_fonts.cpp b/tools/editor/editor_fonts.cpp
index b12b041f16..a3ec08f986 100644
--- a/tools/editor/editor_fonts.cpp
+++ b/tools/editor/editor_fonts.cpp
@@ -31,10 +31,10 @@
#include "doc_title_font.h"
#include "doc_code_font.h"
-static Ref<Font> make_font(int p_height,int p_ascent, int p_valign, int p_charcount, const int *p_chars,const Ref<Texture> &p_texture) {
+static Ref<BitmapFont> make_font(int p_height,int p_ascent, int p_valign, int p_charcount, const int *p_chars,const Ref<Texture> &p_texture) {
- Ref<Font> font( memnew( Font ) );
+ Ref<BitmapFont> font( memnew( BitmapFont ) );
font->add_texture( p_texture );
for (int i=0;i<p_charcount;i++) {
@@ -65,9 +65,9 @@ static Ref<Font> make_font(int p_height,int p_ascent, int p_valign, int p_charco
void editor_register_fonts(Ref<Theme> p_theme) {
- Ref<Font> doc_font = make_font(_bi_font_doc_font_height,_bi_font_doc_font_ascent,0,_bi_font_doc_font_charcount,_bi_font_doc_font_characters,p_theme->get_icon("DocFont","EditorIcons"));
- Ref<Font> doc_code_font = make_font(_bi_font_doc_code_font_height,_bi_font_doc_code_font_ascent,0,_bi_font_doc_code_font_charcount,_bi_font_doc_code_font_characters,p_theme->get_icon("DocCodeFont","EditorIcons"));
- Ref<Font> doc_title_font = make_font(_bi_font_doc_title_font_height,_bi_font_doc_title_font_ascent,0,_bi_font_doc_title_font_charcount,_bi_font_doc_title_font_characters,p_theme->get_icon("DocTitleFont","EditorIcons"));
+ Ref<BitmapFont> doc_font = make_font(_bi_font_doc_font_height,_bi_font_doc_font_ascent,0,_bi_font_doc_font_charcount,_bi_font_doc_font_characters,p_theme->get_icon("DocFont","EditorIcons"));
+ Ref<BitmapFont> doc_code_font = make_font(_bi_font_doc_code_font_height,_bi_font_doc_code_font_ascent,0,_bi_font_doc_code_font_charcount,_bi_font_doc_code_font_characters,p_theme->get_icon("DocCodeFont","EditorIcons"));
+ Ref<BitmapFont> doc_title_font = make_font(_bi_font_doc_title_font_height,_bi_font_doc_title_font_ascent,0,_bi_font_doc_title_font_charcount,_bi_font_doc_title_font_characters,p_theme->get_icon("DocTitleFont","EditorIcons"));
p_theme->set_font("doc","EditorFonts",doc_font);
p_theme->set_font("doc_code","EditorFonts",doc_code_font);
p_theme->set_font("doc_title","EditorFonts",doc_title_font);
diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp
index e02ffd337b..bdf1726d85 100644
--- a/tools/editor/editor_import_export.cpp
+++ b/tools/editor/editor_import_export.cpp
@@ -294,6 +294,39 @@ static void _remove_filter_from_list(Set<StringName>& r_list,const String& p_fil
_edit_filter_list(r_list,p_filter,true);
}
+bool EditorExportPlatform::_set(const StringName& p_name, const Variant& p_value) {
+
+ String n = p_name;
+
+ if (n=="debug/debugging_enabled") {
+ set_debugging_enabled(p_value);
+ } else {
+ return false;
+ }
+
+ return true;
+
+}
+
+bool EditorExportPlatform::_get(const StringName& p_name,Variant &r_ret) const {
+
+ String n = p_name;
+
+ if (n=="debug/debugging_enabled") {
+ r_ret=is_debugging_enabled();
+ } else {
+ return false;
+ }
+
+ return true;
+
+}
+
+void EditorExportPlatform::_get_property_list( List<PropertyInfo> *p_list) const {
+
+ p_list->push_front( PropertyInfo( Variant::BOOL, "debug/debugging_enabled"));
+}
+
Vector<uint8_t> EditorExportPlatform::get_exported_file_default(String& p_fname) const {
FileAccess *f = FileAccess::open(p_fname,FileAccess::READ);
@@ -481,8 +514,15 @@ bool EditorExportPlatform::exists_export_template(String template_file_name, Str
+bool EditorExportPlatform::is_debugging_enabled() const {
+
+ return debugging_enabled;
+}
+void EditorExportPlatform::set_debugging_enabled(bool p_enabled) {
+ debugging_enabled = p_enabled;
+}
bool EditorExportPlatformPC::_set(const StringName& p_name, const Variant& p_value) {
@@ -1260,6 +1300,11 @@ Error EditorExportPlatform::save_pack(FileAccess *dst,bool p_make_bundles, int p
return OK;
}
+EditorExportPlatform::EditorExportPlatform() {
+
+ debugging_enabled = true;
+}
+
Error EditorExportPlatformPC::export_project(const String& p_path, bool p_debug, int p_flags) {
diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h
index fc8ad58bd9..c131488d18 100644
--- a/tools/editor/editor_import_export.h
+++ b/tools/editor/editor_import_export.h
@@ -86,8 +86,17 @@ class EditorExportPlatform : public Reference {
public:
typedef Error (*EditorExportSaveFunction)(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
+
+private:
+
+ bool debugging_enabled;
+
protected:
+ bool _set(const StringName& p_name, const Variant& p_value);
+ bool _get(const StringName& p_name,Variant &r_ret) const;
+ void _get_property_list( List<PropertyInfo> *p_list) const;
+
Vector<uint8_t> get_exported_file_default(String& p_fname) const;
virtual Vector<uint8_t> get_exported_file(String& p_fname) const;
virtual Vector<StringName> get_dependencies(bool p_bundles) const;
@@ -145,6 +154,8 @@ public:
EXPORT_VIEW_NAVIGATION=16,
};
+ bool is_debugging_enabled() const;
+ void set_debugging_enabled( bool p_enabled );
Error export_project_files(EditorExportSaveFunction p_func, void* p_udata,bool p_make_bundles);
@@ -164,11 +175,11 @@ public:
virtual bool can_export(String *r_error=NULL) const=0;
- virtual bool requieres_password(bool p_debug) const { return false; }
+ virtual bool requires_password(bool p_debug) const { return false; }
virtual String get_binary_extension() const=0;
virtual Error export_project(const String& p_path,bool p_debug,int p_flags=0)=0;
- EditorExportPlatform() {};
+ EditorExportPlatform();
};
class EditorExportPlatformPC : public EditorExportPlatform {
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 316485f42a..e556a26d7a 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -6011,11 +6011,6 @@ EditorNode::EditorNode() {
- file_export_check = memnew( CheckButton );
- file_export_check->set_text("Enable Debugging");
- file_export_check->set_pressed(true);
- file_export_check->connect("pressed",this,"_export_debug_toggled");
- file_export->get_vbox()->add_margin_child("Debug:",file_export_check);
file_export_password = memnew( LineEdit );
file_export_password->set_secret(true);
file_export_password->set_editable(false);
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index e4939afd34..c3b7a817c5 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -299,7 +299,6 @@ private:
FileDialog *file_export;
FileDialog *file_export_lib;
FileDialog *file_script;
- CheckButton *file_export_check;
CheckButton *file_export_lib_merge;
LineEdit *file_export_password;
String current_path;
diff --git a/tools/editor/icons/icon_bitmap_font.png b/tools/editor/icons/icon_bitmap_font.png
new file mode 100644
index 0000000000..45de2b0f0a
--- /dev/null
+++ b/tools/editor/icons/icon_bitmap_font.png
Binary files differ
diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp
index ff126a8e8c..715e48fccf 100644
--- a/tools/editor/io_plugins/editor_font_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp
@@ -437,7 +437,7 @@ class EditorFontImportDialog : public ConfirmationDialog {
void _update() {
Ref<ResourceImportMetadata> imd = get_rimd();
- Ref<Font> font = plugin->generate_font(imd);
+ Ref<BitmapFont> font = plugin->generate_font(imd);
test_label->add_font_override("font",font);
_update_text();
}
@@ -454,7 +454,7 @@ class EditorFontImportDialog : public ConfirmationDialog {
void _import_inc(String p_font) {
- Ref<Font> font = ResourceLoader::load(p_font);
+ Ref<BitmapFont> font = ResourceLoader::load(p_font);
if (!font.is_valid())
return;
Ref<ImageTexture> tex = font->get_texture(0);
@@ -471,12 +471,12 @@ class EditorFontImportDialog : public ConfirmationDialog {
for(int i=0;i<ck.size();i++) {
CharType k=ck[i];
- Font::Character c=font->get_character(k);
+ BitmapFont::Character c=font->get_character(k);
f->store_line("{"+itos(k)+","+rtos(c.rect.pos.x)+","+rtos(c.rect.pos.y)+","+rtos(c.rect.size.x)+","+rtos(c.rect.size.y)+","+rtos(c.v_align)+","+rtos(c.h_align)+","+rtos(c.advance)+"},");
}
f->store_line("};");
- Vector<Font::KerningPairKey> kp=font->get_kerning_pair_keys();
+ Vector<BitmapFont::KerningPairKey> kp=font->get_kerning_pair_keys();
f->store_line("static const int _builtin_font_kerning_pair_count="+itos(kp.size())+";");
f->store_line("static const int _builtin_font_kerning_pairs["+itos(kp.size())+"][3]={");
for(int i=0;i<kp.size();i++) {
@@ -634,7 +634,7 @@ public:
dest = memnew( EditorLineEditFileChooser );
//
List<String> fl;
- Ref<Font> font= memnew(Font);
+ Ref<BitmapFont> font= memnew(BitmapFont);
dest->get_file_dialog()->add_filter("*.fnt ; Font" );
//ResourceSaver::get_recognized_extensions(font,&fl);
//for(List<String>::Element *E=fl.front();E;E=E->next()) {
@@ -875,12 +875,12 @@ static unsigned char get_SDF_radial(
}
-Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata>& p_from, const String &p_existing) {
+Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata>& p_from, const String &p_existing) {
Ref<ResourceImportMetadata> from = p_from;
- ERR_FAIL_COND_V(from->get_source_count()!=1,Ref<Font>());
+ ERR_FAIL_COND_V(from->get_source_count()!=1,Ref<BitmapFont>());
String src_path = EditorImportPlugin::expand_source_path(from->get_source_path(0));
@@ -888,15 +888,15 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
if (ResourceLoader::load(src_path).is_valid()) {
EditorNode::get_singleton()->show_warning("Path: "+src_path+"\nIs a Godot font file, please supply a BMFont type file instead.");
- return Ref<Font>();
+ return Ref<BitmapFont>();
}
- Ref<Font> font;
+ Ref<BitmapFont> font;
font.instance();
Error err = font->create_from_fnt(src_path);
if (err) {
EditorNode::get_singleton()->show_warning("Path: "+src_path+"\nFailed opening as BMFont file.");
- return Ref<Font>();
+ return Ref<BitmapFont>();
}
return font;
@@ -913,7 +913,7 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
int error = FT_Init_FreeType( &library );
ERR_EXPLAIN("Error initializing FreeType.");
- ERR_FAIL_COND_V( error !=0, Ref<Font>() );
+ ERR_FAIL_COND_V( error !=0, Ref<BitmapFont>() );
print_line("loadfrom: "+src_path);
error = FT_New_Face( library, src_path.utf8().get_data(),0,&face );
@@ -928,7 +928,7 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
}
- ERR_FAIL_COND_V(error,Ref<Font>());
+ ERR_FAIL_COND_V(error,Ref<BitmapFont>());
int height=0;
@@ -940,7 +940,7 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
if ( error ) {
FT_Done_FreeType( library );
ERR_EXPLAIN("Invalid font size. ");
- ERR_FAIL_COND_V( error,Ref<Font>() );
+ ERR_FAIL_COND_V( error,Ref<BitmapFont>() );
}
@@ -987,7 +987,7 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
FT_Done_FreeType( library );
ERR_EXPLAIN("Invalid font custom source. ");
- ERR_FAIL_COND_V( !fa,Ref<Font>() );
+ ERR_FAIL_COND_V( !fa,Ref<BitmapFont>() );
}
@@ -1546,15 +1546,15 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
int bottom_space = from->get_option("extra_space/bottom");
bool disable_filter = from->get_option("advanced/disable_filter");
- Ref<Font> font;
+ Ref<BitmapFont> font;
if (p_existing!=String() && ResourceCache::has(p_existing)) {
- font = Ref<Font>( ResourceCache::get(p_existing)->cast_to<Font>());
+ font = Ref<BitmapFont>( ResourceCache::get(p_existing)->cast_to<BitmapFont>());
}
if (font.is_null()) {
- font = Ref<Font>( memnew( Font ) );
+ font = Ref<BitmapFont>( memnew( BitmapFont ) );
}
font->clear();
@@ -1596,7 +1596,7 @@ Ref<Font> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata
return font;
#else
- return Ref<Font>();
+ return Ref<BitmapFont>();
#endif
}
@@ -1616,7 +1616,7 @@ void EditorFontImportPlugin::import_dialog(const String& p_from){
Error EditorFontImportPlugin::import(const String& p_path, const Ref<ResourceImportMetadata>& p_from){
- Ref<Font> font = EditorFontImportPlugin::generate_font(p_from,p_path);
+ Ref<BitmapFont> font = EditorFontImportPlugin::generate_font(p_from,p_path);
if (!font.is_valid())
return ERR_CANT_CREATE;
diff --git a/tools/editor/io_plugins/editor_font_import_plugin.h b/tools/editor/io_plugins/editor_font_import_plugin.h
index 814897c5f0..ce26ef91e2 100644
--- a/tools/editor/io_plugins/editor_font_import_plugin.h
+++ b/tools/editor/io_plugins/editor_font_import_plugin.h
@@ -42,7 +42,7 @@ class EditorFontImportPlugin : public EditorImportPlugin {
EditorFontImportDialog *dialog;
public:
- Ref<Font> generate_font(const Ref<ResourceImportMetadata>& p_from,const String& p_existing=String()); //used by editor
+ Ref<BitmapFont> generate_font(const Ref<ResourceImportMetadata>& p_from,const String& p_existing=String()); //used by editor
virtual String get_name() const;
virtual String get_visible_name() const;
diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp
index 08c2a1c3ae..7e1214ec83 100644
--- a/tools/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp
@@ -239,8 +239,12 @@ void AnimationTreeEditor::_play_toggled() {
void AnimationTreeEditor::_master_anim_menu_item(int p_item) {
- String str = master_anim_popup->get_item_text(p_item);
- anim_tree->animation_node_set_master_animation(edited_node,str);
+ if(p_item == 0) _edit_filters();
+ else {
+
+ String str = master_anim_popup->get_item_text(p_item);
+ anim_tree->animation_node_set_master_animation(edited_node,str);
+ }
update();
}
@@ -291,6 +295,8 @@ void AnimationTreeEditor::_popup_edit_dialog() {
AnimationPlayer *ap = anim_tree->get_node(anim_tree->get_master_player())->cast_to<AnimationPlayer>();
master_anim_popup->clear();
+ master_anim_popup->add_item("Edit Filters");
+ master_anim_popup->add_separator();
List<StringName> sn;
ap->get_animation_list(&sn);
sn.sort_custom<StringName::AlphCompare>();
@@ -652,39 +658,35 @@ AnimationTreeEditor::ClickType AnimationTreeEditor::_locate_click(const Point2&
float y = pos.y-style->get_offset().height;
- if (y<h)
- return CLICK_NODE;
- y-=h;
-
- if (y<h)
+ if (y<2*h)
return CLICK_NODE;
+ y-=2*h;
- y-=h;
-
- int count=0; // title and name
int inputs = anim_tree->node_get_input_count(node);
- count += inputs?inputs:1;
+ int count = MAX(inputs,1);
- for(int i=0;i<count;i++) {
+ if (inputs==0 || (pos.x > size.width/2 && type != AnimationTreePlayer::NODE_OUTPUT)) {
- if (y<h) {
+ if (y<count*h) {
- if (inputs==0 || ( type!=AnimationTreePlayer::NODE_OUTPUT && pos.x > size.width/2)) {
+ if (p_slot_index)
+ *p_slot_index=0;
+ return CLICK_OUTPUT_SLOT;
+ }
+ }
- if (p_slot_index)
- *p_slot_index=0;
- return CLICK_OUTPUT_SLOT;
- } else {
+ for(int i=0;i<count;i++) {
- if (p_slot_index)
- *p_slot_index=i;
- return CLICK_INPUT_SLOT;
- }
+ if (y<h) {
+ if (p_slot_index)
+ *p_slot_index=i;
+ return CLICK_INPUT_SLOT;
}
y-=h;
}
- return (type!=AnimationTreePlayer::NODE_OUTPUT && type!=AnimationTreePlayer::NODE_TIMESEEK)?CLICK_PARAMETER:CLICK_NODE;
+ bool has_parameters = type!=AnimationTreePlayer::NODE_OUTPUT && type!=AnimationTreePlayer::NODE_TIMESEEK;
+ return has_parameters ? CLICK_PARAMETER : CLICK_NODE;
}
return CLICK_NONE;
@@ -1243,6 +1245,8 @@ void AnimationTreeEditor::_filter_edited() {
anim_tree->oneshot_node_set_filter_path(edited_node,ed->get_metadata(0),ed->is_checked(0));
} else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_BLEND2) {
anim_tree->blend2_node_set_filter_path(edited_node,ed->get_metadata(0),ed->is_checked(0));
+ } else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_ANIMATION) {
+ anim_tree->animation_node_set_filter_path(edited_node,ed->get_metadata(0),ed->is_checked(0));
}
}
@@ -1310,6 +1314,8 @@ void AnimationTreeEditor::_edit_filters() {
it->set_checked(0, anim_tree->oneshot_node_is_path_filtered(edited_node,E->get()));
} else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_BLEND2) {
it->set_checked(0, anim_tree->blend2_node_is_path_filtered(edited_node,E->get()));
+ } else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_ANIMATION) {
+ it->set_checked(0, anim_tree->animation_node_is_path_filtered(edited_node,E->get()));
}
pm[E->get()]=it;
}
diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp
index 2d3100ac0d..d1e892a513 100644
--- a/tools/editor/plugins/shader_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_editor_plugin.cpp
@@ -78,15 +78,19 @@ void ShaderTextEditor::_load_theme_settings() {
get_text_edit()->set_custom_bg_color(EDITOR_DEF("text_editor/background_color",Color(0,0,0,0)));
get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0)));
+ get_text_edit()->add_color_override("line_number_color",EDITOR_DEF("text_editor/line_number_color",Color(0,0,0)));
+ get_text_edit()->add_color_override("caret_color",EDITOR_DEF("text_editor/caret_color",Color(0,0,0)));
get_text_edit()->add_color_override("font_selected_color",EDITOR_DEF("text_editor/text_selected_color",Color(1,1,1)));
get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1)));
get_text_edit()->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/brace_mismatch_color",Color(1,0.2,0.2)));
get_text_edit()->add_color_override("current_line_color",EDITOR_DEF("text_editor/current_line_color",Color(0.3,0.5,0.8,0.15)));
+ get_text_edit()->add_color_override("word_highlighted_color",EDITOR_DEF("text_editor/word_highlighted_color",Color(0.8,0.9,0.9,0.15)));
+ get_text_edit()->add_color_override("number_color",EDITOR_DEF("text_editor/number_color",Color(0.9,0.6,0.0,2)));
+ get_text_edit()->add_color_override("function_color",EDITOR_DEF("text_editor/function_color",Color(0.4,0.6,0.8)));
+ get_text_edit()->add_color_override("member_variable_color",EDITOR_DEF("text_editor/member_variable_color",Color(0.9,0.3,0.3)));
Color keyword_color= EDITOR_DEF("text_editor/keyword_color",Color(0.5,0.0,0.2));
- get_text_edit()->set_syntax_coloring(true);
-
List<String> keywords;
ShaderLanguage::get_keyword_list(type,&keywords);
@@ -355,9 +359,36 @@ void ShaderEditor::_params_changed() {
light_editor->_validate_script();
}
+void ShaderEditor::_editor_settings_changed() {
+
+ vertex_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
+ vertex_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
+ vertex_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
+ vertex_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs"));
+ vertex_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers"));
+ vertex_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting"));
+ vertex_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences"));
+
+ fragment_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
+ fragment_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
+ fragment_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
+ fragment_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs"));
+ fragment_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers"));
+ fragment_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting"));
+ fragment_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences"));
+
+ light_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
+ light_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
+ light_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
+ light_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs"));
+ light_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers"));
+ light_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting"));
+ light_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences"));
+}
void ShaderEditor::_bind_methods() {
+ ObjectTypeDB::bind_method("_editor_settings_changed",&ShaderEditor::_editor_settings_changed);
ObjectTypeDB::bind_method("_tab_changed",&ShaderEditor::_tab_changed);
ObjectTypeDB::bind_method("_menu_option",&ShaderEditor::_menu_option);
ObjectTypeDB::bind_method("_params_changed",&ShaderEditor::_params_changed);
@@ -506,6 +537,9 @@ ShaderEditor::ShaderEditor() {
vertex_editor->connect("script_changed", this,"apply_shaders");
fragment_editor->connect("script_changed", this,"apply_shaders");
light_editor->connect("script_changed", this,"apply_shaders");
+ EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");
+
+ _editor_settings_changed();
}
diff --git a/tools/editor/plugins/shader_editor_plugin.h b/tools/editor/plugins/shader_editor_plugin.h
index 26d20b80b4..e10c10a446 100644
--- a/tools/editor/plugins/shader_editor_plugin.h
+++ b/tools/editor/plugins/shader_editor_plugin.h
@@ -105,7 +105,7 @@ class ShaderEditor : public Control {
void _close_callback();
-
+ void _editor_settings_changed();
protected:
void _notification(int p_what);
diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp
index df8ebad08d..199d7646d4 100644
--- a/tools/editor/project_export.cpp
+++ b/tools/editor/project_export.cpp
@@ -481,7 +481,8 @@ void ProjectExportDialog::_export_action(const String& p_file) {
return;
String platform = selected->get_metadata(0);
- Error err = export_platform(platform,p_file,file_export_check->is_pressed(),file_export_password->get_text(),false);
+ bool debugging_enabled = EditorImportExport::get_singleton()->get_export_platform(platform)->is_debugging_enabled();
+ Error err = export_platform(platform,p_file,debugging_enabled,file_export_password->get_text(),false);
if (err!=OK) {
error->set_text("Error exporting project!");
error->popup_centered_minsize();
@@ -592,7 +593,7 @@ void ProjectExportDialog::custom_action(const String&) {
String extension = exporter->get_binary_extension();
- file_export_password->set_editable( exporter->requieres_password(file_export_check->is_pressed()));
+ file_export_password->set_editable( exporter->requires_password(exporter->is_debugging_enabled()) );
file_export->clear_filters();
if (extension!="") {
@@ -1453,12 +1454,6 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) {
file_export->set_title("Export Project");
file_export->connect("file_selected", this,"_export_action");
- file_export_check = memnew( CheckButton );
- file_export_check->set_text("Enable Debugging");
- file_export_check->set_pressed(true);
- file_export_check->connect("pressed",this,"_export_debug_toggled");
- file_export->get_vbox()->add_margin_child("Debug:",file_export_check);
-
file_export_password = memnew( LineEdit );
file_export_password->set_secret(true);
file_export_password->set_editable(false);
diff --git a/tools/editor/project_export.h b/tools/editor/project_export.h
index dc076ce201..8cf2bf3afc 100644
--- a/tools/editor/project_export.h
+++ b/tools/editor/project_export.h
@@ -86,7 +86,6 @@ private:
EditorFileDialog *pck_export;
EditorFileDialog *file_export;
- CheckButton *file_export_check;
LineEdit *file_export_password;
Button *button_export;
diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp
index 34bc31d20c..179af051a9 100644
--- a/tools/editor/project_settings.cpp
+++ b/tools/editor/project_settings.cpp
@@ -56,6 +56,20 @@ static const char* _button_names[JOY_BUTTON_MAX]={
"D-Pad Right"
};
+static const char* _axis_names[JOY_AXIS_MAX*2] = {
+ " (Left Stick Left)",
+ " (Left Stick Right)",
+ " (Left Stick Up)",
+ " (Left Stick Down)",
+ " (Right Stick Left)",
+ " (Right Stick Right)",
+ " (Right Stick Up)",
+ " (Right Stick Down)",
+ "","","","",
+ "", " (L2)",
+ "", " (R2)"
+};
+
void ProjectSettings::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
@@ -342,19 +356,7 @@ void ProjectSettings::_add_item(int p_item){
device_index->clear();
for(int i=0;i<JOY_AXIS_MAX*2;i++) {
- String desc;
-
- int ax=i/2;
- if (ax==0 || ax==1)
- desc=" (Left Stick)";
- else if (ax==2 || ax==3)
- desc=" (Right Stick)";
- else if (ax==6)
- desc=" (L2)";
- else if (ax==7)
- desc=" (R2)";
-
-
+ String desc = _axis_names[i];
device_index->add_item("Axis "+itos(i/2)+" "+(i&1?"+":"-")+desc);
}
device_input->popup_centered(Size2(350,95));
@@ -541,18 +543,10 @@ void ProjectSettings::_update_actions() {
} break;
case InputEvent::JOYSTICK_MOTION: {
- String desc;
int ax = ie.joy_motion.axis;
-
- if (ax==0 || ax==1)
- desc=" (Left Stick).";
- else if (ax==2 || ax==3)
- desc=" (Right Stick).";
- else if (ax==6)
- desc=" (L2).";
- else if (ax==7)
- desc=" (R2).";
- String str = "Device "+itos(ie.device)+", Axis "+itos(ie.joy_motion.axis)+" "+(ie.joy_motion.axis_value<0?"-":"+")+desc;
+ int n = 2*ax + (ie.joy_motion.axis_value<0 ? 0:1);
+ String desc = _axis_names[n];
+ String str = "Device "+itos(ie.device)+", Axis "+itos(ax)+" "+(ie.joy_motion.axis_value<0?"-":"+")+desc +".";
action->set_text(0,str);
action->set_icon(0,get_icon("JoyAxis","EditorIcons"));
} break;