summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/input_map.cpp2
-rw-r--r--core/os/input_event.cpp13
-rw-r--r--core/os/input_event.h4
-rw-r--r--doc/classes/InputEventAction.xml3
-rw-r--r--doc/classes/Position2D.xml2
-rw-r--r--editor/editor_about.cpp2
-rw-r--r--editor/project_manager.cpp2
-rw-r--r--main/main.cpp2
-rw-r--r--modules/gdscript/gdscript_compiler.cpp8
-rw-r--r--scene/2d/position_2d.cpp34
-rw-r--r--scene/2d/position_2d.h7
11 files changed, 67 insertions, 12 deletions
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 15f68f9c2a..012c6a7c4f 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -202,7 +202,7 @@ bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const Str
if (p_pressed != NULL)
*p_pressed = input_event_action->is_pressed();
if (p_strength != NULL)
- *p_strength = (*p_pressed) ? 1.0f : 0.0f;
+ *p_strength = (*p_pressed) ? input_event_action->get_strength() : 0.0f;
return input_event_action->get_action() == p_action;
}
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index a072017353..9c5066da3d 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -1010,6 +1010,14 @@ bool InputEventAction::is_pressed() const {
return pressed;
}
+void InputEventAction::set_strength(float p_strength) {
+ strength = CLAMP(p_strength, 0.0f, 1.0f);
+}
+
+float InputEventAction::get_strength() const {
+ return strength;
+}
+
bool InputEventAction::shortcut_match(const Ref<InputEvent> &p_event) const {
if (p_event.is_null())
return false;
@@ -1051,14 +1059,19 @@ void InputEventAction::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventAction::set_pressed);
//ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventAction::is_pressed);
+ ClassDB::bind_method(D_METHOD("set_strength", "strength"), &InputEventAction::set_strength);
+ ClassDB::bind_method(D_METHOD("get_strength"), &InputEventAction::get_strength);
+
// ClassDB::bind_method(D_METHOD("is_action", "name"), &InputEventAction::is_action);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "action"), "set_action", "get_action");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_strength", "get_strength");
}
InputEventAction::InputEventAction() {
pressed = false;
+ strength = 1.0f;
}
/////////////////////////////
diff --git a/core/os/input_event.h b/core/os/input_event.h
index ba01516519..7a9a1f71c3 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -475,6 +475,7 @@ class InputEventAction : public InputEvent {
StringName action;
bool pressed;
+ float strength;
protected:
static void _bind_methods();
@@ -486,6 +487,9 @@ public:
void set_pressed(bool p_pressed);
virtual bool is_pressed() const;
+ void set_strength(float p_strength);
+ float get_strength() const;
+
virtual bool is_action(const StringName &p_action) const;
virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
diff --git a/doc/classes/InputEventAction.xml b/doc/classes/InputEventAction.xml
index 25e9073ec7..9df7bbca74 100644
--- a/doc/classes/InputEventAction.xml
+++ b/doc/classes/InputEventAction.xml
@@ -18,6 +18,9 @@
<member name="pressed" type="bool" setter="set_pressed" getter="is_pressed">
If [code]true[/code], the action's state is pressed. If [code]false[/code], the action's state is released.
</member>
+ <member name="strength" type="float" setter="set_strength" getter="get_strength">
+ The action's strength between 0 and 1. This value is consired as equal to 0 if pressed is [code]false[/code]. The event strength allows faking analog joypad motion events, by precising how strongly is the joypad axis bent or pressed.
+ </member>
</members>
<constants>
</constants>
diff --git a/doc/classes/Position2D.xml b/doc/classes/Position2D.xml
index 034e35d9d7..916bd99131 100644
--- a/doc/classes/Position2D.xml
+++ b/doc/classes/Position2D.xml
@@ -4,7 +4,7 @@
Generic 2D Position hint for editing.
</brief_description>
<description>
- Generic 2D Position hint for editing. It's just like a plain [Node2D] but displays as a cross in the 2D-Editor at all times.
+ Generic 2D Position hint for editing. It's just like a plain [Node2D] but displays as a cross in the 2D-Editor at all times. You can set visual size of the cross by changing Gizmo Extents in the inspector.
</description>
<tutorials>
</tutorials>
diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp
index e9dd6d7199..bea1980b09 100644
--- a/editor/editor_about.cpp
+++ b/editor/editor_about.cpp
@@ -131,7 +131,7 @@ EditorAbout::EditorAbout() {
String hash = String(VERSION_HASH);
if (hash.length() != 0)
- hash = "." + hash.left(7);
+ hash = "." + hash.left(9);
Label *about_text = memnew(Label);
about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index b0baf954d2..7b521aba13 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1971,7 +1971,7 @@ ProjectManager::ProjectManager() {
l = memnew(Label);
String hash = String(VERSION_HASH);
if (hash.length() != 0)
- hash = "." + hash.left(7);
+ hash = "." + hash.left(9);
l->set_text("v" VERSION_FULL_BUILD "" + hash);
l->set_align(Label::ALIGN_CENTER);
top_hb->add_child(l);
diff --git a/main/main.cpp b/main/main.cpp
index 8c742c0f93..a01d1abe43 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -161,7 +161,7 @@ static String unescape_cmdline(const String &p_str) {
static String get_full_version_string() {
String hash = String(VERSION_HASH);
if (hash.length() != 0)
- hash = "." + hash.left(7);
+ hash = "." + hash.left(9);
return String(VERSION_FULL_BUILD) + hash;
}
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index f7be0ce37c..189317b163 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -1977,12 +1977,12 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
for (int i = 0; i < p_class->subclasses.size(); i++) {
StringName name = p_class->subclasses[i]->name;
-
- GDScript *subclass = p_script->subclasses[name].ptr();
+ Ref<GDScript> &subclass = p_script->subclasses[name];
+ GDScript *subclass_ptr = subclass.ptr();
// Subclass might still be parsing, just skip it
- if (!parsed_classes.has(subclass) && !parsing_classes.has(subclass)) {
- Error err = _parse_class_level(subclass, p_class->subclasses[i], p_keep_state);
+ if (!parsed_classes.has(subclass_ptr) && !parsing_classes.has(subclass_ptr)) {
+ Error err = _parse_class_level(subclass_ptr, p_class->subclasses[i], p_keep_state);
if (err)
return err;
}
diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp
index bed6f8a816..8bccf117fd 100644
--- a/scene/2d/position_2d.cpp
+++ b/scene/2d/position_2d.cpp
@@ -35,13 +35,15 @@
void Position2D::_draw_cross() {
- draw_line(Point2(-10, 0), Point2(+10, 0), Color(1, 0.5, 0.5));
- draw_line(Point2(0, -10), Point2(0, +10), Color(0.5, 1, 0.5));
+ float extents = get_gizmo_extents();
+ draw_line(Point2(-extents, 0), Point2(+extents, 0), Color(1, 0.5, 0.5));
+ draw_line(Point2(0, -extents), Point2(0, +extents), Color(0.5, 1, 0.5));
}
Rect2 Position2D::_edit_get_rect() const {
- return Rect2(Point2(-10, -10), Size2(20, 20));
+ float extents = get_gizmo_extents();
+ return Rect2(Point2(-extents, -extents), Size2(extents * 2, extents * 2));
}
bool Position2D::_edit_use_rect() const {
@@ -66,5 +68,31 @@ void Position2D::_notification(int p_what) {
}
}
+void Position2D::set_gizmo_extents(float p_extents) {
+ if (p_extents == DEFAULT_GIZMO_EXTENTS) {
+ set_meta("_gizmo_extents_", Variant());
+ } else {
+ set_meta("_gizmo_extents_", p_extents);
+ }
+
+ update();
+}
+
+float Position2D::get_gizmo_extents() const {
+ if (has_meta("_gizmo_extents_")) {
+ return get_meta("_gizmo_extents_");
+ } else {
+ return DEFAULT_GIZMO_EXTENTS;
+ }
+}
+
+void Position2D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("_set_gizmo_extents", "extents"), &Position2D::set_gizmo_extents);
+ ClassDB::bind_method(D_METHOD("_get_gizmo_extents"), &Position2D::get_gizmo_extents);
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "gizmo_extents", PROPERTY_HINT_RANGE, "0,1000,0.1,or_greater", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_gizmo_extents", "_get_gizmo_extents");
+}
+
Position2D::Position2D() {
}
diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h
index c95315fea3..dc9cc2df15 100644
--- a/scene/2d/position_2d.h
+++ b/scene/2d/position_2d.h
@@ -37,14 +37,21 @@ class Position2D : public Node2D {
GDCLASS(Position2D, Node2D)
+ const float DEFAULT_GIZMO_EXTENTS = 10.0;
+
void _draw_cross();
protected:
void _notification(int p_what);
+ static void _bind_methods();
public:
virtual Rect2 _edit_get_rect() const;
virtual bool _edit_use_rect() const;
+
+ void set_gizmo_extents(float p_extents);
+ float get_gizmo_extents() const;
+
Position2D();
};