Added notification const NOTIFICATION_WM_ABOUT

This commit is contained in:
Marcelo Fernandez 2017-08-11 12:04:32 -03:00
parent 23f6d3fa69
commit aae29c7a0e
5 changed files with 29 additions and 2 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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; }

View File

@ -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]];

View File

@ -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;
};