added "fake user" button (basically a shortcut for pressing Shift+F4 and F)
[blender.git] / source / blender / src / headerbuttons.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  */
32
33 #include <string.h>
34 #include <math.h>
35
36 #include <sys/types.h>
37
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #ifdef WIN32
43 #include "BLI_winstuff.h"
44 #endif
45
46 #include "MEM_guardedalloc.h"
47
48 #include "BMF_Api.h"
49
50 #include "BLI_blenlib.h"
51 #include "BLI_arithb.h"
52 #include "BLI_editVert.h"
53 #include "BLI_storage_types.h"
54
55 #include "IMB_imbuf_types.h"
56 #include "IMB_imbuf.h"
57
58 #include "DNA_ID.h"
59 #include "DNA_action_types.h"
60 #include "DNA_armature_types.h"
61 #include "DNA_camera_types.h"
62 #include "DNA_curve_types.h"
63 #include "DNA_group_types.h"
64 #include "DNA_image_types.h"
65 #include "DNA_ipo_types.h"
66 #include "DNA_key_types.h"
67 #include "DNA_lamp_types.h"
68 #include "DNA_lattice_types.h"
69 #include "DNA_material_types.h"
70 #include "DNA_mesh_types.h"
71 #include "DNA_meta_types.h"
72 #include "DNA_object_types.h"
73 #include "DNA_oops_types.h"
74 #include "DNA_packedFile_types.h"
75 #include "DNA_scene_types.h"
76 #include "DNA_screen_types.h"
77 #include "DNA_sequence_types.h"
78 #include "DNA_sound_types.h"
79 #include "DNA_space_types.h"
80 #include "DNA_texture_types.h"
81 #include "DNA_text_types.h"
82 #include "DNA_userdef_types.h"
83 #include "DNA_view2d_types.h"
84 #include "DNA_view3d_types.h"
85 #include "DNA_world_types.h"
86 #include "DNA_constraint_types.h"
87
88 #include "BKE_utildefines.h"
89
90 #include "BKE_constraint.h"
91 #include "BKE_action.h"
92 #include "BKE_armature.h"
93 #include "BKE_blender.h"
94 #include "BKE_curve.h"
95 #include "BKE_displist.h"
96 #include "BKE_exotic.h"
97 #include "BKE_global.h"
98 #include "BKE_image.h"
99 #include "BKE_ika.h"
100 #include "BKE_ipo.h"
101 #include "BKE_key.h"
102 #include "BKE_lattice.h"
103 #include "BKE_library.h"
104 #include "BKE_main.h"
105 #include "BKE_material.h"
106 #include "BKE_mball.h"
107 #include "BKE_mesh.h"
108 #include "BKE_object.h"
109 #include "BKE_packedFile.h"
110 #include "BKE_sca.h"
111 #include "BKE_scene.h"
112 #include "BKE_texture.h"
113 #include "BKE_text.h"
114 #include "BKE_world.h"
115
116 #include "BLO_readfile.h"
117 #include "BLO_writefile.h"
118
119 #include "BIF_drawimage.h"
120 #include "BIF_drawoops.h"
121 #include "BIF_drawscene.h"
122 #include "BIF_drawtext.h"
123 #include "BIF_editarmature.h"
124 #include "BIF_editfont.h"
125 #include "BIF_editlattice.h"
126 #include "BIF_editconstraint.h"
127 #include "BIF_editmesh.h"
128 #include "BIF_editmesh.h"
129 #include "BIF_editsima.h"
130 #include "BIF_editsound.h"
131 #include "BIF_editsound.h"
132 #include "BIF_gl.h"
133 #include "BIF_imasel.h"
134 #include "BIF_interface.h"
135 #include "BIF_mainqueue.h"
136 #include "BIF_mywindow.h"
137 #include "BIF_poseobject.h"
138 #include "BIF_renderwin.h"
139 #include "BIF_resources.h"
140 #include "BIF_screen.h"
141 #include "BIF_space.h"
142 #include "BIF_toets.h"
143 #include "BIF_toets.h"
144 #include "BIF_toolbox.h"
145 #include "BIF_usiblender.h"
146 #include "BIF_previewrender.h"
147 #include "BIF_writeimage.h"
148
149 #include "BSE_edit.h"
150 #include "BSE_filesel.h"
151 #include "BSE_headerbuttons.h"
152 #include "BSE_view.h"
153 #include "BSE_sequence.h"
154 #include "BSE_editaction.h"
155 #include "BSE_editaction_types.h"
156 #include "BSE_editipo.h"
157 #include "BSE_drawipo.h"
158
159 #include "BDR_drawmesh.h"
160 #include "BDR_vpaint.h"
161 #include "BDR_editface.h"
162 #include "BDR_editobject.h"
163 #include "BDR_editcurve.h"
164 #include "BDR_editmball.h"
165
166 #include "BPY_extern.h" // Blender Python library
167
168 #include "interface.h"
169 #include "mydevice.h"
170 #include "blendef.h"
171 #include "render.h"
172 #include "ipo.h"
173 #include "nla.h"        /* __NLA : To be removed later */
174
175 #include "TPT_DependKludge.h"
176
177 /* local (?) functions */
178 void do_file_buttons(short event);
179 void do_text_buttons(unsigned short event);
180 void load_space_sound(char *str);
181 void load_sound_buttons(char *str);
182 void load_space_image(char *str);
183 void image_replace(Image *old, Image *new);
184 void replace_space_image(char *str);
185 void do_image_buttons(unsigned short event);
186 void do_imasel_buttons(short event);
187 static void check_packAll(void);
188 static void unique_bone_name(Bone *bone, bArmature *arm);
189 static void validate_bonebutton(void *data1, void *data2);
190 static int bonename_exists(Bone *orig, char *name, ListBase *list);
191
192 static  void test_idbutton_cb(void *namev, void *arg2_unused)
193 {
194         char *name= namev;
195         test_idbutton(name+2);
196 }
197
198 #define SPACEICONMAX    13 /* See release/datafiles/blenderbuttons */
199
200 #include "BIF_poseobject.h"
201
202 #include "SYS_System.h"
203
204 static int std_libbuttons(uiBlock *block, 
205                                                   int xco, int pin, short *pinpoin, 
206                                                   int browse, ID *id, ID *parid, 
207                                                   short *menupoin, int users, 
208                                                   int lib, int del, int autobut, int keepbut);
209
210
211 extern char versionstr[]; /* from blender.c */
212 /*  extern                void add_text_fs(char *file);  *//* from text.c, BIF_text.h*/
213
214  /* LET OP:  alle headerbuttons voor zelfde window steeds zelfde naam
215   *                     event B_REDR is standaard redraw
216   *
217   */
218
219
220 /*
221  * The next define turns the newest menu structure on.
222  * There are some loose ends here at the moment so leave this undefined for now.
223  */
224 /* #define EXPERIMENTAL_MENUS */
225
226
227 #define XIC 20
228 #define YIC 20
229
230 static int viewmovetemp=0;
231
232 /*  extern void info_buttons(); in BSE_headerbuttons.c */
233
234 extern char videosc_dir[];      /* exotic.c */
235
236 /* *********************************************************************** */
237
238 void write_videoscape_fs()
239 {
240         if(G.obedit) {
241                 error("Can't save Videoscape. Press TAB to leave EditMode");
242         }
243         else {
244                 if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
245                 activate_fileselect(FILE_SPECIAL, "SAVE VIDEOSCAPE", videosc_dir, write_videoscape);
246         }
247 }
248
249 void write_vrml_fs()
250 {
251         if(G.obedit) {
252                 error("Can't save VRML. Press TAB to leave EditMode");
253         }
254         else {
255                 if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
256         
257                 activate_fileselect(FILE_SPECIAL, "SAVE VRML1", videosc_dir, write_vrml);
258         }
259         
260 }
261
262 void write_dxf_fs()
263 {
264         if(G.obedit) {
265                 error("Can't save DXF. Press TAB to leave EditMode");
266         }
267         else {
268
269                 if(videosc_dir[0]==0) strcpy(videosc_dir, G.sce);
270
271                 activate_fileselect(FILE_SPECIAL, "SAVE DXF", videosc_dir, write_dxf);  
272         }
273 }
274
275 /* ********************** GLOBAL ****************************** */
276
277 static int std_libbuttons(uiBlock *block, int xco, int pin, short *pinpoin, int browse, ID *id, ID *parid, short *menupoin, int users, int lib, int del, int autobut, int keepbut)
278 {
279         ListBase *lb;
280         Object *ob;
281         Ipo *ipo;
282         uiBut *but;
283         int len, idwasnul=0, idtype, oldcol;
284         char *str=NULL, str1[10];
285         
286         oldcol= uiBlockGetCol(block);
287
288         if(id && pin) {
289                 uiDefIconButS(block, ICONTOG, pin, ICON_PIN_DEHLT,      (short)xco,0,XIC,YIC, pinpoin, 0, 0, 0, 0, "Pin this data block; no update according Object selection");
290                 xco+= XIC;
291         }
292         if(browse) {
293                 if(id==0) {
294                         idwasnul= 1;
295                         /* alleen de browse button */
296                         ob= OBACT;
297                         if(curarea->spacetype==SPACE_IMAGE) {
298                                 id= G.main->image.first;
299                         }
300                         else if(curarea->spacetype==SPACE_SOUND) {
301                                 id= G.main->sound.first;
302                         }
303                         else if(curarea->spacetype==SPACE_ACTION) {
304                                 id= G.main->action.first;
305                         }
306                         else if(curarea->spacetype==SPACE_NLA) {
307                                 id=NULL;
308                         }
309                         else if(curarea->spacetype==SPACE_IPO) {
310                                 id= G.main->ipo.first;
311                                 /* testen op ipotype */
312                                 while(id) {
313                                         ipo= (Ipo *)id;
314                                         if(G.sipo->blocktype==ipo->blocktype) break;
315                                         id= id->next;
316                                 }
317                         }
318                         else if(curarea->spacetype==SPACE_BUTS) {
319                                 if(browse==B_WORLDBROWSE) {
320                                         id= G.main->world.first;
321                                 }
322                                 else if(ob && ob->type && (ob->type<OB_LAMP)) {
323                                         if(G.buts->mainb==BUTS_MAT) id= G.main->mat.first;
324                                         else if(G.buts->mainb==BUTS_TEX) id= G.main->tex.first;
325                                 }
326                         }
327                         else if(curarea->spacetype==SPACE_TEXT) {
328                                 id= G.main->text.first;
329                         }
330                 }
331                 if(id) {
332                         char *extrastr= NULL;
333                         
334                         idtype= GS(id->name);
335                         lb= wich_libbase(G.main, GS(id->name));
336                         
337                         if(idwasnul) id= NULL;
338                         else if(id->us>1) uiBlockSetCol(block, BUTDBLUE);
339
340                         if (pin && *pinpoin) {
341                                 uiBlockSetCol(block, BUTDPINK);
342                         }
343                         
344                         if ELEM7( idtype, ID_SCE, ID_SCR, ID_MA, ID_TE, ID_WO, ID_IP, ID_AC) extrastr= "ADD NEW %x 32767";
345                         else if (idtype==ID_TXT) extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
346                         else if (idtype==ID_SO) extrastr= "OPEN NEW %x 32766";
347                         
348                         uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
349                         if( idtype==ID_SCE || idtype==ID_SCR ) uiClearButLock();
350                         
351                         if(curarea->spacetype==SPACE_BUTS)
352                                 uiSetButLock(idtype!=ID_SCR && G.obedit!=0 && G.buts->mainb==BUTS_EDIT, NULL);
353                         
354                         if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
355
356                         if (lb) {
357                                 if( idtype==ID_IP)
358                                         IPOnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin, G.sipo->blocktype);
359                                 else
360                                         IDnames_to_pupstring(&str, NULL, extrastr, lb, id, menupoin);
361                         }
362                         
363                         uiDefButS(block, MENU, browse, str, (short)xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browse Datablock or Add NEW");
364                         
365                         uiClearButLock();
366                 
367                         MEM_freeN(str);
368                         xco+= XIC;
369                 }
370                 else if(curarea->spacetype==SPACE_BUTS) {
371                         if ELEM3(G.buts->mainb, BUTS_MAT, BUTS_TEX, BUTS_WORLD) {
372                                 uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
373                                 if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
374                                 uiDefButS(block, MENU, browse, "ADD NEW %x 32767",(short) xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browse Datablock");
375                                 uiClearButLock();
376                         } else if (G.buts->mainb == BUTS_SOUND) {
377                                 uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",(short) xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browse Datablock");
378                         }
379                 }
380                 else if(curarea->spacetype==SPACE_TEXT) {
381                         uiDefButS(block, MENU, browse, "OPEN NEW %x 32766 | ADD NEW %x 32767", (short)xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browse Datablock");
382                 }
383                 else if(curarea->spacetype==SPACE_SOUND) {
384                         uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",(short)xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browse Datablock");
385                 }
386                 else if(curarea->spacetype==SPACE_NLA) {
387                 }
388                 else if(curarea->spacetype==SPACE_ACTION) {
389                         uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
390                         if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
391
392                         uiDefButS(block, MENU, browse, "ADD NEW %x 32767", xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browse Datablock");
393                         uiClearButLock();
394                 }
395                 else if(curarea->spacetype==SPACE_IPO) {
396                         uiSetButLock(G.scene->id.lib!=0, "Can't edit library data");
397                         if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
398
399                         uiDefButS(block, MENU, browse, "ADD NEW %x 32767", (short)xco,0,XIC,YIC, menupoin, 0, 0, 0, 0, "Browse Datablock");
400                         uiClearButLock();
401                 }
402         }
403
404
405         uiBlockSetCol(block, oldcol);
406
407         if(id) {
408         
409                 /* name */
410                 if(id->us>1) uiBlockSetCol(block, BUTDBLUE);
411                 /* Pinned data ? */
412                 if (pin && *pinpoin) {
413                         uiBlockSetCol(block, BUTDPINK);
414                 }
415                 /* Redalert overrides pin color */
416                 if(id->us<=0) uiBlockSetCol(block, REDALERT);
417
418                 uiSetButLock(id->lib!=0, "Can't edit library data");
419                 
420                 str1[0]= id->name[0];
421                 str1[1]= id->name[1];
422                 str1[2]= ':';
423                 str1[3]= 0;
424                 if(strcmp(str1, "SC:")==0) strcpy(str1, "SCE:");
425                 else if(strcmp(str1, "SR:")==0) strcpy(str1, "SCR:");
426                 
427                 if( GS(id->name)==ID_IP) len= 110;
428                 else len= 120;
429                 
430                 but= uiDefBut(block, TEX, B_IDNAME, str1,(short)xco, 0, (short)len, YIC, id->name+2, 0.0, 19.0, 0, 0, "Datablock name");
431                 uiButSetFunc(but, test_idbutton_cb, id->name, NULL);
432
433                 uiClearButLock();
434
435                 xco+= len;
436                 
437                 if(id->lib) {
438                         
439                         if(parid && parid->lib) uiDefIconBut(block, BUT, 0, ICON_DATALIB,(short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Indirect Library Datablock");
440                         else uiDefIconBut(block, BUT, lib, ICON_PARLIB, (short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Library DataBlock, press to make local");
441                         
442                         xco+= XIC;
443                 }
444                 
445                 
446                 if(users && id->us>1) {
447                         uiSetButLock (pin && *pinpoin, "Can't make pinned data single-user");
448                         
449                         sprintf(str1, "%d", id->us);
450                         if(id->us<100) {
451                                 
452                                 uiDefBut(block, BUT, users, str1,       (short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Number of users,  press to make single-user");
453                                 xco+= XIC;
454                         }
455                         else {
456                                 uiDefBut(block, BUT, users, str1,       (short)xco, 0, XIC+10, YIC, 0, 0, 0, 0, 0, "Number of users,  press to make single-user");
457                                 xco+= XIC+10;
458                         }
459                         
460                         uiClearButLock();
461                         
462                 }
463                 
464                 if(del) {
465
466                         uiSetButLock (pin && *pinpoin, "Can't unlink pinned data");
467                         if(parid && parid->lib);
468                         else {
469                                 uiDefIconBut(block, BUT, del, ICON_X,   (short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Delete link to this Datablock");
470                                 xco+= XIC;
471                         }
472
473                         uiClearButLock();
474                 }
475
476                 if(autobut) {
477                         if(parid && parid->lib);
478                         else {
479                                 uiDefIconBut(block, BUT, autobut, ICON_AUTO,(short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Automatic name");
480                                 xco+= XIC;
481                         }
482                         
483                         
484                 }
485                 if(keepbut) {
486                         uiDefBut(block, BUT, keepbut, "F", (short)xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Keep Datablock");      
487                         xco+= XIC;
488                 }
489         }
490         else xco+=XIC;
491         
492         uiBlockSetCol(block, oldcol);
493
494         return xco;
495 }
496
497 void update_for_newframe(void)
498 {
499         allqueue(REDRAWVIEW3D, 0);
500         allqueue(REDRAWACTION,0);
501         allqueue(REDRAWNLA,0);
502         allqueue(REDRAWIPO, 0);
503         allqueue(REDRAWINFO, 1);
504         allqueue(REDRAWSEQ, 1);
505         allqueue(REDRAWSOUND, 1);
506         allqueue(REDRAWBUTSHEAD, 1);
507         allqueue(REDRAWBUTSMAT, 1);
508         allqueue(REDRAWBUTSLAMP, 1);
509
510         /* layers/materials, object ipos are calculted in where_is_object (too) */
511         do_all_ipos();
512         BPY_do_all_scripts(SCRIPT_FRAMECHANGED);
513         do_all_keys();
514         do_all_actions();
515         do_all_ikas();
516
517         test_all_displists();
518 }
519
520 static void show_splash(void)
521 {
522         extern char datatoc_splash_jpg[];
523         extern int datatoc_splash_jpg_size;
524         char *string = NULL;
525
526 #ifdef NAN_BUILDINFO
527         char buffer[1024];
528         extern char * build_date;
529         extern char * build_time;
530         extern char * build_platform;
531         extern char * build_type;
532
533         string = &buffer[0];
534         sprintf(string,"Built on %s %s     Version %s %s", build_date, build_time, build_platform, build_type);
535 #endif
536
537         splash((void *)datatoc_splash_jpg, datatoc_splash_jpg_size, string);
538 }
539
540 void do_global_buttons(unsigned short event)
541 {
542         ListBase *lb;
543         Object *ob;
544         Material *ma;
545         MTex *mtex;
546         Ipo *ipo;
547         Lamp *la;
548         World *wrld;
549         Sequence *seq;
550         bAction *act;
551         ID *id, *idtest, *from;
552         int nr= 1;
553
554         
555         ob= OBACT;
556         
557         id= 0;  /* id op nul voor texbrowse */
558         
559
560         switch(event) {
561         
562         case B_NEWFRAME:
563                 scrarea_queue_winredraw(curarea);
564                 scrarea_queue_headredraw(curarea);
565
566                 update_for_newframe();
567                 break;          
568         case B_REDR:
569                 scrarea_queue_winredraw(curarea);
570                 scrarea_queue_headredraw(curarea);
571                 break;
572         case B_EDITBROWSE:
573                 if(ob==0) return;
574                 if(ob->id.lib) return;
575                 id= ob->data;
576                 if(id==0) return;
577
578                 if(G.buts->menunr== -2) {
579                         activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_EDITBROWSE, &G.buts->menunr, do_global_buttons);
580                         return;
581                 }
582                 if(G.buts->menunr < 0) return;
583                 
584                 lb= wich_libbase(G.main, GS(id->name));
585                 idtest= lb->first;
586                 while(idtest) {
587                         if(nr==G.buts->menunr) {
588                                 if(idtest!=id) {
589                                         id->us--;
590                                         id_us_plus(idtest);
591                                         
592                                         ob->data= idtest;
593                                         
594                                         test_object_materials(idtest);
595                                         
596                                         if( GS(idtest->name)==ID_CU ) {
597                                                 test_curve_type(ob);
598                                                 allqueue(REDRAWBUTSEDIT, 0);
599                                                 makeDispList(ob);
600                                         }
601                                         else if( ob->type==OB_MESH ) {
602                                                 makeDispList(ob);
603                                         }
604                                         
605                                         allqueue(REDRAWBUTSEDIT, 0);
606                                         allqueue(REDRAWVIEW3D, 0);
607                                         allqueue(REDRAWACTION,0);
608                                         allqueue(REDRAWIPO, 0);
609                                         allqueue(REDRAWNLA,0);
610                                 }
611                                 break;
612                         }
613                         nr++;
614                         idtest= idtest->next;
615                 }
616
617                 break;
618         case B_MESHBROWSE:
619                 if(ob==0) return;
620                 if(ob->id.lib) return;
621                 
622                 id= ob->data;
623                 if(id==0) id= G.main->mesh.first;
624                 if(id==0) return;
625                 
626                 if(G.buts->menunr== -2) {
627                         activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_MESHBROWSE, &G.buts->menunr, do_global_buttons);
628                         return;
629                 }
630                 if(G.buts->menunr < 0) return;
631                 
632
633                 idtest= G.main->mesh.first;
634                 while(idtest) {
635                         if(nr==G.buts->menunr) {
636                                         
637                                 set_mesh(ob, (Mesh *)idtest);
638                                 
639                                 allqueue(REDRAWBUTSEDIT, 0);
640                                 allqueue(REDRAWVIEW3D, 0);
641                                 allqueue(REDRAWACTION,0);
642                                 allqueue(REDRAWIPO, 0);
643
644                                 break;
645                         }
646                         nr++;
647                         idtest= idtest->next;
648                 }
649
650                 break;
651         case B_MATBROWSE:
652                 if(G.buts->menunr== -2) {
653                         activate_databrowse((ID *)G.buts->lockpoin, ID_MA, 0, B_MATBROWSE, &G.buts->menunr, do_global_buttons);
654                         return;
655                 }
656                 
657                 if(G.buts->menunr < 0) return;
658                 
659                 if(G.buts->pin) {
660                         
661                 }
662                 else {
663                         
664                         ma= give_current_material(ob, ob->actcol);
665                         nr= 1;
666                         
667                         id= (ID *)ma;
668                         
669                         idtest= G.main->mat.first;
670                         while(idtest) {
671                                 if(nr==G.buts->menunr) {
672                                         break;
673                                 }
674                                 nr++;
675                                 idtest= idtest->next;
676                         }
677                         if(idtest==0) { /* new mat */
678                                 if(id)  idtest= (ID *)copy_material((Material *)id);
679                                 else {
680                                         idtest= (ID *)add_material("Material");
681                                 }
682                                 idtest->us--;
683                         }
684                         if(idtest!=id) {
685                                 assign_material(ob, (Material *)idtest, ob->actcol);
686                                 
687                                 allqueue(REDRAWBUTSHEAD, 0);
688                                 allqueue(REDRAWBUTSMAT, 0);
689                                 allqueue(REDRAWIPO, 0);
690                                 BIF_preview_changed(G.buts);
691                         }
692                         
693                 }
694                 break;
695         case B_MATDELETE:
696                 if(G.buts->pin) {
697                         
698                 }
699                 else {
700                         ma= give_current_material(ob, ob->actcol);
701                         if(ma) {
702                                 assign_material(ob, 0, ob->actcol);
703                                 allqueue(REDRAWBUTSHEAD, 0);
704                                 allqueue(REDRAWBUTSMAT, 0);
705                                 allqueue(REDRAWIPO, 0);
706                                 BIF_preview_changed(G.buts);
707                         }
708                 }
709                 break;
710         case B_TEXDELETE:
711                 if(G.buts->pin) {
712                         
713                 }
714                 else {
715                         if(G.buts->texfrom==0) {        /* from mat */
716                                 ma= give_current_material(ob, ob->actcol);
717                                 if(ma) {
718                                         mtex= ma->mtex[ ma->texact ];
719                                         if(mtex) {
720                                                 if(mtex->tex) mtex->tex->id.us--;
721                                                 MEM_freeN(mtex);
722                                                 ma->mtex[ ma->texact ]= 0;
723                                                 allqueue(REDRAWBUTSTEX, 0);
724                                                 allqueue(REDRAWIPO, 0);
725                                                 BIF_preview_changed(G.buts);
726                                         }
727                                 }
728                         }
729                         else if(G.buts->texfrom==1) {   /* from world */
730                                 wrld= G.scene->world;
731                                 if(wrld) {
732                                         mtex= wrld->mtex[ wrld->texact ];
733                                         if(mtex) {
734                                                 if(mtex->tex) mtex->tex->id.us--;
735                                                 MEM_freeN(mtex);
736                                                 wrld->mtex[ wrld->texact ]= 0;
737                                                 allqueue(REDRAWBUTSTEX, 0);
738                                                 allqueue(REDRAWIPO, 0);
739                                                 BIF_preview_changed(G.buts);
740                                         }
741                                 }
742                         }
743                         else {  /* from lamp */
744                                 la= ob->data;
745                                 if(la && ob->type==OB_LAMP) {   /* voor zekerheid */
746                                         mtex= la->mtex[ la->texact ];
747                                         if(mtex) {
748                                                 if(mtex->tex) mtex->tex->id.us--;
749                                                 MEM_freeN(mtex);
750                                                 la->mtex[ la->texact ]= 0;
751                                                 allqueue(REDRAWBUTSTEX, 0);
752                                                 allqueue(REDRAWIPO, 0);
753                                                 BIF_preview_changed(G.buts);
754                                         }
755                                 }
756                         }
757                 }
758                 break;
759         case B_EXTEXBROWSE:     
760         case B_TEXBROWSE:
761
762                 if(G.buts->texnr== -2) {
763                         
764                         id= G.buts->lockpoin;
765                         if(event==B_EXTEXBROWSE) {
766                                 id= 0;
767                                 ma= give_current_material(ob, ob->actcol);
768                                 if(ma) {
769                                         mtex= ma->mtex[ ma->texact ];
770                                         if(mtex) id= (ID *)mtex->tex;
771                                 }
772                         }
773                         
774                         activate_databrowse(id, ID_TE, 0, B_TEXBROWSE, &G.buts->texnr, do_global_buttons);
775                         return;
776                 }
777                 if(G.buts->texnr < 0) break;
778                 
779                 if(G.buts->pin) {
780                         
781                 }
782                 else {
783                         id= 0;
784                         
785                         ma= give_current_material(ob, ob->actcol);
786                         if(ma) {
787                                 mtex= ma->mtex[ ma->texact ];
788                                 if(mtex) id= (ID *)mtex->tex;
789                         }
790
791                         idtest= G.main->tex.first;
792                         while(idtest) {
793                                 if(nr==G.buts->texnr) {
794                                         break;
795                                 }
796                                 nr++;
797                                 idtest= idtest->next;
798                         }
799                         if(idtest==0) { /* new tex */
800                                 if(id)  idtest= (ID *)copy_texture((Tex *)id);
801                                 else idtest= (ID *)add_texture("Tex");
802                                 idtest->us--;
803                         }
804                         if(idtest!=id && ma) {
805                                 
806                                 if( ma->mtex[ma->texact]==0) ma->mtex[ma->texact]= add_mtex();
807                                 
808                                 ma->mtex[ ma->texact ]->tex= (Tex *)idtest;
809                                 id_us_plus(idtest);
810                                 if(id) id->us--;
811                                 
812                                 allqueue(REDRAWBUTSHEAD, 0);
813                                 allqueue(REDRAWBUTSTEX, 0);
814                                 allqueue(REDRAWBUTSMAT, 0);
815                                 allqueue(REDRAWIPO, 0);
816                                 BIF_preview_changed(G.buts);
817                         }
818                 }
819                 break;
820         case B_ACTIONDELETE:
821                 act=ob->action;
822                 
823                 if (act)
824                         act->id.us--;
825                 ob->action=NULL;
826                 allqueue(REDRAWACTION, 0);
827                 allqueue(REDRAWNLA, 0);
828                 allqueue(REDRAWIPO, 0);
829                 break;
830         case B_ACTIONBROWSE:
831                 if (!ob)
832                         break;
833                 act=ob->action;
834                 id= (ID *)act;
835
836                 if (G.saction->actnr== -2){
837                                 activate_databrowse((ID *)G.saction->action, ID_AC,  0, B_ACTIONBROWSE, &G.saction->actnr, do_global_buttons);
838                         return;
839                 }
840
841                 if(G.saction->actnr < 0) break;
842
843                 /*      See if we have selected a valid action */
844                 for (idtest= G.main->action.first; idtest; idtest= idtest->next) {
845                                 if(nr==G.saction->actnr) {
846                                         break;
847                                 }
848                                 nr++;
849                         
850                 }
851
852                 if(G.saction->pin) {
853                         G.saction->action= (bAction *)idtest;
854                         allqueue(REDRAWACTION, 0);
855                 }
856                 else {
857
858                         /* Store current action */
859                         if (!idtest){
860                                 if (act)
861                                         idtest= (ID *)copy_action(act);
862                                 else 
863                                         idtest=(ID *)add_empty_action();
864                                 idtest->us--;
865                         }
866                         
867                         
868                         if(idtest!=id && ob) {
869                                 act= (bAction *)idtest;
870                                 
871                                 ob->action= act;
872                                 ob->activecon=NULL;
873                                 id_us_plus(idtest);
874                                 
875                                 if(id) id->us--;
876                                 
877                                 // Update everything
878                                 do_global_buttons (B_NEWFRAME);
879                                 allqueue(REDRAWVIEW3D, 0);
880                                 allqueue(REDRAWNLA, 0);
881                                 allqueue(REDRAWACTION, 0);
882                                 allqueue(REDRAWHEADERS, 0);     
883                         }
884                 }
885                 
886                 break;
887         case B_IPOBROWSE:
888
889                 ipo= get_ipo_to_edit(&from);
890                 id= (ID *)ipo;
891                 if(from==0) return;
892
893                 if(G.sipo->menunr== -2) {
894                         activate_databrowse((ID *)G.sipo->ipo, ID_IP, GS(from->name), B_IPOBROWSE, &G.sipo->menunr, do_global_buttons);
895                         return;
896                 }
897
898                 if(G.sipo->menunr < 0) break;
899
900                 idtest= G.main->ipo.first;
901                 while(idtest) {
902                         if( ((Ipo *)idtest)->blocktype == G.sipo->blocktype) {
903                                 if(nr==G.sipo->menunr) {
904                                         break;
905                                 }
906                                 nr++;
907                         }
908                         idtest= idtest->next;
909                 }
910
911                 if(G.sipo->pin) {
912                         if(idtest) {
913                                 G.sipo->ipo= (Ipo *)idtest;
914                                 allspace(REMAKEIPO, 0);         // in fact it should only do this one, but there is no function for it
915                         }
916                 }
917                 else {
918                         // assign the ipo to ...
919
920                         if(idtest==0) {
921                                 if(ipo) idtest= (ID *)copy_ipo(ipo);
922                                 else {
923                                         nr= GS(from->name);
924                                         if(nr==ID_OB){
925                                                 if (G.sipo->blocktype==IPO_CO)
926                                                         idtest= (ID *)add_ipo("CoIpo", IPO_CO); /* BLEARGH! */
927                                                 else
928                                                         idtest= (ID *)add_ipo("ObIpo", nr);
929                                         }
930                                         else if(nr==ID_MA) idtest= (ID *)add_ipo("MatIpo", nr);
931                                         else if(nr==ID_SEQ) idtest= (ID *)add_ipo("MatSeq", nr);
932                                         else if(nr==ID_CU) idtest= (ID *)add_ipo("CuIpo", nr);
933                                         else if(nr==ID_KE) idtest= (ID *)add_ipo("KeyIpo", nr);
934                                         else if(nr==ID_WO) idtest= (ID *)add_ipo("WoIpo", nr);
935                                         else if(nr==ID_LA) idtest= (ID *)add_ipo("LaIpo", nr);
936                                         else if(nr==ID_CA) idtest= (ID *)add_ipo("CaIpo", nr);
937                                         else if(nr==ID_SO) idtest= (ID *)add_ipo("SndIpo", nr);
938                                         else if(nr==ID_AC) idtest= (ID *)add_ipo("ActIpo", nr);
939                                         else error("Warn bugs@blender.nl!");
940                                 }
941                                 idtest->us--;
942                         }
943                         if(idtest!=id && from) {
944                                 ipo= (Ipo *)idtest;
945                 
946                                 if (ipo->blocktype==IPO_CO){
947                                         ((Object*)from)->activecon->ipo = ipo;
948                                         id_us_plus(idtest);
949                                         allqueue(REDRAWVIEW3D, 0);
950                                         allqueue(REDRAWACTION, 0);
951                                         allqueue(REDRAWNLA, 0);
952                                 }
953                                 else if(ipo->blocktype==ID_OB) {
954                                         ( (Object *)from)->ipo= ipo;
955                                         id_us_plus(idtest);
956                                         allqueue(REDRAWVIEW3D, 0);
957                                 }
958                                 else if(ipo->blocktype==ID_AC) {
959                                         bActionChannel *chan;
960                                         chan = get_hilighted_action_channel ((bAction*)from);
961                                         if (!chan){
962                                                 error ("Create an action channel first");
963                                                 return;
964                                         }
965                                         chan->ipo=ipo;
966                                         id_us_plus(idtest);
967                                         allqueue(REDRAWNLA, 0);
968                                         allqueue(REDRAWACTION, 0);
969                                 }
970                                 else if(ipo->blocktype==ID_MA) {
971                                         ( (Material *)from)->ipo= ipo;
972                                         id_us_plus(idtest);
973                                         allqueue(REDRAWBUTSMAT, 0);
974                                 }
975                                 else if(ipo->blocktype==ID_SEQ) {
976                                         seq= (Sequence *)from;
977                                         if(seq->type & SEQ_EFFECT) {
978                                                 id_us_plus(idtest);
979                                                 seq->ipo= ipo;
980                                         }
981                                 }
982                                 else if(ipo->blocktype==ID_CU) {
983                                         ( (Curve *)from)->ipo= ipo;
984                                         id_us_plus(idtest);
985                                         allqueue(REDRAWVIEW3D, 0);
986                                 }
987                                 else if(ipo->blocktype==ID_KE) {
988                                         ( (Key *)from)->ipo= ipo;
989                                         
990                                         id_us_plus(idtest);
991                                         allqueue(REDRAWVIEW3D, 0);
992                                         
993                                 }
994                                 else if(ipo->blocktype==ID_WO) {
995                                         ( (World *)from)->ipo= ipo;
996                                         id_us_plus(idtest);
997                                         allqueue(REDRAWBUTSWORLD, 0);
998                                 }
999                                 else if(ipo->blocktype==ID_LA) {
1000                                         ( (Lamp *)from)->ipo= ipo;
1001                                         id_us_plus(idtest);
1002                                         allqueue(REDRAWBUTSLAMP, 0);
1003                                 }
1004                                 else if(ipo->blocktype==ID_CA) {
1005                                         ( (Camera *)from)->ipo= ipo;
1006                                         id_us_plus(idtest);
1007                                         allqueue(REDRAWBUTSEDIT, 0);
1008                                 }
1009                                 else if(ipo->blocktype==ID_SO) {
1010                                         ( (bSound *)from)->ipo= ipo;
1011                                         id_us_plus(idtest);
1012                                         allqueue(REDRAWBUTSEDIT, 0);
1013                                 }
1014                                 else
1015                                         printf("error in browse ipo \n");
1016                                 
1017                                 if(id) id->us--;
1018                                 
1019                                 scrarea_queue_winredraw(curarea);
1020                                 scrarea_queue_headredraw(curarea);
1021                                 allqueue(REDRAWIPO, 0);
1022                         }
1023                 }
1024                 break;
1025         case B_IPODELETE:
1026                 ipo= get_ipo_to_edit(&from);
1027                 if(from==0) return;
1028                 
1029                 ipo->id.us--;
1030                 
1031                 if(ipo->blocktype==ID_OB) ( (Object *)from)->ipo= 0;
1032                 else if(ipo->blocktype==ID_MA) ( (Material *)from)->ipo= 0;
1033                 else if(ipo->blocktype==ID_SEQ) ( (Sequence *)from)->ipo= 0;
1034                 else if(ipo->blocktype==ID_CU) ( (Curve *)from)->ipo= 0;
1035                 else if(ipo->blocktype==ID_KE) ( (Key *)from)->ipo= 0;
1036                 else if(ipo->blocktype==ID_WO) ( (World *)from)->ipo= 0;
1037                 else if(ipo->blocktype==ID_LA) ( (Lamp *)from)->ipo= 0;
1038                 else if(ipo->blocktype==ID_WO) ( (World *)from)->ipo= 0;
1039                 else if(ipo->blocktype==ID_CA) ( (Camera *)from)->ipo= 0;
1040                 else if(ipo->blocktype==ID_SO) ( (bSound *)from)->ipo= 0;
1041                 else if(ipo->blocktype==ID_AC) get_hilighted_action_channel((bAction*)from)->ipo= 0;
1042                 else if(ipo->blocktype==IPO_CO) ((Object *)from)->activecon->ipo= 0;
1043
1044                 else error("Warn bugs@blender.nl!");
1045                 
1046                 editipo_changed(G.sipo, 1);     /* doredraw */
1047                 allqueue(REDRAWIPO, 0);
1048                 allqueue(REDRAWNLA, 0);
1049                 allqueue (REDRAWACTION, 0);
1050                 
1051                 break;
1052         case B_WORLDBROWSE:
1053
1054                 if(G.buts->menunr==-2) {
1055                         activate_databrowse((ID *)G.scene->world, ID_WO, 0, B_WORLDBROWSE, &G.buts->menunr, do_global_buttons);
1056                         break;
1057                 }
1058
1059                 if(G.buts->menunr < 0) break;
1060                 /* geen lock */
1061                         
1062                 wrld= G.scene->world;
1063                 nr= 1;
1064                 
1065                 id= (ID *)wrld;
1066                 
1067                 idtest= G.main->world.first;
1068                 while(idtest) {
1069                         if(nr==G.buts->menunr) {
1070                                 break;
1071                         }
1072                         nr++;
1073                         idtest= idtest->next;
1074                 }
1075                 if(idtest==0) { /* new world */
1076                         if(id) idtest= (ID *)copy_world((World *)id);
1077                         else idtest= (ID *)add_world("World");
1078                         idtest->us--;
1079                 }
1080                 if(idtest!=id) {
1081                         G.scene->world= (World *)idtest;
1082                         id_us_plus(idtest);
1083                         if(id) id->us--;
1084                         
1085                         allqueue(REDRAWBUTSHEAD, 0);
1086                         allqueue(REDRAWBUTSWORLD, 0);
1087                         allqueue(REDRAWIPO, 0);
1088                         BIF_preview_changed(G.buts);
1089                 }
1090                 break;
1091         case B_WORLDDELETE:
1092                 if(G.scene->world) {
1093                         G.scene->world->id.us--;
1094                         G.scene->world= 0;
1095                         allqueue(REDRAWBUTSWORLD, 0);
1096                         allqueue(REDRAWIPO, 0);
1097                 }
1098                 
1099                 break;
1100         case B_WTEXBROWSE:
1101
1102                 if(G.buts->texnr== -2) {
1103                         id= 0;
1104                         wrld= G.scene->world;
1105                         if(wrld) {
1106                                 mtex= wrld->mtex[ wrld->texact ];
1107                                 if(mtex) id= (ID *)mtex->tex;
1108                         }
1109
1110                         activate_databrowse((ID *)id, ID_TE, 0, B_WTEXBROWSE, &G.buts->texnr, do_global_buttons);
1111                         return;
1112                 }
1113                 if(G.buts->texnr < 0) break;
1114
1115                 if(G.buts->pin) {
1116                         
1117                 }
1118                 else {
1119                         id= 0;
1120                         
1121                         wrld= G.scene->world;
1122                         if(wrld) {
1123                                 mtex= wrld->mtex[ wrld->texact ];
1124                                 if(mtex) id= (ID *)mtex->tex;
1125                         }
1126
1127                         idtest= G.main->tex.first;
1128                         while(idtest) {
1129                                 if(nr==G.buts->texnr) {
1130                                         break;
1131                                 }
1132                                 nr++;
1133                                 idtest= idtest->next;
1134                         }
1135                         if(idtest==0) { /* new tex */
1136                                 if(id)  idtest= (ID *)copy_texture((Tex *)id);
1137                                 else idtest= (ID *)add_texture("Tex");
1138                                 idtest->us--;
1139                         }
1140                         if(idtest!=id && wrld) {
1141                                 
1142                                 if( wrld->mtex[wrld->texact]==0) {
1143                                         wrld->mtex[wrld->texact]= add_mtex();
1144                                         wrld->mtex[wrld->texact]->texco= TEXCO_VIEW;
1145                                 }
1146                                 wrld->mtex[ wrld->texact ]->tex= (Tex *)idtest;
1147                                 id_us_plus(idtest);
1148                                 if(id) id->us--;
1149                                 
1150                                 allqueue(REDRAWBUTSHEAD, 0);
1151                                 allqueue(REDRAWBUTSTEX, 0);
1152                                 allqueue(REDRAWBUTSWORLD, 0);
1153                                 allqueue(REDRAWIPO, 0);
1154                                 BIF_preview_changed(G.buts);
1155                         }
1156                 }
1157                 break;
1158         case B_LAMPBROWSE:
1159                 /* geen lock */
1160                 if(ob==0) return;
1161                 if(ob->type!=OB_LAMP) return;
1162
1163                 if(G.buts->menunr== -2) {
1164                         activate_databrowse((ID *)G.buts->lockpoin, ID_LA, 0, B_LAMPBROWSE, &G.buts->menunr, do_global_buttons);
1165                         return;
1166                 }
1167                 if(G.buts->menunr < 0) break;
1168                 
1169                 la= ob->data;
1170                 nr= 1;
1171                 id= (ID *)la;
1172                 
1173                 idtest= G.main->lamp.first;
1174                 while(idtest) {
1175                         if(nr==G.buts->menunr) {
1176                                 break;
1177                         }
1178                         nr++;
1179                         idtest= idtest->next;
1180                 }
1181                 if(idtest==0) { /* geen new lamp */
1182                         return;
1183                 }
1184                 if(idtest!=id) {
1185                         ob->data= (Lamp *)idtest;
1186                         id_us_plus(idtest);
1187                         if(id) id->us--;
1188                         
1189                         allqueue(REDRAWBUTSHEAD, 0);
1190                         allqueue(REDRAWBUTSLAMP, 0);
1191                         allqueue(REDRAWVIEW3D, 0);
1192                         allqueue(REDRAWIPO, 0);
1193                         BIF_preview_changed(G.buts);
1194                 }
1195                 break;
1196         
1197         case B_LTEXBROWSE:
1198
1199                 if(ob==0) return;
1200                 if(ob->type!=OB_LAMP) return;
1201
1202                 if(G.buts->texnr== -2) {
1203                         id= 0;
1204                         la= ob->data;
1205                         mtex= la->mtex[ la->texact ];
1206                         if(mtex) id= (ID *)mtex->tex;
1207
1208                         activate_databrowse(id, ID_TE, 0, B_LTEXBROWSE, &G.buts->texnr, do_global_buttons);
1209                         return;
1210                 }
1211                 if(G.buts->texnr < 0) break;
1212
1213                 if(G.buts->pin) {
1214                         
1215                 }
1216                 else {
1217                         id= 0;
1218                         
1219                         la= ob->data;
1220                         mtex= la->mtex[ la->texact ];
1221                         if(mtex) id= (ID *)mtex->tex;
1222
1223                         idtest= G.main->tex.first;
1224                         while(idtest) {
1225                                 if(nr==G.buts->texnr) {
1226                                         break;
1227                                 }
1228                                 nr++;
1229                                 idtest= idtest->next;
1230                         }
1231                         if(idtest==0) { /* new tex */
1232                                 if(id)  idtest= (ID *)copy_texture((Tex *)id);
1233                                 else idtest= (ID *)add_texture("Tex");
1234                                 idtest->us--;
1235                         }
1236                         if(idtest!=id && la) {
1237                                 
1238                                 if( la->mtex[la->texact]==0) {
1239                                         la->mtex[la->texact]= add_mtex();
1240                                         la->mtex[la->texact]->texco= TEXCO_GLOB;
1241                                 }
1242                                 la->mtex[ la->texact ]->tex= (Tex *)idtest;
1243                                 id_us_plus(idtest);
1244                                 if(id) id->us--;
1245                                 
1246                                 allqueue(REDRAWBUTSHEAD, 0);
1247                                 allqueue(REDRAWBUTSTEX, 0);
1248                                 allqueue(REDRAWBUTSLAMP, 0);
1249                                 allqueue(REDRAWIPO, 0);
1250                                 BIF_preview_changed(G.buts);
1251                         }
1252                 }
1253                 break;
1254         
1255         case B_IMAGEDELETE:
1256                 G.sima->image= 0;
1257                 image_changed(G.sima, 0);
1258                 allqueue(REDRAWIMAGE, 0);
1259                 break;
1260         
1261         case B_AUTOMATNAME:
1262                 automatname(G.buts->lockpoin);
1263                 allqueue(REDRAWBUTSHEAD, 0);
1264                 break;          
1265         case B_AUTOTEXNAME:
1266                 if(G.buts->mainb==BUTS_TEX) {
1267                         autotexname(G.buts->lockpoin);
1268                         allqueue(REDRAWBUTSHEAD, 0);
1269                         allqueue(REDRAWBUTSTEX, 0);
1270                 }
1271                 else if(G.buts->mainb==BUTS_MAT) {
1272                         ma= G.buts->lockpoin;
1273                         if(ma->mtex[ ma->texact]) autotexname(ma->mtex[ma->texact]->tex);
1274                         allqueue(REDRAWBUTSMAT, 0);
1275                 }
1276                 else if(G.buts->mainb==BUTS_WORLD) {
1277                         wrld= G.buts->lockpoin;
1278                         if(wrld->mtex[ wrld->texact]) autotexname(wrld->mtex[wrld->texact]->tex);
1279                         allqueue(REDRAWBUTSWORLD, 0);
1280                 }
1281                 else if(G.buts->mainb==BUTS_LAMP) {
1282                         la= G.buts->lockpoin;
1283                         if(la->mtex[ la->texact]) autotexname(la->mtex[la->texact]->tex);
1284                         allqueue(REDRAWBUTSLAMP, 0);
1285                 }
1286                 break;
1287
1288         case B_RESETAUTOSAVE:
1289                 reset_autosave();
1290                 break;
1291         case B_SOUNDTOGGLE:
1292                 SYS_WriteCommandLineInt(SYS_GetSystem(), "noaudio", (U.gameflags & USERDEF_DISABLE_SOUND));
1293                 break;
1294         case B_SHOWSPLASH:
1295                 show_splash();
1296                 break;
1297         case B_MIPMAPCHANGED:
1298                 set_mipmap(!(U.gameflags & USERDEF_DISABLE_SOUND));
1299                 allqueue(REDRAWVIEW3D, 0);
1300                 break;
1301         case B_NEWSPACE:
1302                 newspace(curarea, curarea->butspacetype);
1303                 break;
1304         case B_LOADTEMP:        /* is button uit space.c */
1305                 BIF_read_autosavefile();
1306                 break;
1307         case B_FULL:
1308                 if(curarea->spacetype!=SPACE_INFO) {
1309                         area_fullscreen();
1310                 }
1311                 break;  
1312
1313         case B_IDNAME:
1314                         /* changing a metaballs name, sadly enough,
1315                          * can require it to be updated because its
1316                          * basis might have changed... -zr
1317                          */
1318                 if (OBACT && OBACT->type==OB_MBALL)
1319                         makeDispList(OBACT);
1320                         
1321                 /* redraw omdat naam veranderd is: nieuwe pup */
1322                 scrarea_queue_headredraw(curarea);
1323                 allqueue(REDRAWBUTSHEAD, 0);
1324                 allqueue(REDRAWINFO, 1);
1325                 allqueue(REDRAWOOPS, 1);
1326                 /* naam scene ook in set PUPmenu */
1327                 if ELEM(curarea->spacetype, SPACE_BUTS, SPACE_INFO) allqueue(REDRAWBUTSALL, 0);
1328
1329                 allqueue(REDRAWHEADERS, 0);
1330
1331                 break;
1332         
1333         case B_KEEPDATA:
1334                 /* keep datablock. similar to pressing FKEY in a fileselect window
1335                  * maybe we can move that stuff to a seperate function? -- sg
1336                  */
1337                 if (curarea->spacetype==SPACE_BUTS) {
1338                         id= (ID *)G.buts->lockpoin;
1339                 } else if(curarea->spacetype==SPACE_IPO) {
1340                         id = (ID *)G.sipo->ipo;
1341                 } /* similar for other spacetypes ? */
1342                 if (id) {
1343                         if( id->flag & LIB_FAKEUSER) {
1344                                 id->flag -= LIB_FAKEUSER;
1345                                 id->us--;
1346                         } else {
1347                                 id->flag |= LIB_FAKEUSER;
1348                                 id->us++;
1349                         }
1350                 }
1351                 allqueue(REDRAWHEADERS, 0);
1352
1353                 break;
1354         }
1355 }
1356
1357
1358 void do_global_buttons2(short event)
1359 {
1360         Base *base;
1361         Object *ob;
1362         Material *ma;
1363         MTex *mtex;
1364         Mesh *me;
1365         Curve *cu;
1366         MetaBall *mb;
1367         Ipo *ipo;
1368         Lamp *la;
1369         Lattice *lt;
1370         World *wrld;
1371         ID *idfrom;     
1372         bAction *act;
1373
1374         /* algemeen: Single User mag als from==LOCAL 
1375          *                       Make Local mag als (from==LOCAL && id==LIB)
1376          */
1377         
1378         ob= OBACT;
1379         
1380         switch(event) {
1381                 
1382         case B_LAMPALONE:
1383                 if(ob && ob->id.lib==0) {
1384                         la= ob->data;
1385                         if(la->id.us>1) {
1386                                 if(okee("Single user")) {
1387                                         ob->data= copy_lamp(la);
1388                                         la->id.us--;
1389                                 }
1390                         }
1391                 }
1392                 break;
1393         case B_LAMPLOCAL:
1394                 if(ob && ob->id.lib==0) {
1395                         la= ob->data;
1396                         if(la->id.lib) {
1397                                 if(okee("Make local")) {
1398                                         make_local_lamp(la);
1399                                 }
1400                         }
1401                 }
1402                 break;
1403         
1404         case B_ARMLOCAL:
1405                 if (ob&&ob->id.lib==0){
1406                         bArmature *arm=ob->data;
1407                         if (arm->id.lib){
1408                                 if(okee("Make local")) {
1409                                         make_local_armature(arm);
1410                                 }
1411                         }
1412                 }
1413                 break;
1414         case B_ARMALONE:
1415                 if(ob && ob->id.lib==0) {
1416                         bArmature *arm=ob->data;
1417                         if(arm->id.us>1) {
1418                                 if(okee("Single user")) {
1419                                         ob->data= copy_armature(arm);
1420                                         arm->id.us--;
1421                                 }
1422                         }
1423                 }
1424                 break;
1425         case B_ACTLOCAL:
1426                 if(ob && ob->id.lib==0) {
1427                         act= ob->action;
1428                         if(act->id.lib) {
1429                                 if(okee("Make local")) {
1430                                         make_local_action(act);
1431                                         allqueue(REDRAWACTION,0);
1432                                 }
1433                         }
1434                 }
1435                 break;
1436         case B_ACTALONE:
1437                 if (ob)
1438                         act= ob->action;
1439                 
1440                 if(ob && ob->id.lib==0) {
1441                         if(act->id.us>1) {
1442                                 if(okee("Single user")) {
1443                                         ob->action=copy_action(act);
1444                                         ob->activecon=NULL;
1445                                         act->id.us--;
1446                                         allqueue(REDRAWACTION, 0);
1447                                 }
1448                         }
1449                 }
1450                 break;
1451
1452         case B_CAMERAALONE:
1453                 if(ob && ob->id.lib==0) {
1454                         Camera *ca= ob->data;
1455                         if(ca->id.us>1) {
1456                                 if(okee("Single user")) {
1457                                         ob->data= copy_camera(ca);
1458                                         ca->id.us--;
1459                                 }
1460                         }
1461                 }
1462                 break;
1463         case B_CAMERALOCAL:
1464                 if(ob && ob->id.lib==0) {
1465                         Camera *ca= ob->data;
1466                         if(ca->id.lib) {
1467                                 if(okee("Make local")) {
1468                                         make_local_camera(ca);
1469                                 }
1470                         }
1471                 }
1472                 break;
1473         case B_WORLDALONE:
1474                 wrld= G.scene->world;
1475                 if(wrld->id.us>1) {
1476                         if(okee("Single user")) {
1477                                 G.scene->world= copy_world(wrld);
1478                                 wrld->id.us--;
1479                         }
1480                 }
1481                 break;
1482         case B_WORLDLOCAL:
1483                 wrld= G.scene->world;
1484                 if(wrld && wrld->id.lib) {
1485                         if(okee("Make local")) {
1486                                 make_local_world(wrld);
1487                         }
1488                 }
1489                 break;
1490
1491         case B_LATTALONE:
1492                 if(ob && ob->id.lib==0) {
1493                         lt= ob->data;
1494                         if(lt->id.us>1) {
1495                                 if(okee("Single user")) {
1496                                         ob->data= copy_lattice(lt);
1497                                         lt->id.us--;
1498                                 }
1499                         }
1500                 }
1501                 break;
1502         case B_LATTLOCAL:
1503                 if(ob && ob->id.lib==0) {
1504                         lt= ob->data;
1505                         if(lt->id.lib) {
1506                                 if(okee("Make local")) {
1507                                         make_local_lattice(lt);
1508                                 }
1509                         }
1510                 }
1511                 break;
1512         
1513         case B_MATALONE:
1514                 if(ob==0) return;
1515                 ma= give_current_material(ob, ob->actcol);
1516                 idfrom= material_from(ob, ob->actcol);
1517                 if(idfrom && idfrom->lib==0) {
1518                         if(ma->id.us>1) {
1519                                 if(okee("Single user")) {
1520                                         ma= copy_material(ma);
1521                                         ma->id.us= 0;
1522                                         assign_material(ob, ma, ob->actcol);
1523                                 }
1524                         }
1525                 }
1526                 break;
1527         case B_MATLOCAL:
1528                 if(ob==0) return;
1529                 idfrom= material_from(ob, ob->actcol);
1530                 if(idfrom->lib==0) {
1531                         ma= give_current_material(ob, ob->actcol);
1532                         if(ma && ma->id.lib) {
1533                                 if(okee("Make local")) {
1534                                         make_local_material(ma);
1535                                 }
1536                         }
1537                 }
1538                 break;
1539
1540         case B_MESHLOCAL:
1541                 if(ob && ob->id.lib==0) {
1542                         me= ob->data;
1543                         if(me && me->id.lib) {
1544                                 if(okee("Make local")) {
1545                                         make_local_mesh(me);
1546                                         make_local_key( me->key );
1547                                 }
1548                         }
1549                 }
1550                 break;
1551
1552         case B_MBALLALONE:
1553                 if(ob && ob->id.lib==0) {
1554                         mb= ob->data;
1555                         if(mb->id.us>1) {
1556                                 if(okee("Single user")) {
1557                                         ob->data= copy_mball(mb);
1558                                         mb->id.us--;
1559                                         if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
1560                                 }
1561                         }
1562                 }
1563                 break;
1564         case B_MBALLLOCAL:
1565                 if(ob && ob->id.lib==0) {
1566                         mb= ob->data;
1567                         if(mb->id.lib) {
1568                                 if(okee("Make local")) {
1569                                         make_local_mball(mb);
1570                                 }
1571                         }
1572                 }
1573                 break;
1574
1575         case B_CURVEALONE:
1576                 if(ob && ob->id.lib==0) {
1577                         cu= ob->data;
1578                         if(cu->id.us>1) {
1579                                 if(okee("Single user")) {
1580                                         ob->data= copy_curve(cu);
1581                                         cu->id.us--;
1582                                         makeDispList(ob);
1583                                         if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
1584                                 }
1585                         }
1586                 }
1587                 break;
1588         case B_CURVELOCAL:
1589                 if(ob && ob->id.lib==0) {
1590                         cu= ob->data;
1591                         if(cu->id.lib) {
1592                                 if(okee("Make local")) {
1593                                         make_local_curve(cu);
1594                                         make_local_key( cu->key );
1595                                         makeDispList(ob);
1596                                 }
1597                         }
1598                 }
1599                 break;
1600                 
1601         case B_TEXALONE:
1602                 if(G.buts->texfrom==0) {        /* from mat */
1603                         if(ob==0) return;
1604                         ma= give_current_material(ob, ob->actcol);
1605                         if(ma && ma->id.lib==0) {
1606                                 mtex= ma->mtex[ ma->texact ];
1607                                 if(mtex->tex && mtex->tex->id.us>1) {
1608                                         if(okee("Single user")) {
1609                                                 mtex->tex->id.us--;
1610                                                 mtex->tex= copy_texture(mtex->tex);
1611                                         }
1612                                 }
1613                         }
1614                 }
1615                 else if(G.buts->texfrom==1) {   /* from world */
1616                         wrld= G.scene->world;
1617                         if(wrld->id.lib==0) {
1618                                 mtex= wrld->mtex[ wrld->texact ];
1619                                 if(mtex->tex && mtex->tex->id.us>1) {
1620                                         if(okee("Single user")) {
1621                                                 mtex->tex->id.us--;
1622                                                 mtex->tex= copy_texture(mtex->tex);
1623                                         }
1624                                 }
1625                         }
1626                 }
1627                 else if(G.buts->texfrom==2) {   /* from lamp */
1628                         if(ob==0 || ob->type!=OB_LAMP) return;
1629                         la= ob->data;
1630                         if(la->id.lib==0) {
1631                                 mtex= la->mtex[ la->texact ];
1632                                 if(mtex->tex && mtex->tex->id.us>1) {
1633                                         if(okee("Single user")) {
1634                                                 mtex->tex->id.us--;
1635                                                 mtex->tex= copy_texture(mtex->tex);
1636                                         }
1637                                 }
1638                         }
1639                 }
1640                 break;
1641         case B_TEXLOCAL:
1642                 if(G.buts->texfrom==0) {        /* from mat */
1643                         if(ob==0) return;
1644                         ma= give_current_material(ob, ob->actcol);
1645                         if(ma && ma->id.lib==0) {
1646                                 mtex= ma->mtex[ ma->texact ];
1647                                 if(mtex->tex && mtex->tex->id.lib) {
1648                                         if(okee("Make local")) {
1649                                                 make_local_texture(mtex->tex);
1650                                         }
1651                                 }
1652                         }
1653                 }
1654                 else if(G.buts->texfrom==1) {   /* from world */
1655                         wrld= G.scene->world;
1656                         if(wrld->id.lib==0) {
1657                                 mtex= wrld->mtex[ wrld->texact ];
1658                                 if(mtex->tex && mtex->tex->id.lib) {
1659                                         if(okee("Make local")) {
1660                                                 make_local_texture(mtex->tex);
1661                                         }
1662                                 }
1663                         }
1664                 }
1665                 else if(G.buts->texfrom==2) {   /* from lamp */
1666                         if(ob==0 || ob->type!=OB_LAMP) return;
1667                         la= ob->data;
1668                         if(la->id.lib==0) {
1669                                 mtex= la->mtex[ la->texact ];
1670                                 if(mtex->tex && mtex->tex->id.lib) {
1671                                         if(okee("Make local")) {
1672                                                 make_local_texture(mtex->tex);
1673                                         }
1674                                 }
1675                         }
1676                 }
1677                 break;
1678         
1679         case B_IPOALONE:
1680                 ipo= get_ipo_to_edit(&idfrom);
1681                 
1682                 if(idfrom && idfrom->lib==0) {
1683                         if(ipo->id.us>1) {
1684                                 if(okee("Single user")) {
1685                                         if(ipo->blocktype==ID_OB) ((Object *)idfrom)->ipo= copy_ipo(ipo);
1686                                         else if(ipo->blocktype==ID_MA) ((Material *)idfrom)->ipo= copy_ipo(ipo);
1687                                         else if(ipo->blocktype==ID_SEQ) ((Sequence *)idfrom)->ipo= copy_ipo(ipo);
1688                                         else if(ipo->blocktype==ID_CU) ((Curve *)idfrom)->ipo= copy_ipo(ipo);
1689                                         else if(ipo->blocktype==ID_KE) ((Key *)idfrom)->ipo= copy_ipo(ipo);
1690                                         else if(ipo->blocktype==ID_LA) ((Lamp *)idfrom)->ipo= copy_ipo(ipo);
1691                                         else if(ipo->blocktype==ID_WO) ((World *)idfrom)->ipo= copy_ipo(ipo);
1692                                         else if(ipo->blocktype==ID_CA) ((Camera *)idfrom)->ipo= copy_ipo(ipo);
1693                                         else if(ipo->blocktype==ID_SO) ((bSound *)idfrom)->ipo= copy_ipo(ipo);
1694                                         else if(ipo->blocktype==ID_AC) get_hilighted_action_channel((bAction *)idfrom)->ipo= copy_ipo(ipo);
1695                                         else if(ipo->blocktype==IPO_CO) ((Object *)idfrom)->activecon->ipo= copy_ipo(ipo);
1696                                         else error("Warn ton!");
1697                                         
1698                                         ipo->id.us--;
1699                                         allqueue(REDRAWIPO, 0);
1700                                 }
1701                         }
1702                 }
1703                 break;
1704         case B_IPOLOCAL:
1705                 ipo= get_ipo_to_edit(&idfrom);
1706                 
1707                 if(idfrom && idfrom->lib==0) {
1708                         if(ipo->id.lib) {
1709                                 if(okee("Make local")) {
1710                                         make_local_ipo(ipo);
1711                                         allqueue(REDRAWIPO, 0);
1712                                 }
1713                         }
1714                 }
1715                 break;
1716
1717         case B_OBALONE:
1718                 if(G.scene->id.lib==0) {
1719                         if(ob->id.us>1) {
1720                                 if(okee("Single user")) {
1721                                         base= FIRSTBASE;
1722                                         while(base) {
1723                                                 if(base->object==ob) {
1724                                                         base->object= copy_object(ob);
1725                                                         ob->id.us--;
1726                                                         allqueue(REDRAWVIEW3D, 0);
1727                                                         break;
1728                                                 }
1729                                                 base= base->next;
1730                                         }
1731                                 }
1732                         }
1733                 }
1734                 break;
1735         case B_OBLOCAL:
1736                 if(G.scene->id.lib==0) {
1737                         if(ob->id.lib) {
1738                                 if(okee("Make local")) {
1739                                         make_local_object(ob);
1740                                         allqueue(REDRAWVIEW3D, 0);
1741                                 }
1742                         }
1743                 }
1744                 break;
1745         case B_MESHALONE:
1746                 if(ob && ob->id.lib==0) {
1747                         
1748                         me= ob->data;
1749                         
1750                         if(me && me->id.us>1) {
1751                                 if(okee("Single user")) {
1752                                         Mesh *men= copy_mesh(me);
1753                                         men->id.us= 0;
1754                                         
1755                                         set_mesh(ob, men);
1756                                         
1757                                         if(ob==G.obedit) allqueue(REDRAWVIEW3D, 0);
1758                                 }
1759                         }
1760                 }
1761                 break;
1762         }
1763         
1764         allqueue(REDRAWBUTSALL, 0);
1765         allqueue(REDRAWOOPS, 0);
1766 }
1767
1768 /* ********************** EMPTY ****************************** */
1769 /* ********************** INFO ****************************** */
1770
1771 int buttons_do_unpack()
1772 {
1773         int how;
1774         char menu[2048];
1775         char line[128];
1776         int ret_value = RET_OK, count = 0;
1777
1778         count = countPackedFiles();
1779
1780         if (count) {
1781                 if (count == 1) {
1782                         sprintf(menu, "Unpack 1 file%%t");
1783                 } else {
1784                         sprintf(menu, "Unpack %d files%%t", count);
1785                 }
1786                 
1787                 sprintf(line, "|Use files in current directory (create when necessary)%%x%d", PF_USE_LOCAL);
1788                 strcat(menu, line);
1789         
1790                 sprintf(line, "|Write files to current directory (overwrite existing files)%%x%d", PF_WRITE_LOCAL);
1791                 strcat(menu, line);
1792         
1793                 sprintf(line, "|%%l|Use files in original location (create when necessary)%%x%d", PF_USE_ORIGINAL);
1794                 strcat(menu, line);
1795         
1796                 sprintf(line, "|Write files to original location (overwrite existing files)%%x%d", PF_WRITE_ORIGINAL);
1797                 strcat(menu, line);
1798         
1799                 sprintf(line, "|%%l|Disable AutoPack, keep all packed files %%x%d", PF_KEEP);
1800                 strcat(menu, line);
1801         
1802                 sprintf(line, "|Ask for each file %%x%d", PF_ASK);
1803                 strcat(menu, line);
1804                 
1805                 how = pupmenu(menu);
1806                 
1807                 if(how != -1) {
1808                         if (how != PF_KEEP) {
1809                                 unpackAll(how);
1810                         }
1811                         G.fileflags &= ~G_AUTOPACK;
1812                 } else {
1813                         ret_value = RET_CANCEL;
1814                 }
1815         } else {
1816                 pupmenu("No packed files. Autopack disabled");
1817         }
1818         
1819         return (ret_value);
1820 }
1821
1822 /* here, because of all creator stuff */
1823
1824 Scene *copy_scene(Scene *sce, int level)
1825 {
1826         /* level 0: alle objects shared
1827          * level 1: alle objectdata shared
1828          * level 2: volledige kopie
1829          */
1830         Scene *scen;
1831         Base *base, *obase;
1832
1833
1834         /* level 0 */
1835         scen= copy_libblock(sce);
1836         duplicatelist(&(scen->base), &(sce->base));
1837         
1838         clear_id_newpoins();
1839         
1840         id_us_plus((ID *)scen->world);
1841         id_us_plus((ID *)scen->set);
1842         
1843         scen->ed= 0;
1844         scen->radio= 0;
1845         
1846         obase= sce->base.first;
1847         base= scen->base.first;
1848         while(base) {
1849                 base->object->id.us++;
1850                 if(obase==sce->basact) scen->basact= base;
1851                 
1852                 obase= obase->next;
1853                 base= base->next;
1854         }
1855         
1856         if(level==0) return scen;
1857         
1858         /* level 1 */
1859         G.scene= scen;
1860         single_object_users(0);
1861
1862         /*  camera */
1863         ID_NEW(G.scene->camera);
1864                 
1865         /* level 2 */
1866         if(level>=2) {
1867                 if(scen->world) {
1868                         scen->world->id.us--;
1869                         scen->world= copy_world(scen->world);
1870                 }
1871                 single_obdata_users(0);
1872                 single_mat_users_expand();
1873                 single_tex_users_expand();
1874         }
1875
1876         clear_id_newpoins();
1877
1878         BPY_copy_scriptlink(&sce->scriptlink);
1879
1880
1881
1882         // make a private copy of the avicodecdata
1883
1884         if (sce->r.avicodecdata) {
1885
1886                 scen->r.avicodecdata = MEM_dupallocN(sce->r.avicodecdata);
1887
1888                 scen->r.avicodecdata->lpFormat = MEM_dupallocN(scen->r.avicodecdata->lpFormat);
1889
1890                 scen->r.avicodecdata->lpParms = MEM_dupallocN(scen->r.avicodecdata->lpParms);
1891
1892         }
1893
1894         return scen;
1895 }
1896
1897 void do_info_buttons(unsigned short event)
1898 {
1899         bScreen *sc, *oldscreen;
1900         Scene *sce, *sce1;
1901         ScrArea *sa;
1902         int nr;
1903         
1904         switch(event) {
1905         
1906         case B_INFOSCR:         /* menu select screen */
1907
1908                 if( G.curscreen->screennr== -2) {
1909                         if(curarea->winy <50) {
1910                                 sa= closest_bigger_area();
1911                                 areawinset(sa->win);
1912                         }
1913                         activate_databrowse((ID *)G.curscreen, ID_SCR, 0, B_INFOSCR, &G.curscreen->screennr, do_info_buttons);
1914                         return;
1915                 }
1916                 if( G.curscreen->screennr < 0) return;
1917                 
1918                 sc= G.main->screen.first;
1919                 nr= 1;
1920                 while(sc) {
1921                         if(nr==G.curscreen->screennr) {
1922                                 if(is_allowed_to_change_screen(sc)) setscreen(sc);
1923                                 else error("Unable to perform function in EditMode");
1924                                 break;
1925                         }
1926                         nr++;
1927                         sc= sc->id.next;
1928                 }
1929                 /* laatste item: NEW SCREEN */
1930                 if(sc==0) {
1931                         duplicate_screen();
1932                 }
1933                 break;
1934         case B_INFODELSCR:
1935                 /* dit event alleen met buttons doen, zodoende nooit vanuit full aanroepbaar */
1936
1937                 if(G.curscreen->id.prev) sc= G.curscreen->id.prev;
1938                 else if(G.curscreen->id.next) sc= G.curscreen->id.next;
1939                 else return;
1940                 if(okee("Delete current screen")) {
1941                         /* vind nieuwe G.curscreen */
1942                         
1943                         oldscreen= G.curscreen;
1944                         setscreen(sc);          /* deze test of sc een full heeft */
1945                         unlink_screen(oldscreen);
1946                         free_libblock(&G.main->screen, oldscreen);
1947                 }
1948                 scrarea_queue_headredraw(curarea);
1949
1950                 break;
1951         case B_INFOSCE:         /* menu select scene */
1952                 
1953                 if( G.obedit) {
1954                         error("Unable to perform function in EditMode");
1955                         return;
1956                 }
1957                 if( G.curscreen->scenenr== -2) {
1958                         if(curarea->winy <50) {
1959                                 sa= closest_bigger_area();
1960                                 areawinset(sa->win);
1961                         }
1962                         activate_databrowse((ID *)G.scene, ID_SCE, 0, B_INFOSCE, &G.curscreen->scenenr, do_info_buttons);
1963                         return;
1964                 }
1965                 if( G.curscreen->scenenr < 0) return;
1966
1967                 sce= G.main->scene.first;
1968                 nr= 1;
1969                 while(sce) {
1970                         if(nr==G.curscreen->scenenr) {
1971                                 if(sce!=G.scene) set_scene(sce);
1972                                 break;
1973                         }
1974                         nr++;
1975                         sce= sce->id.next;
1976                 }
1977                 /* laatste item: NEW SCENE */
1978                 if(sce==0) {
1979                         nr= pupmenu("Add scene%t|Empty|Link Objects|Link ObData|Full Copy");
1980                         if(nr<= 0) return;
1981                         if(nr==1) {
1982                                 sce= add_scene(G.scene->id.name+2);
1983                                 sce->r= G.scene->r;
1984                         }
1985                         else sce= copy_scene(G.scene, nr-2);
1986                         
1987                         set_scene(sce);
1988                 }
1989
1990                 break;
1991         case B_INFODELSCE:
1992                 
1993                 if(G.scene->id.prev) sce= G.scene->id.prev;
1994                 else if(G.scene->id.next) sce= G.scene->id.next;
1995                 else return;
1996                 if(okee("Delete current scene")) {
1997                         
1998                         /* alle sets aflopen */
1999                         sce1= G.main->scene.first;
2000                         while(sce1) {
2001                                 if(sce1->set == G.scene) sce1->set= 0;
2002                                 sce1= sce1->id.next;
2003                         }
2004                         
2005                         /* alle sequences aflopen */
2006                         clear_scene_in_allseqs(G.scene);
2007                         
2008                         /* alle schermen */
2009                         sc= G.main->screen.first;
2010                         while(sc) {
2011                                 if(sc->scene == G.scene) sc->scene= sce;
2012                                 sc= sc->id.next;
2013                         }
2014                         free_libblock(&G.main->scene, G.scene);
2015                         set_scene(sce);
2016                 }
2017         
2018                 break;
2019         case B_FILEMENU:
2020                 tbox_setmain(9);
2021                 toolbox();
2022                 break;
2023         }
2024 }
2025
2026 /* strubi shamelessly abused the status line as a progress bar... 
2027    feel free to kill him after release */
2028
2029 static int      g_progress_bar = 0;
2030 static char *g_progress_info = 0;
2031 static float g_done;
2032
2033 int start_progress_bar(void)
2034 {
2035         g_progress_bar = 1;
2036         return 1;               // we never fail (yet)
2037 }
2038
2039 void end_progress_bar(void)
2040 {
2041         g_progress_bar = 0;
2042 }
2043
2044 static void update_progress_bar(float done, char *info)
2045 {
2046         g_done = done;
2047         g_progress_info = info;
2048 }
2049
2050 /** Progress bar
2051         'done': a value between 0.0 and 1.0, showing progress
2052         'info': a info text what is currently being done
2053
2054         Make sure that the progress bar is always called with:
2055         done = 0.0 first
2056                 and
2057         done = 1.0 last -- or alternatively use:
2058
2059         start_progressbar();
2060         do_stuff_and_callback_progress_bar();
2061         end_progressbar();
2062 */
2063 int progress_bar(float done, char *busy_info)
2064 {
2065         ScrArea *sa;
2066         short val; 
2067
2068         /* User break (ESC) */
2069         while (qtest()) {
2070                 if (extern_qread(&val) == ESCKEY) 
2071                         return 0;
2072         }
2073         if (done == 0.0) {
2074                 start_progress_bar();
2075         } else if (done > 0.99) {
2076                 end_progress_bar();
2077         }
2078
2079         sa= G.curscreen->areabase.first;
2080         while(sa) {
2081                 if (sa->spacetype == SPACE_INFO) {
2082                         update_progress_bar(done, busy_info);
2083
2084                         curarea = sa;
2085
2086                         scrarea_do_headdraw(curarea);
2087                         areawinset(curarea->win);
2088                         sa->head_swap= WIN_BACK_OK;
2089                         screen_swapbuffers();
2090                 }
2091                 sa = sa->next;
2092         }
2093         return 1;
2094 }
2095
2096
2097 static void check_packAll()
2098 {
2099         // first check for dirty images
2100         Image *ima;
2101
2102         ima = G.main->image.first;
2103         while (ima) {
2104                 if (ima->ibuf && (ima->ibuf->userflags &= IB_BITMAPDIRTY)) {
2105                         break;
2106                 }
2107                 ima= ima->id.next;
2108         }
2109         
2110         if (ima == 0 || okee("Some images are painted on. These changes will be lost. Continue ?")) {
2111                 packAll();
2112                 G.fileflags |= G_AUTOPACK;
2113         }
2114 }
2115
2116
2117 /* KEYED FUNCTIONS 
2118    --------------- */
2119
2120 /* this function name is meaningless and only called that way for some
2121    obscurity 
2122    It is called by a function table from the license_key;
2123    see include/keyed_functions.h
2124 */
2125
2126 struct twostrings
2127 {
2128         char *outname;
2129         char *exename;
2130 };
2131
2132 /** This function is called for writing runtimes.
2133   * It's locked behind the key and called through a function table
2134   * which is initialized properly by the Python key code (if valid)
2135   */
2136 int make_beautiful_animation(void *vp) 
2137 {
2138         char *freestr= NULL;
2139         struct twostrings *twostrings = (struct twostrings *) vp;
2140         char *str = twostrings->outname;
2141         char *ext = 0;
2142
2143 #ifdef _WIN32
2144         ext = ".exe";
2145 #endif
2146
2147 #ifdef __APPLE__
2148         ext = ".app";
2149 #endif
2150         if (ext && (!BLI_testextensie(str, ext))) {
2151                 freestr= MEM_mallocN(strlen(str) + strlen(ext) + 1, "write_runtime_check");
2152                 strcpy(freestr, str);
2153                 strcat(freestr, ext);
2154                 str= freestr;
2155         }
2156
2157         if (!BLI_exists(str) || saveover(str))
2158                 BLO_write_runtime(str, twostrings->exename);
2159
2160         if (freestr)
2161                 MEM_freeN(freestr);
2162         
2163         return 0;
2164 }
2165
2166 /*
2167 int make_nice_software(void)
2168 {
2169         Fptr f = KEY_RETURN_TRUE;
2170         if (f) return f(0);
2171         else return 0;
2172 }
2173 */
2174         
2175 static void write_runtime_check_dynamic(char *str) 
2176 {
2177         struct twostrings twostrings;
2178
2179         twostrings.outname = str;
2180         twostrings.exename = "blenderdynplayer.exe";
2181
2182         make_beautiful_animation((void *) &twostrings);
2183 }
2184
2185 static void write_runtime_check(char *str) 
2186 {
2187         struct twostrings twostrings;
2188         char player[128];
2189
2190         twostrings.outname = str;
2191         twostrings.exename = player;
2192
2193         strcpy(player, "blenderplayer");
2194
2195 #ifdef _WIN32
2196         strcat(player, ".exe");
2197 #endif
2198
2199 #ifdef __APPLE__
2200         strcat(player, ".app");
2201 #endif
2202
2203         make_beautiful_animation((void *) &twostrings);
2204 }
2205 /* end keyed functions */
2206
2207
2208 static void do_info_filemenu(void *arg, int event)
2209 {
2210         ScrArea *sa;
2211         char dir[FILE_MAXDIR];
2212         
2213         if(curarea->spacetype==SPACE_INFO) {
2214                 sa= closest_bigger_area();
2215                 areawinset(sa->win);
2216         }
2217
2218         /* these are no defines, easier this way, the codes are in the function below */
2219         switch(event) {
2220         case 0:
2221                 if (okee("ERASE ALL")) {
2222                         if (!BIF_read_homefile())
2223                                 error("No file ~/.B.blend");
2224                 }
2225                 break;
2226         case 1:
2227                 activate_fileselect(FILE_BLENDER, "LOAD FILE", G.sce, BIF_read_file);
2228                 break;
2229         case 2:
2230                 {
2231                         char *s= MEM_mallocN(strlen(G.sce) + 11 + 1, "okee_reload");
2232                         strcpy(s, "Open file: ");
2233                         strcat(s, G.sce);
2234                         if (okee(s))
2235                                 BIF_read_file(G.sce);
2236                         MEM_freeN(s);
2237                 }
2238                 break;
2239         case 3:
2240                 activate_fileselect(FILE_LOADLIB, "LOAD LIBRARY", G.lib, 0);
2241                 break;
2242         case 4:
2243                 strcpy(dir, G.sce);
2244                 untitled(dir);
2245                 activate_fileselect(FILE_BLENDER, "SAVE FILE", dir, BIF_write_file);
2246                 break;
2247         case 5:
2248                 strcpy(dir, G.sce);
2249                 if (untitled(dir)) {
2250                         activate_fileselect(FILE_BLENDER, "SAVE FILE", dir, BIF_write_file);
2251                 } else {
2252                         BIF_write_file(dir);
2253                         free_filesel_spec(dir);
2254                 }
2255                 break;
2256         case 6:
2257                 mainqenter(F3KEY, 1);
2258                 break;
2259         case 7:
2260                 write_vrml_fs();
2261                 break;
2262         case 8:
2263                 write_dxf_fs();
2264                 break;
2265         case 9:
2266                 write_videoscape_fs();
2267                 break;
2268 /*
2269         case 20:
2270                 strcpy(dir, G.sce);
2271                 activate_fileselect(FILE_SPECIAL, "INSTALL LICENSE KEY", dir, loadKeyboard);
2272                 break;
2273         case 21:
2274                 SHOW_LICENSE_KEY();
2275                 break;
2276 */
2277         case 22:
2278                 activate_fileselect(FILE_SPECIAL, "WRITE RUNTIME", "", write_runtime_check);
2279                 break;
2280         case 23:
2281                 activate_fileselect(FILE_SPECIAL, "WRITE DYNAMIC RUNTIME", "", write_runtime_check_dynamic);
2282                 break;
2283         case 30:
2284                 // import menu, no handling
2285                 break;
2286
2287 #ifdef EXPERIMENTAL_MENUS
2288         case 10:
2289                 check_packAll();
2290                 break;
2291         case 11:
2292                 unpackAll(PF_WRITE_LOCAL);
2293                 G.fileflags &= ~G_AUTOPACK;
2294                 break;
2295         case 12:
2296                 if (buttons_do_unpack() != RET_CANCEL) {
2297                         /* Clear autopack bit only if user selected one of the unpack options */
2298                         G.fileflags &= ~G_AUTOPACK;
2299                 }
2300                 break;
2301         case 13:
2302 #else /* EXPERIMENTAL_MENUS */
2303         case 10:
2304 #endif /* EXPERIMENTAL_MENUS */
2305                 exit_usiblender();
2306                 break;          
2307         }
2308         allqueue(REDRAWINFO, 0);
2309 }
2310
2311 void do_info_file_optionsmenu(void *arg, int event)
2312 {
2313         G.fileflags ^= (1 << event);
2314
2315         // allqueue(REDRAWINFO, 0);
2316 }
2317
2318
2319 static uiBlock *info_file_optionsmenu(void *arg_unused)
2320 {
2321         uiBlock *block;
2322         short yco= 0, xco = 20;
2323
2324         block= uiNewBlock(&curarea->uiblocks, "runtime_options", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
2325         uiBlockSetButmFunc(block, do_info_file_optionsmenu, NULL);
2326         uiBlockSetXOfs(block,-40);  // offset to parent button
2327
2328         /* flags are case-values */
2329         uiDefBut(block, BUTM, 1, "Compress File",       xco, yco-=20, 100, 19, NULL, 0.0, 0.0, 0, G_FILE_COMPRESS_BIT, "Use file compression");
2330 /*
2331         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");
2332         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");
2333 */
2334         /* Toggle buttons */
2335         
2336         yco= 0;
2337         xco -= 20;
2338         uiBlockSetEmboss(block, UI_EMBOSSW);
2339         uiBlockSetButmFunc(block, NULL, NULL);
2340         /* flags are defines */
2341         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, "");
2342 /*
2343         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, "");
2344         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, "");
2345 */
2346         uiBlockSetDirection(block, UI_RIGHT);
2347                 
2348         return block;
2349 }
2350
2351 static uiBlock *info_runtime_optionsmenu(void *arg_unused)
2352 {
2353         uiBlock *block;
2354         short yco= 0, xco = 20;
2355
2356         block= uiNewBlock(&curarea->uiblocks, "add_surfacemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
2357         uiBlockSetXOfs(block, -40);  // offset to parent button
2358
2359         uiBlockSetEmboss(block, UI_EMBOSSW);
2360
2361         uiDefBut(block, LABEL, 0, "Size options:",              xco, yco-=20, 114, 19, 0, 0.0, 0.0, 0, 0, "");
2362         uiDefButS(block, NUM, 0, "X:",          xco+19, yco-=20, 95, 19,    &G.scene->r.xplay, 10.0, 2000.0, 0, 0, "X screen/window resolution");
2363         uiDefButS(block, NUM, 0, "Y:",          xco+19, yco-=20, 95, 19, &G.scene->r.yplay, 10.0, 2000.0, 0, 0, "Y screen/window resolution");
2364
2365         uiDefBut(block, SEPR, 0, "",            xco, yco-=4, 114, 4, NULL, 0.0, 0.0, 0, 0, "");
2366
2367         uiDefBut(block, LABEL, 0, "Fullscreen options:",                xco, yco-=20, 114, 19, 0, 0.0, 0.0, 0, 0, "");
2368         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");
2369         uiDefButS(block, NUM, 0, "Freq:",       xco+19, yco-=20, 95, 19, &G.scene->r.freqplay, 10.0, 120.0, 0, 0, "Clock frequency of fullscreen display");
2370         uiDefButS(block, NUM, 0, "Bits:",       xco+19, yco-=20, 95, 19, &G.scene->r.depth, 1.0, 32.0, 0, 0, "Bit depth of full screen disply");
2371
2372         uiDefBut(block, SEPR, 0, "",            xco, yco-=4, 114, 4, NULL, 0.0, 0.0, 0, 0, "");
2373
2374         /* stereo settings */
2375         /* can't use any definition from the game engine here so hardcode it. Change it here when it changes there!
2376          * RAS_IRasterizer has definitions:
2377          * RAS_STEREO_NOSTEREO     1
2378          * RAS_STEREO_QUADBUFFERED 2
2379          * RAS_STEREO_ABOVEBELOW   3
2380          * RAS_STEREO_INTERLACED   4   future
2381          */
2382         uiDefBut(block, LABEL, 0, "Stereo options", xco, yco-=20, 114, 19, 0, 0.0, 0.0, 0, 0, "");
2383         uiDefButS(block, ROW, 0, "no stereo", xco+19, yco-=20, 95, 19, &(G.scene->r.stereomode), 6.0, 1.0, 0, 0, "Disables stereo");
2384         uiDefButS(block, ROW, 0, "h/w pageflip", xco+19, yco-=20, 95, 19, &(G.scene->r.stereomode), 6.0, 2.0, 0, 0, "Enables h/w pageflip stereo method");
2385         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");
2386 #if 0
2387         // future
2388         uiDefButS(block, ROW, 0, "syncdoubling", xco+19, yco, 95, 19, &(G.scene->r.stereomode), 5.0, 4.0, 0, 0, "Enables interlaced stereo method");
2389 #endif
2390
2391         uiBlockSetDirection(block, UI_RIGHT);
2392                 
2393         return block;
2394 }
2395
2396 static uiBlock *info_file_importmenu(void *arg_unused)
2397 {
2398         uiBlock *block;
2399         short yco= 0, xco = 20;
2400
2401         block= uiNewBlock(&curarea->uiblocks, "importmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
2402         uiBlockSetXOfs(block, -40);  // offset to parent button
2403
2404         uiBlockSetEmboss(block, UI_EMBOSSW);
2405
2406         /* flags are defines */
2407         uiDefBut(block, LABEL, 0, "VRML 2.0 options", xco, yco, 125, 19,   NULL, 0.0, 0.0, 0, 0, "");
2408         uiDefButS(block, TOG|BIT|0, 0, "SepLayers", xco, yco-=20, 75, 19,                 &U.vrmlflag, 0.0, 0.0, 0, 0, "Separate Empties, Lamps, etc. into Layers");
2409         uiDefButS(block, TOG|BIT|1, 0, "Scale 1/100", xco, yco-=20, 75, 19,   &U.vrmlflag, 0.0, 0.0, 0, 0, "Scale scene by 1/100 (3DS VRML)");
2410         uiDefButS(block, TOG|BIT|2, 0, "Two Sided", xco, yco-=20, 75, 19,   &U.vrmlflag, 0.0, 0.0, 0, 0, "Import two sided faces");
2411
2412         uiBlockSetDirection(block, UI_RIGHT);
2413                 
2414         return block;
2415 }
2416
2417 static uiBlock *info_filemenu(void *arg_unused)
2418 {
2419         uiBlock *block;
2420         short xco=0;
2421
2422         block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
2423         uiBlockSetButmFunc(block, do_info_filemenu, NULL);
2424         
2425         uiDefBut(block, BUTM, 1, "New|Ctrl X",                          0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Start a new project (and delete the current)");
2426         uiDefBut(block, BUTM, 1, "Open|F1",                                     0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Open a new file");
2427         uiDefBut(block, BUTM, 1, "Reopen Last|Ctrl O",          0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Revert to the last version saved to file");
2428         uiDefBut(block, BUTM, 1, "Append|Shift F1",                     0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "Append contents of a file to the current project");
2429         uiDefBlockBut(block, info_file_importmenu, NULL, "Import Settings|>>", 0, xco-=20, 160, 19, "");
2430
2431         uiDefBut(block, SEPR, 0, "",                                            0, xco-=6, 160, 6, NULL, 0.0, 0.0, 0, 0, "");
2432         uiDefBut(block, BUTM, 1, "Save As|F2",                          0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "Save to a new file");
2433         uiDefBut(block, BUTM, 1, "Save|Ctrl W",                         0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "Save to the current file");
2434
2435         uiDefBlockBut(block, info_file_optionsmenu, NULL, "File options|>>", 0, xco-=20, 160, 19, "Click to open the File Options menu");
2436
2437         uiDefBut(block, SEPR, 0, "",                                            0, xco-=6, 160, 6, NULL, 0.0, 0.0, 0, 0, "");
2438
2439         uiDefBut(block, BUTM, 1, "Save Runtime",                        0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 22, "Create a runtime executable with the current project");
2440 #ifdef _WIN32
2441         uiDefBut(block, BUTM, 1, "Save dynamic Runtime",                        0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 23, "Create a dynamic runtime executable with the current project (requieres extenal python20.dll)");
2442 #endif
2443         uiDefBlockBut(block, info_runtime_optionsmenu, NULL, "Runtime options|>>", 0, xco-=20, 160, 19, "Click to open the File Options menu");
2444
2445         uiDefBut(block, SEPR, 0, "",                                            0, xco-=6, 160, 6, NULL, 0.0, 0.0, 0, 0, "");
2446         uiDefBut(block, BUTM, 1, "Save Image|F3",                       0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 6, "Save the image in the render buffer to a file");
2447         uiDefBut(block, BUTM, 1, "Save VRML 1.0|Ctrl F2",               0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 7, "Save the current scene to a file in VRML 1.0 format");
2448         uiDefBut(block, BUTM, 1, "Save DXF|Shift F2",           0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 8, "Save the current scene to a file in DXF format");
2449         uiDefBut(block, BUTM, 1, "Save VideoScape|Alt W",       0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 9, "Save the current scene to a file in VideoScape format");
2450
2451
2452         /*
2453         if (LICENSE_KEY_VALID) {
2454                 uiDefBut(block, SEPR, 0, "",                                            0, xco-=6, 160, 6, NULL, 0.0, 0.0, 1, 0, "");
2455                 uiDefBut(block, BUTM, 1, "Show License Key", 0, xco-=20,        140, 19, NULL, 0.0, 0.0, 1, 21, "Show the personal information stored in your Blender License Key");
2456                 uiDefIconBut(block, BUTM, 1, ICON_PUBLISHER,                     141,xco,       19,  19, NULL, 0.0, 0.0, 1, 21, "Show the personal information stored in your Blender License Key");
2457         } else if (I_AM_PUBLISHER) {
2458                 uiDefBut(block, SEPR, 0, "",                                            0, xco-=6, 160, 6, NULL, 0.0, 0.0, 1, 0, "");
2459                 uiDefBut(block, BUTM, 1, "Install License Key", 0, xco-=20,     140, 19, NULL, 0.0, 0.0, 1, 20, "Install your Blender License Key");
2460                 uiDefIconBut(block, BUTM, 1, ICON_PUBLISHER,                     141,xco,       19,  19, NULL, 0.0, 0.0, 1, 20, "Install your Blender License Key");
2461         }
2462         */
2463
2464
2465         uiDefBut(block, SEPR, 0, "",                                            0, xco-=6, 160, 6, NULL, 0.0, 0.0, 1, 0, "");
2466
2467 #ifdef EXPERIMENTAL_MENUS
2468         uiDefBut(block, BUTM, 1, "Pack Data",                                           0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 10, "");
2469         uiDefBut(block, BUTM, 1, "Unpack Data to current dir",          0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 11, "");
2470         uiDefBut(block, BUTM, 1, "Advanced Unpack",                                     0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 12, "");
2471         uiDefBut(block, SEPR, 0, "",                                            0, xco-=6, 160, 6, NULL, 0.0, 0.0, 1, 0, "");
2472         uiDefBut(block, BUTM, 1, "Quit | Q",                            0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 13, "Quit Blender immediately");
2473 #else /* EXPERIMENTAL_MENUS */
2474         uiDefBut(block, BUTM, 1, "Quit | Q",                            0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 10, "Quit Blender immediately");
2475 #endif /* EXPERIMENTAL_MENUS */
2476         uiBlockSetDirection(block, UI_DOWN);
2477
2478         
2479         return block;
2480 }
2481
2482 static void do_info_editmenu(void *arg, int event)
2483 {
2484         int oldqual;
2485
2486         switch(event) {
2487                 
2488         case 0:
2489                 /* (De)Select All */
2490                 if(select_area(SPACE_VIEW3D)) mainqenter(AKEY, 1);
2491                 break;
2492                 /* Border Select */
2493         case 1:
2494                 if(select_area(SPACE_VIEW3D)) mainqenter(BKEY, 1);
2495                 break;
2496         case 2:
2497                 /* Circle Select */
2498                 /*if(select_area(SPACE_VIEW3D)) {
2499                         winqread3d(BKEY, 1, 0);
2500                         winqread3d(BKEY, 1, 0);
2501                 }*/
2502                 break;
2503         case 3:
2504                 /* Duplicate */
2505                 if(select_area(SPACE_VIEW3D)) {
2506                         oldqual = G.qual;
2507                         G.qual = LR_SHIFTKEY;
2508                         winqread3d(DKEY, 1, 0);
2509                         G.qual = oldqual;
2510                 }
2511                 break;
2512         case 4:
2513                 /* Delete */
2514                 if(select_area(SPACE_VIEW3D)) {
2515                         winqread3d(XKEY, 1, 0);
2516                 }
2517                 break;
2518         case 5:
2519                 /* Edit Mode */
2520                 if(select_area(SPACE_VIEW3D)) {
2521                         blenderqread(TABKEY, 1);
2522                 }
2523                 break;
2524         case 6:
2525                 /* Grabber */
2526                 if(select_area(SPACE_VIEW3D)) {
2527                         transform('g');
2528                 }
2529                 break;
2530         case 7:
2531                 /* Rotate */
2532                 if(select_area(SPACE_VIEW3D)) {
2533                         transform('r');
2534                 }
2535                 break;
2536         case 8:
2537                 /* Scale */
2538                 if(select_area(SPACE_VIEW3D)) {
2539                         transform('s');
2540                 }
2541                 break;
2542         case 9:
2543                 /* Shear */
2544                 if (!G.obedit) {
2545                         enter_editmode();
2546                         /* ### put these into a deselectall_gen() */
2547                         if(G.obedit->type==OB_MESH) deselectall_mesh();
2548                         else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) deselectall_nurb();
2549                         else if(G.obedit->type==OB_MBALL) deselectall_mball();
2550                         else if(G.obedit->type==OB_LATTICE) deselectall_Latt();
2551                         /* ### */
2552                 }       
2553                 if(select_area(SPACE_VIEW3D)) {
2554                         transform('S');
2555                 }
2556                 break;
2557         case 10:
2558                 /* Warp/Bend */
2559                 if (!G.obedit) {
2560                         enter_editmode();
2561                         /* ### put these into a deselectall_gen() */
2562                         if(G.obedit->type==OB_MESH) deselectall_mesh();
2563                         else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) deselectall_nurb();
2564                         else if(G.obedit->type==OB_MBALL) deselectall_mball();
2565                         else if(G.obedit->type==OB_LATTICE) deselectall_Latt();
2566                         /* ### */
2567                 }       
2568                 if(select_area(SPACE_VIEW3D)) {
2569                         oldqual = G.qual;
2570                         G.qual = LR_SHIFTKEY;
2571                         winqread3d(WKEY, 1, 0);
2572                         G.qual = oldqual;
2573                 }
2574                 break;
2575         case 11:
2576                 /* Snap */
2577                 if(select_area(SPACE_VIEW3D)) {
2578                         oldqual = G.qual;
2579                         G.qual = LR_SHIFTKEY;
2580                         winqread3d(SKEY, 1, 0);
2581                         G.qual = oldqual;
2582                 }
2583                 break;
2584         }
2585         allqueue(REDRAWINFO, 0);
2586 }
2587
2588
2589 static uiBlock *info_editmenu(void *arg_unused)
2590 {
2591 /*      static short tog=0; */
2592         uiBlock *block;
2593         short xco= 0;
2594         
2595         block= uiNewBlock(&curarea->uiblocks, "editmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
2596         uiBlockSetButmFunc(block, do_info_editmenu, NULL);
2597
2598         uiDefBut(block, BUTM, 1, "(De)Select All|A",    0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 0, "Select all objects in the scene or empty the selection");
2599         uiDefBut(block, BUTM, 1, "Border Select|B",             0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 1, "Select objects in a rectangular area (press B again to activate circle select in edit mode)");
2600
2601         /* uiDefBut(block, BUTM, 1, "Circle Select",            0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 2, "Select objects in a circular area"); */
2602         uiDefBut(block, SEPR, 0, "",                                    0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
2603         uiDefBut(block, BUTM, 1, "Duplicate|Shift D",   0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 3, "Duplicate the selected object(s)");
2604         uiDefBut(block, BUTM, 1, "Delete|X",                    0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 4, "Delete the selected object(s)");
2605         uiDefBut(block, BUTM, 1, "Edit Mode|Tab",               0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 5, "Toggle between object and edit mode");
2606         uiDefBut(block, SEPR, 0, "",                                    0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
2607         uiDefBut(block, BUTM, 1, "Grabber|G",                   0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 6, "Move the selected object(s)");
2608         uiDefBut(block, BUTM, 1, "Rotate|R",                    0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 7, "Rotate the selected object(s)");
2609         uiDefBut(block, BUTM, 1, "Scale|S",                             0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 8, "Scale the selected object(s)");
2610         uiDefBut(block, SEPR, 0, "",                                    0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
2611         uiDefBut(block, BUTM, 1, "Shear|Ctrl S",                0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 9, "Shear the selected object(s)");
2612         uiDefBut(block, BUTM, 1, "Warp/Bend|Shift W",   0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 10, "Warp or bend the selected objects");
2613         uiDefBut(block, BUTM, 1, "Snap Menu|Shift S",   0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 11, "Activate the snap menu");
2614         
2615         uiBlockSetDirection(block, UI_DOWN);
2616                 
2617         return block;
2618 }
2619
2620 static void do_info_add_meshmenu(void *arg, int event)
2621 {
2622
2623         switch(event) {         
2624 #ifdef EXPERIMENTAL_MENUS
2625         /* Maarten's proposal for a new Add Mesh menu */
2626                 case 0:
2627                         /* Line */
2628                         //add_primitiveMesh(4);
2629                         break;
2630                 case 1:
2631                         /* Circle */
2632                         if(select_area(SPACE_VIEW3D)) {
2633                                 add_primitiveMesh(4);
2634                         }
2635                         break;
2636                 case 2:
2637                         /* Plane */
2638                         add_primitiveMesh(0);
2639                         break;
2640                 case 3:
2641                         /* Cube */
2642                         add_primitiveMesh(1);
2643                         break;
2644                 case 4:
2645                         /* UVsphere */
2646                         add_primitiveMesh(11);
2647                         break;
2648                 case 5:
2649                         /* IcoSphere */
2650                         add_primitiveMesh(12);
2651                         break;
2652                 case 6:
2653                         /* Cylinder */
2654                         add_primitiveMesh(5);
2655                         break;
2656                 case 7:
2657                         /* Tube */
2658                         add_primitiveMesh(6);
2659                         break;
2660                 case 8:
2661                         /* Cone */
2662                         add_primitiveMesh(7);
2663                         break;
2664                 case 9:
2665                         /* Grid */
2666                         add_primitiveMesh(10);
2667                         break;
2668 #else /* EXPERIMENTAL_MENUS*/ 
2669                 case 0:
2670                         /* Plane */
2671                         add_primitiveMesh(0);
2672                         break;
2673                 case 1:
2674                         /* Cube */
2675                         add_primitiveMesh(1);
2676                         break;
2677                 case 2:
2678                         /* Circle */
2679                         add_primitiveMesh(4);
2680                         break;
2681                 case 3:
2682                         /* UVsphere */
2683                         add_primitiveMesh(11);
2684                         break;
2685                 case 4:
2686                         /* IcoSphere */
2687                         add_primitiveMesh(12);
2688                         break;
2689                 case 5:
2690                         /* Cylinder */
2691                         add_primitiveMesh(5);
2692                         break;
2693                 case 6:
2694                         /* Tube */
2695                         add_primitiveMesh(6);
2696                         break;
2697                 case 7:
2698                         /* Cone */
2699                         add_primitiveMesh(7);
2700                         break;
2701                 case 8:
2702                         /* Grid */
2703                         add_primitiveMesh(10);
2704                         break;
2705 #endif /* EXPERIMENTAL_MENUS */
2706                 default:
2707                         break;
2708         }
2709         allqueue(REDRAWINFO, 0);
2710 }
2711
2712 static uiBlock *info_add_meshmenu(void *arg_unused)
2713 {
2714 /*      static short tog=0; */
2715         uiBlock *block;
2716         short xco= 0;
2717         
2718         block= uiNewBlock(&curarea->uiblocks, "add_meshmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
2719         uiBlockSetButmFunc(block, do_info_add_meshmenu, NULL);
2720
2721 #ifdef EXPERIMENTAL_MENUS
2722         /* Maarten's proposal for a new Add Mesh menu */
2723         uiDefBut(block, BUTM, 1, "Line|",                                       0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Add a Mesh Line");
2724         uiDefBut(block, BUTM, 1, "Circle|",                                     0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Add a Mesh Circle");
2725         uiDefBut(block, SEPR, 0, "",                                            0, xco-=6,  160, 6,  NULL, 0.0, 0.0, 0, 0, "");
2726         uiDefBut(block, BUTM, 1, "Plane|",                                      0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Add a Mesh Plane");
2727         uiDefBut(block, BUTM, 1, "Cube|",                                       0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "Add a Mesh Cube");
2728         uiDefBut(block, BUTM, 1, "UVsphere",                            0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "Add a Mesh Sphere");
2729         uiDefBut(block, BUTM, 1, "IcoSphere|",                          0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "Add a Mesh Isocohedron Sphere");
2730         uiDefBut(block, BUTM, 1, "Cylinder With Caps|",         0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 6, "Add a Mesh Cylinder with caps");
2731         uiDefBut(block, BUTM, 1, "Cylinder Without Caps|",      0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 7, "Add a Mesh Cylinder without caps");
2732         uiDefBut(block, BUTM, 1, "Cone|",                                       0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 8, "Add a Mesh Cone");
2733         uiDefBut(block, BUTM, 1, "Grid|",                                       0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 9, "Add a Mesh Grid");
2734 #else /* EXPERIMENTAL_MENUS */
2735         uiDefBut(block, BUTM, 1, "Plane|",                              0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Add a Mesh Plane");
2736         uiDefBut(block, BUTM, 1, "Cube|",                               0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Add a Mesh Cube");
2737         uiDefBut(block, BUTM, 1, "Circle|",                             0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Add a Mesh Circle");
2738         uiDefBut(block, BUTM, 1, "UVsphere",                    0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "Add a Mesh Sphere");
2739         uiDefBut(block, BUTM, 1, "IcoSphere|",                  0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "Add a Mesh Isocohedron Sphere");
2740         uiDefBut(block, BUTM, 1, "Cylinder|",                   0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "Add a Mesh Cylinder");
2741         uiDefBut(block, BUTM, 1, "Tube|",                               0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 6, "Add a Mesh Tube");
2742         uiDefBut(block, BUTM, 1, "Cone|",                               0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 7, "Add a Mesh Cone");
2743         uiDefBut(block, SEPR, 0, "",                                    0, xco-=6,  160, 6,  NULL, 0.0, 0.0, 0, 0, "");
2744         uiDefBut(block, BUTM, 1, "Grid|",                               0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 8, "Add a Mesh Grid");
2745 #endif /* EXPERIMENTAL_MENUS */
2746
2747         uiBlockSetDirection(block, UI_RIGHT);
2748                 
2749         return block;
2750 }
2751
2752 static void do_info_add_curvemenu(void *arg, int event)
2753 {
2754
2755         switch(event) {         
2756                 case 0:
2757                         /* Bezier Curve */
2758                         add_primitiveCurve(10);
2759                         break;
2760                 case 1:
2761                         /* Bezier Circle */
2762                         add_primitiveCurve(11);
2763                         break;
2764                 case 2:
2765                         /* NURB Curve */
2766                         add_primitiveCurve(40);
2767                         break;
2768                 case 3:
2769                         /* NURB Circle */
2770                         add_primitiveCurve(41);
2771                         break;
2772                 case 4:
2773                         /* Path */
2774                         add_primitiveCurve(46);
2775                         break;
2776                 default:
2777                         break;
2778         }
2779         allqueue(REDRAWINFO, 0);
2780 }
2781
2782 static uiBlock *info_add_curvemenu(void *arg_unused)
2783 {
2784 /*      static short tog=0; */
2785         uiBlock *block;
2786         short xco= 0;
2787         
2788         block= uiNewBlock(&curarea->uiblocks, "add_curvemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
2789         uiBlockSetButmFunc(block, do_info_add_curvemenu, NULL);
2790
2791         uiDefBut(block, BUTM, 1, "Bezier Curve|",       0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Add a Bezier curve");
2792         uiDefBut(block, BUTM, 1, "Bezier Circle|",      0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Add a Bezier circle");
2793         uiDefBut(block, BUTM, 1, "NURBS Curve|",                0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Add a NURB curve");
2794         uiDefBut(block, BUTM, 1, "NURBS Circle",                0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "Add a NURB circle");
2795         uiDefBut(block, BUTM, 1, "Path|",                       0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "Add a path");
2796         
2797         uiBlockSetDirection(block, UI_RIGHT);
2798                 
2799         return block;
2800 }
2801
2802
2803 static void do_info_add_surfacemenu(void *arg, int event)
2804 {
2805
2806         switch(event) {         
2807                 case 0:
2808                         /* Curve */
2809                         add_primitiveNurb(0);
2810                         break;
2811                 case 1:
2812                         /* Circle */
2813                         add_primitiveNurb(1);
2814                         break;
2815                 case 2:
2816                         /* Surface */
2817                         add_primitiveNurb(2);
2818                         break;
2819                 case 3:
2820                         /* Tube */
2821                         add_primitiveNurb(3);
2822                         break;
2823                 case 4:
2824                         /* Sphere */
2825                         add_primitiveNurb(4);
2826                         break;
2827                 case 5:
2828                         /* Donut */
2829                         add_primitiveNurb(5);
2830                         break;
2831                 default:
2832                         break;
2833         }
2834         allqueue(REDRAWINFO, 0);
2835 }
2836
2837 static uiBlock *info_add_surfacemenu(void *arg_unused)
2838 {
2839 /*      static short tog=0; */
2840         uiBlock *block;
2841         short xco= 0;
2842         
2843         block= uiNewBlock(&curarea->uiblocks, "add_surfacemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
2844         uiBlockSetButmFunc(block, do_info_add_surfacemenu, NULL);
2845
2846         uiDefBut(block, BUTM, 1, "NURBS Curve|",                0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "Add a curve");
2847         uiDefBut(block, BUTM, 1, "NURBS Circle|",               0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, "Add a circle");
2848         uiDefBut(block, BUTM, 1, "NURBS Surface|",      0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Add a surface");
2849         uiDefBut(block, BUTM, 1, "NURBS Tube",          0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "Add a tube");
2850         uiDefBut(block, BUTM, 1, "NURBS Sphere|",               0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "Add a sphere");
2851         uiDefBut(block, BUTM, 1, "NURBS Donut|",                0, xco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "Add a donut");
2852
2853         uiBlockSetDirection(block, UI_RIGHT);
2854                 
2855         return block;
2856 }
2857
2858 static void do_info_addmenu(void *arg, int event)
2859 {
2860
2861         switch(event) {         
2862                 case 0:
2863                         /* Mesh */
2864                         break;
2865                 case 1:
2866                         /* Curve */
2867                         break;
2868                 case 2:
2869                         /* Surface */
2870                         break;
2871                 case 3:
2872                         /* Text (argument is discarded) */
2873                         add_primitiveFont(event);
2874                         break;
2875                 case 4:
2876                         /* Metaball  (argument is discarded) */
2877                         add_primitiveMball(event);
2878                         break;
2879                 case 5:
2880                         /* Empty */
2881                         add_object_draw(OB_EMPTY);
2882                         break;
2883                 case 6:
2884                         /* Camera */
2885                         add_object_draw(OB_CAMERA);
2886                         break;
2887                 case 7:
2888                         /* Lamp */
2889                         add_object_draw(OB_LAMP);
2890                         break;
2891                 case 8:
2892                         /* Armature */
2893                         add_primitiveArmature(OB_ARMATURE);
2894                         break;
2895                 case 9:
2896                         /* Lattice */
2897                         add_object_draw(OB_LATTICE);
2898                         break;
2899                 default:
2900                         break;
2901         }
2902         allqueue(REDRAWINFO, 0);
2903 }
2904
2905
2906 static uiBlock *info_addmenu(void *arg_unused)
2907 {
2908 /*      static short tog=0; */
2909         uiBlock *block;
2910         short xco= 0;
2911         
2912         block= uiNewBlock(&curarea->uiblocks, "addmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
2913         uiBlockSetButmFunc(block, do_info_addmenu, NULL);
2914
2915         uiDefBlockBut(block, info_add_meshmenu, NULL, "Mesh|>>", 0, xco-=20, 120, 19, "Click to open the Add Mesh menu");
2916         uiDefBlockBut(block, info_add_curvemenu, NULL, "Curve|>>", 0, xco-=20, 120, 19, "Click to open the Add Curve menu");
2917         uiDefBlockBut(block, info_add_surfacemenu, NULL, "Surface|>>", 0, xco-=20, 120, 19, "Click to open the Add Surface menu");
2918
2919         uiDefBut(block, SEPR, 0, "",                                    0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
2920         uiDefBut(block, BUTM, 1, "Text|",                               0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 3, "");
2921         uiDefBut(block, BUTM, 1, "Metaball|",                   0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 4, "");
2922         uiDefBut(block, BUTM, 1, "Empty|",                              0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 5, "");
2923         uiDefBut(block, SEPR, 0, "",                                    0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
2924         uiDefBut(block, BUTM, 1, "Camera|",                             0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 6, "");
2925         uiDefBut(block, BUTM, 1, "Lamp|",                               0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 7, "");
2926 //      uiDefBut(block, BUTM, 1, "Armature|",                   0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 8, "");
2927         uiDefBut(block, SEPR, 0, "",                                    0, xco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
2928         uiDefBut(block, BUTM, 1, "Lattice|",                    0, xco-=20, 120, 19, NULL, 0.0, 0.0, 1, 9, "");
2929         
2930         uiBlockSetDirection(block, UI_DOWN);
2931                 
2932         return block;
2933 }
2934
2935 static void do_info_viewmenu(void *arg, int event)
2936 {
2937         switch(event) {
2938         case 0:
2939                 if(select_area(SPACE_VIEW3D)) mainqenter(PAD1, 1);
2940                 break;
2941         case 1:
2942                 if(select_area(SPACE_VIEW3D)) mainqenter(PAD3, 1);
2943                 break;
2944         case 2:
2945                 if(select_area(SPACE_VIEW3D)) mainqenter(PAD7, 1);
2946                 break;
2947         case 3:
2948                 if(select_area(SPACE_VIEW3D)) mainqenter(PAD0, 1);
2949                 break;
2950         case 4:
2951                 if(select_area(SPACE_VIEW3D)) mainqenter(PADPLUSKEY, 1);
2952                 break;
2953         case 5:
2954                 if(select_area(SPACE_VIEW3D)) mainqenter(PADMINUS, 1);
2955                 break;
2956         case 6:
2957                 if(select_area(SPACE_VIEW3D)) mainqenter(CKEY, 1);
2958                 break;
2959         case 7:
2960                 if(select_area(SPACE_VIEW3D)) mainqenter(HOMEKEY, 1);
2961                 break;
2962         }
2963         allqueue(REDRAWINFO, 0);
2964 }
2965
2966 static uiBlock *info_viewmenu(void *arg_unused)
2967 {
2968 /*      static short tog=0; */
2969         uiBlock *block;
2970         short xco= 0;
2971         
2972         block= uiNewBlock(&curarea->uiblocks, "filemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
2973         uiBlockSetButmFunc(block, do_info_viewmenu, NULL);
2974
2975         // uiBlockSetCol(block, BUTBLUE);
2976         
2977         uiDefBut(block, BUTM, 1, "Front|NumPad 1",              0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 0, "");
2978         uiDefBut(block, BUTM, 1, "Right|NumPad 3",              0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 1, "");
2979         uiDefBut(block, BUTM, 1, "Top|NumPad 7",                0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 2, "");
2980         uiDefBut(block, BUTM, 1, "Camera|NumPad 0",             0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 3, "");
2981
2982         uiDefBut(block, SEPR, 0, "",                                    0, xco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, "");
2983         uiDefBut(block, BUTM, 1, "Zoom In|NumPad +",    0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 4, "");
2984         uiDefBut(block, BUTM, 1, "Zoom Out|NumPad -",   0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 5, "");
2985         
2986         uiDefBut(block, SEPR, 0, "",                                    0, xco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, "");
2987         uiDefBut(block, BUTM, 1, "Center|C",                    0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 6, "");
2988         uiDefBut(block, BUTM, 1, "View All|Home",               0, xco-=20, 140, 19, NULL, 0.0, 0.0, 0, 7, "");
2989         
2990         uiBlockSetDirection(block, UI_DOWN);
2991         
2992         return block;
2993 }
2994
2995 static void do_game_menu(void *arg, int event)
2996 {
2997         switch (event) {
2998         case G_FILE_ENABLE_ALL_FRAMES_BIT:
2999         case G_FILE_SHOW_FRAMERATE