From e0f87002f6f12a3e1b84da2d76e9c97e94090979 Mon Sep 17 00:00:00 2001 From: kaniol-lck <375520360@qq.com> Date: Wed, 3 Jul 2024 11:47:19 +0800 Subject: [PATCH] fix curseforge file update --- modmanager.pro | 2 +- src/curseforge/curseforgemod.cpp | 8 ++++---- src/curseforge/curseforgemod.h | 2 +- src/local/localmod.cpp | 12 +++++++++--- src/ui/framelesswrapper.cpp | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/modmanager.pro b/modmanager.pro index fdc0686..5b0a72c 100644 --- a/modmanager.pro +++ b/modmanager.pro @@ -71,7 +71,7 @@ unix { INSTALLS += target CONFIG(debug, debug|release) { -# QMAKE_CXXFLAGS_DEBUG += -g3 -O0 +# QMAKE_CXXFLAGS_DEBUG += -g3 -O0 message("Currently in DEBUG mode.") } else { DEFINES += QT_NO_DEBUG QT_NO_DEBUG_OUTPUT diff --git a/src/curseforge/curseforgemod.cpp b/src/curseforge/curseforgemod.cpp index 3ee1079..1ca3a51 100644 --- a/src/curseforge/curseforgemod.cpp +++ b/src/curseforge/curseforgemod.cpp @@ -106,9 +106,9 @@ std::shared_ptr > > CurseforgeMod::acquireLatest std::shared_ptr, int>> CurseforgeMod::acquireMoreFileList(GameVersion version, ModLoaderType::Type loaderType, bool clear) { - if(allFileListGetter_ && allFileListGetter_->isRunning()) return allFileListGetter_; - allFileListGetter_ = api_->getModFiles(modInfo_.id(), clear? 0: modInfo().allFileList().size(), version, loaderType).asShared(); - allFileListGetter_->setOnFinished(this, [=](const QList &fileList, int count){ + if(moreFileListGetter_ && moreFileListGetter_->isRunning()) return moreFileListGetter_; + moreFileListGetter_ = api_->getModFiles(modInfo_.id(), clear? 0: modInfo().allFileList().size(), version, loaderType).asShared(); + moreFileListGetter_->setOnFinished(this, [=](const QList &fileList, int count){ if(clear) modInfo_.allFileList_ = fileList; else @@ -118,7 +118,7 @@ std::shared_ptr, int>> CurseforgeMod::acquireMor }, [=](auto){ emit moreFileListReady({}); }); - return allFileListGetter_; + return moreFileListGetter_; } const CurseforgeModInfo &CurseforgeMod::modInfo() const diff --git a/src/curseforge/curseforgemod.h b/src/curseforge/curseforgemod.h index 29962c0..61875cf 100644 --- a/src/curseforge/curseforgemod.h +++ b/src/curseforge/curseforgemod.h @@ -53,7 +53,7 @@ class CurseforgeMod : public QObject, public Tagable bool gettingIcon_ = false; std::unique_ptr> descriptionGetter_; std::shared_ptr>> latestIndexedFileListGetter_; - std::shared_ptr, int>> allFileListGetter_; + std::shared_ptr, int>> moreFileListGetter_; }; #endif // CURSEFORGEMOD_H diff --git a/src/local/localmod.cpp b/src/local/localmod.cpp index c388f7d..18f6d61 100644 --- a/src/local/localmod.cpp +++ b/src/local/localmod.cpp @@ -161,13 +161,19 @@ void LocalMod::checkCurseforgeUpdate(bool force) emit checkCurseforgeUpdateStarted(); //update file list if(force || curseforgeMod_->modInfo().allFileList().isEmpty()){ - //TODO - curseforgeFileListGetter_ = curseforgeMod_->acquireMoreFileList(); + curseforgeFileListGetter_ = curseforgeMod_->acquireMoreFileList(path()->info().gameVersion(), path()->info().loaderType()); curseforgeFileListGetter_->setOnFinished(this, [=](const QList &, int count){ curseforgeUpdater_.findUpdate(modFile_->linker()->curseforgeFileInfo()); emit curseforgeUpdateReady(true); }, [=](auto){ - emit curseforgeUpdateReady(false); + // major version instead + curseforgeFileListGetter_ = curseforgeMod_->acquireMoreFileList(path()->info().gameVersion().majorVersion(), path()->info().loaderType()); + curseforgeFileListGetter_->setOnFinished(this, [=](const QList &, int count){ + curseforgeUpdater_.findUpdate(modFile_->linker()->curseforgeFileInfo()); + emit curseforgeUpdateReady(true); + }, [=](auto){ + emit curseforgeUpdateReady(false); + }); }); }else { curseforgeUpdater_.findUpdate(modFile_->linker()->curseforgeFileInfo()); diff --git a/src/ui/framelesswrapper.cpp b/src/ui/framelesswrapper.cpp index d5c65e3..25e32d0 100644 --- a/src/ui/framelesswrapper.cpp +++ b/src/ui/framelesswrapper.cpp @@ -135,7 +135,7 @@ bool FramelessWrapper::nativeEvent(const QByteArray &eventType, void *message, l titleBar_->setNormal(); } *result = ::DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam); - break; + break; } } return false;