aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--launcher/minecraft/mod/Mod.cpp28
-rw-r--r--launcher/minecraft/mod/Mod.h6
-rw-r--r--launcher/minecraft/mod/ModDetails.h9
-rw-r--r--launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp8
-rw-r--r--launcher/modplatform/ModIndex.cpp2
-rw-r--r--launcher/modplatform/packwiz/Packwiz.cpp9
6 files changed, 49 insertions, 13 deletions
diff --git a/launcher/minecraft/mod/Mod.cpp b/launcher/minecraft/mod/Mod.cpp
index 992b91dc..261ae9d2 100644
--- a/launcher/minecraft/mod/Mod.cpp
+++ b/launcher/minecraft/mod/Mod.cpp
@@ -54,7 +54,6 @@ Mod::Mod(const QDir& mods_dir, const Metadata::ModStruct& metadata)
m_type = MOD_SINGLEFILE;
}
- m_from_metadata = true;
m_enabled = true;
m_changedDateTime = m_file.lastModified();
@@ -117,13 +116,27 @@ auto Mod::enable(bool value) -> bool
return false;
}
- if (!fromMetadata())
+ if (status() == ModStatus::NoMetadata)
repath(QFileInfo(path));
m_enabled = value;
return true;
}
+void Mod::setStatus(ModStatus status)
+{
+ if(m_localDetails.get())
+ m_localDetails->status = status;
+}
+void Mod::setMetadata(Metadata::ModStruct* metadata)
+{
+ if(status() == ModStatus::NoMetadata)
+ setStatus(ModStatus::Installed);
+
+ if(m_localDetails.get())
+ m_localDetails->metadata.reset(metadata);
+}
+
auto Mod::destroy(QDir& index_dir) -> bool
{
auto n = name();
@@ -170,13 +183,22 @@ auto Mod::authors() const -> QStringList
return details().authors;
}
+auto Mod::status() const -> ModStatus
+{
+ return details().status;
+}
+
void Mod::finishResolvingWithDetails(std::shared_ptr<ModDetails> details)
{
m_resolving = false;
m_resolved = true;
m_localDetails = details;
- if (fromMetadata() && m_temp_metadata->isValid() && m_localDetails.get()) {
+ if (status() != ModStatus::NoMetadata
+ && m_temp_metadata.get()
+ && m_temp_metadata->isValid() &&
+ m_localDetails.get()) {
+
m_localDetails->metadata.swap(m_temp_metadata);
}
}
diff --git a/launcher/minecraft/mod/Mod.h b/launcher/minecraft/mod/Mod.h
index 3a0ccfa6..58c7a80f 100644
--- a/launcher/minecraft/mod/Mod.h
+++ b/launcher/minecraft/mod/Mod.h
@@ -41,7 +41,6 @@ public:
auto dateTimeChanged() const -> QDateTime { return m_changedDateTime; }
auto internal_id() const -> QString { return m_internal_id; }
auto type() const -> ModType { return m_type; }
- auto fromMetadata() const -> bool { return m_from_metadata; }
auto enabled() const -> bool { return m_enabled; }
auto valid() const -> bool { return m_type != MOD_UNKNOWN; }
@@ -52,10 +51,14 @@ public:
auto homeurl() const -> QString;
auto description() const -> QString;
auto authors() const -> QStringList;
+ auto status() const -> ModStatus;
auto metadata() const -> const std::shared_ptr<Metadata::ModStruct> { return details().metadata; };
auto metadata() -> std::shared_ptr<Metadata::ModStruct> { return m_localDetails->metadata; };
+ void setStatus(ModStatus status);
+ void setMetadata(Metadata::ModStruct* metadata);
+
auto enable(bool value) -> bool;
// delete all the files of this mod
@@ -82,7 +85,6 @@ protected:
/* Name as reported via the file name */
QString m_name;
ModType m_type = MOD_UNKNOWN;
- bool m_from_metadata = false;
/* If the mod has metadata, this will be filled in the constructor, and passed to
* the ModDetails when calling finishResolvingWithDetails */
diff --git a/launcher/minecraft/mod/ModDetails.h b/launcher/minecraft/mod/ModDetails.h
index f9973fc2..75ffea32 100644
--- a/launcher/minecraft/mod/ModDetails.h
+++ b/launcher/minecraft/mod/ModDetails.h
@@ -7,6 +7,12 @@
#include "minecraft/mod/MetadataHandler.h"
+enum class ModStatus {
+ Installed, // Both JAR and Metadata are present
+ NotInstalled, // Only the Metadata is present
+ NoMetadata, // Only the JAR is present
+};
+
struct ModDetails
{
/* Mod ID as defined in the ModLoader-specific metadata */
@@ -30,6 +36,9 @@ struct ModDetails
/* List of the author's names */
QStringList authors;
+ /* Installation status of the mod */
+ ModStatus status;
+
/* Metadata information, if any */
std::shared_ptr<Metadata::ModStruct> metadata;
};
diff --git a/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp b/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
index 03a17461..addb0dd8 100644
--- a/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
+++ b/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
@@ -19,8 +19,13 @@ void ModFolderLoadTask::run()
m_mods_dir.refresh();
for (auto entry : m_mods_dir.entryInfoList()) {
Mod mod(entry);
- if (!m_result->mods.contains(mod.internal_id()))
+ if(m_result->mods.contains(mod.internal_id())){
+ m_result->mods[mod.internal_id()].setStatus(ModStatus::Installed);
+ }
+ else {
m_result->mods[mod.internal_id()] = mod;
+ m_result->mods[mod.internal_id()].setStatus(ModStatus::NoMetadata);
+ }
}
emit succeeded();
@@ -42,6 +47,7 @@ void ModFolderLoadTask::getFromMetadata()
}
Mod mod(m_mods_dir, metadata);
+ mod.setStatus(ModStatus::NotInstalled);
m_result->mods[mod.internal_id()] = mod;
}
}
diff --git a/launcher/modplatform/ModIndex.cpp b/launcher/modplatform/ModIndex.cpp
index eb8be992..b3c057fb 100644
--- a/launcher/modplatform/ModIndex.cpp
+++ b/launcher/modplatform/ModIndex.cpp
@@ -10,6 +10,7 @@ auto ProviderCapabilities::name(Provider p) -> const char*
case Provider::FLAME:
return "curseforge";
}
+ return {};
}
auto ProviderCapabilities::hashType(Provider p) -> QString
{
@@ -19,6 +20,7 @@ auto ProviderCapabilities::hashType(Provider p) -> QString
case Provider::FLAME:
return "murmur2";
}
+ return {};
}
} // namespace ModPlatform
diff --git a/launcher/modplatform/packwiz/Packwiz.cpp b/launcher/modplatform/packwiz/Packwiz.cpp
index 872da9b1..50f87c24 100644
--- a/launcher/modplatform/packwiz/Packwiz.cpp
+++ b/launcher/modplatform/packwiz/Packwiz.cpp
@@ -48,14 +48,9 @@ auto V1::createModFormat(QDir& index_dir, ::Mod& internal_mod) -> Mod
if(mod.isValid())
return mod;
- // Manually construct packwiz mod
- mod.name = internal_mod.name();
- mod.filename = internal_mod.fileinfo().fileName();
+ qWarning() << QString("Tried to create mod metadata with a Mod without metadata!");
- // TODO: Have a mechanism for telling the UI subsystem that we want to gather user information
- // (i.e. which mod provider we want to use). Maybe an object parameter with a signal for that?
-
- return mod;
+ return {};
}
void V1::updateModIndex(QDir& index_dir, Mod& mod)