-changed name to WiiFlow Lite

-renamed some coverflows and domains for easier code reading. making things more uniform.
This commit is contained in:
fledge68 2016-04-02 16:00:47 +00:00
parent 7bad8c3fd3
commit 86d768c829
12 changed files with 912 additions and 911 deletions

View File

@ -1,62 +1,62 @@
#define APP_NAME "WiiFlow" #define APP_NAME "WiiFlow Lite"
#define APP_VERSION "Beta 4.2.2" #define APP_VERSION "Beta 4.2.2"
#define APPDATA_DIR "wiiflow" #define APPDATA_DIR "wiiflow"
#define APPDATA_DIR2 "apps/wiiflow" #define APPDATA_DIR2 "apps/wiiflow"
#define STDEMU_DIR "/wiiflow/nandemu" #define STDEMU_DIR "/wiiflow/nandemu"
#define GAMES_DIR "%s:/wbfs" #define GAMES_DIR "%s:/wbfs"
#define HOMEBREW_DIR "%s:/apps" #define HOMEBREW_DIR "%s:/apps"
#define DML_DIR "%s:/games" #define DML_DIR "%s:/games"
#define CFG_FILENAME "wiiflow.ini" #define CFG_FILENAME "wiiflow_lite.ini"
#define LANG_FILENAME "languages.ini" #define LANG_FILENAME "languages.ini"
#define CAT_FILENAME "categories_v4.ini" #define CAT_FILENAME "categories_lite.ini"
#define SOURCE_FILENAME "source_menu.ini" #define SOURCE_FILENAME "source_menu.ini"
#define TITLES_FILENAME "titles.ini" #define TITLES_FILENAME "titles.ini"
#define CTITLES_FILENAME "custom_titles.ini" #define CTITLES_FILENAME "custom_titles.ini"
#define AGE_LOCK_FILENAME "age_lock.ini" #define AGE_LOCK_FILENAME "age_lock.ini"
#define TITLES_DUMP_FILENAME "titlesdump.ini" #define TITLES_DUMP_FILENAME "titlesdump.ini"
#define GAME_SETTINGS1_FILENAME "gameconfig1.ini" #define GAME_SETTINGS1_FILENAME "gameconfig1.ini"
#define GAME_SETTINGS2_FILENAME "gameconfig2.ini" #define GAME_SETTINGS2_FILENAME "gameconfig2.ini"
#define PLUGIN_CRCS_FILENAME "plugin_crc32.ini" #define PLUGIN_CRCS_FILENAME "plugin_crc32.ini"
#define WII_DOMAIN "GAMES" #define WII_DOMAIN "WII"
#define GC_DOMAIN "DML" #define GC_DOMAIN "GAMECUBE"
#define CHANNEL_DOMAIN "NAND" #define CHANNEL_DOMAIN "CHANNELS"
#define PLUGIN_DOMAIN "EMULATOR" #define PLUGIN_DOMAIN "PLUGINS"
#define HOMEBREW_DOMAIN "HOMEBREW" #define HOMEBREW_DOMAIN "HOMEBREW"
#define MUSIC_DOMAIN "MUSIC" #define MUSIC_DOMAIN "MUSIC"
#define FTP_DOMAIN "FTP" #define FTP_DOMAIN "FTP"
#define AGE_LOCK_DEFAULT 13 #define AGE_LOCK_DEFAULT 13
#define DEVELOPERS "FIX94, Fledge68, OverjoY" #define DEVELOPERS "FIX94, Fledge68, OverjoY"
#define PAST_DEVELOPERS "Hibernatus, Narolez, Hulk, Miigotu, r-win" #define PAST_DEVELOPERS "Hibernatus, Narolez, Hulk, Miigotu, r-win"
#define LOADER_AUTHOR "Kwiirk, Waninkoko, Hermes" #define LOADER_AUTHOR "Kwiirk, Waninkoko, Hermes"
#define GUI_AUTHOR "Hibernatus" #define GUI_AUTHOR "Hibernatus"
#define THANKS \ #define THANKS \
"Lustar, CedWii, Benjay, Domi78, Oops, \ "Lustar, CedWii, Benjay, Domi78, Oops, \
Celtiore, Jiiwah, FluffyKiwi, Roku93, Yardape8000, \ Celtiore, Jiiwah, FluffyKiwi, Roku93, Yardape8000, \
Spayrosam, Bluescreen81, Chappy23, mamule, seam, \ Spayrosam, Bluescreen81, Chappy23, mamule, seam, \
BlindDude, Bubba, DJTaz, OggZee, entropy, Ayatus, \ BlindDude, Bubba, DJTaz, OggZee, entropy, Ayatus, \
Usptactical, WiiPower, Hermes, Spidy1000, megazig, \ Usptactical, WiiPower, Hermes, Spidy1000, megazig, \
Dimok, Kovani, Drexyl, DvZ, Etheboss, stfour, \ Dimok, Kovani, Drexyl, DvZ, Etheboss, stfour, \
GaiaKnight, nibb, NJ7, Plasma, Pakatus, giantpune, \ GaiaKnight, nibb, NJ7, Plasma, Pakatus, giantpune, \
wolf, ravmn, spidercaleb, Ziggy34, xFede, Abz, \ wolf, ravmn, spidercaleb, Ziggy34, xFede, Abz, \
and to anyone who has donated or \ and to anyone who has donated or \
contributed to Wiiflow that we missed!" contributed to Wiiflow that we missed!"
#define THANKS_SITES \ #define THANKS_SITES \
"devkitpro.org, wiibrew.org, gametdb.com, \ "devkitpro.org, wiibrew.org, gametdb.com, \
ohloh.net, wiifanart.com, wiiflowiki.com, \ ohloh.net, wiifanart.com, wiiflowiki.com, \
tgames.fr.nf" tgames.fr.nf"
#define THANKS_CODE \ #define THANKS_CODE \
"CFG Loader, Wii Banner Player Project, USB Loader GX, \ "CFG Loader, Wii Banner Player Project, USB Loader GX, \
uLoader, NeoGamma, Mighty Channels, WiiXplorer, Triiforce, \ uLoader, NeoGamma, Mighty Channels, WiiXplorer, Triiforce, \
postLoader" postLoader"
#define WIINNERTAG_URL "http://www.wiinnertag.com/wiinnertag_scripts/update_sign.php?key={KEY}&game_id={ID6}" #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 DUTAG_URL "http://tag.darkumbra.net/{KEY}.update={ID6}"

View File

@ -1,334 +1,334 @@
/**************************************************************************** /****************************************************************************
* Copyright (C) 2012 FIX94 * Copyright (C) 2012 FIX94
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#include <dirent.h> #include <dirent.h>
#include <unistd.h> #include <unistd.h>
#include "ListGenerator.hpp" #include "ListGenerator.hpp"
#include "cache.hpp" #include "cache.hpp"
#include "channel/channels.h" #include "channel/channels.h"
#include "devicemounter/DeviceHandler.hpp" #include "devicemounter/DeviceHandler.hpp"
#include "fileOps/fileOps.h" #include "fileOps/fileOps.h"
#include "gui/coverflow.hpp" #include "gui/coverflow.hpp"
#include "gui/text.hpp" #include "gui/text.hpp"
ListGenerator m_gameList; ListGenerator m_gameList;
Config CustomTitles; Config CustomTitles;
GameTDB gameTDB; GameTDB gameTDB;
dir_discHdr ListElement; dir_discHdr ListElement;
void ListGenerator::Init(const char *settingsDir, const char *Language) void ListGenerator::Init(const char *settingsDir, const char *Language)
{ {
if(settingsDir != NULL) if(settingsDir != NULL)
{ {
gameTDB_Path = fmt("%s/wiitdb.xml", settingsDir); gameTDB_Path = fmt("%s/wiitdb.xml", settingsDir);
CustomTitlesPath = fmt("%s/" CTITLES_FILENAME, settingsDir); CustomTitlesPath = fmt("%s/" CTITLES_FILENAME, settingsDir);
} }
if(Language != NULL) gameTDB_Language = Language; if(Language != NULL) gameTDB_Language = Language;
} }
void ListGenerator::OpenConfigs() void ListGenerator::OpenConfigs()
{ {
gameTDB.OpenFile(gameTDB_Path.c_str()); gameTDB.OpenFile(gameTDB_Path.c_str());
if(gameTDB.IsLoaded()) if(gameTDB.IsLoaded())
gameTDB.SetLanguageCode(gameTDB_Language.c_str()); gameTDB.SetLanguageCode(gameTDB_Language.c_str());
CustomTitles.load(CustomTitlesPath.c_str()); CustomTitles.load(CustomTitlesPath.c_str());
} }
void ListGenerator::CloseConfigs() void ListGenerator::CloseConfigs()
{ {
if(gameTDB.IsLoaded()) if(gameTDB.IsLoaded())
gameTDB.CloseFile(); gameTDB.CloseFile();
if(CustomTitles.loaded()) if(CustomTitles.loaded())
CustomTitles.unload(); CustomTitles.unload();
} }
/* /*
static const u32 LIST_TMP_SIZE = 5000; static const u32 LIST_TMP_SIZE = 5000;
dir_discHdr *tmpList = NULL; dir_discHdr *tmpList = NULL;
u32 tmpListPos = 0; u32 tmpListPos = 0;
static void AddToList(const dir_discHdr *element) static void AddToList(const dir_discHdr *element)
{ {
} }
*/ */
static void AddISO(const char *GameID, const char *GameTitle, const char *GamePath, static void AddISO(const char *GameID, const char *GameTitle, const char *GamePath,
u32 GameColor, u8 Type) u32 GameColor, u8 Type)
{ {
memset((void*)&ListElement, 0, sizeof(dir_discHdr)); memset((void*)&ListElement, 0, sizeof(dir_discHdr));
ListElement.index = m_gameList.size(); ListElement.index = m_gameList.size();
if(GameID != NULL) strncpy(ListElement.id, GameID, 6); if(GameID != NULL) strncpy(ListElement.id, GameID, 6);
if(GamePath != NULL) strncpy(ListElement.path, GamePath, sizeof(ListElement.path) - 1); if(GamePath != NULL) strncpy(ListElement.path, GamePath, sizeof(ListElement.path) - 1);
ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, GameColor).intVal(); ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, GameColor).intVal();
const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str(); const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str();
if(gameTDB.IsLoaded()) if(gameTDB.IsLoaded())
{ {
if(ListElement.casecolor == GameColor) if(ListElement.casecolor == GameColor)
ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id); ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id);
ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id); ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id);
ListElement.players = gameTDB.GetPlayers(ListElement.id); ListElement.players = gameTDB.GetPlayers(ListElement.id);
if(CustomTitle == NULL || CustomTitle[0] == '\0') if(CustomTitle == NULL || CustomTitle[0] == '\0')
gameTDB.GetTitle(ListElement.id, CustomTitle); gameTDB.GetTitle(ListElement.id, CustomTitle);
} }
if(!ValidColor(ListElement.casecolor)) if(!ValidColor(ListElement.casecolor))
ListElement.casecolor = CoverFlow.InternalCoverColor(ListElement.id, GameColor); ListElement.casecolor = CoverFlow.InternalCoverColor(ListElement.id, GameColor);
if(CustomTitle != NULL && CustomTitle[0] != '\0') if(CustomTitle != NULL && CustomTitle[0] != '\0')
mbstowcs(ListElement.title, CustomTitle, 63); mbstowcs(ListElement.title, CustomTitle, 63);
else if(GameTitle != NULL) else if(GameTitle != NULL)
mbstowcs(ListElement.title, GameTitle, 63); mbstowcs(ListElement.title, GameTitle, 63);
Asciify(ListElement.title); Asciify(ListElement.title);
ListElement.type = Type; ListElement.type = Type;
m_gameList.push_back(ListElement); m_gameList.push_back(ListElement);
} }
static void Create_Wii_WBFS_List(wbfs_t *handle) static void Create_Wii_WBFS_List(wbfs_t *handle)
{ {
for(u32 i = 0; i < wbfs_count_discs(handle); i++) for(u32 i = 0; i < wbfs_count_discs(handle); i++)
{ {
memset((void*)&wii_hdr, 0, sizeof(discHdr)); memset((void*)&wii_hdr, 0, sizeof(discHdr));
s32 ret = wbfs_get_disc_info(handle, i, (u8*)&wii_hdr, sizeof(discHdr), NULL); s32 ret = wbfs_get_disc_info(handle, i, (u8*)&wii_hdr, sizeof(discHdr), NULL);
if(ret == 0 && wii_hdr.magic == WII_MAGIC) if(ret == 0 && wii_hdr.magic == WII_MAGIC)
AddISO((const char*)wii_hdr.id, (const char*)wii_hdr.title, AddISO((const char*)wii_hdr.id, (const char*)wii_hdr.title,
NULL, 0xFFFFFF, TYPE_WII_GAME); NULL, 0xFFFFFF, TYPE_WII_GAME);
} }
} }
static void Create_Wii_EXT_List(char *FullPath) static void Create_Wii_EXT_List(char *FullPath)
{ {
FILE *fp = fopen(FullPath, "rb"); FILE *fp = fopen(FullPath, "rb");
if(fp) if(fp)
{ {
fseek(fp, strcasestr(FullPath, ".wbfs") != NULL ? 512 : 0, SEEK_SET); fseek(fp, strcasestr(FullPath, ".wbfs") != NULL ? 512 : 0, SEEK_SET);
fread((void*)&wii_hdr, 1, sizeof(discHdr), fp); fread((void*)&wii_hdr, 1, sizeof(discHdr), fp);
if(wii_hdr.magic == WII_MAGIC) if(wii_hdr.magic == WII_MAGIC)
AddISO((const char*)wii_hdr.id, (const char*)wii_hdr.title, AddISO((const char*)wii_hdr.id, (const char*)wii_hdr.title,
FullPath, 0xFFFFFF, TYPE_WII_GAME); FullPath, 0xFFFFFF, TYPE_WII_GAME);
fclose(fp); fclose(fp);
} }
} }
u8 gc_disc[1]; u8 gc_disc[1];
const char *FST_APPEND = "sys/boot.bin"; const char *FST_APPEND = "sys/boot.bin";
const u8 FST_APPEND_SIZE = strlen(FST_APPEND); const u8 FST_APPEND_SIZE = strlen(FST_APPEND);
static void Create_GC_List(char *FullPath) static void Create_GC_List(char *FullPath)
{ {
FILE *fp = fopen(FullPath, "rb"); FILE *fp = fopen(FullPath, "rb");
if(!fp && strstr(FullPath, "/root") != NULL) //fst folder if(!fp && strstr(FullPath, "/root") != NULL) //fst folder
{ {
*(strstr(FullPath, "/root") + 1) = '\0'; *(strstr(FullPath, "/root") + 1) = '\0';
if(strlen(FullPath) + FST_APPEND_SIZE < MAX_MSG_SIZE) strcat(FullPath, FST_APPEND); if(strlen(FullPath) + FST_APPEND_SIZE < MAX_MSG_SIZE) strcat(FullPath, FST_APPEND);
fp = fopen(FullPath, "rb"); fp = fopen(FullPath, "rb");
} }
if(fp) if(fp)
{ {
fread((void*)&gc_hdr, 1, sizeof(gc_discHdr), fp); fread((void*)&gc_hdr, 1, sizeof(gc_discHdr), fp);
if(gc_hdr.magic == GC_MAGIC) if(gc_hdr.magic == GC_MAGIC)
{ {
AddISO((const char*)gc_hdr.id, (const char*)gc_hdr.title, AddISO((const char*)gc_hdr.id, (const char*)gc_hdr.title,
FullPath, 0x000000, TYPE_GC_GAME); FullPath, 0x000000, TYPE_GC_GAME);
/* Check for disc 2 */ /* Check for disc 2 */
fseek(fp, 6, SEEK_SET); fseek(fp, 6, SEEK_SET);
fread(gc_disc, 1, 1, fp); fread(gc_disc, 1, 1, fp);
if(gc_disc[0]) if(gc_disc[0])
{ {
wcslcat(m_gameList.back().title, L" disc 2", 63); wcslcat(m_gameList.back().title, L" disc 2", 63);
m_gameList.back().settings[0] = 1; m_gameList.back().settings[0] = 1;
} }
} }
fclose(fp); fclose(fp);
} }
} }
const char *FolderTitle = NULL; const char *FolderTitle = NULL;
static void Create_Plugin_List(char *FullPath) static void Create_Plugin_List(char *FullPath)
{ {
memset((void*)&ListElement, 0, sizeof(dir_discHdr)); memset((void*)&ListElement, 0, sizeof(dir_discHdr));
strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1); strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1);
strncpy(ListElement.id, "PLUGIN", 6); strncpy(ListElement.id, "PLUGIN", 6);
FolderTitle = strrchr(FullPath, '/') + 1; FolderTitle = strrchr(FullPath, '/') + 1;
*strrchr(FolderTitle, '.') = '\0'; *strrchr(FolderTitle, '.') = '\0';
char PluginMagicWord[9]; char PluginMagicWord[9];
memset(PluginMagicWord, 0, sizeof(PluginMagicWord)); memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
strncpy(PluginMagicWord, fmt("%08x", m_gameList.Magic), 8); strncpy(PluginMagicWord, fmt("%08x", m_gameList.Magic), 8);
const char *CustomTitle = CustomTitles.getString(PluginMagicWord, FolderTitle).c_str(); const char *CustomTitle = CustomTitles.getString(PluginMagicWord, FolderTitle).c_str();
if(CustomTitle != NULL && CustomTitle[0] != '\0') if(CustomTitle != NULL && CustomTitle[0] != '\0')
mbstowcs(ListElement.title, CustomTitle, 63); mbstowcs(ListElement.title, CustomTitle, 63);
else else
mbstowcs(ListElement.title, FolderTitle, 63); mbstowcs(ListElement.title, FolderTitle, 63);
Asciify(ListElement.title); Asciify(ListElement.title);
ListElement.settings[0] = m_gameList.Magic; //Plugin magic ListElement.settings[0] = m_gameList.Magic; //Plugin magic
ListElement.casecolor = m_gameList.Color; ListElement.casecolor = m_gameList.Color;
ListElement.type = TYPE_PLUGIN; ListElement.type = TYPE_PLUGIN;
m_gameList.push_back(ListElement); m_gameList.push_back(ListElement);
} }
static void Create_Homebrew_List(char *FullPath) static void Create_Homebrew_List(char *FullPath)
{ {
if(strcasestr(FullPath, "boot.") == NULL) if(strcasestr(FullPath, "boot.") == NULL)
return; return;
memset((void*)&ListElement, 0, sizeof(dir_discHdr)); memset((void*)&ListElement, 0, sizeof(dir_discHdr));
ListElement.index = m_gameList.size(); ListElement.index = m_gameList.size();
*strrchr(FullPath, '/') = '\0'; *strrchr(FullPath, '/') = '\0';
strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1); strncpy(ListElement.path, FullPath, sizeof(ListElement.path) - 1);
strncpy(ListElement.id, "HB_APP", 6); strncpy(ListElement.id, "HB_APP", 6);
FolderTitle = strrchr(FullPath, '/') + 1; FolderTitle = strrchr(FullPath, '/') + 1;
ListElement.casecolor = CustomTitles.getColor("COVERS", FolderTitle, 0xFFFFFF).intVal(); ListElement.casecolor = CustomTitles.getColor("COVERS", FolderTitle, 0xFFFFFF).intVal();
const string &CustomTitle = CustomTitles.getString("TITLES", FolderTitle); const string &CustomTitle = CustomTitles.getString("TITLES", FolderTitle);
if(CustomTitle.size() > 0) if(CustomTitle.size() > 0)
mbstowcs(ListElement.title, CustomTitle.c_str(), 63); mbstowcs(ListElement.title, CustomTitle.c_str(), 63);
else else
mbstowcs(ListElement.title, FolderTitle, 63); mbstowcs(ListElement.title, FolderTitle, 63);
Asciify(ListElement.title); Asciify(ListElement.title);
ListElement.type = TYPE_HOMEBREW; ListElement.type = TYPE_HOMEBREW;
m_gameList.push_back(ListElement); m_gameList.push_back(ListElement);
} }
Channel *chan = NULL; Channel *chan = NULL;
static void Create_Channel_List() static void Create_Channel_List()
{ {
for(u32 i = 0; i < ChannelHandle.Count(); i++) for(u32 i = 0; i < ChannelHandle.Count(); i++)
{ {
chan = ChannelHandle.GetChannel(i); chan = ChannelHandle.GetChannel(i);
if(chan->id == NULL) if(chan->id == NULL)
continue; // Skip invalid channels continue; // Skip invalid channels
memset((void*)&ListElement, 0, sizeof(dir_discHdr)); memset((void*)&ListElement, 0, sizeof(dir_discHdr));
ListElement.index = m_gameList.size(); ListElement.index = m_gameList.size();
ListElement.settings[0] = TITLE_UPPER(chan->title); ListElement.settings[0] = TITLE_UPPER(chan->title);
ListElement.settings[1] = TITLE_LOWER(chan->title); ListElement.settings[1] = TITLE_LOWER(chan->title);
strncpy(ListElement.id, chan->id, 4); strncpy(ListElement.id, chan->id, 4);
ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, 0xFFFFFF).intVal(); ListElement.casecolor = CustomTitles.getColor("COVERS", ListElement.id, 0xFFFFFF).intVal();
const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str(); const char *CustomTitle = CustomTitles.getString("TITLES", ListElement.id).c_str();
if(gameTDB.IsLoaded()) if(gameTDB.IsLoaded())
{ {
if(ListElement.casecolor == 0xFFFFFF) if(ListElement.casecolor == 0xFFFFFF)
ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id); ListElement.casecolor = gameTDB.GetCaseColor(ListElement.id);
ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id); ListElement.wifi = gameTDB.GetWifiPlayers(ListElement.id);
ListElement.players = gameTDB.GetPlayers(ListElement.id); ListElement.players = gameTDB.GetPlayers(ListElement.id);
if(CustomTitle == NULL || CustomTitle[0] == '\0') if(CustomTitle == NULL || CustomTitle[0] == '\0')
gameTDB.GetTitle(ListElement.id, CustomTitle); gameTDB.GetTitle(ListElement.id, CustomTitle);
} }
if(CustomTitle != NULL && CustomTitle[0] != '\0') if(CustomTitle != NULL && CustomTitle[0] != '\0')
mbstowcs(ListElement.title, CustomTitle, 63); mbstowcs(ListElement.title, CustomTitle, 63);
else else
wcsncpy(ListElement.title, chan->name, 64); wcsncpy(ListElement.title, chan->name, 64);
ListElement.type = TYPE_CHANNEL; ListElement.type = TYPE_CHANNEL;
m_gameList.push_back(ListElement); m_gameList.push_back(ListElement);
} }
} }
void ListGenerator::CreateList(u32 Flow, u32 Device, const string& Path, const vector<string>& FileTypes, void ListGenerator::CreateList(u32 Flow, u32 Device, const string& Path, const vector<string>& FileTypes,
const string& DBName, bool UpdateCache) const string& DBName, bool UpdateCache)
{ {
if(!DBName.empty()) if(!DBName.empty())
{ {
if(UpdateCache) if(UpdateCache)
fsop_deleteFile(DBName.c_str()); fsop_deleteFile(DBName.c_str());
else else
{ {
CCache(*this, DBName, LOAD); CCache(*this, DBName, LOAD);
if(!this->empty()) if(!this->empty())
return; return;
fsop_deleteFile(DBName.c_str()); fsop_deleteFile(DBName.c_str());
} }
} }
//if(Flow != COVERFLOW_PLUGIN) //if(Flow != COVERFLOW_PLUGIN)
OpenConfigs(); OpenConfigs();
if(Flow == COVERFLOW_USB) if(Flow == COVERFLOW_WII)
{ {
if(DeviceHandle.GetFSType(Device) == PART_FS_WBFS) if(DeviceHandle.GetFSType(Device) == PART_FS_WBFS)
Create_Wii_WBFS_List(DeviceHandle.GetWbfsHandle(Device)); Create_Wii_WBFS_List(DeviceHandle.GetWbfsHandle(Device));
else else
GetFiles(Path.c_str(), FileTypes, Create_Wii_EXT_List, false); GetFiles(Path.c_str(), FileTypes, Create_Wii_EXT_List, false);
} }
else if(Flow == COVERFLOW_CHANNEL) else if(Flow == COVERFLOW_CHANNEL)
{ {
ChannelHandle.Init(gameTDB_Language); ChannelHandle.Init(gameTDB_Language);
Create_Channel_List(); Create_Channel_List();
} }
else if(DeviceHandle.GetFSType(Device) != PART_FS_WBFS) else if(DeviceHandle.GetFSType(Device) != PART_FS_WBFS)
{ {
if(Flow == COVERFLOW_DML) if(Flow == COVERFLOW_GAMECUBE)
GetFiles(Path.c_str(), FileTypes, Create_GC_List, true); GetFiles(Path.c_str(), FileTypes, Create_GC_List, true);
else if(Flow == COVERFLOW_PLUGIN) else if(Flow == COVERFLOW_PLUGIN)
GetFiles(Path.c_str(), FileTypes, Create_Plugin_List, false, 30); GetFiles(Path.c_str(), FileTypes, Create_Plugin_List, false, 30);
else if(Flow == COVERFLOW_HOMEBREW) else if(Flow == COVERFLOW_HOMEBREW)
GetFiles(Path.c_str(), FileTypes, Create_Homebrew_List, false); GetFiles(Path.c_str(), FileTypes, Create_Homebrew_List, false);
} }
CloseConfigs(); CloseConfigs();
if(!this->empty() && !DBName.empty()) /* Write a new Cache */ if(!this->empty() && !DBName.empty()) /* Write a new Cache */
CCache(*this, DBName, SAVE); CCache(*this, DBName, SAVE);
} }
static inline bool IsFileSupported(const char *File, const vector<string>& FileTypes) static inline bool IsFileSupported(const char *File, const vector<string>& FileTypes)
{ {
for(vector<string>::const_iterator cmp = FileTypes.begin(); cmp != FileTypes.end(); ++cmp) for(vector<string>::const_iterator cmp = FileTypes.begin(); cmp != FileTypes.end(); ++cmp)
{ {
if(strcasecmp(File, cmp->c_str()) == 0) if(strcasecmp(File, cmp->c_str()) == 0)
return true; return true;
} }
return false; return false;
} }
const char *NewFileName = NULL; const char *NewFileName = NULL;
char *FullPathChar = NULL; char *FullPathChar = NULL;
dirent *pent = NULL; dirent *pent = NULL;
DIR *pdir = NULL; DIR *pdir = NULL;
void GetFiles(const char *Path, const vector<string>& FileTypes, void GetFiles(const char *Path, const vector<string>& FileTypes,
FileAdder AddFile, bool CompareFolders, u32 max_depth, u32 depth) FileAdder AddFile, bool CompareFolders, u32 max_depth, u32 depth)
{ {
vector<string> SubPaths; vector<string> SubPaths;
pdir = opendir(Path); pdir = opendir(Path);
if(pdir == NULL) if(pdir == NULL)
return; return;
while((pent = readdir(pdir)) != NULL) while((pent = readdir(pdir)) != NULL)
{ {
if(pent->d_name[0] == '.') if(pent->d_name[0] == '.')
continue; continue;
FullPathChar = fmt("%s/%s", Path, pent->d_name); FullPathChar = fmt("%s/%s", Path, pent->d_name);
if(pent->d_type == DT_DIR) if(pent->d_type == DT_DIR)
{ {
if(CompareFolders && IsFileSupported(pent->d_name, FileTypes)) if(CompareFolders && IsFileSupported(pent->d_name, FileTypes))
{ {
AddFile(FullPathChar); AddFile(FullPathChar);
continue; continue;
} }
else if(depth < max_depth) //thanks libntfs (fail opendir) and thanks seekdir (slowass speed) else if(depth < max_depth) //thanks libntfs (fail opendir) and thanks seekdir (slowass speed)
SubPaths.push_back(FullPathChar); SubPaths.push_back(FullPathChar);
} }
else if(pent->d_type == DT_REG) else if(pent->d_type == DT_REG)
{ {
NewFileName = strrchr(pent->d_name, '.'); NewFileName = strrchr(pent->d_name, '.');
if(NewFileName == NULL) NewFileName = pent->d_name; if(NewFileName == NULL) NewFileName = pent->d_name;
if(IsFileSupported(NewFileName, FileTypes)) if(IsFileSupported(NewFileName, FileTypes))
{ {
AddFile(FullPathChar); AddFile(FullPathChar);
continue; continue;
} }
} }
} }
closedir(pdir); closedir(pdir);
for(vector<string>::const_iterator p = SubPaths.begin(); p != SubPaths.end(); ++p) for(vector<string>::const_iterator p = SubPaths.begin(); p != SubPaths.end(); ++p)
GetFiles(p->c_str(), FileTypes, AddFile, CompareFolders, max_depth, depth + 1); GetFiles(p->c_str(), FileTypes, AddFile, CompareFolders, max_depth, depth + 1);
SubPaths.clear(); SubPaths.clear();
} }

View File

@ -70,7 +70,7 @@ CMenu::CMenu()
m_base_font_size = 0; m_base_font_size = 0;
m_wbf1_font = NULL; m_wbf1_font = NULL;
m_wbf2_font = NULL; m_wbf2_font = NULL;
m_current_view = COVERFLOW_USB; m_current_view = COVERFLOW_WII;
m_Emulator_boot = false; m_Emulator_boot = false;
m_music_info = true; m_music_info = true;
m_prevBg = NULL; m_prevBg = NULL;
@ -325,7 +325,7 @@ void CMenu::init()
break; break;
} }
if (DeviceHandle.IsInserted(i) 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)) || stat(fmt(checkDir, DeviceName[i]), &dummy) == 0))
{ {
gprintf("Setting Emu NAND to Partition: %i\n",currentPartition); 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++) for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
combinedList.push_back(*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_cfg.getBool(WII_DOMAIN, "source"))
{ {
m_current_view = COVERFLOW_USB; m_current_view = COVERFLOW_WII;
_loadGameList(); _loadGameList();
if(m_combined_view) if(m_combined_view)
for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++) 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++) for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++)
combinedList.push_back(*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_cfg.getBool(GC_DOMAIN, "source"))
{ {
m_current_view = COVERFLOW_DML; m_current_view = COVERFLOW_GAMECUBE;
_loadDmlList(); _loadDmlList();
if(m_combined_view) if(m_combined_view)
for(vector<dir_discHdr>::iterator tmp_itr = m_gameList.begin(); tmp_itr != m_gameList.end(); tmp_itr++) 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 gameDir(fmt(wii_games_dir, DeviceName[currentPartition]));
string cacheDir(fmt("%s/%s_wii.db", m_listCacheDir.c_str(), DeviceName[currentPartition])); string cacheDir(fmt("%s/%s_wii.db", m_listCacheDir.c_str(), DeviceName[currentPartition]));
bool updateCache = m_cfg.getBool(WII_DOMAIN, "update_cache"); 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(); WBFS_Close();
m_cfg.remove(WII_DOMAIN, "update_cache"); m_cfg.remove(WII_DOMAIN, "update_cache");
return true; return true;
@ -2347,7 +2347,7 @@ bool CMenu::_loadDmlList()
string gameDir(fmt(currentPartition == SD ? DML_DIR : m_DMLgameDir.c_str(), DeviceName[currentPartition])); 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])); string cacheDir(fmt("%s/%s_gamecube.db", m_listCacheDir.c_str(), DeviceName[currentPartition]));
bool updateCache = m_cfg.getBool(GC_DOMAIN, "update_cache"); 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); stringToVector(".iso|root", '|'),cacheDir, updateCache);
m_cfg.remove(GC_DOMAIN, "update_cache"); m_cfg.remove(GC_DOMAIN, "update_cache");
return true; return true;
@ -2381,10 +2381,9 @@ bool CMenu::_loadEmuList()
if(m_plugin_cfg.loaded()) if(m_plugin_cfg.loaded())
{ {
m_plugin.AddPlugin(m_plugin_cfg); m_plugin.AddPlugin(m_plugin_cfg);
const char *MagicNumber = m_plugin_cfg.getString(PLUGIN_INI_DEF,"magic").c_str(); u32 MagicWord = strtoul(m_plugin_cfg.getString(PLUGIN_INI_DEF,"magic").c_str(), NULL, 16);
if(!m_cfg.getBool("PLUGIN", MagicNumber, false)) if(!m_plugin.GetEnableStatus(m_cfg, MagicWord))
continue; continue;
u32 MagicWord = strtoul(MagicNumber, NULL, 16);
if(m_plugin_cfg.getString(PLUGIN_INI_DEF,"romDir").find("scummvm.ini") == string::npos) 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())); 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; return CHANNEL_DOMAIN;
case COVERFLOW_HOMEBREW: case COVERFLOW_HOMEBREW:
return HOMEBREW_DOMAIN; return HOMEBREW_DOMAIN;
case COVERFLOW_DML: case COVERFLOW_GAMECUBE:
return GC_DOMAIN; return GC_DOMAIN;
case COVERFLOW_PLUGIN: case COVERFLOW_PLUGIN:
return PLUGIN_DOMAIN; return PLUGIN_DOMAIN;
@ -2630,9 +2629,9 @@ void CMenu::UpdateCache(u32 view)
{ {
if(view == COVERFLOW_MAX) if(view == COVERFLOW_MAX)
{ {
UpdateCache(COVERFLOW_USB); UpdateCache(COVERFLOW_WII);
UpdateCache(COVERFLOW_HOMEBREW); UpdateCache(COVERFLOW_HOMEBREW);
UpdateCache(COVERFLOW_DML); UpdateCache(COVERFLOW_GAMECUBE);
UpdateCache(COVERFLOW_PLUGIN); UpdateCache(COVERFLOW_PLUGIN);
UpdateCache(COVERFLOW_CHANNEL); UpdateCache(COVERFLOW_CHANNEL);
return; return;
@ -2645,7 +2644,7 @@ void CMenu::UpdateCache(u32 view)
case COVERFLOW_HOMEBREW: case COVERFLOW_HOMEBREW:
m_cfg.setBool(HOMEBREW_DOMAIN, "update_cache", true); m_cfg.setBool(HOMEBREW_DOMAIN, "update_cache", true);
break; break;
case COVERFLOW_DML: case COVERFLOW_GAMECUBE:
m_cfg.setBool(GC_DOMAIN, "update_cache", true); m_cfg.setBool(GC_DOMAIN, "update_cache", true);
break; break;
case COVERFLOW_PLUGIN: case COVERFLOW_PLUGIN:

View File

@ -115,16 +115,16 @@ void CMenu::_getIDCats(void)
switch(hdr->type) switch(hdr->type)
{ {
case TYPE_CHANNEL: case TYPE_CHANNEL:
catDomain = "NAND"; catDomain = "CHANNELS";
break; break;
case TYPE_HOMEBREW: case TYPE_HOMEBREW:
catDomain = "HOMEBREW"; catDomain = "HOMEBREW";
break; break;
case TYPE_GC_GAME: case TYPE_GC_GAME:
catDomain = "DML"; catDomain = "GAMECUBE";
break; break;
case TYPE_WII_GAME: case TYPE_WII_GAME:
catDomain = "GAMES"; catDomain = "WII";
break; break;
default: default:
catDomain = (m_plugin.GetPluginName(m_plugin.GetPluginPosition(hdr->settings[0]))).toUTF8(); catDomain = (m_plugin.GetPluginName(m_plugin.GetPluginPosition(hdr->settings[0]))).toUTF8();

View File

@ -12,7 +12,7 @@ void CMenu::_hideConfig3(bool instant)
{ {
_hideConfigCommon(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_config3LblGameLanguage, instant);
m_btnMgr.hide(m_config3LblLanguage, instant); m_btnMgr.hide(m_config3LblLanguage, instant);
@ -49,7 +49,7 @@ void CMenu::_showConfig3(void)
{ {
_showConfigCommon(m_config3Bg, g_curPage); _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_config3LblGameLanguage);
m_btnMgr.show(m_config3LblLanguage); m_btnMgr.show(m_config3LblLanguage);
@ -84,7 +84,7 @@ void CMenu::_showConfig3(void)
int i; 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); 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)); m_btnMgr.setText(m_config3LblVideo, _t(CMenu::_GlobalVideoModes[i].id, CMenu::_GlobalVideoModes[i].text));

View File

@ -67,7 +67,7 @@ start_main:
switch(m_current_view) switch(m_current_view)
{ {
case COVERFLOW_DML: case COVERFLOW_GAMECUBE:
if(show_channel) if(show_channel)
m_btnMgr.show(m_mainBtnChannel); m_btnMgr.show(m_mainBtnChannel);
else if(show_emu) else if(show_emu)
@ -117,8 +117,8 @@ start_main:
{ {
switch(m_current_view) switch(m_current_view)
{ {
case COVERFLOW_USB: case COVERFLOW_WII:
case COVERFLOW_DML: 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.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_mainBtnInit);
m_btnMgr.show(m_mainBtnInit2); m_btnMgr.show(m_mainBtnInit2);
@ -354,9 +354,9 @@ int CMenu::main(void)
{ {
u8 lastView = m_current_view; u8 lastView = m_current_view;
if(BTN_UP_PRESSED) 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)) 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) else if(BTN_LEFT_PRESSED && show_emu)
m_current_view = COVERFLOW_PLUGIN; m_current_view = COVERFLOW_PLUGIN;
else if(BTN_RIGHT_PRESSED && show_channel) else if(BTN_RIGHT_PRESSED && show_channel)
@ -366,10 +366,10 @@ int CMenu::main(void)
_clearSources(); _clearSources();
switch(m_current_view) switch(m_current_view)
{ {
case COVERFLOW_USB: case COVERFLOW_WII:
m_cfg.setBool(WII_DOMAIN, "source", true); m_cfg.setBool(WII_DOMAIN, "source", true);
break; break;
case COVERFLOW_DML: case COVERFLOW_GAMECUBE:
m_cfg.setBool(GC_DOMAIN, "source", true); m_cfg.setBool(GC_DOMAIN, "source", true);
break; break;
case COVERFLOW_CHANNEL: 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)) 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) if(m_current_view == COVERFLOW_WII)
m_current_view = (m_show_dml || m_devo_installed || m_nintendont_installed) ? COVERFLOW_DML : m_current_view = (m_show_dml || m_devo_installed || m_nintendont_installed) ? COVERFLOW_GAMECUBE :
(show_channel ? COVERFLOW_CHANNEL : (show_emu ? COVERFLOW_PLUGIN : (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_DML) 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_USB)); 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) 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) 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) else if(m_current_view == COVERFLOW_HOMEBREW || m_current_view == COVERFLOW_MAX)
m_current_view = COVERFLOW_USB; m_current_view = COVERFLOW_WII;
_clearSources(); _clearSources();
switch(m_current_view) switch(m_current_view)
{ {
case COVERFLOW_USB: case COVERFLOW_WII:
m_cfg.setBool(WII_DOMAIN, "source", true); m_cfg.setBool(WII_DOMAIN, "source", true);
break; break;
case COVERFLOW_DML: case COVERFLOW_GAMECUBE:
m_cfg.setBool(GC_DOMAIN, "source", true); m_cfg.setBool(GC_DOMAIN, "source", true);
break; break;
case COVERFLOW_CHANNEL: case COVERFLOW_CHANNEL:
@ -829,7 +829,7 @@ int CMenu::main(void)
{ {
switch(m_current_view) switch(m_current_view)
{ {
case COVERFLOW_DML: case COVERFLOW_GAMECUBE:
if(show_channel) if(show_channel)
m_btnMgr.show(m_mainBtnChannel); m_btnMgr.show(m_mainBtnChannel);
else if(show_emu) else if(show_emu)
@ -1186,7 +1186,7 @@ void CMenu::_setPartition(s8 direction)
m_cfg.setBool(CHANNEL_DOMAIN, "disable", false); m_cfg.setBool(CHANNEL_DOMAIN, "disable", false);
switch_to_real = 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; u8 limiter = 0;
do do
@ -1198,7 +1198,7 @@ void CMenu::_setPartition(s8 direction)
limiter++; limiter++;
} }
while(limiter < 12 && (!DeviceHandle.IsInserted(currentPartition) || 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))); (NeedFAT && FS_Type != PART_FS_FAT)));
if(m_current_view == COVERFLOW_CHANNEL && FS_Type == -1) if(m_current_view == COVERFLOW_CHANNEL && FS_Type == -1)
@ -1226,7 +1226,7 @@ void CMenu::_setPartition(s8 direction)
char PluginMagicWord[9]; char PluginMagicWord[9];
memset(PluginMagicWord, 0, sizeof(PluginMagicWord)); memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
strncpy(PluginMagicWord, fmt("%08x", m_plugin.getPluginMagic(i)), 8); strncpy(PluginMagicWord, fmt("%08x", m_plugin.getPluginMagic(i)), 8);
m_cfg.setInt("PLUGINS/PARTITION", PluginMagicWord, currentPartition); m_cfg.setInt("PLUGINS_PARTITION", PluginMagicWord, currentPartition);
} }
} }
} }

View File

@ -112,7 +112,7 @@ int CMenu::_FindEmuPart(string &emuPath, bool skipchecks)
m_cfg.setString(CHANNEL_DOMAIN, "path", STDEMU_DIR); 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); emuPart = m_cfg.getInt(WII_DOMAIN, "savepartition", -1);
if(emuPart == -1) if(emuPart == -1)
@ -241,7 +241,7 @@ void CMenu::_showNandEmu(void)
if(nandemuPage == 1) if(nandemuPage == 1)
{ {
int i; 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_nandemuLblEmulation);
m_btnMgr.show(m_nandemuLblEmulationVal); m_btnMgr.show(m_nandemuLblEmulationVal);
@ -249,7 +249,7 @@ void CMenu::_showNandEmu(void)
m_btnMgr.show(m_nandemuBtnEmulationM); 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_nandemuLblSaveDump);
m_btnMgr.show(m_nandemuBtnAll); 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); 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)); 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); 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)); 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; s8 direction = m_btnMgr.selected(m_nandemuBtnEmulationP) ? 1 : -1;
if(m_current_view == COVERFLOW_CHANNEL) 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))); 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))); m_cfg.setInt(WII_DOMAIN, "save_emulation", (int)loopNum((u32)m_cfg.getInt(WII_DOMAIN, "save_emulation", 0) + direction, ARRAY_SIZE(CMenu::_GlobalSaveEmu)));
_showNandEmu(); _showNandEmu();
} }
@ -459,7 +459,7 @@ int CMenu::_NandEmuCfg(void)
{ {
_hideNandEmu(true); _hideNandEmu(true);
u8 tmpView = m_current_view; u8 tmpView = m_current_view;
m_current_view = COVERFLOW_USB; m_current_view = COVERFLOW_WII;
string emuPath; string emuPath;
_FindEmuPart(emuPath, true); _FindEmuPart(emuPath, true);
path = _FolderExplorer(NandHandle.GetPath()); path = _FolderExplorer(NandHandle.GetPath());
@ -804,7 +804,7 @@ int CMenu::_AutoCreateNand(void)
} }
else if(m_btnMgr.selected(m_nandemuBtnPartition)) else if(m_btnMgr.selected(m_nandemuBtnPartition))
{ {
if(m_current_view == COVERFLOW_USB) if(m_current_view == COVERFLOW_WII)
{ {
m_tempView = true; m_tempView = true;
m_current_view = COVERFLOW_CHANNEL; m_current_view = COVERFLOW_CHANNEL;
@ -813,7 +813,7 @@ int CMenu::_AutoCreateNand(void)
_config(1); _config(1);
if(m_tempView) if(m_tempView)
{ {
m_current_view = COVERFLOW_USB; m_current_view = COVERFLOW_WII;
m_tempView = false; m_tempView = false;
return 0; return 0;
} }

View File

@ -113,7 +113,8 @@ void CMenu::_updateSourceBtns(void)
{ {
magicNums.clear(); magicNums.clear();
magicNums = m_source.getStrings(fmt("BUTTON_%i", i), "magic", ','); 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; sourceBtn = i;
selectedBtns++; selectedBtns++;
@ -256,13 +257,13 @@ void CMenu::_sourceFlow()
_clearSources(); _clearSources();
if(source == "wii") if(source == "wii")
{ {
m_current_view = COVERFLOW_USB; m_current_view = COVERFLOW_WII;
m_cfg.setBool(WII_DOMAIN, "source", true); m_cfg.setBool(WII_DOMAIN, "source", true);
m_catStartPage = m_source.getInt(btn_selected, "cat_page", 1); m_catStartPage = m_source.getInt(btn_selected, "cat_page", 1);
} }
else if(source == "dml") else if(source == "dml")
{ {
m_current_view = COVERFLOW_DML; m_current_view = COVERFLOW_GAMECUBE;
m_cfg.setBool(GC_DOMAIN, "source", true); m_cfg.setBool(GC_DOMAIN, "source", true);
m_catStartPage = m_source.getInt(btn_selected, "cat_page", 1); m_catStartPage = m_source.getInt(btn_selected, "cat_page", 1);
} }
@ -312,7 +313,7 @@ void CMenu::_sourceFlow()
m_plugin.SetEnablePlugin(m_cfg, exist, 2); m_plugin.SetEnablePlugin(m_cfg, exist, 2);
if(plugin_magic_nums == 1) 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); m_cfg.setInt(PLUGIN_DOMAIN, "partition", currentPartition);
} }
} }
@ -476,7 +477,7 @@ bool CMenu::_Source()
char PluginMagicWord[9]; char PluginMagicWord[9];
memset(PluginMagicWord, 0, sizeof(PluginMagicWord)); memset(PluginMagicWord, 0, sizeof(PluginMagicWord));
strncpy(PluginMagicWord, fmt("%08x", m_plugin.getPluginMagic(i)), 8); 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); m_cfg.setInt(PLUGIN_DOMAIN, "partition", currentPartition);
} }
u8 sourceCount = 0; u8 sourceCount = 0;
@ -669,7 +670,7 @@ bool CMenu::_Source()
m_plugin.SetEnablePlugin(m_cfg, exist, 2); m_plugin.SetEnablePlugin(m_cfg, exist, 2);
if(plugin_magic_nums == 1) 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); m_cfg.setInt(PLUGIN_DOMAIN, "partition", currentPartition);
} }
} }

View File

@ -511,9 +511,9 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
//m_gameList.SetLanguage(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str()); //m_gameList.SetLanguage(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str());
_showWaitMessage(); _showWaitMessage();
if(upd_dml) if(upd_dml)
UpdateCache(COVERFLOW_DML); UpdateCache(COVERFLOW_GAMECUBE);
if(upd_usb) if(upd_usb)
UpdateCache(COVERFLOW_USB); UpdateCache(COVERFLOW_WII);
if(upd_emu) if(upd_emu)
UpdateCache(COVERFLOW_PLUGIN); UpdateCache(COVERFLOW_PLUGIN);
if(upd_chan) if(upd_chan)
@ -531,9 +531,9 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
{ {
if(done && op == WO_COPY_GAME) if(done && op == WO_COPY_GAME)
{ {
UpdateCache(COVERFLOW_DML); UpdateCache(COVERFLOW_GAMECUBE);
currentPartition = SD; currentPartition = SD;
UpdateCache(COVERFLOW_DML); UpdateCache(COVERFLOW_GAMECUBE);
} }
_loadList(); _loadList();
_initCF(); _initCF();

View File

@ -1,313 +1,313 @@
/**************************************************************************** /****************************************************************************
* Copyright (C) 2012 FIX94 * Copyright (C) 2012 FIX94
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#include <gccore.h> #include <gccore.h>
#include <ogcsys.h> #include <ogcsys.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <malloc.h> #include <malloc.h>
#include <algorithm> #include <algorithm>
#include "plugin.hpp" #include "plugin.hpp"
#include "fileOps/fileOps.h" #include "fileOps/fileOps.h"
#include "gui/text.hpp" #include "gui/text.hpp"
#include "gecko/gecko.hpp" #include "gecko/gecko.hpp"
#include "devicemounter/PartitionHandle.h" #include "devicemounter/PartitionHandle.h"
#include "devicemounter/DeviceHandler.hpp" #include "devicemounter/DeviceHandler.hpp"
#include "types.h" #include "types.h"
#include "crc32.h" #include "crc32.h"
Plugin m_plugin; Plugin m_plugin;
void Plugin::init(const string& m_pluginsDir) void Plugin::init(const string& m_pluginsDir)
{ {
PluginMagicWord[8] = '\0'; PluginMagicWord[8] = '\0';
pluginsDir = m_pluginsDir; pluginsDir = m_pluginsDir;
//Ready to add plugins //Ready to add plugins
adding = true; adding = true;
} }
static bool PluginOptions_cmp(PluginOptions lhs, PluginOptions rhs) static bool PluginOptions_cmp(PluginOptions lhs, PluginOptions rhs)
{ {
const wchar_t *first = lhs.DisplayName.c_str(); const wchar_t *first = lhs.DisplayName.c_str();
const wchar_t *second = rhs.DisplayName.c_str(); const wchar_t *second = rhs.DisplayName.c_str();
return wchar_cmp(first, second, wcslen(first), wcslen(second)); return wchar_cmp(first, second, wcslen(first), wcslen(second));
} }
void Plugin::EndAdd() void Plugin::EndAdd()
{ {
std::sort(Plugins.begin(), Plugins.end(), PluginOptions_cmp); std::sort(Plugins.begin(), Plugins.end(), PluginOptions_cmp);
adding = false; adding = false;
} }
void Plugin::Cleanup() void Plugin::Cleanup()
{ {
Plugins.clear(); Plugins.clear();
adding = true; adding = true;
} }
bool Plugin::AddPlugin(Config &plugin) bool Plugin::AddPlugin(Config &plugin)
{ {
if(!adding) if(!adding)
return false; return false;
PluginOptions NewPlugin; PluginOptions NewPlugin;
NewPlugin.DolName = plugin.getString(PLUGIN_INI_DEF, "dolFile"); NewPlugin.DolName = plugin.getString(PLUGIN_INI_DEF, "dolFile");
NewPlugin.coverFolder = plugin.getString(PLUGIN_INI_DEF, "coverFolder"); NewPlugin.coverFolder = plugin.getString(PLUGIN_INI_DEF, "coverFolder");
NewPlugin.magicWord = strtoul(plugin.getString(PLUGIN_INI_DEF, "magic").c_str(), NULL, 16); 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.caseColor = strtoul(plugin.getString(PLUGIN_INI_DEF, "coverColor").c_str(), NULL, 16);
NewPlugin.Args = plugin.getStrings(PLUGIN_INI_DEF, "arguments", '|'); NewPlugin.Args = plugin.getStrings(PLUGIN_INI_DEF, "arguments", '|');
string PluginName = plugin.getString(PLUGIN_INI_DEF, "displayname"); string PluginName = plugin.getString(PLUGIN_INI_DEF, "displayname");
if(PluginName.size() < 2) if(PluginName.size() < 2)
{ {
PluginName = NewPlugin.DolName; PluginName = NewPlugin.DolName;
PluginName.erase(PluginName.end() - 4, PluginName.end()); PluginName.erase(PluginName.end() - 4, PluginName.end());
} }
NewPlugin.DisplayName.fromUTF8(PluginName.c_str()); NewPlugin.DisplayName.fromUTF8(PluginName.c_str());
NewPlugin.consoleCoverID = plugin.getString(PLUGIN_INI_DEF,"consoleCoverID"); 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()); const string &bannerfilepath = sfmt("%s/%s", pluginsDir.c_str(), plugin.getString(PLUGIN_INI_DEF,"bannerSound").c_str());
fsop_GetFileSizeBytes(bannerfilepath.c_str(), &NewPlugin.BannerSoundSize); fsop_GetFileSizeBytes(bannerfilepath.c_str(), &NewPlugin.BannerSoundSize);
if(NewPlugin.BannerSoundSize > 0) if(NewPlugin.BannerSoundSize > 0)
NewPlugin.BannerSound = bannerfilepath; NewPlugin.BannerSound = bannerfilepath;
Plugins.push_back(NewPlugin); Plugins.push_back(NewPlugin);
return false; return false;
} }
s8 Plugin::GetPluginPosition(u32 magic) s8 Plugin::GetPluginPosition(u32 magic)
{ {
for(u8 pos = 0; pos < Plugins.size(); pos++) for(u8 pos = 0; pos < Plugins.size(); pos++)
{ {
if(magic == Plugins[pos].magicWord) if(magic == Plugins[pos].magicWord)
return pos; return pos;
} }
return -1; return -1;
} }
u8* Plugin::GetBannerSound(u32 magic) u8* Plugin::GetBannerSound(u32 magic)
{ {
if((Plugin_Pos = GetPluginPosition(magic)) >= 0) if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
{ {
u32 size = 0; u32 size = 0;
return fsop_ReadFile(Plugins[Plugin_Pos].BannerSound.c_str(), &size); return fsop_ReadFile(Plugins[Plugin_Pos].BannerSound.c_str(), &size);
} }
return NULL; return NULL;
} }
u32 Plugin::GetBannerSoundSize() u32 Plugin::GetBannerSoundSize()
{ {
//We call that directly after GetBannerSound, so no need to search for the magic again //We call that directly after GetBannerSound, so no need to search for the magic again
if(Plugin_Pos >= 0) if(Plugin_Pos >= 0)
return Plugins[Plugin_Pos].BannerSoundSize; return Plugins[Plugin_Pos].BannerSoundSize;
return 0; return 0;
} }
const char *Plugin::GetDolName(u32 magic) const char *Plugin::GetDolName(u32 magic)
{ {
if((Plugin_Pos = GetPluginPosition(magic)) >= 0) if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
return Plugins[Plugin_Pos].DolName.c_str(); return Plugins[Plugin_Pos].DolName.c_str();
return NULL; return NULL;
} }
const char *Plugin::GetCoverFolderName(u32 magic) const char *Plugin::GetCoverFolderName(u32 magic)
{ {
if((Plugin_Pos = GetPluginPosition(magic)) >= 0) if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
return Plugins[Plugin_Pos].coverFolder.c_str(); return Plugins[Plugin_Pos].coverFolder.c_str();
return NULL; return NULL;
} }
bool Plugin::PluginExist(u8 pos) bool Plugin::PluginExist(u8 pos)
{ {
if(pos < Plugins.size()) if(pos < Plugins.size())
return true; return true;
return false; return false;
} }
wstringEx Plugin::GetPluginName(u8 pos) wstringEx Plugin::GetPluginName(u8 pos)
{ {
return Plugins[pos].DisplayName; return Plugins[pos].DisplayName;
} }
void Plugin::SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode) void Plugin::SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode)
{ {
if(pos < Plugins.size()) if(pos < Plugins.size())
{ {
strncpy(PluginMagicWord, fmt("%08x", Plugins[pos].magicWord), 8); strncpy(PluginMagicWord, fmt("%08x", Plugins[pos].magicWord), 8);
if(ForceMode == 1) if(ForceMode == 1)
cfg.setBool(PLUGIN_INI_DEF, PluginMagicWord, false); cfg.setBool(PLUGIN_ENABLED, PluginMagicWord, false);
else if(ForceMode == 2) else if(ForceMode == 2)
cfg.setBool(PLUGIN_INI_DEF, PluginMagicWord, true); cfg.setBool(PLUGIN_ENABLED, PluginMagicWord, true);
else else
cfg.setBool(PLUGIN_INI_DEF, PluginMagicWord, cfg.getBool(PLUGIN_INI_DEF, PluginMagicWord) ? false : true); cfg.setBool(PLUGIN_ENABLED, PluginMagicWord, cfg.getBool(PLUGIN_ENABLED, PluginMagicWord) ? false : true);
} }
} }
bool Plugin::GetEnableStatus(Config &cfg, u32 magic) bool Plugin::GetEnableStatus(Config &cfg, u32 magic)
{ {
if((Plugin_Pos = GetPluginPosition(magic)) >= 0) if((Plugin_Pos = GetPluginPosition(magic)) >= 0)
{ {
strncpy(PluginMagicWord, fmt("%08x", magic), 8); strncpy(PluginMagicWord, fmt("%08x", magic), 8);
return cfg.getBool(PLUGIN_INI_DEF, PluginMagicWord, true); return cfg.getBool(PLUGIN_ENABLED, PluginMagicWord, true);
} }
return false; return false;
} }
const vector<bool> &Plugin::GetEnabledPlugins(Config &cfg, u8 *num) const vector<bool> &Plugin::GetEnabledPlugins(Config &cfg, u8 *num)
{ {
enabledPlugins.clear(); enabledPlugins.clear();
u8 enabledPluginsNumber = 0; u8 enabledPluginsNumber = 0;
for(u8 i = 0; i < Plugins.size(); i++) for(u8 i = 0; i < Plugins.size(); i++)
{ {
strncpy(PluginMagicWord, fmt("%08x", Plugins[i].magicWord), 8); strncpy(PluginMagicWord, fmt("%08x", Plugins[i].magicWord), 8);
if(cfg.getBool(PLUGIN_INI_DEF, PluginMagicWord, true)) if(cfg.getBool(PLUGIN_ENABLED, PluginMagicWord, true))
{ {
enabledPluginsNumber++; enabledPluginsNumber++;
enabledPlugins.push_back(true); enabledPlugins.push_back(true);
} }
else else
enabledPlugins.push_back(false); enabledPlugins.push_back(false);
} }
if(enabledPluginsNumber == Plugins.size()) if(enabledPluginsNumber == Plugins.size())
enabledPlugins.clear(); enabledPlugins.clear();
if(num != NULL) if(num != NULL)
*num = enabledPluginsNumber; *num = enabledPluginsNumber;
return enabledPlugins; return enabledPlugins;
} }
u32 Plugin::getPluginMagic(u8 pos) u32 Plugin::getPluginMagic(u8 pos)
{ {
return Plugins[pos].magicWord; return Plugins[pos].magicWord;
} }
vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 MagicWord) vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 MagicWord)
{ {
gprintf("Parsing scummvm.ini\n"); gprintf("Parsing scummvm.ini\n");
vector<dir_discHdr> gameHeader; vector<dir_discHdr> gameHeader;
if(!ini.loaded()) if(!ini.loaded())
return gameHeader; return gameHeader;
const char *GameDomain = ini.firstDomain().c_str(); const char *GameDomain = ini.firstDomain().c_str();
dir_discHdr ListElement; dir_discHdr ListElement;
while(1) while(1)
{ {
if(strlen(GameDomain) < 2) if(strlen(GameDomain) < 2)
break; break;
const char *GameName = ini.getString(GameDomain, "description").c_str(); const char *GameName = ini.getString(GameDomain, "description").c_str();
if(strlen(GameName) < 2 || strncasecmp(Device, ini.getString(GameDomain, "path").c_str(), 2) != 0) if(strlen(GameName) < 2 || strncasecmp(Device, ini.getString(GameDomain, "path").c_str(), 2) != 0)
{ {
GameDomain = ini.nextDomain().c_str(); GameDomain = ini.nextDomain().c_str();
continue; continue;
} }
memset((void*)&ListElement, 0, sizeof(dir_discHdr)); memset((void*)&ListElement, 0, sizeof(dir_discHdr));
strncpy(ListElement.id, PLUGIN_INI_DEF, 6); strncpy(ListElement.id, PLUGIN_INI_DEF, 6);
ListElement.casecolor = Plugins.back().caseColor; ListElement.casecolor = Plugins.back().caseColor;
mbstowcs(ListElement.title, GameName, 63); mbstowcs(ListElement.title, GameName, 63);
strncpy(ListElement.path, GameDomain, sizeof(ListElement.path)); strncpy(ListElement.path, GameDomain, sizeof(ListElement.path));
gprintf("Found: %s\n", GameDomain); gprintf("Found: %s\n", GameDomain);
ListElement.settings[0] = MagicWord; ListElement.settings[0] = MagicWord;
ListElement.type = TYPE_PLUGIN; ListElement.type = TYPE_PLUGIN;
gameHeader.push_back(ListElement); gameHeader.push_back(ListElement);
GameDomain = ini.nextDomain().c_str(); GameDomain = ini.nextDomain().c_str();
} }
return gameHeader; return gameHeader;
} }
vector<string> Plugin::CreateArgs(const char *device, const char *path, vector<string> Plugin::CreateArgs(const char *device, const char *path,
const char *title, const char *loader, u32 title_len_no_ext, u32 magic) const char *title, const char *loader, u32 title_len_no_ext, u32 magic)
{ {
vector<string> args; vector<string> args;
Plugin_Pos = GetPluginPosition(magic); Plugin_Pos = GetPluginPosition(magic);
if(Plugin_Pos < 0) if(Plugin_Pos < 0)
return args; return args;
for(vector<string>::const_iterator arg = Plugins[Plugin_Pos].Args.begin(); for(vector<string>::const_iterator arg = Plugins[Plugin_Pos].Args.begin();
arg != Plugins[Plugin_Pos].Args.end(); ++arg) arg != Plugins[Plugin_Pos].Args.end(); ++arg)
{ {
string Argument(*arg); string Argument(*arg);
if(Argument.find(PLUGIN_DEV) != string::npos) if(Argument.find(PLUGIN_DEV) != string::npos)
Argument.replace(Argument.find(PLUGIN_DEV), strlen(PLUGIN_DEV), device); Argument.replace(Argument.find(PLUGIN_DEV), strlen(PLUGIN_DEV), device);
if(Argument.find(PLUGIN_PATH) != string::npos) if(Argument.find(PLUGIN_PATH) != string::npos)
Argument.replace(Argument.find(PLUGIN_PATH), strlen(PLUGIN_PATH), path); Argument.replace(Argument.find(PLUGIN_PATH), strlen(PLUGIN_PATH), path);
if(Argument.find(PLUGIN_NAME) != string::npos) if(Argument.find(PLUGIN_NAME) != string::npos)
Argument.replace(Argument.find(PLUGIN_NAME), strlen(PLUGIN_NAME), title); Argument.replace(Argument.find(PLUGIN_NAME), strlen(PLUGIN_NAME), title);
if(Argument.find(PLUGIN_LDR) != string::npos) if(Argument.find(PLUGIN_LDR) != string::npos)
Argument.replace(Argument.find(PLUGIN_LDR), strlen(PLUGIN_LDR), loader); Argument.replace(Argument.find(PLUGIN_LDR), strlen(PLUGIN_LDR), loader);
if(Argument.find(PLUGIN_NOEXT) != string::npos) if(Argument.find(PLUGIN_NOEXT) != string::npos)
Argument.replace(Argument.find(PLUGIN_NOEXT), strlen(PLUGIN_NOEXT), title, title_len_no_ext); Argument.replace(Argument.find(PLUGIN_NOEXT), strlen(PLUGIN_NOEXT), title, title_len_no_ext);
args.push_back(Argument); args.push_back(Argument);
} }
return args; return args;
} }
string Plugin::GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums) string Plugin::GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums)
{ {
string url(constURL); string url(constURL);
Plugin_Pos = GetPluginPosition(gameHeader.settings[0]); Plugin_Pos = GetPluginPosition(gameHeader.settings[0]);
if(url.find(TAG_LOC) != url.npos) if(url.find(TAG_LOC) != url.npos)
url.replace(url.find(TAG_LOC), strlen(TAG_LOC), "EN"); url.replace(url.find(TAG_LOC), strlen(TAG_LOC), "EN");
if(url.find(TAG_CONSOLE) != url.npos) 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")); url.replace(url.find(TAG_CONSOLE), strlen(TAG_CONSOLE), (Plugins[Plugin_Pos].consoleCoverID.size() ? Plugins[Plugin_Pos].consoleCoverID.c_str() : "nintendo"));
char gamePath[256]; char gamePath[256];
if(string(gameHeader.path).find_last_of("/") != string::npos) if(string(gameHeader.path).find_last_of("/") != string::npos)
strncpy(gamePath, &gameHeader.path[string(gameHeader.path).find_last_of("/")+1], sizeof(gamePath)); strncpy(gamePath, &gameHeader.path[string(gameHeader.path).find_last_of("/")+1], sizeof(gamePath));
else else
strncpy(gamePath, gameHeader.path, sizeof(gamePath)); strncpy(gamePath, gameHeader.path, sizeof(gamePath));
const string& cachedCRC = Checksums.getString("CHECKSUMS", gamePath); const string& cachedCRC = Checksums.getString("CHECKSUMS", gamePath);
char crc_string[9]; char crc_string[9];
crc_string[8] = '\0'; crc_string[8] = '\0';
if(cachedCRC.size() == 8) if(cachedCRC.size() == 8)
{ {
gprintf("CRC32 of %s is cached\n", gamePath); gprintf("CRC32 of %s is cached\n", gamePath);
strncpy(crc_string, cachedCRC.c_str(), 8); strncpy(crc_string, cachedCRC.c_str(), 8);
} }
else else
{ {
gprintf("Generating CRC32 for %s\n", gamePath); gprintf("Generating CRC32 for %s\n", gamePath);
u32 buffer; u32 buffer;
ifstream infile; ifstream infile;
if(strstr(gameHeader.path, ".zip") != NULL) if(strstr(gameHeader.path, ".zip") != NULL)
{ {
infile.open(gameHeader.path, ios::binary); infile.open(gameHeader.path, ios::binary);
infile.seekg(0x0e, ios::beg); infile.seekg(0x0e, ios::beg);
infile.read((char*)&buffer, 8); infile.read((char*)&buffer, 8);
infile.close(); infile.close();
strncpy(crc_string, fmt("%08x", (u32)__builtin_bswap32(buffer)), 8); strncpy(crc_string, fmt("%08x", (u32)__builtin_bswap32(buffer)), 8);
} }
else if(strstr(gameHeader.path, ".7z") != NULL) else if(strstr(gameHeader.path, ".7z") != NULL)
{ {
infile.open(gameHeader.path, ios::binary); infile.open(gameHeader.path, ios::binary);
infile.seekg(-8, ios::end); infile.seekg(-8, ios::end);
while(infile.tellg()) while(infile.tellg())
{ {
infile.read((char*)&buffer, 8); infile.read((char*)&buffer, 8);
if(buffer == 0x00050111) if(buffer == 0x00050111)
break; break;
infile.seekg(-9, ios::cur); infile.seekg(-9, ios::cur);
} }
infile.seekg(-13, ios::cur); infile.seekg(-13, ios::cur);
infile.read((char*)&buffer, 8); infile.read((char*)&buffer, 8);
infile.close(); infile.close();
strncpy(crc_string, fmt("%08x", (u32)__builtin_bswap32(buffer)), 8); strncpy(crc_string, fmt("%08x", (u32)__builtin_bswap32(buffer)), 8);
} }
else else
strncpy(crc_string, fmt("%08x", crc32file(gameHeader.path)), 8); strncpy(crc_string, fmt("%08x", crc32file(gameHeader.path)), 8);
Checksums.setString("CHECKSUMS", gamePath, crc_string); Checksums.setString("CHECKSUMS", gamePath, crc_string);
Checksums.save(); Checksums.save();
} }
url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), upperCase(crc_string).c_str()); url.replace(url.find(TAG_GAME_ID), strlen(TAG_GAME_ID), upperCase(crc_string).c_str());
gprintf("URL: %s\n", url.c_str()); gprintf("URL: %s\n", url.c_str());
return url; return url;
} }

View File

@ -1,87 +1,88 @@
/**************************************************************************** /****************************************************************************
* Copyright (C) 2012 FIX94 * Copyright (C) 2012 FIX94
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#ifndef _PLUGIN_HPP_ #ifndef _PLUGIN_HPP_
#define _PLUGIN_HPP_ #define _PLUGIN_HPP_
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector> #include <vector>
#include "config/config.hpp" #include "config/config.hpp"
#include "loader/disc.h" #include "loader/disc.h"
using namespace std; using namespace std;
#define TAG_GAME_ID "{gameid}" #define TAG_GAME_ID "{gameid}"
#define TAG_LOC "{loc}" #define TAG_LOC "{loc}"
#define TAG_CONSOLE "{console}" #define TAG_CONSOLE "{console}"
#define PLUGIN_INI_DEF "PLUGIN" #define PLUGIN_INI_DEF "PLUGIN"
#define PLUGIN_DEV "{device}" #define PLUGIN_ENABLED "PLUGINS_ENABLED"
#define PLUGIN_PATH "{path}" #define PLUGIN_DEV "{device}"
#define PLUGIN_NAME "{name}" #define PLUGIN_PATH "{path}"
#define PLUGIN_NOEXT "{name_no_ext}" #define PLUGIN_NAME "{name}"
#define PLUGIN_LDR "{loader}" #define PLUGIN_NOEXT "{name_no_ext}"
#define PLUGIN_LDR "{loader}"
struct PluginOptions
{ struct PluginOptions
u32 magicWord; {
u32 caseColor; u32 magicWord;
string DolName; u32 caseColor;
string coverFolder; string DolName;
string consoleCoverID; string coverFolder;
string BannerSound; string consoleCoverID;
u32 BannerSoundSize; string BannerSound;
vector<string> Args; u32 BannerSoundSize;
wstringEx DisplayName; vector<string> Args;
}; wstringEx DisplayName;
};
class Plugin
{ class Plugin
public: {
bool AddPlugin(Config &plugin); public:
u8 *GetBannerSound(u32 magic); bool AddPlugin(Config &plugin);
u32 GetBannerSoundSize(); u8 *GetBannerSound(u32 magic);
const char *GetDolName(u32 magic); u32 GetBannerSoundSize();
const char *GetCoverFolderName(u32 magic); const char *GetDolName(u32 magic);
bool GetEnableStatus(Config &cfg, u32 magic); const char *GetCoverFolderName(u32 magic);
string GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums); bool GetEnableStatus(Config &cfg, u32 magic);
wstringEx GetPluginName(u8 pos); string GenerateCoverLink(dir_discHdr gameHeader, const string& constURL, Config &Checksums);
u32 getPluginMagic(u8 pos); wstringEx GetPluginName(u8 pos);
bool PluginExist(u8 pos); u32 getPluginMagic(u8 pos);
void SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode = 0); bool PluginExist(u8 pos);
const vector<bool> &GetEnabledPlugins(Config &cfg, u8 *num); void SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode = 0);
vector<string> CreateArgs(const char *device, const char *path, const vector<bool> &GetEnabledPlugins(Config &cfg, u8 *num);
const char *title, const char *loader, u32 title_len_no_ext, u32 magic); vector<string> CreateArgs(const char *device, const char *path,
void init(const string& m_pluginsDir); const char *title, const char *loader, u32 title_len_no_ext, u32 magic);
void Cleanup(); void init(const string& m_pluginsDir);
void EndAdd(); void Cleanup();
vector<dir_discHdr> ParseScummvmINI(Config &ini, const char *Device, u32 MagicWord); void EndAdd();
s8 GetPluginPosition(u32 magic); vector<dir_discHdr> ParseScummvmINI(Config &ini, const char *Device, u32 MagicWord);
private: s8 GetPluginPosition(u32 magic);
vector<PluginOptions> Plugins; private:
vector<bool> enabledPlugins; vector<PluginOptions> Plugins;
char PluginMagicWord[9]; vector<bool> enabledPlugins;
s8 Plugin_Pos; char PluginMagicWord[9];
string pluginsDir; s8 Plugin_Pos;
bool adding; string pluginsDir;
}; bool adding;
};
extern Plugin m_plugin;
extern Plugin m_plugin;
#endif
#endif

View File

@ -1,56 +1,56 @@
#ifndef _TYPES_H_ #ifndef _TYPES_H_
#define _TYPES_H_ #define _TYPES_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
enum { enum {
COVERFLOW_USB = 0, COVERFLOW_WII = 0,
COVERFLOW_DML, COVERFLOW_GAMECUBE,
COVERFLOW_CHANNEL, COVERFLOW_CHANNEL,
COVERFLOW_PLUGIN, COVERFLOW_PLUGIN,
COVERFLOW_HOMEBREW, COVERFLOW_HOMEBREW,
COVERFLOW_MAX COVERFLOW_MAX
}; };
enum enum
{ {
TYPE_WII_DISC = 0, TYPE_WII_DISC = 0,
TYPE_WII_WBFS, TYPE_WII_WBFS,
TYPE_WII_WBFS_EXT, TYPE_WII_WBFS_EXT,
}; };
enum enum
{ {
TYPE_WII_GAME = 0, TYPE_WII_GAME = 0,
TYPE_GC_GAME, TYPE_GC_GAME,
TYPE_CHANNEL, TYPE_CHANNEL,
TYPE_PLUGIN, TYPE_PLUGIN,
TYPE_HOMEBREW, TYPE_HOMEBREW,
TYPE_SOURCE, TYPE_SOURCE,
TYPE_END TYPE_END
}; };
#define NoGameID(x) (x == TYPE_PLUGIN || x == TYPE_HOMEBREW || x == TYPE_SOURCE) #define NoGameID(x) (x == TYPE_PLUGIN || x == TYPE_HOMEBREW || x == TYPE_SOURCE)
enum enum
{ {
IOS_TYPE_D2X = 0, IOS_TYPE_D2X = 0,
IOS_TYPE_WANIN, IOS_TYPE_WANIN,
IOS_TYPE_HERMES, IOS_TYPE_HERMES,
IOS_TYPE_KWIIRK, IOS_TYPE_KWIIRK,
IOS_TYPE_NEEK2O, IOS_TYPE_NEEK2O,
IOS_TYPE_NORMAL_IOS, IOS_TYPE_NORMAL_IOS,
IOS_TYPE_STUB, IOS_TYPE_STUB,
}; };
#define CustomIOS(x) (x != IOS_TYPE_NORMAL_IOS && x != IOS_TYPE_STUB) #define CustomIOS(x) (x != IOS_TYPE_NORMAL_IOS && x != IOS_TYPE_STUB)
#define ValidColor(x) (x == 0xFFFFFF || x == 0xFF0000 || x == 0x000000 || \ #define ValidColor(x) (x == 0xFFFFFF || x == 0xFF0000 || x == 0x000000 || \
x == 0xFCFF00 || x == 0x01A300 || x == 0x00E360) x == 0xFCFF00 || x == 0x01A300 || x == 0x00E360)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif