diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/input_default.cpp | 36 | ||||
-rw-r--r-- | main/input_default.h | 5 | ||||
-rw-r--r-- | main/main.cpp | 4 | ||||
-rw-r--r-- | main/performance.cpp | 25 | ||||
-rw-r--r-- | main/performance.h | 3 | ||||
-rw-r--r-- | main/tests/test_gdscript.cpp | 28 | ||||
-rw-r--r-- | main/tests/test_string.cpp | 14 |
7 files changed, 81 insertions, 34 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp index e9f1eeff6a..a939d77a1e 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -623,7 +623,8 @@ bool InputDefault::is_emulating_mouse_from_touch() const { return emulate_mouse_from_touch; } -Input::CursorShape InputDefault::get_default_cursor_shape() { +Input::CursorShape InputDefault::get_default_cursor_shape() const { + return default_shape; } @@ -638,6 +639,11 @@ void InputDefault::set_default_cursor_shape(CursorShape p_shape) { parse_input_event(mm); } +Input::CursorShape InputDefault::get_current_cursor_shape() const { + + return (Input::CursorShape)OS::get_singleton()->get_cursor_shape(); +} + void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { if (Engine::get_singleton()->is_editor_hint()) return; @@ -645,21 +651,6 @@ void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_sh OS::get_singleton()->set_custom_mouse_cursor(p_cursor, (OS::CursorShape)p_shape, p_hotspot); } -void InputDefault::set_mouse_in_window(bool p_in_window) { - /* no longer supported, leaving this for reference to anyone who might want to implement hardware cursors - if (custom_cursor.is_valid()) { - - if (p_in_window) { - set_mouse_mode(MOUSE_MODE_HIDDEN); - VisualServer::get_singleton()->cursor_set_visible(true); - } else { - set_mouse_mode(MOUSE_MODE_VISIBLE); - VisualServer::get_singleton()->cursor_set_visible(false); - } - } - */ -} - void InputDefault::accumulate_input_event(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); @@ -686,6 +677,19 @@ void InputDefault::set_use_accumulated_input(bool p_enable) { use_accumulated_input = p_enable; } +void InputDefault::release_pressed_events() { + + flush_accumulated_events(); // this is needed to release actions strengths + + keys_pressed.clear(); + joy_buttons_pressed.clear(); + _joy_axis.clear(); + + for (Map<StringName, InputDefault::Action>::Element *E = action_state.front(); E; E = E->next()) { + action_release(E->key()); + } +} + InputDefault::InputDefault() { use_accumulated_input = true; diff --git a/main/input_default.h b/main/input_default.h index 79a90cc4a4..80ee17656c 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -242,10 +242,10 @@ public: void set_emulate_mouse_from_touch(bool p_emulate); virtual bool is_emulating_mouse_from_touch() const; - virtual CursorShape get_default_cursor_shape(); + virtual CursorShape get_default_cursor_shape() const; virtual void set_default_cursor_shape(CursorShape p_shape); + virtual CursorShape get_current_cursor_shape() const; virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = Input::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()); - virtual void set_mouse_in_window(bool p_in_window); void parse_mapping(String p_mapping); void joy_button(int p_device, int p_button, bool p_pressed); @@ -272,6 +272,7 @@ public: virtual void flush_accumulated_events(); virtual void set_use_accumulated_input(bool p_enable); + virtual void release_pressed_events(); InputDefault(); }; diff --git a/main/main.cpp b/main/main.cpp index 0871b12338..fc9ec3b2d9 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1882,7 +1882,9 @@ bool Main::iteration() { uint64_t idle_begin = OS::get_singleton()->get_ticks_usec(); - OS::get_singleton()->get_main_loop()->idle(step * time_scale); + if (OS::get_singleton()->get_main_loop()->idle(step * time_scale)) { + exit = true; + } message_queue->flush(); VisualServer::get_singleton()->sync(); //sync if still drawing from previous frames. diff --git a/main/performance.cpp b/main/performance.cpp index 49a08aa8d1..71cd94aeab 100644 --- a/main/performance.cpp +++ b/main/performance.cpp @@ -32,6 +32,7 @@ #include "core/message_queue.h" #include "core/os/os.h" +#include "scene/main/node.h" #include "scene/main/scene_tree.h" #include "servers/audio_server.h" #include "servers/physics_2d_server.h" @@ -55,6 +56,7 @@ void Performance::_bind_methods() { BIND_ENUM_CONSTANT(OBJECT_COUNT); BIND_ENUM_CONSTANT(OBJECT_RESOURCE_COUNT); BIND_ENUM_CONSTANT(OBJECT_NODE_COUNT); + BIND_ENUM_CONSTANT(OBJECT_ORPHAN_NODE_COUNT); BIND_ENUM_CONSTANT(RENDER_OBJECTS_IN_FRAME); BIND_ENUM_CONSTANT(RENDER_VERTICES_IN_FRAME); BIND_ENUM_CONSTANT(RENDER_MATERIAL_CHANGES_IN_FRAME); @@ -76,6 +78,14 @@ void Performance::_bind_methods() { BIND_ENUM_CONSTANT(MONITOR_MAX); } +float Performance::_get_node_count() const { + MainLoop *ml = OS::get_singleton()->get_main_loop(); + SceneTree *sml = Object::cast_to<SceneTree>(ml); + if (!sml) + return 0; + return sml->get_node_count(); +} + String Performance::get_monitor_name(Monitor p_monitor) const { ERR_FAIL_INDEX_V(p_monitor, MONITOR_MAX, String()); @@ -92,6 +102,7 @@ String Performance::get_monitor_name(Monitor p_monitor) const { "object/objects", "object/resources", "object/nodes", + "object/orphan_nodes", "raster/objects_drawn", "raster/vertices_drawn", "raster/mat_changes", @@ -128,14 +139,8 @@ float Performance::get_monitor(Monitor p_monitor) const { case MEMORY_MESSAGE_BUFFER_MAX: return MessageQueue::get_singleton()->get_max_buffer_usage(); case OBJECT_COUNT: return ObjectDB::get_object_count(); case OBJECT_RESOURCE_COUNT: return ResourceCache::get_cached_resource_count(); - case OBJECT_NODE_COUNT: { - - MainLoop *ml = OS::get_singleton()->get_main_loop(); - SceneTree *sml = Object::cast_to<SceneTree>(ml); - if (!sml) - return 0; - return sml->get_node_count(); - }; + case OBJECT_NODE_COUNT: return _get_node_count(); + case OBJECT_ORPHAN_NODE_COUNT: return Node::orphan_node_count; case RENDER_OBJECTS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_OBJECTS_IN_FRAME); case RENDER_VERTICES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_VERTICES_IN_FRAME); case RENDER_MATERIAL_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME); @@ -154,7 +159,8 @@ float Performance::get_monitor(Monitor p_monitor) const { case PHYSICS_3D_ISLAND_COUNT: return PhysicsServer::get_singleton()->get_process_info(PhysicsServer::INFO_ISLAND_COUNT); case AUDIO_OUTPUT_LATENCY: return AudioServer::get_singleton()->get_output_latency(); - default: {} + default: { + } } return 0; @@ -182,6 +188,7 @@ Performance::MonitorType Performance::get_monitor_type(Monitor p_monitor) const MONITOR_TYPE_QUANTITY, MONITOR_TYPE_QUANTITY, MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, MONITOR_TYPE_MEMORY, MONITOR_TYPE_MEMORY, MONITOR_TYPE_MEMORY, diff --git a/main/performance.h b/main/performance.h index 850c4c2d52..912e005c53 100644 --- a/main/performance.h +++ b/main/performance.h @@ -43,6 +43,8 @@ class Performance : public Object { static Performance *singleton; static void _bind_methods(); + float _get_node_count() const; + float _process_time; float _physics_process_time; @@ -60,6 +62,7 @@ public: OBJECT_COUNT, OBJECT_RESOURCE_COUNT, OBJECT_NODE_COUNT, + OBJECT_ORPHAN_NODE_COUNT, RENDER_OBJECTS_IN_FRAME, RENDER_VERTICES_IN_FRAME, RENDER_MATERIAL_CHANGES_IN_FRAME, diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index 27180f84aa..87bd640001 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -127,6 +127,7 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { case GDScriptParser::OperatorNode::OP_PARENT_CALL: txt += "."; + FALLTHROUGH; case GDScriptParser::OperatorNode::OP_CALL: { ERR_FAIL_COND_V(c_node->arguments.size() < 1, ""); @@ -283,10 +284,16 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { case GDScriptParser::OperatorNode::OP_BIT_XOR: { txt = _parser_expr(c_node->arguments[0]) + "^" + _parser_expr(c_node->arguments[1]); } break; - default: {} + default: { + } } } break; + case GDScriptParser::Node::TYPE_CAST: { + const GDScriptParser::CastNode *cast_node = static_cast<const GDScriptParser::CastNode *>(p_expr); + txt = _parser_expr(cast_node->source_node) + " as " + cast_node->cast_type.to_string(); + + } break; case GDScriptParser::Node::TYPE_NEWLINE: { //skippie @@ -667,6 +674,17 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 2; } break; + case GDScriptFunction::OPCODE_CAST_TO_SCRIPT: { + + txt += " cast "; + txt += DADDR(3); + txt += "="; + txt += DADDR(1); + txt += " as "; + txt += DADDR(2); + incr += 4; + + } break; case GDScriptFunction::OPCODE_CONSTRUCT: { Variant::Type t = Variant::Type(code[ip + 1]); @@ -1016,19 +1034,17 @@ MainLoop *test(TestType p_type) { return NULL; } - GDScript *script = memnew(GDScript); + Ref<GDScript> gds; + gds.instance(); GDScriptCompiler gdc; - err = gdc.compile(&parser, script); + err = gdc.compile(&parser, gds.ptr()); if (err) { print_line("Compile Error:\n" + itos(gdc.get_error_line()) + ":" + itos(gdc.get_error_column()) + ":" + gdc.get_error()); - memdelete(script); return NULL; } - Ref<GDScript> gds = Ref<GDScript>(script); - Ref<GDScript> current = gds; while (current.is_valid()) { diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp index 3465fd783e..dcbb930d1b 100644 --- a/main/tests/test_string.cpp +++ b/main/tests/test_string.cpp @@ -1053,6 +1053,19 @@ bool test_33() { return empty.parse_utf8(NULL, -1) == true; } +bool test_34() { + OS::get_singleton()->print("\n\nTest 34: Cyrillic to_lower()\n"); + + String upper = L"АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"; + String lower = L"абвгдеёжзийклмнопрстуфхцчшщъыьэюя"; + + String test = upper.to_lower(); + + bool state = test == lower; + + return state; +} + typedef bool (*TestFunc)(void); TestFunc test_funcs[] = { @@ -1090,6 +1103,7 @@ TestFunc test_funcs[] = { test_31, test_32, test_33, + test_34, 0 }; |