From 384b8aafbf44e42557f3869d371cae2c4106d057 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Aug 2013 15:45:18 +0000 Subject: patch to add backkbacks for game engine start/end, by sjoerd_de_vries --- source/blender/blenlib/BLI_callbacks.h | 2 ++ source/blender/editors/space_view3d/view3d_view.c | 6 ++++++ source/blender/python/intern/bpy_app_handlers.c | 2 ++ 3 files changed, 10 insertions(+) (limited to 'source/blender') diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h index 8a0442c8bc8..e1775965444 100644 --- a/source/blender/blenlib/BLI_callbacks.h +++ b/source/blender/blenlib/BLI_callbacks.h @@ -43,6 +43,8 @@ typedef enum { BLI_CB_EVT_SAVE_POST, BLI_CB_EVT_SCENE_UPDATE_PRE, BLI_CB_EVT_SCENE_UPDATE_POST, + BLI_CB_EVT_GAME_PRE, + BLI_CB_EVT_GAME_POST, BLI_CB_EVT_TOT } eCbEvent; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index dfb4d1b25a2..0246e2b75a9 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -40,6 +40,7 @@ #include "BLI_rect.h" #include "BLI_listbase.h" #include "BLI_utildefines.h" +#include "BLI_callbacks.h" #include "BKE_anim.h" #include "BKE_action.h" @@ -1433,6 +1434,7 @@ static int game_engine_exec(bContext *C, wmOperator *op) { #ifdef WITH_GAMEENGINE Scene *startscene = CTX_data_scene(C); + Main *bmain = CTX_data_main(C); ScrArea /* *sa, */ /* UNUSED */ *prevsa = CTX_wm_area(C); ARegion *ar, *prevar = CTX_wm_region(C); wmWindow *prevwin = CTX_wm_window(C); @@ -1449,6 +1451,8 @@ static int game_engine_exec(bContext *C, wmOperator *op) * the window manager until after this operator exits */ WM_redraw_windows(C); + BLI_callback_exec(bmain, &startscene->id, BLI_CB_EVT_GAME_PRE); + rv3d = CTX_wm_region_view3d(C); /* sa = CTX_wm_area(C); */ /* UNUSED */ ar = CTX_wm_region(C); @@ -1504,6 +1508,8 @@ static int game_engine_exec(bContext *C, wmOperator *op) BKE_scene_set_background(CTX_data_main(C), startscene); //XXX BKE_scene_update_for_newframe(bmain, scene, scene->lay); + BLI_callback_exec(bmain, &startscene->id, BLI_CB_EVT_GAME_POST); + return OPERATOR_FINISHED; #else (void)C; /* unused */ diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index 90a0444ceae..959e4a788dd 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -57,6 +57,8 @@ static PyStructSequence_Field app_cb_info_fields[] = { {(char *)"save_post", (char *)"Callback list - on saving a blend file (after)"}, {(char *)"scene_update_pre", (char *)"Callback list - on updating the scenes data (before)"}, {(char *)"scene_update_post", (char *)"Callback list - on updating the scenes data (after)"}, + {(char *)"game_pre", (char *)"Callback list - on starting the game engine"}, + {(char *)"game_post", (char *)"Callback list - on ending the game engine"}, /* sets the permanent tag */ # define APP_CB_OTHER_FIELDS 1 -- cgit v1.2.3