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?
This commit is contained in:
@@ -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):
|
||||
|
@@ -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");
|
||||
|
@@ -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);
|
||||
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user