소스 검색

Added notification const NOTIFICATION_WM_ABOUT

Marcelo Fernandez 8 년 전
부모
커밋
aae29c7a0e
5개의 변경된 파일29개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 0
      core/os/main_loop.cpp
  2. 5 1
      core/os/main_loop.h
  3. 2 0
      editor/editor_node.h
  4. 6 1
      platform/osx/os_osx.mm
  5. 14 0
      scene/main/scene_tree.cpp

+ 2 - 0
core/os/main_loop.cpp

@@ -54,6 +54,8 @@ void MainLoop::_bind_methods() {
 	BIND_CONSTANT(NOTIFICATION_WM_QUIT_REQUEST);
 	BIND_CONSTANT(NOTIFICATION_WM_UNFOCUS_REQUEST);
 	BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING);
+	BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED);
+	BIND_CONSTANT(NOTIFICATION_WM_ABOUT);
 };
 
 void MainLoop::set_init_script(const Ref<Script> &p_init_script) {

+ 5 - 1
core/os/main_loop.h

@@ -56,7 +56,11 @@ public:
 		NOTIFICATION_WM_GO_BACK_REQUEST = 7,
 		NOTIFICATION_WM_UNFOCUS_REQUEST = 8,
 		NOTIFICATION_OS_MEMORY_WARNING = 9,
-		NOTIFICATION_TRANSLATION_CHANGED = 10,
+		// Note: NOTIFICATION_TRANSLATION_CHANGED and NOTIFICATION_WM_ABOUT used to have id=10 and id=11 but these
+		// conflict with NOTIFICATION_ENTER_TREE (id=10) and NOTIFICATION_EXIT_TREE (id=11), so id=90 and id=91
+		// fixes this issue.
+		NOTIFICATION_TRANSLATION_CHANGED = 90,
+		NOTIFICATION_WM_ABOUT = 91,
 	};
 
 	virtual void input_event(const Ref<InputEvent> &p_event);

+ 2 - 0
editor/editor_node.h

@@ -684,6 +684,8 @@ public:
 
 	void merge_from_scene() { _menu_option_confirm(FILE_IMPORT_SUBSCENE, false); }
 
+	void show_about() { _menu_option_confirm(HELP_ABOUT, false); }
+
 	static bool has_unsaved_changes() { return singleton->unsaved_cache; }
 
 	static HBoxContainer *get_menu_hb() { return singleton->menu_hb; }

+ 6 - 1
platform/osx/os_osx.mm

@@ -137,6 +137,11 @@ static bool mouse_down_control = false;
 	//_GodotInputMonitorChange();
 }
 
+- (void)showAbout:(id)sender {
+	if (OS_OSX::singleton->get_main_loop())
+		OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_ABOUT);
+}
+
 @end
 
 @interface GodotWindowDelegate : NSObject {
@@ -1897,7 +1902,7 @@ OS_OSX::OS_OSX() {
 	// Setup Apple menu
 	NSMenu *apple_menu = [[NSMenu alloc] initWithTitle:@""];
 	title = [NSString stringWithFormat:NSLocalizedString(@"About %@", nil), nsappname];
-	[apple_menu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
+	[apple_menu addItemWithTitle:title action:@selector(showAbout:) keyEquivalent:@""];
 
 	[apple_menu addItem:[NSMenuItem separatorItem]];
 

+ 14 - 0
scene/main/scene_tree.cpp

@@ -38,6 +38,7 @@
 #include <stdio.h>
 //#include "servers/spatial_sound_2d_server.h"
 
+#include "editor/editor_node.h"
 #include "io/marshalls.h"
 #include "io/resource_loader.h"
 #include "scene/resources/material.h"
@@ -701,6 +702,19 @@ void SceneTree::_notification(int p_notification) {
 
 		} break;
 
+		case NOTIFICATION_WM_ABOUT: {
+
+#ifdef TOOLS_ENABLED
+			if (is_editor_hint()) {
+				EditorNode::get_singleton()->show_about();
+			} else {
+#endif
+				get_root()->propagate_notification(p_notification);
+#ifdef TOOLS_ENABLED
+			}
+#endif
+		} break;
+
 		default:
 			break;
 	};