mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-17 23:41:53 +01:00
db8a2b137c
-fixed using categories to hide GC disc 2's. Apparently this has never really worked right for some time or ever. -fixed deleting the cached cover texture file for plugin games. Delete cover for plugins only deletes the cached texture file (.wfc) -fixed favorites and adultonly (parental lock) for plugin games. Apparently I may have broke this a few revisions back. -favorites and adultonly for plugin games now have their own domains in gamecfg1- [FAVORITES_PLUGINS] and [ADULTONLY_PLUGINS]. just makes it more organized. -only wii, GC, channels are added to [PLAYCOUNT] and [LAST_PLAYED] in gamecfg1. -now loading gamecfg1 at startup and leaving it loaded till exit. no more loading it and unloading all the time. -fixed scrolling for game_info synopsis, credits, and help text. -made source menu buttons wider for wiiflow default. old 80x80, now 100x80. looks better. -display music info now defaults to off -screensaver_disabled now defaults to yes -show GC view button is now on by default no matter what. the only way it is disabled is if you edit wiiflow.ini manually. this is how all the view buttons work. -removed hiding homebrew button but if wiiflow locked it won't work or in sourceflow it won't show. -dump_list is now under [GENERAL] instead of each view. Also only works for Wii, GC, and channels. -sorting only works for Wii, GC, and Channels now. disabled for sourceflow, plugins, homebrew, and combined view. -now if no games are found a message is shown with the current path so you can see where wiiflow is looking. (except for plugins) -removed auto create emuNAND for emuNAND view if gamelist is empty. just go to settings>NAND settings if you want to extract or disable it. -now when no games are found all buttons at bottom are still accessible allowing you to change the view or go to settings and change current partition or path and even extract your NAND to create a EmuNAND. Or go to Home Menu and Install a Wii or GC game. -removed auto extract NAND to emuNAND when launching a Wii game with EmuNAND save. Now a message is diplayed saying 'emuNAND for saves not found - using real NAND'. -made the speed at which cover titles fade in/out almost instantly. -removed update button from Home Menu. online update code is still there but not used and probably won't be used any more as there just isn't a need for it now. -removed ftp button from Home Menu and all code for the FTP server. I just use WiiXplorer's FTP server. it seems to work better for me. -disabled keep USB Alive thread for now. i think there's a possibilty it might be the cause of my SD/USB files getting corrupted. -removed Btn B and - combo to switch partitions. didn't seem useful anymore. -redid nand emulation settings menu. looks like this now: pg1 Select EmuNAND EmuNAND Enulation Select SaveNAND SaveNAND Emulation pg2 Extract Saves All Missing Extract NAND Select Saves Partition -no longer blocking Select Plugin menu and View icons when using source menu combined view -now Select Plugins Menu is like switching to plugin view but you get to choose the plugins first -now [PLUGIN] partition= is the default partition for all plugins. to change individual plugins add 'romPartition=x' to the plugin ini. x is the partition number 0 thru 8 with SD being 0. this is how my usbloadergx plugin mod works.
337 lines
10 KiB
C++
337 lines
10 KiB
C++
/****************************************************************************
|
|
* 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, "dolFile");
|
|
NewPlugin.coverFolder = plugin.getString(PLUGIN, "coverFolder");
|
|
NewPlugin.magic = strtoul(plugin.getString(PLUGIN, "magic").c_str(), NULL, 16);
|
|
NewPlugin.caseColor = strtoul(plugin.getString(PLUGIN, "coverColor").c_str(), NULL, 16);
|
|
NewPlugin.romPartition = plugin.getInt(PLUGIN, "rompartition", -1);
|
|
NewPlugin.romDir = plugin.getString(PLUGIN, "romDir");
|
|
NewPlugin.fileTypes = plugin.getString(PLUGIN, "fileTypes");
|
|
NewPlugin.Args = plugin.getStrings(PLUGIN, "arguments", '|');
|
|
string PluginName = plugin.getString(PLUGIN, "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,"consoleCoverID");
|
|
|
|
const string &bannerfilepath = sfmt("%s/%s", pluginsDir.c_str(), plugin.getString(PLUGIN,"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].magic)
|
|
return pos;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
u32 Plugin::getPluginMagic(u8 pos)
|
|
{
|
|
return Plugins[pos].magic;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
int Plugin::GetRomPartition(u8 pos)
|
|
{
|
|
return Plugins[pos].romPartition;
|
|
}
|
|
|
|
const char *Plugin::GetRomDir(u8 pos)
|
|
{
|
|
return Plugins[pos].romDir.c_str();
|
|
}
|
|
|
|
const string& Plugin::GetFileTypes(u8 pos)
|
|
{
|
|
return Plugins[pos].fileTypes;
|
|
}
|
|
|
|
u32 Plugin::GetCaseColor(u8 pos)
|
|
{
|
|
return Plugins[pos].caseColor;
|
|
}
|
|
|
|
wstringEx Plugin::GetPluginName(u8 pos)
|
|
{
|
|
return Plugins[pos].DisplayName;
|
|
}
|
|
|
|
bool Plugin::PluginExist(u8 pos)
|
|
{
|
|
if(pos < Plugins.size())
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
void Plugin::SetEnablePlugin(Config &cfg, u8 pos, u8 ForceMode)
|
|
{
|
|
if(pos < Plugins.size())
|
|
{
|
|
strncpy(PluginMagicWord, fmt("%08x", Plugins[pos].magic), 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].magic), 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;
|
|
}
|
|
|
|
vector<dir_discHdr> Plugin::ParseScummvmINI(Config &ini, const char *Device, u32 Magic)
|
|
{
|
|
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, 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] = Magic;
|
|
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;
|
|
}
|