mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-04-30 09:59:26 +02:00
Stopping windows from balking because of busy processing.
This commit is contained in:
@@ -130,7 +130,6 @@ bool MetadataDatabase::ImportDirectory()
|
|||||||
{
|
{
|
||||||
std::string importFile = Configuration::GetAbsolutePath() + "/" + hyperListPath + "/" + dirp->d_name;
|
std::string importFile = Configuration::GetAbsolutePath() + "/" + hyperListPath + "/" + dirp->d_name;
|
||||||
Logger::Write(Logger::ZONE_INFO, "Metadata", "Importing hyperlist: " + importFile);
|
Logger::Write(Logger::ZONE_INFO, "Metadata", "Importing hyperlist: " + importFile);
|
||||||
Config.SetStatus("Scraping data from " + importFile);
|
|
||||||
ImportHyperList(importFile, collectionName);
|
ImportHyperList(importFile, collectionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -286,6 +285,8 @@ bool MetadataDatabase::ImportHyperList(std::string hyperlistFile, std::string co
|
|||||||
{
|
{
|
||||||
bool retVal = false;
|
bool retVal = false;
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
|
|
||||||
|
Config.SetStatus("Scraping data from \"" + hyperlistFile + "\"");
|
||||||
rapidxml::xml_document<> doc;
|
rapidxml::xml_document<> doc;
|
||||||
std::ifstream file(hyperlistFile.c_str());
|
std::ifstream file(hyperlistFile.c_str());
|
||||||
std::vector<char> buffer((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
std::vector<char> buffer((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
||||||
@@ -347,6 +348,7 @@ bool MetadataDatabase::ImportHyperList(std::string hyperlistFile, std::string co
|
|||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Config.SetStatus("Saving data from \"" + hyperlistFile + "\" to database");
|
||||||
sqlite3_exec(handle, "COMMIT TRANSACTION;", NULL, NULL, &error);
|
sqlite3_exec(handle, "COMMIT TRANSACTION;", NULL, NULL, &error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -369,87 +371,90 @@ bool MetadataDatabase::ImportHyperList(std::string hyperlistFile, std::string co
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MetadataDatabase::ImportMameList(std::string filename, std::string collectionName)
|
bool MetadataDatabase::ImportMameList(std::string filename, std::string collectionName)
|
||||||
{
|
{
|
||||||
bool retVal = true;
|
bool retVal = true;
|
||||||
rapidxml::xml_document<> doc;
|
rapidxml::xml_document<> doc;
|
||||||
rapidxml::xml_node<> * rootNode;
|
rapidxml::xml_node<> * rootNode;
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
sqlite3 *handle = DBInstance.GetHandle();
|
sqlite3 *handle = DBInstance.GetHandle();
|
||||||
|
|
||||||
Logger::Write(Logger::ZONE_INFO, "Mamelist", "Importing mamelist file \"" + filename + "\" (this will take a while)");
|
Config.SetStatus("Scraping data from \"" + filename + "\" (this will take a while)");
|
||||||
std::ifstream file(filename.c_str());
|
|
||||||
|
Logger::Write(Logger::ZONE_INFO, "Mamelist", "Importing mamelist file \"" + filename + "\" (this will take a while)");
|
||||||
std::vector<char> buffer((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
std::ifstream file(filename.c_str());
|
||||||
|
|
||||||
buffer.push_back('\0');
|
std::vector<char> buffer((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
doc.parse<0>(&buffer[0]);
|
buffer.push_back('\0');
|
||||||
|
|
||||||
rootNode = doc.first_node("mame");
|
doc.parse<0>(&buffer[0]);
|
||||||
|
|
||||||
sqlite3_exec(handle, "BEGIN IMMEDIATE TRANSACTION;", NULL, NULL, &error);
|
rootNode = doc.first_node("mame");
|
||||||
for (rapidxml::xml_node<> * game = rootNode->first_node("game"); game; game = game->next_sibling())
|
|
||||||
{
|
sqlite3_exec(handle, "BEGIN IMMEDIATE TRANSACTION;", NULL, NULL, &error);
|
||||||
rapidxml::xml_attribute<> *nameNode = game->first_attribute("name");
|
for (rapidxml::xml_node<> * game = rootNode->first_node("game"); game; game = game->next_sibling())
|
||||||
rapidxml::xml_attribute<> *cloneOfXml = game->first_attribute("cloneof");
|
{
|
||||||
|
rapidxml::xml_attribute<> *nameNode = game->first_attribute("name");
|
||||||
if(nameNode != NULL)
|
rapidxml::xml_attribute<> *cloneOfXml = game->first_attribute("cloneof");
|
||||||
{
|
|
||||||
std::string name = nameNode->value();
|
if(nameNode != NULL)
|
||||||
rapidxml::xml_node<> *descriptionNode = game->first_node("description");
|
{
|
||||||
rapidxml::xml_node<> *yearNode = game->first_node("year");
|
std::string name = nameNode->value();
|
||||||
rapidxml::xml_node<> *manufacturerNode = game->first_node("manufacturer");
|
rapidxml::xml_node<> *descriptionNode = game->first_node("description");
|
||||||
rapidxml::xml_node<> *inputNode = game->first_node("input");
|
rapidxml::xml_node<> *yearNode = game->first_node("year");
|
||||||
|
rapidxml::xml_node<> *manufacturerNode = game->first_node("manufacturer");
|
||||||
std::string description = (descriptionNode == NULL) ? nameNode->value() : descriptionNode->value();
|
rapidxml::xml_node<> *inputNode = game->first_node("input");
|
||||||
std::string year = (yearNode == NULL) ? "" : yearNode->value();
|
|
||||||
std::string manufacturer = (manufacturerNode == NULL) ? "" : manufacturerNode->value();
|
std::string description = (descriptionNode == NULL) ? nameNode->value() : descriptionNode->value();
|
||||||
std::string cloneOf = (cloneOfXml == NULL) ? "" : cloneOfXml->value();
|
std::string year = (yearNode == NULL) ? "" : yearNode->value();
|
||||||
std::string players;
|
std::string manufacturer = (manufacturerNode == NULL) ? "" : manufacturerNode->value();
|
||||||
std::string buttons;
|
std::string cloneOf = (cloneOfXml == NULL) ? "" : cloneOfXml->value();
|
||||||
|
std::string players;
|
||||||
if(inputNode != NULL)
|
std::string buttons;
|
||||||
{
|
|
||||||
rapidxml::xml_attribute<> *playersAttribute = inputNode->first_attribute("players");
|
if(inputNode != NULL)
|
||||||
rapidxml::xml_attribute<> *buttonsAttribute = inputNode->first_attribute("buttons");
|
{
|
||||||
|
rapidxml::xml_attribute<> *playersAttribute = inputNode->first_attribute("players");
|
||||||
if(playersAttribute)
|
rapidxml::xml_attribute<> *buttonsAttribute = inputNode->first_attribute("buttons");
|
||||||
{
|
|
||||||
players = playersAttribute->value();
|
if(playersAttribute)
|
||||||
}
|
{
|
||||||
|
players = playersAttribute->value();
|
||||||
if(buttonsAttribute)
|
}
|
||||||
{
|
|
||||||
buttons = buttonsAttribute->value();
|
if(buttonsAttribute)
|
||||||
}
|
{
|
||||||
|
buttons = buttonsAttribute->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_stmt *stmt;
|
}
|
||||||
|
|
||||||
|
sqlite3_stmt *stmt;
|
||||||
|
|
||||||
sqlite3_prepare_v2(handle,
|
sqlite3_prepare_v2(handle,
|
||||||
"INSERT OR REPLACE INTO Meta (name, title, year, manufacturer, players, buttons, cloneOf, collectionName) VALUES (?,?,?,?,?,?,?,?)",
|
"INSERT OR REPLACE INTO Meta (name, title, year, manufacturer, players, buttons, cloneOf, collectionName) VALUES (?,?,?,?,?,?,?,?)",
|
||||||
-1, &stmt, 0);
|
-1, &stmt, 0);
|
||||||
|
|
||||||
|
|
||||||
sqlite3_bind_text(stmt, 1, name.c_str(), -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(stmt, 1, name.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_bind_text(stmt, 2, description.c_str(), -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(stmt, 2, description.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_bind_text(stmt, 3, year.c_str(), -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(stmt, 3, year.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_bind_text(stmt, 4, manufacturer.c_str(), -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(stmt, 4, manufacturer.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_bind_text(stmt, 5, players.c_str(), -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(stmt, 5, players.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_bind_text(stmt, 6, buttons.c_str(), -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(stmt, 6, buttons.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_bind_text(stmt, 7, cloneOf.c_str(), -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(stmt, 7, cloneOf.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_bind_text(stmt, 8, collectionName.c_str(), -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(stmt, 8, collectionName.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
|
|
||||||
sqlite3_step(stmt);
|
sqlite3_step(stmt);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_exec(handle, "COMMIT TRANSACTION;", NULL, NULL, &error);
|
Config.SetStatus("Saving data from \"" + filename + "\" to database");
|
||||||
|
sqlite3_exec(handle, "COMMIT TRANSACTION;", NULL, NULL, &error);
|
||||||
return retVal;
|
|
||||||
}
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -243,6 +243,12 @@ void RetroFE::Run()
|
|||||||
{
|
{
|
||||||
state = ProcessUserInput(page);
|
state = ProcessUserInput(page);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// read and discard SDL input to prevent windows from balking at us
|
||||||
|
SDL_Event e;
|
||||||
|
(void)SDL_PollEvent(&e);
|
||||||
|
}
|
||||||
|
|
||||||
if(Initialized && splashMode)
|
if(Initialized && splashMode)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user