- fixed 'double-click on blend file' errors on Windows -- INTERNATIONAL stuff now...
authorSimon Clitherow <aphex@nildram.co.uk>
Thu, 22 May 2003 18:06:25 +0000 (18:06 +0000)
committerSimon Clitherow <aphex@nildram.co.uk>
Thu, 22 May 2003 18:06:25 +0000 (18:06 +0000)
- registering .blend files for WinNT/2000/XP now works correctly (settings remain after a reboot).

projectfiles/blender/blenlib/BLI_blenlib.dsp
source/blender/blenlib/BLI_blenlib.h
source/blender/blenlib/intern/Makefile
source/blender/blenlib/intern/winstuff.c
source/blender/ftfont/intern/FTF_TTFont.cpp
source/blender/src/language.c

index 7e33db8..12564e4 100644 (file)
@@ -44,8 +44,7 @@ RSC=rc.exe
 # PROP Target_Dir ""
 LINK32=link.exe -lib
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\lib\windows\guardedalloc\include" /I "..\..\..\..\lib\windows\freetype\include" /I "..\..\..\source\blender\include" /I "..\..\..\source\blender\blenlib" /I "..\..\..\source\blender\bpython\include" /I "..\..\..\source\blender\makesdna" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "WITH_FREETYPE2" /J /FD /c
-# SUBTRACT CPP /YX
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\lib\windows\guardedalloc\include" /I "..\..\..\..\lib\windows\freetype\include" /I "..\..\..\source\blender\include" /I "..\..\..\source\blender\blenlib" /I "..\..\..\source\blender\blenkernel" /I "..\..\..\source\blender\bpython\include" /I "..\..\..\source\blender\makesdna" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "WITH_FREETYPE2" /J /FD /c
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
 BSC32=bscmake.exe
@@ -69,8 +68,7 @@ LIB32=link.exe -lib
 # PROP Target_Dir ""
 LINK32=link.exe -lib
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\lib\windows\guardedalloc\include" /I "..\..\..\source\blender\blenlib" /I "..\..\..\source\blender\bpython\include" /I "..\..\..\source\blender\makesdna" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /J /FD /GZ /c
-# SUBTRACT CPP /Fr /YX
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\lib\windows\guardedalloc\include" /I "..\..\..\source\blender\blenlib" /I "..\..\..\source\blender\blenkernel" /I "..\..\..\source\blender\bpython\include" /I "..\..\..\source\blender\makesdna" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /J /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
index 8d07c76..e56b449 100644 (file)
@@ -211,6 +211,10 @@ void BLI_where_am_i(char *fullname, char *name);
 #ifdef __APPLE__
 char* BLI_getbundle(void);
 #endif
+
+#ifdef WIN32
+int BLI_getInstallationDir( char * str );
+#endif
                
 /* BLI_storage.h */
 int    BLI_filesize(int file);
index 9067b98..7ce3441 100644 (file)
@@ -51,6 +51,8 @@ CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
 # path to freetype font stuff
 CPPFLAGS += -I$(NAN_FREETYPE)/include
 CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2
+# path to blenkernel
+CPPFLAGS += -I$(SRCHOME)/blender/blenkernel
 CPPFLAGS += -I../../include/
 
 ifdef WITH_FREETYPE2
index a0fb005..2a69bf0 100644 (file)
 #include "BLI_util.h"
 #include "BLI_winstuff.h"
 
+#include "BKE_utildefines.h" /* FILE_MAXDIR + FILE_MAXFILE */
+
+int BLI_getInstallationDir( char * str ) {
+       LONG lresult;
+       HKEY hkey = 0;
+       LONG type;
+       char buffer[FILE_MAXDIR+FILE_MAXFILE];
+       DWORD size;
+       
+       size = sizeof(buffer);
+
+       lresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\BlenderFoundation", 0, 
+               KEY_ALL_ACCESS, &hkey);
+
+       if (lresult == ERROR_SUCCESS) {
+               lresult = RegQueryValueEx(hkey, "Install_Dir", 0, NULL, (LPBYTE)buffer, &size);
+               strcpy(str, buffer);
+               RegCloseKey(hkey);
+               return 1;
+       }
+       else
+               return 0;
+}
+
 
 void RegisterBlendExtension(char * str) {
        LONG lresult;
        HKEY hkey = 0;
        DWORD dwd = 0;
+       char *dir;
        char buffer[128];
+       
+       /* Add installation dir to registry --aphex */
+
+       strncpy(dir, str, strlen(str)-11);
+
+       lresult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\BlenderFoundation", 0, 
+               "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+
+       if (lresult == ERROR_SUCCESS) {
+               if (dwd != REG_OPENED_EXISTING_KEY)
+                       lresult = RegSetValueEx(hkey, "Install_Dir", 0, REG_SZ, dir, strlen(dir)+1);
+               RegCloseKey(hkey);
+       }
 
        lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\shell\\open\\command", 0,
-               "", REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+               "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
 
        if (lresult == ERROR_SUCCESS) {
                sprintf(buffer, "\"%s\" \"%%1\"", str);
@@ -63,7 +101,7 @@ void RegisterBlendExtension(char * str) {
        }
 
        lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\DefaultIcon", 0,
-               "", REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+               "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
 
        if (lresult == ERROR_SUCCESS) {
                sprintf(buffer, "\"%s\",1", str);
@@ -72,7 +110,7 @@ void RegisterBlendExtension(char * str) {
        }
 
        lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".blend", 0,
-               "", REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+               "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
 
        if (lresult == ERROR_SUCCESS) {
                sprintf(buffer, "%s", "blendfile");
index 50839c4..6f50c2e 100644 (file)
@@ -43,8 +43,6 @@
 #include "BKE_utildefines.h"
 #endif
 
-#include "BLI_blenlib.h"
-
 #define DOMAIN_NAME "blender"
 
 #define SYSTEM_ENCODING_DEFAULT "UTF-8"
@@ -117,6 +115,13 @@ FTF_TTFont::FTF_TTFont(void)
                BLI_make_file_string("/", messagepath, BLI_gethome(), ".blender/locale");
                
                if(BLI_exist(messagepath) == NULL) {    // locale not in home dir
+
+#ifdef WIN32 
+                       /* message catalogs are stored in the installation dir */
+                       BLI_getInstallationDir(messagepath);
+                       strcat(messagepath, "/.blender/locale");
+                       if(BLI_exist(messagepath) == NULL) {
+#endif
 #ifdef __APPLE__
                        /* message catalogs are stored inside the application bundle */
                        bundlepath = BLI_getbundle();
@@ -129,6 +134,9 @@ FTF_TTFont::FTF_TTFont(void)
                                if(BLI_exist(messagepath) == NULL) {    // locale not in LOCALEDIR
                                        strcpy(messagepath, "message");         // old compatibility as last
                                }
+#ifdef WIN32
+                       }
+#endif
 #ifdef __APPLE__
                        }
 #endif
index 416b87f..7597317 100644 (file)
@@ -41,6 +41,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_linklist.h"      /* linknode */
+#include "BLI_winstuff.h"
 
 #include "BIF_language.h"
 #include "BIF_space.h"         /* allqueue() */
@@ -174,13 +175,19 @@ void start_interface_font(void) {
                U.fontsize= 11;
                U.encoding= 0;
 
-#ifdef __APPLE__
+#if defined (__APPLE__)
                bundlepath = BLI_getbundle();
                strcpy(tstr, bundlepath);
                strcat(tstr, "/Contents/Resources/");
                strcat(tstr, ".bfont.ttf");
                result = FTF_SetFont(tstr, U.fontsize);
 
+               sprintf(U.fontname, ".blender/.bfont.ttf\0");
+#elif defined (WIN32)
+               BLI_getInstallationDir(tstr);
+               strcat(tstr, "/.blender/.bfont.ttf\0");
+               result = FTF_SetFont(tstr, U.fontsize);
+
                sprintf(U.fontname, ".blender/.bfont.ttf\0");
 #else
                sprintf(U.fontname, ".blender/.bfont.ttf\0");
@@ -273,10 +280,14 @@ int read_languagefile(void) {
        if(lines == NULL) {
                /* If not found in home, try current dir 
                 * (Resources folder of app bundle on OS X) */
-#ifdef __APPLE__
+#if defined (__APPLE__)
                char *bundlePath = BLI_getbundle();
                strcpy(name, bundlePath);
                strcat(name, "/Contents/Resources/.Blanguages");
+#elif defined (WIN32)
+               /* Check the installation dir in Windows */
+               BLI_getInstallationDir(name);
+               strcat(name,"/.blender/.Blanguages");
 #else
                strcpy(name, ".blender/.Blanguages");
 #endif
@@ -287,8 +298,8 @@ int read_languagefile(void) {
                        strcpy(name, ".Blanguages");
                        lines= BLI_read_file_as_lines(name);
                        if(lines == NULL) {
-                               error("File \".Blanguages\" not found");
-                               return 0;
+                                       error("File \".Blanguages\" not found");
+                                       return 0;
                        }
                }
        }