diff --git a/platform/android/editor/game_menu_utils_jni.cpp b/platform/android/editor/game_menu_utils_jni.cpp index efdccc8b63..5599a39c43 100644 --- a/platform/android/editor/game_menu_utils_jni.cpp +++ b/platform/android/editor/game_menu_utils_jni.cpp @@ -90,6 +90,24 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_set #endif } +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSelectionAvoidLocked(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()) { + game_view_plugin->get_debugger()->set_selection_avoid_locked(enabled); + } +#endif +} + +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSelectionPreferGroup(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()) { + game_view_plugin->get_debugger()->set_selection_prefer_group(enabled); + } +#endif +} + 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(); diff --git a/platform/android/editor/game_menu_utils_jni.h b/platform/android/editor/game_menu_utils_jni.h index 61129365cd..456d43649b 100644 --- a/platform/android/editor/game_menu_utils_jni.h +++ b/platform/android/editor/game_menu_utils_jni.h @@ -38,6 +38,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_nex 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_setSelectionAvoidLocked(JNIEnv *env, jclass clazz, jboolean enabled); +JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSelectionPreferGroup(JNIEnv *env, jclass clazz, jboolean enabled); 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); diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt b/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt index fce031fe8e..199f4e51fc 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt @@ -147,6 +147,8 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe internal const val GAME_MENU_ACTION_SET_NODE_TYPE = "setNodeType" internal const val GAME_MENU_ACTION_SET_SELECT_MODE = "setSelectMode" internal const val GAME_MENU_ACTION_SET_SELECTION_VISIBLE = "setSelectionVisible" + internal const val GAME_MENU_ACTION_SET_SELECTION_AVOID_LOCKED = "setSelectionAvoidLocked" + internal const val GAME_MENU_ACTION_SET_SELECTION_PREFER_GROUP = "setSelectionPreferGroup" internal const val GAME_MENU_ACTION_SET_CAMERA_OVERRIDE = "setCameraOverride" internal const val GAME_MENU_ACTION_SET_CAMERA_MANIPULATE_MODE = "setCameraManipulateMode" internal const val GAME_MENU_ACTION_RESET_CAMERA_2D_POSITION = "resetCamera2DPosition" @@ -980,6 +982,14 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe val enabled = actionData.getBoolean(KEY_GAME_MENU_ACTION_PARAM1) toggleSelectionVisibility(enabled) } + GAME_MENU_ACTION_SET_SELECTION_AVOID_LOCKED -> { + val enabled = actionData.getBoolean(KEY_GAME_MENU_ACTION_PARAM1) + toggleSelectionAvoidLocked(enabled) + } + GAME_MENU_ACTION_SET_SELECTION_PREFER_GROUP -> { + val enabled = actionData.getBoolean(KEY_GAME_MENU_ACTION_PARAM1) + toggleSelectionPreferGroup(enabled) + } GAME_MENU_ACTION_SET_CAMERA_OVERRIDE -> { val enabled = actionData.getBoolean(KEY_GAME_MENU_ACTION_PARAM1) overrideCamera(enabled) @@ -1040,6 +1050,20 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe } } + override fun toggleSelectionAvoidLocked(enabled: Boolean) { + gameMenuState.putBoolean(GAME_MENU_ACTION_SET_SELECTION_AVOID_LOCKED, enabled) + godot?.runOnRenderThread { + GameMenuUtils.setSelectionAvoidLocked(enabled) + } + } + + override fun toggleSelectionPreferGroup(enabled: Boolean) { + gameMenuState.putBoolean(GAME_MENU_ACTION_SET_SELECTION_PREFER_GROUP, enabled) + godot?.runOnRenderThread { + GameMenuUtils.setSelectionPreferGroup(enabled) + } + } + override fun overrideCamera(enabled: Boolean) { gameMenuState.putBoolean(GAME_MENU_ACTION_SET_CAMERA_OVERRIDE, enabled) godot?.runOnRenderThread { diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt index 286d31f442..6a7d4b9059 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt @@ -130,6 +130,22 @@ open class GodotGame : BaseGodotGame() { editorMessageDispatcher.dispatchGameMenuAction(EDITOR_MAIN_INFO, actionBundle) } + override fun toggleSelectionAvoidLocked(enabled: Boolean) { + val actionBundle = Bundle().apply { + putString(KEY_GAME_MENU_ACTION, GAME_MENU_ACTION_SET_SELECTION_AVOID_LOCKED) + putBoolean(KEY_GAME_MENU_ACTION_PARAM1, enabled) + } + editorMessageDispatcher.dispatchGameMenuAction(EDITOR_MAIN_INFO, actionBundle) + } + + override fun toggleSelectionPreferGroup(enabled: Boolean) { + val actionBundle = Bundle().apply { + putString(KEY_GAME_MENU_ACTION, GAME_MENU_ACTION_SET_SELECTION_PREFER_GROUP) + putBoolean(KEY_GAME_MENU_ACTION_PARAM1, enabled) + } + editorMessageDispatcher.dispatchGameMenuAction(EDITOR_MAIN_INFO, actionBundle) + } + override fun overrideCamera(enabled: Boolean) { val actionBundle = Bundle().apply { putString(KEY_GAME_MENU_ACTION, GAME_MENU_ACTION_SET_CAMERA_OVERRIDE) diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/embed/GameMenuFragment.kt b/platform/android/java/editor/src/main/java/org/godotengine/editor/embed/GameMenuFragment.kt index f00619fb4c..6b2d0fe261 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/embed/GameMenuFragment.kt +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/embed/GameMenuFragment.kt @@ -40,6 +40,7 @@ import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.widget.Button +import android.widget.ImageButton import android.widget.PopupMenu import android.widget.RadioButton import androidx.core.content.edit @@ -98,6 +99,8 @@ class GameMenuFragment : Fragment(), PopupMenu.OnMenuItemClickListener { fun suspendGame(suspended: Boolean) fun dispatchNextFrame() fun toggleSelectionVisibility(enabled: Boolean) + fun toggleSelectionAvoidLocked(enabled: Boolean) + fun toggleSelectionPreferGroup(enabled: Boolean) fun overrideCamera(enabled: Boolean) fun selectRuntimeNode(nodeType: NodeType) fun selectRuntimeNodeSelectMode(selectMode: SelectMode) @@ -142,9 +145,6 @@ class GameMenuFragment : Fragment(), PopupMenu.OnMenuItemClickListener { private val setTimeScaleButton: Button? by lazy { view?.findViewById