If a non-SVG starter or template with the same name as an SVG one
existed, it would be loaded instead of the SVG (despite a thumbnail of the SVG appearing in the file selector). SF.net Bug #191
This commit is contained in:
parent
b1c910dd9a
commit
5b1ba9d0a0
2 changed files with 248 additions and 222 deletions
|
|
@ -545,6 +545,11 @@ $Id$
|
|||
would fail to load.
|
||||
SF.net Bug #191
|
||||
|
||||
* If a non-SVG starter or template with the same name as an SVG one
|
||||
existed, it would be loaded instead of the SVG (despite a thumbnail
|
||||
of the SVG appearing in the file selector).
|
||||
SF.net Bug #191
|
||||
|
||||
* Image on right of dialogs would get scaled/cut-off even if there was
|
||||
room for them.
|
||||
|
||||
|
|
|
|||
121
src/tuxpaint.c
121
src/tuxpaint.c
|
|
@ -11133,8 +11133,7 @@ static void load_starter(char *img_id)
|
|||
img_starter_bkgd = NULL;
|
||||
|
||||
/* Load the core image: */
|
||||
snprintf(fname, sizeof(fname), "%s/%s", dirname, img_id);
|
||||
tmp_surf = load_starter_helper(fname, "png", &IMG_Load);
|
||||
tmp_surf = NULL;
|
||||
|
||||
#ifndef NOSVG
|
||||
if (tmp_surf == NULL)
|
||||
|
|
@ -11146,6 +11145,12 @@ static void load_starter(char *img_id)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%s/%s", dirname, img_id);
|
||||
tmp_surf = load_starter_helper(fname, "png", &IMG_Load);
|
||||
}
|
||||
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
/* Try loading a KPX */
|
||||
|
|
@ -11162,9 +11167,24 @@ static void load_starter(char *img_id)
|
|||
|
||||
/* Try to load the a background image: */
|
||||
|
||||
/* (JPEG first) */
|
||||
tmp_surf = NULL;
|
||||
|
||||
#ifndef NOSVG
|
||||
/* (Try SVG) */
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%s/%s-back", dirname, img_id);
|
||||
tmp_surf = load_starter_helper(fname, "svg", &load_svg);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* (JPEG) */
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%s/%s-back.jpeg", dirname, img_id);
|
||||
tmp_surf = load_starter_helper(fname, "jpeg", &IMG_Load);
|
||||
}
|
||||
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
/* (Then just JPG) */
|
||||
|
|
@ -11179,15 +11199,6 @@ static void load_starter(char *img_id)
|
|||
tmp_surf = load_starter_helper(fname, "png", &IMG_Load);
|
||||
}
|
||||
|
||||
#ifndef NOSVG
|
||||
/* (Failed? Try SVG next) */
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%s/%s-back", dirname, img_id);
|
||||
tmp_surf = load_starter_helper(fname, "svg", &load_svg);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (tmp_surf != NULL)
|
||||
{
|
||||
img_starter_bkgd = SDL_DisplayFormat(tmp_surf);
|
||||
|
|
@ -11311,6 +11322,15 @@ static void load_template(char *img_id)
|
|||
snprintf(fname, sizeof(fname), "%s/%s", dirname, img_id);
|
||||
tmp_surf = load_starter_helper(fname, "kpx", &myIMG_Load);
|
||||
|
||||
#ifndef NOSVG
|
||||
/* (Failed? Try SVG next) */
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%s/%s", dirname, img_id);
|
||||
tmp_surf = load_starter_helper(fname, "svg", &load_svg);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* (JPEG) */
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
|
|
@ -11331,15 +11351,6 @@ static void load_template(char *img_id)
|
|||
tmp_surf = load_starter_helper(fname, "png", &IMG_Load);
|
||||
}
|
||||
|
||||
#ifndef NOSVG
|
||||
/* (Failed? Try SVG next) */
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%s/%s", dirname, img_id);
|
||||
tmp_surf = load_starter_helper(fname, "svg", &load_svg);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (tmp_surf != NULL)
|
||||
{
|
||||
img_starter_bkgd = SDL_DisplayFormat(tmp_surf);
|
||||
|
|
@ -11410,7 +11421,6 @@ static void load_current(void)
|
|||
|
||||
if (file_id[0] != '\0')
|
||||
{
|
||||
|
||||
start_label_node=NULL;
|
||||
current_label_node=NULL;
|
||||
first_label_node_in_redo_stack=NULL;
|
||||
|
|
@ -17605,15 +17615,16 @@ static SDL_Surface * myIMG_Load_RWops(char * file)
|
|||
otherwise call SDL_Image lib's IMG_Load() (for PNGs, JPEGs, BMPs, etc.) */
|
||||
static SDL_Surface * myIMG_Load(char * file)
|
||||
{
|
||||
if (strlen(file) > 4 && strcasecmp(file + strlen(file) - 4, ".kpx") == 0)
|
||||
if (strlen(file) > 4 && strcasecmp(file + strlen(file) - 4, ".kpx") == 0) {
|
||||
return(load_kpx(file));
|
||||
#ifndef NOSVG
|
||||
else if (strlen(file) > 4 && strcasecmp(file + strlen(file) - 4, ".svg") == 0)
|
||||
} else if (strlen(file) > 4 && strcasecmp(file + strlen(file) - 4, ".svg") == 0) {
|
||||
return(load_svg(file));
|
||||
#endif
|
||||
else
|
||||
} else {
|
||||
return(myIMG_Load_RWops(file));
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_Surface * load_kpx(char * file)
|
||||
{
|
||||
|
|
@ -18288,6 +18299,7 @@ static int do_new_dialog(void)
|
|||
int white_in_palette;
|
||||
int val_x, val_y, motioner;
|
||||
int valhat_x, valhat_y, hatmotioner;
|
||||
int skip, k;
|
||||
|
||||
|
||||
val_x = val_y = motioner = 0;
|
||||
|
|
@ -18500,26 +18512,12 @@ static int do_new_dialog(void)
|
|||
)
|
||||
{
|
||||
strcpy(fname, f->d_name);
|
||||
skip = 0;
|
||||
|
||||
if (strcasestr(fname, FNAME_EXTENSION) != NULL)
|
||||
{
|
||||
d_exts[num_files] = strdup(strcasestr(fname, FNAME_EXTENSION));
|
||||
strcpy((char *) strcasestr(fname, FNAME_EXTENSION), "");
|
||||
|
||||
#ifndef NOSVG
|
||||
/* Found a PNG; but if identically-named SVG exists, skip it */
|
||||
if (1)
|
||||
{
|
||||
char svgname[512];
|
||||
FILE * fi;
|
||||
|
||||
sprintf(svgname, "%s/%s.svg", dirname[place], fname);
|
||||
fi = fopen(svgname, "r");
|
||||
if (fi != NULL) {
|
||||
fclose(fi);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (strcasestr(fname, ".bmp") != NULL)
|
||||
|
|
@ -18548,6 +18546,27 @@ static int do_new_dialog(void)
|
|||
strcpy((char *) strcasestr(fname, ".jpg"), "");
|
||||
}
|
||||
|
||||
#ifndef NOSVG
|
||||
/* If identically-named SVG exists, skip this version */
|
||||
for (k = 0; k < num_files_in_dirs; k++) {
|
||||
if (k != j) {
|
||||
struct dirent *f2;
|
||||
char fname2[1024];
|
||||
|
||||
f2 = &(fs[k].f);
|
||||
strcpy(fname2, f2->d_name);
|
||||
|
||||
if (strstr(fname2, fname) == fname2 &&
|
||||
strcasestr(fname2, ".svg") != NULL) {
|
||||
/* SVG of this bitmap exists; we'll skip it */
|
||||
skip = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (skip) {
|
||||
free(d_exts[num_files]);
|
||||
} else {
|
||||
d_names[num_files] = strdup(fname);
|
||||
d_places[num_files] = place;
|
||||
|
||||
|
|
@ -18634,15 +18653,6 @@ static int do_new_dialog(void)
|
|||
img = load_starter_helper(fname, "jpg", &IMG_Load);
|
||||
}
|
||||
|
||||
|
||||
if (img == NULL)
|
||||
{
|
||||
/* (Try PNG next) */
|
||||
snprintf(fname, sizeof(fname), "%s/%s-back",
|
||||
dirname[d_places[num_files]], d_names[num_files]);
|
||||
img = load_starter_helper(fname, "png", &IMG_Load);
|
||||
}
|
||||
|
||||
#ifndef NOSVG
|
||||
if (img == NULL)
|
||||
{
|
||||
|
|
@ -18652,6 +18662,14 @@ static int do_new_dialog(void)
|
|||
img = load_starter_helper(fname, "svg", &load_svg);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (img == NULL)
|
||||
{
|
||||
/* (Try PNG next) */
|
||||
snprintf(fname, sizeof(fname), "%s/%s-back",
|
||||
dirname[d_places[num_files]], d_names[num_files]);
|
||||
img = load_starter_helper(fname, "png", &IMG_Load);
|
||||
}
|
||||
}
|
||||
|
||||
if (img == NULL)
|
||||
|
|
@ -18747,6 +18765,7 @@ static int do_new_dialog(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* It was a thumbnail file ("...-t.png") or immutable scene starter's
|
||||
|
|
@ -19226,6 +19245,8 @@ static int do_new_dialog(void)
|
|||
snprintf(fname, sizeof(fname), "%s/%s%s",
|
||||
dirname[d_places[which]], d_names[which], d_exts[which]);
|
||||
|
||||
printf("LOADING %s\n", fname);
|
||||
|
||||
img = myIMG_Load(fname);
|
||||
|
||||
if (img == NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue