* comment fix
[blender.git] / source / blender / src / header_info.c
1 /**
2  * header_info.c oct-2003
3  *
4  * Functions to draw the "User Preferences" window header
5  * and handle user events sent to it.
6  * 
7  *
8  * ***** BEGIN GPL LICENSE BLOCK *****
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 59 Temple Place - Suite 330, Boston, MA        02111-1307, USA.
23  *
24  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
25  * All rights reserved.
26  *
27  * The Original Code is: all of this file.
28  *
29  * Contributor(s): none yet.
30  *
31  * ***** END GPL LICENSE BLOCK *****
32  */
33  
34 #include <math.h>
35 #include <stdlib.h>
36 #include <string.h>
37
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include "DNA_group_types.h"
43 #include "DNA_ID.h"
44 #include "DNA_image_types.h"
45 #include "DNA_lamp_types.h"
46 #include "DNA_object_types.h"
47 #include "DNA_packedFile_types.h"
48 #include "DNA_scene_types.h"
49 #include "DNA_screen_types.h"
50 #include "DNA_space_types.h"
51 #include "DNA_userdef_types.h"
52 #include "DNA_world_types.h"
53
54 #include "BDR_editcurve.h"
55 #include "BDR_editmball.h"
56 #include "BDR_editobject.h"
57 #include "BDR_editface.h"
58 #include "BDR_vpaint.h"
59
60 #include "BIF_editarmature.h"
61 #include "BIF_editfont.h"
62 #include "BIF_editmesh.h"
63 #include "BIF_gl.h"
64 #include "BIF_interface.h"
65 #include "BIF_language.h"
66 #include "BIF_mainqueue.h"
67 #include "BIF_meshtools.h"
68 #include "BIF_previewrender.h"
69 #include "BIF_renderwin.h"
70 #include "BIF_resources.h"
71 #include "BIF_screen.h"
72 #include "BIF_space.h"
73 #include "BIF_toets.h"
74 #include "BIF_toolbox.h"
75 #include "BIF_usiblender.h"
76 #include "BIF_writeimage.h"
77 #include "BIF_drawscene.h"
78
79 #ifdef WITH_VERSE
80 #include "BIF_verse.h"
81 #endif
82
83 #include "BKE_blender.h"
84 #include "BKE_colortools.h"
85 #include "BKE_depsgraph.h"
86 #include "BKE_exotic.h"
87 #include "BKE_global.h"
88 #include "BKE_image.h"
89 #include "BKE_library.h"
90 #include "BKE_main.h"
91 #include "BKE_node.h"
92 #include "BKE_packedFile.h"
93 #include "BKE_scene.h"
94 #include "BKE_world.h"
95
96 #ifdef WITH_VERSE
97 #include "BKE_verse.h"
98 #endif
99
100 #include "BLI_arithb.h"
101 #include "BLI_blenlib.h"
102 #include "BLI_bpath.h"
103 #include "BLO_writefile.h"
104
105 #include "BSE_editipo.h"
106 #include "BSE_filesel.h"
107 #include "BIF_imasel.h"
108 #include "BSE_headerbuttons.h"
109 #include "BSE_node.h"
110 #include "BSE_sequence.h"
111 #include "BSE_edit.h"
112 #include "BSE_time.h"
113
114 #include "IMB_imbuf_types.h"
115
116 #include "MEM_guardedalloc.h"
117
118 #include "BPY_extern.h"
119 #include "BPY_menus.h"
120
121 #include "GPU_extensions.h"
122 #include "GPU_material.h"
123
124 #include "blendef.h"
125 #include "interface.h"
126 #include "mydevice.h"
127
128 extern char versionstr[]; /* from blender.c */
129
130 /*----------------------------------*/
131 /* Progress bar vars and functions: */
132
133 /* strubi shamelessly abused the status line as a progress bar...
134  * feel free to kill him after release */
135
136 static int g_progress_bar = 0;
137 static char *g_progress_info = 0;
138 static float g_done;
139
140 int start_progress_bar(void)
141 {
142         g_progress_bar = 1;
143         return 1;               // we never fail (yet)
144 }
145
146 void end_progress_bar(void)
147 {
148         g_progress_bar = 0;
149 }
150
151 static void update_progress_bar(float done, char *info)
152 {
153         g_done = done;
154         g_progress_info = info;
155 }
156
157 /** Progress bar
158         'done': a value between 0.0 and 1.0, showing progress
159         'info': a info text what is currently being done
160
161         Make sure that the progress bar is always called with:
162         done = 0.0 first
163                 and
164         done = 1.0 last -- or alternatively use:
165
166         start_progressbar();
167         do_stuff_and_callback_progress_bar();
168         end_progressbar();
169 */
170
171 int progress_bar(float done, char *busy_info)
172 {
173         ScrArea *sa;
174         short val; 
175
176         /* User break (ESC) */
177         while (qtest()) {
178                 if (extern_qread(&val) == ESCKEY) 
179                         return 0;
180         }
181         if (done == 0.0) {
182                 start_progress_bar();
183         } else if (done > 0.99) {
184                 end_progress_bar();
185         }
186
187         sa= G.curscreen->areabase.first;
188         while(sa) {
189                 if (sa->spacetype == SPACE_INFO) {
190                         update_progress_bar(done, busy_info);
191
192                         curarea = sa;
193
194                         scrarea_do_headdraw(curarea);
195                         areawinset(curarea->win);
196                         sa->head_swap= WIN_BACK_OK;
197                         screen_swapbuffers();
198                 }
199                 sa = sa->next;
200         }
201         return 1;
202 }
203 /* -- End of progress bar definitions ------- */
204
205 extern char temp_dir[]; /* XXXXX BAD BAD BAD from exotic.c */
206
207 void write_vrml_fs()
208 {
209         if(G.obedit) {
210                 error("Can't save VRML. Press TAB to leave EditMode");
211         }
212         else {
213                 if(temp_dir[0]==0) strcpy(temp_dir, G.sce);
214         
215                 activate_fileselect(FILE_SPECIAL, "Export VRML 1.0", temp_dir, write_vrml);
216         }  
217 }
218
219 void write_dxf_fs()
220 {
221         if(G.obedit) {
222                 error("Can't save DXF. Press TAB to leave EditMode");
223         }
224         else {
225
226                 if(temp_dir[0]==0) strcpy(temp_dir, G.sce);
227
228                 activate_fileselect(FILE_SPECIAL, "Export DXF", temp_dir, write_dxf);   
229         }
230 }
231
232 void write_stl_fs()
233 {
234         if(G.obedit) {
235                 error("Can't save STL. Press TAB to leave EditMode");
236         }
237         else {
238
239                 if(temp_dir[0]==0) strcpy(temp_dir, G.sce);
240
241                 activate_fileselect(FILE_SPECIAL, "Export STL", temp_dir, write_stl);
242         }
243 }
244 /* ------------ */
245
246 int buttons_do_unpack()
247 {
248         int how;
249         char menu[2048];
250         char *line = menu;
251         int ret_value = RET_OK, count = 0;
252
253         count = countPackedFiles();
254
255         if(!count) {
256                 pupmenu("No packed files. Autopack disabled");
257                 return ret_value;
258         }
259         if (count == 1)
260                 line += sprintf(line, "Unpack 1 file%%t");
261         else
262                 line += sprintf(line, "Unpack %d files%%t", count);
263         
264         line += sprintf(line, "|Use files in current directory (create when necessary)%%x%d", PF_USE_LOCAL);
265         line += sprintf(line, "|Write files to current directory (overwrite existing files)%%x%d", PF_WRITE_LOCAL);
266         line += sprintf(line, "|%%l|Use files in original location (create when necessary)%%x%d", PF_USE_ORIGINAL);
267         line += sprintf(line, "|Write files to original location (overwrite existing files)%%x%d", PF_WRITE_ORIGINAL);
268         line += sprintf(line, "|%%l|Disable AutoPack, keep all packed files %%x%d", PF_KEEP);
269         line += sprintf(line, "|Ask for each file %%x%d", PF_ASK);
270
271         how = pupmenu(menu);
272
273         if(how == -1)
274                 ret_value = RET_CANCEL;
275         else {
276                 if (how != PF_KEEP) unpackAll(how);
277                 G.fileflags &= ~G_AUTOPACK;
278         }
279         
280         return ret_value;
281 }
282
283 /* here, because of all creator stuff */
284
285 Scene *copy_scene(Scene *sce, int level)
286 {
287         /* 
288          * level 0: empty, only copy minimal stuff
289          * level 1: all objects shared
290          * level 2: all object-data shared
291          * level 3: full copy
292          */
293         
294         Scene *scen;
295         Base *base, *obase;
296         
297         if (level==0) { /* Add Empty, minimal copy */
298                 ListBase lb;
299                 scen= add_scene(sce->id.name+2);
300                 
301                 lb= scen->r.layers;
302                 scen->r= sce->r;
303                 scen->r.layers= lb;
304                 
305         } else {
306                 /* level 1+, but not level 0 */
307                 scen= copy_libblock(sce);
308                 duplicatelist(&(scen->base), &(sce->base));
309                 
310                 clear_id_newpoins();
311                 
312                 id_us_plus((ID *)scen->world);
313                 id_us_plus((ID *)scen->set);
314         
315                 scen->ed= NULL;
316                 scen->radio= NULL;
317                 scen->theDag= NULL;
318                 scen->toolsettings= MEM_dupallocN(sce->toolsettings);
319         
320                 duplicatelist(&(scen->markers), &(sce->markers));
321                 duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces));
322                 duplicatelist(&(scen->r.layers), &(sce->r.layers));
323                 
324                 scen->nodetree= ntreeCopyTree(sce->nodetree, 0);
325                 
326                 obase= sce->base.first;
327                 base= scen->base.first;
328                 while(base) {
329                         id_us_plus(&base->object->id);
330                         if(obase==sce->basact) scen->basact= base;
331         
332                         obase= obase->next;
333                         base= base->next;
334                 }
335                 BPY_copy_scriptlink(&sce->scriptlink);
336                 
337                 /* sculpt data */
338                 sce->sculptdata.session = NULL;
339                 if (sce->sculptdata.cumap) {
340                         int a;
341                         scen->sculptdata.cumap = curvemapping_copy(sce->sculptdata.cumap);
342                         scen->sculptdata.session = NULL; /* this is only for temp data storage anyway */
343                         for(a=0; a<MAX_MTEX; ++a) {
344                                 if (sce->sculptdata.mtex[a]) {
345                                         scen->sculptdata.mtex[a]= MEM_dupallocN(sce->sculptdata.mtex[a]);
346                                 }
347                         }
348                 }
349         }
350         
351         // make a private copy of the avicodecdata
352         
353         if (sce->r.avicodecdata) {
354         
355                 scen->r.avicodecdata = MEM_dupallocN(sce->r.avicodecdata);
356                 scen->r.avicodecdata->lpFormat = MEM_dupallocN(scen->r.avicodecdata->lpFormat);
357                 scen->r.avicodecdata->lpParms = MEM_dupallocN(scen->r.avicodecdata->lpParms);
358         }
359         
360         // make a private copy of the qtcodecdata
361         
362         if (sce->r.qtcodecdata) {
363                 scen->r.qtcodecdata = MEM_dupallocN(sce->r.qtcodecdata);
364                 scen->r.qtcodecdata->cdParms = MEM_dupallocN(scen->r.qtcodecdata->cdParms);
365         }
366         
367         
368         if(level==0 || level==1) return scen;
369
370         /* level 2 */
371         G.scene= scen;
372         
373         single_object_users(0);
374
375         /*      camera */
376         ID_NEW(G.scene->camera);
377
378         /* level 3 */
379         if(level>=3) {
380                 if(scen->world) {
381                         id_us_plus(&scen->world->id);
382                         scen->world= copy_world(scen->world);
383                 }
384                 single_obdata_users(0);
385                 single_mat_users_expand();
386                 single_tex_users_expand();
387                 
388                 scen->radio= MEM_dupallocN(sce->radio);
389                 
390         }
391
392         clear_id_newpoins();
393         return scen;
394 }
395
396 void do_info_buttons(unsigned short event)
397 {
398         bScreen *sc, *oldscreen;
399         Scene *sce, *sce1;
400         ScrArea *sa;
401         int nr;
402
403         switch(event) {
404         case B_INFOSCR:         /* menu select screen */
405
406                 if( G.curscreen->screennr== -2) {
407                         if(curarea->winy <50) {
408                                 sa= closest_bigger_area();
409                                 areawinset(sa->win);
410                         }
411                         activate_databrowse((ID *)G.curscreen, ID_SCR, 0, B_INFOSCR,
412                                                                                         &G.curscreen->screennr, do_info_buttons);
413                         return;
414                 }
415                 if( G.curscreen->screennr < 0) return;
416
417                 sc= G.main->screen.first;
418                 nr= 1;
419                 while(sc) {
420                         if(nr==G.curscreen->screennr) {
421                                 if(is_allowed_to_change_screen(sc)) setscreen(sc);
422                                 else error("Unable to perform function in EditMode");
423                                 break;
424                         }
425                         nr++;
426                         sc= sc->id.next;
427                 }
428                 /* last item: NEW SCREEN */
429                 if(sc==0) {
430                         nr= pupmenu("New Screen%t|Empty%x1|Duplicate%x2");
431
432                         if(nr==1) default_twosplit();
433                         if(nr==2) duplicate_screen();
434                 }
435                 break;
436         case B_INFODELSCR:
437 /*do this event only with buttons, so it can never be called with full-window*/
438
439                 if(G.curscreen->id.prev) sc= G.curscreen->id.prev;
440                 else if(G.curscreen->id.next) sc= G.curscreen->id.next;
441                 else return;
442                 if(okee("Delete current screen")) {
443                         /* find new G.curscreen */
444
445                         oldscreen= G.curscreen;
446                         setscreen(sc);          /* this test if sc has a full */
447                         unlink_screen(oldscreen);
448                         free_libblock(&G.main->screen, oldscreen);
449                 }
450                 scrarea_queue_headredraw(curarea);
451
452                 break;
453         case B_INFOSCE:         /* menu select scene */
454
455                 if( G.curscreen->scenenr== -2) {
456                         if(curarea->winy <50) {
457                                 sa= closest_bigger_area();
458                                 areawinset(sa->win);
459                         }
460                         activate_databrowse((ID *)G.scene, ID_SCE, 0, B_INFOSCE,
461                                                                                         &G.curscreen->scenenr, do_info_buttons);
462                         return;
463                 }
464                 if( G.curscreen->scenenr < 0) return;
465
466                 sce= G.main->scene.first;
467                 nr= 1;
468                 while(sce) {
469                         if(nr==G.curscreen->scenenr) {
470                                 if(sce!=G.scene) set_scene(sce);
471                                 break;
472                         }
473                         nr++;
474                         sce= sce->id.next;
475                 }
476                 /* last item: NEW SCENE */
477                 if(sce==0) {
478                         nr= pupmenu("Add scene%t|Empty%x0|Link Objects%x1|Link ObData%x2|Full Copy%x3");
479                         if(nr<0) return;
480                         sce= copy_scene(G.scene, nr);
481                         set_scene(sce);
482                 }
483                 countall();
484                 BIF_preview_changed(ID_TE);
485
486                 break;
487         case B_INFODELSCE:
488
489                 if(G.scene->id.prev) sce= G.scene->id.prev;
490                 else if(G.scene->id.next) sce= G.scene->id.next;
491                 else return;
492                 if(okee("Delete current scene")) {
493                         /* Note, anything besides free_libblock needs to be added in
494                          * Python Scene.c for Blender.Scene.Unlink() */
495                         
496                         
497                         /* exit modes... could become single call once */
498                         exit_editmode(EM_FREEDATA|EM_WAITCURSOR);
499                         exit_paint_modes();
500                         
501                         /* check all sets */
502                         for (sce1= G.main->scene.first; sce1; sce1= sce1->id.next) {
503                                 if(sce1->set == G.scene) sce1->set= 0;
504                         }
505                         
506                         /* check all sequences */
507                         clear_scene_in_allseqs(G.scene);
508
509                         /* check render layer nodes in other scenes */
510                         clear_scene_in_nodes(G.scene);
511                         
512                         /* al screens */
513                         
514                         for (sc= G.main->screen.first; sc; sc= sc->id.next ) {
515                                 if(sc->scene == G.scene) sc->scene= sce;
516                         }
517                         free_libblock(&G.main->scene, G.scene);
518                         set_scene(sce);
519                         countall();
520                 }
521
522                 break;
523         }
524 }
525
526 static void check_packAll()
527 {
528         // first check for dirty images
529         Image *ima;
530
531         for(ima = G.main->image.first; ima; ima= ima->id.next) {
532                 if (ima->ibufs.first) { /* XXX FIX */
533                         ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
534
535                         if (ibuf && (ibuf->userflags &= IB_BITMAPDIRTY))
536                                 break;
537                 }
538         }
539         
540         if (ima == NULL || okee("Some images are painted on. These changes will be lost. Continue ?")) {
541                 packAll();
542                 G.fileflags |= G_AUTOPACK;
543         }
544 }
545
546 #ifdef _WIN32
547 static void copy_game_dll(char *dll_filename, char *source_dir, char *dest_dir)
548 {
549         char source_filename[FILE_MAX];
550         char dest_filename[FILE_MAX];
551
552         strcpy( source_filename, source_dir );
553         strcat( source_filename, dll_filename );
554
555         strcpy( dest_filename, dest_dir );
556         strcat( dest_filename, dll_filename );
557         
558         if(!BLI_exists(dest_filename)) {
559                 BLI_copy_fileops( source_filename, dest_filename );
560         }
561 }
562
563 static void copy_all_game_dlls(char *str)
564 {
565 #define GAME_DLL_COUNT          7
566         char *game_dll_list[GAME_DLL_COUNT]={"gnu_gettext.dll", "libpng.dll", "libtiff.dll", "pthreadVC2.dll", "python25.dll", "SDL.dll", "zlib.dll"};
567
568         char dest_dir[FILE_MAX];
569         char source_dir[FILE_MAX];
570         int i;
571
572         strcpy(source_dir, get_install_dir());
573         strcat(source_dir, "\\");
574         BLI_split_dirfile_basic(str, dest_dir, NULL);
575
576         for (i= 0; i< GAME_DLL_COUNT; i++) {
577                 copy_game_dll(game_dll_list[i], source_dir, dest_dir );
578         };
579 }
580 #endif
581
582 static int write_runtime(char *str, char *exename)
583 {
584         char *freestr= NULL;
585         char *ext = 0;
586
587 #ifdef _WIN32
588         ext = ".exe";
589 #endif
590
591 #ifdef __APPLE__
592         ext = ".app";
593 #endif
594         if (ext && (!BLI_testextensie(str, ext))) {
595                 freestr= MEM_mallocN(strlen(str) + strlen(ext) + 1, "write_runtime_check");
596                 sprintf(freestr,"%s%s", str, ext);
597                 str= freestr;
598         }
599
600         if (!BLI_exists(str) || saveover(str))
601                 BLO_write_runtime(str, exename);
602
603         if (freestr)
604                 MEM_freeN(freestr);
605  
606         return 0;
607 }
608
609 static void write_runtime_check_dynamic(char *str) 
610 {
611         write_runtime(str, "blenderdynplayer.exe");
612 }
613
614 static void write_runtime_check(char *str) 
615 {
616         char player[128];
617
618         strcpy(player, "blenderplayer");
619
620 #ifdef _WIN32
621         strcat(player, ".exe");
622 #endif
623
624 #ifdef __APPLE__
625         strcat(player, ".app");
626 #endif
627
628         write_runtime(str, player);
629
630 #ifdef _WIN32
631         // get a list of the .DLLs in the Blender folder and copy all of these to the destination folder if they don't exist
632         copy_all_game_dlls(str);
633 #endif
634 }
635
636
637 /* end keyed functions */
638
639 /************************** MAIN MENU *****************************/
640 /************************** FILE *****************************/
641
642
643 static void do_info_file_importmenu(void *arg, int event)
644 {
645         ScrArea *sa;
646
647         if(curarea->spacetype==SPACE_INFO) {
648                 sa= find_biggest_area_of_type(SPACE_SCRIPT);
649                 if (!sa) sa= closest_bigger_area();
650                 areawinset(sa->win);
651         }
652
653         /* events >=3 are registered bpython scripts */
654         if (event >= 3) {
655                 BPY_menu_do_python(PYMENU_IMPORT, event - 3);
656                 BIF_undo_push("Import file");
657         }
658         else {
659                 switch(event) {
660                                                                         
661                 case 0: /* DXF */
662                         activate_fileselect(FILE_BLENDER, "Import DXF", G.sce, BIF_read_file);
663                         break;
664                 case 1: /* VRML 1.0 */
665                         activate_fileselect(FILE_BLENDER, "Import VRML 1.0", G.sce, BIF_read_file);
666                         break;
667                 case 2: /* STL */
668                         activate_fileselect(FILE_BLENDER, "Import STL", G.sce, BIF_read_file);
669                         break;
670
671                 }
672         }
673         allqueue(REDRAWINFO, 0);
674 }
675
676 static uiBlock *info_file_importmenu(void *arg_unused)
677 {
678         uiBlock *block;
679         short yco = 20, menuwidth = 120;
680         BPyMenu *pym;
681         int i = 0;
682
683         block= uiNewBlock(&curarea->uiblocks, "importmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
684         uiBlockSetButmFunc(block, do_info_file_importmenu, NULL);
685         //uiBlockSetXOfs(block, -50);  // offset to parent button
686         
687         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "VRML 1.0...",
688                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 1, "");
689         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "DXF...",
690                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 0, "");
691         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "STL...",
692                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "");
693
694         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
695
696         for (pym = BPyMenuTable[PYMENU_IMPORT]; pym; pym = pym->next, i++) {
697                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i+3, pym->tooltip?pym->tooltip:pym->filename);
698         }
699
700         uiBlockSetDirection(block, UI_RIGHT);
701         uiTextBoundsBlock(block, 60);
702
703         return block;
704 }
705
706 static void do_info_file_exportmenu(void *arg, int event)
707 {
708         ScrArea *sa;
709
710         if(curarea->spacetype==SPACE_INFO) {
711                 sa= find_biggest_area_of_type(SPACE_SCRIPT);
712                 if (!sa) sa= closest_bigger_area();
713                 areawinset(sa->win);
714         }
715
716         /* events >=3 are registered bpython scripts */
717         if (event >= 3) BPY_menu_do_python(PYMENU_EXPORT, event - 3);
718
719         else switch(event) {
720                                                                         
721         case 0:
722                 write_vrml_fs();
723                 break;
724         case 1:
725                 write_dxf_fs();
726                 break;
727         case 2:
728                 write_stl_fs();
729                 break;
730         }
731         allqueue(REDRAWINFO, 0);
732 }
733
734 static uiBlock *info_file_exportmenu(void *arg_unused)
735 {
736         uiBlock *block;
737         short yco = 20, menuwidth = 120;
738         BPyMenu *pym;
739         int i = 0;
740
741         block= uiNewBlock(&curarea->uiblocks, "exportmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
742         uiBlockSetButmFunc(block, do_info_file_exportmenu, NULL);
743         //uiBlockSetXOfs(block, -50);  // offset to parent button
744
745         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "VRML 1.0...|Ctrl F2",
746                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 0, "");
747         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "DXF...|Shift F2",
748                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 1, "");
749         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "STL...",
750                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "");
751
752         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
753
754         /* note that we acount for the 3 previous entries with i+3: */
755         for (pym = BPyMenuTable[PYMENU_EXPORT]; pym; pym = pym->next, i++) {
756                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, 
757                                  NULL, 0.0, 0.0, 1, i+3, 
758                                  pym->tooltip?pym->tooltip:pym->filename);
759         }
760
761
762         uiBlockSetDirection(block, UI_RIGHT);
763         uiTextBoundsBlock(block, 60);
764
765         return block;
766 }
767
768 #ifdef WITH_VERSE
769
770 extern ListBase session_list;
771
772 static void do_verse_filemenu(void *arg, int event)
773 {
774         char address[64];               /* lenght of domain name is 63 characters or less */
775         VerseSession *session = NULL;
776         ScrArea *sa;
777         
778         if(curarea->spacetype==SPACE_INFO) {
779                 sa= closest_bigger_area();
780                 areawinset(sa->win);
781         }
782
783         switch(event) {
784                 case 0:
785                         waitcursor(1);
786                         printf("Connecting to localhost!\n");
787                         b_verse_connect("localhost");
788                         waitcursor(0);
789                         break;
790                 case 1:
791                         address[0] = '\0';
792                         if(sbutton(address, 0, 63, "Server:")) {
793                                 waitcursor(1);
794                                 printf("Connecting to %s\n", address);
795                                 b_verse_connect(address);
796                                 waitcursor(0);
797                         }
798                         break;
799                 case 2:
800                         session = session_menu();
801                         if(session) {
802                                 printf("Disconnecting session: %s!\n", session->address);
803                                 end_verse_session(session);
804                         }
805                         break;
806                 case 3:
807                         printf("Disconnecting all sessions!\n");
808                         end_all_verse_sessions();
809                         break;
810         case 4:
811             printf("sending get to master server\n");
812             b_verse_ms_get();
813             break;
814         }
815 }
816
817 static uiBlock *verse_filemenu(void *unusedargs)
818 {
819         uiBlock *block;
820         short yco = 20, menuwidth = 120;
821
822         block= uiNewBlock(&curarea->uiblocks, "verse_filemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
823         uiBlockSetButmFunc(block, do_verse_filemenu, NULL);
824                 
825         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Connect to localhost", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
826         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Connect ...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
827         if(session_list.first != NULL) {
828                 if(session_list.first != session_list.last) {
829                         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Disconnect ...",
830                                         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
831                         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Disconnect all",
832                                         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
833                 }
834                 else {
835                         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Disconnect",
836                                         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
837                 }
838                 
839         }
840         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Get Servers", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
841
842         uiBlockSetDirection(block, UI_RIGHT);
843         uiTextBoundsBlock(block, 60);
844
845         return block;
846 }
847 #endif
848
849 static void do_info_filemenu(void *arg, int event)
850 {
851         ScrArea *sa;
852         char dir[FILE_MAX];
853         
854         if(curarea->spacetype==SPACE_INFO) {
855                 sa= closest_bigger_area();
856                 areawinset(sa->win);
857         }
858
859         /* these are no defines, easier this way, the codes are in the function below */
860         switch(event) {
861         case 0:
862                 if (okee("Erase All")) {
863                         if (!BIF_read_homefile(0))
864                                 error("No file ~/.B.blend");
865                 }
866                 break;
867         case 1: /* open */
868                 activate_fileselect(FILE_BLENDER, "Open", G.sce, BIF_read_file);
869                 break;
870         case 3: /* append */
871                 activate_fileselect(FILE_LOADLIB, "Load Library", G.lib, 0);
872                 break;
873         case 4: /* save */
874                 BLI_strncpy(dir, G.sce, FILE_MAX);
875                 untitled(dir);
876                 activate_fileselect(FILE_BLENDER, "Save As", dir, BIF_write_file);
877                 break;
878         case 5:
879                 BLI_strncpy(dir, G.sce, FILE_MAX);
880                 if (untitled(dir)) {
881                         activate_fileselect(FILE_BLENDER, "Save As", dir, BIF_write_file);
882                 } else {
883                         BIF_write_file(dir);
884                         free_filesel_spec(dir);
885                 }
886                 break;
887         case 6: /* save image */
888                 BIF_save_rendered_image_fs();
889                 break;
890         case 7:
891                 activate_imageselect(FILE_LOADLIB, "Load Library", G.lib, 0);
892                 break;
893         case 22: /* save runtime */
894                 activate_fileselect(FILE_SPECIAL, "Save Runtime", "", write_runtime_check);
895                 break;
896         case 23: /* save dynamic runtime */
897                 activate_fileselect(FILE_SPECIAL, "Save Dynamic Runtime", "", write_runtime_check_dynamic);
898                 break;
899         case 24:
900                 BIF_screendump(0);
901                 break;
902         case 25:
903                 BIF_screendump(1);
904                 break;
905         case 13:
906                 exit_usiblender();
907                 break;
908         case 15:        /* recover previous session */
909                 {
910                         extern short winqueue_break; /* editscreen.c */
911                         int save_over, retval = 0;
912                         char str[FILE_MAX];
913                         char scestr[FILE_MAX];
914                         
915                         BLI_strncpy(scestr, G.sce, FILE_MAX);   /* temporal store */
916                         save_over = G.save_over;
917                         BLI_make_file_string("/", str, btempdir, "quit.blend");
918                         retval = BKE_read_file(str, NULL);
919                         
920                         /*we successfully loaded a blend file, get sure that
921                         pointcache works */
922                         if (retval!=0) G.relbase_valid = 1;
923                         
924                         G.save_over = save_over;
925                         strcpy(G.sce, scestr);
926
927                         winqueue_break= 1;      /* leave queues everywhere */
928                 
929                         BKE_reset_undo();
930                         BKE_write_undo("Original");     /* save current state */
931                         refresh_interface_font();
932                 }
933                 break;
934         case 31: /* save default settings */
935                 BIF_write_homefile();
936                 break;
937         case 32:
938                 if (okee("Erase All")) {
939                         if (!BIF_read_homefile(1))
940                                 error("Can't read data from memory!");
941                 }
942                 break;
943         case 35: /* compress toggle */
944                 U.flag ^= (USER_FILECOMPRESS);
945                 break;
946         }
947         
948         allqueue(REDRAWINFO, 0);
949 }
950
951 static void do_info_operecentmenu(void *arg, int event)
952 {
953         struct RecentFile *recent;
954
955         if(event==0 && G.sce[0]) {
956                 BIF_read_file(G.sce);
957         }
958         else {  /* Global */
959                 recent = BLI_findlink(&(G.recent_files), event-1);
960                 BIF_read_file(recent->filename);
961         }
962 }
963
964 static uiBlock *info_openrecentmenu(void *arg_unused)
965 {
966         uiBlock *block;
967         short yco = 20, menuwidth = 120, i;
968         struct RecentFile *recent;
969
970         block= uiNewBlock(&curarea->uiblocks, "info_openrecentmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
971         uiBlockSetButmFunc(block, do_info_operecentmenu, NULL);
972
973         if (G.sce[0]) {
974                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, G.sce, 0, yco-=20,
975                                 menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
976         }
977
978         for (recent = G.recent_files.first, i=0; i<U.recent_files && recent; recent = recent->next, i++) {
979                 if (strcmp(recent->filename, G.sce)!=0) {
980                         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, recent->filename, 0, yco-=20,
981                                         menuwidth, 19, NULL, 0.0, 0.0, 1, i+1, "");
982                 }
983         }
984
985         uiBlockSetDirection(block, UI_RIGHT);
986         uiTextBoundsBlock(block, 60);
987         return block;
988 }
989
990 static void do_info_externalfiles(void *arg, int event)
991 {
992         switch (event) {
993                 
994         case 1: /* pack data */
995                 check_packAll();
996                 break;
997 #if 0
998         case 2: /* unpack to current dir */
999                 unpackAll(PF_WRITE_LOCAL);
1000                 G.fileflags &= ~G_AUTOPACK;
1001                 break;
1002 #endif
1003         case 3: /* unpack data */
1004                 if (buttons_do_unpack() != RET_CANCEL) {
1005                         /* Clear autopack bit only if user selected one of the unpack options */
1006                         G.fileflags &= ~G_AUTOPACK;
1007                 }
1008                 break;
1009         case 10: /* make all paths relative */
1010                 if (G.relbase_valid) {
1011                         int tot,changed,failed,linked;
1012                         char str[512];
1013                         char txtname[24]; /* text block name */
1014                         txtname[0] = '\0';
1015                         makeFilesRelative(txtname, &tot, &changed, &failed, &linked);
1016                         if (failed) sprintf(str, "Make Relative%%t|Total files %i|Changed %i|Failed %i, See Text \"%s\"|Linked %i", tot, changed, failed, txtname, linked);
1017                         else            sprintf(str, "Make Relative%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
1018                         pupmenu(str);
1019                 } else {
1020                         pupmenu("Can't set relative paths with an unsaved blend file");
1021                 }
1022                 break;
1023         case 11: /* make all paths absolute */
1024                 {
1025                         int tot,changed,failed,linked;
1026                         char str[512];
1027                         char txtname[24]; /* text block name */
1028                         txtname[0] = '\0';
1029                         makeFilesAbsolute(txtname, &tot, &changed, &failed, &linked);
1030                         sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
1031                         if (failed) sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i, See Text \"%s\"|Linked %i", tot, changed, failed, txtname, linked);
1032                         else            sprintf(str, "Make Absolute%%t|Total files %i|Changed %i|Failed %i|Linked %i", tot, changed, failed, linked);
1033                         
1034                         pupmenu(str);
1035                 }
1036                 break;
1037         case 12: /* check images exist */
1038                 {
1039                         char txtname[24]; /* text block name */
1040                         txtname[0] = '\0';
1041                         
1042                         /* run the missing file check */
1043                         checkMissingFiles( txtname );
1044                         
1045                         if (txtname[0] == '\0') {
1046                                 okee("No external files missing");
1047                         } else {
1048                                 char str[128];
1049                                 sprintf(str, "Missing files listed in Text \"%s\"", txtname );
1050                                 error(str);
1051                         }
1052                 }
1053                 break;
1054         case 13: /* search for referenced files that are not available  */
1055                 if(curarea->spacetype==SPACE_INFO) {
1056                         ScrArea *sa;
1057                         sa= closest_bigger_area();
1058                         areawinset(sa->win);
1059                 }
1060                 activate_fileselect(FILE_SPECIAL, "Find Missing Files", "", findMissingFiles);
1061                 break;
1062         }
1063         
1064         allqueue(REDRAWINFO, 0);
1065 }
1066
1067 static uiBlock *info_externalfiles(void *arg_unused)
1068 {
1069         uiBlock *block;
1070         short yco = 20, menuwidth = 120;
1071
1072         block= uiNewBlock(&curarea->uiblocks, "info_externalfiles", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1073         uiBlockSetButmFunc(block, do_info_externalfiles, NULL);
1074
1075         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pack into .blend file",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1076 #if 0
1077         uiDefBut(block, BUTM, 1, "Unpack Data to current dir",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Removes all packed files from the project and saves them to the current directory");
1078 #endif
1079         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Unpack into Files...",                           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1080
1081         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1082         
1083         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Relative",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 10, "");
1084         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Absolute",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 11, "");
1085         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Report Missing Files...",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 12, "");
1086         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Missing Files...",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 13, "");
1087
1088         uiBlockSetDirection(block, UI_RIGHT);
1089         uiTextBoundsBlock(block, 60);
1090         return block;
1091 }
1092
1093 static uiBlock *info_filemenu(void *arg_unused)
1094 {
1095         uiBlock *block;
1096         short yco=0;
1097         short menuwidth=120;
1098
1099         block= uiNewBlock(&curarea->uiblocks, "info_filemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1100         uiBlockSetButmFunc(block, do_info_filemenu, NULL);
1101         
1102         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "New|Ctrl X",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
1103         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Open...|F1",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
1104 #ifdef WITH_VERSE
1105         uiDefIconTextBlockBut(block, verse_filemenu, NULL, ICON_RIGHTARROW_THIN, "Verse", 0, yco-=20, menuwidth, 19, "");
1106 #endif
1107         uiDefIconTextBlockBut(block, info_openrecentmenu, NULL, ICON_RIGHTARROW_THIN, "Open Recent",0, yco-=20, 120, 19, "");
1108         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Recover Last Session",                           0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, "");
1109
1110         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1111
1112         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save|Ctrl W",                            0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
1113         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save As...|F2",                  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
1114         
1115         if(U.flag & USER_FILECOMPRESS) {
1116                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Compress File",     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 35, "Enable file compression");
1117         } else {
1118                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Compress File",   0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 35, "Enable file compression");
1119         }
1120
1121         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1122
1123         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Rendered Image...|F3",                      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
1124         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Screenshot Subwindow|Ctrl F3",                   0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 24, "");
1125         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Screenshot All|Ctrl Shift F3",                   0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 25, "");
1126 #if GAMEBLENDER == 1
1127         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Game As Runtime...",                        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 22, "");
1128 #ifdef _WIN32
1129 //       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Dynamic Runtime...",               0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 23, "");
1130 #endif
1131 #endif
1132         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1133
1134         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Default Settings|Ctrl U",                   0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 31, "");
1135         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Load Factory Settings",                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 32, "");
1136
1137
1138         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1139
1140         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Append or Link|Shift F1",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
1141         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Append or Link (Image Browser)|Ctrl F1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
1142         uiDefIconTextBlockBut(block, info_file_importmenu, NULL, ICON_RIGHTARROW_THIN, "Import", 0, yco-=20, menuwidth, 19, "");
1143         uiDefIconTextBlockBut(block, info_file_exportmenu, NULL, ICON_RIGHTARROW_THIN, "Export", 0, yco-=20, menuwidth, 19, "");
1144         
1145         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1146         
1147         uiDefIconTextBlockBut(block, info_externalfiles, NULL, ICON_RIGHTARROW_THIN, "External Data",0, yco-=20, 120, 19, "");
1148         
1149         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1150         
1151         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Quit Blender|Ctrl Q",                            0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, "");
1152
1153         uiBlockSetDirection(block, UI_DOWN);
1154         uiTextBoundsBlock(block, 80);
1155
1156         return block;
1157 }
1158
1159 /**************************** ADD ******************************/
1160
1161 void do_info_add_meshmenu(void *arg, int event)
1162 {
1163         if (event>=20) {
1164                 BPY_menu_do_python(PYMENU_ADDMESH, event - 20);
1165         } else {
1166                 switch(event) {         
1167                         case 0:
1168                                 /* Plane */
1169                                 add_primitiveMesh(0);
1170                                 break;
1171                         case 1:
1172                                 /* Cube */
1173                                 add_primitiveMesh(1);
1174                                 break;
1175                         case 2:
1176                                 /* Circle */
1177                                 add_primitiveMesh(4);
1178                                 break;
1179                         case 3:
1180                                 /* UVsphere */
1181                                 add_primitiveMesh(11);
1182                                 break;
1183                         case 4:
1184                                 /* IcoSphere */
1185                                 add_primitiveMesh(12);
1186                                 break;
1187                         case 5:
1188                                 /* Cylinder */
1189                                 add_primitiveMesh(5);
1190                                 break;
1191                         case 7:
1192                                 /* Cone */
1193                                 add_primitiveMesh(7);
1194                                 break;
1195                         case 8:
1196                                 /* Grid */
1197                                 add_primitiveMesh(10);
1198                                 break;
1199                         case 9:
1200                                 /* Monkey */
1201                                 add_primitiveMesh(13);
1202                                 break;
1203                         default:
1204                                 break;
1205                 }
1206         }
1207         allqueue(REDRAWINFO, 0);
1208 }
1209
1210 static uiBlock *info_add_meshmenu(void *arg_unused)
1211 {
1212 /*              static short tog=0; */
1213         uiBlock *block;
1214         short yco= 0;
1215         
1216         /* Python Menu */
1217         BPyMenu *pym;
1218         int i=0;
1219         
1220         block= uiNewBlock(&curarea->uiblocks, "add_meshmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1221         uiBlockSetButmFunc(block, do_info_add_meshmenu, NULL);
1222         
1223         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Plane|",                         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1224         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cube|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1225         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Circle|",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1226         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "UVsphere",                       0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1227         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "IcoSphere|",                     0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1228         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cylinder|",                      0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "");
1229         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cone|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 7, "");
1230         uiDefIconTextBut(block, SEPR, 0, ICON_BLANK1, "",                                       0, yco-=6,      160, 6,  NULL, 0.0, 0.0, 0, 0, "");
1231         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grid|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 8, "");
1232         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Monkey|",                        0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 9, "");
1233
1234
1235         pym = BPyMenuTable[PYMENU_ADDMESH];
1236         if (pym) {
1237                 uiDefIconTextBut(block, SEPR, 0, ICON_BLANK1, "",                                       0, yco-=6,      160, 6,  NULL, 0.0, 0.0, 0, 0, "");
1238                 
1239                 for (; pym; pym = pym->next, i++) {
1240                         uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, i+20, pym->tooltip?pym->tooltip:pym->filename);
1241                 }
1242         }
1243                 
1244         uiBlockSetDirection(block, UI_RIGHT);
1245         uiTextBoundsBlock(block, 50);
1246                 
1247         return block;
1248 }
1249
1250 void do_info_add_curvemenu(void *arg, int event)
1251 {
1252
1253         switch(event) {         
1254                 case 0:
1255                         /* Bezier Curve */
1256                         add_primitiveCurve(10);
1257                         break;
1258                 case 1:
1259                         /* Bezier Circle */
1260                         add_primitiveCurve(11);
1261                         break;
1262                 case 2:
1263                         /* NURB Curve */
1264                         add_primitiveCurve(40);
1265                         break;
1266                 case 3:
1267                         /* NURB Circle */
1268                         add_primitiveCurve(41);
1269                         break;
1270                 case 4:
1271                         /* Path */
1272                         add_primitiveCurve(46);
1273                         break;
1274                 default:
1275                         break;
1276         }
1277         allqueue(REDRAWINFO, 0);
1278 }
1279
1280 static uiBlock *info_add_curvemenu(void *arg_unused)
1281 {
1282 /*              static short tog=0; */
1283         uiBlock *block;
1284         short yco= 0;
1285         
1286         block= uiNewBlock(&curarea->uiblocks, "add_curvemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1287         uiBlockSetButmFunc(block, do_info_add_curvemenu, NULL);
1288         
1289         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Bezier Curve|",  0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1290         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Bezier Circle|", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1291         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Curve|",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1292         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Circle",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1293         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Path|",                  0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1294
1295         uiBlockSetDirection(block, UI_RIGHT);
1296         uiTextBoundsBlock(block, 50);
1297                 
1298         return block;
1299 }
1300
1301
1302 void do_info_add_surfacemenu(void *arg, int event)
1303 {
1304
1305         switch(event) {         
1306                 case 0:
1307                         /* Curve */
1308                         add_primitiveNurb(0);
1309                         break;
1310                 case 1:
1311                         /* Circle */
1312                         add_primitiveNurb(1);
1313                         break;
1314                 case 2:
1315                         /* Surface */
1316                         add_primitiveNurb(2);
1317                         break;
1318                 case 3:
1319                         /* Tube */
1320                         add_primitiveNurb(3);
1321                         break;
1322                 case 4:
1323                         /* Sphere */
1324                         add_primitiveNurb(4);
1325                         break;
1326                 case 5:
1327                         /* Donut */
1328                         add_primitiveNurb(5);
1329                         break;
1330                 default:
1331                         break;
1332         }
1333         allqueue(REDRAWINFO, 0);
1334 }
1335
1336 static uiBlock *info_add_surfacemenu(void *arg_unused)
1337 {
1338 /*              static short tog=0; */
1339         uiBlock *block;
1340         short yco= 0;
1341         
1342         block= uiNewBlock(&curarea->uiblocks, "add_surfacemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1343         uiBlockSetButmFunc(block, do_info_add_surfacemenu, NULL);
1344         
1345         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Curve|",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1346         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Circle|",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1347         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Surface|", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1348         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Tube",             0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1349         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Sphere|",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1350         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Donut|",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "");
1351         uiBlockSetDirection(block, UI_RIGHT);
1352         uiTextBoundsBlock(block, 50);
1353                 
1354         return block;
1355 }
1356
1357 void do_info_add_metamenu(void *arg, int event)
1358 {
1359
1360         switch(event) {         
1361                 case 0:
1362                         /* Ball */
1363                         add_primitiveMball(1);
1364                         break;
1365                 case 1:
1366                         /* Tube */
1367                         add_primitiveMball(2);
1368                         break;
1369                 case 2:
1370                         /* Plane */
1371                         add_primitiveMball(3);
1372                         break;
1373                 case 3:
1374                         /* Elipsoid */
1375                         add_primitiveMball(4);
1376                         break;
1377                 case 4:
1378                         /* Cube */
1379                         add_primitiveMball(5);
1380                         break;
1381                 default:
1382                         break;
1383         }
1384         allqueue(REDRAWINFO, 0);
1385 }
1386
1387
1388 static uiBlock *info_add_metamenu(void *arg_unused)
1389 {
1390 /*              static short tog=0; */
1391         uiBlock *block;
1392         short xco= 0;
1393         
1394         block= uiNewBlock(&curarea->uiblocks, "add_metamenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1395         uiBlockSetButmFunc(block, do_info_add_metamenu, NULL);
1396         
1397         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,"Meta Ball|",              0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1398         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Tube|",             0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1399         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Plane|",            0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1400         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Ellipsoid|",        0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1401         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Cube|",             0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1402
1403         uiBlockSetDirection(block, UI_RIGHT);
1404         uiTextBoundsBlock(block, 50);
1405                 
1406         return block;
1407 }
1408
1409 void do_info_add_lampmenu(void *arg, int event)
1410 {
1411
1412         switch(event) {         
1413                 case 0: /* lamp */
1414                         add_objectLamp(LA_LOCAL);
1415                         break;
1416                 case 1: /* sun */
1417                         add_objectLamp(LA_SUN);
1418                         break;
1419                 case 2: /* spot */
1420                         add_objectLamp(LA_SPOT);
1421                         break;
1422                 case 3: /* hemi */
1423                         add_objectLamp(LA_HEMI);
1424                         break;
1425                 case 4: /* area */
1426                         add_objectLamp(LA_AREA);
1427                         break;
1428                 case 5: /* YafRay photon lamp */
1429                         if (G.scene->r.renderer==R_YAFRAY)
1430                                 add_objectLamp(LA_YF_PHOTON);
1431                         break;
1432                 default:
1433                         break;
1434         }
1435         allqueue(REDRAWINFO, 0);
1436 }
1437
1438 static uiBlock *info_add_lampmenu(void *arg_unused)
1439 {
1440 /*              static short tog=0; */
1441         uiBlock *block;
1442         short yco= 0;
1443         
1444         block= uiNewBlock(&curarea->uiblocks, "add_lampmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1445         uiBlockSetButmFunc(block, do_info_add_lampmenu, NULL);
1446         
1447         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Lamp|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1448         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Sun|",                           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1449         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Spot|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1450         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hemi|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1451         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Area|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1452         if (G.scene->r.renderer==R_YAFRAY)
1453                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Photon|",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "");
1454         
1455         uiBlockSetDirection(block, UI_RIGHT);
1456         uiTextBoundsBlock(block, 50);
1457                 
1458         return block;
1459 }
1460
1461 static void do_info_add_groupmenu(void *arg, int event)
1462 {
1463         Object *ob;
1464         
1465         add_object_draw(OB_EMPTY);
1466         ob= OBACT;
1467         
1468         ob->dup_group= BLI_findlink(&G.main->group, event);
1469         if(ob->dup_group) {
1470                 id_us_plus((ID *)ob->dup_group);
1471                 ob->transflag |= OB_DUPLIGROUP;
1472                 DAG_scene_sort(G.scene);
1473         }
1474 }
1475
1476
1477 static uiBlock *info_add_groupmenu(void *arg_unused)
1478 {
1479         Group *group;
1480         uiBlock *block;
1481         short yco= 0;
1482         int a;
1483         
1484         block= uiNewBlock(&curarea->uiblocks, "add_groupmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1485         uiBlockSetButmFunc(block, do_info_add_groupmenu, NULL);
1486         
1487         for(a=0, group= G.main->group.first; group; group= group->id.next, a++) {
1488                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, group->id.name+2,                         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, a, "");
1489         }
1490         
1491         uiBlockSetDirection(block, UI_RIGHT);
1492         uiTextBoundsBlock(block, 50);
1493                 
1494         return block;
1495 }
1496
1497 void do_info_addmenu(void *arg, int event)
1498 {
1499         if (event>=20) {
1500                 BPY_menu_do_python(PYMENU_ADD, event - 20);
1501         } else {
1502                 switch(event) {         
1503                         case 0:
1504                                 /* Mesh */
1505                                 break;
1506                         case 1:
1507                                 /* Curve */
1508                                 break;
1509                         case 2:
1510                                 /* Surface */
1511                                 break;
1512                         case 3:
1513                                 /* Metaball */
1514                                 break;
1515                         case 4:
1516                                 /* Text (argument is discarded) */
1517                                 add_primitiveFont(event);
1518                                 break;
1519                         case 5:
1520                                 /* Empty */
1521                                 add_object_draw(OB_EMPTY);
1522                                 break;
1523                         case 6:
1524                                 /* Camera */
1525                                 add_object_draw(OB_CAMERA);
1526                                 break;
1527                         case 8:
1528                                 /* Armature */
1529                                 add_primitiveArmature(OB_ARMATURE);
1530                                 break;
1531                         case 9:
1532                                 /* Lattice */
1533                                 add_object_draw(OB_LATTICE);
1534                                 break;
1535                         case 10:
1536                                 /* group instance not yet */
1537                                 break;
1538                         default:
1539                                 break;
1540                 }
1541         }
1542         allqueue(REDRAWINFO, 0);
1543 }
1544
1545
1546 static uiBlock *info_addmenu(void *arg_unused)
1547 {
1548 /*              static short tog=0; */
1549         uiBlock *block;
1550         BPyMenu *pym;
1551         int i=0;
1552         short yco= 0;
1553
1554         block= uiNewBlock(&curarea->uiblocks, "addmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1555         uiBlockSetButmFunc(block, do_info_addmenu, NULL);
1556         
1557         uiDefIconTextBlockBut(block, info_add_meshmenu, NULL, ICON_RIGHTARROW_THIN, "Mesh", 0, yco-=20, 120, 19, "");
1558         uiDefIconTextBlockBut(block, info_add_curvemenu, NULL, ICON_RIGHTARROW_THIN, "Curve", 0, yco-=20, 120, 19, "");
1559         uiDefIconTextBlockBut(block, info_add_surfacemenu, NULL, ICON_RIGHTARROW_THIN, "Surface", 0, yco-=20, 120, 19, "");
1560         uiDefIconTextBlockBut(block, info_add_metamenu, NULL, ICON_RIGHTARROW_THIN, "Meta", 0, yco-=20, 120, 19, "");
1561         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Text",                           0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 4, "");
1562         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Empty",                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 5, "");
1563         
1564         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1565         
1566         uiDefIconTextBlockBut(block, info_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, "");
1567         
1568         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1569         
1570         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Camera",                         0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 6, "");
1571         uiDefIconTextBlockBut(block, info_add_lampmenu, NULL, ICON_RIGHTARROW_THIN, "Lamp", 0, yco-=20, 120, 19, "");
1572         
1573         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1574         
1575         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Armature",                       0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 8, "");
1576         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Lattice",                        0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 9, "");
1577
1578         pym = BPyMenuTable[PYMENU_ADD];
1579         if (pym) {
1580                 uiDefIconTextBut(block, SEPR, 0, ICON_BLANK1, "",                                       0, yco-=6,      1620, 6,  NULL, 0.0, 0.0, 0, 0, "");
1581                 
1582                 for (; pym; pym = pym->next, i++) {
1583                         uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, i+20, pym->tooltip?pym->tooltip:pym->filename);
1584                 }
1585         }
1586
1587         uiBlockSetDirection(block, UI_DOWN);
1588         uiTextBoundsBlock(block, 80);
1589                 
1590         return block;
1591 }
1592
1593 /************************** GAME *****************************/
1594
1595 void do_info_game_glslmenu(void *arg, int event)
1596 {
1597         switch (event) {
1598         case G_FILE_GLSL_NO_LIGHTS:
1599         case G_FILE_GLSL_NO_SHADERS:
1600         case G_FILE_GLSL_NO_SHADOWS:
1601         case G_FILE_GLSL_NO_RAMPS:
1602         case G_FILE_GLSL_NO_NODES:
1603         case G_FILE_GLSL_NO_EXTRA_TEX:
1604                 G.fileflags ^= event;
1605                 GPU_materials_free();
1606                 allqueue(REDRAWINFO, 0);
1607                 allqueue(REDRAWVIEW3D, 0);
1608                 break;
1609         default:
1610                 break;
1611         }       
1612 }
1613
1614 static uiBlock *info_game_glslmenu(void *arg_unused)
1615 {
1616         uiBlock *block;
1617         short yco= 0, menuwidth=160;
1618         int check;
1619         
1620         block= uiNewBlock(&curarea->uiblocks, "game_glslmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1621         uiBlockSetButmFunc(block, do_info_game_glslmenu, NULL);
1622
1623         check = (G.fileflags & G_FILE_GLSL_NO_LIGHTS)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
1624         uiDefIconTextBut(block, BUTM, 1, check, "Enable Lights",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_LIGHTS,
1625                 "Enable using lights in GLSL materials.");
1626         check = (G.fileflags & G_FILE_GLSL_NO_SHADERS)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
1627         uiDefIconTextBut(block, BUTM, 1, check, "Enable Shaders",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_SHADERS,
1628                 "Enable using shaders other than Lambert in GLSL materials");
1629         check = (G.fileflags & G_FILE_GLSL_NO_SHADOWS)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
1630         uiDefIconTextBut(block, BUTM, 1, check, "Enable Shadows",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_SHADOWS,
1631                 "Enable using shadows in GLSL materials");
1632         check = (G.fileflags & G_FILE_GLSL_NO_RAMPS)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
1633         uiDefIconTextBut(block, BUTM, 1, check, "Enable Ramps",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_RAMPS,
1634                 "Enable using ramps in GLSL materials");
1635         check = (G.fileflags & G_FILE_GLSL_NO_NODES)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
1636         uiDefIconTextBut(block, BUTM, 1, check, "Enable Nodes",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_NODES,
1637                 "Enable using nodes in GLSL materials.");
1638         check = (G.fileflags & G_FILE_GLSL_NO_EXTRA_TEX)? ICON_CHECKBOX_DEHLT: ICON_CHECKBOX_HLT;
1639         uiDefIconTextBut(block, BUTM, 1, check, "Enable Extra Textures",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GLSL_NO_EXTRA_TEX,
1640                 "Enable using texture channels other than Col and Alpha in GLSL materials.");
1641
1642         uiBlockSetDirection(block, UI_RIGHT);
1643         uiTextBoundsBlock(block, 50);
1644                 
1645         return block;
1646 }
1647
1648 static void do_info_gamemenu(void *arg, int event)
1649 {
1650         switch (event) {
1651         case G_FILE_ENABLE_ALL_FRAMES:
1652         case G_FILE_DISPLAY_LISTS:
1653         case G_FILE_SHOW_FRAMERATE:
1654         case G_FILE_SHOW_DEBUG_PROPS:
1655         case G_FILE_AUTOPLAY:
1656         case G_FILE_GAME_TO_IPO:
1657         case G_FILE_SHOW_PHYSICS:
1658                 G.fileflags ^= event;
1659                 break;
1660         case G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL:
1661                 G.fileflags &= ~(G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL);
1662                 break;
1663         case G_FILE_GAME_MAT:
1664                 G.fileflags |= G_FILE_GAME_MAT;
1665                 G.fileflags &= ~G_FILE_GAME_MAT_GLSL;
1666                 break;
1667         case G_FILE_GAME_MAT_GLSL:
1668                 if(!GPU_extensions_minimum_support())
1669                         error("GLSL not supported with this graphics card or driver.");
1670                 G.fileflags |= (G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL);
1671                 break;
1672         default:
1673                 ; /* ignore the rest */
1674         }
1675 }
1676
1677 static uiBlock *info_gamemenu(void *arg_unused)
1678 {
1679 /*              static short tog=0; */
1680         uiBlock *block;
1681         short yco= 0;
1682         short menuwidth=120;
1683         
1684         block= uiNewBlock(&curarea->uiblocks, "gamemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1685         uiBlockSetButmFunc(block, do_info_gamemenu, NULL);
1686         
1687         uiDefIconTextBut(block, BUTM, B_STARTGAME, ICON_BLANK1, "Start Game|P",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
1688         
1689         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 1, 0, "");
1690
1691
1692         if(G.fileflags & G_FILE_ENABLE_ALL_FRAMES) {
1693                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Enable All Frames",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_ENABLE_ALL_FRAMES, "");
1694         } else {
1695                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Enable All Frames",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_ENABLE_ALL_FRAMES, "");
1696         }
1697         
1698         if(G.fileflags & G_FILE_GAME_TO_IPO) {
1699                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Record Game Physics to IPO",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_TO_IPO, "");
1700         } else {
1701
1702         if(G.fileflags & G_FILE_DISPLAY_LISTS) {
1703                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Generate Display Lists",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_DISPLAY_LISTS, "");
1704         } else {
1705                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Generate Display Lists",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_DISPLAY_LISTS, "");
1706         }       
1707                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Record Game Physics to IPO",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_TO_IPO, "");
1708         }
1709         
1710         if(G.fileflags & G_FILE_SHOW_FRAMERATE) {
1711                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Show Framerate and Profile",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_FRAMERATE, "");
1712         } else {
1713                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Show Framerate and Profile",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_FRAMERATE, "");
1714         }
1715
1716
1717         if(G.fileflags & G_FILE_SHOW_PHYSICS) {
1718                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Show Physics Visualization",                0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_PHYSICS, "");
1719         } else {
1720                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Show Physics Visualization",              0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_PHYSICS, "");
1721         }
1722         
1723         if(G.fileflags & G_FILE_SHOW_DEBUG_PROPS) {
1724                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Show Debug Properties",             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_DEBUG_PROPS, "");
1725         } else {
1726                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Show Debug Properties",           0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_SHOW_DEBUG_PROPS, "");
1727         }
1728
1729         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 1, 0, "");
1730
1731         if(!(G.fileflags & G_FILE_GAME_MAT)) {
1732                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Texture Face Materials",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
1733         } else {
1734                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Texture Face Materials",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL, "");
1735         }       
1736
1737         if((G.fileflags & G_FILE_GAME_MAT) && !(G.fileflags & G_FILE_GAME_MAT_GLSL)) {
1738                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Blender Multitexture Materials",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
1739         } else {
1740                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Blender Multitexture Materials",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_MAT, "");
1741         }       
1742
1743         if((G.fileflags & G_FILE_GAME_MAT) && (G.fileflags & G_FILE_GAME_MAT_GLSL)) {
1744                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Blender GLSL Materials",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
1745         } else {
1746                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Blender GLSL Materials",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_GAME_MAT_GLSL, "");
1747         }       
1748
1749         uiDefIconTextBlockBut(block, info_game_glslmenu, NULL, ICON_RIGHTARROW_THIN, "GLSL Material Settings", 0, yco-=20, menuwidth, 19, "");
1750         
1751         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 1, 0, "");
1752
1753         if(G.fileflags & G_FILE_AUTOPLAY) {
1754                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Autostart",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_AUTOPLAY, "");
1755         } else {
1756                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Autostart",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_AUTOPLAY, "");
1757         }
1758
1759         uiBlockSetDirection(block, UI_DOWN);
1760         uiTextBoundsBlock(block, 70);
1761         
1762         return block;
1763 }
1764 /************************** TIMELINE *****************************/
1765
1766 static void do_info_timelinemenu(void *arg, int event)
1767 {
1768         /* needed to check for valid selected objects */
1769         Base *base=NULL;
1770         Object *ob=NULL;
1771         //char file[FILE_MAXDIR+FILE_MAXFILE];
1772
1773         base= BASACT;
1774         if (base) ob= base->object;
1775
1776         switch(event) {
1777         case 1:
1778                 /* Show Keyframes */
1779                 if (!ob) error("Select an object before showing its keyframes");
1780                 else set_ob_ipoflags();
1781                 break;
1782         case 2:
1783                 /* Show and select Keyframes */
1784                 if (!ob) error("Select an object before showing and selecting its keyframes");
1785                 else select_select_keys();
1786                         break;
1787         case 3:
1788                 /* select next keyframe */
1789                 if (!ob) error("Select an object before selecting its next keyframe");
1790                 else nextkey_obipo(1);
1791                         break;
1792         case 4:
1793                 /* select previous keyframe */
1794                 if (!ob) error("Select an object before selecting its previous keyframe");
1795                 else nextkey_obipo(-1);
1796                 break;
1797                 case 5:
1798         /* next keyframe */
1799                 if (!ob) error("Select an object before going to its next keyframe");
1800                 else movekey_obipo(1);
1801                         break;
1802                 case 6:
1803         /* previous keyframe */
1804                 if (!ob) error("Select an object before going to its previous keyframe");
1805                 else movekey_obipo(-1);
1806                 break;
1807         case 7:
1808                 /* next frame */
1809                 CFRA++;
1810                 update_for_newframe();
1811                 break;
1812                 case 8:
1813                 /* previous frame */
1814                 CFRA--;
1815                 if(CFRA<1) CFRA=1;
1816                 update_for_newframe();
1817                 break;
1818         case 9:
1819                 /* forward 10 frames */
1820                 CFRA+= 10;
1821                 update_for_newframe();
1822                 break;
1823         case 10:
1824                 /* back 10 frames */
1825                 CFRA-= 10;
1826                 if(CFRA<1) CFRA=1;
1827                 update_for_newframe();
1828                 break;
1829         case 11:
1830                 /* end frame */
1831                 CFRA= EFRA;
1832                 update_for_newframe();
1833                 break;
1834         case 12:
1835                 /* start frame */
1836                 CFRA= SFRA;
1837                 update_for_newframe();
1838                 break;
1839         case 13: 
1840                 /* previous keyframe */
1841                 nextprev_timeline_key(-1);
1842                 break;
1843         case 14:
1844                 /* next keyframe */
1845                 nextprev_timeline_key(1);
1846                 break;
1847         }
1848         allqueue(REDRAWINFO, 0);
1849 }
1850
1851 static uiBlock *info_timelinemenu(void *arg_unused)
1852 {
1853 /*              static short tog=0; */
1854         uiBlock *block;
1855         char str[26];
1856         short yco= 0;
1857         short menuwidth=120;
1858
1859         block= uiNewBlock(&curarea->uiblocks, "timelinemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1860         uiBlockSetButmFunc(block, do_info_timelinemenu, NULL);
1861         
1862         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Keyframes|K",               0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
1863         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show and Select Keyframes|Shift K",0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
1864         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Next Keyframe|PageUp",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
1865         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Previous Keyframe|PageDown",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
1866
1867         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1868
1869         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Next Ob-Keyframe|Shift PageUp",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
1870         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Previous Ob-Keyframe|Shift PageDown",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
1871
1872         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Next Keyframe|Ctrl PageUp",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, "");
1873         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Previous Keyframe|Ctrl PageDown",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 14, "");
1874         
1875         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1876
1877         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Next Frame|RightArrow",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
1878         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Previous Frame|LeftArrow",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
1879         
1880         sprintf(str, "Forward %d Frames|UpArrow", G.scene->jumpframe);
1881         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, str,      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
1882         sprintf(str, "Back %d Frames|DownArrow", G.scene->jumpframe);
1883         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, str,      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
1884
1885         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1886
1887         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "End Frame|Shift RightArrow",     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
1888         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Start Frame|Shift LeftArrow",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
1889
1890         uiBlockSetDirection(block, UI_DOWN);
1891         uiTextBoundsBlock(block, 80);
1892
1893         return block;
1894 }
1895
1896 /************************** RENDER *****************************/
1897
1898 void do_info_render_bakemenu(void *arg, int event)
1899 {
1900         switch (event) {
1901         case 6:
1902                 G.scene->r.bake_flag ^= event;
1903                 break;
1904         default:
1905                 objects_bake_render_ui(event);
1906         }       
1907         
1908         allqueue(REDRAWINFO, 0);
1909 }
1910
1911 static uiBlock *info_render_bakemenu(void *arg_unused)
1912 {
1913         uiBlock *block;
1914         short yco= 0, menuwidth=160;
1915         
1916         block= uiNewBlock(&curarea->uiblocks, "render_bakemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1917         uiBlockSetButmFunc(block, do_info_render_bakemenu, NULL);
1918         
1919         if(G.scene->r.bake_flag & R_BAKE_TO_ACTIVE) {
1920                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Selected to Active",                0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
1921         } else {
1922                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Selected to Active",              0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
1923         }
1924         
1925         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1926         
1927         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Full Render|Ctrl Alt B, 1",                              0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
1928         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Ambient Occlusion|Ctrl Alt B, 2",                                0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
1929         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Normals|Ctrl Alt B, 3",                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
1930         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Texture Only|Ctrl Alt B, 4",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
1931         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Displacement|Ctrl Alt B, 5",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");   
1932
1933         uiBlockSetDirection(block, UI_RIGHT);
1934         uiTextBoundsBlock(block, 50);
1935                 
1936         return block;
1937 }
1938
1939 static void do_info_rendermenu(void *arg, int event)
1940 {
1941         ScrArea *sa;
1942         extern void playback_anim();
1943
1944         /* events >=10 are registered bpython scripts */
1945         if (event >= 10) {
1946                 if(curarea->spacetype==SPACE_INFO) {
1947                         sa= find_biggest_area_of_type(SPACE_SCRIPT);
1948                         if (!sa) sa= closest_bigger_area();
1949                         areawinset(sa->win);
1950                 }
1951
1952                 BPY_menu_do_python(PYMENU_RENDER, event - 10);
1953                 BIF_undo_push("Rendering Script");
1954         }
1955         else {
1956         switch(event) {
1957                         
1958                 case 0:
1959                         BIF_do_render(0);
1960                         break;
1961                 case 1:
1962                         BIF_do_render(1);
1963                         break;
1964
1965                         /* note: dont use select_area() for setting active areas for opengl render */
1966                         /* its hackish and instable... code here was removed */
1967                 
1968                 case 4:
1969                         BIF_toggle_render_display();
1970                         break;
1971                 case 5:
1972                         playback_anim();
1973                         break;
1974                 case 6:
1975                         /* dodgy hack turning on SHIFT key to do a proper render border select
1976                         set_render_border(); only works when 3d window active
1977                         
1978                         This code copied from toolbox.c, only works when 3d window is cameraview */
1979
1980                         if(select_area(SPACE_VIEW3D)) {
1981                                 mainqenter(LEFTSHIFTKEY, 1);
1982                                 mainqenter(BKEY, 1);
1983                                 mainqenter(BKEY, 0);
1984                                 mainqenter(EXECUTE, 1);
1985                                 mainqenter(LEFTSHIFTKEY, 0);
1986                         }
1987
1988                         break;
1989
1990                 case 7:
1991                         extern_set_butspace(F10KEY, 0);
1992                         break;
1993                 }
1994         }
1995         allqueue(REDRAWINFO, 0);
1996 }
1997
1998 static uiBlock *info_rendermenu(void *arg_unused)
1999 {
2000         uiBlock *block;
2001         BPyMenu *pym;
2002         short yco= 0;
2003         short menuwidth=120;
2004         int i=0;
2005         
2006         block= uiNewBlock(&curarea->uiblocks, "rendermenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
2007         uiBlockSetButmFunc(block, do_info_rendermenu, NULL);
2008         
2009         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Render Current Frame|F12",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
2010         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Render Animation|Ctrl F12",              0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
2011         
2012         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
2013         
2014         uiDefIconTextBlockBut(block, info_render_bakemenu, NULL, ICON_RIGHTARROW_THIN, "Bake Render Meshes", 0, yco-=20, 120, 19, "");
2015
2016         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
2017
2018         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Render Buffer|F11",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
2019         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Rendered Animation|Ctrl F11",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
2020
2021         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
2022
2023         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Render Border|Shift B",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
2024
2025         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
2026
2027         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Render Settings|F10",            0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
2028
2029         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
2030
2031         for (pym = BPyMenuTable[PYMENU_RENDER]; pym; pym = pym->next, i++) {
2032                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i+10, pym->tooltip?pym->tooltip:pym->filename);
2033         }
2034
2035         uiBlockSetDirection(block, UI_DOWN);
2036         uiTextBoundsBlock(block, 80);
2037
2038         return block;
2039 }
2040
2041 /************************** HELP *****************************/
2042
2043 static void do_info_help_websitesmenu(void *arg, int event)
2044 {
2045         BPY_menu_do_python(PYMENU_HELPWEBSITES, event);
2046
2047         allqueue(REDRAWVIEW3D, 0);
2048 }
2049
2050
2051 static uiBlock *info_help_websitesmenu(void *arg_unused)
2052 {
2053         uiBlock *block;
2054         BPyMenu *pym;
2055         short yco = 20, menuwidth = 120;
2056         int i = 0;
2057
2058         block= uiNewBlock(&curarea->uiblocks, "info_help_websitesmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
2059         uiBlockSetButmFunc(block, do_info_help_websitesmenu, NULL);
2060         
2061         for (pym = BPyMenuTable[PYMENU_HELPWEBSITES]; pym; pym = pym->next, i++) {
2062                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i, pym->tooltip?pym->tooltip:pym->filename);
2063         }
2064         
2065         uiBlockSetDirection(block, UI_RIGHT);
2066         uiTextBoundsBlock(block, 60);
2067                 
2068         return block;
2069 }
2070
2071 static void do_info_help_systemmenu(void *arg, int event)
2072 {
2073         /* events >=10 are registered bpython scripts */
2074         if (event >= 10) BPY_menu_do_python(PYMENU_HELPSYSTEM, event - 10);
2075         else {
2076                 switch(event) {
2077
2078                 case 1: /* Benchmark */
2079                         /* dodgy hack turning on CTRL ALT SHIFT key to do a benchmark 
2080                          *      rather than copying lines and lines of code from toets.c :( 
2081                          */
2082         
2083                         if(select_area(SPACE_VIEW3D)) {
2084                                 mainqenter(LEFTSHIFTKEY, 1);
2085                                 mainqenter(LEFTCTRLKEY, 1);
2086                                 mainqenter(LEFTALTKEY, 1);
2087                                 mainqenter(TKEY, 1);
2088                                 mainqenter(TKEY, 0);
2089                                 mainqenter(EXECUTE, 1);
2090                                 mainqenter(LEFTSHIFTKEY, 0);
2091                                 mainqenter(LEFTCTRLKEY, 0);
2092                                 mainqenter(LEFTALTKEY, 0);
2093                         }
2094                         break;
2095                 }
2096         }
2097
2098         allqueue(REDRAWVIEW3D, 0);
2099 }
2100
2101
2102 static uiBlock *info_help_systemmenu(void *arg_unused)
2103 {
2104         uiBlock *block;
2105         BPyMenu *pym;
2106         short yco = 20, menuwidth = 120;
2107         int i = 0;
2108
2109         block= uiNewBlock(&curarea->uiblocks, "info_help_systemmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
2110         uiBlockSetButmFunc(block, do_info_help_systemmenu, NULL);
2111         
2112         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Benchmark",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
2113         
2114         for (pym = BPyMenuTable[PYMENU_HELPSYSTEM]; pym; pym = pym->next, i++) {
2115                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i+10, pym->tooltip?pym->tooltip:pym->filename);
2116         }
2117         
2118         uiBlockSetDirection(block, UI_RIGHT);
2119         uiTextBoundsBlock(block, 60);
2120                 
2121         return block;
2122 }
2123
2124 static void do_info_helpmenu(void *arg, int event)
2125 {
2126         ScrArea *sa;
2127
2128         if(curarea->spacetype==SPACE_INFO) {
2129                 sa= find_biggest_area_of_type(SPACE_SCRIPT);
2130                 if (!sa) sa= closest_bigger_area();
2131                 areawinset(sa->win);
2132         }
2133
2134         /* events >=10 are registered bpython scripts */
2135         if (event >= 10) BPY_menu_do_python(PYMENU_HELP, event - 10);
2136         else {
2137                 switch(event) {
2138                                                                         
2139                 case 0: /* About Blender */
2140                         break;
2141                 }
2142         }
2143
2144         allqueue(REDRAWINFO, 0);
2145 }
2146
2147 static uiBlock *info_helpmenu(void *arg_unused)
2148 {
2149 /*              static short tog=0; */
2150         uiBlock *block;
2151         short yco= 0;
2152         short menuwidth=120;
2153         BPyMenu *pym;
2154         int i = 0;
2155         
2156         block= uiNewBlock(&curarea->uiblocks, "info_helpmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
2157         uiBlockSetButmFunc(block, do_info_helpmenu, NULL);
2158         
2159         uiDefIconTextBut(block, BUTM, B_SHOWSPLASH, ICON_BLANK1, "About Blender...",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
2160         
2161         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
2162         
2163         for (pym = BPyMenuTable[PYMENU_HELP]; pym; pym = pym->next, i++) {
2164                 uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i+10, pym->tooltip?pym->tooltip:pym->filename);
2165         }
2166         
2167         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
2168         
2169         uiDefIconTextBlockBut(block, info_help_websitesmenu, NULL, ICON_RIGHTARROW_THIN, "Websites", 0, yco-=20, 120, 19, "");
2170         
2171         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
2172         
2173         uiDefIconTextBlockBut(block, info_help_systemmenu, NULL, ICON_RIGHTARROW_THIN, "System", 0, yco-=20, 120, 19, "");
2174
2175         uiBlockSetDirection(block, UI_DOWN);
2176         uiTextBoundsBlock(block, 80);
2177
2178         return block;
2179 }
2180
2181 /************************** END MAIN MENU *****************************/
2182 /* ugly global yes, for renderwin.c to write to */
2183 char info_time_str[32]="";
2184
2185 static void info_text(int x, int y)
2186 {
2187         Object *ob= OBACT;
2188         extern float hashvectf[];
2189         uintptr_t mem_in_use, mmap_in_use;
2190         unsigned int swatch_color;
2191         float fac1, fac2, fac3;
2192         char infostr[300], memstr[64];
2193         char *headerstr, *s;
2194         int hsize;
2195
2196         mem_in_use= MEM_get_memory_in_use();
2197         mmap_in_use= MEM_get_mapped_memory_in_use();
2198
2199         s= memstr + sprintf(memstr," | Mem:%.2fM ", ((mem_in_use-mmap_in_use)>>10)/1024.0);
2200         if(mmap_in_use)
2201                 sprintf(s,"(%.2fM) ", ((mmap_in_use)>>10)/1024.0);
2202
2203         
2204         if(G.obedit) {
2205                 s = infostr;
2206
2207                 s+= sprintf(s, "%s", G.editModeTitleExtra);
2208                 if(G.obedit->type==OB_MESH) {
2209                         if(G.scene->selectmode & SCE_SELECT_VERTEX)
2210                                 s+= sprintf(s,"Ve:%d-%d | Ed:%d-%d | Fa:%d-%d",
2211                                                 G.totvertsel, G.totvert, G.totedgesel, G.totedge, G.totfacesel, G.totface);
2212                         else if(G.scene->selectmode & SCE_SELECT_EDGE)
2213                                 s+= sprintf(s,"Ed:%d-%d | Fa:%d-%d",
2214                                                 G.totedgesel, G.totedge, G.totfacesel, G.totface);
2215                         else 
2216                                 s+= sprintf(s,"Fa:%d-%d", G.totfacesel, G.totface);
2217                 }
2218                 else if(G.obedit->type==OB_ARMATURE) {
2219                         s+= sprintf(s,"Ve:%d-%d | Bo:%d-%d", G.totvertsel, G.totvert, G.totbonesel, G.totbone);
2220                 }
2221                 else {
2222                         s+= sprintf(s,"Ve:%d-%d", G.totvertsel, G.totvert);
2223                 }
2224
2225                 strcat(s, memstr);
2226         }
2227         else if(ob && (ob->flag & OB_POSEMODE)) {
2228                 sprintf(infostr,"Bo:%d-%d %s",
2229                                         G.totbonesel, G.totbone, memstr);
2230         }
2231         else {
2232                 sprintf(infostr,"Ve:%d | Fa:%d | Ob:%d-%d | La:%d %s | Time:%s | ",
2233                         G.totvert, G.totface, G.totobj, G.totobjsel, G.totlamp, memstr, info_time_str);
2234         }
2235         if(ob) {
2236                 strcat(infostr, ob->id.name+2);
2237         }
2238
2239         if (g_progress_bar && g_progress_info) {
2240                 headerstr= g_progress_info;
2241         } else {
2242                 headerstr= versionstr; 
2243         }
2244
2245         if      (g_progress_bar) {
2246                 hsize = 4 + (138.0 * g_done);
2247                 fac1 = 0.5 * g_done; /* do some rainbow colors on progress */
2248                 fac2 = 1.0;
2249                 fac3 = 0.9;
2250         } else {
2251                 hsize= 30+BIF_GetStringWidth(G.font, headerstr, (U.transopts & USER_TR_BUTTONS));
2252
2253                 /* promise! Never change these lines again! (zr & ton did!) */
2254                 fac1= fabs(hashvectf[ 2*G.version+4]);
2255                 fac2= 0.5+0.1*hashvectf[ G.version+3];
2256                 fac3= 0.7;
2257         }
2258         
2259         swatch_color= hsv_to_cpack(fac1, fac2, fac3);
2260
2261         cpack( swatch_color );
2262         glRecti(x-24,  y-6,  x-30+hsize,        y+14);
2263
2264         glColor3ub(0, 0, 0); /* makes text black colored rect */
2265         
2266         glRasterPos2i(x, y);
2267         BIF_RasterPos(x, y);
2268
2269         BIF_DrawString(G.font, headerstr, (U.transopts & USER_TR_MENUS));
2270         hsize= BIF_GetStringWidth(G.font, headerstr, (U.transopts & USER_TR_BUTTONS));
2271         
2272         BIF_ThemeColor(TH_MENU_TEXT); /* makes text readable on dark theme */
2273         
2274         glRasterPos2i(x+hsize+10,       y);
2275         BIF_RasterPos(x+hsize+10,       y);
2276         
2277         BIF_DrawString(G.font, infostr, (U.transopts & USER_TR_MENUS));
2278 }
2279
2280 void info_buttons(void)
2281 {
2282         uiBlock *block;
2283         short xco= 42;
2284         int xmax;
2285
2286         block= uiNewBlock(&curarea->uiblocks, "header info", UI_EMBOSSN, UI_HELV, curarea->headwin);
2287
2288         if(area_is_active_area(curarea)) uiBlockSetCol(block, TH_HEADER);
2289         else uiBlockSetCol(block, TH_HEADERDESEL);
2290         
2291         if(curarea->flag & HEADER_NO_PULLDOWN) {
2292                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU, ICON_DISCLOSURE_TRI_RIGHT,
2293                                 xco,2,XIC,YIC-2,
2294                                 &(curarea->flag), 0, 0, 0, 0, "Enables display of pulldown menus");
2295         } else {
2296                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU, ICON_DISCLOSURE_TRI_DOWN,
2297                                 xco,2,XIC,YIC-2,
2298                                 &(curarea->flag), 0, 0, 0, 0, "Hides pulldown menus");
2299         }
2300         xco+=XIC;
2301
2302         if((curarea->flag & HEADER_NO_PULLDOWN)==0) {
2303         
2304                 uiBlockSetEmboss(block, UI_EMBOSSP);
2305
2306                 /* the 'xmax - 3' rather than xmax is to prevent some weird flickering where the highlighted
2307                  * menu is drawn wider than it should be. The ypos of -1 is to make it properly fill the
2308                  * height of the header */
2309                 xmax= GetButStringLength("File");
2310                 uiDefPulldownBut(block, info_filemenu, NULL, "File",    xco, -1, xmax-3, 22, "");
2311                 xco+= xmax;
2312
2313                 xmax= GetButStringLength("Add");
2314                 uiDefPulldownBut(block, info_addmenu, NULL, "Add",      xco, -1, xmax-3, 22, "");
2315                 xco+= xmax;
2316
2317                 xmax= GetButStringLength("Timeline");
2318                 uiDefPulldownBut(block, info_timelinemenu, NULL, "Timeline",    xco, -1, xmax-3, 22, "");
2319                 xco+= xmax;
2320
2321                 xmax= GetButStringLength("Game");
2322                 uiDefPulldownBut(block, info_gamemenu, NULL, "Game",    xco, -1, xmax-3, 22, "");
2323                 xco+= xmax;
2324
2325                 xmax= GetButStringLength("Render");
2326                 uiDefPulldownBut(block, info_rendermenu, NULL, "Render",        xco, -1, xmax-3, 22, "");
2327                 xco+= xmax;
2328
2329                 xmax= GetButStringLength("Help");
2330                 uiDefPulldownBut(block, info_helpmenu, NULL, "Help",    xco, -1, xmax-3, 22, "");
2331                 xco+= xmax;
2332
2333         }
2334
2335         /* pack icon indicates a packed file */
2336         
2337         if (G.fileflags & G_AUTOPACK) {
2338                 uiBlockSetEmboss(block, UI_EMBOSSN);
2339                 uiDefIconBut(block, LABEL, 0, ICON_PACKAGE, xco, 0, XIC, YIC, &G.fileflags, 0.0, 0.0, 0, 0, "Indicates this is a Packed file. See File menu.");
2340                 xco += XIC;
2341         }
2342
2343         if (curarea->full == 0) {
2344                 curarea->butspacetype= SPACE_INFO;
2345                 uiBlockSetEmboss(block, UI_EMBOSS);
2346                 uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), 8,0,XIC+10,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
2347                 
2348                 /* STD SCREEN BUTTONS */
2349                 xco= std_libbuttons(block, xco, 0, 0, NULL, B_INFOSCR, ID_SCR, 0, (ID *)G.curscreen, 0, &G.curscreen->screennr, 1, 1, B_INFODELSCR, 0, 0);
2350                 
2351                 xco +=8;
2352         
2353                 /* STD SCENE BUTTONS */
2354                 xco= std_libbuttons(block, xco, 0, 0, NULL, B_INFOSCE, ID_SCE, 0, (ID *)G.scene, 0, &G.curscreen->scenenr, 1, 1, B_INFODELSCE, 0, 0);
2355         }
2356         else xco= 430;
2357         
2358 BIF_SetScale(block->aspect);
2359         info_text(xco+24, 6);
2360         
2361         uiBlockSetEmboss(block, UI_EMBOSSN);
2362         uiDefIconBut(block, BUT, B_SHOWSPLASH, ICON_BLENDER, xco+2, 0,XIC,YIC, 0, 0, 0, 0, 0, "Click to display Splash Screen");
2363
2364         /* always do as last */
2365         curarea->headbutlen= xco+2*XIC;
2366
2367 #if 0
2368 // #ifdef _WIN32        // FULLSCREEN
2369         if(U.uiflag & USER_FLIPFULLSCREEN) {
2370                 uiDefIconBut(block, BUT, B_FLIPFULLSCREEN, ICON_WINDOW_WINDOW,
2371                                 (short)(curarea->winx-XIC-5), 0,XIC,YIC,
2372                                 0, 0, 0, 0, 0, "Toggles Blender to fullscreen mode");/* dir             */
2373         } else {
2374                 uiDefIconBut(block, BUT, B_FLIPFULLSCREEN, ICON_WINDOW_FULLSCREEN,
2375                                 (short)(curarea->winx-XIC-5), 0,XIC,YIC,
2376                                 0, 0, 0, 0, 0, "Toggles Blender to fullscreen mode");/* dir             */
2377         }
2378 #endif
2379         
2380         uiDrawBlock(block);
2381 }