Keymap: PKey only runs BGE when engine is set

This commit is contained in:
Campbell Barton 2014-10-28 13:34:11 +01:00
parent 25b7455eea
commit bfa24aa945
2 changed files with 6 additions and 1 deletions

View File

@ -320,6 +320,7 @@ void ED_keymap_object(wmKeyConfig *keyconf)
ED_keymap_proportional_cycle(keyconf, keymap);
ED_keymap_proportional_obmode(keyconf, keymap);
/* game-engine only, leave free for users to define */
WM_keymap_add_item(keymap, "VIEW3D_OT_game_start", PKEY, KM_PRESS, 0, 0);
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0);

View File

@ -1543,18 +1543,22 @@ static void game_set_commmandline_options(GameData *gm)
static int game_engine_poll(bContext *C)
{
bScreen *screen;
/* we need a context and area to launch BGE
* it's a temporary solution to avoid crash at load time
* if we try to auto run the BGE. Ideally we want the
* context to be set as soon as we load the file. */
if (CTX_wm_window(C) == NULL) return 0;
if (CTX_wm_screen(C) == NULL) return 0;
if ((screen = CTX_wm_screen(C)) == NULL) return 0;
if (CTX_wm_area(C) == NULL) return 0;
if (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)
return 0;
if (!BKE_scene_uses_blender_game(screen->scene))
return 0;
return 1;
}