Added a BACK notification besides QUIT, so they go in separate channels.
This commit is contained in:
parent
7bf4b592f8
commit
b7d69c2444
8 changed files with 36 additions and 17 deletions
|
@ -47,11 +47,12 @@ protected:
|
|||
public:
|
||||
|
||||
enum {
|
||||
NOTIFICATION_WM_MOUSE_ENTER = 3,
|
||||
NOTIFICATION_WM_MOUSE_EXIT = 4,
|
||||
NOTIFICATION_WM_FOCUS_IN = 5,
|
||||
NOTIFICATION_WM_FOCUS_OUT = 6,
|
||||
NOTIFICATION_WM_QUIT_REQUEST = 7,
|
||||
NOTIFICATION_WM_MOUSE_ENTER = 2,
|
||||
NOTIFICATION_WM_MOUSE_EXIT = 3,
|
||||
NOTIFICATION_WM_FOCUS_IN = 4,
|
||||
NOTIFICATION_WM_FOCUS_OUT = 5,
|
||||
NOTIFICATION_WM_QUIT_REQUEST = 6,
|
||||
NOTIFICATION_WM_GO_BACK_REQUEST = 7,
|
||||
NOTIFICATION_WM_UNFOCUS_REQUEST = 8,
|
||||
NOTIFICATION_OS_MEMORY_WARNING = 9,
|
||||
NOTIFICATION_TRANSLATION_CHANGED = 10,
|
||||
|
|
|
@ -1301,6 +1301,7 @@ bool Main::start() {
|
|||
sml->set_screen_stretch(sml_sm,sml_aspect,stretch_size);
|
||||
|
||||
sml->set_auto_accept_quit(GLOBAL_DEF("application/auto_accept_quit",true));
|
||||
sml->set_quit_on_go_back(GLOBAL_DEF("application/quit_on_go_back",true));
|
||||
String appname = GlobalConfig::get_singleton()->get("application/name");
|
||||
appname = TranslationServer::get_singleton()->translate(appname);
|
||||
OS::get_singleton()->set_window_title(appname);
|
||||
|
@ -1323,6 +1324,7 @@ bool Main::start() {
|
|||
GLOBAL_DEF("display/stretch/aspect","ignore");
|
||||
GlobalConfig::get_singleton()->set_custom_property_info("display/stretch/aspect",PropertyInfo(Variant::STRING,"display/stretch/aspect",PROPERTY_HINT_ENUM,"ignore,keep,keep_width,keep_height"));
|
||||
sml->set_auto_accept_quit(GLOBAL_DEF("application/auto_accept_quit",true));
|
||||
sml->set_quit_on_go_back(GLOBAL_DEF("application/quit_on_go_back",true));
|
||||
|
||||
GLOBAL_DEF("rendering/shadow_atlas/size",2048);
|
||||
GlobalConfig::get_singleton()->set_custom_property_info("rendering/shadow_atlas/size",PropertyInfo(Variant::INT,"rendering/shadow_atlas/size",PROPERTY_HINT_RANGE,"256,16384"));
|
||||
|
|
|
@ -721,7 +721,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|||
@Override public void onBackPressed() {
|
||||
|
||||
System.out.printf("** BACK REQUEST!\n");
|
||||
GodotLib.quit();
|
||||
GodotLib.back();
|
||||
}
|
||||
|
||||
public void forceQuit() {
|
||||
|
|
|
@ -649,7 +649,7 @@ static Mutex *suspend_mutex=NULL;
|
|||
static int step=0;
|
||||
static bool resized=false;
|
||||
static bool resized_reload=false;
|
||||
static bool quit_request=false;
|
||||
static bool go_back_request=false;
|
||||
static Size2 new_size;
|
||||
static Vector3 accelerometer;
|
||||
static Vector3 magnetometer;
|
||||
|
@ -965,11 +965,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv * e
|
|||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_quit(JNIEnv * env, jobject obj) {
|
||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv * env, jobject obj) {
|
||||
|
||||
input_mutex->lock();
|
||||
quit_request=true;
|
||||
print_line("BACK PRESSED");
|
||||
go_back_request=true;
|
||||
input_mutex->unlock();
|
||||
|
||||
}
|
||||
|
@ -1096,10 +1095,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv * env, jo
|
|||
joy_events.pop_front();
|
||||
}
|
||||
|
||||
if (quit_request) {
|
||||
if (go_back_request) {
|
||||
|
||||
os_android->main_loop_request_quit();
|
||||
quit_request=false;
|
||||
os_android->main_loop_request_go_back();
|
||||
go_back_request=false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1494,7 +1493,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv * env, job
|
|||
ievent.key.unicode = KEY_ENTER;
|
||||
} else if (p_scancode==4) {
|
||||
|
||||
quit_request=true;
|
||||
go_back_request=true;
|
||||
}
|
||||
|
||||
input_mutex->lock();
|
||||
|
|
|
@ -659,10 +659,10 @@ void OS_Android::init_video_mode(int p_video_width,int p_video_height) {
|
|||
default_videomode.resizable=false;
|
||||
}
|
||||
|
||||
void OS_Android::main_loop_request_quit() {
|
||||
void OS_Android::main_loop_request_go_back() {
|
||||
|
||||
if (main_loop)
|
||||
main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
|
||||
main_loop->notification(MainLoop::NOTIFICATION_WM_GO_BACK_REQUEST);
|
||||
}
|
||||
|
||||
void OS_Android::set_display_size(Size2 p_size) {
|
||||
|
|
|
@ -213,7 +213,7 @@ public:
|
|||
|
||||
void main_loop_begin();
|
||||
bool main_loop_iterate();
|
||||
void main_loop_request_quit();
|
||||
void main_loop_request_go_back();
|
||||
void main_loop_end();
|
||||
void main_loop_focusout();
|
||||
void main_loop_focusin();
|
||||
|
|
|
@ -498,6 +498,7 @@ void SceneTree::init() {
|
|||
|
||||
//_quit=false;
|
||||
accept_quit=true;
|
||||
quit_on_go_back=true;
|
||||
initialized=true;
|
||||
input_handled=false;
|
||||
|
||||
|
@ -646,6 +647,15 @@ void SceneTree::_notification(int p_notification) {
|
|||
break;
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_WM_GO_BACK_REQUEST: {
|
||||
|
||||
get_root()->propagate_notification(p_notification);
|
||||
|
||||
if (quit_on_go_back) {
|
||||
_quit=true;
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_OS_MEMORY_WARNING:
|
||||
case NOTIFICATION_WM_FOCUS_IN:
|
||||
case NOTIFICATION_WM_FOCUS_OUT: {
|
||||
|
@ -672,6 +682,11 @@ void SceneTree::set_auto_accept_quit(bool p_enable) {
|
|||
accept_quit=p_enable;
|
||||
}
|
||||
|
||||
void SceneTree::set_quit_on_go_back(bool p_enable) {
|
||||
|
||||
quit_on_go_back=p_enable;
|
||||
}
|
||||
|
||||
void SceneTree::set_editor_hint(bool p_enabled) {
|
||||
|
||||
editor_hint=p_enabled;
|
||||
|
|
|
@ -107,6 +107,7 @@ private:
|
|||
float fixed_process_time;
|
||||
float idle_process_time;
|
||||
bool accept_quit;
|
||||
bool quit_on_go_back;
|
||||
uint32_t last_id;
|
||||
|
||||
bool editor_hint;
|
||||
|
@ -353,6 +354,7 @@ public:
|
|||
virtual void finish();
|
||||
|
||||
void set_auto_accept_quit(bool p_enable);
|
||||
void set_quit_on_go_back(bool p_enable);
|
||||
|
||||
void quit();
|
||||
|
||||
|
|
Loading…
Reference in a new issue