aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
authorkumquat-ir <66188216+kumquat-ir@users.noreply.github.com>2023-02-12 17:23:15 -0500
committerkumquat-ir <66188216+kumquat-ir@users.noreply.github.com>2023-02-12 17:23:15 -0500
commitc07fff750354e23149470d493a7c96624fe2ab26 (patch)
tree8d9c030ad178c08a8183b3bd2c5a89a573f641f9 /launcher
parent7896dd19c12c0276551ba188adc6184dcf0a3184 (diff)
downloadPrismLauncher-c07fff750354e23149470d493a7c96624fe2ab26.tar.gz
PrismLauncher-c07fff750354e23149470d493a7c96624fe2ab26.tar.bz2
PrismLauncher-c07fff750354e23149470d493a7c96624fe2ab26.zip
switch to qdcss for parsing
make it not horrible to look at Signed-off-by: kumquat-ir <66188216+kumquat-ir@users.noreply.github.com>
Diffstat (limited to 'launcher')
-rw-r--r--launcher/CMakeLists.txt1
-rw-r--r--launcher/minecraft/mod/tasks/LocalModParseTask.cpp41
2 files changed, 14 insertions, 28 deletions
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 1bfe9cbc..c6b9e380 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -1025,6 +1025,7 @@ target_link_libraries(Launcher_logic
nbt++
${ZLIB_LIBRARIES}
tomlplusplus::tomlplusplus
+ qdcss
BuildConfig
Katabasis
Qt${QT_VERSION_MAJOR}::Widgets
diff --git a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp
index 03b599ea..2263f8ec 100644
--- a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp
+++ b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp
@@ -3,6 +3,7 @@
#include <quazip/quazip.h>
#include <quazip/quazipfile.h>
#include <toml++/toml.h>
+#include <qdcss.h>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
@@ -290,37 +291,21 @@ ModDetails ReadNilModInfo(QByteArray contents, QString fname)
{
ModDetails details;
- // this is a css file (why) but we only care about a couple key/value pairs from it
- // hence this instead of a css parser lib
- // could be made a lot better but it works(tm)
- // (does css require properties to be on their own lines? if so, the code can get less horrible looking)
- QString contentStr = QString(contents).trimmed();
- int firstidx = contentStr.indexOf("@nilmod");
- firstidx = contentStr.indexOf("{", firstidx);
- int lastidx = contentStr.indexOf("}", firstidx);
- int nameidx = contentStr.indexOf("name:", firstidx);
- int descidx = contentStr.indexOf("description:", firstidx);
- int authorsidx = contentStr.indexOf("authors:", firstidx);
- int versionidx = contentStr.indexOf("version:", firstidx);
-
- if (nameidx != -1 && nameidx < lastidx) {
- nameidx = contentStr.indexOf('"', nameidx);
- details.name = contentStr.mid(nameidx + 1, contentStr.indexOf('"', nameidx + 1) - nameidx - 1);
- }
- if (descidx != -1 && descidx < lastidx) {
- descidx = contentStr.indexOf('"', descidx);
- details.description = contentStr.mid(descidx + 1, contentStr.indexOf('"', descidx + 1) - descidx - 1);
+ QDCSS cssData = QDCSS(contents);
+ auto name = cssData.get("@nilmod.name");
+ auto desc = cssData.get("@nilmod.description");
+ auto authors = cssData.get("@nilmod.authors");
+
+ if (name->has_value()) {
+ details.name = name->value();
}
- if (authorsidx != -1 && authorsidx < lastidx) {
- authorsidx = contentStr.indexOf('"', authorsidx);
- details.authors.append(contentStr.mid(authorsidx + 1, contentStr.indexOf('"', authorsidx + 1) - authorsidx - 1));
+ if (desc->has_value()) {
+ details.description = desc->value();
}
- if (versionidx != -1 && versionidx < lastidx) {
- versionidx = contentStr.indexOf('"', versionidx);
- details.version = contentStr.mid(versionidx + 1, contentStr.indexOf('"', versionidx + 1) - versionidx - 1);
- } else {
- details.version = "?";
+ if (authors->has_value()) {
+ details.authors.append(authors->value());
}
+ details.version = cssData.get("@nilmod.version")->value_or("?");
details.mod_id = fname.remove(".nilmod.css");