Skip to content

Commit

Permalink
remove mod update functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshadow565 committed Jun 3, 2024
1 parent bd5f892 commit 0949d54
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 259 deletions.
2 changes: 1 addition & 1 deletion cslol-tools/src/main_diag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static void check_basic_info() {
static void check_patcher_signature(bool interactive) {
auto const dll = basedir(exe_path()) + L"//cslol-dll.dll";
if (GetFileAttributesW(dll.c_str()) == INVALID_FILE_ATTRIBUTES) {
wprintf(L"Patcher dll: missing [%hs]", dll.c_str(), REP_SUS);
wprintf(L"Patcher dll: missing [%hs]\n", REP_SUS);
return;
}
auto file = WINTRUST_FILE_INFO{
Expand Down
1 change: 0 additions & 1 deletion src/CSLOLTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ CSLOLTools::CSLOLTools(QObject *parent) : QObject(parent) {
connect(this, &CSLOLTools::addModWad, worker_, &CSLOLToolsImpl::addModWad);
connect(this, &CSLOLTools::removeModWads, worker_, &CSLOLToolsImpl::removeModWads);
connect(this, &CSLOLTools::refreshMods, worker_, &CSLOLToolsImpl::refreshMods);
connect(this, &CSLOLTools::doUpdate, worker_, &CSLOLToolsImpl::doUpdate);
connect(this, &CSLOLTools::runDiag, worker_, &CSLOLToolsImpl::runDiag);

connect(this, &CSLOLTools::destroyed, worker_, &CSLOLToolsImpl::deleteLater);
Expand Down
1 change: 0 additions & 1 deletion src/CSLOLTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class CSLOLTools : public QObject {
void addModWad(QString modFileName, QString wad, bool removeUnknownNames);
void removeModWads(QString modFileName, QJsonArray wads);
void refreshMods();
void doUpdate(QString urls);
void runDiag();

public slots:
Expand Down
79 changes: 0 additions & 79 deletions src/CSLOLToolsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,85 +436,6 @@ void CSLOLToolsImpl::refreshMods() {
}
}

void CSLOLToolsImpl::doUpdate(QString urls) {
if (!networkManager_) {
this->networkManager_ = new QNetworkAccessManager(this);
this->networkManager_->setTransferTimeout(30000);
connect(this->networkManager_, &QNetworkAccessManager::finished, this, [this](QNetworkReply* reply) {
if (reply->error()) {
auto error = reply->errorString();
setStatus("[WRN] Failed to fetch update index: " + error);
this->networkResults_.push_back(QJsonDocument::fromJson("[]"));
} else {
auto result = reply->readAll();
this->networkResults_.push_back(QJsonDocument::fromJson(result));
}

if (this->networkResults_.size() < this->networkRequests_.size()) {
return;
}

auto lookup = QMap<QString, QVersionNumber>{};
for (auto name : modList()) {
auto info = modInfoRead(name);
auto key = info["Name"].toString().toLower();
auto version = QVersionNumber::fromString(info["Version"].toString());
lookup[key] = version;
}

auto mods = QJsonArray{};
for (auto const& result : this->networkResults_) {
if (!result.isArray()) {
continue;
}
for (auto const& value : result.array()) {
auto info = modInfoFixup("", value.toObject());
if (info["Download"].toString().isEmpty() || !info["Download"].isString()) {
info["Download"] = info["Home"];
}
auto key = info["Name"].toString().toLower();
if (lookup.contains(key)) {
auto const& old_version = lookup[key];
auto new_version = QVersionNumber::fromString(info["Version"].toString());
if (old_version < new_version) {
mods.append(info);
}
}
}
}

emit updatedMods(mods);

setState(CSLOLState::StateIdle);
});
}

if (state_ == CSLOLState::StateIdle) {
setState(CSLOLState::StateBusy);
setStatus("Updating mods");

this->networkResults_.clear();
this->networkRequests_.clear();
for (auto url : urls.split('\n')) {
url = url.trimmed();
if (url.isEmpty() || url.startsWith("#")) {
continue;
}
this->networkRequests_.emplace_back(QUrl(url));
}

if (this->networkRequests_.empty()) {
doReportError("Update mods", "Make sure to set update urls in settings!", "");
setState(CSLOLState::StateIdle);
return;
}

for (auto& req : this->networkRequests_) {
this->networkManager_->get(req);
}
}
}

void CSLOLToolsImpl::runDiag() {
if (state_ == CSLOLState::StateIdle) {
setState(CSLOLState::StateBusy);
Expand Down
1 change: 0 additions & 1 deletion src/CSLOLToolsImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public slots:
void stopProfile();
void makeMod(QString fileName, QJsonObject infoData, QString image);
void refreshMods();
void doUpdate(QString urls);
void runDiag();

void startEditMod(QString fileName);
Expand Down
19 changes: 0 additions & 19 deletions src/qml/CSLOLDialogSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Dialog {
property alias suppressInstallConflicts: suppressInstallConflictsCheck.checked
property alias enableSystray: enableSystrayCheck.checked
property alias enableAutoRun: enableAutoRunCheck.checked
property alias updateUrls: updateUrlsTextArea.text
property alias debugPatcher: debugPatcherCheck.checked

property var colors_LIST: [
Expand Down Expand Up @@ -126,24 +125,6 @@ Dialog {
onClicked: Qt.openUrlExternally(CSLOLUtils.toFile("./log.txt"))
Layout.fillWidth: true
}
Button {
text: qsTr("Updates")
onClicked: Qt.openUrlExternally(cslolDialogUpdate.update_url)
Layout.fillWidth: true
}
ScrollView {
Layout.fillHeight: true
Layout.fillWidth: true
ScrollBar.horizontal.policy: ScrollBar.AsNeeded
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
padding: ScrollBar.vertical.width
clip: true
TextArea {
id: updateUrlsTextArea
placeholderText: qsTr("Update urls")
textFormat: TextEdit.PlainText
}
}
CheckBox {
id: enableUpdatesCheck
text: qsTr("Enable updates")
Expand Down
135 changes: 0 additions & 135 deletions src/qml/CSLOLDialogUpdateMods.qml

This file was deleted.

13 changes: 0 additions & 13 deletions src/qml/CSLOLModsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ ColumnLayout {

signal tryRefresh()

signal getUpdates()

function addMod(fileName, info, enabled) {
let infoData = {
"FileName": fileName,
Expand Down Expand Up @@ -467,17 +465,6 @@ ColumnLayout {
visible: parent.hovered
}
}
RoundButton {
enabled: !isBussy
text: "\uf0ad"
font.family: "FontAwesome"
onClicked: cslolModsView.getUpdates()
Material.background: Material.primaryColor
CSLOLToolTip {
text: qsTr("Mod updates and fixes")
visible: parent.hovered
}
}
RoundButton {
enabled: !isBussy
text: "\uf067"
Expand Down
8 changes: 0 additions & 8 deletions src/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ApplicationWindow {
property alias blacklist: cslolDialogSettings.blacklist
property alias ignorebad: cslolDialogSettings.ignorebad
property alias suppressInstallConflicts: cslolDialogSettings.suppressInstallConflicts
property alias updateUrls: cslolDialogSettings.updateUrls
property alias enableUpdates: cslolDialogSettings.enableUpdates
property alias enableAutoRun: cslolDialogSettings.enableAutoRun
property alias enableSystray: cslolDialogSettings.enableSystray
Expand Down Expand Up @@ -223,7 +222,6 @@ ApplicationWindow {
}
}
onTryRefresh: cslolTools.refreshMods()
onGetUpdates: cslolTools.doUpdate(settings.updateUrls)
}

footer: CSLOLStatusBar {
Expand Down Expand Up @@ -315,12 +313,6 @@ ApplicationWindow {
enableUpdates: settings.enableUpdates
}

CSLOLDialogUpdateMods {
id: cslolDialogUpdateMods
rowHeight: cslolToolBar.height
columnCount: Math.max(1, Math.floor(window.width / window.minimumWidth))
}

CSLOLTools {
id: cslolTools
onInitialized: function(mods, profiles, profileName, profileMods) {
Expand Down
1 change: 0 additions & 1 deletion src/qml/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@
<file>CSLOLModInfoEdit.qml</file>
<file>CSLOLDialogGame.qml</file>
<file>CSLOLToolTip.qml</file>
<file>CSLOLDialogUpdateMods.qml</file>
</qresource>
</RCC>

0 comments on commit 0949d54

Please sign in to comment.