diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index ccf9463ebd5..58cc49009c6 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -311,9 +311,7 @@ void EditorDebuggerNode::stop(bool p_force) { // Also close all debugging sessions. _for_all(tabs, [&](ScriptEditorDebugger *dbg) { - if (dbg->is_session_active()) { - dbg->_stop_and_notify(); - } + dbg->_stop_and_notify(); }); _break_state_changed(); breakpoints.clear(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index e7b74b79e1d..2b74e84d270 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2136,7 +2136,7 @@ void EditorNode::try_autosave() { Node *scene = editor_data.get_edited_scene_root(); if (scene && !scene->get_scene_file_path().is_empty()) { // Only autosave if there is a scene and if it has a path. - _save_scene(scene->get_scene_file_path()); + _save_scene(scene->get_scene_file_path(), -1, false); } } _menu_option(SCENE_SAVE_ALL_SCENES); diff --git a/platform/android/SCsub b/platform/android/SCsub index 5eccdd19295..bbe2c1b6791 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -32,7 +32,8 @@ android_files = [ "rendering_context_driver_vulkan_android.cpp", "variant/callable_jni.cpp", "dialog_utils_jni.cpp", - "game_menu_utils_jni.cpp", + "editor/game_menu_utils_jni.cpp", + "editor/editor_utils_jni.cpp", ] env_android = env.Clone() diff --git a/platform/android/editor/editor_utils_jni.cpp b/platform/android/editor/editor_utils_jni.cpp new file mode 100644 index 00000000000..0167dceb31a --- /dev/null +++ b/platform/android/editor/editor_utils_jni.cpp @@ -0,0 +1,82 @@ +/**************************************************************************/ +/* editor_utils_jni.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 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. */ +/**************************************************************************/ + +#include "editor_utils_jni.h" + +#include "jni_utils.h" + +#ifdef TOOLS_ENABLED +#include "editor/gui/editor_run_bar.h" +#include "main/main.h" +#endif + +extern "C" { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_EditorUtils_runScene(JNIEnv *p_env, jclass, jstring p_scene, jobjectArray p_scene_args) { +#ifdef TOOLS_ENABLED + Vector scene_args; + jint length = p_env->GetArrayLength(p_scene_args); + for (jint i = 0; i < length; ++i) { + jstring j_arg = (jstring)p_env->GetObjectArrayElement(p_scene_args, i); + String arg = jstring_to_string(j_arg, p_env); + scene_args.push_back(arg); + p_env->DeleteLocalRef(j_arg); + } + + String scene = jstring_to_string(p_scene, p_env); + + EditorRunBar *editor_run_bar = EditorRunBar::get_singleton(); + if (editor_run_bar != nullptr) { + if (scene.is_empty()) { + editor_run_bar->play_main_scene(false); + } else { + editor_run_bar->play_custom_scene(scene, scene_args); + } + } else { + List args; + + for (const String &a : Main::get_forwardable_cli_arguments(Main::CLI_SCOPE_PROJECT)) { + args.push_back(a); + } + + for (const String &arg : scene_args) { + args.push_back(arg); + } + + if (!scene.is_empty()) { + args.push_back("--scene"); + args.push_back(scene); + } + + Error err = OS::get_singleton()->create_instance(args); + ERR_FAIL_COND(err); + } +#endif +} +} diff --git a/platform/android/editor/editor_utils_jni.h b/platform/android/editor/editor_utils_jni.h new file mode 100644 index 00000000000..68d269617c1 --- /dev/null +++ b/platform/android/editor/editor_utils_jni.h @@ -0,0 +1,37 @@ +/**************************************************************************/ +/* editor_utils_jni.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 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. */ +/**************************************************************************/ + +#pragma once + +#include + +extern "C" { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_EditorUtils_runScene(JNIEnv *p_env, jclass, jstring p_scene, jobjectArray p_scene_args); +} diff --git a/platform/android/game_menu_utils_jni.cpp b/platform/android/editor/game_menu_utils_jni.cpp similarity index 78% rename from platform/android/game_menu_utils_jni.cpp rename to platform/android/editor/game_menu_utils_jni.cpp index e56ad3d5f8e..852894f5297 100644 --- a/platform/android/game_menu_utils_jni.cpp +++ b/platform/android/editor/game_menu_utils_jni.cpp @@ -45,7 +45,7 @@ static GameViewPlugin *_get_game_view_plugin() { extern "C" { -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSuspend(JNIEnv *env, jclass clazz, jboolean enabled) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSuspend(JNIEnv *env, jclass clazz, jboolean enabled) { #ifdef TOOLS_ENABLED GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) { @@ -54,7 +54,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSuspend #endif } -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_nextFrame(JNIEnv *env, jclass clazz) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_nextFrame(JNIEnv *env, jclass clazz) { #ifdef TOOLS_ENABLED GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) { @@ -63,7 +63,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_nextFrame( #endif } -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setNodeType(JNIEnv *env, jclass clazz, jint type) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setNodeType(JNIEnv *env, jclass clazz, jint type) { #ifdef TOOLS_ENABLED GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) { @@ -72,7 +72,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setNodeTyp #endif } -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSelectMode(JNIEnv *env, jclass clazz, jint mode) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSelectMode(JNIEnv *env, jclass clazz, jint mode) { #ifdef TOOLS_ENABLED GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) { @@ -81,7 +81,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSelectM #endif } -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSelectionVisible(JNIEnv *env, jclass clazz, jboolean visible) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSelectionVisible(JNIEnv *env, jclass clazz, jboolean visible) { #ifdef TOOLS_ENABLED GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) { @@ -90,7 +90,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSelecti #endif } -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setCameraOverride(JNIEnv *env, jclass clazz, jboolean enabled) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setCameraOverride(JNIEnv *env, jclass clazz, jboolean enabled) { #ifdef TOOLS_ENABLED GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) { @@ -99,7 +99,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setCameraO #endif } -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setCameraManipulateMode(JNIEnv *env, jclass clazz, jint mode) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setCameraManipulateMode(JNIEnv *env, jclass clazz, jint mode) { #ifdef TOOLS_ENABLED GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) { @@ -108,7 +108,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setCameraM #endif } -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_resetCamera2DPosition(JNIEnv *env, jclass clazz) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_resetCamera2DPosition(JNIEnv *env, jclass clazz) { #ifdef TOOLS_ENABLED GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) { @@ -117,7 +117,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_resetCamer #endif } -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_resetCamera3DPosition(JNIEnv *env, jclass clazz) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_resetCamera3DPosition(JNIEnv *env, jclass clazz) { #ifdef TOOLS_ENABLED GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) { @@ -126,7 +126,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_resetCamer #endif } -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_playMainScene(JNIEnv *env, jclass clazz) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_playMainScene(JNIEnv *env, jclass clazz) { #ifdef TOOLS_ENABLED if (EditorInterface::get_singleton()) { EditorInterface::get_singleton()->play_main_scene(); @@ -134,7 +134,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_playMainSc #endif } -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setDebugMuteAudio(JNIEnv *env, jclass clazz, jboolean enabled) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setDebugMuteAudio(JNIEnv *env, jclass clazz, jboolean enabled) { #ifdef TOOLS_ENABLED GameViewPlugin *game_view_plugin = _get_game_view_plugin(); if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) { diff --git a/platform/android/game_menu_utils_jni.h b/platform/android/editor/game_menu_utils_jni.h similarity index 61% rename from platform/android/game_menu_utils_jni.h rename to platform/android/editor/game_menu_utils_jni.h index d8412a084f2..2140672e60a 100644 --- a/platform/android/game_menu_utils_jni.h +++ b/platform/android/editor/game_menu_utils_jni.h @@ -33,15 +33,15 @@ #include extern "C" { -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSuspend(JNIEnv *env, jclass clazz, jboolean enabled); -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_nextFrame(JNIEnv *env, jclass clazz); -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setNodeType(JNIEnv *env, jclass clazz, jint type); -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSelectMode(JNIEnv *env, jclass clazz, jint mode); -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setSelectionVisible(JNIEnv *env, jclass clazz, jboolean visible); -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setCameraOverride(JNIEnv *env, jclass clazz, jboolean enabled); -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setCameraManipulateMode(JNIEnv *env, jclass clazz, jint mode); -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_resetCamera2DPosition(JNIEnv *env, jclass clazz); -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_resetCamera3DPosition(JNIEnv *env, jclass clazz); -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_playMainScene(JNIEnv *env, jclass clazz); -JNIEXPORT void JNICALL Java_org_godotengine_godot_utils_GameMenuUtils_setDebugMuteAudio(JNIEnv *env, jclass clazz, jboolean enabled); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSuspend(JNIEnv *env, jclass clazz, jboolean enabled); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_nextFrame(JNIEnv *env, jclass clazz); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setNodeType(JNIEnv *env, jclass clazz, jint type); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSelectMode(JNIEnv *env, jclass clazz, jint mode); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSelectionVisible(JNIEnv *env, jclass clazz, jboolean visible); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setCameraOverride(JNIEnv *env, jclass clazz, jboolean enabled); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setCameraManipulateMode(JNIEnv *env, jclass clazz, jint mode); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_resetCamera2DPosition(JNIEnv *env, jclass clazz); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_resetCamera3DPosition(JNIEnv *env, jclass clazz); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_playMainScene(JNIEnv *env, jclass clazz); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setDebugMuteAudio(JNIEnv *env, jclass clazz, jboolean enabled); } diff --git a/platform/android/java/editor/build.gradle b/platform/android/java/editor/build.gradle index 2c2a213e546..82c6ad02e59 100644 --- a/platform/android/java/editor/build.gradle +++ b/platform/android/java/editor/build.gradle @@ -180,6 +180,8 @@ android { } dependencies { + implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"]) + implementation "androidx.fragment:fragment:$versions.fragmentVersion" implementation project(":lib") diff --git a/platform/android/java/editor/src/main/AndroidManifest.xml b/platform/android/java/editor/src/main/AndroidManifest.xml index 72dab3f7082..9508789f67e 100644 --- a/platform/android/java/editor/src/main/AndroidManifest.xml +++ b/platform/android/java/editor/src/main/AndroidManifest.xml @@ -60,6 +60,22 @@ + + + + + + + + + + + + + + - + android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />