svn merge -r 30323:30417 https://svn.blender.org/svnroot/bf-blender/trunk/blender
authorJoerg Mueller <nexyon@gmail.com>
Fri, 16 Jul 2010 17:43:08 +0000 (17:43 +0000)
committerJoerg Mueller <nexyon@gmail.com>
Fri, 16 Jul 2010 17:43:08 +0000 (17:43 +0000)
1  2 
source/blender/python/intern/bpy.c
source/blender/windowmanager/intern/wm_init_exit.c
source/creator/creator.c

index fb5c56f383e7c03e18460525591e3ec60e1d9535,15be6174f29fc5ec40f1489528dccd56f2ddc0e5..934288065b88b6606a5e0e7a40a334f221164316
  #include "../generic/blf_api.h"
  #include "../generic/IDProp.h"
  
- static char bpy_home_paths_doc[] =
- ".. function:: home_paths(subfolder)\n"
 +#ifndef DISABLE_PYTHON
 +#define WITH_PYTHON
 +#endif
 +#include "AUD_C-API.h"
 +
+ static char bpy_script_paths_doc[] =
+ ".. function:: script_paths()\n"
  "\n"
- "   Return 3 paths to blender home directories.\n"
+ "   Return 2 paths to blender scripts directories.\n"
  "\n"
- "   :arg subfolder: The name of a subfolder to find within the blenders home directory.\n"
- "   :type subfolder: string\n"
- "   :return: (system, local, user) strings will be empty when not found.\n"
+ "   :return: (system, user) strings will be empty when not found.\n"
  "   :rtype: tuple of strigs\n";
  
- PyObject *bpy_home_paths(PyObject *self, PyObject *args)
+ PyObject *bpy_script_paths(PyObject *self)
  {
-       PyObject *ret= PyTuple_New(3);
+       PyObject *ret= PyTuple_New(2);
        char *path;
-       char *subfolder= "";
      
-       if (!PyArg_ParseTuple(args, "|s:blender_homes", &subfolder))
-               return NULL;
-       path= BLI_gethome_folder(subfolder, BLI_GETHOME_SYSTEM);
+       path= BLI_get_folder(BLENDER_USER_SCRIPTS, NULL);
        PyTuple_SET_ITEM(ret, 0, PyUnicode_FromString(path?path:""));
-       path= BLI_gethome_folder(subfolder, BLI_GETHOME_LOCAL);
+       path= BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, NULL);
        PyTuple_SET_ITEM(ret, 1, PyUnicode_FromString(path?path:""));
-       path= BLI_gethome_folder(subfolder, BLI_GETHOME_USER);
-       PyTuple_SET_ITEM(ret, 2, PyUnicode_FromString(path?path:""));
      
        return ret;
  }
@@@ -125,7 -110,7 +115,7 @@@ static PyObject *bpy_blend_paths(PyObje
        return list;
  }
  
- static PyMethodDef meth_bpy_home_paths[] = {{ "home_paths", (PyCFunction)bpy_home_paths, METH_VARARGS, bpy_home_paths_doc}};
+ static PyMethodDef meth_bpy_script_paths[] = {{ "script_paths", (PyCFunction)bpy_script_paths, METH_NOARGS, bpy_script_paths_doc}};
  static PyMethodDef meth_bpy_blend_paths[] = {{ "blend_paths", (PyCFunction)bpy_blend_paths, METH_VARARGS|METH_KEYWORDS, bpy_blend_paths_doc}};
  
  static void bpy_import_test(char *modname)
@@@ -167,7 -152,7 +157,7 @@@ void BPy_init_modules( void 
        BGL_Init();
        BLF_Init();
        IDProp_Init_Types();
 -
 +      AUD_initPython();
  
        mod = PyModule_New("_bpy");
  
        PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module);
  
        /* utility func's that have nowhere else to go */
-       PyModule_AddObject(mod, meth_bpy_home_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_home_paths, NULL));
+       PyModule_AddObject(mod, meth_bpy_script_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_script_paths, NULL));
        PyModule_AddObject(mod, meth_bpy_blend_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_blend_paths, NULL));
  
        /* add our own modules dir, this is a python package */
index 9257401b650e53dd042fbc258fc0c7a639f9b07e,558d20021ce6ea0a3ac692443eb81f3abab93dac..fe3172f5fdae674e53849f5967e0f2a5a8744fc4
@@@ -49,7 -49,6 +49,7 @@@
  #include "BKE_font.h"
  #include "BKE_global.h"
  #include "BKE_library.h"
 +#include "BKE_main.h"
  #include "BKE_mball.h"
  #include "BKE_report.h"
  #include "BKE_utildefines.h"
@@@ -165,6 -164,10 +165,10 @@@ void WM_init(bContext *C, int argc, cha
        G.ndofdevice = -1;      /* XXX bad initializer, needs set otherwise buttons show! */
        
        read_history();
+       if(G.sce[0] == 0)
+               BLI_make_file_string("/", G.sce, BLI_getDefaultDocumentFolder(), "untitled.blend");
        BLI_strncpy(G.lib, G.sce, FILE_MAX);
  
  }
@@@ -183,107 -186,18 +187,107 @@@ void WM_init_splash(bContext *C
        }
  }
  
 -void WM_init_game(bContext *C)
 +static ScrArea *biggest_view3d(bContext *C)
 +{
 +      bScreen *sc= CTX_wm_screen(C);
 +      ScrArea *sa, *big= NULL;
 +      int size, maxsize= 0;
 +
 +      for(sa= sc->areabase.first; sa; sa= sa->next) {
 +              if(sa->spacetype==SPACE_VIEW3D) {
 +                      size= sa->winx * sa->winy;
 +                      if(size > maxsize) {
 +                              maxsize= size;
 +                              big= sa;
 +                      }
 +              }
 +      }
 +      return big;
 +}
 +
 +int WM_init_game(bContext *C)
  {
 -      //XXX copied from WM_init_splash we may not even need those "window" related code
 -      //XXX not working yet, it fails at the game_start_operator pool (it needs an area)
        wmWindowManager *wm= CTX_wm_manager(C);
 -      wmWindow *prevwin= CTX_wm_window(C);
 -      
 -      if(wm->windows.first) {
 -              CTX_wm_window_set(C, wm->windows.first);
 +      wmWindow* win;
 +
 +      ScrArea *sa;
 +      ARegion *ar;
 +
 +      Main *main = CTX_data_main(C);
 +      Scene *scene= CTX_data_scene(C);
 +
 +      if (!scene)
 +              scene= main->scene.first;
 +
 +      win = wm->windows.first;
 +
 +      //first to get a valid window
 +      if(win)
 +              CTX_wm_window_set(C, win);
 +
 +      sa = biggest_view3d(C);
 +
 +      if(sa)
 +      {
 +              for(ar=sa->regionbase.first; ar; ar=ar->next) {
 +                      if(ar->regiontype == RGN_TYPE_WINDOW) {
 +                              break;
 +                      }
 +              }
 +      }
 +
 +      // if we have a valid 3D view
 +      if (sa && ar) {
 +              ARegion *arhide;
 +
 +              CTX_wm_area_set(C, sa);
 +              CTX_wm_region_set(C, ar);
 +
 +              /* disable quad view */
 +              if(ar->alignment == RGN_ALIGN_QSPLIT)
 +                      WM_operator_name_call(C, "SCREEN_OT_region_quadview", WM_OP_EXEC_DEFAULT, NULL);
 +
 +              /* toolbox, properties panel and header are hidden */
 +              for(arhide=sa->regionbase.first; arhide; arhide=arhide->next) {
 +                      if(arhide->regiontype != RGN_TYPE_WINDOW) {
 +                              if(!(arhide->flag & RGN_FLAG_HIDDEN)) {
 +                                      ED_region_toggle_hidden(C, arhide);
 +                              }
 +                      }
 +              }
 +
 +              /* full screen the area */
 +              if(!sa->full) {
 +                      ED_screen_full_toggle(C, wm->windows.first, sa);
 +              }
 +
 +              /* Fullscreen */
 +              if(scene->gm.fullscreen) {
 +                      WM_operator_name_call(C, "WM_OT_window_fullscreen_toggle", WM_OP_EXEC_DEFAULT, NULL);
 +                      ar->winrct.ymax = win->sizey;
 +                      ar->winrct.xmax = win->sizex;
 +              }
 +
                WM_operator_name_call(C, "VIEW3D_OT_game_start", WM_OP_EXEC_DEFAULT, NULL);
 -              CTX_wm_window_set(C, prevwin);
 +
 +              return 1;
 +      }
 +      else
 +      {
 +              ReportTimerInfo *rti;
 +
 +              BKE_report(&wm->reports, RPT_ERROR, "No valid 3D View found. Game auto start is not possible.");
 +
 +              /* After adding the report to the global list, reset the report timer. */
 +              WM_event_remove_timer(wm, NULL, wm->reports.reporttimer);
 +
 +              /* Records time since last report was added */
 +              wm->reports.reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER, 0.02);
 +
 +              rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
 +              wm->reports.reporttimer->customdata = rti;
        }
 +      return 0;
  }
  
  /* free strings of open recent files */
diff --combined source/creator/creator.c
index cf1f583a74051c5c1046c55234595ececdfdb97f,283511ef3ffabfae3890fb49495845122f45eaac..77961ec4d809ad602e9f9b99ff08674ff0589683
@@@ -131,14 -131,6 +131,6 @@@ extern int pluginapi_force_ref(void);  
  char bprogname[FILE_MAXDIR+FILE_MAXFILE]; /* from blenpluginapi:pluginapi.c */
  char btempdir[FILE_MAXDIR+FILE_MAXFILE];
  
- /* unix path support.
-  * defined by the compiler. eg "/usr/share/blender/2.5" "/opt/blender/2.5" */
- #ifndef BLENDERPATH
- #define BLENDERPATH ""
- #endif
-  
- char blender_path[FILE_MAXDIR+FILE_MAXFILE] = BLENDERPATH;
  /* Initialise callbacks for the modules that need them */
  static void setCallbacks(void); 
  
@@@ -289,20 -281,22 +281,22 @@@ static int print_help(int argc, char **
        printf ("\t\t\"blender --background test.blend --render-output /tmp --render-frame 1\" works as expected.\n\n");
  
        printf ("\nEnvironment Variables:\n");
-       printf ("  $HOME\t\t\tStore files such as .blender/ .B.blend .Bfs .Blog here.\n");
-       printf ("  $BLENDERPATH  System directory to use for data files and scripts.\n");
-       printf ("                For this build of blender the default $BLENDERPATH is...\n");
-       printf ("                \"%s\"\n", blender_path);
-       printf ("                setting the $BLENDERPATH will override this\n");
+       printf ("  $BLENDER_USER_CONFIG      Directory for user configuration files.\n");
+       printf ("  $BLENDER_SYSTEM_CONFIG    Directory for system wide configuration files.\n");
+       printf ("  $BLENDER_USER_SCRIPTS     Directory for user scripts.\n");
+       printf ("  $BLENDER_SYSTEM_SCRIPTS   Directory for system wide scripts.\n");
+       printf ("  $BLENDER_USER_DATAFILES   Directory for user data files (icons, translations, ..).\n");
+       printf ("  $BLENDER_SYSTEM_DATAFILES Directory for system wide data files.\n");
+       printf ("  $BLENDER_SYSTEM_PYTHON    Directory for system python libraries.\n");
  #ifdef WIN32
-       printf ("  $TEMP         Store temporary files here.\n");
+       printf ("  $TEMP                     Store temporary files here.\n");
  #else
-       printf ("  $TMP or $TMPDIR  Store temporary files here.\n");
+       printf ("  $TMP or $TMPDIR           Store temporary files here.\n");
  #endif
  #ifndef DISABLE_SDL
-       printf ("  $SDL_AUDIODRIVER  LibSDL audio driver - alsa, esd, alsa, dma.\n");
+       printf ("  $SDL_AUDIODRIVER          LibSDL audio driver - alsa, esd, dma.\n");
  #endif
-       printf ("  $PYTHONHOME   Path to the python directory, eg. /usr/lib/python.\n\n");
+       printf ("  $PYTHONHOME               Path to the python directory, eg. /usr/lib/python.\n\n");
  
        exit(0);
  
@@@ -1038,12 -1032,6 +1032,6 @@@ int main(int argc, char **argv
  
        BLI_where_am_i(bprogname, argv[0]);
        
-       {       /* override the hard coded blender path */
-               char *blender_path_env = getenv("BLENDERPATH");
-               if(blender_path_env)
-                       BLI_strncpy(blender_path, blender_path_env, sizeof(blender_path));
-       }
  #ifdef BUILD_DATE     
      strip_quotes(build_date);
      strip_quotes(build_time);
                WM_init(C, argc, argv);
                
                /* this is properly initialized with user defs, but this is default */
-               BLI_where_is_temp( btempdir, 1 ); /* call after loading the .B.blend so we can read U.tempdir */
+               BLI_where_is_temp( btempdir, 1 ); /* call after loading the startup.blend so we can read U.tempdir */
  
  #ifndef DISABLE_SDL
        BLI_setenv("SDL_VIDEODRIVER", "dummy");
  
                WM_init(C, argc, argv);
  
-               BLI_where_is_temp( btempdir, 0 ); /* call after loading the .B.blend so we can read U.tempdir */
+               BLI_where_is_temp( btempdir, 0 ); /* call after loading the startup.blend so we can read U.tempdir */
        }
  #ifndef DISABLE_PYTHON
        /**
  
        else {
                if((G.fileflags & G_FILE_AUTOPLAY) && (G.f & G_SCRIPT_AUTOEXEC))
 -                      WM_init_game(C);
 +                      if(WM_init_game(C))
 +                              return 0;
  
                else if(!G.file_loaded)
                        WM_init_splash(C);