[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27274] trunk/blender: Bringing back " Auto Start" option in the Game Menu.

Campbell Barton ideasman42 at gmail.com
Fri Mar 5 12:11:18 CET 2010


This should check for G_SCRIPT_AUTOEXEC otherwise a game can run on
any blend without permission & also run scripts.

On Fri, Mar 5, 2010 at 11:37 AM, Dalai Felinto <dfelinto at gmail.com> wrote:
> Revision: 27274
>          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27274
> Author:   dfelinto
> Date:     2010-03-05 11:37:55 +0100 (Fri, 05 Mar 2010)
>
> Log Message:
> -----------
> Bringing back "Auto Start" option in the Game Menu.
> It's (still) not working since the pool in the operator will not allow this operator to run without context.
> For the window/area/screen has to be created somewhere (maybe in WM_init_game ).
>
> I have no idea on what should be done to initialize it here, so if anyone knows how to proceed, please help here.
> * side note: should we also have it as a command line option?
>
> Modified Paths:
> --------------
>    trunk/blender/release/scripts/ui/space_info.py
>    trunk/blender/source/blender/makesrna/intern/rna_scene.c
>    trunk/blender/source/blender/windowmanager/WM_api.h
>    trunk/blender/source/blender/windowmanager/intern/wm_files.c
>    trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c
>    trunk/blender/source/creator/creator.c
>
> Modified: trunk/blender/release/scripts/ui/space_info.py
> ===================================================================
> --- trunk/blender/release/scripts/ui/space_info.py      2010-03-05 10:26:23 UTC (rev 27273)
> +++ trunk/blender/release/scripts/ui/space_info.py      2010-03-05 10:37:55 UTC (rev 27274)
> @@ -263,6 +263,8 @@
>         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):
>
> Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c
> ===================================================================
> --- trunk/blender/source/blender/makesrna/intern/rna_scene.c    2010-03-05 10:26:23 UTC (rev 27273)
> +++ trunk/blender/source/blender/makesrna/intern/rna_scene.c    2010-03-05 10:37:55 UTC (rev 27274)
> @@ -730,6 +730,22 @@
>        }
>  }
>
> +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 @@
>        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");
>
> Modified: trunk/blender/source/blender/windowmanager/WM_api.h
> ===================================================================
> --- trunk/blender/source/blender/windowmanager/WM_api.h 2010-03-05 10:26:23 UTC (rev 27273)
> +++ trunk/blender/source/blender/windowmanager/WM_api.h 2010-03-05 10:37:55 UTC (rev 27274)
> @@ -57,6 +57,7 @@
>  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);
>
>
>
> Modified: trunk/blender/source/blender/windowmanager/intern/wm_files.c
> ===================================================================
> --- trunk/blender/source/blender/windowmanager/intern/wm_files.c        2010-03-05 10:26:23 UTC (rev 27273)
> +++ trunk/blender/source/blender/windowmanager/intern/wm_files.c        2010-03-05 10:37:55 UTC (rev 27274)
> @@ -523,6 +523,9 @@
>                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 @@
>        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 @@
>        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);
>
> Modified: trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c
> ===================================================================
> --- trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c    2010-03-05 10:26:23 UTC (rev 27273)
> +++ trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c    2010-03-05 10:37:55 UTC (rev 27274)
> @@ -181,6 +181,20 @@
>        }
>  }
>
> +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)
>  {
>
> Modified: trunk/blender/source/creator/creator.c
> ===================================================================
> --- trunk/blender/source/creator/creator.c      2010-03-05 10:26:23 UTC (rev 27273)
> +++ trunk/blender/source/creator/creator.c      2010-03-05 10:37:55 UTC (rev 27274)
> @@ -1037,9 +1037,15 @@
>                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);
>
>
>
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>



-- 
- Campbell


More information about the Bf-committers mailing list