Path: blob/master/platform/android/editor/game_menu_utils_jni.cpp
10278 views
/**************************************************************************/1/* game_menu_utils_jni.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "game_menu_utils_jni.h"3132#ifdef TOOLS_ENABLED33#include "editor/editor_interface.h"34#include "editor/editor_node.h"35#include "editor/run/game_view_plugin.h"3637static GameViewPlugin *_get_game_view_plugin() {38ERR_FAIL_NULL_V(EditorNode::get_singleton(), nullptr);39ERR_FAIL_NULL_V(EditorNode::get_singleton()->get_editor_main_screen(), nullptr);40return Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));41}4243#endif4445extern "C" {4647JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSuspend(JNIEnv *env, jclass clazz, jboolean enabled) {48#ifdef TOOLS_ENABLED49GameViewPlugin *game_view_plugin = _get_game_view_plugin();50if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {51game_view_plugin->get_debugger()->set_suspend(enabled);52}53#endif54}5556JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_nextFrame(JNIEnv *env, jclass clazz) {57#ifdef TOOLS_ENABLED58GameViewPlugin *game_view_plugin = _get_game_view_plugin();59if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {60game_view_plugin->get_debugger()->next_frame();61}62#endif63}6465JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setNodeType(JNIEnv *env, jclass clazz, jint type) {66#ifdef TOOLS_ENABLED67GameViewPlugin *game_view_plugin = _get_game_view_plugin();68if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {69game_view_plugin->get_debugger()->set_node_type(type);70}71#endif72}7374JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSelectMode(JNIEnv *env, jclass clazz, jint mode) {75#ifdef TOOLS_ENABLED76GameViewPlugin *game_view_plugin = _get_game_view_plugin();77if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {78game_view_plugin->get_debugger()->set_select_mode(mode);79}80#endif81}8283JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSelectionVisible(JNIEnv *env, jclass clazz, jboolean visible) {84#ifdef TOOLS_ENABLED85GameViewPlugin *game_view_plugin = _get_game_view_plugin();86if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {87game_view_plugin->get_debugger()->set_selection_visible(visible);88}89#endif90}9192JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setCameraOverride(JNIEnv *env, jclass clazz, jboolean enabled) {93#ifdef TOOLS_ENABLED94GameViewPlugin *game_view_plugin = _get_game_view_plugin();95if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {96game_view_plugin->get_debugger()->set_camera_override(enabled);97}98#endif99}100101JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setCameraManipulateMode(JNIEnv *env, jclass clazz, jint mode) {102#ifdef TOOLS_ENABLED103GameViewPlugin *game_view_plugin = _get_game_view_plugin();104if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {105game_view_plugin->get_debugger()->set_camera_manipulate_mode(static_cast<EditorDebuggerNode::CameraOverride>(mode));106}107#endif108}109110JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_resetCamera2DPosition(JNIEnv *env, jclass clazz) {111#ifdef TOOLS_ENABLED112GameViewPlugin *game_view_plugin = _get_game_view_plugin();113if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {114game_view_plugin->get_debugger()->reset_camera_2d_position();115}116#endif117}118119JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_resetCamera3DPosition(JNIEnv *env, jclass clazz) {120#ifdef TOOLS_ENABLED121GameViewPlugin *game_view_plugin = _get_game_view_plugin();122if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {123game_view_plugin->get_debugger()->reset_camera_3d_position();124}125#endif126}127128JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_playMainScene(JNIEnv *env, jclass clazz) {129#ifdef TOOLS_ENABLED130if (EditorInterface::get_singleton()) {131EditorInterface::get_singleton()->play_main_scene();132}133#endif134}135136JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setDebugMuteAudio(JNIEnv *env, jclass clazz, jboolean enabled) {137#ifdef TOOLS_ENABLED138GameViewPlugin *game_view_plugin = _get_game_view_plugin();139if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {140game_view_plugin->get_debugger()->set_debug_mute_audio(enabled);141}142#endif143}144}145146147