ported: Make auto_accept_quit and quit_on_go_back properties. - timothyqiu

58650af062
This commit is contained in:
Relintai 2022-07-27 18:26:15 +02:00
parent a29aac105f
commit cb6e070227
3 changed files with 22 additions and 16 deletions

View File

@ -171,14 +171,6 @@
Returns [constant OK] on success, [constant ERR_UNCONFIGURED] if no [member current_scene] was defined yet, [constant ERR_CANT_OPEN] if [member current_scene] cannot be loaded into a [PackedScene], or [constant ERR_CANT_CREATE] if the scene cannot be instantiated.
</description>
</method>
<method name="set_auto_accept_quit">
<return type="void" />
<argument index="0" name="enabled" type="bool" />
<description>
If [code]true[/code], the application automatically accepts quitting. Enabled by default.
For mobile platforms, see [method set_quit_on_go_back].
</description>
</method>
<method name="set_group">
<return type="void" />
<argument index="0" name="group" type="StringName" />
@ -202,14 +194,6 @@
Marks the most recent [InputEvent] as handled.
</description>
</method>
<method name="set_quit_on_go_back">
<return type="void" />
<argument index="0" name="enabled" type="bool" />
<description>
If [code]true[/code], the application quits automatically on going back (e.g. on Android). Enabled by default.
To handle 'Go Back' button when this option is disabled, use [constant MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST].
</description>
</method>
<method name="set_screen_stretch">
<return type="void" />
<argument index="0" name="mode" type="int" enum="SceneTree.StretchMode" />
@ -222,6 +206,10 @@
</method>
</methods>
<members>
<member name="auto_accept_quit" type="bool" setter="set_auto_accept_quit" getter="is_auto_accept_quit" default="true">
If [code]true[/code], the application automatically accepts quitting.
For mobile platforms, see [member quit_on_go_back].
</member>
<member name="current_scene" type="Node" setter="set_current_scene" getter="get_current_scene">
The current scene.
</member>
@ -252,6 +240,10 @@
<member name="physics_interpolation" type="bool" setter="set_physics_interpolation_enabled" getter="is_physics_interpolation_enabled" default="false">
Although physics interpolation would normally be globally turned on and off using [member ProjectSettings.physics/common/physics_interpolation], this property allows control over interpolation at runtime.
</member>
<member name="quit_on_go_back" type="bool" setter="set_quit_on_go_back" getter="is_quit_on_go_back" default="true">
If [code]true[/code], the application quits automatically on going back (e.g. on Android).
To handle 'Go Back' button when this option is disabled, use [constant MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST].
</member>
<member name="refuse_new_network_connections" type="bool" setter="set_refuse_new_network_connections" getter="is_refusing_new_network_connections" default="false">
If [code]true[/code], the [SceneTree]'s [member network_peer] refuses new incoming connections.
</member>

View File

@ -839,10 +839,18 @@ void SceneTree::_notification(int p_notification) {
};
};
bool SceneTree::is_auto_accept_quit() const {
return accept_quit;
}
void SceneTree::set_auto_accept_quit(bool p_enable) {
accept_quit = p_enable;
}
bool SceneTree::is_quit_on_go_back() const {
return quit_on_go_back;
}
void SceneTree::set_quit_on_go_back(bool p_enable) {
quit_on_go_back = p_enable;
}
@ -1953,9 +1961,13 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_root"), &SceneTree::get_root);
ClassDB::bind_method(D_METHOD("has_group", "name"), &SceneTree::has_group);
ClassDB::bind_method(D_METHOD("is_auto_accept_quit"), &SceneTree::is_auto_accept_quit);
ClassDB::bind_method(D_METHOD("set_auto_accept_quit", "enabled"), &SceneTree::set_auto_accept_quit);
ClassDB::bind_method(D_METHOD("is_quit_on_go_back"), &SceneTree::is_quit_on_go_back);
ClassDB::bind_method(D_METHOD("set_quit_on_go_back", "enabled"), &SceneTree::set_quit_on_go_back);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_accept_quit"), "set_auto_accept_quit", "is_auto_accept_quit");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "quit_on_go_back"), "set_quit_on_go_back", "is_quit_on_go_back");
ClassDB::bind_method(D_METHOD("set_debug_collisions_hint", "enable"), &SceneTree::set_debug_collisions_hint);
ClassDB::bind_method(D_METHOD("is_debugging_collisions_hint"), &SceneTree::is_debugging_collisions_hint);
ClassDB::bind_method(D_METHOD("set_debug_navigation_hint", "enable"), &SceneTree::set_debug_navigation_hint);

View File

@ -310,7 +310,9 @@ public:
virtual void finish();
bool is_auto_accept_quit() const;
void set_auto_accept_quit(bool p_enable);
bool is_quit_on_go_back() const;
void set_quit_on_go_back(bool p_enable);
void quit(int p_exit_code = -1);