2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version. The Blender
|
|
|
|
* Foundation also sells licenses for use in proprietary software under
|
|
|
|
* the Blender License. See http://www.blender.org/BL/ for information
|
|
|
|
* about this.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* placed up here because of crappy
|
|
|
|
* winsock stuff.
|
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2002-11-25 12:02:15 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include "BLI_winstuff.h"
|
2003-03-24 01:46:05 +00:00
|
|
|
#include <process.h> /* getpid */
|
2002-10-12 11:37:38 +00:00
|
|
|
#else
|
|
|
|
#include <unistd.h> /* getpid */
|
|
|
|
#endif
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BMF_Api.h"
|
2003-05-03 12:17:11 +00:00
|
|
|
#ifdef INTERNATIONAL
|
|
|
|
#include "BIF_language.h"
|
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_arithb.h"
|
|
|
|
#include "BLI_editVert.h"
|
|
|
|
#include "BLI_linklist.h"
|
|
|
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
#include "DNA_userdef_types.h"
|
|
|
|
|
|
|
|
#include "BKE_blender.h"
|
|
|
|
#include "BKE_curve.h"
|
|
|
|
#include "BKE_displist.h"
|
|
|
|
#include "BKE_exotic.h"
|
|
|
|
#include "BKE_font.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_mball.h"
|
|
|
|
#include "BKE_packedFile.h"
|
2003-05-05 21:28:54 +00:00
|
|
|
#include "BKE_utildefines.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "BIF_fsmenu.h"
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_interface.h"
|
|
|
|
#include "BIF_usiblender.h"
|
|
|
|
#include "BIF_drawtext.h"
|
|
|
|
#include "BIF_editarmature.h"
|
|
|
|
#include "BIF_editlattice.h"
|
|
|
|
#include "BIF_editfont.h"
|
|
|
|
#include "BIF_editmesh.h"
|
|
|
|
#include "BIF_editsound.h"
|
|
|
|
#include "BIF_renderwin.h"
|
|
|
|
#include "BIF_resources.h"
|
|
|
|
#include "BIF_screen.h"
|
|
|
|
#include "BIF_space.h"
|
|
|
|
#include "BIF_toolbox.h"
|
|
|
|
|
|
|
|
#include "BSE_drawview.h"
|
|
|
|
#include "BSE_headerbuttons.h"
|
|
|
|
#include "BSE_editipo.h"
|
|
|
|
#include "BSE_editaction.h"
|
|
|
|
#include "BSE_filesel.h"
|
|
|
|
|
|
|
|
#include "BLO_readfile.h"
|
|
|
|
#include "BLO_writefile.h"
|
|
|
|
|
|
|
|
#include "BDR_drawobject.h"
|
|
|
|
#include "BDR_editobject.h"
|
|
|
|
#include "BDR_vpaint.h"
|
|
|
|
|
|
|
|
#include "BPY_extern.h"
|
|
|
|
#include "blendef.h"
|
|
|
|
|
|
|
|
#include "radio.h"
|
|
|
|
#include "render.h"
|
|
|
|
#include "datatoc.h"
|
|
|
|
|
|
|
|
#include "SYS_System.h"
|
|
|
|
|
|
|
|
#include "PIL_time.h"
|
|
|
|
|
|
|
|
/***/
|
|
|
|
|
|
|
|
void BIF_read_file(char *name)
|
|
|
|
{
|
|
|
|
extern short winqueue_break; /* editscreen.c */
|
2003-07-14 13:48:44 +00:00
|
|
|
|
2003-04-30 13:22:26 +00:00
|
|
|
//here?
|
2002-10-12 11:37:38 +00:00
|
|
|
//sound_end_all_sounds();
|
|
|
|
|
|
|
|
// first try to read exotic file formats...
|
|
|
|
if (BKE_read_exotic(name) == 0) { /* throws first error box */
|
2003-05-22 17:16:41 +00:00
|
|
|
/* we didn't succeed, now try to read Blender file
|
|
|
|
calls readfile, calls toolbox, throws one more,
|
|
|
|
on failure calls the stream, and that is stubbed.... */
|
|
|
|
BKE_read_file(name, NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sound_initialize_sounds();
|
|
|
|
|
2003-04-30 13:22:26 +00:00
|
|
|
winqueue_break= 1; /* leave queues everywhere */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int BIF_read_homefile(void)
|
|
|
|
{
|
|
|
|
char tstr[FILE_MAXDIR+FILE_MAXFILE], scestr[FILE_MAXDIR];
|
|
|
|
char *home= BLI_gethome();
|
2003-05-09 12:48:21 +00:00
|
|
|
int success;
|
2003-08-14 15:18:45 +00:00
|
|
|
#ifdef _WIN32 // FULLSCREEN
|
2003-05-12 14:23:03 +00:00
|
|
|
static int screenmode = -1;
|
|
|
|
|
|
|
|
screenmode = U.uiflag & FLIPFULLSCREEN;
|
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
BLI_make_file_string(G.sce, tstr, home, ".B.blend");
|
2003-04-30 13:22:26 +00:00
|
|
|
strcpy(scestr, G.sce); /* temporal store */
|
2002-10-12 11:37:38 +00:00
|
|
|
if (BLI_exists(tstr)) {
|
|
|
|
success = BKE_read_file(tstr, NULL);
|
|
|
|
} else {
|
|
|
|
success = BKE_read_file_from_memory(datatoc_B_blend, datatoc_B_blend_size, NULL);
|
|
|
|
}
|
|
|
|
strcpy(G.sce, scestr);
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
G.save_over = 0;
|
|
|
|
|
|
|
|
/* disable autoplay in .B.blend... */
|
|
|
|
G.fileflags &= ~G_FILE_AUTOPLAY;
|
2003-05-08 16:24:58 +00:00
|
|
|
|
2003-05-09 14:03:34 +00:00
|
|
|
#ifdef _WIN32 // FULLSCREEN
|
|
|
|
/* choose window startmode */
|
|
|
|
switch (G.windowstate){
|
|
|
|
case G_WINDOWSTATE_USERDEF: /* use the usersetting */
|
|
|
|
break;
|
|
|
|
case G_WINDOWSTATE_FULLSCREEN: /* force fullscreen */
|
|
|
|
U.uiflag |= FLIPFULLSCREEN;
|
|
|
|
break;
|
|
|
|
case G_WINDOWSTATE_BORDER: /* force with borders */
|
|
|
|
U.uiflag &= ~FLIPFULLSCREEN;
|
|
|
|
}
|
2003-05-12 14:23:03 +00:00
|
|
|
|
|
|
|
if(screenmode != (U.uiflag & FLIPFULLSCREEN)) {
|
|
|
|
mainwindow_toggle_fullscreen ((U.uiflag & FLIPFULLSCREEN));
|
|
|
|
screenmode = (U.uiflag & FLIPFULLSCREEN);
|
|
|
|
}
|
2003-05-09 14:03:34 +00:00
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if (BLI_streq(U.tempdir, "/")) {
|
|
|
|
char *tmp= getenv("TEMP");
|
|
|
|
|
|
|
|
strcpy(U.tempdir, tmp?tmp:"/tmp/");
|
|
|
|
}
|
2003-05-30 19:00:12 +00:00
|
|
|
if (U.savetime <= 0) {
|
|
|
|
U.savetime = 1;
|
|
|
|
error("%s is buggy, please cosider removing it.\n",
|
|
|
|
tstr);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
if (G.main->versionfile <= 191) {
|
|
|
|
strcpy(U.plugtexdir, U.textudir);
|
|
|
|
strcpy(U.sounddir, "/");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* patch to set Dupli Armature */
|
|
|
|
if (G.main->versionfile < 220) {
|
|
|
|
U.dupflag |= DUPARM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* userdef new option */
|
|
|
|
if (G.main->versionfile <= 222) {
|
|
|
|
U.vrmlflag= USERDEF_VRML_LAYERS;
|
|
|
|
}
|
|
|
|
|
2003-05-12 14:23:03 +00:00
|
|
|
#ifndef __sgi
|
|
|
|
/* startup 2.26 with aa fonts ! */
|
2003-05-10 11:25:52 +00:00
|
|
|
if (G.main->versionfile <= 225) {
|
|
|
|
U.transopts |= TR_ALL;
|
|
|
|
}
|
2003-05-12 14:23:03 +00:00
|
|
|
#endif
|
Commit message and the brunt of the code courtesy of intrr, apologies for the
size of this;
Finally, the Sequencer audio support and global audio/animation sync stuff!
(See http://intrr.org/blender/audiosequencer.html)
Stuff that has been done:
./source/blender/blenloader/intern/writefile.c
./source/blender/blenloader/intern/readfile.c
Added code to make it handle sounds used by audio strips, and to convert
Scene data from older (<2.28) versions to init Scene global audio settings
(Scene->audio) to defaults.
./source/blender/include/BSE_seqaudio.h
./source/blender/src/seqaudio.c
The main audio routines that start/stop/scrub the audio stream at
a certain frame position, provide the frame reference for the current
stream position, mix the audio, convert the audio, mixdown the audio
into a file.
./source/blender/makesdna/DNA_sound_types.h
Introduced new variables in the bSound struct to accomodate the sample
data after converted to the scene's global mixing format (stream, streamlen).
Also added a new flag SOUND_FLAGS_SEQUENCE that gets set if the Sound
belongs to a sequence strip.
./source/blender/makesdna/DNA_scene_types.h
Added AudioData struct, which holds scene-global audio settings.
./source/blender/makesdna/DNA_sequence_types.h
Added support for audio strips. Some variables to hold Panning/Attenuation
information, position information, reference to the sample, and some flags.
./source/blender/makesdna/DNA_userdef_types.h
./source/blender/src/usiblender.c
Added a "Mixing buffer size" userpref. Made the versions stuff initialize
it to a default for versions <2.28.
./source/blender/makesdna/DNA_space_types.h
./source/blender/src/filesel.c
Added a Cyan dot to .WAV files. Any other suggestions on a better color? :)
./source/blender/src/editsound.c
Changes (fixes) to the WAV file loader, re-enabled some gameengine code that
is needed for dealing with bSounds and bSamples.
./source/blender/src/editipo.c
./source/blender/src/drawseq.c
./source/blender/src/editnla.c
./source/blender/src/space.c
./source/blender/src/drawview.c
./source/blender/src/renderwin.c
./source/blender/src/headerbuttons.c
- Created two different wrappers for update_for_newframe(), one which scrubs
the audio, one which doesn't.
- Replaced some of the occurences of update_for_newframe() with
update_for_newframe_muted(), which doesn't scrub the audio.
- In drawview.c: Changed the synchronization scheme to get the current audio
position from the audio engine, and use that as a reference for setting
CFRA. Implements a/v sync and framedrop.
- In editipo.c: Changed handling of Fac IPOs to be usable for audio strips as
volume envelopes.
- In space.c: Added the mixing buffer size Userpref, enabled audio scrubbing
(update_for_newframe()) for moving the sequence editor framebar.
./source/blender/src/editseq.c
Added support for audio strips and a default directory for WAV files which
gets saved from the last Shift-A operation.
./source/blender/src/buttons.c
Added Scene-global audio sequencer settings in Sound buttons.
./source/blender/src/sequence.c
Various stuff that deals with handling audio strips differently than
usual strips.
2003-07-13 20:16:56 +00:00
|
|
|
if (G.main->versionfile <= 227) {
|
|
|
|
U.mixbufsize= 2048;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
space_set_commmandline_options();
|
|
|
|
|
|
|
|
reset_autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void get_autosave_location(char buf[FILE_MAXDIR+FILE_MAXFILE])
|
|
|
|
{
|
|
|
|
char pidstr[32];
|
|
|
|
|
|
|
|
sprintf(pidstr, "%d.blend", abs(getpid()));
|
|
|
|
BLI_make_file_string("/", buf, U.tempdir, pidstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BIF_read_autosavefile(void)
|
|
|
|
{
|
|
|
|
char tstr[FILE_MAXDIR+FILE_MAXFILE], scestr[FILE_MAXDIR];
|
|
|
|
int save_over;
|
|
|
|
|
2003-04-30 13:22:26 +00:00
|
|
|
strcpy(scestr, G.sce); /* temporal store */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
get_autosave_location(tstr);
|
|
|
|
|
|
|
|
save_over = G.save_over;
|
|
|
|
BKE_read_file(tstr, NULL);
|
|
|
|
G.save_over = save_over;
|
|
|
|
strcpy(G.sce, scestr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/
|
|
|
|
|
|
|
|
static void readBlog(void)
|
|
|
|
{
|
|
|
|
char name[FILE_MAXDIR+FILE_MAXFILE];
|
|
|
|
LinkNode *l, *lines;
|
|
|
|
|
|
|
|
BLI_make_file_string("/", name, BLI_gethome(), ".Blog");
|
|
|
|
lines= BLI_read_file_as_lines(name);
|
|
|
|
|
|
|
|
if (lines && !BLI_streq(lines->link, "")) {
|
|
|
|
strcpy(G.sce, lines->link);
|
|
|
|
} else {
|
|
|
|
BLI_make_file_string("/", G.sce, BLI_gethome(), "untitled.blend");
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_free_file_lines(lines);
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
/* Add the drive names to the listing */
|
|
|
|
{
|
|
|
|
__int64 tmp;
|
|
|
|
char tmps[4];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
tmp= GetLogicalDrives();
|
|
|
|
|
|
|
|
for (i=2; i < 26; i++) {
|
|
|
|
if ((tmp>>i) & 1) {
|
|
|
|
tmps[0]='a'+i;
|
|
|
|
tmps[1]=':';
|
|
|
|
tmps[2]='\\';
|
|
|
|
tmps[3]=0;
|
|
|
|
|
|
|
|
fsmenu_insert_entry(tmps, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fsmenu_append_seperator();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BLI_make_file_string(G.sce, name, BLI_gethome(), ".Bfs");
|
|
|
|
lines= BLI_read_file_as_lines(name);
|
|
|
|
|
|
|
|
for (l= lines; l; l= l->next) {
|
|
|
|
char *line= l->link;
|
|
|
|
|
|
|
|
if (!BLI_streq(line, "")) {
|
|
|
|
fsmenu_insert_entry(line, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fsmenu_append_seperator();
|
|
|
|
BLI_free_file_lines(lines);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void writeBlog(void)
|
|
|
|
{
|
|
|
|
char name[FILE_MAXDIR+FILE_MAXFILE];
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
BLI_make_file_string("/", name, BLI_gethome(), ".Blog");
|
|
|
|
|
|
|
|
fp= fopen(name, "w");
|
|
|
|
if (fp) {
|
|
|
|
fprintf(fp, G.sce);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_history(char *name)
|
|
|
|
{
|
|
|
|
char tempname1[FILE_MAXDIR+FILE_MAXFILE], tempname2[FILE_MAXDIR+FILE_MAXFILE];
|
|
|
|
int hisnr= U.versions;
|
|
|
|
|
|
|
|
if(U.versions==0) return;
|
|
|
|
if(strlen(name)<2) return;
|
|
|
|
|
|
|
|
while( hisnr > 1) {
|
|
|
|
sprintf(tempname1, "%s%d", name, hisnr-1);
|
|
|
|
sprintf(tempname2, "%s%d", name, hisnr);
|
|
|
|
|
|
|
|
if(BLI_rename(tempname1, tempname2))
|
|
|
|
error("Unable to make version backup");
|
|
|
|
|
|
|
|
hisnr--;
|
|
|
|
}
|
|
|
|
|
2003-04-30 13:22:26 +00:00
|
|
|
/* is needed when hisnr==1 */
|
2002-10-12 11:37:38 +00:00
|
|
|
sprintf(tempname1, "%s%d", name, hisnr);
|
|
|
|
|
|
|
|
if(BLI_rename(name, tempname1))
|
|
|
|
error("Unable to make version backup");
|
|
|
|
}
|
|
|
|
|
|
|
|
void BIF_write_file(char *target)
|
|
|
|
{
|
|
|
|
Library *li;
|
|
|
|
char di[FILE_MAXDIR];
|
|
|
|
char *err;
|
|
|
|
|
|
|
|
if (BLI_streq(target, "")) return;
|
|
|
|
|
|
|
|
for (li= G.main->library.first; li; li= li->id.next) {
|
|
|
|
if (BLI_streq(li->name, target)) {
|
|
|
|
error("Cannot overwrite used library");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!BLO_has_bfile_extension(target)) {
|
|
|
|
sprintf(di, "%s.blend", target);
|
|
|
|
} else {
|
|
|
|
strcpy(di, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BLI_exists(di)) {
|
|
|
|
if(!saveover(di))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
waitcursor(1);
|
|
|
|
|
|
|
|
if(G.obedit) {
|
2003-04-30 13:22:26 +00:00
|
|
|
exit_editmode(0); /* 0 = no free data */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
if (G.fileflags & G_AUTOPACK) {
|
|
|
|
packAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
do_history(di);
|
|
|
|
|
|
|
|
if (BLO_write_file(di, G.fileflags, &err)) {
|
|
|
|
strcpy(G.sce, di);
|
2003-04-30 13:22:26 +00:00
|
|
|
strcpy(G.main->name, di); /* is guarenteed current file */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
G.save_over = 1;
|
|
|
|
|
|
|
|
writeBlog();
|
|
|
|
} else {
|
|
|
|
error("%s", err);
|
|
|
|
}
|
|
|
|
|
|
|
|
waitcursor(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BIF_write_homefile(void)
|
|
|
|
{
|
|
|
|
char *err, tstr[FILE_MAXDIR+FILE_MAXFILE];
|
|
|
|
int write_flags;
|
|
|
|
|
2003-08-12 20:37:14 +00:00
|
|
|
/* "change-over" period for Windows - Ctrl+U now saves in ~/.blender,
|
|
|
|
but blender still checks the old locations.
|
|
|
|
To be removed at v2.4 or so! ;)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
char dir[FILE_MAXDIR+FILE_MAXFILE];
|
|
|
|
BLI_getInstallationDir(dir);
|
|
|
|
|
|
|
|
strcat(dir,"/.blender/");
|
|
|
|
|
|
|
|
BLI_make_file_string("/", tstr, dir, ".B.blend");
|
|
|
|
#else
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_make_file_string("/", tstr, BLI_gethome(), ".B.blend");
|
2003-08-12 20:37:14 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/* force save as regular blend file */
|
|
|
|
write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
|
|
|
|
BLO_write_file(tstr, write_flags, &err);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BIF_write_autosave(void)
|
|
|
|
{
|
|
|
|
char *err, tstr[FILE_MAXDIR+FILE_MAXFILE];
|
|
|
|
int write_flags;
|
|
|
|
|
|
|
|
get_autosave_location(tstr);
|
|
|
|
|
|
|
|
/* force save as regular blend file */
|
|
|
|
write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
|
|
|
|
BLO_write_file(tstr, write_flags, &err);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void delete_autosave(void)
|
|
|
|
{
|
|
|
|
char tstr[FILE_MAXDIR+FILE_MAXFILE], pidstr[FILE_MAXFILE];
|
|
|
|
|
|
|
|
sprintf(pidstr, "%d", abs(getpid()));
|
|
|
|
BLI_make_file_string("/", tstr, U.tempdir, pidstr);
|
|
|
|
|
|
|
|
if (BLI_exists(tstr)) {
|
|
|
|
char str[FILE_MAXDIR+FILE_MAXFILE];
|
|
|
|
BLI_make_file_string("/", str, U.tempdir, "quit.blend");
|
|
|
|
BLI_rename(tstr, str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/
|
|
|
|
|
|
|
|
static void initbuttons(void)
|
|
|
|
{
|
|
|
|
uiDefFont(UI_HELVB,
|
|
|
|
BMF_GetFont(BMF_kHelveticaBold14),
|
|
|
|
BMF_GetFont(BMF_kHelveticaBold12),
|
|
|
|
BMF_GetFont(BMF_kHelveticaBold10),
|
|
|
|
BMF_GetFont(BMF_kHelveticaBold8));
|
|
|
|
uiDefFont(UI_HELV,
|
|
|
|
BMF_GetFont(BMF_kHelvetica12),
|
|
|
|
BMF_GetFont(BMF_kHelvetica12),
|
|
|
|
BMF_GetFont(BMF_kHelvetica10),
|
|
|
|
BMF_GetFont(BMF_kHelveticaBold8));
|
|
|
|
|
|
|
|
BIF_resources_init();
|
|
|
|
|
|
|
|
glClearColor(.7, .7, .6, 0.0);
|
|
|
|
|
|
|
|
G.font= BMF_GetFont(BMF_kHelvetica12);
|
|
|
|
G.fonts= BMF_GetFont(BMF_kHelvetica10);
|
|
|
|
G.fontss= BMF_GetFont(BMF_kHelveticaBold8);
|
|
|
|
|
|
|
|
clear_matcopybuf();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BIF_init(void)
|
|
|
|
{
|
|
|
|
BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size);
|
|
|
|
|
2003-04-30 13:22:26 +00:00
|
|
|
initscreen(); /* for (visuele) speed, this first, then setscreen */
|
2002-10-12 11:37:38 +00:00
|
|
|
initbuttons();
|
- The basic layer for Themes in place!
- currently only implemented for 3d window
- create as many themes you like, and name them
- default theme is not editable, and always will be defined at startup
(initTheme)
- saves in .B.blend
- themes for spaces can become local too, so you can set individual
3d windows at theme 'Maya' or so. (to be implemented)
- it uses alpha as well...!
API:
This doesnt use the old method with BFCOLORID blahblah. The API is copied
from OpenGL conventions (naming) as much as possible:
- void BIF_ThemeColor(ScrArea *sa, int colorid)
sets a color... id's are in BIF_resources.h (TH_GRID, TH_WIRE, etc)
- void BIF_ThemeColorShade(ScrArea *sa, int colorid, int offset)
sets a color with offset, no more weird COLORSHADE_LGREY stuff
- void BIF_GetThemeColor3fv(ScrArea *sa, int colorid, float *col)
like opengl, this gives you in *col the three rgb values
- void BIF_GetThemeColor4ubv(ScrArea *sa, int colorid, char *col)
or the one to get 4 bytes
ThemeColor calls for globals (UI etc) can also call NULL for *sa... this
is to be implemented still.
Next step: cleaning up interface.c for all weird colorcalls.
2003-10-17 14:02:08 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
init_draw_rects(); /* drawobject.c */
|
|
|
|
init_gl_stuff(); /* drawview.c */
|
|
|
|
BIF_read_homefile();
|
- The basic layer for Themes in place!
- currently only implemented for 3d window
- create as many themes you like, and name them
- default theme is not editable, and always will be defined at startup
(initTheme)
- saves in .B.blend
- themes for spaces can become local too, so you can set individual
3d windows at theme 'Maya' or so. (to be implemented)
- it uses alpha as well...!
API:
This doesnt use the old method with BFCOLORID blahblah. The API is copied
from OpenGL conventions (naming) as much as possible:
- void BIF_ThemeColor(ScrArea *sa, int colorid)
sets a color... id's are in BIF_resources.h (TH_GRID, TH_WIRE, etc)
- void BIF_ThemeColorShade(ScrArea *sa, int colorid, int offset)
sets a color with offset, no more weird COLORSHADE_LGREY stuff
- void BIF_GetThemeColor3fv(ScrArea *sa, int colorid, float *col)
like opengl, this gives you in *col the three rgb values
- void BIF_GetThemeColor4ubv(ScrArea *sa, int colorid, char *col)
or the one to get 4 bytes
ThemeColor calls for globals (UI etc) can also call NULL for *sa... this
is to be implemented still.
Next step: cleaning up interface.c for all weird colorcalls.
2003-10-17 14:02:08 +00:00
|
|
|
BIF_InitThemeColors(); /* after read home file! */
|
2002-10-12 11:37:38 +00:00
|
|
|
readBlog();
|
|
|
|
strcpy(G.lib, G.sce);
|
2003-05-09 12:48:21 +00:00
|
|
|
|
|
|
|
#ifdef INTERNATIONAL
|
|
|
|
read_languagefile();
|
|
|
|
|
|
|
|
if(U.transopts & TR_ALL)
|
|
|
|
start_interface_font();
|
|
|
|
else
|
|
|
|
G.ui_international = FALSE;
|
|
|
|
#endif // INTERNATIONAL
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***/
|
|
|
|
|
|
|
|
extern ListBase editNurb;
|
|
|
|
extern ListBase editelems;
|
|
|
|
|
|
|
|
void exit_usiblender(void)
|
|
|
|
{
|
|
|
|
freeAllRad();
|
|
|
|
BKE_freecubetable();
|
|
|
|
|
|
|
|
if (G.background == 0)
|
|
|
|
sound_end_all_sounds();
|
|
|
|
|
|
|
|
if(G.obedit) {
|
|
|
|
if(G.obedit->type==OB_FONT) {
|
|
|
|
free_editText();
|
|
|
|
}
|
|
|
|
else if(G.obedit->type==OB_MBALL) BLI_freelistN(&editelems);
|
|
|
|
free_editMesh();
|
|
|
|
}
|
|
|
|
|
|
|
|
free_editLatt();
|
|
|
|
free_editArmature();
|
|
|
|
free_posebuf();
|
|
|
|
|
2003-04-30 13:22:26 +00:00
|
|
|
free_blender(); /* blender.c, does entire library */
|
2002-10-12 11:37:38 +00:00
|
|
|
free_hashedgetab();
|
|
|
|
free_matcopybuf();
|
|
|
|
free_ipocopybuf();
|
|
|
|
freefastshade();
|
|
|
|
free_vertexpaint();
|
|
|
|
|
2003-04-30 13:22:26 +00:00
|
|
|
/* editnurb can remain to exist outside editmode */
|
2002-10-12 11:37:38 +00:00
|
|
|
freeNurblist(&editNurb);
|
|
|
|
|
|
|
|
fsmenu_free();
|
2003-05-03 12:17:11 +00:00
|
|
|
#ifdef INTERNATIONAL
|
2003-05-09 12:48:21 +00:00
|
|
|
free_languagemenu();
|
2003-05-03 12:17:11 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
RE_free_render_data();
|
|
|
|
RE_free_filt_mask();
|
|
|
|
|
|
|
|
free_txt_data();
|
|
|
|
|
|
|
|
sound_exit_audio();
|
2003-04-28 02:15:46 +00:00
|
|
|
|
2003-09-18 12:27:43 +00:00
|
|
|
#ifdef WITH_QUICKTIME
|
2003-09-18 11:41:50 +00:00
|
|
|
quicktime_exit();
|
2003-09-18 12:27:43 +00:00
|
|
|
#endif
|
2003-09-18 11:41:50 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
BPY_end_python();
|
|
|
|
|
|
|
|
if (!G.background) {
|
|
|
|
BIF_resources_free();
|
|
|
|
|
|
|
|
BIF_close_render_display();
|
|
|
|
mainwindow_close();
|
|
|
|
}
|
|
|
|
|
- The basic layer for Themes in place!
- currently only implemented for 3d window
- create as many themes you like, and name them
- default theme is not editable, and always will be defined at startup
(initTheme)
- saves in .B.blend
- themes for spaces can become local too, so you can set individual
3d windows at theme 'Maya' or so. (to be implemented)
- it uses alpha as well...!
API:
This doesnt use the old method with BFCOLORID blahblah. The API is copied
from OpenGL conventions (naming) as much as possible:
- void BIF_ThemeColor(ScrArea *sa, int colorid)
sets a color... id's are in BIF_resources.h (TH_GRID, TH_WIRE, etc)
- void BIF_ThemeColorShade(ScrArea *sa, int colorid, int offset)
sets a color with offset, no more weird COLORSHADE_LGREY stuff
- void BIF_GetThemeColor3fv(ScrArea *sa, int colorid, float *col)
like opengl, this gives you in *col the three rgb values
- void BIF_GetThemeColor4ubv(ScrArea *sa, int colorid, char *col)
or the one to get 4 bytes
ThemeColor calls for globals (UI etc) can also call NULL for *sa... this
is to be implemented still.
Next step: cleaning up interface.c for all weird colorcalls.
2003-10-17 14:02:08 +00:00
|
|
|
BLI_freelistN(&U.themes);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(totblock!=0) {
|
- The basic layer for Themes in place!
- currently only implemented for 3d window
- create as many themes you like, and name them
- default theme is not editable, and always will be defined at startup
(initTheme)
- saves in .B.blend
- themes for spaces can become local too, so you can set individual
3d windows at theme 'Maya' or so. (to be implemented)
- it uses alpha as well...!
API:
This doesnt use the old method with BFCOLORID blahblah. The API is copied
from OpenGL conventions (naming) as much as possible:
- void BIF_ThemeColor(ScrArea *sa, int colorid)
sets a color... id's are in BIF_resources.h (TH_GRID, TH_WIRE, etc)
- void BIF_ThemeColorShade(ScrArea *sa, int colorid, int offset)
sets a color with offset, no more weird COLORSHADE_LGREY stuff
- void BIF_GetThemeColor3fv(ScrArea *sa, int colorid, float *col)
like opengl, this gives you in *col the three rgb values
- void BIF_GetThemeColor4ubv(ScrArea *sa, int colorid, char *col)
or the one to get 4 bytes
ThemeColor calls for globals (UI etc) can also call NULL for *sa... this
is to be implemented still.
Next step: cleaning up interface.c for all weird colorcalls.
2003-10-17 14:02:08 +00:00
|
|
|
printf("Error Totblock: %d\n",totblock);
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_printmemlist();
|
|
|
|
}
|
|
|
|
delete_autosave();
|
|
|
|
|
|
|
|
printf("\nBlender quit\n");
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
// when debugging enter infinite loop to enable
|
|
|
|
// reading the printouts...
|
|
|
|
while(G.f & G_DEBUG) {PIL_sleep_ms(10);}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
SYS_DeleteSystem(SYS_GetSystem());
|
|
|
|
|
|
|
|
exit(G.afbreek==1);
|
|
|
|
}
|