Debian Codegraph @

platform/android/editor/game_menu_utils_jni.cpp

raw symbols SCIP
1 /**************************************************************************/
2 /* game_menu_utils_jni.cpp */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #include "game_menu_utils_jni.h"
32
33 #ifdef TOOLS_ENABLED
34 #include "editor/editor_interface.h"
35 #include "editor/editor_node.h"
36 #include "editor/run/game_view_plugin.h"
37
38 _FORCE_INLINE_ static GameViewPlugin *_get_game_view_plugin() {
39 ERR_FAIL_NULL_V(EditorNode::get_singleton(), nullptr);
40 ERR_FAIL_NULL_V(EditorNode::get_singleton()->get_editor_main_screen(), nullptr);
41 return Object::cast_to<GameViewPlugin>(EditorNode::get_singleton()->get_editor_main_screen()->get_plugin_by_name("Game"));
42 }
43
44 #endif
45
46 extern "C" {
47
48 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSuspend(JNIEnv *env, jclass clazz, jboolean enabled) {
49 #ifdef TOOLS_ENABLED
50 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
51 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
52 game_view_plugin->get_debugger()->set_suspend(enabled);
53 }
54 #endif
55 }
56
57 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_nextFrame(JNIEnv *env, jclass clazz) {
58 #ifdef TOOLS_ENABLED
59 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
60 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
61 game_view_plugin->get_debugger()->next_frame();
62 }
63 #endif
64 }
65
66 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setNodeType(JNIEnv *env, jclass clazz, jint type) {
67 #ifdef TOOLS_ENABLED
68 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
69 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
70 game_view_plugin->get_debugger()->set_node_type(type);
71 }
72 #endif
73 }
74
75 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSelectMode(JNIEnv *env, jclass clazz, jint mode) {
76 #ifdef TOOLS_ENABLED
77 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
78 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
79 game_view_plugin->get_debugger()->set_select_mode(mode);
80 }
81 #endif
82 }
83
84 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setSelectionVisible(JNIEnv *env, jclass clazz, jboolean visible) {
85 #ifdef TOOLS_ENABLED
86 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
87 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
88 game_view_plugin->get_debugger()->set_selection_visible(visible);
89 }
90 #endif
91 }
92
93 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setCameraOverride(JNIEnv *env, jclass clazz, jboolean enabled) {
94 #ifdef TOOLS_ENABLED
95 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
96 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
97 game_view_plugin->get_debugger()->set_camera_override(enabled);
98 }
99 #endif
100 }
101
102 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setCameraManipulateMode(JNIEnv *env, jclass clazz, jint mode) {
103 #ifdef TOOLS_ENABLED
104 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
105 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
106 game_view_plugin->get_debugger()->set_camera_manipulate_mode(static_cast<EditorDebuggerNode::CameraOverride>(mode));
107 }
108 #endif
109 }
110
111 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_resetCamera2DPosition(JNIEnv *env, jclass clazz) {
112 #ifdef TOOLS_ENABLED
113 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
114 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
115 game_view_plugin->get_debugger()->reset_camera_2d_position();
116 }
117 #endif
118 }
119
120 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_resetCamera3DPosition(JNIEnv *env, jclass clazz) {
121 #ifdef TOOLS_ENABLED
122 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
123 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
124 game_view_plugin->get_debugger()->reset_camera_3d_position();
125 }
126 #endif
127 }
128
129 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_playMainScene(JNIEnv *env, jclass clazz) {
130 #ifdef TOOLS_ENABLED
131 if (EditorInterface::get_singleton()) {
132 EditorInterface::get_singleton()->play_main_scene();
133 }
134 #endif
135 }
136
137 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setDebugMuteAudio(JNIEnv *env, jclass clazz, jboolean enabled) {
138 #ifdef TOOLS_ENABLED
139 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
140 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
141 game_view_plugin->get_debugger()->set_debug_mute_audio(enabled);
142 }
143 #endif
144 }
145
146 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_resetTimeScale(JNIEnv *env, jclass clazz) {
147 #ifdef TOOLS_ENABLED
148 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
149 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
150 game_view_plugin->get_debugger()->reset_time_scale();
151 }
152 #endif
153 }
154
155 JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_GameMenuUtils_setTimeScale(JNIEnv *env, jclass clazz, jdouble scale) {
156 #ifdef TOOLS_ENABLED
157 GameViewPlugin *game_view_plugin = _get_game_view_plugin();
158 if (game_view_plugin != nullptr && game_view_plugin->get_debugger().is_valid()) {
159 game_view_plugin->get_debugger()->set_time_scale(scale);
160 }
161 #endif
162 }
163 }