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