mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-01 00:55:06 +01:00
-changed name to WiiFlow Lite
-renamed some coverflows and domains for easier code reading. making things more uniform.
This commit is contained in:
parent
7bad8c3fd3
commit
86d768c829
124
source/defines.h
124
source/defines.h
@ -1,62 +1,62 @@
|
||||
#define APP_NAME "WiiFlow"
|
||||
#define APP_VERSION "Beta 4.2.2"
|
||||
|
||||
#define APPDATA_DIR "wiiflow"
|
||||
#define APPDATA_DIR2 "apps/wiiflow"
|
||||
|
||||
#define STDEMU_DIR "/wiiflow/nandemu"
|
||||
#define GAMES_DIR "%s:/wbfs"
|
||||
#define HOMEBREW_DIR "%s:/apps"
|
||||
#define DML_DIR "%s:/games"
|
||||
#define CFG_FILENAME "wiiflow.ini"
|
||||
#define LANG_FILENAME "languages.ini"
|
||||
#define CAT_FILENAME "categories_v4.ini"
|
||||
#define SOURCE_FILENAME "source_menu.ini"
|
||||
#define TITLES_FILENAME "titles.ini"
|
||||
#define CTITLES_FILENAME "custom_titles.ini"
|
||||
#define AGE_LOCK_FILENAME "age_lock.ini"
|
||||
#define TITLES_DUMP_FILENAME "titlesdump.ini"
|
||||
#define GAME_SETTINGS1_FILENAME "gameconfig1.ini"
|
||||
#define GAME_SETTINGS2_FILENAME "gameconfig2.ini"
|
||||
#define PLUGIN_CRCS_FILENAME "plugin_crc32.ini"
|
||||
|
||||
#define WII_DOMAIN "GAMES"
|
||||
#define GC_DOMAIN "DML"
|
||||
#define CHANNEL_DOMAIN "NAND"
|
||||
#define PLUGIN_DOMAIN "EMULATOR"
|
||||
#define HOMEBREW_DOMAIN "HOMEBREW"
|
||||
#define MUSIC_DOMAIN "MUSIC"
|
||||
#define FTP_DOMAIN "FTP"
|
||||
|
||||
#define AGE_LOCK_DEFAULT 13
|
||||
|
||||
#define DEVELOPERS "FIX94, Fledge68, OverjoY"
|
||||
#define PAST_DEVELOPERS "Hibernatus, Narolez, Hulk, Miigotu, r-win"
|
||||
#define LOADER_AUTHOR "Kwiirk, Waninkoko, Hermes"
|
||||
#define GUI_AUTHOR "Hibernatus"
|
||||
|
||||
#define THANKS \
|
||||
"Lustar, CedWii, Benjay, Domi78, Oops, \
|
||||
Celtiore, Jiiwah, FluffyKiwi, Roku93, Yardape8000, \
|
||||
Spayrosam, Bluescreen81, Chappy23, mamule, seam, \
|
||||
BlindDude, Bubba, DJTaz, OggZee, entropy, Ayatus, \
|
||||
Usptactical, WiiPower, Hermes, Spidy1000, megazig, \
|
||||
Dimok, Kovani, Drexyl, DvZ, Etheboss, stfour, \
|
||||
GaiaKnight, nibb, NJ7, Plasma, Pakatus, giantpune, \
|
||||
wolf, ravmn, spidercaleb, Ziggy34, xFede, Abz, \
|
||||
and to anyone who has donated or \
|
||||
contributed to Wiiflow that we missed!"
|
||||
|
||||
#define THANKS_SITES \
|
||||
"devkitpro.org, wiibrew.org, gametdb.com, \
|
||||
ohloh.net, wiifanart.com, wiiflowiki.com, \
|
||||
tgames.fr.nf"
|
||||
|
||||
#define THANKS_CODE \
|
||||
"CFG Loader, Wii Banner Player Project, USB Loader GX, \
|
||||
uLoader, NeoGamma, Mighty Channels, WiiXplorer, Triiforce, \
|
||||
postLoader"
|
||||
|
||||
|
||||
#define WIINNERTAG_URL "http://www.wiinnertag.com/wiinnertag_scripts/update_sign.php?key={KEY}&game_id={ID6}"
|
||||
#define DUTAG_URL "http://tag.darkumbra.net/{KEY}.update={ID6}"
|
||||
#define APP_NAME "WiiFlow Lite"
|
||||
#define APP_VERSION "Beta 4.2.2"
|
||||
|
||||
#define APPDATA_DIR "wiiflow"
|
||||
#define APPDATA_DIR2 "apps/wiiflow"
|
||||
|
||||
#define STDEMU_DIR "/wiiflow/nandemu"
|
||||
#define GAMES_DIR "%s:/wbfs"
|
||||
#define HOMEBREW_DIR "%s:/apps"
|
||||
#define DML_DIR "%s:/games"
|
||||
#define CFG_FILENAME "wiiflow_lite.ini"
|
||||
#define LANG_FILENAME "languages.ini"
|
||||
#define CAT_FILENAME "categories_lite.ini"
|
||||
#define SOURCE_FILENAME "source_menu.ini"
|
||||
#define TITLES_FILENAME "titles.ini"
|
||||
#define CTITLES_FILENAME "custom_titles.ini"
|
||||
#define AGE_LOCK_FILENAME "age_lock.ini"
|
||||
#define TITLES_DUMP_FILENAME "titlesdump.ini"
|
||||
#define GAME_SETTINGS1_FILENAME "gameconfig1.ini"
|
||||
#define GAME_SETTINGS2_FILENAME "gameconfig2.ini"
|
||||
#define PLUGIN_CRCS_FILENAME "plugin_crc32.ini"
|
||||
|
||||
#define WII_DOMAIN "WII"
|
||||
#define GC_DOMAIN "GAMECUBE"
|
||||
#define CHANNEL_DOMAIN "CHANNELS"
|
||||
#define PLUGIN_DOMAIN "PLUGINS"
|
||||
#define HOMEBREW_DOMAIN "HOMEBREW"
|
||||
#define MUSIC_DOMAIN "MUSIC"
|
||||
#define FTP_DOMAIN "FTP"
|
||||
|
||||
#define AGE_LOCK_DEFAULT 13
|
||||
|
||||
#define DEVELOPERS "FIX94, Fledge68, OverjoY"
|
||||
#define PAST_DEVELOPERS "Hibernatus, Narolez, Hulk, Miigotu, r-win"
|
||||
#define LOADER_AUTHOR "Kwiirk, Waninkoko, Hermes"
|
||||
#define GUI_AUTHOR "Hibernatus"
|
||||
|
||||
#define THANKS \
|
||||
"Lustar, CedWii, Benjay, Domi78, Oops, \
|
||||
Celtiore, Jiiwah, FluffyKiwi, Roku93, Yardape8000, \
|
||||
Spayrosam, Bluescreen81, Chappy23, mamule, seam, \
|
||||
BlindDude, Bubba, DJTaz, OggZee, entropy, Ayatus, \
|
||||
Usptactical, WiiPower, Hermes, Spidy1000, megazig, \
|
||||
Dimok, Kovani, Drexyl, DvZ, Etheboss, stfour, \
|
||||
GaiaKnight, nibb, NJ7, Plasma, Pakatus, giantpune, \
|
||||
wolf, ravmn, spidercaleb, Ziggy34, xFede, Abz, \
|
||||
and to anyone who has donated or \
|
||||
contributed to Wiiflow that we missed!"
|
||||
|
||||
#define THANKS_SITES \
|
||||
"devkitpro.org, wiibrew.org, gametdb.com, \
|
||||
ohloh.net, wiifanart.com, wiiflowiki.com, \
|
||||
tgames.fr.nf"
|
||||
|
||||
#define THANKS_CODE \
|
||||
"CFG Loader, Wii Banner Player Project, USB Loader GX, \
|
||||
uLoader, NeoGamma, Mighty Channels, WiiXplorer, Triiforce, \
|
||||
postLoader"
|
||||
|
||||
|
||||
#define WIINNERTAG_URL "http://www.wiinnertag.com/wiinnertag_scripts/update_sign.php?key={KEY}&game_id={ID6}"
|
||||
#define DUTAG_URL "http://tag.darkumbra.net/{KEY}.update={ID6}"
|
||||
|
@ -1,334 +1,334 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2012 FIX94
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include "ListGenerator.hpp"
|
||||
#include "cache.hpp"
|
||||
#include "channel/channels.h"
|
||||
#include "devicemounter/DeviceHandler.hpp"
|
||||
#include "fileOps/fileOps.h"
|
||||
#include "gui/coverflow.hpp"
|
||||
#include "gui/text.hpp"
|
||||
|
||||
ListGenerator m_gameList;
|
||||
Config CustomTitles;
|
||||
GameTDB gameTDB;
|
||||
|
||||
dir_discHdr ListElement;
|
||||
void ListGenerator::Init(const char *settingsDir, const char *Language)
|
||||
{
|
||||
if(settingsDir != NULL)
|
||||
{
|
||||
gameTDB_Path = fmt("%s/wiitdb.xml", settingsDir);
|
||||
CustomTitlesPath = fmt("%s/" CTITLES_FILENAME, settingsDir);
|
||||
}
|
||||
if(Language != NULL) gameTDB_Language = Language;
|
||||
}
|
||||
|
||||
void ListGenerator::OpenConfigs()
|
||||
{
|
||||
gameTDB.OpenFile(gameTDB_Path.c_str());
|
||||
if(gameTDB.IsLoaded())
|
||||
gameTDB.SetLanguageCode(gameTDB_Language.c_str());
|
||||
CustomTitles.load(CustomTitlesPath.c_str());
|
||||
}
|
||||
|
||||
void ListGenerator::CloseConfigs()
|
||||
{
|
||||
if(gameTDB.IsLoaded())
|
||||
gameTDB.CloseFile();
|
||||
if(CustomTitles.loaded())
|
||||
CustomTitles.unload();
|
||||
}
|
||||
|
||||
/*
|
||||
static const u32 LIST_TMP_SIZE = 5000;
|
||||
dir_discHdr *tmpList = NULL;
|
||||
u32 tmpListPos = 0;
|
||||
static void AddToList(const dir_discHdr *element)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
static void AddISO(const char *GameID, const char *GameTitle, const char *GamePath,
|
||||
u32 GameColor, u8 Type)
|
||||
{
|
||||
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
|
||||
ListElement.index = m_gameList.size();
|
||||
if(GameID != NULL) strncpy(ListElement.id, GameID, 6);
|
||||
if(GamePath != NULL) strncpy(ListElement.path, GamePath, sizeof(ListElement.path) - 1);
|
||||
ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, GameColor).intVal();
|
||||
const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str();
|
||||
if(gameTDB.IsLoaded())
|
||||
{
|
||||
if(ListElement.casecolor == GameColor)
|
||||
ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id);
|
||||
ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id);
|
||||
ListElement.players = gameTDB.GetPlayers(ListElement.id);
|
||||
if(CustomTitle == NULL || CustomTitle[0] == '\0')
|
||||
gameTDB.GetTitle(ListElement.id, CustomTitle);
|
||||
}
|
||||
if(!ValidColor(ListElement.casecolor))
|
||||
ListElement.casecolor = CoverFlow.InternalCoverColor(ListElement.id, GameColor);
|
||||
|
||||
if(CustomTitle != NULL && CustomTitle[0] != '\0')
|
||||
mbstowcs(ListElement.title, CustomTitle, 63);
|
||||
else if(GameTitle != NULL)
|
||||
mbstowcs(ListElement.title, GameTitle, 63);
|
||||
Asciify(ListElement.title);
|
||||
|
||||
ListElement.type = Type;
|
||||
m_gameList.push_back(ListElement);
|
||||
}
|
||||
|
||||
static void Create_Wii_WBFS_List(wbfs_t *handle)
|
||||
{
|
||||
for(u32 i = 0; i < wbfs_count_discs(handle); i++)
|
||||
{
|
||||
memset((void*)&wii_hdr, 0, sizeof(discHdr));
|
||||
s32 ret = wbfs_get_disc_info(handle, i, (u8*)&wii_hdr, sizeof(discHdr), NULL);
|
||||
if(ret == 0 && wii_hdr.magic == WII_MAGIC)
|
||||
AddISO((const char*)wii_hdr.id, (const char*)wii_hdr.title,
|
||||
NULL, 0xFFFFFF, TYPE_WII_GAME);
|
||||
}
|
||||
}
|
||||
|
||||
static void Create_Wii_EXT_List(char *FullPath)
|
||||
{
|
||||
FILE *fp = fopen(FullPath, "rb");
|
||||
if(fp)
|
||||
{
|
||||
fseek(fp, strcasestr(FullPath, ".wbfs") != NULL ? 512 : 0, SEEK_SET);
|
||||
fread((void*)&wii_hdr, 1, sizeof(discHdr), fp);
|
||||
if(wii_hdr.magic == WII_MAGIC)
|
||||
AddISO((const char*)wii_hdr.id, (const char*)wii_hdr.title,
|
||||
FullPath, 0xFFFFFF, TYPE_WII_GAME);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
u8 gc_disc[1];
|
||||
const char *FST_APPEND = "sys/boot.bin";
|
||||
const u8 FST_APPEND_SIZE = strlen(FST_APPEND);
|
||||
static void Create_GC_List(char *FullPath)
|
||||
{
|
||||
FILE *fp = fopen(FullPath, "rb");
|
||||
if(!fp && strstr(FullPath, "/root") != NULL) //fst folder
|
||||
{
|
||||
*(strstr(FullPath, "/root") + 1) = '\0';
|
||||
if(strlen(FullPath) + FST_APPEND_SIZE < MAX_MSG_SIZE) strcat(FullPath, FST_APPEND);
|
||||
fp = fopen(FullPath, "rb");
|
||||
}
|
||||
if(fp)
|
||||
{
|
||||
fread((void*)&gc_hdr, 1, sizeof(gc_discHdr), fp);
|
||||
if(gc_hdr.magic == GC_MAGIC)
|
||||
{
|
||||
AddISO((const char*)gc_hdr.id, (const char*)gc_hdr.title,
|
||||
FullPath, 0x000000, TYPE_GC_GAME);
|
||||
/* Check for disc 2 */
|
||||
fseek(fp, 6, SEEK_SET);
|
||||
fread(gc_disc, 1, 1, fp);
|
||||
if(gc_disc[0])
|
||||
{
|
||||
wcslcat(m_gameList.back().title, L" disc 2", 63);
|
||||
m_gameList.back().settings[0] = 1;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
const char *FolderTitle = NULL;
|
||||
static void Create_Plugin_List(char *FullPath)
|
||||
{
|
||||
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
|
||||
|
||||
strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1);
|
||||
strncpy(ListElement.id, "PLUGIN", 6);
|
||||
|
||||
FolderTitle = strrchr(FullPath, '/') + 1;
|
||||
*strrchr(FolderTitle, '.') = '\0';
|
||||
|
||||
char PluginMagicWord[9];
|
||||
memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
|
||||
strncpy(PluginMagicWord, fmt("%08x", m_gameList.Magic), 8);
|
||||
const char *CustomTitle = CustomTitles.getString(PluginMagicWord, FolderTitle).c_str();
|
||||
if(CustomTitle != NULL && CustomTitle[0] != '\0')
|
||||
mbstowcs(ListElement.title, CustomTitle, 63);
|
||||
else
|
||||
mbstowcs(ListElement.title, FolderTitle, 63);
|
||||
Asciify(ListElement.title);
|
||||
|
||||
ListElement.settings[0] = m_gameList.Magic; //Plugin magic
|
||||
ListElement.casecolor = m_gameList.Color;
|
||||
ListElement.type = TYPE_PLUGIN;
|
||||
m_gameList.push_back(ListElement);
|
||||
}
|
||||
|
||||
static void Create_Homebrew_List(char *FullPath)
|
||||
{
|
||||
if(strcasestr(FullPath, "boot.") == NULL)
|
||||
return;
|
||||
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
|
||||
ListElement.index = m_gameList.size();
|
||||
*strrchr(FullPath, '/') = '\0';
|
||||
strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1);
|
||||
strncpy(ListElement.id, "HB_APP", 6);
|
||||
|
||||
FolderTitle = strrchr(FullPath, '/') + 1;
|
||||
ListElement.casecolor = CustomTitles.getColor("COVERS", FolderTitle, 0xFFFFFF).intVal();
|
||||
const string &CustomTitle = CustomTitles.getString("TITLES", FolderTitle);
|
||||
if(CustomTitle.size() > 0)
|
||||
mbstowcs(ListElement.title, CustomTitle.c_str(), 63);
|
||||
else
|
||||
mbstowcs(ListElement.title, FolderTitle, 63);
|
||||
Asciify(ListElement.title);
|
||||
|
||||
ListElement.type = TYPE_HOMEBREW;
|
||||
m_gameList.push_back(ListElement);
|
||||
}
|
||||
|
||||
Channel *chan = NULL;
|
||||
static void Create_Channel_List()
|
||||
{
|
||||
for(u32 i = 0; i < ChannelHandle.Count(); i++)
|
||||
{
|
||||
chan = ChannelHandle.GetChannel(i);
|
||||
if(chan->id == NULL)
|
||||
continue; // Skip invalid channels
|
||||
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
|
||||
ListElement.index = m_gameList.size();
|
||||
ListElement.settings[0] = TITLE_UPPER(chan->title);
|
||||
ListElement.settings[1] = TITLE_LOWER(chan->title);
|
||||
strncpy(ListElement.id, chan->id, 4);
|
||||
ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, 0xFFFFFF).intVal();
|
||||
const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str();
|
||||
if(gameTDB.IsLoaded())
|
||||
{
|
||||
if(ListElement.casecolor == 0xFFFFFF)
|
||||
ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id);
|
||||
ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id);
|
||||
ListElement.players = gameTDB.GetPlayers(ListElement.id);
|
||||
if(CustomTitle == NULL || CustomTitle[0] == '\0')
|
||||
gameTDB.GetTitle(ListElement.id, CustomTitle);
|
||||
}
|
||||
if(CustomTitle != NULL && CustomTitle[0] != '\0')
|
||||
mbstowcs(ListElement.title, CustomTitle, 63);
|
||||
else
|
||||
wcsncpy(ListElement.title, chan->name, 64);
|
||||
ListElement.type = TYPE_CHANNEL;
|
||||
m_gameList.push_back(ListElement);
|
||||
}
|
||||
}
|
||||
|
||||
void ListGenerator::CreateList(u32 Flow, u32 Device, const string& Path, const vector<string>& FileTypes,
|
||||
const string& DBName, bool UpdateCache)
|
||||
{
|
||||
if(!DBName.empty())
|
||||
{
|
||||
if(UpdateCache)
|
||||
fsop_deleteFile(DBName.c_str());
|
||||
else
|
||||
{
|
||||
CCache(*this, DBName, LOAD);
|
||||
if(!this->empty())
|
||||
return;
|
||||
fsop_deleteFile(DBName.c_str());
|
||||
}
|
||||
}
|
||||
//if(Flow != COVERFLOW_PLUGIN)
|
||||
OpenConfigs();
|
||||
if(Flow == COVERFLOW_USB)
|
||||
{
|
||||
if(DeviceHandle.GetFSType(Device) == PART_FS_WBFS)
|
||||
Create_Wii_WBFS_List(DeviceHandle.GetWbfsHandle(Device));
|
||||
else
|
||||
GetFiles(Path.c_str(), FileTypes, Create_Wii_EXT_List, false);
|
||||
}
|
||||
else if(Flow == COVERFLOW_CHANNEL)
|
||||
{
|
||||
ChannelHandle.Init(gameTDB_Language);
|
||||
Create_Channel_List();
|
||||
}
|
||||
else if(DeviceHandle.GetFSType(Device) != PART_FS_WBFS)
|
||||
{
|
||||
if(Flow == COVERFLOW_DML)
|
||||
GetFiles(Path.c_str(), FileTypes, Create_GC_List, true);
|
||||
else if(Flow == COVERFLOW_PLUGIN)
|
||||
GetFiles(Path.c_str(), FileTypes, Create_Plugin_List, false, 30);
|
||||
else if(Flow == COVERFLOW_HOMEBREW)
|
||||
GetFiles(Path.c_str(), FileTypes, Create_Homebrew_List, false);
|
||||
}
|
||||
CloseConfigs();
|
||||
if(!this->empty() && !DBName.empty()) /* Write a new Cache */
|
||||
CCache(*this, DBName, SAVE);
|
||||
}
|
||||
|
||||
static inline bool IsFileSupported(const char *File, const vector<string>& FileTypes)
|
||||
{
|
||||
for(vector<string>::const_iterator cmp = FileTypes.begin(); cmp != FileTypes.end(); ++cmp)
|
||||
{
|
||||
if(strcasecmp(File, cmp->c_str()) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *NewFileName = NULL;
|
||||
char *FullPathChar = NULL;
|
||||
dirent *pent = NULL;
|
||||
DIR *pdir = NULL;
|
||||
void GetFiles(const char *Path, const vector<string>& FileTypes,
|
||||
FileAdder AddFile, bool CompareFolders, u32 max_depth, u32 depth)
|
||||
{
|
||||
vector<string> SubPaths;
|
||||
|
||||
pdir = opendir(Path);
|
||||
if(pdir == NULL)
|
||||
return;
|
||||
while((pent = readdir(pdir)) != NULL)
|
||||
{
|
||||
if(pent->d_name[0] == '.')
|
||||
continue;
|
||||
FullPathChar = fmt("%s/%s", Path, pent->d_name);
|
||||
if(pent->d_type == DT_DIR)
|
||||
{
|
||||
if(CompareFolders && IsFileSupported(pent->d_name, FileTypes))
|
||||
{
|
||||
AddFile(FullPathChar);
|
||||
continue;
|
||||
}
|
||||
else if(depth < max_depth) //thanks libntfs (fail opendir) and thanks seekdir (slowass speed)
|
||||
SubPaths.push_back(FullPathChar);
|
||||
}
|
||||
else if(pent->d_type == DT_REG)
|
||||
{
|
||||
NewFileName = strrchr(pent->d_name, '.');
|
||||
if(NewFileName == NULL) NewFileName = pent->d_name;
|
||||
if(IsFileSupported(NewFileName, FileTypes))
|
||||
{
|
||||
AddFile(FullPathChar);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(pdir);
|
||||
for(vector<string>::const_iterator p = SubPaths.begin(); p != SubPaths.end(); ++p)
|
||||
GetFiles(p->c_str(), FileTypes, AddFile, CompareFolders, max_depth, depth + 1);
|
||||
SubPaths.clear();
|
||||
}
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2012 FIX94
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include "ListGenerator.hpp"
|
||||
#include "cache.hpp"
|
||||
#include "channel/channels.h"
|
||||
#include "devicemounter/DeviceHandler.hpp"
|
||||
#include "fileOps/fileOps.h"
|
||||
#include "gui/coverflow.hpp"
|
||||
#include "gui/text.hpp"
|
||||
|
||||
ListGenerator m_gameList;
|
||||
Config CustomTitles;
|
||||
GameTDB gameTDB;
|
||||
|
||||
dir_discHdr ListElement;
|
||||
void ListGenerator::Init(const char *settingsDir, const char *Language)
|
||||
{
|
||||
if(settingsDir != NULL)
|
||||
{
|
||||
gameTDB_Path = fmt("%s/wiitdb.xml", settingsDir);
|
||||
CustomTitlesPath = fmt("%s/" CTITLES_FILENAME, settingsDir);
|
||||
}
|
||||
if(Language != NULL) gameTDB_Language = Language;
|
||||
}
|
||||
|
||||
void ListGenerator::OpenConfigs()
|
||||
{
|
||||
gameTDB.OpenFile(gameTDB_Path.c_str());
|
||||
if(gameTDB.IsLoaded())
|
||||
gameTDB.SetLanguageCode(gameTDB_Language.c_str());
|
||||
CustomTitles.load(CustomTitlesPath.c_str());
|
||||
}
|
||||
|
||||
void ListGenerator::CloseConfigs()
|
||||
{
|
||||
if(gameTDB.IsLoaded())
|
||||
gameTDB.CloseFile();
|
||||
if(CustomTitles.loaded())
|
||||
CustomTitles.unload();
|
||||
}
|
||||
|
||||
/*
|
||||
static const u32 LIST_TMP_SIZE = 5000;
|
||||
dir_discHdr *tmpList = NULL;
|
||||
u32 tmpListPos = 0;
|
||||
static void AddToList(const dir_discHdr *element)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
static void AddISO(const char *GameID, const char *GameTitle, const char *GamePath,
|
||||
u32 GameColor, u8 Type)
|
||||
{
|
||||
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
|
||||
ListElement.index = m_gameList.size();
|
||||
if(GameID != NULL) strncpy(ListElement.id, GameID, 6);
|
||||
if(GamePath != NULL) strncpy(ListElement.path, GamePath, sizeof(ListElement.path) - 1);
|
||||
ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, GameColor).intVal();
|
||||
const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str();
|
||||
if(gameTDB.IsLoaded())
|
||||
{
|
||||
if(ListElement.casecolor == GameColor)
|
||||
ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id);
|
||||
ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id);
|
||||
ListElement.players = gameTDB.GetPlayers(ListElement.id);
|
||||
if(CustomTitle == NULL || CustomTitle[0] == '\0')
|
||||
gameTDB.GetTitle(ListElement.id, CustomTitle);
|
||||
}
|
||||
if(!ValidColor(ListElement.casecolor))
|
||||
ListElement.casecolor = CoverFlow.InternalCoverColor(ListElement.id, GameColor);
|
||||
|
||||
if(CustomTitle != NULL && CustomTitle[0] != '\0')
|
||||
mbstowcs(ListElement.title, CustomTitle, 63);
|
||||
else if(GameTitle != NULL)
|
||||
mbstowcs(ListElement.title, GameTitle, 63);
|
||||
Asciify(ListElement.title);
|
||||
|
||||
ListElement.type = Type;
|
||||
m_gameList.push_back(ListElement);
|
||||
}
|
||||
|
||||
static void Create_Wii_WBFS_List(wbfs_t *handle)
|
||||
{
|
||||
for(u32 i = 0; i < wbfs_count_discs(handle); i++)
|
||||
{
|
||||
memset((void*)&wii_hdr, 0, sizeof(discHdr));
|
||||
s32 ret = wbfs_get_disc_info(handle, i, (u8*)&wii_hdr, sizeof(discHdr), NULL);
|
||||
if(ret == 0 && wii_hdr.magic == WII_MAGIC)
|
||||
AddISO((const char*)wii_hdr.id, (const char*)wii_hdr.title,
|
||||
NULL, 0xFFFFFF, TYPE_WII_GAME);
|
||||
}
|
||||
}
|
||||
|
||||
static void Create_Wii_EXT_List(char *FullPath)
|
||||
{
|
||||
FILE *fp = fopen(FullPath, "rb");
|
||||
if(fp)
|
||||
{
|
||||
fseek(fp, strcasestr(FullPath, ".wbfs") != NULL ? 512 : 0, SEEK_SET);
|
||||
fread((void*)&wii_hdr, 1, sizeof(discHdr), fp);
|
||||
if(wii_hdr.magic == WII_MAGIC)
|
||||
AddISO((const char*)wii_hdr.id, (const char*)wii_hdr.title,
|
||||
FullPath, 0xFFFFFF, TYPE_WII_GAME);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
u8 gc_disc[1];
|
||||
const char *FST_APPEND = "sys/boot.bin";
|
||||
const u8 FST_APPEND_SIZE = strlen(FST_APPEND);
|
||||
static void Create_GC_List(char *FullPath)
|
||||
{
|
||||
FILE *fp = fopen(FullPath, "rb");
|
||||
if(!fp && strstr(FullPath, "/root") != NULL) //fst folder
|
||||
{
|
||||
*(strstr(FullPath, "/root") + 1) = '\0';
|
||||
if(strlen(FullPath) + FST_APPEND_SIZE < MAX_MSG_SIZE) strcat(FullPath, FST_APPEND);
|
||||
fp = fopen(FullPath, "rb");
|
||||
}
|
||||
if(fp)
|
||||
{
|
||||
fread((void*)&gc_hdr, 1, sizeof(gc_discHdr), fp);
|
||||
if(gc_hdr.magic == GC_MAGIC)
|
||||
{
|
||||
AddISO((const char*)gc_hdr.id, (const char*)gc_hdr.title,
|
||||
FullPath, 0x000000, TYPE_GC_GAME);
|
||||
/* Check for disc 2 */
|
||||
fseek(fp, 6, SEEK_SET);
|
||||
fread(gc_disc, 1, 1, fp);
|
||||
if(gc_disc[0])
|
||||
{
|
||||
wcslcat(m_gameList.back().title, L" disc 2", 63);
|
||||
m_gameList.back().settings[0] = 1;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
const char *FolderTitle = NULL;
|
||||
static void Create_Plugin_List(char *FullPath)
|
||||
{
|
||||
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
|
||||
|
||||
strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1);
|
||||
strncpy(ListElement.id, "PLUGIN", 6);
|
||||
|
||||
FolderTitle = strrchr(FullPath, '/') + 1;
|
||||
*strrchr(FolderTitle, '.') = '\0';
|
||||
|
||||
char PluginMagicWord[9];
|
||||
memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
|
||||
strncpy(PluginMagicWord, fmt("%08x", m_gameList.Magic), 8);
|
||||
const char *CustomTitle = CustomTitles.getString(PluginMagicWord, FolderTitle).c_str();
|
||||
if(CustomTitle != NULL && CustomTitle[0] != '\0')
|
||||
mbstowcs(ListElement.title, CustomTitle, 63);
|
||||
else
|
||||
mbstowcs(ListElement.title, FolderTitle, 63);
|
||||
Asciify(ListElement.title);
|
||||
|
||||
ListElement.settings[0] = m_gameList.Magic; //Plugin magic
|
||||
ListElement.casecolor = m_gameList.Color;
|
||||
ListElement.type = TYPE_PLUGIN;
|
||||
m_gameList.push_back(ListElement);
|
||||
}
|
||||
|
||||
static void Create_Homebrew_List(char *FullPath)
|
||||
{
|
||||
if(strcasestr(FullPath, "boot.") == NULL)
|
||||
return;
|
||||
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
|
||||
ListElement.index = m_gameList.size();
|
||||
*strrchr(FullPath, '/') = '\0';
|
||||
strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1);
|
||||
strncpy(ListElement.id, "HB_APP", 6);
|
||||
|
||||
FolderTitle = strrchr(FullPath, '/') + 1;
|
||||
ListElement.casecolor = CustomTitles.getColor("COVERS", FolderTitle, 0xFFFFFF).intVal();
|
||||
const string &CustomTitle = CustomTitles.getString("TITLES", FolderTitle);
|
||||
if(CustomTitle.size() > 0)
|
||||
mbstowcs(ListElement.title, CustomTitle.c_str(), 63);
|
||||
else
|
||||
mbstowcs(ListElement.title, FolderTitle, 63);
|
||||
Asciify(ListElement.title);
|
||||
|
||||
ListElement.type = TYPE_HOMEBREW;
|
||||
m_gameList.push_back(ListElement);
|
||||
}
|
||||
|
||||
Channel *chan = NULL;
|
||||
static void Create_Channel_List()
|
||||
{
|
||||
for(u32 i = 0; i < ChannelHandle.Count(); i++)
|
||||
{
|
||||
chan = ChannelHandle.GetChannel(i);
|
||||
if(chan->id == NULL)
|
||||
continue; // Skip invalid channels
|
||||
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
|
||||
ListElement.index = m_gameList.size();
|
||||
ListElement.settings[0] = TITLE_UPPER(chan->title);
|
||||
ListElement.settings[1] = TITLE_LOWER(chan->title);
|
||||
strncpy(ListElement.id, chan->id, 4);
|
||||
ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, 0xFFFFFF).intVal();
|
||||
const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str();
|
||||
if(gameTDB.IsLoaded())
|
||||
{
|
||||
if(ListElement.casecolor == 0xFFFFFF)
|
||||
ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id);
|
||||
ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id);
|
||||
ListElement.players = gameTDB.GetPlayers(ListElement.id);
|
||||
if(CustomTitle == NULL || CustomTitle[0] == '\0')
|
||||
gameTDB.GetTitle(ListElement.id, CustomTitle);
|
||||
}
|
||||
if(CustomTitle != NULL && CustomTitle[0] != '\0')
|
||||
mbstowcs(ListElement.title, CustomTitle, 63);
|
||||
else
|
||||
wcsncpy(ListElement.title, chan->name, 64);
|
||||
ListElement.type = TYPE_CHANNEL;
|
||||
m_gameList.push_back(ListElement);
|
||||
}
|
||||
}
|
||||
|
||||
void ListGenerator::CreateList(u32 Flow, u32 Device, const string& Path, const vector<string>& FileTypes,
|
||||
const string& DBName, bool UpdateCache)
|
||||
{
|
||||
if(!DBName.empty())
|
||||
{
|
||||
if(UpdateCache)
|
||||
fsop_deleteFile(DBName.c_str());
|
||||
else
|
||||
{
|
||||
CCache(*this, DBName, LOAD);
|
||||
if(!this->empty())
|
||||
return;
|
||||
fsop_deleteFile(DBName.c_str());
|
||||
}
|
||||
}
|
||||
//if(Flow != COVERFLOW_PLUGIN)
|
||||
OpenConfigs();
|
||||
if(Flow == COVERFLOW_WII)
|
||||
{
|
||||
if(DeviceHandle.GetFSType(Device) == PART_FS_WBFS)
|
||||
Create_Wii_WBFS_List(DeviceHandle.GetWbfsHandle(Device));
|
||||
else
|
||||
GetFiles(Path.c_str(), FileTypes, Create_Wii_EXT_List, false);
|
||||
}
|
||||
else if(Flow == COVERFLOW_CHANNEL)
|
||||
{
|
||||
ChannelHandle.Init(gameTDB_Language);
|
||||
Create_Channel_List();
|
||||
}
|
||||
else if(DeviceHandle.GetFSType(Device) != PART_FS_WBFS)
|
||||
{
|
||||
if(Flow == COVERFLOW_GAMECUBE)
|
||||
GetFiles(Path.c_str(), FileTypes, Create_GC_List, true);
|
||||
else if(Flow == COVERFLOW_PLUGIN)
|
||||
GetFiles(Path.c_str(), FileTypes, Create_Plugin_List, false, 30);
|
||||
else if(Flow == COVERFLOW_HOMEBREW)
|
||||
GetFiles(Path.c_str(), FileTypes, Create_Homebrew_List, false);
|
||||
}
|
||||
CloseConfigs();
|
||||
if(!this->empty() && !DBName.empty()) /* Write a new Cache */
|
||||
CCache(*this, DBName, SAVE);
|
||||
}
|
||||
|
||||
static inline bool IsFileSupported(const char *File, const vector<string>& FileTypes)
|
||||
{
|
||||
for(vector<string>::const_iterator cmp = FileTypes.begin(); cmp != FileTypes.end(); ++cmp)
|
||||
{
|
||||
if(strcasecmp(File, cmp->c_str()) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *NewFileName = NULL;
|
||||
char *FullPathChar = NULL;
|
||||
dirent *pent = NULL;
|
||||
DIR *pdir = NULL;
|
||||
void GetFiles(const char *Path, const vector<string>& FileTypes,
|
||||
FileAdder AddFile, bool CompareFolders, u32 max_depth, u32 depth)
|
||||
{
|
||||
vector<string> SubPaths;
|
||||
|
||||
pdir = opendir(Path);
|
||||
if(pdir == NULL)
|
||||
return;
|
||||
while((pent = readdir(pdir)) != NULL)
|
||||
{
|
||||
if(pent->d_name[0] == '.')
|
||||
continue;
|
||||
FullPathChar = fmt("%s/%s", Path, pent->d_name);
|
||||
if(pent->d_type == DT_DIR)
|
||||
{
|
||||
if(CompareFolders && IsFileSupported(pent->d_name, FileTypes))
|
||||
{
|
||||
AddFile(FullPathChar);
|
||||
continue;
|
||||
}
|
||||
else if(depth < max_depth) //thanks libntfs (fail opendir) and thanks seekdir (slowass speed)
|
||||
SubPaths.push_back(FullPathChar);
|
||||
}
|
||||
else if(pent->d_type == DT_REG)
|
||||
{
|
||||
NewFileName = strrchr(pent->d_name, '.');
|
||||
if(NewFileName == NULL) NewFileName = pent->d_name;
|
||||
if(IsFileSupported(NewFileName, FileTypes))
|
||||
{
|
||||
AddFile(FullPathChar);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(pdir);
|
||||
for(vector<string>::const_iterator p = SubPaths.begin(); p != SubPaths.end(); ++p)
|
||||
GetFiles(p->c_str(), FileTypes, AddFile, CompareFolders, max_depth, depth + 1);
|
||||
SubPaths.clear();
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ CMenu::CMenu()
|
||||
m_base_font_size = 0;
|
||||
m_wbf1_font = NULL;
|
||||
m_wbf2_font = NULL;
|
||||
m_current_view = COVERFLOW_USB;
|
||||
m_current_view = COVERFLOW_WII;
|
||||
m_Emulator_boot = false;
|
||||
m_music_info = true;
|
||||
m_prevBg = NULL;
|
||||
@ -325,7 +325,7 @@ void CMenu::init()
|
||||
break;
|
||||
}
|
||||
if (DeviceHandle.IsInserted(i)
|
||||
&& ((m_current_view == COVERFLOW_USB && DeviceHandle.GetFSType(i) == PART_FS_WBFS)
|
||||
&& ((m_current_view == COVERFLOW_WII && DeviceHandle.GetFSType(i) == PART_FS_WBFS)
|
||||
|| stat(fmt(checkDir, DeviceName[i]), &dummy) == 0))
|
||||
{
|
||||
gprintf("Setting Emu NAND to Partition: %i\n",currentPartition);
|
||||
@ -2256,10 +2256,10 @@ bool CMenu::_loadList(void)
|
||||
for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
|
||||
combinedList.push_back(*tmp_itr);
|
||||
}
|
||||
if((m_current_view == COVERFLOW_USB && !m_cfg.has(WII_DOMAIN, "source")) ||
|
||||
if((m_current_view == COVERFLOW_WII && !m_cfg.has(WII_DOMAIN, "source")) ||
|
||||
m_cfg.getBool(WII_DOMAIN, "source"))
|
||||
{
|
||||
m_current_view = COVERFLOW_USB;
|
||||
m_current_view = COVERFLOW_WII;
|
||||
_loadGameList();
|
||||
if(m_combined_view)
|
||||
for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
|
||||
@ -2274,10 +2274,10 @@ bool CMenu::_loadList(void)
|
||||
for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
|
||||
combinedList.push_back(*tmp_itr);
|
||||
}
|
||||
if((m_current_view == COVERFLOW_DML && !m_cfg.has(GC_DOMAIN, "source")) ||
|
||||
if((m_current_view == COVERFLOW_GAMECUBE && !m_cfg.has(GC_DOMAIN, "source")) ||
|
||||
m_cfg.getBool(GC_DOMAIN, "source"))
|
||||
{
|
||||
m_current_view = COVERFLOW_DML;
|
||||
m_current_view = COVERFLOW_GAMECUBE;
|
||||
_loadDmlList();
|
||||
if(m_combined_view)
|
||||
for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
|
||||
@ -2316,7 +2316,7 @@ bool CMenu::_loadGameList(void)
|
||||
string gameDir(fmt(wii_games_dir, DeviceName[currentPartition]));
|
||||
string cacheDir(fmt("%s/%s_wii.db", m_listCacheDir.c_str(), DeviceName[currentPartition]));
|
||||
bool updateCache = m_cfg.getBool(WII_DOMAIN, "update_cache");
|
||||
m_gameList.CreateList(COVERFLOW_USB, currentPartition, gameDir, stringToVector(".wbfs|.iso", '|'), cacheDir, updateCache);
|
||||
m_gameList.CreateList(COVERFLOW_WII, currentPartition, gameDir, stringToVector(".wbfs|.iso", '|'), cacheDir, updateCache);
|
||||
WBFS_Close();
|
||||
m_cfg.remove(WII_DOMAIN, "update_cache");
|
||||
return true;
|
||||
@ -2347,7 +2347,7 @@ bool CMenu::_loadDmlList()
|
||||
string gameDir(fmt(currentPartition == SD ? DML_DIR : m_DMLgameDir.c_str(), DeviceName[currentPartition]));
|
||||
string cacheDir(fmt("%s/%s_gamecube.db", m_listCacheDir.c_str(), DeviceName[currentPartition]));
|
||||
bool updateCache = m_cfg.getBool(GC_DOMAIN, "update_cache");
|
||||
m_gameList.CreateList(COVERFLOW_DML, currentPartition, gameDir,
|
||||
m_gameList.CreateList(COVERFLOW_GAMECUBE, currentPartition, gameDir,
|
||||
stringToVector(".iso|root", '|'),cacheDir, updateCache);
|
||||
m_cfg.remove(GC_DOMAIN, "update_cache");
|
||||
return true;
|
||||
@ -2381,10 +2381,9 @@ bool CMenu::_loadEmuList()
|
||||
if(m_plugin_cfg.loaded())
|
||||
{
|
||||
m_plugin.AddPlugin(m_plugin_cfg);
|
||||
const char *MagicNumber = m_plugin_cfg.getString(PLUGIN_INI_DEF,"magic").c_str();
|
||||
if(!m_cfg.getBool("PLUGIN", MagicNumber, false))
|
||||
u32 MagicWord = strtoul(m_plugin_cfg.getString(PLUGIN_INI_DEF,"magic").c_str(), NULL, 16);
|
||||
if(!m_plugin.GetEnableStatus(m_cfg, MagicWord))
|
||||
continue;
|
||||
u32 MagicWord = strtoul(MagicNumber, NULL, 16);
|
||||
if(m_plugin_cfg.getString(PLUGIN_INI_DEF,"romDir").find("scummvm.ini") == string::npos)
|
||||
{
|
||||
string gameDir(fmt("%s:/%s", DeviceName[currentPartition], m_plugin_cfg.getString(PLUGIN_INI_DEF,"romDir").c_str()));
|
||||
@ -2616,7 +2615,7 @@ const char *CMenu::_domainFromView()
|
||||
return CHANNEL_DOMAIN;
|
||||
case COVERFLOW_HOMEBREW:
|
||||
return HOMEBREW_DOMAIN;
|
||||
case COVERFLOW_DML:
|
||||
case COVERFLOW_GAMECUBE:
|
||||
return GC_DOMAIN;
|
||||
case COVERFLOW_PLUGIN:
|
||||
return PLUGIN_DOMAIN;
|
||||
@ -2630,9 +2629,9 @@ void CMenu::UpdateCache(u32 view)
|
||||
{
|
||||
if(view == COVERFLOW_MAX)
|
||||
{
|
||||
UpdateCache(COVERFLOW_USB);
|
||||
UpdateCache(COVERFLOW_WII);
|
||||
UpdateCache(COVERFLOW_HOMEBREW);
|
||||
UpdateCache(COVERFLOW_DML);
|
||||
UpdateCache(COVERFLOW_GAMECUBE);
|
||||
UpdateCache(COVERFLOW_PLUGIN);
|
||||
UpdateCache(COVERFLOW_CHANNEL);
|
||||
return;
|
||||
@ -2645,7 +2644,7 @@ void CMenu::UpdateCache(u32 view)
|
||||
case COVERFLOW_HOMEBREW:
|
||||
m_cfg.setBool(HOMEBREW_DOMAIN, "update_cache", true);
|
||||
break;
|
||||
case COVERFLOW_DML:
|
||||
case COVERFLOW_GAMECUBE:
|
||||
m_cfg.setBool(GC_DOMAIN, "update_cache", true);
|
||||
break;
|
||||
case COVERFLOW_PLUGIN:
|
||||
|
@ -115,16 +115,16 @@ void CMenu::_getIDCats(void)
|
||||
switch(hdr->type)
|
||||
{
|
||||
case TYPE_CHANNEL:
|
||||
catDomain = "NAND";
|
||||
catDomain = "CHANNELS";
|
||||
break;
|
||||
case TYPE_HOMEBREW:
|
||||
catDomain = "HOMEBREW";
|
||||
break;
|
||||
case TYPE_GC_GAME:
|
||||
catDomain = "DML";
|
||||
catDomain = "GAMECUBE";
|
||||
break;
|
||||
case TYPE_WII_GAME:
|
||||
catDomain = "GAMES";
|
||||
catDomain = "WII";
|
||||
break;
|
||||
default:
|
||||
catDomain = (m_plugin.GetPluginName(m_plugin.GetPluginPosition(hdr->settings[0]))).toUTF8();
|
||||
|
@ -12,7 +12,7 @@ void CMenu::_hideConfig3(bool instant)
|
||||
{
|
||||
_hideConfigCommon(instant);
|
||||
|
||||
if(m_current_view != COVERFLOW_DML)
|
||||
if(m_current_view != COVERFLOW_GAMECUBE)
|
||||
{
|
||||
m_btnMgr.hide(m_config3LblGameLanguage, instant);
|
||||
m_btnMgr.hide(m_config3LblLanguage, instant);
|
||||
@ -49,7 +49,7 @@ void CMenu::_showConfig3(void)
|
||||
{
|
||||
_showConfigCommon(m_config3Bg, g_curPage);
|
||||
|
||||
if(m_current_view != COVERFLOW_DML)
|
||||
if(m_current_view != COVERFLOW_GAMECUBE)
|
||||
{
|
||||
m_btnMgr.show(m_config3LblGameLanguage);
|
||||
m_btnMgr.show(m_config3LblLanguage);
|
||||
@ -84,7 +84,7 @@ void CMenu::_showConfig3(void)
|
||||
|
||||
int i;
|
||||
|
||||
if(m_current_view != COVERFLOW_DML)
|
||||
if(m_current_view != COVERFLOW_GAMECUBE)
|
||||
{
|
||||
i = min(max(0, m_cfg.getInt("GENERAL", "video_mode", 0)), (int)ARRAY_SIZE(CMenu::_GlobalVideoModes) - 1);
|
||||
m_btnMgr.setText(m_config3LblVideo, _t(CMenu::_GlobalVideoModes[i].id, CMenu::_GlobalVideoModes[i].text));
|
||||
|
@ -67,7 +67,7 @@ start_main:
|
||||
|
||||
switch(m_current_view)
|
||||
{
|
||||
case COVERFLOW_DML:
|
||||
case COVERFLOW_GAMECUBE:
|
||||
if(show_channel)
|
||||
m_btnMgr.show(m_mainBtnChannel);
|
||||
else if(show_emu)
|
||||
@ -117,8 +117,8 @@ start_main:
|
||||
{
|
||||
switch(m_current_view)
|
||||
{
|
||||
case COVERFLOW_USB:
|
||||
case COVERFLOW_DML:
|
||||
case COVERFLOW_WII:
|
||||
case COVERFLOW_GAMECUBE:
|
||||
m_btnMgr.setText(m_mainLblInit, _t("main2", L"Welcome to WiiFlow. I have not found any games. Click Install to install games, or Select partition to select your partition type."));
|
||||
m_btnMgr.show(m_mainBtnInit);
|
||||
m_btnMgr.show(m_mainBtnInit2);
|
||||
@ -354,9 +354,9 @@ int CMenu::main(void)
|
||||
{
|
||||
u8 lastView = m_current_view;
|
||||
if(BTN_UP_PRESSED)
|
||||
m_current_view = COVERFLOW_USB;
|
||||
m_current_view = COVERFLOW_WII;
|
||||
else if(BTN_DOWN_PRESSED && (m_show_dml || m_devo_installed || m_nintendont_installed))
|
||||
m_current_view = COVERFLOW_DML;
|
||||
m_current_view = COVERFLOW_GAMECUBE;
|
||||
else if(BTN_LEFT_PRESSED && show_emu)
|
||||
m_current_view = COVERFLOW_PLUGIN;
|
||||
else if(BTN_RIGHT_PRESSED && show_channel)
|
||||
@ -366,10 +366,10 @@ int CMenu::main(void)
|
||||
_clearSources();
|
||||
switch(m_current_view)
|
||||
{
|
||||
case COVERFLOW_USB:
|
||||
case COVERFLOW_WII:
|
||||
m_cfg.setBool(WII_DOMAIN, "source", true);
|
||||
break;
|
||||
case COVERFLOW_DML:
|
||||
case COVERFLOW_GAMECUBE:
|
||||
m_cfg.setBool(GC_DOMAIN, "source", true);
|
||||
break;
|
||||
case COVERFLOW_CHANNEL:
|
||||
@ -412,25 +412,25 @@ int CMenu::main(void)
|
||||
}
|
||||
else if(m_btnMgr.selected(m_mainBtnChannel) || m_btnMgr.selected(m_mainBtnUsb) || m_btnMgr.selected(m_mainBtnDML) || m_btnMgr.selected(m_mainBtnHomebrew) || m_btnMgr.selected(m_mainBtnEmu))
|
||||
{
|
||||
if(m_current_view == COVERFLOW_USB)
|
||||
m_current_view = (m_show_dml || m_devo_installed || m_nintendont_installed) ? COVERFLOW_DML :
|
||||
if(m_current_view == COVERFLOW_WII)
|
||||
m_current_view = (m_show_dml || m_devo_installed || m_nintendont_installed) ? COVERFLOW_GAMECUBE :
|
||||
(show_channel ? COVERFLOW_CHANNEL : (show_emu ? COVERFLOW_PLUGIN :
|
||||
((show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_USB)));
|
||||
else if(m_current_view == COVERFLOW_DML)
|
||||
m_current_view = show_channel ? COVERFLOW_CHANNEL : ((show_emu ? COVERFLOW_PLUGIN : (show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_USB));
|
||||
((show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_WII)));
|
||||
else if(m_current_view == COVERFLOW_GAMECUBE)
|
||||
m_current_view = show_channel ? COVERFLOW_CHANNEL : ((show_emu ? COVERFLOW_PLUGIN : (show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_WII));
|
||||
else if(m_current_view == COVERFLOW_CHANNEL)
|
||||
m_current_view = (show_emu ? COVERFLOW_PLUGIN : (show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_USB);
|
||||
m_current_view = (show_emu ? COVERFLOW_PLUGIN : (show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_WII);
|
||||
else if(m_current_view == COVERFLOW_PLUGIN)
|
||||
m_current_view = (show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_USB;
|
||||
m_current_view = (show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_WII;
|
||||
else if(m_current_view == COVERFLOW_HOMEBREW || m_current_view == COVERFLOW_MAX)
|
||||
m_current_view = COVERFLOW_USB;
|
||||
m_current_view = COVERFLOW_WII;
|
||||
_clearSources();
|
||||
switch(m_current_view)
|
||||
{
|
||||
case COVERFLOW_USB:
|
||||
case COVERFLOW_WII:
|
||||
m_cfg.setBool(WII_DOMAIN, "source", true);
|
||||
break;
|
||||
case COVERFLOW_DML:
|
||||
case COVERFLOW_GAMECUBE:
|
||||
m_cfg.setBool(GC_DOMAIN, "source", true);
|
||||
break;
|
||||
case COVERFLOW_CHANNEL:
|
||||
@ -829,7 +829,7 @@ int CMenu::main(void)
|
||||
{
|
||||
switch(m_current_view)
|
||||
{
|
||||
case COVERFLOW_DML:
|
||||
case COVERFLOW_GAMECUBE:
|
||||
if(show_channel)
|
||||
m_btnMgr.show(m_mainBtnChannel);
|
||||
else if(show_emu)
|
||||
@ -1186,7 +1186,7 @@ void CMenu::_setPartition(s8 direction)
|
||||
m_cfg.setBool(CHANNEL_DOMAIN, "disable", false);
|
||||
switch_to_real = false;
|
||||
}
|
||||
bool NeedFAT = m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_DML;
|
||||
bool NeedFAT = m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_GAMECUBE;
|
||||
|
||||
u8 limiter = 0;
|
||||
do
|
||||
@ -1198,7 +1198,7 @@ void CMenu::_setPartition(s8 direction)
|
||||
limiter++;
|
||||
}
|
||||
while(limiter < 12 && (!DeviceHandle.IsInserted(currentPartition) ||
|
||||
(m_current_view != COVERFLOW_USB && FS_Type == PART_FS_WBFS) ||
|
||||
(m_current_view != COVERFLOW_WII && FS_Type == PART_FS_WBFS) ||
|
||||
(NeedFAT && FS_Type != PART_FS_FAT)));
|
||||
|
||||
if(m_current_view == COVERFLOW_CHANNEL && FS_Type == -1)
|
||||
@ -1226,7 +1226,7 @@ void CMenu::_setPartition(s8 direction)
|
||||
char PluginMagicWord[9];
|
||||
memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
|
||||
strncpy(PluginMagicWord, fmt("%08x", m_plugin.getPluginMagic(i)), 8);
|
||||
m_cfg.setInt("PLUGINS/PARTITION", PluginMagicWord, currentPartition);
|
||||
m_cfg.setInt("PLUGINS_PARTITION", PluginMagicWord, currentPartition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ int CMenu::_FindEmuPart(string &emuPath, bool skipchecks)
|
||||
m_cfg.setString(CHANNEL_DOMAIN, "path", STDEMU_DIR);
|
||||
}
|
||||
}
|
||||
else if(m_current_view == COVERFLOW_USB)
|
||||
else if(m_current_view == COVERFLOW_WII)
|
||||
{
|
||||
emuPart = m_cfg.getInt(WII_DOMAIN, "savepartition", -1);
|
||||
if(emuPart == -1)
|
||||
@ -241,7 +241,7 @@ void CMenu::_showNandEmu(void)
|
||||
if(nandemuPage == 1)
|
||||
{
|
||||
int i;
|
||||
if(((m_current_view == COVERFLOW_CHANNEL && !m_cfg.getBool(CHANNEL_DOMAIN, "disable", true)) || m_current_view == COVERFLOW_USB))
|
||||
if(((m_current_view == COVERFLOW_CHANNEL && !m_cfg.getBool(CHANNEL_DOMAIN, "disable", true)) || m_current_view == COVERFLOW_WII))
|
||||
{
|
||||
m_btnMgr.show(m_nandemuLblEmulation);
|
||||
m_btnMgr.show(m_nandemuLblEmulationVal);
|
||||
@ -249,7 +249,7 @@ void CMenu::_showNandEmu(void)
|
||||
m_btnMgr.show(m_nandemuBtnEmulationM);
|
||||
}
|
||||
|
||||
if((m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_USB))
|
||||
if((m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_WII))
|
||||
{
|
||||
m_btnMgr.show(m_nandemuLblSaveDump);
|
||||
m_btnMgr.show(m_nandemuBtnAll);
|
||||
@ -261,7 +261,7 @@ void CMenu::_showNandEmu(void)
|
||||
i = min(max(0, m_cfg.getInt(CHANNEL_DOMAIN, "emulation", 0)), (int)ARRAY_SIZE(CMenu::_NandEmu) - 1);
|
||||
m_btnMgr.setText(m_nandemuLblEmulationVal, _t(CMenu::_NandEmu[i].id, CMenu::_NandEmu[i].text));
|
||||
}
|
||||
else if (m_current_view == COVERFLOW_USB)
|
||||
else if (m_current_view == COVERFLOW_WII)
|
||||
{
|
||||
i = min(max(0, m_cfg.getInt(WII_DOMAIN, "save_emulation", 0)), (int)ARRAY_SIZE(CMenu::_GlobalSaveEmu) - 1);
|
||||
m_btnMgr.setText(m_nandemuLblEmulationVal, _t(CMenu::_GlobalSaveEmu[i].id, CMenu::_GlobalSaveEmu[i].text));
|
||||
@ -375,7 +375,7 @@ int CMenu::_NandEmuCfg(void)
|
||||
s8 direction = m_btnMgr.selected(m_nandemuBtnEmulationP) ? 1 : -1;
|
||||
if(m_current_view == COVERFLOW_CHANNEL)
|
||||
m_cfg.setInt(CHANNEL_DOMAIN, "emulation", (int)loopNum((u32)m_cfg.getInt(CHANNEL_DOMAIN, "emulation", 0) + direction, ARRAY_SIZE(CMenu::_NandEmu)));
|
||||
else if(m_current_view == COVERFLOW_USB)
|
||||
else if(m_current_view == COVERFLOW_WII)
|
||||
m_cfg.setInt(WII_DOMAIN, "save_emulation", (int)loopNum((u32)m_cfg.getInt(WII_DOMAIN, "save_emulation", 0) + direction, ARRAY_SIZE(CMenu::_GlobalSaveEmu)));
|
||||
_showNandEmu();
|
||||
}
|
||||
@ -459,7 +459,7 @@ int CMenu::_NandEmuCfg(void)
|
||||
{
|
||||
_hideNandEmu(true);
|
||||
u8 tmpView = m_current_view;
|
||||
m_current_view = COVERFLOW_USB;
|
||||
m_current_view = COVERFLOW_WII;
|
||||
string emuPath;
|
||||
_FindEmuPart(emuPath, true);
|
||||
path = _FolderExplorer(NandHandle.GetPath());
|
||||
@ -804,7 +804,7 @@ int CMenu::_AutoCreateNand(void)
|
||||
}
|
||||
else if(m_btnMgr.selected(m_nandemuBtnPartition))
|
||||
{
|
||||
if(m_current_view == COVERFLOW_USB)
|
||||
if(m_current_view == COVERFLOW_WII)
|
||||
{
|
||||
m_tempView = true;
|
||||
m_current_view = COVERFLOW_CHANNEL;
|
||||
@ -813,7 +813,7 @@ int CMenu::_AutoCreateNand(void)
|
||||
_config(1);
|
||||
if(m_tempView)
|
||||
{
|
||||
m_current_view = COVERFLOW_USB;
|
||||
m_current_view = COVERFLOW_WII;
|
||||
m_tempView = false;
|
||||
return 0;
|
||||
}
|
||||
|
@ -113,7 +113,8 @@ void CMenu::_updateSourceBtns(void)
|
||||
{
|
||||
magicNums.clear();
|
||||
magicNums = m_source.getStrings(fmt("BUTTON_%i", i), "magic", ',');
|
||||
if(m_cfg.getBool(PLUGIN_DOMAIN, "source", false) && m_cfg.getBool("PLUGIN", magicNums.at(0), false))
|
||||
u32 magic = strtoul(magicNums.at(0).c_str(), NULL, 16);
|
||||
if(m_cfg.getBool(PLUGIN_DOMAIN, "source", false) && m_plugin.GetEnableStatus(m_cfg, magic))
|
||||
{
|
||||
sourceBtn = i;
|
||||
selectedBtns++;
|
||||
@ -256,13 +257,13 @@ void CMenu::_sourceFlow()
|
||||
_clearSources();
|
||||
if(source == "wii")
|
||||
{
|
||||
m_current_view = COVERFLOW_USB;
|
||||
m_current_view = COVERFLOW_WII;
|
||||
m_cfg.setBool(WII_DOMAIN, "source", true);
|
||||
m_catStartPage = m_source.getInt(btn_selected, "cat_page", 1);
|
||||
}
|
||||
else if(source == "dml")
|
||||
{
|
||||
m_current_view = COVERFLOW_DML;
|
||||
m_current_view = COVERFLOW_GAMECUBE;
|
||||
m_cfg.setBool(GC_DOMAIN, "source", true);
|
||||
m_catStartPage = m_source.getInt(btn_selected, "cat_page", 1);
|
||||
}
|
||||
@ -312,7 +313,7 @@ void CMenu::_sourceFlow()
|
||||
m_plugin.SetEnablePlugin(m_cfg, exist, 2);
|
||||
if(plugin_magic_nums == 1)
|
||||
{
|
||||
currentPartition = m_cfg.getInt("PLUGINS/PARTITION", itr->c_str(), 1);
|
||||
currentPartition = m_cfg.getInt("PLUGINS_PARTITION", itr->c_str(), 1);
|
||||
m_cfg.setInt(PLUGIN_DOMAIN, "partition", currentPartition);
|
||||
}
|
||||
}
|
||||
@ -476,7 +477,7 @@ bool CMenu::_Source()
|
||||
char PluginMagicWord[9];
|
||||
memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
|
||||
strncpy(PluginMagicWord, fmt("%08x", m_plugin.getPluginMagic(i)), 8);
|
||||
currentPartition = m_cfg.getInt("PLUGINS/PARTITION", PluginMagicWord, 1);
|
||||
currentPartition = m_cfg.getInt("PLUGINS_PARTITION", PluginMagicWord, 1);
|
||||
m_cfg.setInt(PLUGIN_DOMAIN, "partition", currentPartition);
|
||||
}
|
||||
u8 sourceCount = 0;
|
||||
@ -669,7 +670,7 @@ bool CMenu::_Source()
|
||||
m_plugin.SetEnablePlugin(m_cfg, exist, 2);
|
||||
if(plugin_magic_nums == 1)
|
||||
{
|
||||
currentPartition = m_cfg.getInt("PLUGINS/PARTITION", itr->c_str(), 1);
|
||||
currentPartition = m_cfg.getInt("PLUGINS_PARTITION", itr->c_str(), 1);
|
||||
m_cfg.setInt(PLUGIN_DOMAIN, "partition", currentPartition);
|
||||
}
|
||||
}
|
||||
|
@ -511,9 +511,9 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
|
||||
//m_gameList.SetLanguage(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str());
|
||||
_showWaitMessage();
|
||||
if(upd_dml)
|
||||
UpdateCache(COVERFLOW_DML);
|
||||
UpdateCache(COVERFLOW_GAMECUBE);
|
||||
if(upd_usb)
|
||||
UpdateCache(COVERFLOW_USB);
|
||||
UpdateCache(COVERFLOW_WII);
|
||||
if(upd_emu)
|
||||
UpdateCache(COVERFLOW_PLUGIN);
|
||||
if(upd_chan)
|
||||
@ -531,9 +531,9 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
|
||||
{
|
||||
if(done && op == WO_COPY_GAME)
|
||||
{
|
||||
UpdateCache(COVERFLOW_DML);
|
||||
UpdateCache(COVERFLOW_GAMECUBE);
|
||||
currentPartition = SD;
|
||||
UpdateCache(COVERFLOW_DML);
|
||||
UpdateCache(COVERFLOW_GAMECUBE);
|
||||
}
|
||||
_loadList();
|
||||
_initCF();
|
||||
|
@ -1,313 +1,313 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2012 FIX94
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#include <gccore.h>
|
||||
#include <ogcsys.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <algorithm>
|
||||
#include "plugin.hpp"
|
||||
#include "fileOps/fileOps.h"
|
||||
#include "gui/text.hpp"
|
||||
#include "gecko/gecko.hpp"
|
||||
#include "devicemounter/PartitionHandle.h"
|
||||
#include "devicemounter/DeviceHandler.hpp"
|
||||
#include "types.h"
|
||||
#include "crc32.h"
|
||||
|
||||
Plugin m_plugin;
|
||||
void Plugin::init(const string& m_pluginsDir)
|
||||
{
|
||||
PluginMagicWord[8] = '\0';
|
||||
pluginsDir = m_pluginsDir;
|
||||
//Ready to add plugins
|
||||
adding = true;
|
||||
}
|
||||
|
||||
static bool PluginOptions_cmp(PluginOptions lhs, PluginOptions rhs)
|
||||
{
|
||||
const wchar_t *first = lhs.DisplayName.c_str();
|
||||
const wchar_t *second = rhs.DisplayName.c_str();
|
||||
return wchar_cmp(first, second, wcslen(first), wcslen(second));
|
||||
}
|
||||
|
||||
void Plugin::EndAdd()
|
||||
{
|
||||
std::sort(Plugins.begin(), Plugins.end(), PluginOptions_cmp);
|
||||
adding = false;
|
||||
}
|
||||
|
||||
void Plugin::Cleanup()
|
||||
{
|
||||
Plugins.clear();
|
||||
adding = true;
|
||||
}
|
||||
|
||||
bool Plugin::AddPlugin(Config &plugin)
|
||||
{
|
||||
if(!adding)
|
||||
return false;
|
||||
|
||||
PluginOptions NewPlugin;
|
||||
NewPlugin.DolName = plugin.getString(PLUGIN_INI_DEF, "dolFile");
|
||||
NewPlugin.coverFolder = plugin.getString(PLUGIN_INI_DEF, "coverFolder");
|
||||
NewPlugin.magicWord = strtoul(plugin.getString(PLUGIN_INI_DEF, "magic").c_str(), NULL, 16);
|
||||
NewPlugin.caseColor = strtoul(plugin.getString(PLUGIN_INI_DEF, "coverColor").c_str(), NULL, 16);
|
||||
NewPlugin.Args = plugin.getStrings(PLUGIN_INI_DEF, "arguments", '|');
|
||||
string PluginName = plugin.getString(PLUGIN_INI_DEF, "displayname");
|
||||
if(PluginName.size() < 2)
|
||||
{
|
||||
PluginName = NewPlugin.DolName;
|
||||
PluginName.erase(PluginName.end() - 4, PluginName.end());
|
||||
}
|
||||
NewPlugin.DisplayName.fromUTF8(PluginName.c_str());
|
||||
NewPlugin.consoleCoverID = plugin.getString(PLUGIN_INI_DEF,"consoleCoverID");
|
||||
|
||||
const string &bannerfilepath = sfmt("%s/%s", pluginsDir.c_str(), plugin.getString(PLUGIN_INI_DEF,"bannerSound").c_str());
|
||||
fsop_GetFileSizeBytes(bannerfilepath.c_str(), &NewPlugin.BannerSoundSize);
|
||||
if(NewPlugin.BannerSoundSize > 0)
|
||||
NewPlugin.BannerSound = bannerfilepath;
|
||||
Plugins.push_back(NewPlugin);
|
||||
return false;
|
||||
}
|
||||
|
||||
s8 Plugin::GetPluginPosition(u32 magic)
|
||||
{
|
||||
for(u8 pos = 0; pos < Plugins.size(); pos++)
|
||||
{
|
||||
if(magic == Plugins[pos].magicWord)
|
||||
return pos;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
u8* Plugin::GetBannerSound(u32 magic)
|
||||
{
|
||||
if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
|
||||
{
|
||||
u32 size = 0;
|
||||
return fsop_ReadFile(Plugins[Plugin_Pos].BannerSound.c_str(), &size);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u32 Plugin::GetBannerSoundSize()
|
||||
{
|
||||
//We call that directly after GetBannerSound, so no need to search for the magic again
|
||||
if(Plugin_Pos >= 0)
|
||||
return Plugins[Plugin_Pos].BannerSoundSize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *Plugin::GetDolName(u32 magic)
|
||||
{
|
||||
if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
|
||||
return Plugins[Plugin_Pos].DolName.c_str();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *Plugin::GetCoverFolderName(u32 magic)
|
||||
{
|
||||
if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
|
||||
return Plugins[Plugin_Pos].coverFolder.c_str();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool Plugin::PluginExist(u8 pos)
|
||||
{
|
||||
if(pos < Plugins.size())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
wstringEx Plugin::GetPluginName(u8 pos)
|
||||
{
|
||||
return Plugins[pos].DisplayName;
|
||||
}
|
||||
|
||||
void Plugin::SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode)
|
||||
{
|
||||
if(pos < Plugins.size())
|
||||
{
|
||||
strncpy(PluginMagicWord, fmt("%08x", Plugins[pos].magicWord), 8);
|
||||
if(ForceMode == 1)
|
||||
cfg.setBool(PLUGIN_INI_DEF, PluginMagicWord, false);
|
||||
else if(ForceMode == 2)
|
||||
cfg.setBool(PLUGIN_INI_DEF, PluginMagicWord, true);
|
||||
else
|
||||
cfg.setBool(PLUGIN_INI_DEF, PluginMagicWord, cfg.getBool(PLUGIN_INI_DEF, PluginMagicWord) ? false : true);
|
||||
}
|
||||
}
|
||||
|
||||
bool Plugin::GetEnableStatus(Config &cfg, u32 magic)
|
||||
{
|
||||
if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
|
||||
{
|
||||
strncpy(PluginMagicWord, fmt("%08x", magic), 8);
|
||||
return cfg.getBool(PLUGIN_INI_DEF, PluginMagicWord, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const vector<bool> &Plugin::GetEnabledPlugins(Config &cfg, u8 *num)
|
||||
{
|
||||
enabledPlugins.clear();
|
||||
u8 enabledPluginsNumber = 0;
|
||||
for(u8 i = 0; i < Plugins.size(); i++)
|
||||
{
|
||||
strncpy(PluginMagicWord, fmt("%08x", Plugins[i].magicWord), 8);
|
||||
if(cfg.getBool(PLUGIN_INI_DEF, PluginMagicWord, true))
|
||||
{
|
||||
enabledPluginsNumber++;
|
||||
enabledPlugins.push_back(true);
|
||||
}
|
||||
else
|
||||
enabledPlugins.push_back(false);
|
||||
}
|
||||
if(enabledPluginsNumber == Plugins.size())
|
||||
enabledPlugins.clear();
|
||||
if(num != NULL)
|
||||
*num = enabledPluginsNumber;
|
||||
return enabledPlugins;
|
||||
}
|
||||
|
||||
u32 Plugin::getPluginMagic(u8 pos)
|
||||
{
|
||||
return Plugins[pos].magicWord;
|
||||
}
|
||||
|
||||
vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 MagicWord)
|
||||
{
|
||||
gprintf("Parsing scummvm.ini\n");
|
||||
vector<dir_discHdr> gameHeader;
|
||||
if(!ini.loaded())
|
||||
return gameHeader;
|
||||
|
||||
const char *GameDomain = ini.firstDomain().c_str();
|
||||
dir_discHdr ListElement;
|
||||
while(1)
|
||||
{
|
||||
if(strlen(GameDomain) < 2)
|
||||
break;
|
||||
const char *GameName = ini.getString(GameDomain, "description").c_str();
|
||||
if(strlen(GameName) < 2 || strncasecmp(Device, ini.getString(GameDomain, "path").c_str(), 2) != 0)
|
||||
{
|
||||
GameDomain = ini.nextDomain().c_str();
|
||||
continue;
|
||||
}
|
||||
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
|
||||
strncpy(ListElement.id, PLUGIN_INI_DEF, 6);
|
||||
ListElement.casecolor = Plugins.back().caseColor;
|
||||
mbstowcs(ListElement.title, GameName, 63);
|
||||
strncpy(ListElement.path, GameDomain, sizeof(ListElement.path));
|
||||
gprintf("Found: %s\n", GameDomain);
|
||||
ListElement.settings[0] = MagicWord;
|
||||
ListElement.type = TYPE_PLUGIN;
|
||||
gameHeader.push_back(ListElement);
|
||||
GameDomain = ini.nextDomain().c_str();
|
||||
}
|
||||
return gameHeader;
|
||||
}
|
||||
|
||||
vector<string> Plugin::CreateArgs(const char *device, const char *path,
|
||||
const char *title, const char *loader, u32 title_len_no_ext, u32 magic)
|
||||
{
|
||||
vector<string> args;
|
||||
Plugin_Pos = GetPluginPosition(magic);
|
||||
if(Plugin_Pos < 0)
|
||||
return args;
|
||||
for(vector<string>::const_iterator arg = Plugins[Plugin_Pos].Args.begin();
|
||||
arg != Plugins[Plugin_Pos].Args.end(); ++arg)
|
||||
{
|
||||
string Argument(*arg);
|
||||
if(Argument.find(PLUGIN_DEV) != string::npos)
|
||||
Argument.replace(Argument.find(PLUGIN_DEV), strlen(PLUGIN_DEV), device);
|
||||
if(Argument.find(PLUGIN_PATH) != string::npos)
|
||||
Argument.replace(Argument.find(PLUGIN_PATH), strlen(PLUGIN_PATH), path);
|
||||
if(Argument.find(PLUGIN_NAME) != string::npos)
|
||||
Argument.replace(Argument.find(PLUGIN_NAME), strlen(PLUGIN_NAME), title);
|
||||
if(Argument.find(PLUGIN_LDR) != string::npos)
|
||||
Argument.replace(Argument.find(PLUGIN_LDR), strlen(PLUGIN_LDR), loader);
|
||||
if(Argument.find(PLUGIN_NOEXT) != string::npos)
|
||||
Argument.replace(Argument.find(PLUGIN_NOEXT), strlen(PLUGIN_NOEXT), title, title_len_no_ext);
|
||||
args.push_back(Argument);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
string Plugin::GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums)
|
||||
{
|
||||
string url(constURL);
|
||||
Plugin_Pos = GetPluginPosition(gameHeader.settings[0]);
|
||||
|
||||
if(url.find(TAG_LOC) != url.npos)
|
||||
url.replace(url.find(TAG_LOC), strlen(TAG_LOC), "EN");
|
||||
|
||||
if(url.find(TAG_CONSOLE) != url.npos)
|
||||
url.replace(url.find(TAG_CONSOLE), strlen(TAG_CONSOLE), (Plugins[Plugin_Pos].consoleCoverID.size() ? Plugins[Plugin_Pos].consoleCoverID.c_str() : "nintendo"));
|
||||
|
||||
char gamePath[256];
|
||||
if(string(gameHeader.path).find_last_of("/") != string::npos)
|
||||
strncpy(gamePath, &gameHeader.path[string(gameHeader.path).find_last_of("/")+1], sizeof(gamePath));
|
||||
else
|
||||
strncpy(gamePath, gameHeader.path, sizeof(gamePath));
|
||||
const string& cachedCRC = Checksums.getString("CHECKSUMS", gamePath);
|
||||
char crc_string[9];
|
||||
crc_string[8] = '\0';
|
||||
if(cachedCRC.size() == 8)
|
||||
{
|
||||
gprintf("CRC32 of %s is cached\n", gamePath);
|
||||
strncpy(crc_string, cachedCRC.c_str(), 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
gprintf("Generating CRC32 for %s\n", gamePath);
|
||||
u32 buffer;
|
||||
ifstream infile;
|
||||
if(strstr(gameHeader.path, ".zip") != NULL)
|
||||
{
|
||||
infile.open(gameHeader.path, ios::binary);
|
||||
infile.seekg(0x0e, ios::beg);
|
||||
infile.read((char*)&buffer, 8);
|
||||
infile.close();
|
||||
strncpy(crc_string, fmt("%08x", (u32)__builtin_bswap32(buffer)), 8);
|
||||
}
|
||||
else if(strstr(gameHeader.path, ".7z") != NULL)
|
||||
{
|
||||
infile.open(gameHeader.path, ios::binary);
|
||||
infile.seekg(-8, ios::end);
|
||||
while(infile.tellg())
|
||||
{
|
||||
infile.read((char*)&buffer, 8);
|
||||
if(buffer == 0x00050111)
|
||||
break;
|
||||
infile.seekg(-9, ios::cur);
|
||||
}
|
||||
infile.seekg(-13, ios::cur);
|
||||
infile.read((char*)&buffer, 8);
|
||||
infile.close();
|
||||
strncpy(crc_string, fmt("%08x", (u32)__builtin_bswap32(buffer)), 8);
|
||||
}
|
||||
else
|
||||
strncpy(crc_string, fmt("%08x", crc32file(gameHeader.path)), 8);
|
||||
Checksums.setString("CHECKSUMS", gamePath, crc_string);
|
||||
Checksums.save();
|
||||
}
|
||||
url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), upperCase(crc_string).c_str());
|
||||
gprintf("URL: %s\n", url.c_str());
|
||||
return url;
|
||||
}
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2012 FIX94
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#include <gccore.h>
|
||||
#include <ogcsys.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <algorithm>
|
||||
#include "plugin.hpp"
|
||||
#include "fileOps/fileOps.h"
|
||||
#include "gui/text.hpp"
|
||||
#include "gecko/gecko.hpp"
|
||||
#include "devicemounter/PartitionHandle.h"
|
||||
#include "devicemounter/DeviceHandler.hpp"
|
||||
#include "types.h"
|
||||
#include "crc32.h"
|
||||
|
||||
Plugin m_plugin;
|
||||
void Plugin::init(const string& m_pluginsDir)
|
||||
{
|
||||
PluginMagicWord[8] = '\0';
|
||||
pluginsDir = m_pluginsDir;
|
||||
//Ready to add plugins
|
||||
adding = true;
|
||||
}
|
||||
|
||||
static bool PluginOptions_cmp(PluginOptions lhs, PluginOptions rhs)
|
||||
{
|
||||
const wchar_t *first = lhs.DisplayName.c_str();
|
||||
const wchar_t *second = rhs.DisplayName.c_str();
|
||||
return wchar_cmp(first, second, wcslen(first), wcslen(second));
|
||||
}
|
||||
|
||||
void Plugin::EndAdd()
|
||||
{
|
||||
std::sort(Plugins.begin(), Plugins.end(), PluginOptions_cmp);
|
||||
adding = false;
|
||||
}
|
||||
|
||||
void Plugin::Cleanup()
|
||||
{
|
||||
Plugins.clear();
|
||||
adding = true;
|
||||
}
|
||||
|
||||
bool Plugin::AddPlugin(Config &plugin)
|
||||
{
|
||||
if(!adding)
|
||||
return false;
|
||||
|
||||
PluginOptions NewPlugin;
|
||||
NewPlugin.DolName = plugin.getString(PLUGIN_INI_DEF, "dolFile");
|
||||
NewPlugin.coverFolder = plugin.getString(PLUGIN_INI_DEF, "coverFolder");
|
||||
NewPlugin.magicWord = strtoul(plugin.getString(PLUGIN_INI_DEF, "magic").c_str(), NULL, 16);
|
||||
NewPlugin.caseColor = strtoul(plugin.getString(PLUGIN_INI_DEF, "coverColor").c_str(), NULL, 16);
|
||||
NewPlugin.Args = plugin.getStrings(PLUGIN_INI_DEF, "arguments", '|');
|
||||
string PluginName = plugin.getString(PLUGIN_INI_DEF, "displayname");
|
||||
if(PluginName.size() < 2)
|
||||
{
|
||||
PluginName = NewPlugin.DolName;
|
||||
PluginName.erase(PluginName.end() - 4, PluginName.end());
|
||||
}
|
||||
NewPlugin.DisplayName.fromUTF8(PluginName.c_str());
|
||||
NewPlugin.consoleCoverID = plugin.getString(PLUGIN_INI_DEF,"consoleCoverID");
|
||||
|
||||
const string &bannerfilepath = sfmt("%s/%s", pluginsDir.c_str(), plugin.getString(PLUGIN_INI_DEF,"bannerSound").c_str());
|
||||
fsop_GetFileSizeBytes(bannerfilepath.c_str(), &NewPlugin.BannerSoundSize);
|
||||
if(NewPlugin.BannerSoundSize > 0)
|
||||
NewPlugin.BannerSound = bannerfilepath;
|
||||
Plugins.push_back(NewPlugin);
|
||||
return false;
|
||||
}
|
||||
|
||||
s8 Plugin::GetPluginPosition(u32 magic)
|
||||
{
|
||||
for(u8 pos = 0; pos < Plugins.size(); pos++)
|
||||
{
|
||||
if(magic == Plugins[pos].magicWord)
|
||||
return pos;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
u8* Plugin::GetBannerSound(u32 magic)
|
||||
{
|
||||
if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
|
||||
{
|
||||
u32 size = 0;
|
||||
return fsop_ReadFile(Plugins[Plugin_Pos].BannerSound.c_str(), &size);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u32 Plugin::GetBannerSoundSize()
|
||||
{
|
||||
//We call that directly after GetBannerSound, so no need to search for the magic again
|
||||
if(Plugin_Pos >= 0)
|
||||
return Plugins[Plugin_Pos].BannerSoundSize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *Plugin::GetDolName(u32 magic)
|
||||
{
|
||||
if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
|
||||
return Plugins[Plugin_Pos].DolName.c_str();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *Plugin::GetCoverFolderName(u32 magic)
|
||||
{
|
||||
if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
|
||||
return Plugins[Plugin_Pos].coverFolder.c_str();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool Plugin::PluginExist(u8 pos)
|
||||
{
|
||||
if(pos < Plugins.size())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
wstringEx Plugin::GetPluginName(u8 pos)
|
||||
{
|
||||
return Plugins[pos].DisplayName;
|
||||
}
|
||||
|
||||
void Plugin::SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode)
|
||||
{
|
||||
if(pos < Plugins.size())
|
||||
{
|
||||
strncpy(PluginMagicWord, fmt("%08x", Plugins[pos].magicWord), 8);
|
||||
if(ForceMode == 1)
|
||||
cfg.setBool(PLUGIN_ENABLED, PluginMagicWord, false);
|
||||
else if(ForceMode == 2)
|
||||
cfg.setBool(PLUGIN_ENABLED, PluginMagicWord, true);
|
||||
else
|
||||
cfg.setBool(PLUGIN_ENABLED, PluginMagicWord, cfg.getBool(PLUGIN_ENABLED, PluginMagicWord) ? false : true);
|
||||
}
|
||||
}
|
||||
|
||||
bool Plugin::GetEnableStatus(Config &cfg, u32 magic)
|
||||
{
|
||||
if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
|
||||
{
|
||||
strncpy(PluginMagicWord, fmt("%08x", magic), 8);
|
||||
return cfg.getBool(PLUGIN_ENABLED, PluginMagicWord, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const vector<bool> &Plugin::GetEnabledPlugins(Config &cfg, u8 *num)
|
||||
{
|
||||
enabledPlugins.clear();
|
||||
u8 enabledPluginsNumber = 0;
|
||||
for(u8 i = 0; i < Plugins.size(); i++)
|
||||
{
|
||||
strncpy(PluginMagicWord, fmt("%08x", Plugins[i].magicWord), 8);
|
||||
if(cfg.getBool(PLUGIN_ENABLED, PluginMagicWord, true))
|
||||
{
|
||||
enabledPluginsNumber++;
|
||||
enabledPlugins.push_back(true);
|
||||
}
|
||||
else
|
||||
enabledPlugins.push_back(false);
|
||||
}
|
||||
if(enabledPluginsNumber == Plugins.size())
|
||||
enabledPlugins.clear();
|
||||
if(num != NULL)
|
||||
*num = enabledPluginsNumber;
|
||||
return enabledPlugins;
|
||||
}
|
||||
|
||||
u32 Plugin::getPluginMagic(u8 pos)
|
||||
{
|
||||
return Plugins[pos].magicWord;
|
||||
}
|
||||
|
||||
vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 MagicWord)
|
||||
{
|
||||
gprintf("Parsing scummvm.ini\n");
|
||||
vector<dir_discHdr> gameHeader;
|
||||
if(!ini.loaded())
|
||||
return gameHeader;
|
||||
|
||||
const char *GameDomain = ini.firstDomain().c_str();
|
||||
dir_discHdr ListElement;
|
||||
while(1)
|
||||
{
|
||||
if(strlen(GameDomain) < 2)
|
||||
break;
|
||||
const char *GameName = ini.getString(GameDomain, "description").c_str();
|
||||
if(strlen(GameName) < 2 || strncasecmp(Device, ini.getString(GameDomain, "path").c_str(), 2) != 0)
|
||||
{
|
||||
GameDomain = ini.nextDomain().c_str();
|
||||
continue;
|
||||
}
|
||||
memset((void*)&ListElement, 0, sizeof(dir_discHdr));
|
||||
strncpy(ListElement.id, PLUGIN_INI_DEF, 6);
|
||||
ListElement.casecolor = Plugins.back().caseColor;
|
||||
mbstowcs(ListElement.title, GameName, 63);
|
||||
strncpy(ListElement.path, GameDomain, sizeof(ListElement.path));
|
||||
gprintf("Found: %s\n", GameDomain);
|
||||
ListElement.settings[0] = MagicWord;
|
||||
ListElement.type = TYPE_PLUGIN;
|
||||
gameHeader.push_back(ListElement);
|
||||
GameDomain = ini.nextDomain().c_str();
|
||||
}
|
||||
return gameHeader;
|
||||
}
|
||||
|
||||
vector<string> Plugin::CreateArgs(const char *device, const char *path,
|
||||
const char *title, const char *loader, u32 title_len_no_ext, u32 magic)
|
||||
{
|
||||
vector<string> args;
|
||||
Plugin_Pos = GetPluginPosition(magic);
|
||||
if(Plugin_Pos < 0)
|
||||
return args;
|
||||
for(vector<string>::const_iterator arg = Plugins[Plugin_Pos].Args.begin();
|
||||
arg != Plugins[Plugin_Pos].Args.end(); ++arg)
|
||||
{
|
||||
string Argument(*arg);
|
||||
if(Argument.find(PLUGIN_DEV) != string::npos)
|
||||
Argument.replace(Argument.find(PLUGIN_DEV), strlen(PLUGIN_DEV), device);
|
||||
if(Argument.find(PLUGIN_PATH) != string::npos)
|
||||
Argument.replace(Argument.find(PLUGIN_PATH), strlen(PLUGIN_PATH), path);
|
||||
if(Argument.find(PLUGIN_NAME) != string::npos)
|
||||
Argument.replace(Argument.find(PLUGIN_NAME), strlen(PLUGIN_NAME), title);
|
||||
if(Argument.find(PLUGIN_LDR) != string::npos)
|
||||
Argument.replace(Argument.find(PLUGIN_LDR), strlen(PLUGIN_LDR), loader);
|
||||
if(Argument.find(PLUGIN_NOEXT) != string::npos)
|
||||
Argument.replace(Argument.find(PLUGIN_NOEXT), strlen(PLUGIN_NOEXT), title, title_len_no_ext);
|
||||
args.push_back(Argument);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
string Plugin::GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums)
|
||||
{
|
||||
string url(constURL);
|
||||
Plugin_Pos = GetPluginPosition(gameHeader.settings[0]);
|
||||
|
||||
if(url.find(TAG_LOC) != url.npos)
|
||||
url.replace(url.find(TAG_LOC), strlen(TAG_LOC), "EN");
|
||||
|
||||
if(url.find(TAG_CONSOLE) != url.npos)
|
||||
url.replace(url.find(TAG_CONSOLE), strlen(TAG_CONSOLE), (Plugins[Plugin_Pos].consoleCoverID.size() ? Plugins[Plugin_Pos].consoleCoverID.c_str() : "nintendo"));
|
||||
|
||||
char gamePath[256];
|
||||
if(string(gameHeader.path).find_last_of("/") != string::npos)
|
||||
strncpy(gamePath, &gameHeader.path[string(gameHeader.path).find_last_of("/")+1], sizeof(gamePath));
|
||||
else
|
||||
strncpy(gamePath, gameHeader.path, sizeof(gamePath));
|
||||
const string& cachedCRC = Checksums.getString("CHECKSUMS", gamePath);
|
||||
char crc_string[9];
|
||||
crc_string[8] = '\0';
|
||||
if(cachedCRC.size() == 8)
|
||||
{
|
||||
gprintf("CRC32 of %s is cached\n", gamePath);
|
||||
strncpy(crc_string, cachedCRC.c_str(), 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
gprintf("Generating CRC32 for %s\n", gamePath);
|
||||
u32 buffer;
|
||||
ifstream infile;
|
||||
if(strstr(gameHeader.path, ".zip") != NULL)
|
||||
{
|
||||
infile.open(gameHeader.path, ios::binary);
|
||||
infile.seekg(0x0e, ios::beg);
|
||||
infile.read((char*)&buffer, 8);
|
||||
infile.close();
|
||||
strncpy(crc_string, fmt("%08x", (u32)__builtin_bswap32(buffer)), 8);
|
||||
}
|
||||
else if(strstr(gameHeader.path, ".7z") != NULL)
|
||||
{
|
||||
infile.open(gameHeader.path, ios::binary);
|
||||
infile.seekg(-8, ios::end);
|
||||
while(infile.tellg())
|
||||
{
|
||||
infile.read((char*)&buffer, 8);
|
||||
if(buffer == 0x00050111)
|
||||
break;
|
||||
infile.seekg(-9, ios::cur);
|
||||
}
|
||||
infile.seekg(-13, ios::cur);
|
||||
infile.read((char*)&buffer, 8);
|
||||
infile.close();
|
||||
strncpy(crc_string, fmt("%08x", (u32)__builtin_bswap32(buffer)), 8);
|
||||
}
|
||||
else
|
||||
strncpy(crc_string, fmt("%08x", crc32file(gameHeader.path)), 8);
|
||||
Checksums.setString("CHECKSUMS", gamePath, crc_string);
|
||||
Checksums.save();
|
||||
}
|
||||
url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), upperCase(crc_string).c_str());
|
||||
gprintf("URL: %s\n", url.c_str());
|
||||
return url;
|
||||
}
|
||||
|
@ -1,87 +1,88 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2012 FIX94
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#ifndef _PLUGIN_HPP_
|
||||
#define _PLUGIN_HPP_
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "config/config.hpp"
|
||||
#include "loader/disc.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define TAG_GAME_ID "{gameid}"
|
||||
#define TAG_LOC "{loc}"
|
||||
#define TAG_CONSOLE "{console}"
|
||||
|
||||
#define PLUGIN_INI_DEF "PLUGIN"
|
||||
#define PLUGIN_DEV "{device}"
|
||||
#define PLUGIN_PATH "{path}"
|
||||
#define PLUGIN_NAME "{name}"
|
||||
#define PLUGIN_NOEXT "{name_no_ext}"
|
||||
#define PLUGIN_LDR "{loader}"
|
||||
|
||||
struct PluginOptions
|
||||
{
|
||||
u32 magicWord;
|
||||
u32 caseColor;
|
||||
string DolName;
|
||||
string coverFolder;
|
||||
string consoleCoverID;
|
||||
string BannerSound;
|
||||
u32 BannerSoundSize;
|
||||
vector<string> Args;
|
||||
wstringEx DisplayName;
|
||||
};
|
||||
|
||||
class Plugin
|
||||
{
|
||||
public:
|
||||
bool AddPlugin(Config &plugin);
|
||||
u8 *GetBannerSound(u32 magic);
|
||||
u32 GetBannerSoundSize();
|
||||
const char *GetDolName(u32 magic);
|
||||
const char *GetCoverFolderName(u32 magic);
|
||||
bool GetEnableStatus(Config &cfg, u32 magic);
|
||||
string GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums);
|
||||
wstringEx GetPluginName(u8 pos);
|
||||
u32 getPluginMagic(u8 pos);
|
||||
bool PluginExist(u8 pos);
|
||||
void SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode = 0);
|
||||
const vector<bool> &GetEnabledPlugins(Config &cfg, u8 *num);
|
||||
vector<string> CreateArgs(const char *device, const char *path,
|
||||
const char *title, const char *loader, u32 title_len_no_ext, u32 magic);
|
||||
void init(const string& m_pluginsDir);
|
||||
void Cleanup();
|
||||
void EndAdd();
|
||||
vector<dir_discHdr> ParseScummvmINI(Config &ini, const char *Device, u32 MagicWord);
|
||||
s8 GetPluginPosition(u32 magic);
|
||||
private:
|
||||
vector<PluginOptions> Plugins;
|
||||
vector<bool> enabledPlugins;
|
||||
char PluginMagicWord[9];
|
||||
s8 Plugin_Pos;
|
||||
string pluginsDir;
|
||||
bool adding;
|
||||
};
|
||||
|
||||
extern Plugin m_plugin;
|
||||
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2012 FIX94
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#ifndef _PLUGIN_HPP_
|
||||
#define _PLUGIN_HPP_
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "config/config.hpp"
|
||||
#include "loader/disc.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define TAG_GAME_ID "{gameid}"
|
||||
#define TAG_LOC "{loc}"
|
||||
#define TAG_CONSOLE "{console}"
|
||||
|
||||
#define PLUGIN_INI_DEF "PLUGIN"
|
||||
#define PLUGIN_ENABLED "PLUGINS_ENABLED"
|
||||
#define PLUGIN_DEV "{device}"
|
||||
#define PLUGIN_PATH "{path}"
|
||||
#define PLUGIN_NAME "{name}"
|
||||
#define PLUGIN_NOEXT "{name_no_ext}"
|
||||
#define PLUGIN_LDR "{loader}"
|
||||
|
||||
struct PluginOptions
|
||||
{
|
||||
u32 magicWord;
|
||||
u32 caseColor;
|
||||
string DolName;
|
||||
string coverFolder;
|
||||
string consoleCoverID;
|
||||
string BannerSound;
|
||||
u32 BannerSoundSize;
|
||||
vector<string> Args;
|
||||
wstringEx DisplayName;
|
||||
};
|
||||
|
||||
class Plugin
|
||||
{
|
||||
public:
|
||||
bool AddPlugin(Config &plugin);
|
||||
u8 *GetBannerSound(u32 magic);
|
||||
u32 GetBannerSoundSize();
|
||||
const char *GetDolName(u32 magic);
|
||||
const char *GetCoverFolderName(u32 magic);
|
||||
bool GetEnableStatus(Config &cfg, u32 magic);
|
||||
string GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums);
|
||||
wstringEx GetPluginName(u8 pos);
|
||||
u32 getPluginMagic(u8 pos);
|
||||
bool PluginExist(u8 pos);
|
||||
void SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode = 0);
|
||||
const vector<bool> &GetEnabledPlugins(Config &cfg, u8 *num);
|
||||
vector<string> CreateArgs(const char *device, const char *path,
|
||||
const char *title, const char *loader, u32 title_len_no_ext, u32 magic);
|
||||
void init(const string& m_pluginsDir);
|
||||
void Cleanup();
|
||||
void EndAdd();
|
||||
vector<dir_discHdr> ParseScummvmINI(Config &ini, const char *Device, u32 MagicWord);
|
||||
s8 GetPluginPosition(u32 magic);
|
||||
private:
|
||||
vector<PluginOptions> Plugins;
|
||||
vector<bool> enabledPlugins;
|
||||
char PluginMagicWord[9];
|
||||
s8 Plugin_Pos;
|
||||
string pluginsDir;
|
||||
bool adding;
|
||||
};
|
||||
|
||||
extern Plugin m_plugin;
|
||||
|
||||
#endif
|
||||
|
110
source/types.h
110
source/types.h
@ -1,56 +1,56 @@
|
||||
|
||||
#ifndef _TYPES_H_
|
||||
#define _TYPES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
COVERFLOW_USB = 0,
|
||||
COVERFLOW_DML,
|
||||
COVERFLOW_CHANNEL,
|
||||
COVERFLOW_PLUGIN,
|
||||
COVERFLOW_HOMEBREW,
|
||||
COVERFLOW_MAX
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TYPE_WII_DISC = 0,
|
||||
TYPE_WII_WBFS,
|
||||
TYPE_WII_WBFS_EXT,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TYPE_WII_GAME = 0,
|
||||
TYPE_GC_GAME,
|
||||
TYPE_CHANNEL,
|
||||
TYPE_PLUGIN,
|
||||
TYPE_HOMEBREW,
|
||||
TYPE_SOURCE,
|
||||
TYPE_END
|
||||
};
|
||||
#define NoGameID(x) (x == TYPE_PLUGIN || x == TYPE_HOMEBREW || x == TYPE_SOURCE)
|
||||
|
||||
enum
|
||||
{
|
||||
IOS_TYPE_D2X = 0,
|
||||
IOS_TYPE_WANIN,
|
||||
IOS_TYPE_HERMES,
|
||||
IOS_TYPE_KWIIRK,
|
||||
IOS_TYPE_NEEK2O,
|
||||
IOS_TYPE_NORMAL_IOS,
|
||||
IOS_TYPE_STUB,
|
||||
};
|
||||
#define CustomIOS(x) (x != IOS_TYPE_NORMAL_IOS && x != IOS_TYPE_STUB)
|
||||
|
||||
#define ValidColor(x) (x == 0xFFFFFF || x == 0xFF0000 || x == 0x000000 || \
|
||||
x == 0xFCFF00 || x == 0x01A300 || x == 0x00E360)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _TYPES_H_
|
||||
#define _TYPES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
COVERFLOW_WII = 0,
|
||||
COVERFLOW_GAMECUBE,
|
||||
COVERFLOW_CHANNEL,
|
||||
COVERFLOW_PLUGIN,
|
||||
COVERFLOW_HOMEBREW,
|
||||
COVERFLOW_MAX
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TYPE_WII_DISC = 0,
|
||||
TYPE_WII_WBFS,
|
||||
TYPE_WII_WBFS_EXT,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TYPE_WII_GAME = 0,
|
||||
TYPE_GC_GAME,
|
||||
TYPE_CHANNEL,
|
||||
TYPE_PLUGIN,
|
||||
TYPE_HOMEBREW,
|
||||
TYPE_SOURCE,
|
||||
TYPE_END
|
||||
};
|
||||
#define NoGameID(x) (x == TYPE_PLUGIN || x == TYPE_HOMEBREW || x == TYPE_SOURCE)
|
||||
|
||||
enum
|
||||
{
|
||||
IOS_TYPE_D2X = 0,
|
||||
IOS_TYPE_WANIN,
|
||||
IOS_TYPE_HERMES,
|
||||
IOS_TYPE_KWIIRK,
|
||||
IOS_TYPE_NEEK2O,
|
||||
IOS_TYPE_NORMAL_IOS,
|
||||
IOS_TYPE_STUB,
|
||||
};
|
||||
#define CustomIOS(x) (x != IOS_TYPE_NORMAL_IOS && x != IOS_TYPE_STUB)
|
||||
|
||||
#define ValidColor(x) (x == 0xFFFFFF || x == 0xFF0000 || x == 0x000000 || \
|
||||
x == 0xFCFF00 || x == 0x01A300 || x == 0x00E360)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user