mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Universal-Updater -> DarkStore Part 2
Renamed Strings For DarkStore Made .store Files Useable
This commit is contained in:
+23
-23
@@ -73,7 +73,7 @@ void Meta::ImportMetadata() {
|
||||
if (oldJson.is_discarded())
|
||||
oldJson = { };
|
||||
|
||||
std::vector<UniStoreInfo> info = GetUniStoreInfo(_STORE_PATH); // Fetch UniStores.
|
||||
std::vector<StoreInfo> info = GetStoreInfo(_STORE_PATH); // Fetch Stores.
|
||||
|
||||
for (int i = 0; i < (int)info.size(); i++) {
|
||||
if (info[i].Title != "" && oldJson.contains(info[i].FileName)) {
|
||||
@@ -89,49 +89,49 @@ void Meta::ImportMetadata() {
|
||||
/*
|
||||
Get Last Updated.
|
||||
|
||||
const std::string &unistoreName: The UniStore name.
|
||||
const std::string &storeName: The Store name.
|
||||
const std::string &entry: The Entry name.
|
||||
*/
|
||||
std::string Meta::GetUpdated(const std::string &unistoreName, const std::string &entry) const {
|
||||
if (!this->metadataJson.contains(unistoreName)) return ""; // UniStore Name does not exist.
|
||||
std::string Meta::GetUpdated(const std::string &storeName, const std::string &entry) const {
|
||||
if (!this->metadataJson.contains(storeName)) return ""; // Store Name does not exist.
|
||||
|
||||
if (!this->metadataJson[unistoreName].contains(entry)) return ""; // Entry does not exist.
|
||||
if (!this->metadataJson[storeName].contains(entry)) return ""; // Entry does not exist.
|
||||
|
||||
if (!this->metadataJson[unistoreName][entry].contains("updated")) return ""; // updated does not exist.
|
||||
if (!this->metadataJson[storeName][entry].contains("updated")) return ""; // updated does not exist.
|
||||
|
||||
if (this->metadataJson[unistoreName][entry]["updated"].is_string()) return this->metadataJson[unistoreName][entry]["updated"];
|
||||
if (this->metadataJson[storeName][entry]["updated"].is_string()) return this->metadataJson[storeName][entry]["updated"];
|
||||
return "";
|
||||
}
|
||||
|
||||
/*
|
||||
Get the marks.
|
||||
|
||||
const std::string &unistoreName: The UniStore name.
|
||||
const std::string &storeName: The Store name.
|
||||
const std::string &entry: The Entry name.
|
||||
*/
|
||||
int Meta::GetMarks(const std::string &unistoreName, const std::string &entry) const {
|
||||
int Meta::GetMarks(const std::string &storeName, const std::string &entry) const {
|
||||
int temp = 0;
|
||||
|
||||
if (!this->metadataJson.contains(unistoreName)) return temp; // UniStore Name does not exist.
|
||||
if (!this->metadataJson.contains(storeName)) return temp; // Store Name does not exist.
|
||||
|
||||
if (!this->metadataJson[unistoreName].contains(entry)) return temp; // Entry does not exist.
|
||||
if (!this->metadataJson[storeName].contains(entry)) return temp; // Entry does not exist.
|
||||
|
||||
if (!this->metadataJson[unistoreName][entry].contains("marks")) return temp; // marks does not exist.
|
||||
if (!this->metadataJson[storeName][entry].contains("marks")) return temp; // marks does not exist.
|
||||
|
||||
if (this->metadataJson[unistoreName][entry]["marks"].is_number()) return this->metadataJson[unistoreName][entry]["marks"];
|
||||
if (this->metadataJson[storeName][entry]["marks"].is_number()) return this->metadataJson[storeName][entry]["marks"];
|
||||
return temp;
|
||||
}
|
||||
|
||||
/*
|
||||
Return, if update available.
|
||||
|
||||
const std::string &unistoreName: The UniStore name.
|
||||
const std::string &storeName: The Store name.
|
||||
const std::string &entry: The Entry name.
|
||||
const std::string &updated: Compare for the update.
|
||||
*/
|
||||
bool Meta::UpdateAvailable(const std::string &unistoreName, const std::string &entry, const std::string &updated) const {
|
||||
if (this->GetUpdated(unistoreName, entry) != "" && updated != "") {
|
||||
return strcasecmp(updated.c_str(), this->GetUpdated(unistoreName, entry).c_str()) > 0;
|
||||
bool Meta::UpdateAvailable(const std::string &storeName, const std::string &entry, const std::string &updated) const {
|
||||
if (this->GetUpdated(storeName, entry) != "" && updated != "") {
|
||||
return strcasecmp(updated.c_str(), this->GetUpdated(storeName, entry).c_str()) > 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -140,17 +140,17 @@ bool Meta::UpdateAvailable(const std::string &unistoreName, const std::string &e
|
||||
/*
|
||||
Get the marks.
|
||||
|
||||
const std::string &unistoreName: The UniStore name.
|
||||
const std::string &storeName: The Store name.
|
||||
const std::string &entry: The Entry name.
|
||||
*/
|
||||
std::vector<std::string> Meta::GetInstalled(const std::string &unistoreName, const std::string &entry) const {
|
||||
if (!this->metadataJson.contains(unistoreName)) return { }; // UniStore Name does not exist.
|
||||
std::vector<std::string> Meta::GetInstalled(const std::string &storeName, const std::string &entry) const {
|
||||
if (!this->metadataJson.contains(storeName)) return { }; // Store Name does not exist.
|
||||
|
||||
if (!this->metadataJson[unistoreName].contains(entry)) return { }; // Entry does not exist.
|
||||
if (!this->metadataJson[storeName].contains(entry)) return { }; // Entry does not exist.
|
||||
|
||||
if (!this->metadataJson[unistoreName][entry].contains("installed")) return { }; // marks does not exist.
|
||||
if (!this->metadataJson[storeName][entry].contains("installed")) return { }; // marks does not exist.
|
||||
|
||||
if (this->metadataJson[unistoreName][entry]["installed"].is_array()) return this->metadataJson[unistoreName][entry]["installed"];
|
||||
if (this->metadataJson[storeName][entry]["installed"].is_array()) return this->metadataJson[storeName][entry]["installed"];
|
||||
return { };
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -38,8 +38,8 @@ static bool firstStart = true;
|
||||
/*
|
||||
Initialize a Store.
|
||||
|
||||
const std::string &file: The UniStore file.
|
||||
const std::string &file2: The UniStore file.. without full path.
|
||||
const std::string &file: The Store file.
|
||||
const std::string &file2: The Store file.. without full path.
|
||||
bool ARGMode: If Argument mode.
|
||||
*/
|
||||
Store::Store(const std::string &file, const std::string &file2, bool ARGMode) {
|
||||
@@ -62,7 +62,7 @@ Store::Store(const std::string &file, const std::string &file2, bool ARGMode) {
|
||||
};
|
||||
|
||||
/*
|
||||
Update an UniStore, including SpriteSheet, if revision increased.
|
||||
Update an Store, including SpriteSheet, if revision increased.
|
||||
|
||||
const std::string &file: Const Reference to the fileName.
|
||||
*/
|
||||
@@ -100,7 +100,7 @@ void Store::update(const std::string &file) {
|
||||
|
||||
if (URL != "") {
|
||||
std::string tmp = "";
|
||||
doSheet = DownloadUniStore(URL, rev, tmp);
|
||||
doSheet = DownloadStore(URL, rev, tmp);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -218,9 +218,9 @@ void Store::loadSheets() {
|
||||
|
||||
|
||||
/*
|
||||
Load a UniStore from a file.
|
||||
Load a Store from a file.
|
||||
|
||||
const std::string &file: The file of the UniStore.
|
||||
const std::string &file: The file of the Store.
|
||||
*/
|
||||
void Store::LoadFromFile(const std::string &file) {
|
||||
FILE *in = fopen(file.c_str(), "rt");
|
||||
@@ -237,22 +237,22 @@ void Store::LoadFromFile(const std::string &file) {
|
||||
/* Check, if valid. */
|
||||
if (this->storeJson.contains("storeInfo") && this->storeJson.contains("storeContent")) {
|
||||
if (this->storeJson["storeInfo"].contains("version") && this->storeJson["storeInfo"]["version"].is_number()) {
|
||||
if (this->storeJson["storeInfo"]["version"] < 3) Msg::waitMsg(Lang::get("UNISTORE_TOO_OLD"));
|
||||
else if (this->storeJson["storeInfo"]["version"] > _UNISTORE_VERSION) Msg::waitMsg(Lang::get("UNISTORE_TOO_NEW"));
|
||||
else if (this->storeJson["storeInfo"]["version"] == 3 || this->storeJson["storeInfo"]["version"] == _UNISTORE_VERSION) {
|
||||
if (this->storeJson["storeInfo"]["version"] < 3) Msg::waitMsg(Lang::get("STORE_TOO_OLD"));
|
||||
else if (this->storeJson["storeInfo"]["version"] > _STORE_VERSION) Msg::waitMsg(Lang::get("STORE_TOO_NEW"));
|
||||
else if (this->storeJson["storeInfo"]["version"] == 3 || this->storeJson["storeInfo"]["version"] == _STORE_VERSION) {
|
||||
this->valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
Msg::waitMsg(Lang::get("UNISTORE_INVALID_ERROR"));
|
||||
Msg::waitMsg(Lang::get("STORE_INVALID_ERROR"));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Return the Title of the UniStore.
|
||||
Return the Title of the Store.
|
||||
*/
|
||||
std::string Store::GetUniStoreTitle() const {
|
||||
std::string Store::GetStoreTitle() const {
|
||||
if (this->valid) {
|
||||
if (this->storeJson["storeInfo"].contains("title")) return this->storeJson["storeInfo"]["title"];
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ StoreEntry::StoreEntry(const std::unique_ptr<Store> &store, const std::unique_pt
|
||||
this->Console = StringUtils::FetchStringsFromVector(store->GetConsoleEntry(index));
|
||||
this->LastUpdated = store->GetLastUpdatedEntry(index);
|
||||
this->License = store->GetLicenseEntry(index);
|
||||
this->MarkString = StringUtils::GetMarkString(meta->GetMarks(store->GetUniStoreTitle(), this->Title));
|
||||
this->MarkString = StringUtils::GetMarkString(meta->GetMarks(store->GetStoreTitle(), this->Title));
|
||||
|
||||
this->Icon = store->GetIconEntry(index);
|
||||
this->SheetIndex = 0;
|
||||
@@ -53,8 +53,8 @@ StoreEntry::StoreEntry(const std::unique_ptr<Store> &store, const std::unique_pt
|
||||
this->FullCategory = store->GetCategoryIndex(index);
|
||||
this->FullConsole = store->GetConsoleEntry(index);
|
||||
|
||||
this->UpdateAvailable = meta->UpdateAvailable(store->GetUniStoreTitle(), this->Title, store->GetLastUpdatedEntry(index));
|
||||
this->Marks = meta->GetMarks(store->GetUniStoreTitle(), this->Title);
|
||||
this->UpdateAvailable = meta->UpdateAvailable(store->GetStoreTitle(), this->Title, store->GetLastUpdatedEntry(index));
|
||||
this->Marks = meta->GetMarks(store->GetStoreTitle(), this->Title);
|
||||
|
||||
const std::vector<std::string> entries = store->GetDownloadList(index);
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ void StoreUtils::ResetAll() {
|
||||
void StoreUtils::RefreshUpdateAVL() {
|
||||
for (int i = 0; i < (int)StoreUtils::entries.size(); i++) {
|
||||
if (StoreUtils::entries[i]) {
|
||||
StoreUtils::entries[i]->SetUpdateAvl(StoreUtils::meta->UpdateAvailable(StoreUtils::store->GetUniStoreTitle(), StoreUtils::entries[i]->GetTitle(), StoreUtils::entries[i]->GetLastUpdated()));
|
||||
StoreUtils::entries[i]->SetUpdateAvl(StoreUtils::meta->UpdateAvailable(StoreUtils::store->GetStoreTitle(), StoreUtils::entries[i]->GetTitle(), StoreUtils::entries[i]->GetLastUpdated()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@ void StoreUtils::AddToQueue(int index, const std::string &entry, const std::stri
|
||||
}
|
||||
}
|
||||
|
||||
QueueSystem::AddToQueue(Script, StoreUtils::store->GetIconEntry(index), entry, StoreUtils::store->GetUniStoreTitle(), entryName, lUpdated); // Here we add this to the Queue at the end.
|
||||
QueueSystem::AddToQueue(Script, StoreUtils::store->GetIconEntry(index), entry, StoreUtils::store->GetStoreTitle(), entryName, lUpdated); // Here we add this to the Queue at the end.
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -221,7 +221,7 @@ void StoreUtils::AddAllToQueue() {
|
||||
if (StoreUtils::entries[storeEntry]) { // Ensure pointer is valid.
|
||||
|
||||
const std::vector<std::string> entryNames = StoreUtils::store->GetDownloadList(StoreUtils::entries[storeEntry]->GetEntryIndex()); // Return a vector of all Download Entries.
|
||||
const std::vector<std::string> installedNames = StoreUtils::meta->GetInstalled(StoreUtils::store->GetUniStoreTitle(), StoreUtils::entries[storeEntry]->GetTitle()); // Return a vector from all installed entries.
|
||||
const std::vector<std::string> installedNames = StoreUtils::meta->GetInstalled(StoreUtils::store->GetStoreTitle(), StoreUtils::entries[storeEntry]->GetTitle()); // Return a vector from all installed entries.
|
||||
|
||||
if (!entryNames.empty() && !installedNames.empty()) { // Ensure both aren't empty.
|
||||
for (int i = 0; i < (int)entryNames.size(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user