Bugfix [#26650] Reset to Default Theme doesn't reset Bone Color Sets
[blender-staging.git] / source / blender / editors / interface / resources.c
1 /** \file blender/editors/interface/resources.c
2  *  \ingroup edinterface
3  */
4 /*
5  * $Id$
6  *
7  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version. The Blender
13  * Foundation also sells licenses for use in proprietary software under
14  * the Blender License.  See http://www.blender.org/BL/ for information
15  * about this.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25  *
26  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
27  * All rights reserved.
28  *
29  * The Original Code is: all of this file.
30  *
31  * Contributor(s): none yet.
32  *
33  * ***** END GPL/BL DUAL LICENSE BLOCK *****
34  */
35
36 #include <math.h>
37 #include <stdlib.h>
38 #include <string.h>
39
40 #include "MEM_guardedalloc.h"
41
42 #include "DNA_curve_types.h"
43 #include "DNA_userdef_types.h"
44 #include "DNA_screen_types.h"
45 #include "DNA_space_types.h"
46 #include "DNA_windowmanager_types.h"
47
48 #include "BLI_blenlib.h"
49 #include "BLI_utildefines.h"
50
51 #include "BKE_DerivedMesh.h"
52 #include "BKE_global.h"
53 #include "BKE_main.h"
54 #include "BKE_texture.h"
55
56
57 #include "BIF_gl.h"
58
59 #include "UI_interface.h"
60 #include "UI_interface_icons.h"
61
62 #include "interface_intern.h"
63
64 /* global for themes */
65 typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
66
67 static bTheme *theme_active=NULL;
68 static int theme_spacetype= SPACE_VIEW3D;
69 static int theme_regionid= RGN_TYPE_WINDOW;
70
71 void ui_resources_init(void)
72 {
73         UI_icons_init(BIFICONID_LAST);
74 }
75
76 void ui_resources_free(void)
77 {
78         UI_icons_free();
79 }
80
81
82 /* ******************************************************** */
83 /*    THEMES */
84 /* ******************************************************** */
85
86 const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
87 {
88         ThemeSpace *ts= NULL;
89         static char error[4]={240, 0, 240, 255};
90         static char alert[4]={240, 60, 60, 255};
91         static char headerdesel[4]={0,0,0,255};
92         
93         const char *cp= error;
94         
95         if(btheme) {
96         
97                 // first check for ui buttons theme
98                 if(colorid < TH_THEMEUI) {
99                 
100                         switch(colorid) {
101
102                         case TH_REDALERT:
103                                 cp= alert; break;
104                         }
105                 }
106                 else {
107                 
108                         switch(spacetype) {
109                         case SPACE_BUTS:
110                                 ts= &btheme->tbuts;
111                                 break;
112                         case SPACE_VIEW3D:
113                                 ts= &btheme->tv3d;
114                                 break;
115                         case SPACE_IPO:
116                                 ts= &btheme->tipo;
117                                 break;
118                         case SPACE_FILE:
119                                 ts= &btheme->tfile;
120                                 break;
121                         case SPACE_NLA:
122                                 ts= &btheme->tnla;
123                                 break;
124                         case SPACE_ACTION:
125                                 ts= &btheme->tact;
126                                 break;
127                         case SPACE_SEQ:
128                                 ts= &btheme->tseq;
129                                 break;
130                         case SPACE_IMAGE:
131                                 ts= &btheme->tima;
132                                 break;
133                         case SPACE_IMASEL:
134                                 ts= &btheme->timasel;
135                                 break;
136                         case SPACE_TEXT:
137                                 ts= &btheme->text;
138                                 break;
139                         case SPACE_OUTLINER:
140                                 ts= &btheme->toops;
141                                 break;
142                         case SPACE_SOUND:
143                                 ts= &btheme->tsnd;
144                                 break;
145                         case SPACE_INFO:
146                                 ts= &btheme->tinfo;
147                                 break;
148                         case SPACE_USERPREF:
149                                 ts= &btheme->tuserpref;
150                                 break;
151                         case SPACE_CONSOLE:
152                                 ts= &btheme->tconsole;
153                                 break;
154                         case SPACE_TIME:
155                                 ts= &btheme->ttime;
156                                 break;
157                         case SPACE_NODE:
158                                 ts= &btheme->tnode;
159                                 break;
160                         case SPACE_LOGIC:
161                                 ts= &btheme->tlogic;
162                                 break;
163                         default:
164                                 ts= &btheme->tv3d;
165                                 break;
166                         }
167                         
168                         switch(colorid) {
169                         case TH_BACK:
170                                 if(theme_regionid==RGN_TYPE_WINDOW)
171                                         cp= ts->back;
172                                 else if(theme_regionid==RGN_TYPE_CHANNELS)
173                                         cp= ts->list;
174                                 else if(theme_regionid==RGN_TYPE_HEADER)
175                                         cp= ts->header;
176                                 else
177                                         cp= ts->button; 
178                                 break;
179                         case TH_TEXT:
180                                 if(theme_regionid==RGN_TYPE_WINDOW)
181                                         cp= ts->text; 
182                                 else if(theme_regionid==RGN_TYPE_CHANNELS)
183                                         cp= ts->list_text;
184                                 else if(theme_regionid==RGN_TYPE_HEADER)
185                                         cp= ts->header_text;
186                                 else
187                                         cp= ts->button_text; 
188                                 break;
189                         case TH_TEXT_HI:
190                                 if(theme_regionid==RGN_TYPE_WINDOW)
191                                         cp= ts->text_hi;
192                                 else if(theme_regionid==RGN_TYPE_CHANNELS)
193                                         cp= ts->list_text_hi;
194                                 else if(theme_regionid==RGN_TYPE_HEADER)
195                                         cp= ts->header_text_hi;
196                                 else
197                                         cp= ts->button_text_hi; 
198                                 break;
199                         case TH_TITLE:
200                                 if(theme_regionid==RGN_TYPE_WINDOW)
201                                         cp= ts->title;
202                                 else if(theme_regionid==RGN_TYPE_CHANNELS)
203                                         cp= ts->list_title;
204                                 else if(theme_regionid==RGN_TYPE_HEADER)
205                                         cp= ts->header_title;
206                                 else
207                                         cp= ts->button_title; 
208                                 break;
209                                 
210                         case TH_HEADER:
211                                 cp= ts->header; break;
212                         case TH_HEADERDESEL:
213                                 /* we calculate a dynamic builtin header deselect color, also for pulldowns... */
214                                 cp= ts->header; 
215                                 headerdesel[0]= cp[0]>10?cp[0]-10:0;
216                                 headerdesel[1]= cp[1]>10?cp[1]-10:0;
217                                 headerdesel[2]= cp[2]>10?cp[2]-10:0;
218                                 cp= headerdesel;
219                                 break;
220                         case TH_HEADER_TEXT:
221                                 cp= ts->header_text; break;
222                         case TH_HEADER_TEXT_HI:
223                                 cp= ts->header_text_hi; break;
224                                 
225                         case TH_PANEL:
226                                 cp= ts->panel; break;
227                         case TH_PANEL_TEXT:
228                                 cp= ts->panel_text; break;
229                         case TH_PANEL_TEXT_HI:
230                                 cp= ts->panel_text_hi; break;
231                                 
232                         case TH_BUTBACK:
233                                 cp= ts->button; break;
234                         case TH_BUTBACK_TEXT:
235                                 cp= ts->button_text; break;
236                         case TH_BUTBACK_TEXT_HI:
237                                 cp= ts->button_text_hi; break;
238                                 
239                         case TH_SHADE1:
240                                 cp= ts->shade1; break;
241                         case TH_SHADE2:
242                                 cp= ts->shade2; break;
243                         case TH_HILITE:
244                                 cp= ts->hilite; break;
245                                 
246                         case TH_GRID:
247                                 cp= ts->grid; break;
248                         case TH_WIRE:
249                                 cp= ts->wire; break;
250                         case TH_LAMP:
251                                 cp= ts->lamp; break;
252                         case TH_SELECT:
253                                 cp= ts->select; break;
254                         case TH_ACTIVE:
255                                 cp= ts->active; break;
256                         case TH_GROUP:
257                                 cp= ts->group; break;
258                         case TH_GROUP_ACTIVE:
259                                 cp= ts->group_active; break;
260                         case TH_TRANSFORM:
261                                 cp= ts->transform; break;
262                         case TH_VERTEX:
263                                 cp= ts->vertex; break;
264                         case TH_VERTEX_SELECT:
265                                 cp= ts->vertex_select; break;
266                         case TH_VERTEX_SIZE:
267                                 cp= &ts->vertex_size; break;
268                         case TH_OUTLINE_WIDTH:
269                                 cp= &ts->outline_width; break;
270                         case TH_EDGE:
271                                 cp= ts->edge; break;
272                         case TH_EDGE_SELECT:
273                                 cp= ts->edge_select; break;
274                         case TH_EDGE_SEAM:
275                                 cp= ts->edge_seam; break;
276                         case TH_EDGE_SHARP:
277                                 cp= ts->edge_sharp; break;
278                         case TH_EDGE_CREASE:
279                                 cp= ts->edge_crease; break;
280                         case TH_EDITMESH_ACTIVE:
281                                 cp= ts->editmesh_active; break;
282                         case TH_EDGE_FACESEL:
283                                 cp= ts->edge_facesel; break;
284                         case TH_FACE:
285                                 cp= ts->face; break;
286                         case TH_FACE_SELECT:
287                                 cp= ts->face_select; break;
288                         case TH_FACE_DOT:
289                                 cp= ts->face_dot; break;
290                         case TH_FACEDOT_SIZE:
291                                 cp= &ts->facedot_size; break;
292                         case TH_DRAWEXTRA_EDGELEN:
293                                 cp= ts->extra_edge_len; break;
294                         case TH_DRAWEXTRA_FACEAREA:
295                                 cp= ts->extra_face_area; break;
296                         case TH_DRAWEXTRA_FACEANG:
297                                 cp= ts->extra_face_angle; break;
298                         case TH_NORMAL:
299                                 cp= ts->normal; break;
300                         case TH_VNORMAL:
301                                 cp= ts->vertex_normal; break;
302                         case TH_BONE_SOLID:
303                                 cp= ts->bone_solid; break;
304                         case TH_BONE_POSE:
305                                 cp= ts->bone_pose; break;
306                         case TH_STRIP:
307                                 cp= ts->strip; break;
308                         case TH_STRIP_SELECT:
309                                 cp= ts->strip_select; break;
310                         case TH_CFRAME:
311                                 cp= ts->cframe; break;
312                         case TH_NURB_ULINE:
313                                 cp= ts->nurb_uline; break;
314                         case TH_NURB_VLINE:
315                                 cp= ts->nurb_vline; break;
316                         case TH_NURB_SEL_ULINE:
317                                 cp= ts->nurb_sel_uline; break;
318                         case TH_NURB_SEL_VLINE:
319                                 cp= ts->nurb_sel_vline; break;
320                         case TH_ACTIVE_SPLINE:
321                                 cp= ts->act_spline; break;
322                         case TH_LASTSEL_POINT:
323                                 cp= ts->lastsel_point; break;
324                         case TH_HANDLE_FREE:
325                                 cp= ts->handle_free; break;
326                         case TH_HANDLE_AUTO:
327                                 cp= ts->handle_auto; break;
328                         case TH_HANDLE_VECT:
329                                 cp= ts->handle_vect; break;
330                         case TH_HANDLE_ALIGN:
331                                 cp= ts->handle_align; break;
332                         case TH_HANDLE_SEL_FREE:
333                                 cp= ts->handle_sel_free; break;
334                         case TH_HANDLE_SEL_AUTO:
335                                 cp= ts->handle_sel_auto; break;
336                         case TH_HANDLE_SEL_VECT:
337                                 cp= ts->handle_sel_vect; break;
338                         case TH_HANDLE_SEL_ALIGN:
339                                 cp= ts->handle_sel_align; break;
340
341                         case TH_SYNTAX_B:
342                                 cp= ts->syntaxb; break;
343                         case TH_SYNTAX_V:
344                                 cp= ts->syntaxv; break;
345                         case TH_SYNTAX_C:
346                                 cp= ts->syntaxc; break;
347                         case TH_SYNTAX_L:
348                                 cp= ts->syntaxl; break;
349                         case TH_SYNTAX_N:
350                                 cp= ts->syntaxn; break;
351
352                         case TH_NODE:
353                                 cp= ts->syntaxl; break;
354                         case TH_NODE_IN_OUT:
355                                 cp= ts->syntaxn; break;
356                         case TH_NODE_OPERATOR:
357                                 cp= ts->syntaxb; break;
358                         case TH_NODE_CONVERTOR:
359                                 cp= ts->syntaxv; break;
360                         case TH_NODE_GROUP:
361                                 cp= ts->syntaxc; break;
362                                 
363                         case TH_SEQ_MOVIE:
364                                 cp= ts->movie; break;
365                         case TH_SEQ_IMAGE:
366                                 cp= ts->image; break;
367                         case TH_SEQ_SCENE:
368                                 cp= ts->scene; break;
369                         case TH_SEQ_AUDIO:
370                                 cp= ts->audio; break;
371                         case TH_SEQ_EFFECT:
372                                 cp= ts->effect; break;
373                         case TH_SEQ_PLUGIN:
374                                 cp= ts->plugin; break;
375                         case TH_SEQ_TRANSITION:
376                                 cp= ts->transition; break;
377                         case TH_SEQ_META:
378                                 cp= ts->meta; break;
379                                 
380                         case TH_CONSOLE_OUTPUT:
381                                 cp= ts->console_output; break;
382                         case TH_CONSOLE_INPUT:
383                                 cp= ts-> console_input; break;
384                         case TH_CONSOLE_INFO:
385                                 cp= ts->console_info; break;
386                         case TH_CONSOLE_ERROR:
387                                 cp= ts->console_error; break;
388                         case TH_CONSOLE_CURSOR:
389                                 cp= ts->console_cursor; break;
390
391                         case TH_HANDLE_VERTEX:
392                                 cp= ts->handle_vertex;
393                                 break;
394                         case TH_HANDLE_VERTEX_SELECT:
395                                 cp= ts->handle_vertex_select;
396                                 break;
397                         case TH_HANDLE_VERTEX_SIZE:
398                                 cp= &ts->handle_vertex_size;
399                                 break;
400                                 
401                         case TH_DOPESHEET_CHANNELOB:
402                                 cp= ts->ds_channel;
403                                 break;
404                         case TH_DOPESHEET_CHANNELSUBOB:
405                                 cp= ts->ds_subchannel;
406                                 break;  
407                                         
408                         case TH_PREVIEW_BACK:
409                                 cp= ts->preview_back;
410                                 break;  
411                         }
412                 }
413         }
414         
415         return (unsigned char *)cp;
416 }
417
418
419 #define SETCOL(col, r, g, b, a)  col[0]=r; col[1]=g; col[2]= b; col[3]= a;
420 #define SETCOLF(col, r, g, b, a)  col[0]=r*255; col[1]=g*255; col[2]= b*255; col[3]= a*255;
421 #define SETCOLTEST(col, r, g, b, a)  if(col[3]==0) {col[0]=r; col[1]=g; col[2]= b; col[3]= a;}
422
423 /* use this call to init new bone color sets in Theme */
424 static void ui_theme_init_boneColorSets(bTheme *btheme)
425 {
426         int i;
427         
428         /* define default color sets - currently we only define 15 of these, though that should be ample */
429                 /* set 1 */
430         SETCOL(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255);
431         SETCOL(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255);
432         SETCOL(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255);
433                 /* set 2 */
434         SETCOL(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255);
435         SETCOL(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255);
436         SETCOL(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255);
437                 /* set 3 */
438         SETCOL(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255);
439         SETCOL(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255);
440         SETCOL(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255);
441                 /* set 4 */
442         SETCOL(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255);
443         SETCOL(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255);
444         SETCOL(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255);
445                 /* set 5 */
446         SETCOL(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255);
447         SETCOL(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255);
448         SETCOL(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255);
449                 /* set 6 */
450         SETCOL(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255);
451         SETCOL(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255);
452         SETCOL(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255);
453                 /* set 7 */
454         SETCOL(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255);
455         SETCOL(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255);
456         SETCOL(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255);
457                 /* set 8 */
458         SETCOL(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255);
459         SETCOL(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255);
460         SETCOL(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255);
461                 /* set 9 */
462         SETCOL(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255);
463         SETCOL(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255);
464         SETCOL(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255);
465                 /* set 10 */
466         SETCOL(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255);
467         SETCOL(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255);
468         SETCOL(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255);
469                 /* set 11 */
470         SETCOL(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255);
471         SETCOL(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255);
472         SETCOL(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255);
473                 /* set 12 */
474         SETCOL(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255);
475         SETCOL(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255);
476         SETCOL(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255);
477                 /* set 13 */
478         SETCOL(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255);
479         SETCOL(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255);
480         SETCOL(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255);
481                 /* set 14 */
482         SETCOL(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255);
483         SETCOL(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255);
484         SETCOL(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255);
485                 /* set 15 */
486         SETCOL(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255);
487         SETCOL(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255);
488         SETCOL(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255);
489         
490         /* reset flags too */
491         for (i = 0; i < 20; i++)
492                 btheme->tarm[i].flag = 0;
493 }
494
495 /* use this call to init new variables in themespace, if they're same for all */
496 static void ui_theme_init_new_do(ThemeSpace *ts)
497 {
498         SETCOLTEST(ts->header_text,             0, 0, 0, 255);
499         SETCOLTEST(ts->header_title,    0, 0, 0, 255);
500         SETCOLTEST(ts->header_text_hi,  255, 255, 255, 255);
501         
502         SETCOLTEST(ts->panel_text,              0, 0, 0, 255);
503         SETCOLTEST(ts->panel_title,             0, 0, 0, 255);
504         SETCOLTEST(ts->panel_text_hi,   255, 255, 255, 255);
505         
506         SETCOLTEST(ts->button,                  145, 145, 145, 245);
507         SETCOLTEST(ts->button_title,    0, 0, 0, 255);
508         SETCOLTEST(ts->button_text,             0, 0, 0, 255);
509         SETCOLTEST(ts->button_text_hi,  255, 255, 255, 255);
510         
511         SETCOLTEST(ts->list,                    165, 165, 165, 255);
512         SETCOLTEST(ts->list_title,              0, 0, 0, 255);
513         SETCOLTEST(ts->list_text,               0, 0, 0, 255);
514         SETCOLTEST(ts->list_text_hi,    255, 255, 255, 255);
515 }
516
517 static void ui_theme_init_new(bTheme *btheme)
518 {
519         ui_theme_init_new_do(&btheme->tbuts);
520         ui_theme_init_new_do(&btheme->tv3d);
521         ui_theme_init_new_do(&btheme->tfile);
522         ui_theme_init_new_do(&btheme->tipo);
523         ui_theme_init_new_do(&btheme->tinfo);
524         ui_theme_init_new_do(&btheme->tsnd);
525         ui_theme_init_new_do(&btheme->tact);
526         ui_theme_init_new_do(&btheme->tnla);
527         ui_theme_init_new_do(&btheme->tseq);
528         ui_theme_init_new_do(&btheme->tima);
529         ui_theme_init_new_do(&btheme->timasel);
530         ui_theme_init_new_do(&btheme->text);
531         ui_theme_init_new_do(&btheme->toops);
532         ui_theme_init_new_do(&btheme->ttime);
533         ui_theme_init_new_do(&btheme->tnode);
534         ui_theme_init_new_do(&btheme->tlogic);
535         ui_theme_init_new_do(&btheme->tuserpref);
536         ui_theme_init_new_do(&btheme->tconsole);
537         
538 }
539
540
541 /* initialize default theme
542    Note: when you add new colors, created & saved themes need initialized
543    use function below, init_userdef_do_versions() 
544 */
545 void ui_theme_init_default(void)
546 {
547         bTheme *btheme;
548         
549         /* we search for the theme with name Default */
550         for(btheme= U.themes.first; btheme; btheme= btheme->next) {
551                 if(strcmp("Default", btheme->name)==0) break;
552         }
553         
554         if(btheme==NULL) {
555                 btheme= MEM_callocN(sizeof(bTheme), "theme");
556                 BLI_addtail(&U.themes, btheme);
557                 strcpy(btheme->name, "Default");
558         }
559         
560         UI_SetTheme(0, 0);      // make sure the global used in this file is set
561
562         /* UI buttons */
563         ui_widget_color_init(&btheme->tui);
564         
565         /* Bone Color Sets */
566         ui_theme_init_boneColorSets(btheme);
567         
568         /* common (new) variables */
569         ui_theme_init_new(btheme);
570         
571         /* space view3d */
572         SETCOLF(btheme->tv3d.back,       0.225, 0.225, 0.225, 1.0);
573         SETCOL(btheme->tv3d.text,       0, 0, 0, 255);
574         SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255);
575         
576         SETCOLF(btheme->tv3d.header,    0.45, 0.45, 0.45, 1.0);
577         SETCOLF(btheme->tv3d.button,    0.45, 0.45, 0.45, 1.0);
578         SETCOL(btheme->tv3d.panel,      165, 165, 165, 127);
579         
580         SETCOL(btheme->tv3d.shade1,  160, 160, 160, 100);
581         SETCOL(btheme->tv3d.shade2,  0x7f, 0x70, 0x70, 100);
582
583         SETCOLF(btheme->tv3d.grid,     0.251, 0.251, 0.251, 1.0);
584         SETCOL(btheme->tv3d.wire,       0x0, 0x0, 0x0, 255);
585         SETCOL(btheme->tv3d.lamp,       0, 0, 0, 40);
586         SETCOL(btheme->tv3d.select, 241, 88, 0, 255);
587         SETCOL(btheme->tv3d.active, 255, 140, 25, 255);
588         SETCOL(btheme->tv3d.group,      8, 48, 8, 255);
589         SETCOL(btheme->tv3d.group_active, 85, 187, 85, 255);
590         SETCOL(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
591         SETCOL(btheme->tv3d.vertex, 0, 0, 0, 255);
592         SETCOL(btheme->tv3d.vertex_select, 255, 133, 0, 255);
593         btheme->tv3d.vertex_size= 3;
594         btheme->tv3d.outline_width= 1;
595         SETCOL(btheme->tv3d.edge,       0x0, 0x0, 0x0, 255);
596         SETCOL(btheme->tv3d.edge_select, 255, 160, 0, 255);
597         SETCOL(btheme->tv3d.edge_seam, 219, 37, 18, 255);
598         SETCOL(btheme->tv3d.edge_facesel, 75, 75, 75, 255);
599         SETCOL(btheme->tv3d.face,       0, 0, 0, 18);
600         SETCOL(btheme->tv3d.face_select, 255, 133, 0, 60);
601         SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
602         SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
603         SETCOL(btheme->tv3d.face_dot, 255, 133, 0, 255);
604         btheme->tv3d.facedot_size= 4;
605
606         SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
607         SETCOL(btheme->tv3d.extra_face_area, 0, 32, 0, 255);
608         SETCOL(btheme->tv3d.extra_face_angle, 0, 0, 128, 255);
609
610         SETCOL(btheme->tv3d.cframe, 0x60, 0xc0,  0x40, 255);
611
612         SETCOL(btheme->tv3d.nurb_uline, 0x90, 0x90, 0x00, 255);
613         SETCOL(btheme->tv3d.nurb_vline, 0x80, 0x30, 0x60, 255);
614         SETCOL(btheme->tv3d.nurb_sel_uline, 0xf0, 0xff, 0x40, 255);
615         SETCOL(btheme->tv3d.nurb_sel_vline, 0xf0, 0x90, 0xa0, 255);
616
617         SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
618         SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
619         SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
620         SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
621         SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
622         SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
623         SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
624         SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
625
626         SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
627         SETCOL(btheme->tv3d.lastsel_point,  0xff, 0xff, 0xff, 255);
628
629         SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
630         SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);               // alpha 80 is not meant editable, used for wire+action draw
631         
632         
633         /* space buttons */
634         /* to have something initialized */
635         btheme->tbuts= btheme->tv3d;
636
637         SETCOLF(btheme->tbuts.back,     0.45, 0.45, 0.45, 1.0);
638         SETCOL(btheme->tbuts.panel, 0x82, 0x82, 0x82, 255);
639
640         /* graph editor */
641         btheme->tipo= btheme->tv3d;
642         SETCOLF(btheme->tipo.back,      0.42, 0.42, 0.42, 1.0);
643         SETCOLF(btheme->tipo.list,      0.4, 0.4, 0.4, 1.0);
644         SETCOL(btheme->tipo.grid,       94, 94, 94, 255);
645         SETCOL(btheme->tipo.panel,  255, 255, 255, 150);
646         SETCOL(btheme->tipo.shade1,             150, 150, 150, 100);    /* scrollbars */
647         SETCOL(btheme->tipo.shade2,             0x70, 0x70, 0x70, 100);
648         SETCOL(btheme->tipo.vertex,             0, 0, 0, 255);
649         SETCOL(btheme->tipo.vertex_select, 255, 133, 0, 255);
650         SETCOL(btheme->tipo.hilite, 0x60, 0xc0, 0x40, 255); 
651         btheme->tipo.vertex_size= 3;
652
653         SETCOL(btheme->tipo.handle_vertex,              0, 0, 0, 255);
654         SETCOL(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
655         btheme->tipo.handle_vertex_size= 3;
656         
657         SETCOL(btheme->tipo.ds_channel,         82, 96, 110, 255);
658         SETCOL(btheme->tipo.ds_subchannel,      124, 137, 150, 255);
659         SETCOL(btheme->tipo.group, 79, 101, 73, 255);
660         SETCOL(btheme->tipo.group_active, 135, 177, 125, 255);
661
662         /* dopesheet */
663         btheme->tact= btheme->tipo;
664         SETCOL(btheme->tact.strip,                      12, 10, 10, 128); 
665         SETCOL(btheme->tact.strip_select,       255, 140, 0, 255); 
666         
667         /* space nla */
668         btheme->tnla= btheme->tact;
669         
670         /* space file */
671         /* to have something initialized */
672         btheme->tfile= btheme->tv3d;
673         SETCOLF(btheme->tfile.back, 0.3, 0.3, 0.3, 1);
674         SETCOLF(btheme->tfile.panel, 0.3, 0.3, 0.3, 1);
675         SETCOLF(btheme->tfile.list, 0.4, 0.4, 0.4, 1);
676         SETCOL(btheme->tfile.text,      250, 250, 250, 255);
677         SETCOL(btheme->tfile.text_hi, 15, 15, 15, 255);
678         SETCOL(btheme->tfile.panel, 145, 145, 145, 255);        // bookmark/ui regions
679         SETCOL(btheme->tfile.active, 130, 130, 130, 255); // selected files
680         SETCOL(btheme->tfile.hilite, 255, 140, 25, 255); // selected files
681         
682         SETCOL(btheme->tfile.grid,      250, 250, 250, 255);
683         SETCOL(btheme->tfile.image,     250, 250, 250, 255);
684         SETCOL(btheme->tfile.movie,     250, 250, 250, 255);
685         SETCOL(btheme->tfile.scene,     250, 250, 250, 255);
686
687         
688         /* space seq */
689         btheme->tseq= btheme->tv3d;
690         SETCOL(btheme->tseq.back,       116, 116, 116, 255);
691         SETCOL(btheme->tseq.movie,      81, 105, 135, 255);
692         SETCOL(btheme->tseq.image,      109, 88, 129, 255);
693         SETCOL(btheme->tseq.scene,      78, 152, 62, 255);
694         SETCOL(btheme->tseq.audio,      46, 143, 143, 255);
695         SETCOL(btheme->tseq.effect,     169, 84, 124, 255);
696         SETCOL(btheme->tseq.plugin,     126, 126, 80, 255);
697         SETCOL(btheme->tseq.transition, 162, 95, 111, 255);
698         SETCOL(btheme->tseq.meta,       109, 145, 131, 255);
699         
700
701         /* space image */
702         btheme->tima= btheme->tv3d;
703         SETCOL(btheme->tima.back,       53, 53, 53, 255);
704         SETCOL(btheme->tima.vertex, 0, 0, 0, 255);
705         SETCOL(btheme->tima.vertex_select, 255, 133, 0, 255);
706         btheme->tima.vertex_size= 3;
707         btheme->tima.facedot_size= 3;
708         SETCOL(btheme->tima.face,   255, 255, 255, 10);
709         SETCOL(btheme->tima.face_select, 255, 133, 0, 60);
710         SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
711         SETCOLF(btheme->tima.preview_back,      0.45, 0.45, 0.45, 1.0);
712
713         /* space imageselect */
714         btheme->timasel= btheme->tv3d;
715         SETCOL(btheme->timasel.active,  195, 195, 195, 255); /* active tile */
716         SETCOL(btheme->timasel.grid,  94, 94, 94, 255); /* active file text */
717         SETCOL(btheme->timasel.back,    110, 110, 110, 255);
718         SETCOL(btheme->timasel.shade1,  94, 94, 94, 255);       /* bar */
719         SETCOL(btheme->timasel.shade2,  172, 172, 172, 255); /* sliders */
720         SETCOL(btheme->timasel.hilite,  17, 27, 60, 100);       /* selected tile */
721         SETCOL(btheme->timasel.text,    0, 0, 0, 255);
722         SETCOL(btheme->timasel.text_hi, 255, 255, 255, 255);
723         SETCOL(btheme->timasel.panel,   132, 132, 132, 255);
724
725         /* space text */
726         btheme->text= btheme->tv3d;
727         SETCOL(btheme->text.back,       153, 153, 153, 255);
728         SETCOL(btheme->text.shade1,     143, 143, 143, 255);
729         SETCOL(btheme->text.shade2,     0xc6, 0x77, 0x77, 255);
730         SETCOL(btheme->text.hilite,     255, 0, 0, 255);
731         
732         /* syntax highlighting */
733         SETCOL(btheme->text.syntaxn,    0, 0, 200, 255);        /* Numbers  Blue*/
734         SETCOL(btheme->text.syntaxl,    100, 0, 0, 255);        /* Strings  red */
735         SETCOL(btheme->text.syntaxc,    0, 100, 50, 255);       /* Comments greenish */
736         SETCOL(btheme->text.syntaxv,    95, 95, 0, 255);        /* Special */
737         SETCOL(btheme->text.syntaxb,    128, 0, 80, 255);       /* Builtin, red-purple */
738         
739         /* space oops */
740         btheme->toops= btheme->tv3d;
741         SETCOLF(btheme->toops.back,     0.45, 0.45, 0.45, 1.0);
742         
743         /* space info */
744         btheme->tinfo= btheme->tv3d;
745         SETCOLF(btheme->tinfo.back,     0.45, 0.45, 0.45, 1.0);
746
747         /* space user preferences */
748         btheme->tuserpref= btheme->tv3d;
749         SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
750         
751         /* space console */
752         btheme->tconsole= btheme->tv3d;
753         SETCOL(btheme->tconsole.back, 0, 0, 0, 255);
754         SETCOL(btheme->tconsole.console_output, 96, 128, 255, 255);
755         SETCOL(btheme->tconsole.console_input, 255, 255, 255, 255);
756         SETCOL(btheme->tconsole.console_info, 0, 170, 0, 255);
757         SETCOL(btheme->tconsole.console_error, 220, 96, 96, 255);
758         SETCOL(btheme->tconsole.console_cursor, 220, 96, 96, 255);
759         
760
761         /* space sound */
762         btheme->tsnd= btheme->tv3d;
763         SETCOLF(btheme->tsnd.back,      0.45, 0.45, 0.45, 1.0);
764         SETCOLF(btheme->tsnd.grid,      0.36, 0.36, 0.36, 1.0);
765         SETCOL(btheme->tsnd.shade1,  173, 173, 173, 255);               // sliders
766         
767         /* space time */
768         btheme->ttime= btheme->tsnd;    // same as sound space
769         
770         /* space node, re-uses syntax color storage */
771         btheme->tnode= btheme->tv3d;
772         SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
773         SETCOL(btheme->tnode.syntaxl, 155, 155, 155, 160);      /* TH_NODE, backdrop */
774         SETCOL(btheme->tnode.syntaxn, 100, 100, 100, 255);      /* in/output */
775         SETCOL(btheme->tnode.syntaxb, 108, 105, 111, 255);      /* operator */
776         SETCOL(btheme->tnode.syntaxv, 104, 106, 117, 255);      /* generator */
777         SETCOL(btheme->tnode.syntaxc, 105, 117, 110, 255);      /* group */
778
779         /* space logic */
780         btheme->tlogic= btheme->tv3d;
781         SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
782         
783 }
784
785
786 void UI_SetTheme(int spacetype, int regionid)
787 {
788         if(spacetype==0) {      // called for safety, when delete themes
789                 theme_active= U.themes.first;
790                 theme_spacetype= SPACE_VIEW3D;
791                 theme_regionid= RGN_TYPE_WINDOW;
792         }
793         else {
794                 // later on, a local theme can be found too
795                 theme_active= U.themes.first;
796                 theme_spacetype= spacetype;
797                 theme_regionid= regionid;
798         }
799 }
800
801 // for space windows only
802 void UI_ThemeColor(int colorid)
803 {
804         const unsigned char *cp;
805         
806         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
807         glColor3ubv(cp);
808
809 }
810
811 // plus alpha
812 void UI_ThemeColor4(int colorid)
813 {
814         const unsigned char *cp;
815         
816         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
817         glColor4ubv(cp);
818
819 }
820
821 // set the color with offset for shades
822 void UI_ThemeColorShade(int colorid, int offset)
823 {
824         int r, g, b;
825         const unsigned char *cp;
826         
827         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
828         r= offset + (int) cp[0];
829         CLAMP(r, 0, 255);
830         g= offset + (int) cp[1];
831         CLAMP(g, 0, 255);
832         b= offset + (int) cp[2];
833         CLAMP(b, 0, 255);
834         //glColor3ub(r, g, b);
835         glColor4ub(r, g, b, cp[3]);
836 }
837 void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
838 {
839         int r, g, b, a;
840         const unsigned char *cp;
841         
842         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
843         r= coloffset + (int) cp[0];
844         CLAMP(r, 0, 255);
845         g= coloffset + (int) cp[1];
846         CLAMP(g, 0, 255);
847         b= coloffset + (int) cp[2];
848         CLAMP(b, 0, 255);
849         a= alphaoffset + (int) cp[3];
850         CLAMP(a, 0, 255);
851         glColor4ub(r, g, b, a);
852 }
853
854 // blend between to theme colors, and set it
855 void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
856 {
857         int r, g, b;
858         const unsigned char *cp1, *cp2;
859         
860         cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
861         cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
862
863         CLAMP(fac, 0.0f, 1.0f);
864         r= floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
865         g= floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
866         b= floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
867         
868         glColor3ub(r, g, b);
869 }
870
871 // blend between to theme colors, shade it, and set it
872 void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
873 {
874         int r, g, b;
875         const unsigned char *cp1, *cp2;
876         
877         cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
878         cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
879
880         CLAMP(fac, 0.0f, 1.0f);
881         r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
882         g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
883         b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
884         
885         CLAMP(r, 0, 255);
886         CLAMP(g, 0, 255);
887         CLAMP(b, 0, 255);
888         
889         glColor3ub(r, g, b);
890 }
891
892 // blend between to theme colors, shade it, and set it
893 void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset)
894 {
895         int r, g, b, a;
896         const unsigned char *cp1, *cp2;
897         
898         cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
899         cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
900
901         CLAMP(fac, 0.0f, 1.0f);
902         r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
903         g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
904         b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
905         a= alphaoffset + floorf((1.0f-fac)*cp1[3] + fac*cp2[3]);
906         
907         CLAMP(r, 0, 255);
908         CLAMP(g, 0, 255);
909         CLAMP(b, 0, 255);
910         CLAMP(a, 0, 255);
911
912         glColor4ub(r, g, b, a);
913 }
914
915
916 // get individual values, not scaled
917 float UI_GetThemeValuef(int colorid)
918 {
919         const unsigned char *cp;
920         
921         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
922         return ((float)cp[0]);
923
924 }
925
926 // get individual values, not scaled
927 int UI_GetThemeValue(int colorid)
928 {
929         const unsigned char *cp;
930         
931         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
932         return ((int) cp[0]);
933
934 }
935
936
937 // get the color, range 0.0-1.0
938 void UI_GetThemeColor3fv(int colorid, float *col)
939 {
940         const unsigned char *cp;
941         
942         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
943         col[0]= ((float)cp[0])/255.0f;
944         col[1]= ((float)cp[1])/255.0f;
945         col[2]= ((float)cp[2])/255.0f;
946 }
947
948 // get the color, range 0.0-1.0, complete with shading offset
949 void UI_GetThemeColorShade3fv(int colorid, int offset, float *col)
950 {
951         int r, g, b;
952         const unsigned char *cp;
953         
954         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
955         
956         r= offset + (int) cp[0];
957         CLAMP(r, 0, 255);
958         g= offset + (int) cp[1];
959         CLAMP(g, 0, 255);
960         b= offset + (int) cp[2];
961         CLAMP(b, 0, 255);
962         
963         col[0]= ((float)r)/255.0f;
964         col[1]= ((float)g)/255.0f;
965         col[2]= ((float)b)/255.0f;
966 }
967
968 // get the color, in char pointer
969 void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
970 {
971         const unsigned char *cp;
972         
973         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
974         col[0]= cp[0];
975         col[1]= cp[1];
976         col[2]= cp[2];
977 }
978
979 // get the color, in char pointer
980 void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
981 {
982         const unsigned char *cp;
983         
984         cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
985         col[0]= cp[0];
986         col[1]= cp[1];
987         col[2]= cp[2];
988         col[3]= cp[3];
989 }
990
991 void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
992 {
993         const unsigned char *cp;
994         
995         cp= UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
996         col[0]= cp[0];
997         col[1]= cp[1];
998         col[2]= cp[2];
999         col[3]= cp[3];
1000 }
1001
1002 // blends and shades between two char color pointers
1003 void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset)
1004 {
1005         int r, g, b;
1006         CLAMP(fac, 0.0f, 1.0f);
1007         r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
1008         g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
1009         b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
1010         
1011         r= r<0?0:(r>255?255:r);
1012         g= g<0?0:(g>255?255:g);
1013         b= b<0?0:(b>255?255:b);
1014         
1015         glColor3ub(r, g, b);
1016 }
1017
1018 // get a 3 byte color, blended and shaded between two other char color pointers
1019 void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3], float fac, int offset)
1020 {
1021         int r, g, b;
1022
1023         CLAMP(fac, 0.0f, 1.0f);
1024         r= offset+floor((1.0f-fac)*cp1[0] + fac*cp2[0]);
1025         g= offset+floor((1.0f-fac)*cp1[1] + fac*cp2[1]);
1026         b= offset+floor((1.0f-fac)*cp1[2] + fac*cp2[2]);
1027
1028         CLAMP(r, 0, 255);
1029         CLAMP(g, 0, 255);
1030         CLAMP(b, 0, 255);
1031
1032         col[0] = r;
1033         col[1] = g;
1034         col[2] = b;
1035 }
1036
1037 void UI_ThemeClearColor(int colorid)
1038 {
1039         float col[3];
1040         
1041         UI_GetThemeColor3fv(colorid, col);
1042         glClearColor(col[0], col[1], col[2], 0.0);
1043 }
1044
1045 void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
1046 {
1047         switch(axis)
1048         {
1049                 case 'X':
1050                         dst_col[0]= src_col[0]>219?255:src_col[0]+36;
1051                         dst_col[1]= src_col[1]<26?0:src_col[1]-26;
1052                         dst_col[2]= src_col[2]<26?0:src_col[2]-26;
1053                         break;
1054                 case 'Y':
1055                         dst_col[0]= src_col[0]<46?0:src_col[0]-36;
1056                         dst_col[1]= src_col[1]>189?255:src_col[1]+66;
1057                         dst_col[2]= src_col[2]<46?0:src_col[2]-36;
1058                         break;
1059                 case 'Z':
1060                         dst_col[0]= src_col[0]<26?0:src_col[0]-26; 
1061                         dst_col[1]= src_col[1]<26?0:src_col[1]-26; 
1062                         dst_col[2]= src_col[2]>209?255:src_col[2]+46;
1063                         break;
1064                 default:
1065                         BLI_assert(!"invalid axis arg");
1066         }
1067 }
1068
1069 /* ************************************************************* */
1070
1071 /* patching UserDef struct and Themes */
1072 void init_userdef_do_versions(void)
1073 {
1074         Main *bmain= G.main;
1075 //      countall();
1076         
1077         /* the UserDef struct is not corrected with do_versions() .... ugh! */
1078         if(U.wheellinescroll == 0) U.wheellinescroll = 3;
1079         if(U.menuthreshold1==0) {
1080                 U.menuthreshold1= 5;
1081                 U.menuthreshold2= 2;
1082         }
1083         if(U.tb_leftmouse==0) {
1084                 U.tb_leftmouse= 5;
1085                 U.tb_rightmouse= 5;
1086         }
1087         if(U.mixbufsize==0) U.mixbufsize= 2048;
1088         if (strcmp(U.tempdir, "/") == 0) {
1089                 BLI_where_is_temp(U.tempdir, sizeof(U.tempdir), FALSE);
1090         }
1091         if (U.autokey_mode == 0) {
1092                 /* 'add/replace' but not on */
1093                 U.autokey_mode = 2;
1094         }
1095         if (U.savetime <= 0) {
1096                 U.savetime = 1;
1097 // XXX          error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
1098         }
1099         /* transform widget settings */
1100         if(U.tw_hotspot==0) {
1101                 U.tw_hotspot= 14;
1102                 U.tw_size= 20;                  // percentage of window size
1103                 U.tw_handlesize= 16;    // percentage of widget radius
1104         }
1105         if(U.pad_rot_angle==0)
1106                 U.pad_rot_angle= 15;
1107         
1108         if(U.flag & USER_CUSTOM_RANGE) 
1109                 vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */
1110         
1111         if (bmain->versionfile <= 191) {
1112                 strcpy(U.plugtexdir, U.textudir);
1113                 strcpy(U.sounddir, "/");
1114         }
1115         
1116         /* patch to set Dupli Armature */
1117         if (bmain->versionfile < 220) {
1118                 U.dupflag |= USER_DUP_ARM;
1119         }
1120         
1121         /* added seam, normal color, undo */
1122         if (bmain->versionfile <= 234) {
1123                 bTheme *btheme;
1124                 
1125                 U.uiflag |= USER_GLOBALUNDO;
1126                 if (U.undosteps==0) U.undosteps=32;
1127                 
1128                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1129                         /* check for alpha==0 is safe, then color was never set */
1130                         if(btheme->tv3d.edge_seam[3]==0) {
1131                                 SETCOL(btheme->tv3d.edge_seam, 230, 150, 50, 255);
1132                         }
1133                         if(btheme->tv3d.normal[3]==0) {
1134                                 SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
1135                         }
1136                         if(btheme->tv3d.vertex_normal[3]==0) {
1137                                 SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
1138                         }
1139                         if(btheme->tv3d.face_dot[3]==0) {
1140                                 SETCOL(btheme->tv3d.face_dot, 255, 138, 48, 255);
1141                                 btheme->tv3d.facedot_size= 4;
1142                         }
1143                 }
1144         }
1145         if (bmain->versionfile <= 235) {
1146                 /* illegal combo... */
1147                 if (U.flag & USER_LMOUSESELECT) 
1148                         U.flag &= ~USER_TWOBUTTONMOUSE;
1149         }
1150         if (bmain->versionfile <= 236) {
1151                 bTheme *btheme;
1152                 /* new space type */
1153                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1154                         /* check for alpha==0 is safe, then color was never set */
1155                         if(btheme->ttime.back[3]==0) {
1156                                 btheme->ttime = btheme->tsnd;   // copy from sound
1157                         }
1158                         if(btheme->text.syntaxn[3]==0) {
1159                                 SETCOL(btheme->text.syntaxn,    0, 0, 200, 255);        /* Numbers  Blue*/
1160                                 SETCOL(btheme->text.syntaxl,    100, 0, 0, 255);        /* Strings  red */
1161                                 SETCOL(btheme->text.syntaxc,    0, 100, 50, 255);       /* Comments greenish */
1162                                 SETCOL(btheme->text.syntaxv,    95, 95, 0, 255);        /* Special */
1163                                 SETCOL(btheme->text.syntaxb,    128, 0, 80, 255);       /* Builtin, red-purple */
1164                         }
1165                 }
1166         }
1167         if (bmain->versionfile <= 237) {
1168                 bTheme *btheme;
1169                 /* bone colors */
1170                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1171                         /* check for alpha==0 is safe, then color was never set */
1172                         if(btheme->tv3d.bone_solid[3]==0) {
1173                                 SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
1174                                 SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);
1175                         }
1176                 }
1177         }
1178         if (bmain->versionfile <= 238) {
1179                 bTheme *btheme;
1180                 /* bone colors */
1181                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1182                         /* check for alpha==0 is safe, then color was never set */
1183                         if(btheme->tnla.strip[3]==0) {
1184                                 SETCOL(btheme->tnla.strip_select,       0xff, 0xff, 0xaa, 255);
1185                                 SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
1186                         }
1187                 }
1188         }
1189         if (bmain->versionfile <= 239) {
1190                 bTheme *btheme;
1191                 
1192                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1193                         /* Lamp theme, check for alpha==0 is safe, then color was never set */
1194                         if(btheme->tv3d.lamp[3]==0) {
1195                                 SETCOL(btheme->tv3d.lamp,       0, 0, 0, 40);
1196 /* TEMPORAL, remove me! (ton) */                                
1197                                 U.uiflag |= USER_PLAINMENUS;
1198                         }
1199                         
1200                 }
1201                 if(U.obcenter_dia==0) U.obcenter_dia= 6;
1202         }
1203         if (bmain->versionfile <= 241) {
1204                 bTheme *btheme;
1205                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1206                         /* Node editor theme, check for alpha==0 is safe, then color was never set */
1207                         if(btheme->tnode.syntaxn[3]==0) {
1208                                 /* re-uses syntax color storage */
1209                                 btheme->tnode= btheme->tv3d;
1210                                 SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255);
1211                                 SETCOL(btheme->tnode.syntaxl, 150, 150, 150, 255);      /* TH_NODE, backdrop */
1212                                 SETCOL(btheme->tnode.syntaxn, 129, 131, 144, 255);      /* in/output */
1213                                 SETCOL(btheme->tnode.syntaxb, 127,127,127, 255);        /* operator */
1214                                 SETCOL(btheme->tnode.syntaxv, 142, 138, 145, 255);      /* generator */
1215                                 SETCOL(btheme->tnode.syntaxc, 120, 145, 120, 255);      /* group */
1216                         }
1217                         /* Group theme colors */
1218                         if(btheme->tv3d.group[3]==0) {
1219                                 SETCOL(btheme->tv3d.group, 0x0C, 0x30, 0x0C, 255);
1220                                 SETCOL(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255);
1221                         }
1222                         /* Sequence editor theme*/
1223                         if(btheme->tseq.movie[3]==0) {
1224                                 SETCOL(btheme->tseq.movie,      81, 105, 135, 255);
1225                                 SETCOL(btheme->tseq.image,      109, 88, 129, 255);
1226                                 SETCOL(btheme->tseq.scene,      78, 152, 62, 255);
1227                                 SETCOL(btheme->tseq.audio,      46, 143, 143, 255);
1228                                 SETCOL(btheme->tseq.effect,     169, 84, 124, 255);
1229                                 SETCOL(btheme->tseq.plugin,     126, 126, 80, 255);
1230                                 SETCOL(btheme->tseq.transition, 162, 95, 111, 255);
1231                                 SETCOL(btheme->tseq.meta,       109, 145, 131, 255);
1232                         }
1233                 }
1234                 
1235                 /* set defaults for 3D View rotating axis indicator */ 
1236                 /* since size can't be set to 0, this indicates it's not saved in startup.blend */
1237                 if (U.rvisize == 0) {
1238                         U.rvisize = 15;
1239                         U.rvibright = 8;
1240                         U.uiflag |= USER_SHOW_ROTVIEWICON;
1241                 }
1242                 
1243         }
1244         if (bmain->versionfile <= 242) {
1245                 bTheme *btheme;
1246                 
1247                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1248                         /* long keyframe color */
1249                         /* check for alpha==0 is safe, then color was never set */
1250                         if(btheme->tact.strip[3]==0) {
1251                                 SETCOL(btheme->tv3d.edge_sharp, 255, 32, 32, 255);
1252                                 SETCOL(btheme->tact.strip_select,       0xff, 0xff, 0xaa, 204);
1253                                 SETCOL(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204);
1254                         }
1255                         
1256                         /* IPO-Editor - Vertex Size*/
1257                         if(btheme->tipo.vertex_size == 0) {
1258                                 btheme->tipo.vertex_size= 3;
1259                         }
1260                 }
1261         }
1262         if (bmain->versionfile <= 243) {
1263                 /* set default number of recently-used files (if not set) */
1264                 if (U.recent_files == 0) U.recent_files = 10;
1265         }
1266         if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) {
1267                 bTheme *btheme;
1268                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1269                         SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
1270                 }
1271                 if(U.coba_weight.tot==0)
1272                         init_colorband(&U.coba_weight, 1);
1273         }
1274         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
1275                 bTheme *btheme;
1276                 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1277                         /* these should all use the same color */
1278                         SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
1279                         SETCOL(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255);
1280                         SETCOL(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255);
1281                         SETCOL(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255);
1282                         SETCOL(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255);
1283                         SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255);
1284                         SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255);
1285                 }
1286         }
1287         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) {
1288                 bTheme *btheme;
1289                 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1290                         /* action channel groups (recolor anyway) */
1291                         SETCOL(btheme->tact.group, 0x39, 0x7d, 0x1b, 255);
1292                         SETCOL(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255);
1293                         
1294                         /* bone custom-color sets */
1295                         if (btheme->tarm[0].solid[3] == 0)
1296                                 ui_theme_init_boneColorSets(btheme);
1297                 }
1298         }
1299         if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) {
1300                 U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE;
1301         }
1302         if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) {
1303                 bTheme *btheme;
1304                 
1305                 /* adjust themes */
1306                 for (btheme= U.themes.first; btheme; btheme= btheme->next) {
1307                         char *col;
1308                         
1309                         /* IPO Editor: Handles/Vertices */
1310                         col = btheme->tipo.vertex;
1311                         SETCOL(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255);
1312                         col = btheme->tipo.vertex_select;
1313                         SETCOL(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255);
1314                         btheme->tipo.handle_vertex_size= btheme->tipo.vertex_size;
1315                         
1316                         /* Sequence/Image Editor: colors for GPencil text */
1317                         col = btheme->tv3d.bone_pose;
1318                         SETCOL(btheme->tseq.bone_pose, col[0], col[1], col[2], 255);
1319                         SETCOL(btheme->tima.bone_pose, col[0], col[1], col[2], 255);
1320                         col = btheme->tv3d.vertex_select;
1321                         SETCOL(btheme->tseq.vertex_select, col[0], col[1], col[2], 255);
1322                 }
1323         }
1324         if (bmain->versionfile < 250) {
1325                 bTheme *btheme;
1326                 
1327                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1328                         /* this was not properly initialized in 2.45 */
1329                         if(btheme->tima.face_dot[3]==0) {
1330                                 SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128);
1331                                 SETCOL(btheme->tima.face_dot, 255, 133, 0, 255);
1332                                 btheme->tima.facedot_size= 2;
1333                         }
1334                         
1335                         /* DopeSheet - (Object) Channel color */
1336                         SETCOL(btheme->tact.ds_channel,         82, 96, 110, 255);
1337                         SETCOL(btheme->tact.ds_subchannel,      124, 137, 150, 255);
1338                         /* DopeSheet - Group Channel color (saner version) */
1339                         SETCOL(btheme->tact.group, 79, 101, 73, 255);
1340                         SETCOL(btheme->tact.group_active, 135, 177, 125, 255);
1341                         
1342                         /* Graph Editor - (Object) Channel color */
1343                         SETCOL(btheme->tipo.ds_channel,         82, 96, 110, 255);
1344                         SETCOL(btheme->tipo.ds_subchannel,      124, 137, 150, 255);
1345                         /* Graph Editor - Group Channel color */
1346                         SETCOL(btheme->tipo.group, 79, 101, 73, 255);
1347                         SETCOL(btheme->tipo.group_active, 135, 177, 125, 255);
1348                         
1349                         /* Nla Editor - (Object) Channel color */
1350                         SETCOL(btheme->tnla.ds_channel,         82, 96, 110, 255);
1351                         SETCOL(btheme->tnla.ds_subchannel,      124, 137, 150, 255);
1352                         /* NLA Editor - New Strip colors */
1353                         SETCOL(btheme->tnla.strip,                      12, 10, 10, 128); 
1354                         SETCOL(btheme->tnla.strip_select,       255, 140, 0, 255);
1355                 }
1356                 
1357                 /* adjust grease-pencil distances */
1358                 U.gp_manhattendist= 1;
1359                 U.gp_euclideandist= 2;
1360                 
1361                 /* adjust default interpolation for new IPO-curves */
1362                 U.ipo_new= BEZT_IPO_BEZ;
1363         }
1364         
1365         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
1366                 bTheme *btheme;
1367
1368                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1369                         
1370                         /* common (new) variables, it checks for alpha==0 */
1371                         ui_theme_init_new(btheme);
1372
1373                         if(btheme->tui.wcol_num.outline[3]==0)
1374                                 ui_widget_color_init(&btheme->tui);
1375                         
1376                         /* Logic editor theme, check for alpha==0 is safe, then color was never set */
1377                         if(btheme->tlogic.syntaxn[3]==0) {
1378                                 /* re-uses syntax color storage */
1379                                 btheme->tlogic= btheme->tv3d;
1380                                 SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
1381                         }
1382
1383                         SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
1384                         SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
1385                 }
1386         }
1387
1388         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) {
1389                 /* new audio system */
1390                 if(U.audiochannels == 0)
1391                         U.audiochannels = 2;
1392                 if(U.audiodevice == 0) {
1393 #ifdef WITH_OPENAL
1394                         U.audiodevice = 2;
1395 #endif
1396 #ifdef WITH_SDL
1397                         U.audiodevice = 1;
1398 #endif
1399                 }
1400                 if(U.audioformat == 0)
1401                         U.audioformat = 0x24;
1402                 if(U.audiorate == 0)
1403                         U.audiorate = 44100;
1404         }
1405
1406         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 5))
1407                 U.gameflags |= USER_DISABLE_VBO;
1408         
1409         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
1410                 wmKeyMap *km;
1411                 
1412                 for(km=U.keymaps.first; km; km=km->next) {
1413                         if (strcmp(km->idname, "Armature_Sketch")==0)
1414                                 strcpy(km->idname, "Armature Sketch");
1415                         else if (strcmp(km->idname, "View3D")==0)
1416                                 strcpy(km->idname, "3D View");
1417                         else if (strcmp(km->idname, "View3D Generic")==0)
1418                                 strcpy(km->idname, "3D View Generic");
1419                         else if (strcmp(km->idname, "EditMesh")==0)
1420                                 strcpy(km->idname, "Mesh");
1421                         else if (strcmp(km->idname, "TimeLine")==0)
1422                                 strcpy(km->idname, "Timeline");
1423                         else if (strcmp(km->idname, "UVEdit")==0)
1424                                 strcpy(km->idname, "UV Editor");
1425                         else if (strcmp(km->idname, "Animation_Channels")==0)
1426                                 strcpy(km->idname, "Animation Channels");
1427                         else if (strcmp(km->idname, "GraphEdit Keys")==0)
1428                                 strcpy(km->idname, "Graph Editor");
1429                         else if (strcmp(km->idname, "GraphEdit Generic")==0)
1430                                 strcpy(km->idname, "Graph Editor Generic");
1431                         else if (strcmp(km->idname, "Action_Keys")==0)
1432                                 strcpy(km->idname, "Dopesheet");
1433                         else if (strcmp(km->idname, "NLA Data")==0)
1434                                 strcpy(km->idname, "NLA Editor");
1435                         else if (strcmp(km->idname, "Node Generic")==0)
1436                                 strcpy(km->idname, "Node Editor");
1437                         else if (strcmp(km->idname, "Logic Generic")==0)
1438                                 strcpy(km->idname, "Logic Editor");
1439                         else if (strcmp(km->idname, "File")==0)
1440                                 strcpy(km->idname, "File Browser");
1441                         else if (strcmp(km->idname, "FileMain")==0)
1442                                 strcpy(km->idname, "File Browser Main");
1443                         else if (strcmp(km->idname, "FileButtons")==0)
1444                                 strcpy(km->idname, "File Browser Buttons");
1445                         else if (strcmp(km->idname, "Buttons Generic")==0)
1446                                 strcpy(km->idname, "Property Editor");
1447                 }
1448         }
1449         if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) {
1450                 if(U.wmdrawmethod == USER_DRAW_TRIPLE)
1451                         U.wmdrawmethod = USER_DRAW_AUTOMATIC;
1452         }
1453         
1454         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 3)) {
1455                 if (U.flag & USER_LMOUSESELECT) 
1456                         U.flag &= ~USER_TWOBUTTONMOUSE;
1457         }
1458         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 4)) {
1459                 bTheme *btheme;
1460                 
1461                 /* default new handle type is auto handles */
1462                 U.keyhandles_new = HD_AUTO;
1463                 
1464                 /* init new curve colors */
1465                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1466                         /* init colors used for handles in 3D-View  */
1467                         SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
1468                         SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
1469                         SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
1470                         SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
1471                         SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
1472                         SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
1473                         SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
1474                         SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
1475                         SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
1476                         
1477                         /* same colors again for Graph Editor... */
1478                         SETCOL(btheme->tipo.handle_free, 0, 0, 0, 255);
1479                         SETCOL(btheme->tipo.handle_auto, 0x90, 0x90, 0x00, 255);
1480                         SETCOL(btheme->tipo.handle_vect, 0x40, 0x90, 0x30, 255);
1481                         SETCOL(btheme->tipo.handle_align, 0x80, 0x30, 0x60, 255);
1482                         SETCOL(btheme->tipo.handle_sel_free, 0, 0, 0, 255);
1483                         SETCOL(btheme->tipo.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
1484                         SETCOL(btheme->tipo.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
1485                         SETCOL(btheme->tipo.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
1486                         
1487                         /* edge crease */
1488                         SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
1489                 }
1490         }
1491         if (bmain->versionfile <= 252) {
1492                 bTheme *btheme;
1493
1494                 /* init new curve colors */
1495                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1496                         if (btheme->tv3d.lastsel_point[3] == 0)
1497                                 SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
1498                 }
1499         }
1500         if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
1501                 bTheme *btheme;
1502                 
1503                 /* interface_widgets.c */
1504                 struct uiWidgetColors wcol_progress= {
1505                         {0, 0, 0, 255},
1506                         {190, 190, 190, 255},
1507                         {100, 100, 100, 180},
1508                         {68, 68, 68, 255},
1509                         
1510                         {0, 0, 0, 255},
1511                         {255, 255, 255, 255},
1512                         
1513                         0,
1514                         5, -5
1515                 };
1516                 
1517                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1518                         /* init progress bar theme */
1519                         btheme->tui.wcol_progress= wcol_progress;
1520                 }
1521         }
1522
1523         if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 2)) {
1524                 bTheme *btheme;
1525                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1526                         SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
1527                         SETCOL(btheme->tv3d.extra_face_angle, 0, 32, 0, 255);
1528                         SETCOL(btheme->tv3d.extra_face_area, 0, 0, 128, 255);
1529                 }
1530         }
1531         
1532         if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 4)) {
1533                 bTheme *btheme;
1534                 for(btheme= U.themes.first; btheme; btheme= btheme->next) {
1535                         if((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width= 1;
1536                 }
1537         }
1538
1539         if (bmain->versionfile < 257) {
1540                 /* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs, so that it doesn't linger around from old configs like a ghost */
1541                 U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
1542         }
1543         
1544         /* GL Texture Garbage Collection (variable abused above!) */
1545         if (U.textimeout == 0) {
1546                 U.texcollectrate = 60;
1547                 U.textimeout = 120;
1548         }
1549         if (U.memcachelimit <= 0) {
1550                 U.memcachelimit = 32;
1551         }
1552         if (U.frameserverport == 0) {
1553                 U.frameserverport = 8080;
1554         }
1555         if (U.dbl_click_time == 0) {
1556                 U.dbl_click_time = 350;
1557         }
1558         if (U.anim_player_preset == 0) {
1559                 U.anim_player_preset = 1 ;
1560         }
1561         if (U.scrcastfps == 0) {
1562                 U.scrcastfps = 10;
1563                 U.scrcastwait = 50;
1564         }
1565         if (U.v2d_min_gridsize == 0) {
1566                 U.v2d_min_gridsize= 35;
1567         }
1568         if (U.dragthreshold == 0 )
1569                 U.dragthreshold= 5;
1570
1571         /* funny name, but it is GE stuff, moves userdef stuff to engine */
1572 // XXX  space_set_commmandline_options();
1573         /* this timer uses U */
1574 // XXX  reset_autosave();
1575
1576 }