Help menu!
[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  * $Id$
8  *
9  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version. The Blender
15  * Foundation also sells licenses for use in proprietary software under
16  * the Blender License.  See http://www.blender.org/BL/ for information
17  * about this.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software Foundation,
26  * Inc., 59 Temple Place - Suite 330, Boston, MA        02111-1307, USA.
27  *
28  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
29  * All rights reserved.
30  *
31  * The Original Code is: all of this file.
32  *
33  * Contributor(s): none yet.
34  *
35  * ***** END GPL/BL DUAL LICENSE BLOCK *****
36  */
37  
38 #include <math.h>
39 #include <stdlib.h>
40 #include <string.h>
41
42 #ifdef HAVE_CONFIG_H
43 #include <config.h>
44 #endif
45
46 #ifdef WIN32
47 #include "BLI_winstuff.h"
48 #endif
49
50 #include "BMF_Api.h"
51 #include "BIF_language.h"
52 #ifdef INTERNATIONAL
53 #include "FTF_Api.h"
54 #endif
55
56 #include "DNA_ID.h"
57 #include "DNA_image_types.h"
58 #include "DNA_object_types.h"
59 #include "DNA_packedFile_types.h"
60 #include "DNA_scene_types.h"
61 #include "DNA_screen_types.h"
62 #include "DNA_space_types.h"
63 #include "DNA_userdef_types.h"
64 #include "DNA_world_types.h"
65
66 #include "BDR_editcurve.h"
67 #include "BDR_editmball.h"
68 #include "BDR_editobject.h"
69
70 #include "BIF_editarmature.h"
71 #include "BIF_editfont.h"
72 #include "BIF_editmesh.h"
73 #include "BIF_gl.h"
74 #include "BIF_interface.h"
75 #include "BIF_language.h"
76 #include "BIF_mainqueue.h"
77 #include "BIF_previewrender.h"
78 #include "BIF_renderwin.h"
79 #include "BIF_resources.h"
80 #include "BIF_screen.h"
81 #include "BIF_space.h"
82 #include "BIF_toets.h"
83 #include "BIF_toolbox.h"
84 #include "BIF_usiblender.h"
85 #include "BIF_drawscene.h"
86
87 #include "BKE_blender.h"
88 #include "BKE_exotic.h"
89 #include "BKE_global.h"
90 #include "BKE_image.h"
91 #include "BKE_library.h"
92 #include "BKE_main.h"
93 #include "BKE_packedFile.h"
94 #include "BKE_scene.h"
95 #include "BKE_world.h"
96
97 #include "BLI_arithb.h"
98 #include "BLI_blenlib.h"
99 #include "BLO_writefile.h"
100
101 #include "BSE_editipo.h"
102 #include "BSE_filesel.h"
103 #include "BSE_headerbuttons.h"
104 #include "BSE_sequence.h"
105
106 #include "IMB_imbuf_types.h"
107
108 #include "MEM_guardedalloc.h"
109
110 #include "BPY_extern.h"
111 #include "BPY_menus.h"
112
113 #include "render.h" // for R - should use BKE_bad_level_calls.h instead?
114
115 #include "blendef.h"
116 #include "mydevice.h"
117
118 extern char versionstr[]; /* from blender.c */
119
120 /*----------------------------------*/
121 /* Progress bar vars and functions: */
122
123 /* strubi shamelessly abused the status line as a progress bar...
124  * feel free to kill him after release */
125
126 static int g_progress_bar = 0;
127 static char *g_progress_info = 0;
128 static float g_done;
129
130 int start_progress_bar(void)
131 {
132         g_progress_bar = 1;
133         return 1;               // we never fail (yet)
134 }
135
136 void end_progress_bar(void)
137 {
138         g_progress_bar = 0;
139 }
140
141 static void update_progress_bar(float done, char *info)
142 {
143         g_done = done;
144         g_progress_info = info;
145 }
146
147 /** Progress bar
148         'done': a value between 0.0 and 1.0, showing progress
149         'info': a info text what is currently being done
150
151         Make sure that the progress bar is always called with:
152         done = 0.0 first
153                 and
154         done = 1.0 last -- or alternatively use:
155
156         start_progressbar();
157         do_stuff_and_callback_progress_bar();
158         end_progressbar();
159 */
160
161 int progress_bar(float done, char *busy_info)
162 {
163         ScrArea *sa;
164         short val; 
165
166         /* User break (ESC) */
167         while (qtest()) {
168                 if (extern_qread(&val) == ESCKEY) 
169                         return 0;
170         }
171         if (done == 0.0) {
172                 start_progress_bar();
173         } else if (done > 0.99) {
174                 end_progress_bar();
175         }
176
177         sa= G.curscreen->areabase.first;
178         while(sa) {
179                 if (sa->spacetype == SPACE_INFO) {
180                         update_progress_bar(done, busy_info);
181
182                         curarea = sa;
183
184                         scrarea_do_headdraw(curarea);
185                         areawinset(curarea->win);
186                         sa->head_swap= WIN_BACK_OK;
187                         screen_swapbuffers();
188                 }
189                 sa = sa->next;
190         }
191         return 1;
192 }
193 /* -- End of progress bar definitions ------- */
194
195 extern char videosc_dir[];      /* exotic.c */
196
197 void write_videoscape_fs()
198 {
199         if(G.obedit) {
200                 error("Can't save Videoscape. Press TAB to leave EditMode");
201         }
202         else {
203                 if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
204                 activate_fileselect(FILE_SPECIAL, "Export Videoscape", videosc_dir,
205                                                                                 write_videoscape);
206         }
207 }
208
209 void write_vrml_fs()
210 {
211         if(G.obedit) {
212                 error("Can't save VRML. Press TAB to leave EditMode");
213         }
214         else {
215                 if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
216         
217                 activate_fileselect(FILE_SPECIAL, "Export VRML 1.0", videosc_dir, write_vrml);
218         }  
219 }
220
221 void write_dxf_fs()
222 {
223         if(G.obedit) {
224                 error("Can't save DXF. Press TAB to leave EditMode");
225         }
226         else {
227
228                 if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
229
230                 activate_fileselect(FILE_SPECIAL, "Export DXF", videosc_dir, write_dxf);        
231         }
232 }
233
234 void write_stl_fs()
235 {
236         if(G.obedit) {
237                 error("Can't save STL. Press TAB to leave EditMode");
238         }
239         else {
240
241                 if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
242
243                 activate_fileselect(FILE_SPECIAL, "Export STL", videosc_dir, write_stl);
244         }
245 }
246 /* ------------ */
247
248 int buttons_do_unpack()
249 {
250         int how;
251         char menu[2048];
252         char line[128];
253         int ret_value = RET_OK, count = 0;
254
255         count = countPackedFiles();
256
257         if (count) {
258                 if (count == 1) {
259                         sprintf(menu, "Unpack 1 file%%t");
260                 } else {
261                         sprintf(menu, "Unpack %d files%%t", count);
262                 }
263                 
264                 sprintf(line, "|Use files in current directory (create when necessary)%%x%d", PF_USE_LOCAL);
265                 strcat(menu, line);
266         
267                 sprintf(line, "|Write files to current directory (overwrite existing files)%%x%d", PF_WRITE_LOCAL);
268                 strcat(menu, line);
269         
270                 sprintf(line, "|%%l|Use files in original location (create when necessary)%%x%d", PF_USE_ORIGINAL);
271                 strcat(menu, line);
272         
273                 sprintf(line, "|Write files to original location (overwrite existing files)%%x%d", PF_WRITE_ORIGINAL);
274                 strcat(menu, line);
275         
276                 sprintf(line, "|%%l|Disable AutoPack, keep all packed files %%x%d", PF_KEEP);
277                 strcat(menu, line);
278         
279                 sprintf(line, "|Ask for each file %%x%d", PF_ASK);
280                 strcat(menu, line);
281                 
282                 how = pupmenu(menu);
283                 
284                 if(how != -1) {
285                         if (how != PF_KEEP) {
286                                 unpackAll(how);
287                         }
288                         G.fileflags &= ~G_AUTOPACK;
289                 } else {
290                         ret_value = RET_CANCEL;
291                 }
292         } else {
293                 pupmenu("No packed files. Autopack disabled");
294         }
295         
296         return (ret_value);
297 }
298
299 /* here, because of all creator stuff */
300
301 Scene *copy_scene(Scene *sce, int level)
302 {
303         /* level 0: al objects shared
304          * level 1: al object-data shared
305          * level 2: full copy
306          */
307         Scene *scen;
308         Base *base, *obase;
309
310         /* level 0 */
311         scen= copy_libblock(sce);
312         duplicatelist(&(scen->base), &(sce->base));
313         
314         clear_id_newpoins();
315         
316         id_us_plus((ID *)scen->world);
317         id_us_plus((ID *)scen->set);
318
319         scen->ed= 0;
320         scen->radio= 0;
321
322         obase= sce->base.first;
323         base= scen->base.first;
324         while(base) {
325                 base->object->id.us++;
326                 if(obase==sce->basact) scen->basact= base;
327
328                 obase= obase->next;
329                 base= base->next;
330         }
331
332         if(level==0) return scen;
333
334         /* level 1 */
335         G.scene= scen;
336         single_object_users(0);
337
338         /*      camera */
339         ID_NEW(G.scene->camera);
340
341         /* level 2 */
342         if(level>=2) {
343                 if(scen->world) {
344                         scen->world->id.us--;
345                         scen->world= copy_world(scen->world);
346                 }
347                 single_obdata_users(0);
348                 single_mat_users_expand();
349                 single_tex_users_expand();
350         }
351
352         clear_id_newpoins();
353
354         BPY_copy_scriptlink(&sce->scriptlink);
355
356         // make a private copy of the avicodecdata
357
358         if (sce->r.avicodecdata) {
359
360                 scen->r.avicodecdata = MEM_dupallocN(sce->r.avicodecdata);
361                 scen->r.avicodecdata->lpFormat = MEM_dupallocN(scen->r.avicodecdata->lpFormat);
362                 scen->r.avicodecdata->lpParms = MEM_dupallocN(scen->r.avicodecdata->lpParms);
363         }
364
365         // make a private copy of the qtcodecdata
366
367         if (sce->r.qtcodecdata) {
368                 scen->r.qtcodecdata = MEM_dupallocN(sce->r.qtcodecdata);
369                 scen->r.qtcodecdata->cdParms = MEM_dupallocN(scen->r.qtcodecdata->cdParms);
370         }
371
372         return scen;
373 }
374
375 void do_info_buttons(unsigned short event)
376 {
377         bScreen *sc, *oldscreen;
378         Scene *sce, *sce1;
379         ScrArea *sa;
380         int nr;
381
382         switch(event) {
383
384         case B_INFOSCR:         /* menu select screen */
385
386                 if( G.curscreen->screennr== -2) {
387                         if(curarea->winy <50) {
388                                 sa= closest_bigger_area();
389                                 areawinset(sa->win);
390                         }
391                         activate_databrowse((ID *)G.curscreen, ID_SCR, 0, B_INFOSCR,
392                                                                                         &G.curscreen->screennr, do_info_buttons);
393                         return;
394                 }
395                 if( G.curscreen->screennr < 0) return;
396
397                 sc= G.main->screen.first;
398                 nr= 1;
399                 while(sc) {
400                         if(nr==G.curscreen->screennr) {
401                                 if(is_allowed_to_change_screen(sc)) setscreen(sc);
402                                 else error("Unable to perform function in EditMode");
403                                 break;
404                         }
405                         nr++;
406                         sc= sc->id.next;
407                 }
408                 /* last item: NEW SCREEN */
409                 if(sc==0) {
410                         duplicate_screen();
411                 }
412                 break;
413         case B_INFODELSCR:
414 /*do this event only with buttons, so it can never be called with full-window*/
415
416                 if(G.curscreen->id.prev) sc= G.curscreen->id.prev;
417                 else if(G.curscreen->id.next) sc= G.curscreen->id.next;
418                 else return;
419                 if(okee("Delete current screen")) {
420                         /* find new G.curscreen */
421
422                         oldscreen= G.curscreen;
423                         setscreen(sc);          /* this test if sc has a full */
424                         unlink_screen(oldscreen);
425                         free_libblock(&G.main->screen, oldscreen);
426                 }
427                 scrarea_queue_headredraw(curarea);
428
429                 break;
430         case B_INFOSCE:         /* menu select scene */
431
432                 if( G.obedit) {
433                         error("Unable to perform function in EditMode");
434                         return;
435                 }
436                 if( G.curscreen->scenenr== -2) {
437                         if(curarea->winy <50) {
438                                 sa= closest_bigger_area();
439                                 areawinset(sa->win);
440                         }
441                         activate_databrowse((ID *)G.scene, ID_SCE, 0, B_INFOSCE,
442                                                                                         &G.curscreen->scenenr, do_info_buttons);
443                         return;
444                 }
445                 if( G.curscreen->scenenr < 0) return;
446
447                 sce= G.main->scene.first;
448                 nr= 1;
449                 while(sce) {
450                         if(nr==G.curscreen->scenenr) {
451                                 if(sce!=G.scene) set_scene(sce);
452                                 break;
453                         }
454                         nr++;
455                         sce= sce->id.next;
456                 }
457                 /* last item: NEW SCENE */
458                 if(sce==0) {
459                         nr= pupmenu("Add scene%t|Empty|Link Objects|Link ObData|Full Copy");
460                         if(nr<= 0) return;
461                         if(nr==1) {
462                                 sce= add_scene(G.scene->id.name+2);
463                                 sce->r= G.scene->r;
464 #ifdef _WIN32
465                                 if (sce->r.avicodecdata) {
466                                         sce->r.avicodecdata = MEM_dupallocN(G.scene->r.avicodecdata);
467                                         sce->r.avicodecdata->lpFormat = MEM_dupallocN(G.scene->r.avicodecdata->lpFormat);
468                                         sce->r.avicodecdata->lpParms = MEM_dupallocN(G.scene->r.avicodecdata->lpParms);
469                                 }
470 #endif
471 #ifdef WITH_QUICKTIME
472                                 if (sce->r.qtcodecdata) {
473                                         sce->r.qtcodecdata = MEM_dupallocN(G.scene->r.qtcodecdata);
474                                         sce->r.qtcodecdata->cdParms = MEM_dupallocN(G.scene->r.qtcodecdata->cdParms);
475                                 }
476 #endif
477                         }
478                         else sce= copy_scene(G.scene, nr-2);
479
480                         set_scene(sce);
481                 }
482                 BIF_preview_changed(G.buts);
483
484                 break;
485         case B_INFODELSCE:
486
487                 if(G.scene->id.prev) sce= G.scene->id.prev;
488                 else if(G.scene->id.next) sce= G.scene->id.next;
489                 else return;
490                 if(okee("Delete current scene")) {
491
492                         /* check all sets */
493                         sce1= G.main->scene.first;
494                         while(sce1) {
495                                 if(sce1->set == G.scene) sce1->set= 0;
496                                 sce1= sce1->id.next;
497                         }
498
499                         /* check all sequences */
500                         clear_scene_in_allseqs(G.scene);
501
502                         /* al screens */
503                         sc= G.main->screen.first;
504                         while(sc) {
505                                 if(sc->scene == G.scene) sc->scene= sce;
506                                 sc= sc->id.next;
507                         }
508                         free_libblock(&G.main->scene, G.scene);
509                         set_scene(sce);
510                 }
511
512                 break;
513         }
514 }
515
516 static void check_packAll()
517 {
518         // first check for dirty images
519         Image *ima;
520
521         ima = G.main->image.first;
522         while (ima) {
523                 if (ima->ibuf && (ima->ibuf->userflags &= IB_BITMAPDIRTY)) {
524                         break;
525                 }
526                 ima= ima->id.next;
527                 }
528         
529         if (ima == 0 || okee("Some images are painted on. These changes will be lost. Continue ?")) {
530                 packAll();
531                 G.fileflags |= G_AUTOPACK;
532         }
533 }
534
535 int write_runtime(char *str, char *exename)
536 {
537         char *freestr= NULL;
538         char *ext = 0;
539
540 #ifdef _WIN32
541         ext = ".exe";
542 #endif
543
544 #ifdef __APPLE__
545         ext = ".app";
546 #endif
547         if (ext && (!BLI_testextensie(str, ext))) {
548                 freestr= MEM_mallocN(strlen(str) + strlen(ext) + 1, "write_runtime_check");
549                 strcpy(freestr, str);
550                 strcat(freestr, ext);
551                 str= freestr;
552         }
553
554         if (!BLI_exists(str) || saveover(str))
555                 BLO_write_runtime(str, exename);
556
557         if (freestr)
558                 MEM_freeN(freestr);
559  
560         return 0;
561 }
562
563 static void write_runtime_check_dynamic(char *str) 
564 {
565         write_runtime(str, "blenderdynplayer.exe");
566 }
567
568 static void write_runtime_check(char *str) 
569 {
570         char player[128];
571
572         strcpy(player, "blenderplayer");
573
574 #ifdef _WIN32
575         strcat(player, ".exe");
576 #endif
577
578 #ifdef __APPLE__
579         strcat(player, ".app");
580 #endif
581
582         write_runtime(str, player);
583 }
584 /* end keyed functions */
585
586 /************************** MAIN MENU *****************************/
587 /************************** FILE *****************************/
588
589 void do_info_file_optionsmenu(void *arg, int event)
590 {
591         G.fileflags ^= (1 << event);
592
593         // allqueue(REDRAWINFO, 0);
594 }
595
596 #if GAMEBLENDER == 1
597 static uiBlock *info_file_optionsmenu(void *arg_unused)
598 {
599         uiBlock *block;
600         short yco= 0, xco = 20;
601
602         block= uiNewBlock(&curarea->uiblocks, "runtime_options", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
603         uiBlockSetButmFunc(block, do_info_file_optionsmenu, NULL);
604         uiBlockSetXOfs(block,-40);      // offset to parent button
605         
606         /* flags are case-values */
607         uiDefBut(block, BUTM, 1, "Compress File",       xco, yco-=20, 100, 19, NULL, 0.0, 0.0, 0, G_FILE_COMPRESS_BIT, "Enables file compression");
608 /*
609         uiDefBut(block, BUTM, 1, "Sign File",   xco, yco-=20, 100, 19, NULL, 0.0, 0.0, 0, G_FILE_SIGN_BIT, "Add signature to file");
610         uiDefBut(block, BUTM, 1, "Lock File",   xco, yco-=20, 100, 19, NULL, 0.0, 0.0, 0, G_FILE_LOCK_BIT, "Protect the file from editing by others");
611 */
612         uiTextBoundsBlock(block, 50);
613
614         /* Toggle buttons */
615         
616         yco= 0;
617         xco -= 20;
618         uiBlockSetEmboss(block, UI_EMBOSSM);
619         uiBlockSetButmFunc(block, NULL, NULL);
620         /* flags are defines */
621         uiDefIconButI(block, ICONTOG|BIT|G_FILE_COMPRESS_BIT, 0, ICON_CHECKBOX_DEHLT, xco, yco-=20, 19, 19, &G.fileflags, 0.0, 0.0, 0, 0, "");
622 /*
623         uiDefIconButI(block, ICONTOG|BIT|G_FILE_SIGN_BIT, 0, ICON_CHECKBOX_DEHLT, xco, yco-=20, 19, 19, &G.fileflags, 0.0, 0.0, 0, 0, "");
624         uiDefIconButI(block, ICONTOG|BIT|G_FILE_LOCK_BIT, 0, ICON_CHECKBOX_DEHLT, xco, yco-=20, 19, 19, &G.fileflags, 0.0, 0.0, 0, 0, "");
625 */
626         uiBlockSetDirection(block, UI_RIGHT);
627                 
628         return block;
629 }
630
631 static uiBlock *info_runtime_optionsmenu(void *arg_unused)
632 {
633         uiBlock *block;
634         short yco= 0, xco = 20;
635
636         block= uiNewBlock(&curarea->uiblocks, "add_surfacemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
637         uiBlockSetXOfs(block, -40);  // offset to parent button
638         uiBlockSetEmboss(block, UI_EMBOSSM);
639
640         uiDefBut(block, LABEL, 0, "Size options:",              xco, yco-=20, 114, 19, 0, 0.0, 0.0, 0, 0, "");
641         uiDefButS(block, NUM, 0, "X:",          xco+19, yco-=20, 95, 19,                &G.scene->r.xplay, 10.0, 2000.0, 0, 0, "Displays current X screen/window resolution. Click to change.");
642         uiDefButS(block, NUM, 0, "Y:",          xco+19, yco-=20, 95, 19, &G.scene->r.yplay, 10.0, 2000.0, 0, 0, "Displays current Y screen/window resolution. Click to change.");
643
644         uiDefBut(block, SEPR, 0, "",            xco, yco-=4, 114, 4, NULL, 0.0, 0.0, 0, 0, "");
645
646         uiDefBut(block, LABEL, 0, "Fullscreen options:",                xco, yco-=20, 114, 19, 0, 0.0, 0.0, 0, 0, "");
647         uiDefButS(block, TOG, 0, "Fullscreen", xco + 19, yco-=20, 95, 19, &G.scene->r.fullscreen, 0.0, 0.0, 0, 0, "Starts player in a new fullscreen display");
648         uiDefButS(block, NUM, 0, "Freq:",       xco+19, yco-=20, 95, 19, &G.scene->r.freqplay, 10.0, 120.0, 0, 0, "Displays clock frequency of fullscreen display. Click to change.");
649         uiDefButS(block, NUM, 0, "Bits:",       xco+19, yco-=20, 95, 19, &G.scene->r.depth, 1.0, 32.0, 0, 0, "Displays bit depth of full screen display. Click to change.");
650
651         uiDefBut(block, SEPR, 0, "",            xco, yco-=4, 114, 4, NULL, 0.0, 0.0, 0, 0, "");
652
653         /* stereo settings */
654         /* can't use any definition from the game engine here so hardcode it. Change it here when it changes there!
655          * RAS_IRasterizer has definitions:
656          * RAS_STEREO_NOSTEREO           1
657          * RAS_STEREO_QUADBUFFERED 2
658          * RAS_STEREO_ABOVEBELOW         3
659          * RAS_STEREO_INTERLACED         4       future
660          */
661         uiDefBut(block, LABEL, 0, "Stereo options", xco, yco-=20, 114, 19, 0, 0.0, 0.0, 0, 0, "");
662         uiDefButS(block, ROW, 0, "no stereo", xco+19, yco-=20, 95, 19, &(G.scene->r.stereomode), 6.0, 1.0, 0, 0, "Disables stereo");
663         uiDefButS(block, ROW, 0, "h/w pageflip", xco+19, yco-=20, 95, 19, &(G.scene->r.stereomode), 6.0, 2.0, 0, 0, "Enables hardware pageflip stereo method");
664         uiDefButS(block, ROW, 0, "syncdoubling", xco+19, yco-=20, 95, 19, &(G.scene->r.stereomode), 6.0, 3.0, 0, 0, "Enables syncdoubling stereo method");
665
666         uiBlockSetDirection(block, UI_RIGHT);
667         uiTextBoundsBlock(block, 50);
668                 
669         return block;
670 }
671 #endif
672
673 static void do_info_file_importmenu(void *arg, int event)
674 {
675         ScrArea *sa;
676
677         if(curarea->spacetype==SPACE_INFO) {
678                 sa= find_biggest_area_of_type(SPACE_SCRIPT);
679                 if (!sa) sa= closest_bigger_area();
680                 areawinset(sa->win);
681         }
682
683         /* events >=4 are registered bpython scripts */
684         if (event >= 4) BPY_menu_do_python(PYMENU_IMPORT, event - 4);
685
686         else switch(event) {
687                                                                         
688         case 0: /* DXF */
689                 activate_fileselect(FILE_BLENDER, "Import DXF", G.sce, BIF_read_file);
690                 break;
691         case 1: /* VRML 1.0 */
692                 activate_fileselect(FILE_BLENDER, "Import VRML 1.0", G.sce, BIF_read_file);
693                 break;
694         case 2: /* VideoScape */
695                 activate_fileselect(FILE_BLENDER, "Import VideoScape", G.sce, BIF_read_file);
696                 break;
697         case 3: /* STL */
698                 activate_fileselect(FILE_BLENDER, "Import STL", G.sce, BIF_read_file);
699                 break;
700
701         }
702
703         allqueue(REDRAWINFO, 0);
704 }
705
706 static uiBlock *info_file_importmenu(void *arg_unused)
707 {
708         uiBlock *block;
709         short yco = 20, menuwidth = 120;
710         BPyMenu *pym;
711         int i = 0;
712
713         block= uiNewBlock(&curarea->uiblocks, "importmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
714         uiBlockSetButmFunc(block, do_info_file_importmenu, NULL);
715         //uiBlockSetXOfs(block, -50);  // offset to parent button
716         
717         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "VRML 1.0...",
718                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 1, "");
719         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "DXF...",
720                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 0, "");
721         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "VideoScape...",
722                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "");
723         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "STL...",
724                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 3, "");
725
726         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
727
728         for (pym = BPyMenuTable[PYMENU_IMPORT]; pym; pym = pym->next, i++) {
729                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i+4, pym->tooltip?pym->tooltip:pym->filename);
730         }
731
732         uiBlockSetDirection(block, UI_RIGHT);
733         uiTextBoundsBlock(block, 60);
734
735         return block;
736 }
737
738 static void do_info_file_exportmenu(void *arg, int event)
739 {
740         ScrArea *sa;
741
742         if(curarea->spacetype==SPACE_INFO) {
743                 sa= find_biggest_area_of_type(SPACE_SCRIPT);
744                 if (!sa) sa= closest_bigger_area();
745                 areawinset(sa->win);
746         }
747
748         /* events >=4 are registered bpython scripts */
749         if (event >= 4) BPY_menu_do_python(PYMENU_EXPORT, event - 4);
750
751         else switch(event) {
752                                                                         
753         case 0:
754                 write_vrml_fs();
755                 break;
756         case 1:
757                 write_dxf_fs();
758                 break;
759         case 2:
760                 write_videoscape_fs();
761                 break;
762         case 3:
763                 write_stl_fs();
764                 break;
765         }
766         allqueue(REDRAWINFO, 0);
767 }
768
769 static uiBlock *info_file_exportmenu(void *arg_unused)
770 {
771         uiBlock *block;
772         short yco = 20, menuwidth = 120;
773         BPyMenu *pym;
774         int i = 0;
775
776         block= uiNewBlock(&curarea->uiblocks, "exportmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
777         uiBlockSetButmFunc(block, do_info_file_exportmenu, NULL);
778         //uiBlockSetXOfs(block, -50);  // offset to parent button
779
780         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "VRML 1.0...|Ctrl F2",
781                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 0, "");
782         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "DXF...|Shift F2",
783                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 1, "");
784         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Videoscape...|Alt W",
785                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "");
786         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "STL...",
787                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 3, "");
788
789         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
790
791         /* note that we acount for the 3 previous entries with i+3: */
792         for (pym = BPyMenuTable[PYMENU_EXPORT]; pym; pym = pym->next, i++) {
793                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, pym->name, 0, yco-=20, menuwidth, 19, 
794                                  NULL, 0.0, 0.0, 1, i+4, 
795                                  pym->tooltip?pym->tooltip:pym->filename);
796         }
797
798
799         uiBlockSetDirection(block, UI_RIGHT);
800         uiTextBoundsBlock(block, 60);
801
802         return block;
803 }
804
805 static void do_info_filemenu(void *arg, int event)
806 {
807         ScrArea *sa;
808         char dir[FILE_MAXDIR];
809         
810         if(curarea->spacetype==SPACE_INFO) {
811                 sa= closest_bigger_area();
812                 areawinset(sa->win);
813         }
814
815         /* these are no defines, easier this way, the codes are in the function below */
816         switch(event) {
817         case 0:
818                 if (okee("Erase All")) {
819                         if (!BIF_read_homefile())
820                                 error("No file ~/.B.blend");
821                 }
822                 break;
823         case 1: /* open */
824                 activate_fileselect(FILE_BLENDER, "Open", G.sce, BIF_read_file);
825                 break;
826         case 2: /* reopen last */
827                 {
828                         char *s= MEM_mallocN(strlen(G.sce) + 11 + 1, "okee_reload");
829                         strcpy(s, "Open file: ");
830                         strcat(s, G.sce);
831                         if (okee(s)) BIF_read_file(G.sce);
832                         MEM_freeN(s);
833                 }
834                 break;
835         case 3: /* append */
836                 activate_fileselect(FILE_LOADLIB, "Load Library", G.lib, 0);
837                 break;
838         case 4: /* save */
839                 strcpy(dir, G.sce);
840                 untitled(dir);
841                 activate_fileselect(FILE_BLENDER, "Save As", dir, BIF_write_file);
842                 break;
843         case 5:
844                 strcpy(dir, G.sce);
845                 if (untitled(dir)) {
846                         activate_fileselect(FILE_BLENDER, "Save As", dir, BIF_write_file);
847                 } else {
848                         BIF_write_file(dir);
849                         free_filesel_spec(dir);
850                 }
851                 break;
852         case 6: /* save image */
853                 mainqenter(F3KEY, 1);
854                 break;
855 /*
856         case 20:
857                 strcpy(dir, G.sce);
858                 activate_fileselect(FILE_SPECIAL, "INSTALL LICENSE KEY", dir, loadKeyboard);
859                 break;
860         case 21:
861                 SHOW_LICENSE_KEY();
862                 break;
863 */
864         case 22: /* save runtime */
865                 activate_fileselect(FILE_SPECIAL, "Save Runtime", "", write_runtime_check);
866                 break;
867         case 23: /* save dynamic runtime */
868                 activate_fileselect(FILE_SPECIAL, "Save Dynamic Runtime", "", write_runtime_check_dynamic);
869                 break;
870         case 10: /* pack data */
871                 check_packAll();
872                 break;
873         case 11: /* unpack to current dir */
874                 unpackAll(PF_WRITE_LOCAL);
875                 G.fileflags &= ~G_AUTOPACK;
876                 break;
877         case 12: /* unpack data */
878                 if (buttons_do_unpack() != RET_CANCEL) {
879                         /* Clear autopack bit only if user selected one of the unpack options */
880                         G.fileflags &= ~G_AUTOPACK;
881                 }
882                 break;
883         case 13:
884                 exit_usiblender();
885                 break;
886         case 31: /* save default settings */
887                 BIF_write_homefile();
888                 break;
889         }
890         allqueue(REDRAWINFO, 0);
891 }
892 static uiBlock *info_filemenu(void *arg_unused)
893 {
894         uiBlock *block;
895         short yco=0;
896         short menuwidth=120;
897
898         block= uiNewBlock(&curarea->uiblocks, "info_filemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
899         uiBlockSetButmFunc(block, do_info_filemenu, NULL);
900         
901         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "New|Ctrl X",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
902         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Open...|F1",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
903         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reopen Last|Ctrl O",                             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
904
905         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
906
907         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save|Ctrl W",                            0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
908         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save As...|F2",                  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
909
910         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
911
912         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Image...|F3",                       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
913 #if GAMEBLENDER == 1
914         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Runtime...",                        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 22, "");
915 #ifdef _WIN32
916         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Dynamic Runtime...",                0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 23, "");
917 #endif
918 #endif
919         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
920
921         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Default Settings|Ctrl U",                   0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 31, "");
922
923         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
924
925         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Append...|Shift F1",     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
926         uiDefIconTextBlockBut(block, info_file_importmenu, NULL, ICON_RIGHTARROW_THIN, "Import", 0, yco-=20, menuwidth, 19, "");
927         uiDefIconTextBlockBut(block, info_file_exportmenu, NULL, ICON_RIGHTARROW_THIN, "Export", 0, yco-=20, menuwidth, 19, "");
928         
929         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
930
931         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pack Data",                              0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 10, "");
932 //      uiDefBut(block, BUTM, 1, "Unpack Data to current dir",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 11, "Removes all packed files from the project and saves them to the current directory");
933         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Unpack Data...",                         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 12, "");
934
935         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
936
937         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Quit Blender| Q",                                0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, "");
938
939         uiBlockSetDirection(block, UI_DOWN);
940         uiTextBoundsBlock(block, 80);
941
942         return block;
943 }
944
945 /**************************** ADD ******************************/
946
947 void do_info_add_meshmenu(void *arg, int event)
948 {
949
950         switch(event) {         
951                 case 0:
952                         /* Plane */
953                         add_primitiveMesh(0);
954                         break;
955                 case 1:
956                         /* Cube */
957                         add_primitiveMesh(1);
958                         break;
959                 case 2:
960                         /* Circle */
961                         add_primitiveMesh(4);
962                         break;
963                 case 3:
964                         /* UVsphere */
965                         add_primitiveMesh(11);
966                         break;
967                 case 4:
968                         /* IcoSphere */
969                         add_primitiveMesh(12);
970                         break;
971                 case 5:
972                         /* Cylinder */
973                         add_primitiveMesh(5);
974                         break;
975                 case 6:
976                         /* Tube */
977                         add_primitiveMesh(6);
978                         break;
979                 case 7:
980                         /* Cone */
981                         add_primitiveMesh(7);
982                         break;
983                 case 8:
984                         /* Grid */
985                         add_primitiveMesh(10);
986                         break;
987                 case 9:
988                         /* Monkey */
989                         add_primitiveMesh(13);
990                         break;
991                 default:
992                         break;
993         }
994         allqueue(REDRAWINFO, 0);
995 }
996
997 static uiBlock *info_add_meshmenu(void *arg_unused)
998 {
999 /*              static short tog=0; */
1000         uiBlock *block;
1001         short yco= 0;
1002         
1003         block= uiNewBlock(&curarea->uiblocks, "add_meshmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1004         uiBlockSetButmFunc(block, do_info_add_meshmenu, NULL);
1005         
1006         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Plane|",                         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1007         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cube|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1008         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Circle|",                                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1009         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "UVsphere",                       0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1010         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "IcoSphere|",                     0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1011         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cylinder|",                      0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "");
1012         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tube|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 6, "");
1013         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cone|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 7, "");
1014         uiDefIconTextBut(block, SEPR, 0, ICON_BLANK1, "",                                       0, yco-=6,      160, 6,  NULL, 0.0, 0.0, 0, 0, "");
1015         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grid|",                          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 8, "");
1016         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Monkey|",                        0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 9, "");
1017
1018         uiBlockSetDirection(block, UI_RIGHT);
1019         uiTextBoundsBlock(block, 50);
1020                 
1021         return block;
1022 }
1023
1024 void do_info_add_curvemenu(void *arg, int event)
1025 {
1026
1027         switch(event) {         
1028                 case 0:
1029                         /* Bezier Curve */
1030                         add_primitiveCurve(10);
1031                         break;
1032                 case 1:
1033                         /* Bezier Circle */
1034                         add_primitiveCurve(11);
1035                         break;
1036                 case 2:
1037                         /* NURB Curve */
1038                         add_primitiveCurve(40);
1039                         break;
1040                 case 3:
1041                         /* NURB Circle */
1042                         add_primitiveCurve(41);
1043                         break;
1044                 case 4:
1045                         /* Path */
1046                         add_primitiveCurve(46);
1047                         break;
1048                 default:
1049                         break;
1050         }
1051         allqueue(REDRAWINFO, 0);
1052 }
1053
1054 static uiBlock *info_add_curvemenu(void *arg_unused)
1055 {
1056 /*              static short tog=0; */
1057         uiBlock *block;
1058         short yco= 0;
1059         
1060         block= uiNewBlock(&curarea->uiblocks, "add_curvemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1061         uiBlockSetButmFunc(block, do_info_add_curvemenu, NULL);
1062         
1063         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Bezier Curve|",  0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1064         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Bezier Circle|", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1065         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Curve|",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1066         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Circle",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1067         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Path|",                  0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1068
1069         uiBlockSetDirection(block, UI_RIGHT);
1070         uiTextBoundsBlock(block, 50);
1071                 
1072         return block;
1073 }
1074
1075
1076 void do_info_add_surfacemenu(void *arg, int event)
1077 {
1078
1079         switch(event) {         
1080                 case 0:
1081                         /* Curve */
1082                         add_primitiveNurb(0);
1083                         break;
1084                 case 1:
1085                         /* Circle */
1086                         add_primitiveNurb(1);
1087                         break;
1088                 case 2:
1089                         /* Surface */
1090                         add_primitiveNurb(2);
1091                         break;
1092                 case 3:
1093                         /* Tube */
1094                         add_primitiveNurb(3);
1095                         break;
1096                 case 4:
1097                         /* Sphere */
1098                         add_primitiveNurb(4);
1099                         break;
1100                 case 5:
1101                         /* Donut */
1102                         add_primitiveNurb(5);
1103                         break;
1104                 default:
1105                         break;
1106         }
1107         allqueue(REDRAWINFO, 0);
1108 }
1109
1110 static uiBlock *info_add_surfacemenu(void *arg_unused)
1111 {
1112 /*              static short tog=0; */
1113         uiBlock *block;
1114         short yco= 0;
1115         
1116         block= uiNewBlock(&curarea->uiblocks, "add_surfacemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1117         uiBlockSetButmFunc(block, do_info_add_surfacemenu, NULL);
1118         
1119         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Curve|",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1120         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Circle|",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1121         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Surface|", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1122         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Tube",             0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1123         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Sphere|",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1124         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "NURBS Donut|",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "");
1125         uiBlockSetDirection(block, UI_RIGHT);
1126         uiTextBoundsBlock(block, 50);
1127                 
1128         return block;
1129 }
1130
1131 void do_info_add_metamenu(void *arg, int event)
1132 {
1133
1134         switch(event) {         
1135                 case 0:
1136                         /* Ball */
1137                         add_primitiveMball(1);
1138                         break;
1139                 case 1:
1140                         /* Tube */
1141                         add_primitiveMball(2);
1142                         break;
1143                 case 2:
1144                         /* Plane */
1145                         add_primitiveMball(3);
1146                         break;
1147                 case 3:
1148                         /* Elipsoid */
1149                         add_primitiveMball(4);
1150                         break;
1151                 case 4:
1152                         /* Cube */
1153                         add_primitiveMball(5);
1154                         break;
1155                 default:
1156                         break;
1157         }
1158         allqueue(REDRAWINFO, 0);
1159 }
1160
1161
1162 static uiBlock *info_add_metamenu(void *arg_unused)
1163 {
1164 /*              static short tog=0; */
1165         uiBlock *block;
1166         short xco= 0;
1167         
1168         block= uiNewBlock(&curarea->uiblocks, "add_metamenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1169         uiBlockSetButmFunc(block, do_info_add_metamenu, NULL);
1170         
1171         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,"Meta Ball|",              0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1172         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Tube|",             0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "");
1173         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Plane|",            0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "");
1174         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Ellipsoid|",        0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
1175         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Meta Cube|",             0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
1176
1177         uiBlockSetDirection(block, UI_RIGHT);
1178         uiTextBoundsBlock(block, 50);
1179                 
1180         return block;
1181 }
1182
1183
1184 void do_info_addmenu(void *arg, int event)
1185 {
1186         switch(event) {         
1187                 case 0:
1188                         /* Mesh */
1189                         break;
1190                 case 1:
1191                         /* Curve */
1192                         break;
1193                 case 2:
1194                         /* Surface */
1195                         break;
1196                 case 3:
1197                         /* Metaball */
1198                         break;
1199                 case 4:
1200                         /* Text (argument is discarded) */
1201                         add_primitiveFont(event);
1202                         break;
1203                 case 5:
1204                         /* Empty */
1205                         add_object_draw(OB_EMPTY);
1206                         break;
1207                 case 6:
1208                         /* Camera */
1209                         add_object_draw(OB_CAMERA);
1210                         break;
1211                 case 7:
1212                         /* Lamp */
1213                         add_object_draw(OB_LAMP);
1214                         break;
1215                 case 8:
1216                         /* Armature */
1217                         add_primitiveArmature(OB_ARMATURE);
1218                         break;
1219                 case 9:
1220                         /* Lattice */
1221                         add_object_draw(OB_LATTICE);
1222                         break;
1223                 default:
1224                         break;
1225         }
1226         allqueue(REDRAWINFO, 0);
1227 }
1228
1229
1230 static uiBlock *info_addmenu(void *arg_unused)
1231 {
1232 /*              static short tog=0; */
1233         uiBlock *block;
1234         short yco= 0;
1235
1236         block= uiNewBlock(&curarea->uiblocks, "addmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1237         uiBlockSetButmFunc(block, do_info_addmenu, NULL);
1238         
1239         uiDefIconTextBlockBut(block, info_add_meshmenu, NULL, ICON_RIGHTARROW_THIN, "Mesh", 0, yco-=20, 120, 19, "");
1240         uiDefIconTextBlockBut(block, info_add_curvemenu, NULL, ICON_RIGHTARROW_THIN, "Curve", 0, yco-=20, 120, 19, "");
1241         uiDefIconTextBlockBut(block, info_add_surfacemenu, NULL, ICON_RIGHTARROW_THIN, "Surface", 0, yco-=20, 120, 19, "");
1242         uiDefIconTextBlockBut(block, info_add_metamenu, NULL, ICON_RIGHTARROW_THIN, "Meta", 0, yco-=20, 120, 19, "");
1243         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Text",                           0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 4, "");
1244         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Empty",                          0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 5, "");
1245         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1246         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Camera",                         0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 6, "");
1247         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Lamp",                           0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 7, "");
1248         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1249         /* armature needs 3d window to draw */
1250         //uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Armature",                     0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 8, "");
1251         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Lattice",                        0, yco-=20, 120, 19, NULL, 0.0, 0.0, 1, 9, "");
1252
1253         uiBlockSetDirection(block, UI_DOWN);
1254         uiTextBoundsBlock(block, 80);
1255                 
1256         return block;
1257 }
1258
1259 /************************** GAME *****************************/
1260
1261 static void do_info_gamemenu(void *arg, int event)
1262 {
1263         switch (event) {
1264         case G_FILE_ENABLE_ALL_FRAMES_BIT:
1265         case G_FILE_SHOW_FRAMERATE_BIT:
1266         case G_FILE_SHOW_DEBUG_PROPS_BIT:
1267         case G_FILE_AUTOPLAY_BIT:
1268                 G.fileflags ^= (1 << event);
1269                 break;
1270         default:
1271                 ; /* ignore the rest */
1272         }
1273 }
1274
1275 static uiBlock *info_gamemenu(void *arg_unused)
1276 {
1277 /*              static short tog=0; */
1278         uiBlock *block;
1279         short yco= 0;
1280         short menuwidth=120;
1281         
1282         block= uiNewBlock(&curarea->uiblocks, "gamemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1283         uiBlockSetButmFunc(block, do_info_gamemenu, NULL);
1284         
1285         uiDefIconTextBut(block, BUTM, B_STARTGAME, ICON_BLANK1, "Start Game|P",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
1286         
1287         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 1, 0, "");
1288
1289
1290         if(G.fileflags & (1 << G_FILE_ENABLE_ALL_FRAMES_BIT)) {
1291                 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_BIT, "");
1292         } else {
1293                                         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_BIT, "");
1294         }
1295
1296         if(G.fileflags & (1 << G_FILE_SHOW_FRAMERATE_BIT)) {
1297                 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_BIT, "");
1298         } else {
1299                 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_BIT, "");
1300         }
1301
1302         if(G.fileflags & (1 << G_FILE_SHOW_DEBUG_PROPS_BIT)) {
1303                 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_BIT, "");
1304         } else {
1305                 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_BIT, "");
1306         }
1307         
1308         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 1, 0, "");
1309
1310         if(G.fileflags & (1 << G_FILE_AUTOPLAY_BIT)) {
1311                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Autostart",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_AUTOPLAY_BIT, "");
1312         } else {
1313                 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Autostart",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, G_FILE_AUTOPLAY_BIT, "");
1314         }
1315
1316         uiBlockSetDirection(block, UI_DOWN);
1317         uiTextBoundsBlock(block, 50);
1318         
1319         return block;
1320 }
1321 /************************** TIMELINE *****************************/
1322
1323 static void do_info_timelinemenu(void *arg, int event)
1324 {
1325         /* needed to check for valid selected objects */
1326         Base *base=NULL;
1327         Object *ob=NULL;
1328         //char file[FILE_MAXDIR+FILE_MAXFILE];
1329
1330         base= BASACT;
1331         if (base) ob= base->object;
1332
1333         switch(event) {
1334         case 1:
1335                 /* Show Keyframes */
1336                 if (!ob) error("Select an object before showing its keyframes");
1337                 else set_ob_ipoflags();
1338                 break;
1339         case 2:
1340                 /* Show and select Keyframes */
1341                 if (!ob) error("Select an object before showing and selecting its keyframes");
1342                 else select_select_keys();
1343                         break;
1344                 case 3:
1345                 /* select next keyframe */
1346                 if (!ob) error("Select an object before selecting its next keyframe");
1347                 else nextkey_obipo(1);
1348                         break;
1349                 case 4:
1350                 /* select previous keyframe */
1351                 if (!ob) error("Select an object before selecting its previous keyframe");
1352                 else nextkey_obipo(-1);
1353                 break;
1354                 case 5:
1355                 /* next keyframe */
1356                 if (!ob) error("Select an object before going to its next keyframe");
1357                 else movekey_obipo(1);
1358                         break;
1359                 case 6:
1360                 /* previous keyframe */
1361                 if (!ob) error("Select an object before going to its previous keyframe");
1362                 else movekey_obipo(-1);
1363                 break;
1364         case 7:
1365                 /* next frame */
1366                 CFRA++;
1367                 update_for_newframe();
1368                 break;
1369                 case 8:
1370                 /* previous frame */
1371                 CFRA--;
1372                 if(CFRA<1) CFRA=1;
1373                 update_for_newframe();
1374                 break;
1375         case 9:
1376                 /* forward 10 frames */
1377                 CFRA+= 10;
1378                 update_for_newframe();
1379                 break;
1380         case 10:
1381                 /* back 10 frames */
1382                 CFRA-= 10;
1383                 if(CFRA<1) CFRA=1;
1384                 update_for_newframe();
1385                 break;
1386         case 11:
1387                 /* end frame */
1388                 CFRA= EFRA;
1389                 update_for_newframe();
1390                 break;
1391         case 12:
1392                 /* start frame */
1393                 CFRA= SFRA;
1394                 update_for_newframe();
1395                 break;
1396         }
1397         allqueue(REDRAWINFO, 0);
1398 }
1399
1400 static uiBlock *info_timelinemenu(void *arg_unused)
1401 {
1402 /*              static short tog=0; */
1403         uiBlock *block;
1404         short yco= 0;
1405         short menuwidth=120;
1406
1407         block= uiNewBlock(&curarea->uiblocks, "timelinemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1408         uiBlockSetButmFunc(block, do_info_timelinemenu, NULL);
1409         
1410         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Keyframes|K",               0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
1411         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show and Select Keyframes|Shift K",0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
1412         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Next Keyframe|PageUp",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
1413         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Previous Keyframe|PageDown",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
1414
1415         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1416
1417         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Next Keyframe|Ctrl PageUp",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
1418         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Previous Keyframe|Ctrl PageDown",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
1419
1420         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1421
1422         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Next Frame|RightArrow",  0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
1423         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Previous Frame|LeftArrow",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
1424         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Forward 10 Frames|UpArrow",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
1425         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Back 10 Frames|DownArrow",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
1426
1427         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1428
1429         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "End Frame|Shift RightArrow",     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
1430         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Start Frame|Shift LeftArrow",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
1431
1432         uiBlockSetDirection(block, UI_DOWN);
1433         uiTextBoundsBlock(block, 80);
1434
1435         return block;
1436 }
1437
1438 /************************** RENDER *****************************/
1439
1440 /* copied from buttons.c. .. probably not such a good idea!? */
1441 static void run_playanim(char *file)
1442 {
1443         extern char bprogname[];        /* usiblender.c */
1444         char str[FILE_MAXDIR+FILE_MAXFILE];
1445         int pos[2], size[2];
1446
1447         calc_renderwin_rectangle(R.winpos, pos, size);
1448
1449         sprintf(str, "%s -a -p %d %d \"%s\"", bprogname, pos[0], pos[1], file);
1450         system(str);
1451 }
1452
1453 static void do_info_rendermenu(void *arg, int event)
1454 {
1455         char file[FILE_MAXDIR+FILE_MAXFILE];
1456
1457         extern void makeavistring(char *string);
1458         extern void makeqtstring (char *string);
1459
1460         switch(event) {
1461                 
1462         case 0:
1463                 BIF_do_render(0);
1464                 break;
1465         case 1:
1466                 BIF_do_render(1);
1467                 break;
1468
1469                 /* note: dont use select_area() for setting active areas for opengl render */
1470                 /* its hackish and instable... code here was removed */
1471         
1472         case 4:
1473                 BIF_toggle_render_display();
1474                 break;
1475         case 5:
1476 #ifdef WITH_QUICKTIME
1477                 if(G.scene->r.imtype == R_QUICKTIME)
1478                         makeqtstring(file);
1479                 else
1480 #endif
1481                         makeavistring(file);
1482                 if(BLI_exist(file)) {
1483                         run_playanim(file);
1484                 }
1485                 else {
1486                         makepicstring(file, G.scene->r.sfra);
1487                         if(BLI_exist(file)) {
1488                                 run_playanim(file);
1489                         }
1490                         else error("Can't find image: %s", file);
1491                 }
1492                 break;
1493         case 6:
1494                 /* dodgy hack turning on SHIFT key to do a proper render border select
1495                 set_render_border(); only works when 3d window active
1496                 
1497                 This code copied from toolbox.c, only works when 3d window is cameraview */
1498
1499                 if(select_area(SPACE_VIEW3D)) {
1500                         mainqenter(LEFTSHIFTKEY, 1);
1501                         mainqenter(BKEY, 1);
1502                         mainqenter(BKEY, 0);
1503                         mainqenter(EXECUTE, 1);
1504                         mainqenter(LEFTSHIFTKEY, 0);
1505                 }
1506
1507                 break;
1508
1509                 case 7:
1510                 extern_set_butspace(F10KEY);
1511                 break;
1512         }
1513         allqueue(REDRAWINFO, 0);
1514 }
1515
1516 static uiBlock *info_rendermenu(void *arg_unused)
1517 {
1518 /*              static short tog=0; */
1519         uiBlock *block;
1520         short yco= 0;
1521         short menuwidth=120;
1522         
1523         block= uiNewBlock(&curarea->uiblocks, "rendermenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1524         uiBlockSetButmFunc(block, do_info_rendermenu, NULL);
1525         
1526         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Render Current Frame|F12",       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
1527         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Render Animation",               0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
1528
1529         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1530
1531         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Render Buffer|F11",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
1532         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Rendered Animation",   0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
1533
1534         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1535
1536         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Render Border|Shift B",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
1537
1538         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1539
1540         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Render Settings|F10",            0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
1541
1542         uiBlockSetDirection(block, UI_DOWN);
1543         uiTextBoundsBlock(block, 80);
1544
1545         return block;
1546 }
1547
1548 /************************** HELP *****************************/
1549
1550 static void do_info_help_websitesmenu(void *arg, int event)
1551 {
1552         BPY_menu_do_python(PYMENU_HELPWEBSITES, event);
1553
1554         allqueue(REDRAWVIEW3D, 0);
1555 }
1556
1557
1558 static uiBlock *info_help_websitesmenu(void *arg_unused)
1559 {
1560         uiBlock *block;
1561         BPyMenu *pym;
1562         short yco = 20, menuwidth = 120;
1563         int i = 0;
1564
1565         block= uiNewBlock(&curarea->uiblocks, "info_help_websitesmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1566         uiBlockSetButmFunc(block, do_info_help_websitesmenu, NULL);
1567         
1568         for (pym = BPyMenuTable[PYMENU_HELPWEBSITES]; pym; pym = pym->next, i++) {
1569                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i, pym->tooltip?pym->tooltip:pym->filename);
1570         }
1571         
1572         uiBlockSetDirection(block, UI_RIGHT);
1573         uiTextBoundsBlock(block, 60);
1574                 
1575         return block;
1576 }
1577
1578 static void do_info_help_systemmenu(void *arg, int event)
1579 {
1580         /* events >=10 are registered bpython scripts */
1581         if (event >= 10) BPY_menu_do_python(PYMENU_HELPSYSTEM, event - 10);
1582         else {
1583                 switch(event) {
1584
1585                 case 1: /* Benchmark */
1586                         /* dodgy hack turning on CTRL ALT SHIFT key to do a benchmark 
1587                          *      rather than copying lines and lines of code from toets.c :( 
1588                          */
1589         
1590                         if(select_area(SPACE_VIEW3D)) {
1591                                 mainqenter(LEFTSHIFTKEY, 1);
1592                                 mainqenter(LEFTCTRLKEY, 1);
1593                                 mainqenter(LEFTALTKEY, 1);
1594                                 mainqenter(TKEY, 1);
1595                                 mainqenter(TKEY, 0);
1596                                 mainqenter(EXECUTE, 1);
1597                                 mainqenter(LEFTSHIFTKEY, 0);
1598                                 mainqenter(LEFTCTRLKEY, 0);
1599                                 mainqenter(LEFTALTKEY, 0);
1600                         }
1601                         break;
1602                 }
1603         }
1604
1605         allqueue(REDRAWVIEW3D, 0);
1606 }
1607
1608
1609 static uiBlock *info_help_systemmenu(void *arg_unused)
1610 {
1611         uiBlock *block;
1612         BPyMenu *pym;
1613         short yco = 20, menuwidth = 120;
1614         int i = 0;
1615
1616         block= uiNewBlock(&curarea->uiblocks, "info_help_systemmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1617         uiBlockSetButmFunc(block, do_info_help_systemmenu, NULL);
1618         
1619         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Benchmark",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
1620         
1621         for (pym = BPyMenuTable[PYMENU_HELPSYSTEM]; pym; pym = pym->next, i++) {
1622                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i+10, pym->tooltip?pym->tooltip:pym->filename);
1623         }
1624         
1625         uiBlockSetDirection(block, UI_RIGHT);
1626         uiTextBoundsBlock(block, 60);
1627                 
1628         return block;
1629 }
1630
1631 static void do_info_helpmenu(void *arg, int event)
1632 {
1633         ScrArea *sa;
1634
1635         if(curarea->spacetype==SPACE_INFO) {
1636                 sa= find_biggest_area_of_type(SPACE_SCRIPT);
1637                 if (!sa) sa= closest_bigger_area();
1638                 areawinset(sa->win);
1639         }
1640
1641         /* events >=10 are registered bpython scripts */
1642         if (event >= 10) BPY_menu_do_python(PYMENU_HELP, event - 10);
1643         else {
1644                 switch(event) {
1645                                                                         
1646                 case 0: /* About Blender */
1647                         break;
1648                 }
1649         }
1650
1651         allqueue(REDRAWINFO, 0);
1652 }
1653
1654 static uiBlock *info_helpmenu(void *arg_unused)
1655 {
1656 /*              static short tog=0; */
1657         uiBlock *block;
1658         short yco= 0;
1659         short menuwidth=120;
1660         BPyMenu *pym;
1661         int i = 0;
1662         
1663         block= uiNewBlock(&curarea->uiblocks, "info_helpmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
1664         uiBlockSetButmFunc(block, do_info_helpmenu, NULL);
1665         
1666         uiDefIconTextBut(block, BUTM, B_SHOWSPLASH, ICON_BLANK1, "About Blender...",    0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
1667         
1668         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1669         
1670         for (pym = BPyMenuTable[PYMENU_HELP]; pym; pym = pym->next, i++) {
1671                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i+10, pym->tooltip?pym->tooltip:pym->filename);
1672         }
1673         
1674         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1675         
1676         uiDefIconTextBlockBut(block, info_help_websitesmenu, NULL, ICON_RIGHTARROW_THIN, "Websites", 0, yco-=20, 120, 19, "");
1677         
1678         uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1679         
1680         uiDefIconTextBlockBut(block, info_help_systemmenu, NULL, ICON_RIGHTARROW_THIN, "System", 0, yco-=20, 120, 19, "");
1681
1682         uiBlockSetDirection(block, UI_DOWN);
1683         uiTextBoundsBlock(block, 80);
1684
1685         return block;
1686 }
1687
1688 /************************** END MAIN MENU *****************************/
1689 /* ugly global yes, for renderwin.c to write to */
1690 char info_time_str[32]="";
1691
1692 static void info_text(int x, int y)
1693 {
1694         Object *ob;
1695         extern float hashvectf[];
1696         extern int mem_in_use;
1697         unsigned int swatch_color;
1698         float fac1, fac2, fac3;
1699         char infostr[300];
1700         char *headerstr;
1701         int hsize;
1702
1703         if(G.obedit) {
1704                 sprintf(infostr,"Ve:%d-%d | Fa:%d-%d | Mem:%.2fM ",
1705                 G.totvertsel, G.totvert, G.totfacesel, G.totface,
1706                 (mem_in_use>>10)/1024.0);
1707         }
1708         else {
1709                 sprintf(infostr,"Ve:%d | Fa:%d | Ob:%d-%d | La:%d | Mem:%.2fM | Time:%s | ",
1710                         G.totvert, G.totface, G.totobj, G.totobjsel, G.totlamp,  (mem_in_use>>10)/1024.0, info_time_str);
1711         }
1712         ob= OBACT;
1713         if(ob) {
1714                 strcat(infostr, ob->id.name+2);
1715         }
1716
1717         if      (g_progress_bar) {
1718                 hsize = 4 + (138.0 * g_done);
1719                 fac1 = 0.5 * g_done; // do some rainbow colours on progress
1720                 fac2 = 1.0;
1721                 fac3 = 0.9;
1722         } else {
1723                 hsize = 142;
1724                 /* promise! Never change these lines again! (zr & ton did!) */
1725                 fac1= fabs(hashvectf[ 2*G.version+4]);
1726                 fac2= 0.5+0.1*hashvectf[ G.version+3];
1727                 fac3= 0.7;
1728         }
1729
1730         if (g_progress_bar && g_progress_info) {
1731                 headerstr= g_progress_info;
1732         } else {
1733                 headerstr= versionstr; 
1734         }
1735         
1736         swatch_color= hsv_to_cpack(fac1, fac2, fac3);
1737
1738         cpack( swatch_color );
1739         glRecti(x-24,  y-6,  x-22+hsize,        y+14);
1740
1741         glColor3ub(0, 0, 0);
1742
1743         glRasterPos2i(x, y);
1744
1745         BIF_DrawString(G.font, headerstr, (U.transopts & USER_TR_MENUS));
1746                 
1747         glRasterPos2i(x+122,    y);
1748
1749         BIF_DrawString(G.font, infostr, (U.transopts & USER_TR_MENUS));
1750 }
1751
1752 void info_buttons(void)
1753 {
1754         uiBlock *block;
1755         short xco= 42;
1756         int xmax;
1757
1758         block= uiNewBlock(&curarea->uiblocks, "header info", UI_EMBOSSN, UI_HELV, curarea->headwin);
1759
1760         if(area_is_active_area(curarea)) uiBlockSetCol(block, TH_HEADER);
1761         else uiBlockSetCol(block, TH_HEADERDESEL);
1762         
1763         if(curarea->flag & HEADER_NO_PULLDOWN) {
1764                 uiDefIconButS(block, TOG|BIT|0, B_FLIPINFOMENU, ICON_DISCLOSURE_TRI_RIGHT,
1765                                 xco,2,XIC,YIC-2,
1766                                 &(curarea->flag), 0, 0, 0, 0, "Enables display of pulldown menus");
1767         } else {
1768                 uiDefIconButS(block, TOG|BIT|0, B_FLIPINFOMENU, ICON_DISCLOSURE_TRI_DOWN,
1769                                 xco,2,XIC,YIC-2,
1770                                 &(curarea->flag), 0, 0, 0, 0, "Hides pulldown menus");
1771         }
1772         xco+=XIC;
1773
1774         if((curarea->flag & HEADER_NO_PULLDOWN)==0) {
1775         
1776                 uiBlockSetEmboss(block, UI_EMBOSSP);
1777
1778                 /* the 'xmax - 3' rather than xmax is to prevent some weird flickering where the highlighted
1779                  * menu is drawn wider than it should be. The ypos of -1 is to make it properly fill the
1780                  * height of the header */
1781                 xmax= GetButStringLength("File");
1782                 uiDefBlockBut(block, info_filemenu, NULL, "File",       xco, -1, xmax-3, 22, "");
1783                 xco+= xmax;
1784
1785                 xmax= GetButStringLength("Add");
1786                 uiDefBlockBut(block, info_addmenu, NULL, "Add", xco, -1, xmax-3, 22, "");
1787                 xco+= xmax;
1788
1789                 xmax= GetButStringLength("Timeline");
1790                 uiDefBlockBut(block, info_timelinemenu, NULL, "Timeline",       xco, -1, xmax-3, 22, "");
1791                 xco+= xmax;
1792
1793                 xmax= GetButStringLength("Game");
1794                 uiDefBlockBut(block, info_gamemenu, NULL, "Game",       xco, -1, xmax-3, 22, "");
1795                 xco+= xmax;
1796
1797                 xmax= GetButStringLength("Render");
1798                 uiDefBlockBut(block, info_rendermenu, NULL, "Render",   xco, -1, xmax-3, 22, "");
1799                 xco+= xmax;
1800
1801                 xmax= GetButStringLength("Help");
1802                 uiDefBlockBut(block, info_helpmenu, NULL, "Help",       xco, -1, xmax-3, 22, "");
1803                 xco+= xmax;
1804
1805         }
1806
1807         /* pack icon indicates a packed file */
1808         
1809         if (G.fileflags & G_AUTOPACK) {
1810                 uiBlockSetEmboss(block, UI_EMBOSSN);
1811                 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.");
1812                 xco += XIC;
1813         }
1814
1815         if (curarea->full == 0) {
1816                 curarea->butspacetype= SPACE_INFO;
1817                 uiBlockSetEmboss(block, UI_EMBOSS);
1818                 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.");
1819                 
1820                 /* STD SCREEN BUTTONS */
1821                 xco= std_libbuttons(block, xco, 0, 0, NULL, B_INFOSCR, (ID *)G.curscreen, 0, &G.curscreen->screennr, 1, 1, B_INFODELSCR, 0, 0);
1822                 
1823                 xco +=8;
1824         
1825                 /* STD SCENE BUTTONS */
1826                 xco= std_libbuttons(block, xco, 0, 0, NULL, B_INFOSCE, (ID *)G.scene, 0, &G.curscreen->scenenr, 1, 1, B_INFODELSCE, 0, 0);
1827         }
1828         else xco= 430;
1829         
1830         info_text(xco+24, 6);
1831         
1832         uiBlockSetEmboss(block, UI_EMBOSSN);
1833         uiDefIconBut(block, BUT, B_SHOWSPLASH, ICON_BLENDER, xco+2, 0,XIC,YIC, 0, 0, 0, 0, 0, "Click to display Splash Screen");
1834
1835         /* always do as last */
1836         curarea->headbutlen= xco+2*XIC;
1837
1838 #ifdef _WIN32   // FULLSCREEN
1839         if(U.uiflag & USER_FLIPFULLSCREEN) {
1840                 uiDefIconBut(block, BUT, B_FLIPFULLSCREEN, ICON_WINDOW_WINDOW,
1841                                 (short)(curarea->winx-XIC-5), 0,XIC,YIC,
1842                                 0, 0, 0, 0, 0, "Toggles Blender to fullscreen mode");/* dir             */
1843         } else {
1844                 uiDefIconBut(block, BUT, B_FLIPFULLSCREEN, ICON_WINDOW_FULLSCREEN,
1845                                 (short)(curarea->winx-XIC-5), 0,XIC,YIC,
1846                                 0, 0, 0, 0, 0, "Toggles Blender to fullscreen mode");/* dir             */
1847         }
1848 #endif
1849         
1850         uiDrawBlock(block);
1851 }