- as proposed by Ton, default dir for menu enabled scripts is:
userhome/.blender/scripts if available or (using bprogname -- argv[0]),
blenderInstallationDir/.blender/scripts/ otherwise.
- moved a piece of code from BPY_interface.c to BPY_menus.c to get rid
of a linkage warning reported by J. Walton
-- added the first scripts to release/scripts:

We need time to get more scripts there, but the situation should improve
consistently from now on.  Adding three export scripts: cal3d, directX, ac3d.
And one import: ac3d.
This commit is contained in:
Willian Padovani Germano
2004-01-27 03:34:16 +00:00
parent d482d34ffb
commit 33dd2f5e0d
8 changed files with 2308 additions and 13 deletions

View File

@@ -482,15 +482,7 @@ int BPY_menu_do_python(short menutype, int event)
Script *script = G.main->script.first;
int len;
if ((menutype < 0) || (menutype > PYMENU_TOTAL) || (event < 0))
return 0;
pym = BPyMenuTable[menutype];
while (event--) {
if (pym) pym = pym->next;
else break;
}
pym = BPyMenu_GetEntry(menutype, (short)event);
if (!pym) return 0;
@@ -527,7 +519,7 @@ int BPY_menu_do_python(short menutype, int event)
if (pym->dir) /* script is in U.pythondir */
BLI_make_file_string("/", filestr, U.pythondir, pym->filename);
else { /* script is in ~/.blender/scripts/ */
BLI_make_file_string("/", dirname, BLI_gethome(), ".blender/scripts");
BLI_make_file_string("/", dirname, bpymenu_gethome(), "scripts");
BLI_make_file_string("/", filestr, dirname, pym->filename);
}

View File

@@ -74,19 +74,35 @@ static int DEBUG;
BPyMenu *BPyMenuTable[PYMENU_TOTAL];
/* we can't be sure if BLI_gethome() returned a path
* with '.blender' appended or not, so: */
static char *bpymenu_gethome()
* with '.blender' appended or not. Besides, this function now
* either returns userhome/.blender (if it exists) or
* blenderInstallDir/.blender/ otherwise */
char *bpymenu_gethome()
{
static char homedir[FILE_MAXDIR];
char bprogdir[FILE_MAXDIR];
char *s;
int i;
if (homedir[0] != '\0') return homedir;
if (homedir[0] != '\0') return homedir; /* no need to search twice */
s = BLI_gethome();
if (strstr(s, ".blender")) PyOS_snprintf(homedir, FILE_MAXDIR, s);
else BLI_make_file_string ("/", homedir, s, ".blender/");
/* if userhome/.blender/ exists, return it */
if (BLI_exists(homedir)) return homedir;
/* otherwise, use argv[0] (bprogname) to get .blender/ in
* Blender's installation dir */
s = BLI_last_slash(bprogname);
i = s - bprogname + 1;
PyOS_snprintf(bprogdir, i, bprogname);
BLI_make_file_string ("/", homedir, bprogdir, ".blender/");
return homedir;
}
@@ -195,6 +211,26 @@ static BPyMenu *bpymenu_FindEntry (short group, char *name)
return NULL;
}
/* BPyMenu_GetEntry:
* given a group and a position, return the entry in that position from
* that group.
*/
BPyMenu *BPyMenu_GetEntry (short group, short pos)
{
BPyMenu *pym = NULL;
if ((group < 0) || (group >= PYMENU_TOTAL)) return NULL;
pym = BPyMenuTable[group];
while (pos--) {
if (pym) pym = pym->next;
else break;
}
return pym; /* found entry or NULL */
}
static void bpymenu_set_tooltip (BPyMenu *pymenu, char *tip)
{
if (!pymenu) return;

View File

@@ -96,5 +96,7 @@ void BPyMenu_RemoveAllEntries(void);
void BPyMenu_PrintAllEntries(void);
char *BPyMenu_CreatePupmenuStr(BPyMenu *pym, short group);
char *BPyMenu_group_itoa (short group);
char *bpymenu_gethome();
struct BPyMenu *BPyMenu_GetEntry (short group, short pos);
#endif /* BPY_MENUS_H */