From d38b90530b3ba3a49c4eb072eb344ae2b0836913 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Mon, 16 Sep 2013 00:54:39 +0200 Subject: Forge version list implementation. Needs integration and testing. --- gui/OneSixModEditDialog.ui | 135 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 115 insertions(+), 20 deletions(-) (limited to 'gui/OneSixModEditDialog.ui') diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui index 3feca726..bffcaed0 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/OneSixModEditDialog.ui @@ -6,15 +6,15 @@ 0 0 - 543 - 423 + 555 + 463 Dialog - - + + true @@ -28,26 +28,121 @@ 0 - - Qt::ElideNone - - - false - - Library + Version - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - + + + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOff + + + + + + + + + Main Class: + + + + + + + + + + + + + + + + Replace any current custom version with Minecraft Forge + + + Install Forge + + + + + + + Create an customized copy of the base version + + + Customize + + + + + + + Revert to original base version + + + Revert + + + + + + + QFrame::Sunken + + + Qt::Horizontal + + + + + + + false + + + Add new libraries + + + &Add + + + + + + + false + + + Remove selected libraries + + + &Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + @@ -163,7 +258,7 @@ - + false -- cgit From b979d0ce5da515793a02802a6421ef607a498323 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Wed, 18 Sep 2013 00:00:35 +0200 Subject: Implement legacy forge button! Many refactors of the task system. Progress dialog now accepts generic ProgressProvider objects --- CMakeLists.txt | 9 ++-- MultiMC.cpp | 1 + gui/LegacyModEditDialog.cpp | 41 +++++++++++++- gui/LegacyModEditDialog.h | 2 + gui/LegacyModEditDialog.ui | 3 -- gui/OneSixModEditDialog.cpp | 22 ++++++-- gui/OneSixModEditDialog.h | 1 + gui/OneSixModEditDialog.ui | 2 +- gui/ProgressDialog.cpp | 108 +++++++++++++++++++++++++++++++++++++ gui/ProgressDialog.h | 62 +++++++++++++++++++++ gui/ProgressDialog.ui | 53 ++++++++++++++++++ gui/mainwindow.cpp | 8 +-- gui/newinstancedialog.cpp | 2 +- gui/taskdialog.cpp | 107 ------------------------------------ gui/taskdialog.h | 61 --------------------- gui/taskdialog.ui | 53 ------------------ gui/versionselectdialog.cpp | 19 +++---- gui/versionselectdialog.h | 5 +- gui/versionselectdialog.ui | 69 ------------------------ logic/BaseUpdate.cpp | 4 +- logic/InstanceLauncher.cpp | 4 +- logic/LegacyUpdate.cpp | 6 +-- logic/OneSixUpdate.cpp | 4 +- logic/lists/ForgeVersionList.cpp | 93 +++++++++++++++++++++++++++----- logic/lists/ForgeVersionList.h | 10 ++-- logic/lists/MinecraftVersionList.h | 2 +- logic/net/DownloadJob.cpp | 2 + logic/net/DownloadJob.h | 19 ++++++- logic/tasks/ProgressProvider.h | 20 +++++++ logic/tasks/Task.cpp | 48 ++++++----------- logic/tasks/Task.h | 48 ++++++----------- 31 files changed, 474 insertions(+), 414 deletions(-) create mode 100644 gui/ProgressDialog.cpp create mode 100644 gui/ProgressDialog.h create mode 100644 gui/ProgressDialog.ui delete mode 100644 gui/taskdialog.cpp delete mode 100644 gui/taskdialog.h delete mode 100644 gui/taskdialog.ui create mode 100644 logic/tasks/ProgressProvider.h (limited to 'gui/OneSixModEditDialog.ui') diff --git a/CMakeLists.txt b/CMakeLists.txt index d4f0cbbf..7f09e324 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,7 +156,7 @@ gui/mainwindow.h gui/settingsdialog.h gui/newinstancedialog.h gui/logindialog.h -gui/taskdialog.h +gui/ProgressDialog.h gui/aboutdialog.h gui/consolewindow.h gui/instancedelegate.h @@ -228,6 +228,7 @@ logic/EnabledItemFilter.h # Tasks logic/tasks/Task.h logic/tasks/LoginTask.h +logic/tasks/ProgressProvider.h ) @@ -239,13 +240,14 @@ gui/mainwindow.cpp gui/settingsdialog.cpp gui/newinstancedialog.cpp gui/logindialog.cpp -gui/taskdialog.cpp gui/aboutdialog.cpp gui/consolewindow.cpp gui/instancedelegate.cpp gui/versionselectdialog.cpp gui/lwjglselectdialog.cpp gui/instancesettings.cpp + +gui/ProgressDialog.cpp gui/IconPickerDialog.cpp gui/LegacyModEditDialog.cpp gui/OneSixModEditDialog.cpp @@ -313,12 +315,13 @@ gui/mainwindow.ui gui/settingsdialog.ui gui/newinstancedialog.ui gui/logindialog.ui -gui/taskdialog.ui gui/aboutdialog.ui gui/consolewindow.ui gui/versionselectdialog.ui gui/lwjglselectdialog.ui gui/instancesettings.ui + +gui/ProgressDialog.ui gui/IconPickerDialog.ui gui/LegacyModEditDialog.ui gui/OneSixModEditDialog.ui diff --git a/MultiMC.cpp b/MultiMC.cpp index 08e5ed25..4b5b40b2 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -282,6 +282,7 @@ void MultiMC::initHttpMetaCache() m_metacache->addBase("assets", QDir("assets").absolutePath()); m_metacache->addBase("versions", QDir("versions").absolutePath()); m_metacache->addBase("libraries", QDir("libraries").absolutePath()); + m_metacache->addBase("minecraftforge", QDir("mods/minecraftforge").absolutePath()); m_metacache->Load(); } diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index c336f837..ac7f7f25 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -13,10 +13,15 @@ * limitations under the License. */ +#include "MultiMC.h" #include "LegacyModEditDialog.h" #include "ModEditDialogCommon.h" +#include "versionselectdialog.h" +#include "ProgressDialog.h" #include "ui_LegacyModEditDialog.h" -#include +#include "logic/ModList.h" +#include "logic/lists/ForgeVersionList.h" + #include #include #include @@ -194,7 +199,39 @@ void LegacyModEditDialog::on_addCoreBtn_clicked() } void LegacyModEditDialog::on_addForgeBtn_clicked() { - + VersionSelectDialog vselect(MMC->forgelist(), this); + vselect.setFilter(1, m_inst->intendedVersionId()); + if (vselect.exec() && vselect.selectedVersion()) + { + ForgeVersionPtr forge = vselect.selectedVersion().dynamicCast(); + if(!forge) + return; + auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename); + if(entry->stale) + { + DownloadJob * fjob = new DownloadJob("Forge download"); + fjob->add(forge->universal_url, entry); + ProgressDialog dlg(this); + dlg.exec(fjob); + if(dlg.result() == QDialog::Accepted) + { + m_jarmods->stopWatching(); + m_jarmods->installMod(QFileInfo(entry->getFullPath())); + m_jarmods->startWatching(); + } + else + { + // failed to download forge :/ + } + } + else + { + m_jarmods->stopWatching(); + m_jarmods->installMod(QFileInfo(entry->getFullPath())); + m_jarmods->startWatching(); + } + //m_selectedInstance->setIntendedVersionId(->descriptor()); + } } void LegacyModEditDialog::on_addJarBtn_clicked() { diff --git a/gui/LegacyModEditDialog.h b/gui/LegacyModEditDialog.h index bc9ebac0..b824a86a 100644 --- a/gui/LegacyModEditDialog.h +++ b/gui/LegacyModEditDialog.h @@ -17,6 +17,7 @@ #include #include "logic/LegacyInstance.h" +#include namespace Ui { class LegacyModEditDialog; @@ -64,4 +65,5 @@ private: QSharedPointer m_jarmods; QSharedPointer m_texturepacks; LegacyInstance * m_inst; + DownloadJobPtr forgeJob; }; diff --git a/gui/LegacyModEditDialog.ui b/gui/LegacyModEditDialog.ui index bd147c85..73b767dc 100644 --- a/gui/LegacyModEditDialog.ui +++ b/gui/LegacyModEditDialog.ui @@ -52,9 +52,6 @@ - - false - MCForge diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp index f778127f..fad9d2e2 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/OneSixModEditDialog.cpp @@ -12,18 +12,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include "MultiMC.h" #include "OneSixModEditDialog.h" #include "ModEditDialogCommon.h" #include "ui_OneSixModEditDialog.h" -#include +#include "logic/ModList.h" +#include "logic/OneSixVersion.h" +#include "logic/EnabledItemFilter.h" +#include "logic/lists/ForgeVersionList.h" +#include "gui/versionselectdialog.h" + #include #include #include #include #include -#include "logic/OneSixVersion.h" -#include OneSixModEditDialog::OneSixModEditDialog(OneSixInstance * inst, QWidget *parent): m_inst(inst), @@ -66,6 +69,17 @@ OneSixModEditDialog::~OneSixModEditDialog() delete ui; } +void OneSixModEditDialog::on_forgeBtn_clicked() +{ + VersionSelectDialog vselect(MMC->forgelist(), this); + vselect.setFilter(1, m_inst->currentVersionId()); + if (vselect.exec() && vselect.selectedVersion()) + { + //m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor()); + } +} + + bool OneSixModEditDialog::loaderListFilter ( QKeyEvent* keyEvent ) { switch(keyEvent->key()) diff --git a/gui/OneSixModEditDialog.h b/gui/OneSixModEditDialog.h index c637df01..d14c842c 100644 --- a/gui/OneSixModEditDialog.h +++ b/gui/OneSixModEditDialog.h @@ -40,6 +40,7 @@ private slots: void on_viewResPackBtn_clicked(); // Questionable: SettingsDialog doesn't need this for some reason? void on_buttonBox_rejected(); + void on_forgeBtn_clicked(); protected: bool eventFilter(QObject *obj, QEvent *ev); bool loaderListFilter( QKeyEvent* ev ); diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui index bffcaed0..aadaf3ae 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/OneSixModEditDialog.ui @@ -64,7 +64,7 @@ - + Replace any current custom version with Minecraft Forge diff --git a/gui/ProgressDialog.cpp b/gui/ProgressDialog.cpp new file mode 100644 index 00000000..154ab1c0 --- /dev/null +++ b/gui/ProgressDialog.cpp @@ -0,0 +1,108 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ProgressDialog.h" +#include "ui_ProgressDialog.h" + +#include + +#include "logic/tasks/Task.h" + +ProgressDialog::ProgressDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::ProgressDialog) +{ + ui->setupUi(this); + updateSize(); + + changeProgress(0,100); +} + +ProgressDialog::~ProgressDialog() +{ + delete ui; +} + +void ProgressDialog::updateSize() +{ + resize(QSize(480, minimumSizeHint().height())); +} + +int ProgressDialog::exec(ProgressProvider *task) +{ + this->task = task; + + // Connect signals. + connect(task, SIGNAL(started()), SLOT(onTaskStarted())); + connect(task, SIGNAL(failed(QString)), SLOT(onTaskFailed(QString))); + connect(task, SIGNAL(succeeded()), SLOT(onTaskSucceeded())); + connect(task, SIGNAL(status(QString)), SLOT(changeStatus(const QString&))); + connect(task, SIGNAL(progress(qint64,qint64)), SLOT(changeProgress(qint64,qint64))); + + // this makes sure that the task is started after the dialog is created + QMetaObject::invokeMethod(task, "start", Qt::QueuedConnection); + return QDialog::exec(); +} + +ProgressProvider* ProgressDialog::getTask() +{ + return task; +} + +void ProgressDialog::onTaskStarted() +{ + +} + +void ProgressDialog::onTaskFailed(QString failure) +{ + reject(); +} + +void ProgressDialog::onTaskSucceeded() +{ + accept(); +} + +void ProgressDialog::changeStatus(const QString &status) +{ + ui->statusLabel->setText(status); + updateSize(); +} + +void ProgressDialog::changeProgress(qint64 current, qint64 total) +{ + ui->taskProgressBar->setMaximum(total); + ui->taskProgressBar->setValue(current); +} + +void ProgressDialog::keyPressEvent(QKeyEvent* e) +{ + if (e->key() == Qt::Key_Escape) + return; + QDialog::keyPressEvent(e); +} + +void ProgressDialog::closeEvent(QCloseEvent* e) +{ + if (task && task->isRunning()) + { + e->ignore(); + } + else + { + QDialog::closeEvent(e); + } +} diff --git a/gui/ProgressDialog.h b/gui/ProgressDialog.h new file mode 100644 index 00000000..ac6bb412 --- /dev/null +++ b/gui/ProgressDialog.h @@ -0,0 +1,62 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TASKDIALOG_H +#define TASKDIALOG_H + +#include + +class ProgressProvider; + +namespace Ui { +class ProgressDialog; +} + +class ProgressDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ProgressDialog(QWidget *parent = 0); + ~ProgressDialog(); + + void updateSize(); + + int exec(ProgressProvider* task); + + ProgressProvider* getTask(); + +public slots: + void onTaskStarted(); + void onTaskFailed(QString failure); + void onTaskSucceeded(); + + void changeStatus(const QString& status); + void changeProgress(qint64 current, qint64 total); + +signals: + + +protected: + virtual void keyPressEvent(QKeyEvent* e); + virtual void closeEvent(QCloseEvent* e); + +private: + Ui::ProgressDialog *ui; + + ProgressProvider* task; +}; + +#endif // TASKDIALOG_H diff --git a/gui/ProgressDialog.ui b/gui/ProgressDialog.ui new file mode 100644 index 00000000..a56d2a92 --- /dev/null +++ b/gui/ProgressDialog.ui @@ -0,0 +1,53 @@ + + + ProgressDialog + + + + 0 + 0 + 400 + 68 + + + + + 400 + 0 + + + + + 600 + 16777215 + + + + Please wait... + + + + + + Task Status... + + + true + + + + + + + 24 + + + false + + + + + + + + diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 241df383..6f707236 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -42,7 +42,7 @@ #include "gui/settingsdialog.h" #include "gui/newinstancedialog.h" #include "gui/logindialog.h" -#include "gui/taskdialog.h" +#include "gui/ProgressDialog.h" #include "gui/aboutdialog.h" #include "gui/versionselectdialog.h" #include "gui/lwjglselectdialog.h" @@ -479,7 +479,7 @@ void MainWindow::doLogin(const QString& errorMsg) { UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()}; - TaskDialog* tDialog = new TaskDialog(this); + ProgressDialog* tDialog = new ProgressDialog(this); LoginTask* loginTask = new LoginTask(uInfo, tDialog); connect(loginTask, SIGNAL(succeeded()),SLOT(onLoginComplete()), Qt::QueuedConnection); connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)), Qt::QueuedConnection); @@ -512,7 +512,7 @@ void MainWindow::onLoginComplete() } else { - TaskDialog *tDialog = new TaskDialog(this); + ProgressDialog *tDialog = new ProgressDialog(this); connect(updateTask, SIGNAL(succeeded()),SLOT(onGameUpdateComplete())); connect(updateTask, SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString))); tDialog->exec(updateTask); @@ -575,7 +575,7 @@ void MainWindow::startTask(Task *task) connect(task, SIGNAL(started()), SLOT(taskStart())); connect(task, SIGNAL(succeeded()), SLOT(taskEnd())); connect(task, SIGNAL(failed(QString)), SLOT(taskEnd())); - task->startTask(); + task->start(); } diff --git a/gui/newinstancedialog.cpp b/gui/newinstancedialog.cpp index af2b11c5..6604d03b 100644 --- a/gui/newinstancedialog.cpp +++ b/gui/newinstancedialog.cpp @@ -24,7 +24,7 @@ #include "logic/tasks/Task.h" #include "versionselectdialog.h" -#include "taskdialog.h" +#include "ProgressDialog.h" #include "IconPickerDialog.h" #include diff --git a/gui/taskdialog.cpp b/gui/taskdialog.cpp deleted file mode 100644 index 8c745b38..00000000 --- a/gui/taskdialog.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "taskdialog.h" -#include "ui_taskdialog.h" - -#include - -#include "logic/tasks/Task.h" - -TaskDialog::TaskDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::TaskDialog) -{ - ui->setupUi(this); - updateSize(); - - changeProgress(0); -} - -TaskDialog::~TaskDialog() -{ - delete ui; -} - -void TaskDialog::updateSize() -{ - resize(QSize(480, minimumSizeHint().height())); -} - -void TaskDialog::exec(Task *task) -{ - this->task = task; - - // Connect signals. - connect(task, SIGNAL(started()), SLOT(onTaskStarted())); - connect(task, SIGNAL(failed(QString)), SLOT(onTaskEnded())); - connect(task, SIGNAL(succeeded()), SLOT(onTaskEnded())); - connect(task, SIGNAL(statusChanged(const QString&)), SLOT(changeStatus(const QString&))); - connect(task, SIGNAL(progressChanged(int)), SLOT(changeProgress(int))); - - // this makes sure that the task is started after the dialog is created - QMetaObject::invokeMethod(task, "startTask", Qt::QueuedConnection); - QDialog::exec(); -} - -Task* TaskDialog::getTask() -{ - return task; -} - -void TaskDialog::onTaskStarted() -{ - -} - -void TaskDialog::onTaskEnded() -{ - close(); -} - -void TaskDialog::changeStatus(const QString &status) -{ - ui->statusLabel->setText(status); - updateSize(); -} - -void TaskDialog::changeProgress(int progress) -{ - if (progress < 0) - progress = 0; - else if (progress > 100) - progress = 100; - - ui->taskProgressBar->setValue(progress); -} - -void TaskDialog::keyPressEvent(QKeyEvent* e) -{ - if (e->key() == Qt::Key_Escape) - return; - QDialog::keyPressEvent(e); -} - -void TaskDialog::closeEvent(QCloseEvent* e) -{ - if (task && task->isRunning()) - { - e->ignore(); - } - else - { - QDialog::closeEvent(e); - } -} diff --git a/gui/taskdialog.h b/gui/taskdialog.h deleted file mode 100644 index 3d31b7be..00000000 --- a/gui/taskdialog.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TASKDIALOG_H -#define TASKDIALOG_H - -#include - -class Task; - -namespace Ui { -class TaskDialog; -} - -class TaskDialog : public QDialog -{ - Q_OBJECT - -public: - explicit TaskDialog(QWidget *parent = 0); - ~TaskDialog(); - - void updateSize(); - - void exec(Task* task); - - Task* getTask(); - -public slots: - void onTaskStarted(); - void onTaskEnded(); - - void changeStatus(const QString& status); - void changeProgress(int progress); - -signals: - - -protected: - virtual void keyPressEvent(QKeyEvent* e); - virtual void closeEvent(QCloseEvent* e); - -private: - Ui::TaskDialog *ui; - - Task* task; -}; - -#endif // TASKDIALOG_H diff --git a/gui/taskdialog.ui b/gui/taskdialog.ui deleted file mode 100644 index 1cdf7978..00000000 --- a/gui/taskdialog.ui +++ /dev/null @@ -1,53 +0,0 @@ - - - TaskDialog - - - - 0 - 0 - 400 - 58 - - - - - 400 - 0 - - - - - 600 - 16777215 - - - - Please wait... - - - - - - Task Status... - - - true - - - - - - - 24 - - - false - - - - - - - - diff --git a/gui/versionselectdialog.cpp b/gui/versionselectdialog.cpp index b14956fd..1e60c7d9 100644 --- a/gui/versionselectdialog.cpp +++ b/gui/versionselectdialog.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include #include @@ -41,11 +41,6 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QWidget *parent ui->listView->setModel(m_proxyModel); ui->listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); ui->listView->header()->setSectionResizeMode(0, QHeaderView::Stretch); - - connect(ui->filterSnapshotsCheckbox, SIGNAL(clicked()), SLOT(updateFilterState())); - connect(ui->filterMCNostalgiaCheckbox, SIGNAL(clicked()), SLOT(updateFilterState())); - - updateFilterState(); } VersionSelectDialog::~VersionSelectDialog() @@ -63,7 +58,7 @@ int VersionSelectDialog::exec() void VersionSelectDialog::loadList() { - TaskDialog *taskDlg = new TaskDialog(this); + ProgressDialog *taskDlg = new ProgressDialog(this); Task *loadTask = m_vlist->getLoadTask(); loadTask->setParent(taskDlg); taskDlg->exec(loadTask); @@ -81,10 +76,11 @@ void VersionSelectDialog::on_refreshButton_clicked() loadList(); } -void VersionSelectDialog::updateFilterState() +void VersionSelectDialog::setFilter(int column, QString filter) { - m_proxyModel->setFilterKeyColumn(BaseVersionList::TypeColumn); - + m_proxyModel->setFilterKeyColumn(column); + m_proxyModel->setFilterFixedString(filter); + /* QStringList filteredTypes; if (!ui->filterSnapshotsCheckbox->isChecked()) filteredTypes += "Snapshot"; @@ -96,6 +92,5 @@ void VersionSelectDialog::updateFilterState() regexStr = QString("^((?!%1).)*$").arg(filteredTypes.join('|')); qDebug() << "Filter:" << regexStr; - - m_proxyModel->setFilterRegExp(regexStr); + */ } diff --git a/gui/versionselectdialog.h b/gui/versionselectdialog.h index 57e4d0df..0bb1745a 100644 --- a/gui/versionselectdialog.h +++ b/gui/versionselectdialog.h @@ -43,11 +43,10 @@ public: BaseVersionPtr selectedVersion() const; + void setFilter(int column, QString filter); + private slots: void on_refreshButton_clicked(); - - void updateFilterState(); - private: Ui::VersionSelectDialog *ui; diff --git a/gui/versionselectdialog.ui b/gui/versionselectdialog.ui index 02937794..222f29cf 100644 --- a/gui/versionselectdialog.ui +++ b/gui/versionselectdialog.ui @@ -39,75 +39,6 @@ - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Show &snapshots? - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Show &Nostalgia? - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - diff --git a/logic/BaseUpdate.cpp b/logic/BaseUpdate.cpp index b086ab14..02b29d32 100644 --- a/logic/BaseUpdate.cpp +++ b/logic/BaseUpdate.cpp @@ -7,7 +7,5 @@ BaseUpdate::BaseUpdate ( BaseInstance* inst, QObject* parent ) : Task ( parent ) void BaseUpdate::updateDownloadProgress(qint64 current, qint64 total) { - // The progress on the current file is current / total - float currentDLProgress = (float) current / (float) total; - setProgress((int)(currentDLProgress * 100)); // convert to percentage + emit progress(current, total); } \ No newline at end of file diff --git a/logic/InstanceLauncher.cpp b/logic/InstanceLauncher.cpp index a0557b37..f2f792c9 100644 --- a/logic/InstanceLauncher.cpp +++ b/logic/InstanceLauncher.cpp @@ -3,7 +3,7 @@ #include #include "gui/logindialog.h" -#include "gui/taskdialog.h" +#include "gui/ProgressDialog.h" #include "gui/consolewindow.h" #include "logic/tasks/LoginTask.h" #include "logic/MinecraftProcess.h" @@ -48,7 +48,7 @@ void InstanceLauncher::doLogin ( const QString& errorMsg ) { UserInfo uInfo {loginDlg->getUsername(), loginDlg->getPassword() }; - TaskDialog* tDialog = new TaskDialog ( nullptr ); + ProgressDialog* tDialog = new ProgressDialog ( nullptr ); LoginTask* loginTask = new LoginTask ( uInfo, tDialog ); connect ( loginTask, SIGNAL ( succeeded() ),SLOT ( onLoginComplete() ), Qt::QueuedConnection ); connect ( loginTask, SIGNAL ( failed ( QString ) ),SLOT ( doLogin ( QString ) ), Qt::QueuedConnection ); diff --git a/logic/LegacyUpdate.cpp b/logic/LegacyUpdate.cpp index 25be5e7d..0f58e3e3 100644 --- a/logic/LegacyUpdate.cpp +++ b/logic/LegacyUpdate.cpp @@ -59,7 +59,7 @@ void LegacyUpdate::lwjglStart() QNetworkReply * rep = worker->get ( req ); m_reply = QSharedPointer (rep, &QObject::deleteLater); - connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64))); + connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(progress(qint64,qint64))); connect(worker, SIGNAL(finished(QNetworkReply*)), SLOT(lwjglFinished(QNetworkReply*))); //connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError))); } @@ -97,7 +97,7 @@ void LegacyUpdate::lwjglFinished(QNetworkReply* reply) req.setRawHeader("Host", hostname.toLatin1()); req.setHeader(QNetworkRequest::UserAgentHeader, "Wget/1.14 (linux-gnu)"); QNetworkReply * rep = worker->get(req); - connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64))); + connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(progress(qint64,qint64))); m_reply = QSharedPointer (rep, &QObject::deleteLater); return; } @@ -232,7 +232,7 @@ void LegacyUpdate::jarStart() legacyDownloadJob.reset(dljob); connect(dljob, SIGNAL(succeeded()), SLOT(jarFinished())); connect(dljob, SIGNAL(failed()), SLOT(jarFailed())); - connect(dljob, SIGNAL(progress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64))); + connect(dljob, SIGNAL(progress(qint64,qint64)), SIGNAL(progress(qint64,qint64))); legacyDownloadJob->start(); } diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp index 67395818..298ad28a 100644 --- a/logic/OneSixUpdate.cpp +++ b/logic/OneSixUpdate.cpp @@ -78,7 +78,7 @@ void OneSixUpdate::versionFileStart() specificVersionDownloadJob.reset(job); connect(specificVersionDownloadJob.data(), SIGNAL(succeeded()), SLOT(versionFileFinished())); connect(specificVersionDownloadJob.data(), SIGNAL(failed()), SLOT(versionFileFailed())); - connect(specificVersionDownloadJob.data(), SIGNAL(progress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64))); + connect(specificVersionDownloadJob.data(), SIGNAL(progress(qint64,qint64)), SIGNAL(progress(qint64,qint64))); specificVersionDownloadJob->start(); } @@ -171,7 +171,7 @@ void OneSixUpdate::jarlibStart() } connect(jarlibDownloadJob.data(), SIGNAL(succeeded()), SLOT(jarlibFinished())); connect(jarlibDownloadJob.data(), SIGNAL(failed()), SLOT(jarlibFailed())); - connect(jarlibDownloadJob.data(), SIGNAL(progress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64))); + connect(jarlibDownloadJob.data(), SIGNAL(progress(qint64,qint64)), SIGNAL(progress(qint64,qint64))); jarlibDownloadJob->start(); } diff --git a/logic/lists/ForgeVersionList.cpp b/logic/lists/ForgeVersionList.cpp index f45b8b6b..412c04fe 100644 --- a/logic/lists/ForgeVersionList.cpp +++ b/logic/lists/ForgeVersionList.cpp @@ -50,21 +50,90 @@ int ForgeVersionList::count() const { return m_vlist.count(); } -/* -bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second) + +int ForgeVersionList::columnCount(const QModelIndex& parent) const { - const BaseVersion & left = *first; - const BaseVersion & right = *second; - return left > right; + return 3; } -void MinecraftVersionList::sort() +QVariant ForgeVersionList::data(const QModelIndex &index, int role) const { - beginResetModel(); - qSort(m_vlist.begin(), m_vlist.end(), cmpVersions); - endResetModel(); + if (!index.isValid()) + return QVariant(); + + if (index.row() > count()) + return QVariant(); + + auto version = m_vlist[index.row()].dynamicCast(); + switch (role) + { + case Qt::DisplayRole: + switch (index.column()) + { + case 0: + return version->name(); + + case 1: + return version->mcver; + + case 2: + return version->typeString(); + default: + return QVariant(); + } + + case Qt::ToolTipRole: + return version->descriptor(); + + case VersionPointerRole: + return qVariantFromValue(m_vlist[index.row()]); + + default: + return QVariant(); + } } -*/ + +QVariant ForgeVersionList::headerData(int section, Qt::Orientation orientation, int role) const +{ + switch (role) + { + case Qt::DisplayRole: + switch (section) + { + case 0: + return "Version"; + + case 1: + return "Minecraft"; + + case 2: + return "Type"; + + default: + return QVariant(); + } + + case Qt::ToolTipRole: + switch (section) + { + case 0: + return "The name of the version."; + + case 1: + return "Minecraft version"; + + case 2: + return "The version's type."; + + default: + return QVariant(); + } + + default: + return QVariant(); + } +} + BaseVersionPtr ForgeVersionList::getLatestStable() const { return BaseVersionPtr(); @@ -99,7 +168,7 @@ void ForgeListLoadTask::executeTask() listJob.reset(job); connect(listJob.data(), SIGNAL(succeeded()), SLOT(list_downloaded())); connect(listJob.data(), SIGNAL(failed()), SLOT(versionFileFailed())); - connect(listJob.data(), SIGNAL(progress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64))); + connect(listJob.data(), SIGNAL(progress(qint64,qint64)), SIGNAL(progress(qint64,qint64))); listJob->start(); } @@ -148,7 +217,7 @@ void ForgeListLoadTask::list_downloaded() int build_nr = obj.value("build").toDouble(0); if(!build_nr) continue; - QJsonArray files = root.value("files").toArray(); + QJsonArray files = obj.value("files").toArray(); QString url, jobbuildver, mcver, buildtype, filename; QString changelog_url, installer_url; bool valid = false; diff --git a/logic/lists/ForgeVersionList.h b/logic/lists/ForgeVersionList.h index 8d4a2d46..ca6b27bc 100644 --- a/logic/lists/ForgeVersionList.h +++ b/logic/lists/ForgeVersionList.h @@ -26,7 +26,7 @@ #include "logic/net/DownloadJob.h" class ForgeVersion; -typedef QSharedPointer PtrForgeVersion; +typedef QSharedPointer ForgeVersionPtr; struct ForgeVersion : public BaseVersion { @@ -36,7 +36,7 @@ struct ForgeVersion : public BaseVersion }; virtual QString name() { - return "Forge " + jobbuildver + " (" + mcver + ")"; + return "Forge " + jobbuildver; }; virtual QString typeString() const { @@ -71,8 +71,12 @@ public: virtual BaseVersionPtr getLatestStable() const; + virtual QVariant data(const QModelIndex& index, int role) const; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; + virtual int columnCount(const QModelIndex& parent) const; + protected: - QList m_vlist; + QList m_vlist; bool m_loaded; diff --git a/logic/lists/MinecraftVersionList.h b/logic/lists/MinecraftVersionList.h index 8937ba7b..fb28ddfe 100644 --- a/logic/lists/MinecraftVersionList.h +++ b/logic/lists/MinecraftVersionList.h @@ -49,7 +49,7 @@ protected: bool m_loaded; protected slots: - virtual void updateListData(QList versions); + virtual void updateListData(QList versions); }; class MCVListLoadTask : public Task diff --git a/logic/net/DownloadJob.cpp b/logic/net/DownloadJob.cpp index 9b083b6b..3acba050 100644 --- a/logic/net/DownloadJob.cpp +++ b/logic/net/DownloadJob.cpp @@ -5,6 +5,8 @@ #include "ByteArrayDownload.h" #include "CacheDownload.h" +#include + ByteArrayDownloadPtr DownloadJob::add ( QUrl url ) { ByteArrayDownloadPtr ptr (new ByteArrayDownload(url)); diff --git a/logic/net/DownloadJob.h b/logic/net/DownloadJob.h index 69a49e59..c8f6a9d7 100644 --- a/logic/net/DownloadJob.h +++ b/logic/net/DownloadJob.h @@ -5,6 +5,7 @@ #include "FileDownload.h" #include "CacheDownload.h" #include "HttpMetaCache.h" +#include "logic/tasks/ProgressProvider.h" class DownloadJob; typedef QSharedPointer DownloadJobPtr; @@ -12,12 +13,12 @@ typedef QSharedPointer DownloadJobPtr; /** * A single file for the downloader/cache to process. */ -class DownloadJob : public QObject +class DownloadJob : public ProgressProvider { Q_OBJECT public: explicit DownloadJob(QString job_name) - :QObject(), m_job_name(job_name){}; + :ProgressProvider(), m_job_name(job_name){}; ByteArrayDownloadPtr add(QUrl url); FileDownloadPtr add(QUrl url, QString rel_target_path); @@ -37,6 +38,19 @@ public: { return downloads.size(); } + virtual void getProgress(qint64& current, qint64& total) + { + current = current_progress; + total = total_progress; + }; + virtual QString getStatus() const + { + return m_job_name; + }; + virtual bool isRunning() const + { + return m_running; + }; signals: void started(); void progress(qint64 current, qint64 total); @@ -56,5 +70,6 @@ private: qint64 total_progress = 0; int num_succeeded = 0; int num_failed = 0; + bool m_running = false; }; diff --git a/logic/tasks/ProgressProvider.h b/logic/tasks/ProgressProvider.h new file mode 100644 index 00000000..e158eb54 --- /dev/null +++ b/logic/tasks/ProgressProvider.h @@ -0,0 +1,20 @@ +#pragma once +#include +class ProgressProvider : public QObject +{ + Q_OBJECT +protected: + explicit ProgressProvider(QObject* parent = 0): QObject(parent){} +signals: + void started(); + void progress(qint64 current, qint64 total); + void succeeded(); + void failed(QString reason); + void status(QString status); +public: + virtual QString getStatus() const = 0; + virtual void getProgress(qint64 ¤t, qint64 &total) = 0; + virtual bool isRunning() const = 0; +public slots: + virtual void start() = 0; +}; diff --git a/logic/tasks/Task.cpp b/logic/tasks/Task.cpp index 7c148591..c75bcb8f 100644 --- a/logic/tasks/Task.cpp +++ b/logic/tasks/Task.cpp @@ -16,70 +16,56 @@ #include "Task.h" Task::Task(QObject *parent) : - QObject(parent) + ProgressProvider(parent) { } QString Task::getStatus() const { - return status; + return m_status; } -void Task::setStatus(const QString &status) +void Task::setStatus(const QString &new_status) { - this->status = status; - emitStatusChange(status); + m_status = new_status; + emit status(new_status); } -int Task::getProgress() const +void Task::setProgress(int new_progress) { - return progress; + m_progress = new_progress; + emit progress(new_progress, 100); } -void Task::setProgress(int progress) +void Task::getProgress(qint64& current, qint64& total) { - this->progress = progress; - emitProgressChange(progress); + current = m_progress; + total = 100; } -void Task::startTask() -{ - emitStarted(); - executeTask(); -} -void Task::emitStarted() +void Task::start() { - running = true; + m_running = true; emit started(); + executeTask(); } void Task::emitFailed(QString reason) { - running = false; + m_running = false; emit failed(reason); } void Task::emitSucceeded() { - running = false; + m_running = false; emit succeeded(); } bool Task::isRunning() const { - return running; -} - - -void Task::emitStatusChange(const QString &status) -{ - emit statusChanged(status); -} - -void Task::emitProgressChange(int progress) -{ - emit progressChanged(progress); + return m_running; } diff --git a/logic/tasks/Task.h b/logic/tasks/Task.h index 91852b0f..cfe71c51 100644 --- a/logic/tasks/Task.h +++ b/logic/tasks/Task.h @@ -13,53 +13,37 @@ * limitations under the License. */ -#ifndef TASK_H -#define TASK_H +#pragma once #include #include +#include "ProgressProvider.h" -class Task : public QObject +class Task : public ProgressProvider { Q_OBJECT public: explicit Task(QObject *parent = 0); - QString getStatus() const; - int getProgress() const; - bool isRunning() const; + virtual QString getStatus() const; + virtual void getProgress(qint64& current, qint64& total); + virtual bool isRunning() const; public slots: - void startTask(); - -protected slots: - void setStatus(const QString& status); - void setProgress(int progress); - -signals: - void started(); - void failed(QString reason); - void succeeded(); - - void statusChanged(Task* task, const QString& status); - void progressChanged(Task* task, int progress); - - void statusChanged(const QString& status); - void progressChanged(int progress); + virtual void start(); protected: virtual void executeTask() = 0; - virtual void emitStarted(); - virtual void emitFailed(QString reason); virtual void emitSucceeded(); + virtual void emitFailed(QString reason); + +protected slots: + void setStatus(const QString& status); + void setProgress(int progress); - virtual void emitStatusChange(const QString &status); - virtual void emitProgressChange(int progress); - - QString status; - int progress; - bool running = false; +protected: + QString m_status; + int m_progress = 0; + bool m_running = false; }; - -#endif // TASK_H -- cgit From c2c7293083de8e8d40190992ccd6a65b613a4d06 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Fri, 20 Sep 2013 01:21:48 +0200 Subject: Things... and stuff... with 1.6 modding. Maybe. --- gui/LegacyModEditDialog.cpp | 1 - gui/OneSixModEditDialog.cpp | 85 +++++++++++++++++++++++++++++++++++++--- gui/OneSixModEditDialog.h | 5 +++ gui/OneSixModEditDialog.ui | 9 ++++- logic/OneSixInstance.cpp | 24 ++++++++++++ logic/OneSixInstance.h | 4 ++ logic/lists/ForgeVersionList.cpp | 4 ++ 7 files changed, 124 insertions(+), 8 deletions(-) (limited to 'gui/OneSixModEditDialog.ui') diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index ac7f7f25..1a1198b1 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -230,7 +230,6 @@ void LegacyModEditDialog::on_addForgeBtn_clicked() m_jarmods->installMod(QFileInfo(entry->getFullPath())); m_jarmods->startWatching(); } - //m_selectedInstance->setIntendedVersionId(->descriptor()); } } void LegacyModEditDialog::on_addJarBtn_clicked() diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp index fad9d2e2..7cbb9cbd 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/OneSixModEditDialog.cpp @@ -21,9 +21,11 @@ #include "logic/EnabledItemFilter.h" #include "logic/lists/ForgeVersionList.h" #include "gui/versionselectdialog.h" +#include "ProgressDialog.h" #include #include +#include #include #include #include @@ -38,11 +40,13 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance * inst, QWidget *parent) { m_version = m_inst->getFullVersion(); - auto filter = new EnabledItemFilter(this); - filter->setActive(true); - filter->setSourceModel(m_version.data()); - ui->libraryTreeView->setModel(filter); + main_model = new EnabledItemFilter(this); + main_model->setActive(true); + main_model->setSourceModel(m_version.data()); + ui->libraryTreeView->setModel(main_model); ui->libraryTreeView->installEventFilter( this ); + ui->mainClassEdit->setText(m_version->mainClass); + updateButtons(); } // Loader mods { @@ -69,17 +73,86 @@ OneSixModEditDialog::~OneSixModEditDialog() delete ui; } +void OneSixModEditDialog::updateButtons() +{ + bool customVersion = m_inst->versionIsCustom(); + ui->customizeBtn->setEnabled(!customVersion); + ui->revertBtn->setEnabled(customVersion); +} + + +void OneSixModEditDialog::on_customizeBtn_clicked() +{ + if(m_inst->customizeVersion()) + { + m_version = m_inst->getFullVersion(); + main_model->setSourceModel(m_version.data()); + updateButtons(); + } +} + +void OneSixModEditDialog::on_revertBtn_clicked() +{ + auto reply = QMessageBox::question(this, tr("Revert?"), tr("Do you want to revert the version of this instance to its original configuration?"),QMessageBox::Yes|QMessageBox::No); + if (reply == QMessageBox::Yes) + { + if(m_inst->revertCustomVersion()) + { + m_version = m_inst->getFullVersion(); + main_model->setSourceModel(m_version.data()); + updateButtons(); + } + } +} + + void OneSixModEditDialog::on_forgeBtn_clicked() { VersionSelectDialog vselect(MMC->forgelist(), this); vselect.setFilter(1, m_inst->currentVersionId()); if (vselect.exec() && vselect.selectedVersion()) { - //m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor()); + if(m_inst->versionIsCustom()) + { + auto reply = QMessageBox::question(this, tr("Revert?"), tr("This will revert any changes you did to the version up to this point. Is that OK?"),QMessageBox::Yes|QMessageBox::No); + if (reply == QMessageBox::Yes) + { + m_inst->revertCustomVersion(); + m_inst->customizeVersion(); + { + m_version = m_inst->getFullVersion(); + main_model->setSourceModel(m_version.data()); + updateButtons(); + } + } + else return; + } + ForgeVersionPtr forge = vselect.selectedVersion().dynamicCast(); + if(!forge) + return; + auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename); + if(entry->stale) + { + DownloadJob * fjob = new DownloadJob("Forge download"); + fjob->add(forge->universal_url, entry); + ProgressDialog dlg(this); + dlg.exec(fjob); + if(dlg.result() == QDialog::Accepted) + { + // install + } + else + { + // failed to download forge :/ + } + } + else + { + // install + } } } - bool OneSixModEditDialog::loaderListFilter ( QKeyEvent* keyEvent ) { switch(keyEvent->key()) diff --git a/gui/OneSixModEditDialog.h b/gui/OneSixModEditDialog.h index d14c842c..714c911a 100644 --- a/gui/OneSixModEditDialog.h +++ b/gui/OneSixModEditDialog.h @@ -18,6 +18,7 @@ #include +class EnabledItemFilter; namespace Ui { class OneSixModEditDialog; } @@ -41,6 +42,9 @@ private slots: // Questionable: SettingsDialog doesn't need this for some reason? void on_buttonBox_rejected(); void on_forgeBtn_clicked(); + void on_customizeBtn_clicked(); + void on_revertBtn_clicked(); + void updateButtons(); protected: bool eventFilter(QObject *obj, QEvent *ev); bool loaderListFilter( QKeyEvent* ev ); @@ -50,5 +54,6 @@ private: QSharedPointer m_version; QSharedPointer m_mods; QSharedPointer m_resourcepacks; + EnabledItemFilter * main_model; OneSixInstance * m_inst; }; diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui index aadaf3ae..527899ca 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/OneSixModEditDialog.ui @@ -55,7 +55,11 @@ - + + + false + + @@ -85,6 +89,9 @@ + + false + Revert to original base version diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index 7b038c46..8124b4a0 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -226,6 +226,30 @@ QString OneSixInstance::currentVersionId() const return intendedVersionId(); } +bool OneSixInstance::customizeVersion() +{ + if(!versionIsCustom()) + { + auto pathCustom = PathCombine(instanceRoot(), "custom.json"); + auto pathOrig = PathCombine(instanceRoot(), "version.json"); + QFile::copy(pathOrig, pathCustom); + return reloadFullVersion(); + } + else return true; +} + +bool OneSixInstance::revertCustomVersion() +{ + if(versionIsCustom()) + { + auto path = PathCombine(instanceRoot(), "custom.json"); + QFile::remove(path); + return reloadFullVersion(); + } + else return true; +} + + bool OneSixInstance::reloadFullVersion() { I_D(OneSixInstance); diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h index 72bde630..0139b645 100644 --- a/logic/OneSixInstance.h +++ b/logic/OneSixInstance.h @@ -41,6 +41,10 @@ public: bool reloadFullVersion(); /// get the current full version info QSharedPointer getFullVersion(); + /// revert the current custom version back to base + bool revertCustomVersion(); + /// customize the current base version + bool customizeVersion(); /// is the current version original, or custom? bool versionIsCustom(); diff --git a/logic/lists/ForgeVersionList.cpp b/logic/lists/ForgeVersionList.cpp index 412c04fe..492849ee 100644 --- a/logic/lists/ForgeVersionList.cpp +++ b/logic/lists/ForgeVersionList.cpp @@ -220,6 +220,7 @@ void ForgeListLoadTask::list_downloaded() QJsonArray files = obj.value("files").toArray(); QString url, jobbuildver, mcver, buildtype, filename; QString changelog_url, installer_url; + QString installer_filename; bool valid = false; for(int j = 0; j < files.count(); j++) { @@ -246,6 +247,8 @@ void ForgeListLoadTask::list_downloaded() else if(buildtype == "installer") { installer_url = file.value("url").toString(); + int lastSlash = installer_url.lastIndexOf('/'); + installer_filename = installer_url.mid(lastSlash+1); } } if(valid) @@ -258,6 +261,7 @@ void ForgeListLoadTask::list_downloaded() fVersion->jobbuildver = jobbuildver; fVersion->mcver = mcver; fVersion->filename = filename; + fVersion->filename = installer_filename; fVersion->m_buildnr = build_nr; tempList.append(fVersion); } -- cgit From 05e2da51d8d25374140dce3c1646a2a1a0a2a553 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Tue, 8 Oct 2013 01:36:11 +0200 Subject: Add mod website button thing feature widget. It is super effective. --- gui/LegacyModEditDialog.cpp | 35 +++++++++++- gui/LegacyModEditDialog.h | 39 ++++++++------ gui/LegacyModEditDialog.ui | 21 ++++++++ gui/ModEditDialogCommon.cpp | 37 ++++++++++--- gui/ModEditDialogCommon.h | 5 +- gui/OneSixModEditDialog.cpp | 11 ++++ gui/OneSixModEditDialog.h | 1 + gui/OneSixModEditDialog.ui | 7 +++ logic/Mod.cpp | 102 ++++++++++++++++++----------------- logic/Mod.h | 69 ++++++++++++++++-------- logic/lists/MinecraftVersionList.cpp | 77 +++++++++++++------------- 11 files changed, 270 insertions(+), 134 deletions(-) (limited to 'gui/OneSixModEditDialog.ui') diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index 45f041f3..87647e0f 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -24,6 +24,7 @@ #include #include +//#include #include #include #include @@ -342,4 +343,36 @@ void LegacyModEditDialog::on_viewTexPackBtn_clicked() void LegacyModEditDialog::on_buttonBox_rejected() { close(); -} \ No newline at end of file +} + +//FIXME: too much copypasta makes peterix a sad hacker. BUT IT'S SO DELICIOUS! + +void LegacyModEditDialog::on_coreWebsite_clicked() +{ + int first, last; + auto list = ui->coreModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + showWebsiteForMod(this, m_coremods->operator[](first)); +} + +void LegacyModEditDialog::on_jarWebsite_clicked() +{ + int first, last; + auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + showWebsiteForMod(this, m_jarmods->operator[](first)); +} + +void LegacyModEditDialog::on_loaderWebsite_clicked() +{ + int first, last; + auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + showWebsiteForMod(this, m_mods->operator[](first)); +} diff --git a/gui/LegacyModEditDialog.h b/gui/LegacyModEditDialog.h index 5f6973d3..f12d9a7b 100644 --- a/gui/LegacyModEditDialog.h +++ b/gui/LegacyModEditDialog.h @@ -3,7 +3,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -19,51 +19,60 @@ #include "logic/LegacyInstance.h" #include -namespace Ui { +namespace Ui +{ class LegacyModEditDialog; } class LegacyModEditDialog : public QDialog { Q_OBJECT - + public: - explicit LegacyModEditDialog(LegacyInstance* inst, QWidget *parent = 0); + explicit LegacyModEditDialog(LegacyInstance *inst, QWidget *parent = 0); ~LegacyModEditDialog(); - -private slots: - + +private +slots: + void on_addJarBtn_clicked(); void on_rmJarBtn_clicked(); void on_addForgeBtn_clicked(); void on_moveJarUpBtn_clicked(); void on_moveJarDownBtn_clicked(); - + void on_addCoreBtn_clicked(); void on_rmCoreBtn_clicked(); void on_viewCoreBtn_clicked(); - + void on_addModBtn_clicked(); void on_rmModBtn_clicked(); void on_viewModBtn_clicked(); - + void on_addTexPackBtn_clicked(); void on_rmTexPackBtn_clicked(); void on_viewTexPackBtn_clicked(); + + void on_jarWebsite_clicked(); + void on_loaderWebsite_clicked(); + void on_coreWebsite_clicked(); + // Questionable: SettingsDialog doesn't need this for some reason? void on_buttonBox_rejected(); + protected: bool eventFilter(QObject *obj, QEvent *ev); - bool jarListFilter( QKeyEvent* ev ); - bool coreListFilter( QKeyEvent* ev ); - bool loaderListFilter( QKeyEvent* ev ); - bool texturePackListFilter( QKeyEvent* ev ); + bool jarListFilter(QKeyEvent *ev); + bool coreListFilter(QKeyEvent *ev); + bool loaderListFilter(QKeyEvent *ev); + bool texturePackListFilter(QKeyEvent *ev); + private: Ui::LegacyModEditDialog *ui; std::shared_ptr m_mods; std::shared_ptr m_coremods; std::shared_ptr m_jarmods; std::shared_ptr m_texturepacks; - LegacyInstance * m_inst; + LegacyInstance *m_inst; DownloadJobPtr forgeJob; }; diff --git a/gui/LegacyModEditDialog.ui b/gui/LegacyModEditDialog.ui index 73b767dc..6a4b6d1e 100644 --- a/gui/LegacyModEditDialog.ui +++ b/gui/LegacyModEditDialog.ui @@ -57,6 +57,13 @@ + + + + Website + + + @@ -116,6 +123,13 @@ + + + + Website + + + @@ -171,6 +185,13 @@ + + + + Website + + + diff --git a/gui/ModEditDialogCommon.cpp b/gui/ModEditDialogCommon.cpp index 5da0a039..692ac0c4 100644 --- a/gui/ModEditDialogCommon.cpp +++ b/gui/ModEditDialogCommon.cpp @@ -1,17 +1,40 @@ #include "ModEditDialogCommon.h" - -bool lastfirst (QModelIndexList & list, int & first, int & last) +#include +#include +#include +#include +bool lastfirst(QModelIndexList &list, int &first, int &last) { - if(!list.size()) + if (!list.size()) return false; first = last = list[0].row(); - for(auto item: list) + for (auto item : list) { int row = item.row(); - if(row < first) + if (row < first) first = row; - if(row > last) + if (row > last) last = row; } return true; -} \ No newline at end of file +} + +void showWebsiteForMod(QWidget *parentDlg, Mod &m) +{ + QString url = m.homeurl(); + if (url.size()) + { + // catch the cases where the protocol is missing + if(!url.startsWith("http")) + { + url = "http://" + url; + } + QDesktopServices::openUrl(url); + } + else + { + QMessageBox::warning( + parentDlg, parentDlg->tr("How sad!"), + parentDlg->tr("The mod author didn't provide a website link for this mod.")); + } +} diff --git a/gui/ModEditDialogCommon.h b/gui/ModEditDialogCommon.h index a27a8a82..bc8e223f 100644 --- a/gui/ModEditDialogCommon.h +++ b/gui/ModEditDialogCommon.h @@ -1,4 +1,7 @@ #pragma once #include +#include -bool lastfirst (QModelIndexList & list, int & first, int & last); \ No newline at end of file +bool lastfirst (QModelIndexList & list, int & first, int & last); + +void showWebsiteForMod(QWidget * parentDlg, Mod& m); \ No newline at end of file diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp index 24f01c53..788a61d0 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/OneSixModEditDialog.cpp @@ -30,6 +30,7 @@ #include #include #include +#include OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent) : m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog) @@ -296,3 +297,13 @@ void OneSixModEditDialog::on_viewResPackBtn_clicked() { openDirInDefaultProgram(m_inst->resourcePacksDir(), true); } + +void OneSixModEditDialog::on_loaderWebsite_clicked() +{ + int first, last; + auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + showWebsiteForMod(this, m_mods->operator[](first)); +} diff --git a/gui/OneSixModEditDialog.h b/gui/OneSixModEditDialog.h index 5c65fea3..ce4da4fe 100644 --- a/gui/OneSixModEditDialog.h +++ b/gui/OneSixModEditDialog.h @@ -44,6 +44,7 @@ private slots: void on_forgeBtn_clicked(); void on_customizeBtn_clicked(); void on_revertBtn_clicked(); + void on_loaderWebsite_clicked(); void updateVersionControls(); void disableVersionControls(); protected: diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui index 527899ca..b97d4304 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/OneSixModEditDialog.ui @@ -184,6 +184,13 @@ + + + + Website + + + diff --git a/logic/Mod.cpp b/logic/Mod.cpp index 75e0a3a9..825e663f 100644 --- a/logic/Mod.cpp +++ b/logic/Mod.cpp @@ -1,12 +1,12 @@ -// +// // Copyright 2012 MultiMC Contributors -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,17 +28,17 @@ #include #include -Mod::Mod( const QFileInfo& file ) +Mod::Mod(const QFileInfo &file) { repath(file); } -void Mod::repath ( const QFileInfo& file ) +void Mod::repath(const QFileInfo &file) { m_file = file; m_name = file.completeBaseName(); m_id = file.fileName(); - + m_type = Mod::MOD_UNKNOWN; if (m_file.isDir()) m_type = MOD_FOLDER; @@ -50,19 +50,19 @@ void Mod::repath ( const QFileInfo& file ) else m_type = MOD_SINGLEFILE; } - if(m_type == MOD_ZIPFILE) + if (m_type == MOD_ZIPFILE) { QuaZip zip(m_file.filePath()); - if(!zip.open(QuaZip::mdUnzip)) + if (!zip.open(QuaZip::mdUnzip)) return; - + QuaZipFile file(&zip); - for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile()) + for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) { QString name = zip.getCurrentFileName(); - if(name == "mcmod.info") + if (name == "mcmod.info") { - if(!file.open(QIODevice::ReadOnly)) + if (!file.open(QIODevice::ReadOnly)) { zip.close(); return; @@ -72,9 +72,9 @@ void Mod::repath ( const QFileInfo& file ) zip.close(); return; } - else if(name == "forgeversion.properties") + else if (name == "forgeversion.properties") { - if(!file.open(QIODevice::ReadOnly)) + if (!file.open(QIODevice::ReadOnly)) { zip.close(); return; @@ -87,16 +87,16 @@ void Mod::repath ( const QFileInfo& file ) } zip.close(); } - else if(m_type == MOD_FOLDER) + else if (m_type == MOD_FOLDER) { QFileInfo mcmod_info(PathCombine(m_file.filePath(), "mcmod.info")); if (mcmod_info.isFile()) { QFile mcmod(mcmod_info.filePath()); - if(!mcmod.open(QIODevice::ReadOnly)) + if (!mcmod.open(QIODevice::ReadOnly)) return; auto data = mcmod.readAll(); - if(data.isEmpty() || data.isNull()) + if (data.isEmpty() || data.isNull()) return; ReadMCModInfo(data); } @@ -110,35 +110,37 @@ void Mod::repath ( const QFileInfo& file ) // https://github.com/MinecraftForge/FML/wiki/FML-mod-information-file/5bf6a2d05145ec79387acc0d45c958642fb049fc void Mod::ReadMCModInfo(QByteArray contents) { - auto getInfoFromArray = [&]( QJsonArray arr ) -> void + auto getInfoFromArray = [&](QJsonArray arr)->void { - if(!arr.at(0).isObject()) + if (!arr.at(0).isObject()) return; auto firstObj = arr.at(0).toObject(); m_id = firstObj.value("modid").toString(); m_name = firstObj.value("name").toString(); m_version = firstObj.value("version").toString(); + m_homeurl = firstObj.value("url").toString(); return; - }; + } + ; QJsonParseError jsonError; QJsonDocument jsonDoc = QJsonDocument::fromJson(contents, &jsonError); // this is the very old format that had just the array - if(jsonDoc.isArray()) + if (jsonDoc.isArray()) { getInfoFromArray(jsonDoc.array()); } - else if(jsonDoc.isObject()) + else if (jsonDoc.isObject()) { auto val = jsonDoc.object().value("modinfoversion"); int version = val.toDouble(); - if(version != 2) + if (version != 2) { QLOG_ERROR() << "BAD stuff happened to mod json:"; QLOG_ERROR() << contents; return; } auto arrVal = jsonDoc.object().value("modlist"); - if(arrVal.isArray()) + if (arrVal.isArray()) { getInfoFromArray(arrVal.toArray()); } @@ -150,33 +152,34 @@ void Mod::ReadForgeInfo(QByteArray contents) // Read the data m_name = "Minecraft Forge"; m_id = "Forge"; + m_homeurl = "http://www.minecraftforge.net/forum/"; INIFile ini; - if(!ini.loadFile(contents)) + if (!ini.loadFile(contents)) return; - - QString major = ini.get("forge.major.number","0").toString(); - QString minor = ini.get("forge.minor.number","0").toString(); - QString revision = ini.get("forge.revision.number","0").toString(); - QString build = ini.get("forge.build.number","0").toString(); - + + QString major = ini.get("forge.major.number", "0").toString(); + QString minor = ini.get("forge.minor.number", "0").toString(); + QString revision = ini.get("forge.revision.number", "0").toString(); + QString build = ini.get("forge.build.number", "0").toString(); + m_version = major + "." + minor + "." + revision + "." + build; } -bool Mod::replace ( Mod& with ) +bool Mod::replace(Mod &with) { - if(!destroy()) + if (!destroy()) return false; bool success = false; auto t = with.type(); - if(t == MOD_ZIPFILE || t == MOD_SINGLEFILE) + if (t == MOD_ZIPFILE || t == MOD_SINGLEFILE) { success = QFile::copy(with.m_file.filePath(), m_file.path()); } - if(t == MOD_FOLDER) + if (t == MOD_FOLDER) { success = copyPath(with.m_file.filePath(), m_file.path()); } - if(success) + if (success) { m_id = with.m_id; m_mcversion = with.m_mcversion; @@ -189,10 +192,10 @@ bool Mod::replace ( Mod& with ) bool Mod::destroy() { - if(m_type == MOD_FOLDER) + if (m_type == MOD_FOLDER) { QDir d(m_file.filePath()); - if(d.removeRecursively()) + if (d.removeRecursively()) { m_type = MOD_UNKNOWN; return true; @@ -202,7 +205,7 @@ bool Mod::destroy() else if (m_type == MOD_SINGLEFILE || m_type == MOD_ZIPFILE) { QFile f(m_file.filePath()); - if(f.remove()) + if (f.remove()) { m_type = MOD_UNKNOWN; return true; @@ -212,18 +215,17 @@ bool Mod::destroy() return true; } - QString Mod::version() const { - switch(type()) + switch (type()) { - case MOD_ZIPFILE: - return m_version; - case MOD_FOLDER: - return "Folder"; - case MOD_SINGLEFILE: - return "File"; - default: - return "VOID"; + case MOD_ZIPFILE: + return m_version; + case MOD_FOLDER: + return "Folder"; + case MOD_SINGLEFILE: + return "File"; + default: + return "VOID"; } } diff --git a/logic/Mod.h b/logic/Mod.h index fcfcc139..9831fdc0 100644 --- a/logic/Mod.h +++ b/logic/Mod.h @@ -1,12 +1,12 @@ -// +// // Copyright 2012 MultiMC Contributors -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,46 +22,72 @@ class Mod public: enum ModType { - MOD_UNKNOWN, //!< Indicates an unspecified mod type. - MOD_ZIPFILE, //!< The mod is a zip file containing the mod's class files. + MOD_UNKNOWN, //!< Indicates an unspecified mod type. + MOD_ZIPFILE, //!< The mod is a zip file containing the mod's class files. MOD_SINGLEFILE, //!< The mod is a single file (not a zip file). - MOD_FOLDER, //!< The mod is in a folder on the filesystem. + MOD_FOLDER, //!< The mod is in a folder on the filesystem. }; Mod(const QFileInfo &file); - - QFileInfo filename() const { return m_file; } - QString id() const { return m_id; } - ModType type() const { return m_type; } - QString mcversion() const { return m_mcversion; }; - bool valid() {return m_type != MOD_UNKNOWN;} - QString name() const {return m_name; }; - + + QFileInfo filename() const + { + return m_file; + } + QString id() const + { + return m_id; + } + ModType type() const + { + return m_type; + } + QString mcversion() const + { + return m_mcversion; + } + ; + bool valid() + { + return m_type != MOD_UNKNOWN; + } + QString name() const + { + return m_name; + } + QString version() const; - - + + QString homeurl() const + { + return m_homeurl; + } + // delete all the files of this mod bool destroy(); // replace this mod with a copy of the other - bool replace(Mod & with); + bool replace(Mod &with); // change the mod's filesystem path (used by mod lists for *MAGIC* purposes) void repath(const QFileInfo &file); // WEAK compare operator - used for replacing mods - bool operator ==(const Mod &other) const + bool operator==(const Mod &other) const { return filename() == other.filename(); } bool strongCompare(const Mod &other) const { - return filename() == other.filename() && id() == other.id() && version() == other.version() && type() == other.type(); + return filename() == other.filename() && id() == other.id() && + version() == other.version() && type() == other.type(); } + private: void ReadMCModInfo(QByteArray contents); void ReadForgeInfo(QByteArray contents); + protected: - //FIXME: what do do with those? HMM... + // FIXME: what do do with those? HMM... /* void ReadModInfoData(QString info); void ReadForgeInfoData(QString infoFileData); @@ -72,6 +98,7 @@ protected: QString m_name; QString m_version; QString m_mcversion; + QString m_homeurl; ModType m_type; }; diff --git a/logic/lists/MinecraftVersionList.cpp b/logic/lists/MinecraftVersionList.cpp index fbf609b5..dd26714a 100644 --- a/logic/lists/MinecraftVersionList.cpp +++ b/logic/lists/MinecraftVersionList.cpp @@ -3,7 +3,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -32,10 +32,8 @@ #define ASSETS_URLBASE "http://assets.minecraft.net/" #define MCN_URLBASE "http://sonicrules.org/mcnweb.py" -MinecraftVersionList::MinecraftVersionList(QObject *parent) : - BaseVersionList(parent) +MinecraftVersionList::MinecraftVersionList(QObject *parent) : BaseVersionList(parent) { - } Task *MinecraftVersionList::getLoadTask() @@ -76,7 +74,7 @@ BaseVersionPtr MinecraftVersionList::getLatestStable() const { for (int i = 0; i < m_vlist.length(); i++) { - auto ver =std::dynamic_pointer_cast(m_vlist.at(i)); + auto ver = std::dynamic_pointer_cast(m_vlist.at(i)); if (ver->is_latest && !ver->is_snapshot) { return m_vlist.at(i); @@ -85,7 +83,7 @@ BaseVersionPtr MinecraftVersionList::getLatestStable() const return BaseVersionPtr(); } -void MinecraftVersionList::updateListData(QList versions) +void MinecraftVersionList::updateListData(QList versions) { beginResetModel(); m_vlist = versions; @@ -109,7 +107,6 @@ inline QDateTime timeFromS3Time(QString str) return QDateTime::fromString(str, Qt::ISODate); } - MCVListLoadTask::MCVListLoadTask(MinecraftVersionList *vlist) { m_list = vlist; @@ -151,91 +148,91 @@ void MCVListLoadTask::executeTask() connect(vlistReply, SIGNAL(finished()), this, SLOT(list_downloaded())); } - void MCVListLoadTask::list_downloaded() { - if(vlistReply->error() != QNetworkReply::NoError) + if (vlistReply->error() != QNetworkReply::NoError) { vlistReply->deleteLater(); emitFailed("Failed to load Minecraft main version list" + vlistReply->errorString()); return; } - + QJsonParseError jsonError; QJsonDocument jsonDoc = QJsonDocument::fromJson(vlistReply->readAll(), &jsonError); vlistReply->deleteLater(); - + if (jsonError.error != QJsonParseError::NoError) { emitFailed("Error parsing version list JSON:" + jsonError.errorString()); return; } - if(!jsonDoc.isObject()) + if (!jsonDoc.isObject()) { emitFailed("Error parsing version list JSON: jsonDoc is not an object"); return; } - + QJsonObject root = jsonDoc.object(); - + // Get the ID of the latest release and the latest snapshot. - if(!root.value("latest").isObject()) + if (!root.value("latest").isObject()) { emitFailed("Error parsing version list JSON: version list is missing 'latest' object"); return; } - + QJsonObject latest = root.value("latest").toObject(); - + QString latestReleaseID = latest.value("release").toString(""); QString latestSnapshotID = latest.value("snapshot").toString(""); - if(latestReleaseID.isEmpty()) + if (latestReleaseID.isEmpty()) { emitFailed("Error parsing version list JSON: latest release field is missing"); return; } - if(latestSnapshotID.isEmpty()) + if (latestSnapshotID.isEmpty()) { emitFailed("Error parsing version list JSON: latest snapshot field is missing"); return; } // Now, get the array of versions. - if(!root.value("versions").isArray()) + if (!root.value("versions").isArray()) { - emitFailed("Error parsing version list JSON: version list object is missing 'versions' array"); + emitFailed( + "Error parsing version list JSON: version list object is missing 'versions' array"); return; } QJsonArray versions = root.value("versions").toArray(); - - QList tempList; + + QList tempList; for (int i = 0; i < versions.count(); i++) { bool is_snapshot = false; bool is_latest = false; - + // Load the version info. - if(!versions[i].isObject()) + if (!versions[i].isObject()) { - //FIXME: log this somewhere + // FIXME: log this somewhere continue; } QJsonObject version = versions[i].toObject(); QString versionID = version.value("id").toString(""); QString versionTimeStr = version.value("releaseTime").toString(""); QString versionTypeStr = version.value("type").toString(""); - if(versionID.isEmpty() || versionTimeStr.isEmpty() || versionTypeStr.isEmpty()) + if (versionID.isEmpty() || versionTimeStr.isEmpty() || versionTypeStr.isEmpty()) { - //FIXME: log this somewhere + // FIXME: log this somewhere continue; } - + // Parse the timestamp. QDateTime versionTime = timeFromS3Time(versionTimeStr); - if(!versionTime.isValid()) + if (!versionTime.isValid()) { - //FIXME: log this somewhere + // FIXME: log this somewhere continue; } // Parse the type. @@ -243,23 +240,25 @@ void MCVListLoadTask::list_downloaded() // OneSix or Legacy. use filter to determine type if (versionTypeStr == "release") { - versionType = legacyWhitelist.contains(versionID)?MinecraftVersion::Legacy:MinecraftVersion::OneSix; + versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy + : MinecraftVersion::OneSix; is_latest = (versionID == latestReleaseID); is_snapshot = false; } - else if(versionTypeStr == "snapshot") // It's a snapshot... yay + else if (versionTypeStr == "snapshot") // It's a snapshot... yay { - versionType = legacyWhitelist.contains(versionID)?MinecraftVersion::Legacy:MinecraftVersion::OneSix; + versionType = legacyWhitelist.contains(versionID) ? MinecraftVersion::Legacy + : MinecraftVersion::OneSix; is_latest = (versionID == latestSnapshotID); is_snapshot = true; } - else if(versionTypeStr == "old_alpha") + else if (versionTypeStr == "old_alpha") { versionType = MinecraftVersion::Nostalgia; is_latest = false; is_snapshot = false; } - else if(versionTypeStr == "old_beta") + else if (versionTypeStr == "old_beta") { versionType = MinecraftVersion::Legacy; is_latest = false; @@ -267,12 +266,12 @@ void MCVListLoadTask::list_downloaded() } else { - //FIXME: log this somewhere + // FIXME: log this somewhere continue; } // Get the download URL. QString dlUrl = QString(MCVLIST_URLBASE) + versionID + "/"; - + // Now, we construct the version object and add it to the list. std::shared_ptr mcVersion(new MinecraftVersion()); mcVersion->m_name = mcVersion->m_descriptor = versionID; @@ -284,7 +283,7 @@ void MCVListLoadTask::list_downloaded() tempList.append(mcVersion); } m_list->updateListData(tempList); - + emitSucceeded(); return; } -- cgit From 60e7e019fe62f48ebdb5cea0ab83ab58f3379fdf Mon Sep 17 00:00:00 2001 From: Sky Date: Tue, 8 Oct 2013 17:07:54 +0100 Subject: Start mcmod.info panel. Needs to be its own widget and included in legacy mod edit window, text labels need eliding --- gui/OneSixModEditDialog.cpp | 31 +++- gui/OneSixModEditDialog.h | 4 +- gui/OneSixModEditDialog.ui | 365 ++++++++++++++++++++++++++++++++++++++------ logic/Mod.cpp | 12 ++ logic/Mod.h | 18 +++ 5 files changed, 377 insertions(+), 53 deletions(-) (limited to 'gui/OneSixModEditDialog.ui') diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp index 788a61d0..d97967e8 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/OneSixModEditDialog.cpp @@ -298,12 +298,39 @@ void OneSixModEditDialog::on_viewResPackBtn_clicked() openDirInDefaultProgram(m_inst->resourcePacksDir(), true); } -void OneSixModEditDialog::on_loaderWebsite_clicked() +void OneSixModEditDialog::on_loaderModTreeView_pressed(const QModelIndex &index) { int first, last; auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); if (!lastfirst(list, first, last)) return; - showWebsiteForMod(this, m_mods->operator[](first)); + + Mod &m = m_mods->operator[](first); + + QString missing = "

Missing from mcmod.info

"; + + QString name = m.name(); + if(name.isEmpty()) name = missing; + QString description = m.description(); + if(description.isEmpty()) description = missing; + QString authors = m.authors(); + if(authors.isEmpty()) authors = missing; + QString credits = m.credits(); + if(credits.isEmpty()) credits = missing; + QString website = m.homeurl(); + if(website.isEmpty()) website = missing; + else website = "" + website + ""; + + ui->label_Name->setText("

" + name + "

"); + ui->label_Description->setText(description); + ui->label_Authors->setText(authors); + ui->label_Credits->setText(credits); + ui->label_Website->setText(website); + + ui->label_Name->setToolTip("

" + name + "

"); + ui->label_Description->setToolTip(description); + ui->label_Authors->setToolTip(authors); + ui->label_Credits->setToolTip(credits); + //ui->label_Website->setToolTip(website); } diff --git a/gui/OneSixModEditDialog.h b/gui/OneSixModEditDialog.h index ce4da4fe..03ebf7a3 100644 --- a/gui/OneSixModEditDialog.h +++ b/gui/OneSixModEditDialog.h @@ -44,9 +44,11 @@ private slots: void on_forgeBtn_clicked(); void on_customizeBtn_clicked(); void on_revertBtn_clicked(); - void on_loaderWebsite_clicked(); void updateVersionControls(); void disableVersionControls(); + + void on_loaderModTreeView_pressed(const QModelIndex &index); + protected: bool eventFilter(QObject *obj, QEvent *ev); bool loaderListFilter( QKeyEvent* ev ); diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui index b97d4304..88ba5a76 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/OneSixModEditDialog.ui @@ -26,7 +26,7 @@
- 0 + 1 @@ -157,62 +157,327 @@ Loader Mods - + - - - true - - - QAbstractItemView::DropOnly - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Website - - - + - - - Qt::Vertical - - - - 20 - 40 - - - + + + + + + 0 + 0 + + + + true + + + QAbstractItemView::DropOnly + + + + - - - &View Folder - - + + + + + &Add + + + + + + + &Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + &View Folder + + + + + + + + + 55 + 0 + + + + + 16777215 + 150 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 250 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 9 + + + 0 + + + + + + 0 + 0 + + + + + 250 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-size:9pt; font-weight:600; font-style:italic;">Select a mod to view information...</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + 0 + 0 + + + + + 250 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic;">Mod description</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + + + QLayout::SetDefaultConstraint + + + QFormLayout::AllNonFixedFieldsGrow + + + + + + 200 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod authors</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Credits: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 200 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod credits</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Website: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 200 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod website</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + + + + + Authors: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + diff --git a/logic/Mod.cpp b/logic/Mod.cpp index 825e663f..c45e3ad2 100644 --- a/logic/Mod.cpp +++ b/logic/Mod.cpp @@ -119,6 +119,18 @@ void Mod::ReadMCModInfo(QByteArray contents) m_name = firstObj.value("name").toString(); m_version = firstObj.value("version").toString(); m_homeurl = firstObj.value("url").toString(); + m_description = firstObj.value("description").toString(); + QJsonArray authors = firstObj.value("authors").toArray(); + if(authors.size() == 0) m_authors = ""; + else if(authors.size() >= 1) + { + m_authors = authors.at(0).toString(); + for(int i = 1; i < authors.size(); i++) + { + m_authors += ", " + authors.at(i).toString(); + } + } + m_credits = firstObj.value("credits").toString(); return; } ; diff --git a/logic/Mod.h b/logic/Mod.h index 9831fdc0..f3aaf18b 100644 --- a/logic/Mod.h +++ b/logic/Mod.h @@ -63,6 +63,21 @@ public: return m_homeurl; } + QString description() const + { + return m_description; + } + + QString authors() const + { + return m_authors; + } + + QString credits() const + { + return m_credits; + } + // delete all the files of this mod bool destroy(); // replace this mod with a copy of the other @@ -99,6 +114,9 @@ protected: QString m_version; QString m_mcversion; QString m_homeurl; + QString m_description; + QString m_authors; + QString m_credits; ModType m_type; }; -- cgit From f2291ef161c6ae2d47ede15633626ab1e8caab86 Mon Sep 17 00:00:00 2001 From: Sky Date: Tue, 8 Oct 2013 21:45:48 +0100 Subject: Move mod info frame and handler to MCModInfoFrame, use on all instances --- CMakeLists.txt | 4 + gui/LegacyModEditDialog.cpp | 39 ++++++ gui/LegacyModEditDialog.h | 6 + gui/LegacyModEditDialog.ui | 327 ++++++++++++++++++++++++-------------------- gui/MCModInfoFrame.cpp | 66 +++++++++ gui/MCModInfoFrame.h | 32 +++++ gui/MCModInfoFrame.ui | 261 +++++++++++++++++++++++++++++++++++ gui/ModListView.h | 3 +- gui/OneSixModEditDialog.cpp | 26 +--- gui/OneSixModEditDialog.ui | 256 +--------------------------------- 10 files changed, 595 insertions(+), 425 deletions(-) create mode 100644 gui/MCModInfoFrame.cpp create mode 100644 gui/MCModInfoFrame.h create mode 100644 gui/MCModInfoFrame.ui (limited to 'gui/OneSixModEditDialog.ui') diff --git a/CMakeLists.txt b/CMakeLists.txt index a02a4b27..5503c5ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,6 +215,8 @@ gui/LabeledToolButton.h gui/LabeledToolButton.cpp gui/EditNotesDialog.h gui/EditNotesDialog.cpp +gui/MCModInfoFrame.h +gui/MCModInfoFrame.cpp # Base classes and infrastructure logic/BaseVersion.h @@ -334,6 +336,8 @@ gui/IconPickerDialog.ui gui/LegacyModEditDialog.ui gui/OneSixModEditDialog.ui gui/EditNotesDialog.ui + +gui/MCModInfoFrame.ui ) set (FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${MULTIMC_SOURCES} ${MULTIMC_UIS}) diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index 87647e0f..72792581 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -376,3 +376,42 @@ void LegacyModEditDialog::on_loaderWebsite_clicked() return; showWebsiteForMod(this, m_mods->operator[](first)); } + +void LegacyModEditDialog::on_jarModsTreeView_pressed(const QModelIndex &index) +{ + int first, last; + auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + + Mod &m = m_jarmods->operator[](first); + + handleModInfoUpdate(m, ui->jarMIFrame); +} + +void LegacyModEditDialog::on_coreModsTreeView_pressed(const QModelIndex &index) +{ + int first, last; + auto list = ui->coreModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + + Mod &m = m_coremods->operator[](first); + + handleModInfoUpdate(m, ui->coreMIFrame); +} + +void LegacyModEditDialog::on_loaderModTreeView_pressed(const QModelIndex &index) +{ + int first, last; + auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + + Mod &m = m_mods->operator[](first); + + handleModInfoUpdate(m, ui->loaderMIFrame); +} diff --git a/gui/LegacyModEditDialog.h b/gui/LegacyModEditDialog.h index f12d9a7b..fcf07f1c 100644 --- a/gui/LegacyModEditDialog.h +++ b/gui/LegacyModEditDialog.h @@ -60,6 +60,12 @@ slots: // Questionable: SettingsDialog doesn't need this for some reason? void on_buttonBox_rejected(); + void on_jarModsTreeView_pressed(const QModelIndex &index); + + void on_coreModsTreeView_pressed(const QModelIndex &index); + + void on_loaderModTreeView_pressed(const QModelIndex &index); + protected: bool eventFilter(QObject *obj, QEvent *ev); bool jarListFilter(QKeyEvent *ev); diff --git a/gui/LegacyModEditDialog.ui b/gui/LegacyModEditDialog.ui index 6a4b6d1e..3ab946d9 100644 --- a/gui/LegacyModEditDialog.ui +++ b/gui/LegacyModEditDialog.ui @@ -23,197 +23,218 @@ Jar Mods - + - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - - - - - - - &Add - - - - - - - &Remove - - - + - - - MCForge - - - - - - - Website - - - - - - - Qt::Vertical - - - - 20 - 40 - + + + Qt::ScrollBarAlwaysOn - - - - - - Move &Up + + Qt::ScrollBarAlwaysOff - - - Move &Down - - + + + + + &Add + + + + + + + &Remove + + + + + + + MCForge + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Move &Up + + + + + + + Move &Down + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + Core Mods - + - - - QAbstractItemView::DropOnly - - - - - - - - - &Add - - - + - - - &Remove + + + QAbstractItemView::DropOnly - - - Website - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - + + + + + &Add + + + + + + + &Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + &View Folder + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + Loader Mods - - - - - true - - - QAbstractItemView::DropOnly - - - + - + - - - &Add + + + true - - - - - - &Remove - - - - - - - Website + + QAbstractItemView::DropOnly - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - + + + + + &Add + + + + + + + &Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + &View Folder + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + @@ -291,6 +312,12 @@ QTreeView
gui/ModListView.h
+ + MCModInfoFrame + QFrame +
gui/MCModInfoFrame.h
+ 1 +
diff --git a/gui/MCModInfoFrame.cpp b/gui/MCModInfoFrame.cpp new file mode 100644 index 00000000..805af56b --- /dev/null +++ b/gui/MCModInfoFrame.cpp @@ -0,0 +1,66 @@ +#include "MCModInfoFrame.h" +#include "ui_MCModInfoFrame.h" + +void handleModInfoUpdate(Mod &m, MCModInfoFrame *frame) +{ + QString missing = "

Missing from mcmod.info

"; + + QString name = m.name(); + if(name.isEmpty()) name = missing; + QString description = m.description(); + if(description.isEmpty()) description = missing; + QString authors = m.authors(); + if(authors.isEmpty()) authors = missing; + QString credits = m.credits(); + if(credits.isEmpty()) credits = missing; + QString website = m.homeurl(); + if(website.isEmpty()) website = missing; + else website = "" + website + ""; + + frame->setName("

" + name + "

"); + frame->setDescription(description); + frame->setAuthors(authors); + frame->setCredits(credits); + frame->setWebsite(website); +} + +MCModInfoFrame::MCModInfoFrame(QWidget *parent) : + QFrame(parent), + ui(new Ui::MCModInfoFrame) +{ + ui->setupUi(this); +} + +MCModInfoFrame::~MCModInfoFrame() +{ + delete ui; +} + +void MCModInfoFrame::setName(QString name) +{ + ui->label_Name->setText(name); + ui->label_Name->setToolTip(name); +} + +void MCModInfoFrame::setDescription(QString description) +{ + ui->label_Description->setText(description); + ui->label_Description->setToolTip(description); +} + +void MCModInfoFrame::setAuthors(QString authors) +{ + ui->label_Authors->setText(authors); + ui->label_Authors->setToolTip(authors); +} + +void MCModInfoFrame::setCredits(QString credits) +{ + ui->label_Credits->setText(credits); + ui->label_Credits->setToolTip(credits); +} + +void MCModInfoFrame::setWebsite(QString website) +{ + ui->label_Website->setText(website); +} diff --git a/gui/MCModInfoFrame.h b/gui/MCModInfoFrame.h new file mode 100644 index 00000000..7910bd0c --- /dev/null +++ b/gui/MCModInfoFrame.h @@ -0,0 +1,32 @@ +#ifndef MCMODINFOFRAME_H +#define MCMODINFOFRAME_H + +#include +#include "logic/Mod.h" + +namespace Ui { +class MCModInfoFrame; +} + +class MCModInfoFrame : public QFrame +{ + Q_OBJECT + +public: + explicit MCModInfoFrame(QWidget *parent = 0); + ~MCModInfoFrame(); + + void setName(QString name); + void setDescription(QString description); + void setAuthors(QString authors); + void setCredits(QString credits); + void setWebsite(QString website); + + +private: + Ui::MCModInfoFrame *ui; +}; + +void handleModInfoUpdate(Mod &m, MCModInfoFrame *frame); + +#endif // MCMODINFOFRAME_H diff --git a/gui/MCModInfoFrame.ui b/gui/MCModInfoFrame.ui new file mode 100644 index 00000000..022588d5 --- /dev/null +++ b/gui/MCModInfoFrame.ui @@ -0,0 +1,261 @@ + + + MCModInfoFrame + + + + 0 + 0 + 571 + 55 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 250 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 9 + + + 0 + + + + + + 0 + 0 + + + + + 250 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-size:9pt; font-weight:600; font-style:italic;">Select a mod to view information...</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + 0 + 0 + + + + + 250 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic;">Mod description</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + + + QLayout::SetDefaultConstraint + + + QFormLayout::AllNonFixedFieldsGrow + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + 200 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod authors</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Credits: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 200 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod credits</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Website: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 200 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod website</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + + + + + Authors: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + diff --git a/gui/ModListView.h b/gui/ModListView.h index a9408fe7..69a26755 100644 --- a/gui/ModListView.h +++ b/gui/ModListView.h @@ -9,4 +9,5 @@ class ModListView: public QTreeView public: explicit ModListView ( QWidget* parent = 0 ); virtual void setModel ( QAbstractItemModel* model ); -}; \ No newline at end of file + +}; diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp index d97967e8..9724cec5 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/OneSixModEditDialog.cpp @@ -308,29 +308,5 @@ void OneSixModEditDialog::on_loaderModTreeView_pressed(const QModelIndex &index) Mod &m = m_mods->operator[](first); - QString missing = "

Missing from mcmod.info

"; - - QString name = m.name(); - if(name.isEmpty()) name = missing; - QString description = m.description(); - if(description.isEmpty()) description = missing; - QString authors = m.authors(); - if(authors.isEmpty()) authors = missing; - QString credits = m.credits(); - if(credits.isEmpty()) credits = missing; - QString website = m.homeurl(); - if(website.isEmpty()) website = missing; - else website = "" + website + ""; - - ui->label_Name->setText("

" + name + "

"); - ui->label_Description->setText(description); - ui->label_Authors->setText(authors); - ui->label_Credits->setText(credits); - ui->label_Website->setText(website); - - ui->label_Name->setToolTip("

" + name + "

"); - ui->label_Description->setToolTip(description); - ui->label_Authors->setToolTip(authors); - ui->label_Credits->setToolTip(credits); - //ui->label_Website->setToolTip(website); + handleModInfoUpdate(m, ui->frame); } diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui index 88ba5a76..675a6faa 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/OneSixModEditDialog.ui @@ -221,261 +221,13 @@
- - - - 55 - 0 - - - - - 16777215 - 150 - - + QFrame::StyledPanel QFrame::Raised - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 250 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 9 - - - 0 - - - - - - 0 - 0 - - - - - 250 - 0 - - - - - 16777215 - 92 - - - - <html><head/><body><p><span style=" font-size:9pt; font-weight:600; font-style:italic;">Select a mod to view information...</span></p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - - 0 - 0 - - - - - 250 - 0 - - - - - 16777215 - 92 - - - - <html><head/><body><p><span style=" font-style:italic;">Mod description</span></p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - - - - QLayout::SetDefaultConstraint - - - QFormLayout::AllNonFixedFieldsGrow - - - - - - 200 - 0 - - - - - 16777215 - 92 - - - - <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod authors</span></p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - Credits: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 200 - 0 - - - - - 16777215 - 92 - - - - <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod credits</span></p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - Website: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 200 - 0 - - - - - 16777215 - 92 - - - - <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod website</span></p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - true - - - - - - - Authors: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - @@ -555,6 +307,12 @@ QTreeView
gui/ModListView.h
+ + MCModInfoFrame + QFrame +
gui/MCModInfoFrame.h
+ 1 +
-- cgit From 14b47057fdbcec7d259ae0a73b201f3f0757b8e2 Mon Sep 17 00:00:00 2001 From: Sky Date: Wed, 9 Oct 2013 02:26:03 +0100 Subject: Clean up mcmod panel massively. Keep it simple - name (optionally linked), optional authors and description. Needs cut-off handling, frame looking at on Windows --- gui/LegacyModEditDialog.ui | 5 +- gui/MCModInfoFrame.cpp | 64 ++++-------- gui/MCModInfoFrame.h | 7 +- gui/MCModInfoFrame.ui | 246 +++++++++++---------------------------------- gui/OneSixModEditDialog.ui | 10 +- 5 files changed, 87 insertions(+), 245 deletions(-) (limited to 'gui/OneSixModEditDialog.ui') diff --git a/gui/LegacyModEditDialog.ui b/gui/LegacyModEditDialog.ui index 3ab946d9..bb0d9ef2 100644 --- a/gui/LegacyModEditDialog.ui +++ b/gui/LegacyModEditDialog.ui @@ -92,11 +92,8 @@ - - QFrame::StyledPanel - - QFrame::Raised + QFrame::Plain diff --git a/gui/MCModInfoFrame.cpp b/gui/MCModInfoFrame.cpp index 15ead7ab..a0458cbc 100644 --- a/gui/MCModInfoFrame.cpp +++ b/gui/MCModInfoFrame.cpp @@ -23,34 +23,27 @@ void MCModInfoFrame::updateWithMod(Mod &m) return; } - QString missing = tr("Missing from mcmod.info"); + QString text = ""; + if(m.homeurl().isEmpty()) text = m.name(); + else text = "" + m.name() + ""; + if(!m.authors().isEmpty()) text += " by " + m.authors(); - QString name = m.name(); - if(name.isEmpty()) name = missing; - QString description = m.description(); - if(description.isEmpty()) description = missing; - QString authors = m.authors(); - if(authors.isEmpty()) authors = missing; - QString credits = m.credits(); - if(credits.isEmpty()) credits = missing; - QString website = m.homeurl(); - if(website.isEmpty()) website = missing; - else website = "" + website + ""; + setModText(text); - setName(name); - setDescription(description); - setAuthors(authors); - setCredits(credits); - setWebsite(website); + if(m.description().isEmpty()) + { + setModDescription(tr("No description provided in mcmod.info")); + } + else + { + setModDescription(m.description()); + } } void MCModInfoFrame::clear() { - setName(tr("Select a mod to view information...")); - setDescription(tr("Mod description")); - setAuthors(tr("Mod authors")); - setCredits(tr("Mod credits")); - setWebsite(tr("Mod website")); + setModText(tr("Select a mod to view title and authors...")); + setModDescription(tr("Select a mod to view description...")); } MCModInfoFrame::MCModInfoFrame(QWidget *parent) : @@ -65,31 +58,12 @@ MCModInfoFrame::~MCModInfoFrame() delete ui; } -void MCModInfoFrame::setName(QString name) -{ - ui->label_Name->setText(name); - //ui->label_Name->setToolTip(name); -} - -void MCModInfoFrame::setDescription(QString description) -{ - ui->label_Description->setText(description); - //ui->label_Description->setToolTip(description); -} - -void MCModInfoFrame::setAuthors(QString authors) -{ - ui->label_Authors->setText(authors); - //ui->label_Authors->setToolTip(authors); -} - -void MCModInfoFrame::setCredits(QString credits) +void MCModInfoFrame::setModText(QString text) { - ui->label_Credits->setText(credits); - //ui->label_Credits->setToolTip(credits); + ui->label_ModText->setText(text); } -void MCModInfoFrame::setWebsite(QString website) +void MCModInfoFrame::setModDescription(QString text) { - ui->label_Website->setText(website); + ui->label_ModDescription->setText(text); } diff --git a/gui/MCModInfoFrame.h b/gui/MCModInfoFrame.h index 01812df7..cdf399cb 100644 --- a/gui/MCModInfoFrame.h +++ b/gui/MCModInfoFrame.h @@ -31,11 +31,8 @@ public: explicit MCModInfoFrame(QWidget *parent = 0); ~MCModInfoFrame(); - void setName(QString name); - void setDescription(QString description); - void setAuthors(QString authors); - void setCredits(QString credits); - void setWebsite(QString website); + void setModText(QString text); + void setModDescription(QString text); void updateWithMod(Mod &m); void clear(); diff --git a/gui/MCModInfoFrame.ui b/gui/MCModInfoFrame.ui index 41902c1a..b24251ae 100644 --- a/gui/MCModInfoFrame.ui +++ b/gui/MCModInfoFrame.ui @@ -2,202 +2,76 @@ MCModInfoFrame + + + 0 + 0 + 527 + 68 + + + + + 0 + 0 + + + + + 16777215 + 120 + + Frame - + - - - - - - 0 - 0 - - - - - 250 - 0 - - - - - 16777215 - 92 - - - - - 75 - true - - - - Select a mod to view information... - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - - 0 - 0 - - - - - 250 - 0 - - - - - 16777215 - 92 - - - - Mod description - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - + + + + 0 + 0 + + + + Select a mod to view title and authors... + + + Qt::RichText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + - - - QLayout::SetDefaultConstraint + + + + 0 + 0 + + + + Select a mod to view description... - - QFormLayout::AllNonFixedFieldsGrow + + Qt::PlainText - + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - Authors: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 200 - 0 - - - - - 16777215 - 92 - - - - Mod authors - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - Website: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 200 - 0 - - - - - 16777215 - 92 - - - - Mod website - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - true - - - - - - - - 200 - 0 - - - - - 16777215 - 92 - - - - Mod credits - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - Credits: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - + + true + + diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui index 675a6faa..6d70200a 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/OneSixModEditDialog.ui @@ -222,11 +222,11 @@ - - QFrame::StyledPanel - - - QFrame::Raised + + + 0 + 0 + -- cgit