Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-24 01:35:11 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-24 01:35:11 +0400
commit1ee8038e41f2daf3aaac40e58d7cdc416d2af35d (patch)
treedc2c0108f0b297edc3960e174457d1c57fe3dd2b /source
parent0bb50594f9118eedaac32d716f2eaf81e3efe1dc (diff)
2.5: Top Menu
* Clean up File menu, added back recover last session op. * .blend compress now behaves a bit different, previously it would only respect the user preference. Now it saves existing files the same way they are saved, and new files following the user preference. The save operator has a Compress toggle in the file browser left panels now. * Add menu working again, some fixes to make these operators work outside the 3d view were needed. * Timeline menu removed, its contents will be moved to the timeline header menus. * Game menu can now start game, changed the start game op to choose another 3d view if none is available. * Render menu has a few items now. * Help menu contains a few links again.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/curve/editcurve.c6
-rw-r--r--source/blender/editors/object/object_edit.c5
-rw-r--r--source/blender/editors/screen/screen_context.c2
-rw-r--r--source/blender/editors/screen/screen_ops.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c33
-rw-r--r--source/blender/windowmanager/WM_api.h2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c2
-rw-r--r--source/blender/windowmanager/intern/wm_files.c14
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c117
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp3
10 files changed, 145 insertions, 40 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 2bf5d357e5c..28a9d3ac7c9 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -4724,11 +4724,13 @@ Nurb *add_nurbs_primitive(bContext *C, int type, int newname)
Mat3MulMat3(cmat, imat, mat);
Mat3Inv(imat, cmat);
}
+ else
+ Mat3One(imat);
+
setflagsNurb(editnurb, 0);
}
- else {
+ else
return NULL;
- }
/* these types call this function to return a Nurb */
if (stype!=CU_PRIM_TUBE && stype!=CU_PRIM_DONUT) {
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 37453039cf5..cf37b0dd812 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -3587,10 +3587,11 @@ void ED_object_enter_editmode(bContext *C, int flag)
if(scene->id.lib) return;
if(base==NULL) return;
- if(sa->spacetype==SPACE_VIEW3D)
+ if(sa && sa->spacetype==SPACE_VIEW3D)
v3d= sa->spacedata.first;
- if((v3d==NULL || (base->lay & v3d->lay))==0) return;
+ if(v3d && (base->lay & v3d->lay)==0) return;
+ else if(!v3d && (base->lay & scene->lay)==0) return;
ob = base->object;
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 19750833b4d..2dc2cf9f293 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -93,7 +93,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if(CTX_data_equals(member, "active_base")) {
if(scene->basact)
- CTX_data_pointer_set(result, &scene->id, &RNA_UnknownType, &scene->basact);
+ CTX_data_pointer_set(result, &scene->id, &RNA_UnknownType, scene->basact);
return 1;
}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 4a42d1ed369..3032bff18df 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -206,6 +206,7 @@ int ED_operator_object_active(bContext *C)
int ED_operator_editmesh(bContext *C)
{
Object *obedit= CTX_data_edit_object(C);
+ printf("em %p %d\n", obedit, (obedit)? obedit->type == OB_MESH: -1);
if(obedit && obedit->type==OB_MESH)
return NULL != ((Mesh *)obedit->data)->edit_mesh;
return 0;
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index cb20b3dc93e..20e0a79f0c7 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1425,7 +1425,7 @@ static void RestoreState(bContext *C)
}
/* maybe we need this defined somewhere else */
-extern void StartKetsjiShell(struct bContext *C,int always_use_expand_framing);
+extern void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int always_use_expand_framing);
#endif // GAMEBLENDER == 1
@@ -1433,13 +1433,40 @@ static int game_engine_exec(bContext *C, wmOperator *unused)
{
#if GAMEBLENDER == 1
Scene *startscene = CTX_data_scene(C);
+ bScreen *sc= CTX_wm_screen(C);
+ ScrArea *sa, *prevsa= CTX_wm_area(C);
+ ARegion *ar, *prevar= CTX_wm_region(C);
+
+ sa= prevsa;
+ if(sa->spacetype != SPACE_VIEW3D) {
+ for(sa=sc->areabase.first; sa; sa= sa->next)
+ if(sa->spacetype==SPACE_VIEW3D)
+ break;
+ }
+
+ if(!sa)
+ return OPERATOR_CANCELLED;
+
+ for(ar=sa->regionbase.first; ar; ar=ar->next)
+ if(ar->regiontype == RGN_TYPE_WINDOW)
+ break;
+
+ if(!ar)
+ return OPERATOR_CANCELLED;
+ // bad context switch ..
+ CTX_wm_area_set(C, sa);
+ CTX_wm_region_set(C, ar);
+
view3d_operator_needs_opengl(C);
SaveState(C);
- StartKetsjiShell(C, 1);
+ StartKetsjiShell(C, ar, 1);
RestoreState(C);
+ CTX_wm_region_set(C, prevar);
+ CTX_wm_area_set(C, prevsa);
+
//XXX restore_all_scene_cfra(scene_cfra_store);
set_scene_bg(startscene);
//XXX scene_update_for_newframe(G.scene, G.scene->lay);
@@ -1461,7 +1488,7 @@ void VIEW3D_OT_game_start(wmOperatorType *ot)
/* api callbacks */
ot->exec= game_engine_exec;
- ot->poll= ED_operator_view3d_active;
+ //ot->poll= ED_operator_view3d_active;
}
/* ************************************** */
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 542a747d454..56ae220f7f0 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -57,7 +57,7 @@ struct wmWindow *WM_window_open (struct bContext *C, struct rcti *rect);
int WM_read_homefile (struct bContext *C, struct wmOperator *op);
int WM_write_homefile (struct bContext *C, struct wmOperator *op);
void WM_read_file (struct bContext *C, char *name, struct ReportList *reports);
-void WM_write_file (struct bContext *C, char *target, struct ReportList *reports);
+void WM_write_file (struct bContext *C, char *target, int compress, struct ReportList *reports);
void WM_read_autosavefile(struct bContext *C);
void WM_write_autosave (struct bContext *C);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 5377e351ff0..11b8f7f8c6f 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -451,7 +451,7 @@ int WM_operator_name_call(bContext *C, const char *opstring, int context, Pointe
CTX_wm_region_set(C, NULL);
CTX_wm_area_set(C, NULL);
- retval= wm_operator_invoke(C, ot, window->eventstate, properties);
+ retval= wm_operator_invoke(C, ot, event, properties);
CTX_wm_region_set(C, ar);
CTX_wm_area_set(C, area);
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index c3b317590f1..2019906bd5e 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -539,7 +539,7 @@ static void do_history(char *name, ReportList *reports)
BKE_report(reports, RPT_ERROR, "Unable to make version backup");
}
-void WM_write_file(bContext *C, char *target, ReportList *reports)
+void WM_write_file(bContext *C, char *target, int compress, ReportList *reports)
{
Library *li;
int writeflags, len;
@@ -580,10 +580,11 @@ void WM_write_file(bContext *C, char *target, ReportList *reports)
do_history(di, reports);
- /* we use the UserDef to define compression flag */
- writeflags= G.fileflags & ~G_FILE_COMPRESS;
- if(U.flag & USER_FILECOMPRESS)
- writeflags |= G_FILE_COMPRESS;
+ writeflags= G.fileflags;
+
+ /* set compression flag */
+ if(compress) writeflags |= G_FILE_COMPRESS;
+ else writeflags &= ~G_FILE_COMPRESS;
if (BLO_write_file(CTX_data_main(C), di, writeflags, reports)) {
strcpy(G.sce, di);
@@ -591,6 +592,9 @@ void WM_write_file(bContext *C, char *target, ReportList *reports)
strcpy(G.main->name, di); /* is guaranteed current file */
G.save_over = 1; /* disable untitled.blend convention */
+
+ if(compress) G.fileflags |= G_FILE_COMPRESS;
+ else G.fileflags &= ~G_FILE_COMPRESS;
writeBlog();
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 5e60207f62d..5c484dfa322 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -571,7 +571,7 @@ static void WM_OT_read_homefile(wmOperatorType *ot)
static int recentfile_exec(bContext *C, wmOperator *op)
{
- int event= RNA_int_get(op->ptr, "nr");
+ int event= RNA_enum_get(op->ptr, "file");
// XXX wm in context is not set correctly after WM_read_file -> crash
// do it before for now, but is this correct with multiple windows?
@@ -594,30 +594,54 @@ static int recentfile_exec(bContext *C, wmOperator *op)
static int wm_recentfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- struct RecentFile *recent;
uiPopupMenu *pup;
uiLayout *layout;
- int i, ofs= 0;
pup= uiPupMenuBegin(C, "Open Recent", 0);
layout= uiPupMenuLayout(pup);
+ uiItemsEnumO(layout, op->type->idname, "file");
+ uiPupMenuEnd(C, pup);
+
+ return OPERATOR_CANCELLED;
+}
+
+static EnumPropertyItem *open_recentfile_itemf(bContext *C, PointerRNA *ptr, int *free)
+{
+ EnumPropertyItem tmp = {0, "", 0, "", ""};
+ EnumPropertyItem *item= NULL;
+ struct RecentFile *recent;
+ int totitem= 0, i, ofs= 0;
if(G.sce[0]) {
- uiItemIntO(layout, G.sce, 0, op->type->idname, "nr", 1);
+ tmp.value= 1;
+ tmp.identifier= G.sce;
+ tmp.name= G.sce;
+ RNA_enum_item_add(&item, &totitem, &tmp);
ofs = 1;
}
-
- for(recent = G.recent_files.first, i=0; (i<U.recent_files) && (recent); recent = recent->next, i++)
- if(strcmp(recent->filename, G.sce))
- uiItemIntO(layout, recent->filename, 0, op->type->idname, "nr", i+ofs+1);
- uiPupMenuEnd(C, pup);
-
- return OPERATOR_CANCELLED;
+ /* dynamically construct enum */
+ for(recent = G.recent_files.first, i=0; (i<U.recent_files) && (recent); recent = recent->next, i++) {
+ if(strcmp(recent->filename, G.sce)) {
+ tmp.value= i+ofs+1;
+ tmp.identifier= recent->filename;
+ tmp.name= recent->filename;
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+ }
+
+ RNA_enum_item_end(&item, &totitem);
+ *free= 1;
+
+ return item;
}
static void WM_OT_open_recentfile(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+ static EnumPropertyItem file_items[]= {
+ {0, NULL, 0, NULL, NULL}};
+
ot->name= "Open Recent File";
ot->idname= "WM_OT_open_recentfile";
@@ -625,7 +649,8 @@ static void WM_OT_open_recentfile(wmOperatorType *ot)
ot->exec= recentfile_exec;
ot->poll= WM_operator_winactive;
- RNA_def_property(ot->srna, "nr", PROP_INT, PROP_UNSIGNED);
+ prop= RNA_def_enum(ot->srna, "file", file_items, 1, "File", "");
+ RNA_def_enum_funcs(prop, open_recentfile_itemf);
}
/* ********* main file *********** */
@@ -675,15 +700,57 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
ot->exec= wm_open_mainfile_exec;
ot->poll= WM_operator_winactive;
- ot->flag= 0;
-
RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);
+}
+
+static int wm_recover_last_session_exec(bContext *C, wmOperator *op)
+{
+ char scestr[FILE_MAX], filename[FILE_MAX];
+ int save_over;
+ /* back up some values */
+ BLI_strncpy(scestr, G.sce, sizeof(scestr));
+ save_over = G.save_over;
+
+ // XXX wm in context is not set correctly after WM_read_file -> crash
+ // do it before for now, but is this correct with multiple windows?
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
+
+ /* load file */
+ BLI_make_file_string("/", filename, btempdir, "quit.blend");
+ WM_read_file(C, filename, op->reports);
+
+ /* restore */
+ G.save_over = save_over;
+ BLI_strncpy(G.sce, scestr, sizeof(G.sce));
+
+ return 0;
+}
+
+static void WM_OT_recover_last_session(wmOperatorType *ot)
+{
+ ot->name= "Recover Last Session";
+ ot->idname= "WM_OT_recover_last_session";
+
+ ot->exec= wm_recover_last_session_exec;
+ ot->poll= WM_operator_winactive;
+}
+
+static void save_set_compress(wmOperator *op)
+{
+ if(!RNA_property_is_set(op->ptr, "compress")) {
+ if(G.save_over) /* keep flag for existing file */
+ RNA_boolean_set(op->ptr, "compress", G.fileflags & G_FILE_COMPRESS);
+ else /* use userdef for new file */
+ RNA_boolean_set(op->ptr, "compress", U.flag & USER_FILECOMPRESS);
+ }
}
static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
char name[FILE_MAX];
+
+ save_set_compress(op);
BLI_strncpy(name, G.sce, FILE_MAX);
untitled(name);
@@ -698,6 +765,10 @@ static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *even
static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
{
char filename[FILE_MAX];
+ int compress;
+
+ save_set_compress(op);
+ compress= RNA_boolean_get(op->ptr, "compress");
if(RNA_property_is_set(op->ptr, "filename"))
RNA_string_get(op->ptr, "filename", filename);
@@ -705,7 +776,8 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
BLI_strncpy(filename, G.sce, FILE_MAX);
untitled(filename);
}
- WM_write_file(C, filename, op->reports);
+
+ WM_write_file(C, filename, compress, op->reports);
WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL);
@@ -721,10 +793,8 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
ot->exec= wm_save_as_mainfile_exec;
ot->poll= WM_operator_winactive;
- ot->flag= 0;
-
- RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);
-
+ RNA_def_string_file_path(ot->srna, "filename", "", 0, "Filename", "");
+ RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file.");
}
/* *************** Save file directly ******** */
@@ -732,6 +802,8 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
char name[FILE_MAX];
+
+ save_set_compress(op);
BLI_strncpy(name, G.sce, FILE_MAX);
untitled(name);
@@ -750,10 +822,8 @@ static void WM_OT_save_mainfile(wmOperatorType *ot)
ot->exec= wm_save_as_mainfile_exec;
ot->poll= WM_operator_winactive;
- ot->flag= 0;
-
- RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);
-
+ RNA_def_string_file_path(ot->srna, "filename", "", 0, "Filename", "");
+ RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file.");
}
@@ -1590,6 +1660,7 @@ void wm_operatortype_init(void)
WM_operatortype_append(WM_OT_exit_blender);
WM_operatortype_append(WM_OT_open_recentfile);
WM_operatortype_append(WM_OT_open_mainfile);
+ WM_operatortype_append(WM_OT_recover_last_session);
WM_operatortype_append(WM_OT_jobs_timer);
WM_operatortype_append(WM_OT_save_as_mainfile);
WM_operatortype_append(WM_OT_save_mainfile);
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 03dd5d07eb0..6e6531c9b5f 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -118,11 +118,10 @@ static BlendFileData *load_game_data(char *filename)
return bfd;
}
-extern "C" void StartKetsjiShell(struct bContext *C, int always_use_expand_framing)
+extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int always_use_expand_framing)
{
/* context values */
struct wmWindow *win= CTX_wm_window(C);
- struct ARegion *ar= CTX_wm_region(C);
struct Scene *scene= CTX_data_scene(C);
struct Main* maggie1= CTX_data_main(C);