Adjust subsong title description and show for TXTP subsongs

This commit is contained in:
bnnm 2019-02-10 02:54:16 +01:00
parent 802997b255
commit 46290fe16f
2 changed files with 42 additions and 25 deletions

View File

@ -141,9 +141,9 @@ void input_vgmstream::get_info(t_uint32 p_subsong, file_info & p_info, abort_cal
/* set tag info (metadata tab in file properties) */ /* set tag info (metadata tab in file properties) */
/* Shows a custom subsong title by default with subsong name, to simplify for average users. /* Shows a custom subsong title by default with subsong name, to simplify for average users.
* This can be overriden and extended and using the exported STREAM_x below and foobar's formatting. * This can be overriden and extended using the exported STREAM_x below and foobar's formatting.
* foobar defaults to filename minus extension if there is no meta "title" value. */ * foobar defaults to filename minus extension if there is no meta "title" value. */
if (!override_title && get_subsong_count() > 1) { if (!override_title) {
p_info.meta_set("TITLE",temp); p_info.meta_set("TITLE",temp);
} }
if (get_description_tag(temp,description,"stream count: ")) p_info.meta_set("stream_count",temp); if (get_description_tag(temp,description,"stream count: ")) p_info.meta_set("stream_count",temp);
@ -478,26 +478,32 @@ void input_vgmstream::get_subsong_info(t_uint32 p_subsong, pfc::string_base & ti
} }
} }
if (title) {
/* infostream gets added with index 0 (other) or 1 (current) */
if (infostream && title) {
const char *p = filename + strlen(filename); const char *p = filename + strlen(filename);
while (*p != '\\' && p >= filename) p--; while (*p != '\\' && p >= filename) p--;
p++; p++;
const char *e = filename + strlen(filename); const char *e = filename + strlen(filename);
while (*e != '.' && e >= filename) e--; while (*e != '.' && e >= filename) e--;
title.set_string(p, e - p); /* name without ext */
title.set_string(p, e - p); const char* info_name = infostream->stream_name;
int info_streams = infostream->num_streams;
int info_subsong = infostream->stream_index;
if (info_subsong == 0)
info_subsong = 1;
if (!disable_subsongs && infostream && infostream->num_streams > 1) { /* show number if file has more than 1 subsong */
int info_subsong = infostream->stream_index; if (info_streams > 1) {
if (info_subsong==0)
info_subsong = 1;
sprintf(temp,"#%d",info_subsong); sprintf(temp,"#%d",info_subsong);
title += temp; title += temp;
}
if (infostream->stream_name[0] != '\0') { /* show name if file has subsongs (implicitly shows also for TXTP) */
sprintf(temp," (%s)",infostream->stream_name); if (info_name[0] != '\0' && info_streams > 0) {
title += temp; sprintf(temp," (%s)",info_name);
} title += temp;
} }
} }

View File

@ -853,10 +853,10 @@ static void get_title(in_char * dst, int dst_size, const in_char * fn, VGMSTREAM
in_char *basename; in_char *basename;
in_char buffer[PATH_LIMIT]; in_char buffer[PATH_LIMIT];
in_char filename[PATH_LIMIT]; in_char filename[PATH_LIMIT];
int stream_index = 0; //int stream_index = 0;
parse_fn_string(fn, NULL, filename,PATH_LIMIT); parse_fn_string(fn, NULL, filename,PATH_LIMIT);
parse_fn_int(fn, wa_L("$s"), &stream_index); //parse_fn_int(fn, wa_L("$s"), &stream_index);
basename = (in_char*)filename + wa_strlen(filename); /* find end */ basename = (in_char*)filename + wa_strlen(filename); /* find end */
while (*basename != '\\' && basename >= filename) /* and find last "\" */ while (*basename != '\\' && basename >= filename) /* and find last "\" */
@ -864,18 +864,29 @@ static void get_title(in_char * dst, int dst_size, const in_char * fn, VGMSTREAM
basename++; basename++;
wa_strcpy(dst,basename); wa_strcpy(dst,basename);
/* show stream subsong number */ /* infostream gets added at first with index 0, then once played it re-adds proper numbers */
if (stream_index > 0) { if (infostream) {
wa_snprintf(buffer,PATH_LIMIT, wa_L("#%i"), stream_index); const char* info_name = infostream->stream_name;
wa_strcat(dst,buffer); int info_streams = infostream->num_streams;
} int info_subsong = infostream->stream_index;
int is_first = infostream->stream_index == 0;
/* show name, but not for the base stream */ /* show number if file has more than 1 subsong */
if (infostream && infostream->stream_name[0] != '\0' && stream_index > 0) { if (info_streams > 1) {
in_char stream_name[PATH_LIMIT]; if (is_first)
wa_char_to_ichar(stream_name, PATH_LIMIT, infostream->stream_name); wa_snprintf(buffer,PATH_LIMIT, wa_L("#1~%i"), info_streams);
wa_snprintf(buffer,PATH_LIMIT, wa_L(" (%s)"), stream_name); else
wa_strcat(dst,buffer); wa_snprintf(buffer,PATH_LIMIT, wa_L("#%i"), info_subsong);
wa_strcat(dst,buffer);
}
/* show name if file has subsongs (implicitly shows also for TXTP) */
if (info_name[0] != '\0' && ((info_streams > 0 && !is_first) || info_streams == 1)) {
in_char stream_name[PATH_LIMIT];
wa_char_to_ichar(stream_name, PATH_LIMIT, info_name);
wa_snprintf(buffer,PATH_LIMIT, wa_L(" (%s)"), stream_name);
wa_strcat(dst,buffer);
}
} }
} }