Add load_ui to WM_OT_read_homefile
Useful for implementing templates. Patch D423 by Gaia Clary
This commit is contained in:
@@ -576,9 +576,6 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c
|
||||
}
|
||||
}
|
||||
|
||||
/* prevent loading no UI */
|
||||
G.fileflags &= ~G_FILE_NO_UI;
|
||||
|
||||
/* put aside screens to match with persistent windows later */
|
||||
wm_window_match_init(C, &wmbase);
|
||||
|
||||
@@ -687,6 +684,12 @@ int wm_homefile_read_exec(bContext *C, wmOperator *op)
|
||||
|
||||
if (!from_memory) {
|
||||
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "filepath");
|
||||
|
||||
/* This can be used when loading of a start-up file should only change
|
||||
* the scene content but keep the blender UI as it is. */
|
||||
wm_open_init_load_ui(op, true);
|
||||
BKE_BIT_TEST_SET(G.fileflags, !RNA_boolean_get(op->ptr, "load_ui"), G_FILE_NO_UI);
|
||||
|
||||
if (RNA_property_is_set(op->ptr, prop)) {
|
||||
RNA_property_string_get(op->ptr, prop, filepath_buf);
|
||||
filepath = filepath_buf;
|
||||
|
||||
@@ -161,6 +161,9 @@ void WM_init(bContext *C, int argc, const char **argv)
|
||||
BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
|
||||
BLF_lang_init();
|
||||
|
||||
/* Enforce loading the UI for the initial homefile */
|
||||
G.fileflags &= ~G_FILE_NO_UI;
|
||||
|
||||
/* get the default database, plus a wm */
|
||||
wm_homefile_read(C, NULL, G.factory_startup, NULL);
|
||||
|
||||
|
||||
@@ -2146,6 +2146,11 @@ static void WM_OT_read_homefile(wmOperatorType *ot)
|
||||
"Path to an alternative start-up file");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
|
||||
/* So scripts can use an alternative start-up file without the UI */
|
||||
prop = RNA_def_boolean(ot->srna, "load_ui", true, "Load UI",
|
||||
"Load user interface setup from the .blend file");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
|
||||
/* ommit poll to run in background mode */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user