mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-04 18:45:05 +01:00
Make cover and banner URLs editable
This commit is contained in:
parent
de391c7d25
commit
80ed6d0b98
@ -32,24 +32,9 @@
|
||||
|
||||
#define VALID_IMAGE(x) (!(x->size == 36864 || x->size <= 1024 || x->size == 7386 || x->size <= 1174 || x->size == 4446 || x->data == NULL))
|
||||
|
||||
static const char *serverURL3D = "https://art.gametdb.com/wii/cover3D/";
|
||||
static const char *serverURL2D = "https://art.gametdb.com/wii/cover/";
|
||||
static const char *serverURLFullHQ = "https://art.gametdb.com/wii/coverfullHQ/";
|
||||
static const char *serverURLFull = "https://art.gametdb.com/wii/coverfull/";
|
||||
static const char *serverURLOrigDiscs = "https://art.gametdb.com/wii/disc/";
|
||||
static const char *serverURLCustomDiscs = "https://art.gametdb.com/wii/disccustom/";
|
||||
static const char *serverURLCustomBannersGC = "https://banner.rc24.xyz/";
|
||||
|
||||
void ImageDownloader::DownloadImages()
|
||||
{
|
||||
bool ValidBannerURL = false;
|
||||
if(strncasecmp(serverURLCustomBannersGC, "https://", strlen("https://")) == 0)
|
||||
{
|
||||
char *path = strchr(serverURLCustomBannersGC + strlen("https://"), '/');
|
||||
if(path)
|
||||
ValidBannerURL = true;
|
||||
}
|
||||
bool showBanner = (ValidBannerURL && Settings.LoaderMode & MODE_GCGAMES);
|
||||
bool showBanner = (Settings.LoaderMode & MODE_GCGAMES);
|
||||
|
||||
int choice = CheckboxWindow(tr( "Cover Download" ), 0, tr( "3D Covers" ), tr( "Flat Covers" ), tr("Full Covers"), tr( "Discarts" ), showBanner ? tr( "Custom Banners" ) : 0, 0, showBanner ? 0x1F : 0xF); // ask for download choice
|
||||
if (choice == 0 || choice == CheckedNone)
|
||||
@ -105,32 +90,32 @@ void ImageDownloader::Start()
|
||||
void ImageDownloader::FindMissingImages()
|
||||
{
|
||||
if(choices & CheckedBox1)
|
||||
FindMissing(Settings.covers_path, serverURL3D, NULL, tr("Downloading 3D Covers"), NULL, ".png");
|
||||
FindMissing(Settings.covers_path, Settings.URL_Covers3D, NULL, tr("Downloading 3D Covers"), NULL, ".png");
|
||||
|
||||
if(choices & CheckedBox2)
|
||||
FindMissing(Settings.covers2d_path, serverURL2D, NULL, tr("Downloading Flat Covers"), NULL, ".png");
|
||||
FindMissing(Settings.covers2d_path, Settings.URL_Covers2D, NULL, tr("Downloading Flat Covers"), NULL, ".png");
|
||||
|
||||
if(choices & CheckedBox3)
|
||||
{
|
||||
const char * downloadURL = (Settings.coversfull == COVERSFULL_HQ || Settings.coversfull == COVERSFULL_HQ_LQ ) ? serverURLFullHQ : serverURLFull;
|
||||
const char * downloadURL = (Settings.coversfull == COVERSFULL_HQ || Settings.coversfull == COVERSFULL_HQ_LQ ) ? Settings.URL_CoversFullHQ : Settings.URL_CoversFull;
|
||||
const char * progressTitle = (Settings.coversfull == COVERSFULL_HQ || Settings.coversfull == COVERSFULL_HQ_LQ ) ? tr("Downloading Full HQ Covers") : tr("Downloading Full LQ Covers");
|
||||
const char * backupURL = (Settings.coversfull == COVERSFULL_HQ_LQ || Settings.coversfull == COVERSFULL_LQ_HQ) ? ((Settings.coversfull == COVERSFULL_HQ_LQ) ? serverURLFull : serverURLFullHQ) : NULL;
|
||||
const char * backupURL = (Settings.coversfull == COVERSFULL_HQ_LQ || Settings.coversfull == COVERSFULL_LQ_HQ) ? ((Settings.coversfull == COVERSFULL_HQ_LQ) ? Settings.URL_CoversFull : Settings.URL_CoversFullHQ) : NULL;
|
||||
const char * backupProgressTitle = (Settings.coversfull == COVERSFULL_HQ_LQ || Settings.coversfull == COVERSFULL_LQ_HQ) ? ((Settings.coversfull == COVERSFULL_HQ_LQ) ? tr("Downloading Full LQ Covers") : tr("Downloading Full HQ Covers")) : NULL;
|
||||
FindMissing(Settings.coversFull_path, downloadURL, backupURL, progressTitle, backupProgressTitle, ".png");
|
||||
}
|
||||
|
||||
if(choices & CheckedBox4)
|
||||
{
|
||||
const char * downloadURL = (Settings.discart == DISCARTS_ORIGINALS || Settings.discart == DISCARTS_ORIGINALS_CUSTOMS ) ? serverURLOrigDiscs : serverURLCustomDiscs;
|
||||
const char * downloadURL = (Settings.discart == DISCARTS_ORIGINALS || Settings.discart == DISCARTS_ORIGINALS_CUSTOMS ) ? Settings.URL_Discs : Settings.URL_DiscsCustom;
|
||||
const char * progressTitle = (Settings.discart == DISCARTS_ORIGINALS || Settings.discart == DISCARTS_ORIGINALS_CUSTOMS ) ? tr("Downloading original Discarts") : tr("Downloading custom Discarts");
|
||||
const char * backupURL = (Settings.discart == DISCARTS_ORIGINALS_CUSTOMS || Settings.discart == DISCARTS_CUSTOMS_ORIGINALS) ? ((Settings.discart == DISCARTS_ORIGINALS_CUSTOMS) ? serverURLCustomDiscs : serverURLOrigDiscs) : NULL;
|
||||
const char * backupURL = (Settings.discart == DISCARTS_ORIGINALS_CUSTOMS || Settings.discart == DISCARTS_CUSTOMS_ORIGINALS) ? ((Settings.discart == DISCARTS_ORIGINALS_CUSTOMS) ? Settings.URL_DiscsCustom : Settings.URL_Discs) : NULL;
|
||||
const char * backupProgressTitle = (Settings.discart == DISCARTS_ORIGINALS_CUSTOMS || Settings.discart == DISCARTS_CUSTOMS_ORIGINALS) ? ((Settings.discart == DISCARTS_ORIGINALS_CUSTOMS) ? tr("Downloading custom Discarts") : tr("Downloading original Discarts")) : NULL;
|
||||
FindMissing(Settings.disc_path, downloadURL, backupURL, progressTitle, backupProgressTitle, ".png");
|
||||
}
|
||||
|
||||
if(choices & CheckedBox5)
|
||||
{
|
||||
FindMissing(Settings.BNRCachePath, serverURLCustomBannersGC, NULL, tr("Downloading Custom Banners"), NULL, ".bnr");
|
||||
FindMissing(Settings.BNRCachePath, Settings.URL_Banners, NULL, tr("Downloading Custom Banners"), NULL, ".bnr");
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,12 +159,7 @@ void ImageDownloader::FindMissing(const char *writepath, const char *downloadURL
|
||||
|
||||
int ImageDownloader::DownloadProcess(int TotalDownloadCount)
|
||||
{
|
||||
char progressMsg[255];
|
||||
char *path = strchr(serverURLCustomBannersGC + strlen("https://"), '/');
|
||||
int domainlength = path - serverURLCustomBannersGC;
|
||||
char domain[domainlength + 1];
|
||||
strncpy(domain, serverURLCustomBannersGC, domainlength);
|
||||
domain[domainlength] = '\0';
|
||||
char progressMsg[270];
|
||||
|
||||
for(u32 i = 0, pos = 0; i < MissingImages.size(); ++i, ++pos)
|
||||
{
|
||||
@ -187,9 +167,21 @@ int ImageDownloader::DownloadProcess(int TotalDownloadCount)
|
||||
break;
|
||||
|
||||
if(strcmp(MissingImages[i].fileExt, ".bnr") == 0)
|
||||
{
|
||||
char *path = strchr(MissingImages[i].downloadURL + ((strncmp(Settings.URL_Banners, "https://", 8) == 0) ? 8 : 7), '/');
|
||||
int domainlength = path - Settings.URL_Banners;
|
||||
char domain[domainlength + 1];
|
||||
strlcpy(domain, Settings.URL_Banners, domainlength + 1);
|
||||
snprintf(progressMsg, sizeof(progressMsg), "%s : %s.bnr", domain, MissingImages[i].gameID.c_str());
|
||||
}
|
||||
else
|
||||
snprintf(progressMsg, sizeof(progressMsg), "https://gametdb.com : %s.png", MissingImages[i].gameID.c_str());
|
||||
{
|
||||
char *path = strchr(MissingImages[i].downloadURL + ((strncmp(MissingImages[i].downloadURL, "https://", 8) == 0) ? 8 : 7), '/');
|
||||
int domainlength = path - MissingImages[i].downloadURL;
|
||||
char domain[domainlength + 1];
|
||||
strlcpy(domain, MissingImages[i].downloadURL, domainlength + 1);
|
||||
snprintf(progressMsg, sizeof(progressMsg), "%s : %s.png", domain, MissingImages[i].gameID.c_str());
|
||||
}
|
||||
|
||||
ShowProgress(MissingImages[i].progressTitle, fmt("%i %s", TotalDownloadCount - pos, tr( "files left" )), progressMsg, pos, TotalDownloadCount);
|
||||
|
||||
@ -224,6 +216,7 @@ int ImageDownloader::DownloadProcess(int TotalDownloadCount)
|
||||
MissingImagesCount--;
|
||||
}
|
||||
free(file.data);
|
||||
gprintf("File saved successfully (%s%s)\n", MissingImages[i].gameID.c_str(), MissingImages[i].fileExt);
|
||||
|
||||
//! Remove the image from the vector since it's done
|
||||
MissingImages.erase(MissingImages.begin()+i);
|
||||
@ -374,31 +367,31 @@ void ImageDownloader::CreateCSVLog()
|
||||
|
||||
for (u32 i = 0; i < MissingImages.size(); ++i)
|
||||
{
|
||||
if(MissingImages[i].downloadURL == serverURL3D)
|
||||
if(MissingImages[i].downloadURL == Settings.URL_Covers3D)
|
||||
{
|
||||
ImageType = "3D Cover";
|
||||
}
|
||||
else if(MissingImages[i].downloadURL == serverURL2D)
|
||||
else if(MissingImages[i].downloadURL == Settings.URL_Covers2D)
|
||||
{
|
||||
ImageType = "2D Cover";
|
||||
}
|
||||
else if(MissingImages[i].downloadURL == serverURLFullHQ)
|
||||
else if(MissingImages[i].downloadURL == Settings.URL_CoversFullHQ)
|
||||
{
|
||||
ImageType = "Full HQ Cover";
|
||||
}
|
||||
else if(MissingImages[i].downloadURL == serverURLFull)
|
||||
else if(MissingImages[i].downloadURL == Settings.URL_CoversFull)
|
||||
{
|
||||
ImageType = "Full LQ Cover";
|
||||
}
|
||||
else if(MissingImages[i].downloadURL == serverURLOrigDiscs)
|
||||
else if(MissingImages[i].downloadURL == Settings.URL_Discs)
|
||||
{
|
||||
ImageType = "Original Discart";
|
||||
}
|
||||
else if(MissingImages[i].downloadURL == serverURLCustomDiscs)
|
||||
else if(MissingImages[i].downloadURL == Settings.URL_DiscsCustom)
|
||||
{
|
||||
ImageType = "Custom Discart";
|
||||
}
|
||||
else if(MissingImages[i].downloadURL == serverURLCustomBannersGC)
|
||||
else if(MissingImages[i].downloadURL == Settings.URL_Banners)
|
||||
{
|
||||
ImageType = "Custom Banner";
|
||||
}
|
||||
|
@ -51,8 +51,6 @@
|
||||
#include "sys.h"
|
||||
#include "svnrev.h"
|
||||
|
||||
static const char *GameTDB_URL = "https://www.gametdb.com/wiitdb.zip";
|
||||
|
||||
/****************************************************************************
|
||||
* Checking if an Update is available
|
||||
***************************************************************************/
|
||||
@ -112,7 +110,7 @@ static bool CheckNewGameTDBVersion(const char *url)
|
||||
|
||||
int UpdateGameTDB()
|
||||
{
|
||||
if (CheckNewGameTDBVersion(GameTDB_URL) == false)
|
||||
if (CheckNewGameTDBVersion(Settings.URL_GameTDB) == false)
|
||||
{
|
||||
gprintf("Not updating GameTDB: Version is the same\n");
|
||||
return -1;
|
||||
@ -126,7 +124,7 @@ int UpdateGameTDB()
|
||||
|
||||
ZipPath += "wiitdb.zip";
|
||||
|
||||
int filesize = DownloadFileToPath(GameTDB_URL, ZipPath.c_str());
|
||||
int filesize = DownloadFileToPath(Settings.URL_GameTDB, ZipPath.c_str());
|
||||
|
||||
if (filesize <= 0)
|
||||
return -1;
|
||||
|
@ -869,7 +869,7 @@ static int InternalShowGameInfo(struct discHdr *header)
|
||||
txtWindow.Append(&dnBtn);
|
||||
}
|
||||
|
||||
gametdb1Txt = new GuiText("http://gametdb.com", 16, ( GXColor ) {0, 0, 0, 255});
|
||||
gametdb1Txt = new GuiText("gametdb.com", 16, ( GXColor ) {0, 0, 0, 255});
|
||||
gametdb1Txt->SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
|
||||
gametdb1Txt->SetPosition(40, -15);
|
||||
gameinfoWindow.Append(gametdb1Txt);
|
||||
|
@ -78,6 +78,14 @@ void CSettings::SetDefault()
|
||||
strlcpy(NandEmuChanPath, NandEmuPath, sizeof(NandEmuChanPath));
|
||||
strlcpy(GameCubePath, "usb1:/games/", sizeof(GameCubePath));
|
||||
strlcpy(GameCubeSDPath, "sd:/games/", sizeof(GameCubeSDPath));
|
||||
strlcpy(URL_Banners, "https://banner.rc24.xyz/", sizeof(URL_Banners));
|
||||
strlcpy(URL_Covers2D, "https://art.gametdb.com/wii/cover/", sizeof(URL_Covers2D));
|
||||
strlcpy(URL_Covers3D, "https://art.gametdb.com/wii/cover3D/", sizeof(URL_Covers3D));
|
||||
strlcpy(URL_CoversFull, "https://art.gametdb.com/wii/coverfull/", sizeof(URL_CoversFull));
|
||||
strlcpy(URL_CoversFullHQ, "https://art.gametdb.com/wii/coverfullHQ/", sizeof(URL_CoversFullHQ));
|
||||
strlcpy(URL_Discs, "https://art.gametdb.com/wii/disc/", sizeof(URL_Discs));
|
||||
strlcpy(URL_DiscsCustom, "https://art.gametdb.com/wii/disccustom/", sizeof(URL_DiscsCustom));
|
||||
strlcpy(URL_GameTDB, "https://www.gametdb.com/wiitdb.zip", sizeof(URL_GameTDB));
|
||||
theme[0] = 0;
|
||||
language_path[0] = 0;
|
||||
ogg_path[0] = 0;
|
||||
@ -481,11 +489,37 @@ bool CSettings::Save()
|
||||
fprintf(file, "GCInstallCompressed = %d\n", GCInstallCompressed);
|
||||
fprintf(file, "GCInstallAligned = %d\n", GCInstallAligned);
|
||||
fprintf(file, "PrivateServer = %d\n", PrivateServer);
|
||||
fprintf(file, "URL_Banners = %s\n", URL_Banners);
|
||||
fprintf(file, "URL_Covers2D = %s\n", URL_Covers2D);
|
||||
fprintf(file, "URL_Covers3D = %s\n", URL_Covers3D);
|
||||
fprintf(file, "URL_CoversFull = %s\n", URL_CoversFull);
|
||||
fprintf(file, "URL_CoversFullHQ = %s\n", URL_CoversFullHQ);
|
||||
fprintf(file, "URL_Discs = %s\n", URL_Discs);
|
||||
fprintf(file, "URL_DiscsCustom = %s\n", URL_DiscsCustom);
|
||||
fprintf(file, "URL_GameTDB = %s\n", URL_GameTDB);
|
||||
fclose(file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSettings::ValidateURL(char *value, bool zip)
|
||||
{
|
||||
if (strlen(value) >= 12 && (strncmp(value, "https://", 8) == 0 || strncmp(value, "http://", 7) == 0))
|
||||
{
|
||||
if (zip)
|
||||
{
|
||||
if (strncmp(value + strlen(value) -4, ".zip", 4) == 0) // The URL must end with .zip to be valid
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strncmp(value + strlen(value) -1, "/", 1) == 0) // The URL must end with / to be valid
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSettings::SetSetting(char *name, char *value)
|
||||
{
|
||||
if (strcmp(name, "godmode") == 0)
|
||||
@ -1242,6 +1276,54 @@ bool CSettings::SetSetting(char *name, char *value)
|
||||
strlcpy(GameCubeSDPath, value, sizeof(GameCubeSDPath));
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "URL_Banners") == 0)
|
||||
{
|
||||
if (ValidateURL(value))
|
||||
strlcpy(URL_Banners, value, sizeof(URL_Banners));
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "URL_Covers2D") == 0)
|
||||
{
|
||||
if (ValidateURL(value))
|
||||
strlcpy(URL_Covers2D, value, sizeof(URL_Covers2D));
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "URL_Covers3D") == 0)
|
||||
{
|
||||
if (ValidateURL(value))
|
||||
strlcpy(URL_Covers3D, value, sizeof(URL_Covers3D));
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "URL_CoversFull") == 0)
|
||||
{
|
||||
if (ValidateURL(value))
|
||||
strlcpy(URL_CoversFull, value, sizeof(URL_CoversFull));
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "URL_CoversFullHQ") == 0)
|
||||
{
|
||||
if (ValidateURL(value))
|
||||
strlcpy(URL_CoversFullHQ, value, sizeof(URL_CoversFullHQ));
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "URL_Discs") == 0)
|
||||
{
|
||||
if (ValidateURL(value))
|
||||
strlcpy(URL_Discs, value, sizeof(URL_Discs));
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "URL_DiscsCustom") == 0)
|
||||
{
|
||||
if (ValidateURL(value))
|
||||
strlcpy(URL_DiscsCustom, value, sizeof(URL_DiscsCustom));
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "URL_GameTDB") == 0)
|
||||
{
|
||||
if (ValidateURL(value, true))
|
||||
strlcpy(URL_GameTDB, value, sizeof(URL_GameTDB));
|
||||
return true;
|
||||
}
|
||||
else if(strcmp(name, "PrivateServer") == 0)
|
||||
{
|
||||
PrivateServer = atoi(value);
|
||||
|
@ -89,6 +89,14 @@ class CSettings
|
||||
char GameCubeSDPath[100];
|
||||
char DEVOLoaderPath[100];
|
||||
char NINLoaderPath[100];
|
||||
char URL_Banners[300];
|
||||
char URL_Covers2D[300];
|
||||
char URL_Covers3D[300];
|
||||
char URL_CoversFull[300];
|
||||
char URL_CoversFullHQ[300];
|
||||
char URL_Discs[300];
|
||||
char URL_DiscsCustom[300];
|
||||
char URL_GameTDB[300];
|
||||
short videomode;
|
||||
short language;
|
||||
short ocarina;
|
||||
@ -226,6 +234,7 @@ class CSettings
|
||||
bool FirstTimeRun;
|
||||
protected:
|
||||
bool ValidVersion(FILE * file);
|
||||
bool ValidateURL(char *value, bool zip = false);
|
||||
bool SetSetting(char *name, char *value);
|
||||
//!Find the config file in the default paths
|
||||
bool FindConfig();
|
||||
|
@ -67,7 +67,7 @@ int GetMissingGameFiles(const char * path, const char * fileext, std::vector<std
|
||||
//! Bring game list to the old state
|
||||
gameList.FilterList(oldFilter.c_str());
|
||||
|
||||
gprintf(" = %i", MissingFilesList.size());
|
||||
gprintf(" = %i\n", MissingFilesList.size());
|
||||
|
||||
return MissingFilesList.size();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user