mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-25 04:36:53 +01:00
b78388e779
*change default virtual pointer speed to 0.18 *added instruction invalidation of dol areas before starting them *corrected PAL60 system default video mode set *fixed loading titles when titles from wiitdb is OFF *removed buggy lz77 implementation and use the one known working *fix small scrollbar bug when having only 1 item *fix launch of dollz compressed dol files (thx FIX94)
96 lines
2.0 KiB
C++
96 lines
2.0 KiB
C++
#include <malloc.h>
|
|
#include <string.h>
|
|
#include "FileOperations/fileops.h"
|
|
#include "Resources.h"
|
|
#include "filelist.h"
|
|
|
|
void Resources::Clear()
|
|
{
|
|
for(int i = 0; RecourceFiles[i].filename != NULL; ++i)
|
|
{
|
|
if(RecourceFiles[i].CustomFile)
|
|
{
|
|
free(RecourceFiles[i].CustomFile);
|
|
RecourceFiles[i].CustomFile = NULL;
|
|
}
|
|
|
|
if(RecourceFiles[i].CustomFileSize != 0)
|
|
RecourceFiles[i].CustomFileSize = 0;
|
|
}
|
|
}
|
|
|
|
bool Resources::LoadFiles(const char * path)
|
|
{
|
|
if(!path)
|
|
return false;
|
|
|
|
bool result = false;
|
|
Clear();
|
|
|
|
char fullpath[1024];
|
|
|
|
for(int i = 0; RecourceFiles[i].filename != NULL; ++i)
|
|
{
|
|
snprintf(fullpath, sizeof(fullpath), "%s/%s", path, RecourceFiles[i].filename);
|
|
|
|
if(CheckFile(fullpath))
|
|
{
|
|
u8 * buffer = NULL;
|
|
u32 filesize = 0;
|
|
|
|
LoadFileToMem(fullpath, &buffer, &filesize);
|
|
|
|
RecourceFiles[i].CustomFile = buffer;
|
|
RecourceFiles[i].CustomFileSize = (u32) filesize;
|
|
result = true;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
const u8 * Resources::GetFile(const char * filename)
|
|
{
|
|
for(int i = 0; RecourceFiles[i].filename != NULL; ++i)
|
|
{
|
|
if(strcasecmp(filename, RecourceFiles[i].filename) == 0)
|
|
{
|
|
return (RecourceFiles[i].CustomFile ? RecourceFiles[i].CustomFile : RecourceFiles[i].DefaultFile);
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
u32 Resources::GetFileSize(const char * filename)
|
|
{
|
|
for(int i = 0; RecourceFiles[i].filename != NULL; ++i)
|
|
{
|
|
if(strcasecmp(filename, RecourceFiles[i].filename) == 0)
|
|
{
|
|
return (RecourceFiles[i].CustomFile ? RecourceFiles[i].CustomFileSize : RecourceFiles[i].DefaultFileSize);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
GuiImageData * Resources::GetImageData(const char * filename)
|
|
{
|
|
for(int i = 0; RecourceFiles[i].filename != NULL; ++i)
|
|
{
|
|
if(strcasecmp(filename, RecourceFiles[i].filename) == 0)
|
|
{
|
|
const u8 * buff = RecourceFiles[i].CustomFile ? RecourceFiles[i].CustomFile : RecourceFiles[i].DefaultFile;
|
|
const u32 size = RecourceFiles[i].CustomFile ? RecourceFiles[i].CustomFileSize : RecourceFiles[i].DefaultFileSize;
|
|
|
|
if(buff != NULL)
|
|
return (new GuiImageData(buff, size));
|
|
else
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|