mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-01 08:25:12 +01:00
Shortens all display names of ROMs by removing rubbish from file names.
Menu works properly in PAL now, before there was a mismatch between the Ortho projection matrix and the screen height, causing the bottom of the menu to be off the screen.
This commit is contained in:
parent
1eae7aeb57
commit
0fcc7edce5
@ -323,6 +323,77 @@ void StripExt(char* returnstring, char * inputstring)
|
||||
*loc_dot = 0; // strip file extension
|
||||
}
|
||||
|
||||
// Shorten a ROM filename by removing the extension, URLs, id numbers and other rubbish
|
||||
void ShortenFilename(char * returnstring, char * inputstring)
|
||||
{
|
||||
if (!inputstring) {
|
||||
returnstring[0] = '\0';
|
||||
return;
|
||||
}
|
||||
// skip URLs in brackets
|
||||
char * dotcom = (char *) strstr(inputstring, ".com)");
|
||||
char * url = NULL;
|
||||
if (dotcom) {
|
||||
url = (char *) strchr(inputstring, '(');
|
||||
if (url >= dotcom) {
|
||||
url = NULL;
|
||||
dotcom = NULL;
|
||||
} else dotcom+= 5; // point to after ')'
|
||||
}
|
||||
// skip URLs not in brackets
|
||||
if (!dotcom) {
|
||||
dotcom = (char *) strstr(inputstring, ".com");
|
||||
url = NULL;
|
||||
if (dotcom) {
|
||||
url = (char *) strstr(inputstring, "www");
|
||||
if (url >= dotcom) {
|
||||
url = NULL;
|
||||
dotcom = NULL;
|
||||
} else dotcom+= 4; // point to after ')'
|
||||
}
|
||||
}
|
||||
// skip file extension
|
||||
char * loc_dot = (char *)strrchr(inputstring,'.');
|
||||
char * s = (char *)inputstring;
|
||||
char * r = (char *)returnstring;
|
||||
// skip initial whitespace, numbers, - and _ ...
|
||||
while ((*s!='\0' && *s<=' ') || *s=='-' || *s=='_' || *s=='+') s++;
|
||||
// ... except those that SHOULD begin with numbers
|
||||
if (strncmp(s,"3D",2)==0) for (int i=0; i<2; i++, r++, s++) *r=*s;
|
||||
if (strncmp(s,"1st",3)==0 || strncmp(s,"2nd",3)==0 || strncmp(s,"3rd",3)==0 || strncmp(s,"4th",3)==0) for (int i=0; i<3; i++, r++, s++) *r=*s;
|
||||
if (strncmp(s,"199",3)==0 || strncmp(s,"007",3)==0 || strncmp(s,"4x4",3)==0 || strncmp(s,"720",3)==0 || strncmp(s,"10 ",3)==0) for (int i=0; i<3; i++, r++, s++) *r=*s;
|
||||
if (strncmp(s,"102 ",4)==0 || strncmp(s,"1942",4)==0 || strncmp(s,"3 Ch",4)==0) for (int i=0; i<4; i++, r++, s++) *r=*s;
|
||||
if (strncmp(s,"2 in 1",6)==0 || strncmp(s,"3 in 1",6)==0 || strncmp(s,"4 in 1",6)==0) for (int i=0; i<6; i++, r++, s++) *r=*s;
|
||||
if (strncmp(s,"2-in-1",6)==0 || strncmp(s,"3-in-1",6)==0 || strncmp(s,"4-in-1",6)==0) for (int i=0; i<6; i++, r++, s++) *r=*s;
|
||||
while (*s>='0' && *s<='9') s++;
|
||||
if (r==(char *)returnstring) while ((*s!='\0' && *s<=' ') || *s=='-' || *s=='_' || *s=='+') s++;
|
||||
// now go through rest of string until we get to the end or the extension
|
||||
while (*s!='\0' && (loc_dot==NULL || s<loc_dot)) {
|
||||
// skip url
|
||||
if (s==url) s=dotcom;
|
||||
// skip whitespace, numbers, - and _ after url
|
||||
if (s==dotcom) {
|
||||
while ((*s>'\0' && *s<=' ') || *s=='-' || *s=='_') s++;
|
||||
while (*s>='0' && *s<='9') s++;
|
||||
while ((*s>'\0' && *s<=' ') || *s=='-' || *s=='_') s++;
|
||||
}
|
||||
// skip all but 1 '-', '_' or space in a row
|
||||
char c = s[0];
|
||||
if (c==s[1] && (c=='-' || c=='_' || c==' ')) s++;
|
||||
// skip space before hyphen
|
||||
if (*s==' ' && s[1]=='-') s++;
|
||||
// copy character to result
|
||||
if (*s=='_') *r=' ';
|
||||
else *r = *s;
|
||||
// skip spaces after hyphen
|
||||
if (*s=='-') while (s[1]==' ') s++;
|
||||
s++; r++;
|
||||
}
|
||||
*r = '\0';
|
||||
// if the result is too short, abandon what we did and just strip the ext instead
|
||||
if (strlen(returnstring) <= 4) StripExt(returnstring, inputstring);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* BrowserLoadSz
|
||||
*
|
||||
|
@ -50,6 +50,7 @@ int autoLoadMethod();
|
||||
int autoSaveMethod(bool silent);
|
||||
int FileSortCallback(const void *f1, const void *f2);
|
||||
void StripExt(char* returnstring, char * inputstring);
|
||||
void ShortenFilename(char* returnstring, char * inputstring);
|
||||
bool IsSz();
|
||||
void ResetBrowser();
|
||||
int BrowserLoadSz(int method);
|
||||
|
@ -344,7 +344,7 @@ ParseDirectory(int method)
|
||||
}
|
||||
else
|
||||
{
|
||||
StripExt(tmpname, filename); // hide file extension
|
||||
ShortenFilename(tmpname, filename); // hide file extension
|
||||
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
|
||||
}
|
||||
|
||||
|
@ -482,7 +482,9 @@ int SzParse(char * filepath, int method)
|
||||
|
||||
// parse information about this file to the dvd file list structure
|
||||
strncpy(browserList[SzJ].filename, SzF->Name, MAXJOLIET); // copy joliet name (useless...)
|
||||
strncpy(browserList[SzJ].displayname, SzF->Name, MAXDISPLAY); // crop name for display
|
||||
char tmpname[MAXJOLIET+1] = "";
|
||||
ShortenFilename(tmpname, browserList[SzJ].filename);
|
||||
strncpy(browserList[SzJ].displayname, tmpname, MAXDISPLAY); // crop name for display
|
||||
browserList[SzJ].length = SzF->Size; // filesize
|
||||
browserList[SzJ].offset = SzI; // the extraction function identifies the file with this number
|
||||
browserList[SzJ].isdir = 0; // only files will be displayed (-> no flags)
|
||||
|
@ -124,7 +124,7 @@ ParseMCDirectory (int slot)
|
||||
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
|
||||
strncpy(browserList[entryNum].filename, (char *)CardDir.filename, MAXJOLIET);
|
||||
StripExt(tmpname, (char *)CardDir.filename); // hide file extension
|
||||
ShortenFilename(tmpname, (char *)CardDir.filename); // hide file extension
|
||||
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
|
||||
browserList[entryNum].length = CardDir.filelen;
|
||||
|
||||
|
@ -392,7 +392,7 @@ InitializeVideo ()
|
||||
|
||||
VIDEO_Configure (vmode);
|
||||
|
||||
screenheight = vmode->xfbHeight;
|
||||
screenheight = 480; //vmode->xfbHeight;
|
||||
screenwidth = vmode->fbWidth;
|
||||
|
||||
// Allocate the video buffers
|
||||
|
Loading…
Reference in New Issue
Block a user