diff options
-rw-r--r-- | core/global_constants.cpp | 150 | ||||
-rw-r--r-- | core/os/input_event.h | 4 | ||||
-rw-r--r-- | doc/classes/BaseButton.xml | 11 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 45 | ||||
-rw-r--r-- | editor/script_editor_debugger.cpp | 63 | ||||
-rw-r--r-- | editor/script_editor_debugger.h | 2 | ||||
-rw-r--r-- | main/performance.cpp | 38 | ||||
-rw-r--r-- | main/performance.h | 8 | ||||
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 6 | ||||
-rw-r--r-- | modules/mono/csharp_script.cpp | 9 | ||||
-rw-r--r-- | platform/osx/os_osx.h | 3 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 17 | ||||
-rw-r--r-- | scene/3d/SCsub | 3 | ||||
-rw-r--r-- | scene/register_scene_types.cpp | 9 |
14 files changed, 256 insertions, 112 deletions
diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 6f58af2ccf..8bddeae69a 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -86,6 +86,8 @@ static Vector<_GlobalConstant> _global_constants; VARIANT_ENUM_CAST(KeyList); VARIANT_ENUM_CAST(KeyModifierMask); +VARIANT_ENUM_CAST(ButtonList); +VARIANT_ENUM_CAST(JoystickList); void register_global_constants() { @@ -367,82 +369,82 @@ void register_global_constants() { BIND_GLOBAL_ENUM_CONSTANT(KEY_MASK_GROUP_SWITCH); // mouse - BIND_GLOBAL_CONSTANT(BUTTON_LEFT); - BIND_GLOBAL_CONSTANT(BUTTON_RIGHT); - BIND_GLOBAL_CONSTANT(BUTTON_MIDDLE); - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_UP); - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_DOWN); - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_LEFT); - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_RIGHT); - BIND_GLOBAL_CONSTANT(BUTTON_MASK_LEFT); - BIND_GLOBAL_CONSTANT(BUTTON_MASK_RIGHT); - BIND_GLOBAL_CONSTANT(BUTTON_MASK_MIDDLE); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_LEFT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_RIGHT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MIDDLE); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_UP); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_DOWN); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_LEFT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_RIGHT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_LEFT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_RIGHT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_MIDDLE); //joypads - BIND_GLOBAL_CONSTANT(JOY_BUTTON_0); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_1); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_2); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_3); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_4); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_5); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_6); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_7); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_8); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_9); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_10); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_11); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_12); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_13); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_14); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_15); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_MAX); - - BIND_GLOBAL_CONSTANT(JOY_SONY_CIRCLE); - BIND_GLOBAL_CONSTANT(JOY_SONY_X); - BIND_GLOBAL_CONSTANT(JOY_SONY_SQUARE); - BIND_GLOBAL_CONSTANT(JOY_SONY_TRIANGLE); - - BIND_GLOBAL_CONSTANT(JOY_XBOX_B); - BIND_GLOBAL_CONSTANT(JOY_XBOX_A); - BIND_GLOBAL_CONSTANT(JOY_XBOX_X); - BIND_GLOBAL_CONSTANT(JOY_XBOX_Y); - - BIND_GLOBAL_CONSTANT(JOY_DS_A); - BIND_GLOBAL_CONSTANT(JOY_DS_B); - BIND_GLOBAL_CONSTANT(JOY_DS_X); - BIND_GLOBAL_CONSTANT(JOY_DS_Y); - - BIND_GLOBAL_CONSTANT(JOY_SELECT); - BIND_GLOBAL_CONSTANT(JOY_START); - BIND_GLOBAL_CONSTANT(JOY_DPAD_UP); - BIND_GLOBAL_CONSTANT(JOY_DPAD_DOWN); - BIND_GLOBAL_CONSTANT(JOY_DPAD_LEFT); - BIND_GLOBAL_CONSTANT(JOY_DPAD_RIGHT); - BIND_GLOBAL_CONSTANT(JOY_L); - BIND_GLOBAL_CONSTANT(JOY_L2); - BIND_GLOBAL_CONSTANT(JOY_L3); - BIND_GLOBAL_CONSTANT(JOY_R); - BIND_GLOBAL_CONSTANT(JOY_R2); - BIND_GLOBAL_CONSTANT(JOY_R3); - - BIND_GLOBAL_CONSTANT(JOY_AXIS_0); - BIND_GLOBAL_CONSTANT(JOY_AXIS_1); - BIND_GLOBAL_CONSTANT(JOY_AXIS_2); - BIND_GLOBAL_CONSTANT(JOY_AXIS_3); - BIND_GLOBAL_CONSTANT(JOY_AXIS_4); - BIND_GLOBAL_CONSTANT(JOY_AXIS_5); - BIND_GLOBAL_CONSTANT(JOY_AXIS_6); - BIND_GLOBAL_CONSTANT(JOY_AXIS_7); - BIND_GLOBAL_CONSTANT(JOY_AXIS_MAX); - - BIND_GLOBAL_CONSTANT(JOY_ANALOG_LX); - BIND_GLOBAL_CONSTANT(JOY_ANALOG_LY); - - BIND_GLOBAL_CONSTANT(JOY_ANALOG_RX); - BIND_GLOBAL_CONSTANT(JOY_ANALOG_RY); - - BIND_GLOBAL_CONSTANT(JOY_ANALOG_L2); - BIND_GLOBAL_CONSTANT(JOY_ANALOG_R2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_0); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_1); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_3); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_4); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_5); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_6); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_7); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_8); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_9); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_10); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_11); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_12); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_13); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_14); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_15); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_MAX); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_CIRCLE); + BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_X); + BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_SQUARE); + BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_TRIANGLE); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_B); + BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_A); + BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_X); + BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_Y); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_A); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_B); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_X); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_Y); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_SELECT); + BIND_GLOBAL_ENUM_CONSTANT(JOY_START); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_UP); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_DOWN); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_LEFT); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_RIGHT); + BIND_GLOBAL_ENUM_CONSTANT(JOY_L); + BIND_GLOBAL_ENUM_CONSTANT(JOY_L2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_L3); + BIND_GLOBAL_ENUM_CONSTANT(JOY_R); + BIND_GLOBAL_ENUM_CONSTANT(JOY_R2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_R3); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_0); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_1); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_3); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_4); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_5); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_6); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_7); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_MAX); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_LX); + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_LY); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_RX); + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_RY); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_L2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_R2); // error list diff --git a/core/os/input_event.h b/core/os/input_event.h index 5dc0f91d5f..f2c8cc802d 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -44,7 +44,7 @@ * The events are pretty obvious. */ -enum { +enum ButtonList { BUTTON_LEFT = 1, BUTTON_RIGHT = 2, BUTTON_MIDDLE = 3, @@ -58,7 +58,7 @@ enum { }; -enum { +enum JoystickList { JOY_BUTTON_0 = 0, JOY_BUTTON_1 = 1, diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml index 2ad46579b2..1b6583a834 100644 --- a/doc/classes/BaseButton.xml +++ b/doc/classes/BaseButton.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="BaseButton" inherits="Control" category="Core" version="3.0.alpha.custom_build"> <brief_description> - Provides a base class for different kinds of buttons. + Base class for different kinds of buttons. </brief_description> <description> - BaseButton is the abstract base class for buttons, so it shouldn't be used directly (It doesn't display anything). Other types of buttons inherit from it. + BaseButton is the abstract base class for buttons, so it shouldn't be used directly (it doesn't display anything). Other types of buttons inherit from it. </description> <tutorials> </tutorials> @@ -152,18 +152,25 @@ </methods> <members> <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" enum="BaseButton.ActionMode"> + Determines when the button is considered clicked, one of the ACTION_MODE_* constants. </member> <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled"> + If [code]true[/code] the button is in disabled state and can't be clicked or toggled. </member> <member name="enabled_focus_mode" type="int" setter="set_enabled_focus_mode" getter="get_enabled_focus_mode" enum="Control.FocusMode"> + Focus access mode to use when switching between enabled/disabled (see [method Control.set_focus_mode] and [member disabled]). </member> <member name="group" type="ButtonGroup" setter="set_button_group" getter="get_button_group"> + [ButtonGroup] associated to the button. </member> <member name="pressed" type="bool" setter="set_pressed" getter="is_pressed"> + If [code]true[/code] the button's state is pressed. Means the button is pressed down or toggled (if toggle_mode is active). </member> <member name="shortcut" type="ShortCut" setter="set_shortcut" getter="get_shortcut"> + [Shortcut] associated to the button. </member> <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode"> + If [code]true[/code] the button is in toggle mode. Makes the button flip state between pressed and unpressed each time its area is clicked. </member> </members> <signals> diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index d12b3f1e0e..9235dafaa6 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -945,6 +945,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (mm.is_valid()) { Point2i new_over_tile = node->world_to_map(xform_inv.xform(mm->get_position())); + Point2i old_over_tile = over_tile; if (new_over_tile != over_tile) { @@ -963,17 +964,43 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (tool == TOOL_PAINTING) { + // Paint using bresenham line to prevent holes in painting if the user moves fast + + Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y); int id = get_selected_tile(); - if (id != TileMap::INVALID_CELL) { + + for (int i = 0; i < points.size(); ++i) { + + Point2i pos = points[i]; if (!paint_undo.has(over_tile)) { - paint_undo[over_tile] = _get_op_from_cell(over_tile); + paint_undo[pos] = _get_op_from_cell(pos); } - _set_cell(over_tile, id, flip_h, flip_v, transpose); + _set_cell(pos, id, flip_h, flip_v, transpose); + } - return true; + return true; + } + + if (tool == TOOL_ERASING) { + + // erase using bresenham line to prevent holes in painting if the user moves fast + + Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y); + + for (int i = 0; i < points.size(); ++i) { + + Point2i pos = points[i]; + + if (!paint_undo.has(over_tile)) { + paint_undo[pos] = _get_op_from_cell(pos); + } + + _set_cell(pos, TileMap::INVALID_CELL); } + + return true; } if (tool == TOOL_SELECTING) { @@ -1044,16 +1071,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } - if (tool == TOOL_ERASING) { - - if (!paint_undo.has(over_tile)) { - paint_undo[over_tile] = _get_op_from_cell(over_tile); - } - - _set_cell(over_tile, TileMap::INVALID_CELL); - - return true; - } if (tool == TOOL_PICKING && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) { _pick_tile(over_tile); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index ef61aad341..bc2423fffd 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -574,7 +574,38 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da for (int i = 0; i < arr.size(); i++) { p[i] = arr[i]; if (i < perf_items.size()) { - perf_items[i]->set_text(1, rtos(p[i])); + + float v = p[i]; + String vs = rtos(v); + String tt = vs; + switch (Performance::MonitorType((int)perf_items[i]->get_metadata(1))) { + case Performance::MONITOR_TYPE_MEMORY: { + // for the time being, going above GBs is a bad sign. + String unit = "B"; + if ((int)v > 1073741824) { + unit = "GB"; + v /= 1073741824.0; + } else if ((int)v > 1048576) { + unit = "MB"; + v /= 1048576.0; + } else if ((int)v > 1024) { + unit = "KB"; + v /= 1024.0; + } + tt += " bytes"; + vs = rtos(v) + " " + unit; + } break; + case Performance::MONITOR_TYPE_TIME: { + tt += " seconds"; + vs += " s"; + } break; + default: { + tt += " " + perf_items[i]->get_text(0); + } break; + } + + perf_items[i]->set_text(1, vs); + perf_items[i]->set_tooltip(1, tt); if (p[i] > perf_max[i]) perf_max[i] = p[i]; } @@ -775,7 +806,7 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType reason->set_tooltip(p_reason); } -void ScriptEditorDebugger::_performance_select(Object *, int, bool) { +void ScriptEditorDebugger::_performance_select() { perf_draw->update(); } @@ -785,7 +816,7 @@ void ScriptEditorDebugger::_performance_draw() { Vector<int> which; for (int i = 0; i < perf_items.size(); i++) { - if (perf_items[i]->is_selected(0)) + if (perf_items[i]->is_checked(0)) which.push_back(i); } @@ -816,14 +847,14 @@ void ScriptEditorDebugger::_performance_draw() { r.position += graph_sb->get_offset(); r.size -= graph_sb->get_minimum_size(); int pi = which[i]; - Color c = get_color("success_color", "Editor"); - c.set_hsv(Math::fmod(c.get_h() + pi * 0.7654, 1), c.get_s(), c.get_v()); - //c = c.linear_interpolate(get_color("base_color", "Editor"), 0.9); + Color c = get_color("accent_color", "Editor"); + float h = (float)which[i] / (float)(perf_items.size()); + c.set_hsv(Math::fmod(h + 0.4, 0.9), c.get_s() * 0.9, c.get_v() * 1.4); - c.a = 0.8; - perf_draw->draw_string(graph_font, r.position + Point2(0, graph_font->get_ascent()), perf_items[pi]->get_text(0), c, r.size.x); c.a = 0.6; - perf_draw->draw_string(graph_font, r.position + Point2(graph_font->get_char_size('X').width, graph_font->get_ascent() + graph_font->get_height()), perf_items[pi]->get_text(1), c, r.size.y); + perf_draw->draw_string(graph_font, r.position + Point2(0, graph_font->get_ascent()), perf_items[pi]->get_text(0), c, r.size.x); + c.a = 0.9; + perf_draw->draw_string(graph_font, r.position + Point2(0, graph_font->get_ascent() + graph_font->get_height()), perf_items[pi]->get_text(1), c, r.size.y); float spacing = point_sep / float(cols); float from = r.size.width; @@ -1785,13 +1816,12 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { perf_monitors->set_column_title(1, TTR("Value")); perf_monitors->set_column_titles_visible(true); hsp->add_child(perf_monitors); - perf_monitors->set_select_mode(Tree::SELECT_MULTI); - perf_monitors->connect("multi_selected", this, "_performance_select"); + perf_monitors->connect("item_edited", this, "_performance_select"); perf_draw = memnew(Control); perf_draw->connect("draw", this, "_performance_draw"); hsp->add_child(perf_draw); hsp->set_name(TTR("Monitors")); - hsp->set_split_offset(300); + hsp->set_split_offset(340 * EDSCALE); tabs->add_child(hsp); perf_max.resize(Performance::MONITOR_MAX); @@ -1801,6 +1831,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { for (int i = 0; i < Performance::MONITOR_MAX; i++) { String n = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)); + Performance::MonitorType mtype = Performance::get_singleton()->get_monitor_type(Performance::Monitor(i)); String base = n.get_slice("/", 0); String name = n.get_slice("/", 1); if (!bases.has(base)) { @@ -1808,12 +1839,16 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { b->set_text(0, base.capitalize()); b->set_editable(0, false); b->set_selectable(0, false); + b->set_expand_right(0, true); bases[base] = b; } TreeItem *it = perf_monitors->create_item(bases[base]); - it->set_editable(0, false); - it->set_selectable(0, true); + it->set_metadata(1, mtype); + it->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); + it->set_editable(0, true); + it->set_selectable(0, false); + it->set_selectable(1, false); it->set_text(0, name.capitalize()); perf_items.push_back(it); perf_max[i] = 0; diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index d0faab5892..d18a625eef 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -142,7 +142,7 @@ class ScriptEditorDebugger : public Control { bool live_debug; void _performance_draw(); - void _performance_select(Object *, int, bool); + void _performance_select(); void _stack_dump_frame_selected(); void _output_clear(); diff --git a/main/performance.cpp b/main/performance.cpp index c4b62559c7..39b42e803c 100644 --- a/main/performance.cpp +++ b/main/performance.cpp @@ -153,6 +153,44 @@ float Performance::get_monitor(Monitor p_monitor) const { return 0; } +Performance::MonitorType Performance::get_monitor_type(Monitor p_monitor) const { + ERR_FAIL_INDEX_V(p_monitor, MONITOR_MAX, MONITOR_TYPE_QUANTITY); + // ugly + static const MonitorType types[MONITOR_MAX] = { + + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_TIME, + MONITOR_TYPE_TIME, + MONITOR_TYPE_MEMORY, + MONITOR_TYPE_MEMORY, + MONITOR_TYPE_MEMORY, + MONITOR_TYPE_MEMORY, + MONITOR_TYPE_MEMORY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_MEMORY, + MONITOR_TYPE_MEMORY, + MONITOR_TYPE_MEMORY, + MONITOR_TYPE_MEMORY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + + }; + + return types[p_monitor]; +} + void Performance::set_process_time(float p_pt) { _process_time = p_pt; diff --git a/main/performance.h b/main/performance.h index 900e6434b7..21fbd7a1d2 100644 --- a/main/performance.h +++ b/main/performance.h @@ -79,9 +79,17 @@ public: MONITOR_MAX }; + enum MonitorType { + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_MEMORY, + MONITOR_TYPE_TIME + }; + float get_monitor(Monitor p_monitor) const; String get_monitor_name(Monitor p_monitor) const; + MonitorType get_monitor_type(Monitor p_monitor) const; + void set_process_time(float p_pt); void set_physics_process_time(float p_pt); diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index b0408917a4..9d37703357 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -61,7 +61,11 @@ Ref<Script> GDScriptLanguage::get_template(const String &p_class_name, const Str "func _ready():\n" + "%TS%# Called every time the node is added to the scene.\n" + "%TS%# Initialization here\n" + - "%TS%pass\n"; + "%TS%pass\n\n" + + "#func _process(delta):\n" + + "#%TS%# Called every frame. Delta is time since last frame.\n" + + "#%TS%# Update game logic here.\n" + + "#%TS%pass\n"; _template = _template.replace("%BASE%", p_base_class_name); _template = _template.replace("%TS%", _get_indentation()); diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index ba8c7df9cc..7143177c3f 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -277,7 +277,14 @@ Ref<Script> CSharpLanguage::get_template(const String &p_class_name, const Strin " // Initialization here\n" " \n" " }\n" - "}\n"; + "\n" + "// public override void _Process(float delta)\n" + "// {\n" + "// // Called every frame. Delta is time since last frame.\n" + "// // Update game logic here.\n" + "// \n" + "// }\n" + "//}\n"; script_template = script_template.replace("%BASE_CLASS_NAME%", p_base_class_name).replace("%CLASS_NAME%", p_class_name); diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 05adfeb0f5..420bb50af9 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -219,6 +219,9 @@ public: virtual bool _check_internal_feature_support(const String &p_feature); + virtual void set_use_vsync(bool p_enable); + virtual bool is_vsync_enabled() const; + void run(); void set_mouse_mode(MouseMode p_mode); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 2c81a02014..e1a01d2b59 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1954,6 +1954,23 @@ Error OS_OSX::move_to_trash(const String &p_path) { return OK; } +void OS_OSX::set_use_vsync(bool p_enable) { + CGLContextObj ctx = CGLGetCurrentContext(); + if (ctx) { + GLint swapInterval = p_enable ? 1 : 0; + CGLSetParameter(ctx, kCGLCPSwapInterval, &swapInterval); + } +} + +bool OS_OSX::is_vsync_enabled() const { + GLint swapInterval = 0; + CGLContextObj ctx = CGLGetCurrentContext(); + if (ctx) { + CGLGetParameter(ctx, kCGLCPSwapInterval, &swapInterval); + } + return swapInterval ? true : false; +} + OS_OSX *OS_OSX::singleton = NULL; OS_OSX::OS_OSX() { diff --git a/scene/3d/SCsub b/scene/3d/SCsub index 72739b527e..4008f4f196 100644 --- a/scene/3d/SCsub +++ b/scene/3d/SCsub @@ -7,6 +7,9 @@ if env['disable_3d']: env.scene_sources.append("3d/spatial.cpp") env.scene_sources.append("3d/skeleton.cpp") + env.scene_sources.append("3d/particles.cpp") + env.scene_sources.append("3d/visual_instance.cpp") + env.scene_sources.append("3d/scenario_fx.cpp") else: env.add_source_files(env.scene_sources, "*.cpp") diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 75268aad1f..3bdfe097c9 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -152,6 +152,10 @@ #include "scene/resources/world_2d.h" #include "scene/scene_string_names.h" +#include "scene/3d/particles.h" +#include "scene/3d/scenario_fx.h" +#include "scene/3d/spatial.h" + #ifndef _3D_DISABLED #include "scene/3d/area.h" #include "scene/3d/arvr_nodes.h" @@ -169,7 +173,6 @@ #include "scene/3d/multimesh_instance.h" #include "scene/3d/navigation.h" #include "scene/3d/navigation_mesh.h" -#include "scene/3d/particles.h" #include "scene/3d/path.h" #include "scene/3d/physics_body.h" #include "scene/3d/physics_joint.h" @@ -180,9 +183,7 @@ #include "scene/3d/reflection_probe.h" #include "scene/3d/remote_transform.h" #include "scene/3d/room_instance.h" -#include "scene/3d/scenario_fx.h" #include "scene/3d/skeleton.h" -#include "scene/3d/spatial.h" #include "scene/3d/sprite_3d.h" #include "scene/3d/vehicle_body.h" #include "scene/3d/visibility_notifier.h" @@ -551,7 +552,9 @@ void register_scene_types() { ClassDB::register_class<AudioStreamPlayer>(); ClassDB::register_class<AudioStreamPlayer2D>(); +#ifndef _3D_DISABLED ClassDB::register_class<AudioStreamPlayer3D>(); +#endif ClassDB::register_virtual_class<VideoStream>(); ClassDB::register_class<AudioStreamSample>(); |