diff --git a/release/scripts/ui/space_info.py b/release/scripts/ui/space_info.py index e1bc8f2b226..780884591b0 100644 --- a/release/scripts/ui/space_info.py +++ b/release/scripts/ui/space_info.py @@ -263,6 +263,8 @@ class INFO_MT_game(bpy.types.Menu): layout.prop(gs, "show_physics_visualization") layout.prop(gs, "use_deprecation_warnings") layout.prop(gs, "use_animation_record") + layout.separator() + layout.prop(gs, "auto_start") class INFO_MT_render(bpy.types.Menu): diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f4efb015893..ea7a81e8018 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -730,6 +730,22 @@ static void rna_Scene_sync_mode_set(PointerRNA *ptr, int value) } } +static int rna_GameSettings_auto_start_get(PointerRNA *ptr) +{ + if (G.fileflags & G_FILE_AUTOPLAY) + return 1; + + return 0; +} + +static void rna_GameSettings_auto_start_set(PointerRNA *ptr, int value) +{ + if(value) + G.fileflags |= G_FILE_AUTOPLAY; + else + G.fileflags &= ~G_FILE_AUTOPLAY; +} + #else static void rna_def_transform_orientation(BlenderRNA *brna) @@ -1542,6 +1558,10 @@ static void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_ENABLE_ANIMATION_RECORD); RNA_def_property_ui_text(prop, "Record Animation", "Record animation to fcurves"); + prop= RNA_def_property(srna, "auto_start", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_GameSettings_auto_start_get", "rna_GameSettings_auto_start_set"); + RNA_def_property_ui_text(prop, "Auto Start", "Automatically start game at load time"); + /* materials */ prop= RNA_def_property(srna, "material_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "matmode"); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 82788dc962b..7a1a14b645d 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -57,6 +57,7 @@ void WM_init (struct bContext *C, int argc, char **argv); void WM_exit (struct bContext *C); void WM_main (struct bContext *C); +void WM_init_game (struct bContext *C); void WM_init_splash (struct bContext *C); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 2ab6f78daa5..2a8091c1aa2 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -523,6 +523,9 @@ void WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports if(fileflags & G_FILE_COMPRESS) G.fileflags |= G_FILE_COMPRESS; else G.fileflags &= ~G_FILE_COMPRESS; + if(fileflags & G_FILE_AUTOPLAY) G.fileflags |= G_FILE_AUTOPLAY; + else G.fileflags &= ~G_FILE_AUTOPLAY; + writeBlog(); } @@ -544,7 +547,7 @@ int WM_write_homefile(bContext *C, wmOperator *op) BLI_make_file_string("/", tstr, BLI_gethome(), ".B25.blend"); /* force save as regular blend file */ - fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN); + fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN); BLO_write_file(CTX_data_main(C), tstr, fileflags, op->reports); @@ -612,7 +615,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) wm_autosave_location(filename); /* force save as regular blend file */ - fileflags = G.fileflags & ~(G_FILE_COMPRESS|G_FILE_LOCK|G_FILE_SIGN); + fileflags = G.fileflags & ~(G_FILE_COMPRESS|G_FILE_AUTOPLAY |G_FILE_LOCK|G_FILE_SIGN); /* no error reporting to console */ BLO_write_file(CTX_data_main(C), filename, fileflags, NULL); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index dadc6b60616..449c586c178 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -181,6 +181,20 @@ void WM_init_splash(bContext *C) } } +void WM_init_game(bContext *C) +{ + //XXX copied from WM_init_splash we may not even need those "window" related code + //XXX not working yet, it fails at the game_start_operator pool (it needs an area) + wmWindowManager *wm= CTX_wm_manager(C); + wmWindow *prevwin= CTX_wm_window(C); + + if(wm->windows.first) { + CTX_wm_window_set(C, wm->windows.first); + WM_operator_name_call(C, "VIEW3D_OT_game_start", WM_OP_EXEC_DEFAULT, NULL); + CTX_wm_window_set(C, prevwin); + } +} + /* free strings of open recent files */ static void free_openrecent(void) { diff --git a/source/creator/creator.c b/source/creator/creator.c index 3b9bac2ccd5..1d811ba61f3 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1037,8 +1037,14 @@ int main(int argc, char **argv) WM_exit(C); } - if(!G.background && !G.file_loaded) - WM_init_splash(C); + else { + if(G.fileflags & G_FILE_AUTOPLAY){ + WM_init_game(C); + } + + else if(!G.file_loaded) + WM_init_splash(C); + } WM_main(C);