Merge branch 'feature_library_model' into develop
This commit is contained in:
commit
930b07afd4
@ -156,7 +156,7 @@ gui/mainwindow.h
|
|||||||
gui/settingsdialog.h
|
gui/settingsdialog.h
|
||||||
gui/newinstancedialog.h
|
gui/newinstancedialog.h
|
||||||
gui/logindialog.h
|
gui/logindialog.h
|
||||||
gui/taskdialog.h
|
gui/ProgressDialog.h
|
||||||
gui/aboutdialog.h
|
gui/aboutdialog.h
|
||||||
gui/consolewindow.h
|
gui/consolewindow.h
|
||||||
gui/instancedelegate.h
|
gui/instancedelegate.h
|
||||||
@ -172,7 +172,7 @@ gui/LabeledToolButton.h
|
|||||||
gui/EditNotesDialog.h
|
gui/EditNotesDialog.h
|
||||||
|
|
||||||
# Base classes and infrastructure
|
# Base classes and infrastructure
|
||||||
logic/InstanceVersion.h
|
logic/BaseVersion.h
|
||||||
logic/MinecraftVersion.h
|
logic/MinecraftVersion.h
|
||||||
logic/InstanceFactory.h
|
logic/InstanceFactory.h
|
||||||
logic/BaseUpdate.h
|
logic/BaseUpdate.h
|
||||||
@ -205,21 +205,30 @@ logic/OneSixInstance.h
|
|||||||
logic/OneSixInstance_p.h
|
logic/OneSixInstance_p.h
|
||||||
logic/OneSixUpdate.h
|
logic/OneSixUpdate.h
|
||||||
logic/OneSixVersion.h
|
logic/OneSixVersion.h
|
||||||
|
logic/OneSixLibrary.h
|
||||||
|
logic/OneSixRule.h
|
||||||
logic/VersionFactory.h
|
logic/VersionFactory.h
|
||||||
|
logic/OpSys.h
|
||||||
|
|
||||||
|
|
||||||
# Nostalgia
|
# Nostalgia
|
||||||
logic/NostalgiaInstance.h
|
logic/NostalgiaInstance.h
|
||||||
|
|
||||||
# Lists
|
# Lists
|
||||||
logic/lists/InstanceList.h
|
logic/lists/InstanceList.h
|
||||||
logic/lists/InstVersionList.h
|
logic/lists/IconList.h
|
||||||
|
logic/lists/BaseVersionList.h
|
||||||
logic/lists/MinecraftVersionList.h
|
logic/lists/MinecraftVersionList.h
|
||||||
logic/lists/LwjglVersionList.h
|
logic/lists/LwjglVersionList.h
|
||||||
logic/lists/IconList.h
|
logic/lists/ForgeVersionList.h
|
||||||
|
|
||||||
|
# misc model/view
|
||||||
|
logic/EnabledItemFilter.h
|
||||||
|
|
||||||
# Tasks
|
# Tasks
|
||||||
logic/tasks/Task.h
|
logic/tasks/Task.h
|
||||||
logic/tasks/LoginTask.h
|
logic/tasks/LoginTask.h
|
||||||
|
logic/tasks/ProgressProvider.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -231,13 +240,14 @@ gui/mainwindow.cpp
|
|||||||
gui/settingsdialog.cpp
|
gui/settingsdialog.cpp
|
||||||
gui/newinstancedialog.cpp
|
gui/newinstancedialog.cpp
|
||||||
gui/logindialog.cpp
|
gui/logindialog.cpp
|
||||||
gui/taskdialog.cpp
|
|
||||||
gui/aboutdialog.cpp
|
gui/aboutdialog.cpp
|
||||||
gui/consolewindow.cpp
|
gui/consolewindow.cpp
|
||||||
gui/instancedelegate.cpp
|
gui/instancedelegate.cpp
|
||||||
gui/versionselectdialog.cpp
|
gui/versionselectdialog.cpp
|
||||||
gui/lwjglselectdialog.cpp
|
gui/lwjglselectdialog.cpp
|
||||||
gui/instancesettings.cpp
|
gui/instancesettings.cpp
|
||||||
|
|
||||||
|
gui/ProgressDialog.cpp
|
||||||
gui/IconPickerDialog.cpp
|
gui/IconPickerDialog.cpp
|
||||||
gui/LegacyModEditDialog.cpp
|
gui/LegacyModEditDialog.cpp
|
||||||
gui/OneSixModEditDialog.cpp
|
gui/OneSixModEditDialog.cpp
|
||||||
@ -272,19 +282,26 @@ logic/LegacyForge.cpp
|
|||||||
# 1.6 instances
|
# 1.6 instances
|
||||||
logic/OneSixAssets.cpp
|
logic/OneSixAssets.cpp
|
||||||
logic/OneSixInstance.cpp
|
logic/OneSixInstance.cpp
|
||||||
logic/OneSixVersion.cpp
|
|
||||||
logic/OneSixUpdate.cpp
|
logic/OneSixUpdate.cpp
|
||||||
|
logic/OneSixVersion.cpp
|
||||||
|
logic/OneSixLibrary.cpp
|
||||||
|
logic/OneSixRule.cpp
|
||||||
logic/VersionFactory.cpp
|
logic/VersionFactory.cpp
|
||||||
|
logic/OpSys.cpp
|
||||||
|
|
||||||
# Nostalgia
|
# Nostalgia
|
||||||
logic/NostalgiaInstance.cpp
|
logic/NostalgiaInstance.cpp
|
||||||
|
|
||||||
# Lists
|
# Lists
|
||||||
logic/lists/InstanceList.cpp
|
logic/lists/InstanceList.cpp
|
||||||
logic/lists/InstVersionList.cpp
|
logic/lists/IconList.cpp
|
||||||
|
logic/lists/BaseVersionList.cpp
|
||||||
logic/lists/MinecraftVersionList.cpp
|
logic/lists/MinecraftVersionList.cpp
|
||||||
logic/lists/LwjglVersionList.cpp
|
logic/lists/LwjglVersionList.cpp
|
||||||
logic/lists/IconList.cpp
|
logic/lists/ForgeVersionList.cpp
|
||||||
|
|
||||||
|
# misc model/view
|
||||||
|
logic/EnabledItemFilter.cpp
|
||||||
|
|
||||||
# Tasks
|
# Tasks
|
||||||
logic/tasks/Task.cpp
|
logic/tasks/Task.cpp
|
||||||
@ -298,12 +315,13 @@ gui/mainwindow.ui
|
|||||||
gui/settingsdialog.ui
|
gui/settingsdialog.ui
|
||||||
gui/newinstancedialog.ui
|
gui/newinstancedialog.ui
|
||||||
gui/logindialog.ui
|
gui/logindialog.ui
|
||||||
gui/taskdialog.ui
|
|
||||||
gui/aboutdialog.ui
|
gui/aboutdialog.ui
|
||||||
gui/consolewindow.ui
|
gui/consolewindow.ui
|
||||||
gui/versionselectdialog.ui
|
gui/versionselectdialog.ui
|
||||||
gui/lwjglselectdialog.ui
|
gui/lwjglselectdialog.ui
|
||||||
gui/instancesettings.ui
|
gui/instancesettings.ui
|
||||||
|
|
||||||
|
gui/ProgressDialog.ui
|
||||||
gui/IconPickerDialog.ui
|
gui/IconPickerDialog.ui
|
||||||
gui/LegacyModEditDialog.ui
|
gui/LegacyModEditDialog.ui
|
||||||
gui/OneSixModEditDialog.ui
|
gui/OneSixModEditDialog.ui
|
||||||
|
46
MultiMC.cpp
46
MultiMC.cpp
@ -9,6 +9,10 @@
|
|||||||
#include "gui/mainwindow.h"
|
#include "gui/mainwindow.h"
|
||||||
#include "logic/lists/InstanceList.h"
|
#include "logic/lists/InstanceList.h"
|
||||||
#include "logic/lists/IconList.h"
|
#include "logic/lists/IconList.h"
|
||||||
|
#include "logic/lists/LwjglVersionList.h"
|
||||||
|
#include "logic/lists/MinecraftVersionList.h"
|
||||||
|
#include "logic/lists/ForgeVersionList.h"
|
||||||
|
|
||||||
#include "logic/InstanceLauncher.h"
|
#include "logic/InstanceLauncher.h"
|
||||||
#include "logic/net/HttpMetaCache.h"
|
#include "logic/net/HttpMetaCache.h"
|
||||||
|
|
||||||
@ -158,6 +162,21 @@ MultiMC::~MultiMC()
|
|||||||
delete m_qt_translator;
|
delete m_qt_translator;
|
||||||
m_qt_translator = nullptr;
|
m_qt_translator = nullptr;
|
||||||
}
|
}
|
||||||
|
if(m_icons)
|
||||||
|
{
|
||||||
|
delete m_icons;
|
||||||
|
m_icons = nullptr;
|
||||||
|
}
|
||||||
|
if(m_lwjgllist)
|
||||||
|
{
|
||||||
|
delete m_lwjgllist;
|
||||||
|
m_lwjgllist = nullptr;
|
||||||
|
}
|
||||||
|
if(m_minecraftlist)
|
||||||
|
{
|
||||||
|
delete m_minecraftlist;
|
||||||
|
m_minecraftlist = nullptr;
|
||||||
|
}
|
||||||
delete m_settings;
|
delete m_settings;
|
||||||
delete m_metacache;
|
delete m_metacache;
|
||||||
}
|
}
|
||||||
@ -263,6 +282,7 @@ void MultiMC::initHttpMetaCache()
|
|||||||
m_metacache->addBase("assets", QDir("assets").absolutePath());
|
m_metacache->addBase("assets", QDir("assets").absolutePath());
|
||||||
m_metacache->addBase("versions", QDir("versions").absolutePath());
|
m_metacache->addBase("versions", QDir("versions").absolutePath());
|
||||||
m_metacache->addBase("libraries", QDir("libraries").absolutePath());
|
m_metacache->addBase("libraries", QDir("libraries").absolutePath());
|
||||||
|
m_metacache->addBase("minecraftforge", QDir("mods/minecraftforge").absolutePath());
|
||||||
m_metacache->Load();
|
m_metacache->Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,6 +296,32 @@ IconList* MultiMC::icons()
|
|||||||
return m_icons;
|
return m_icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LWJGLVersionList* MultiMC::lwjgllist()
|
||||||
|
{
|
||||||
|
if ( !m_lwjgllist )
|
||||||
|
{
|
||||||
|
m_lwjgllist = new LWJGLVersionList();
|
||||||
|
}
|
||||||
|
return m_lwjgllist;
|
||||||
|
}
|
||||||
|
ForgeVersionList* MultiMC::forgelist()
|
||||||
|
{
|
||||||
|
if ( !m_forgelist )
|
||||||
|
{
|
||||||
|
m_forgelist = new ForgeVersionList();
|
||||||
|
}
|
||||||
|
return m_forgelist;
|
||||||
|
}
|
||||||
|
|
||||||
|
MinecraftVersionList* MultiMC::minecraftlist()
|
||||||
|
{
|
||||||
|
if ( !m_minecraftlist )
|
||||||
|
{
|
||||||
|
m_minecraftlist = new MinecraftVersionList();
|
||||||
|
}
|
||||||
|
return m_minecraftlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
13
MultiMC.h
13
MultiMC.h
@ -4,11 +4,14 @@
|
|||||||
#include "MultiMCVersion.h"
|
#include "MultiMCVersion.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
class MinecraftVersionList;
|
||||||
|
class LWJGLVersionList;
|
||||||
class HttpMetaCache;
|
class HttpMetaCache;
|
||||||
class SettingsObject;
|
class SettingsObject;
|
||||||
class InstanceList;
|
class InstanceList;
|
||||||
class IconList;
|
class IconList;
|
||||||
class QNetworkAccessManager;
|
class QNetworkAccessManager;
|
||||||
|
class ForgeVersionList;
|
||||||
|
|
||||||
#if defined(MMC)
|
#if defined(MMC)
|
||||||
#undef MMC
|
#undef MMC
|
||||||
@ -61,6 +64,12 @@ public:
|
|||||||
{
|
{
|
||||||
return m_metacache;
|
return m_metacache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LWJGLVersionList * lwjgllist();
|
||||||
|
|
||||||
|
ForgeVersionList * forgelist();
|
||||||
|
|
||||||
|
MinecraftVersionList * minecraftlist();
|
||||||
private:
|
private:
|
||||||
void initGlobalSettings();
|
void initGlobalSettings();
|
||||||
|
|
||||||
@ -76,5 +85,9 @@ private:
|
|||||||
QNetworkAccessManager * m_qnam = nullptr;
|
QNetworkAccessManager * m_qnam = nullptr;
|
||||||
HttpMetaCache * m_metacache = nullptr;
|
HttpMetaCache * m_metacache = nullptr;
|
||||||
Status m_status = MultiMC::Failed;
|
Status m_status = MultiMC::Failed;
|
||||||
|
LWJGLVersionList * m_lwjgllist = nullptr;
|
||||||
|
ForgeVersionList * m_forgelist = nullptr;
|
||||||
|
MinecraftVersionList * m_minecraftlist = nullptr;
|
||||||
|
|
||||||
MultiMCVersion m_version = {VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD};
|
MultiMCVersion m_version = {VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD};
|
||||||
};
|
};
|
@ -13,10 +13,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "MultiMC.h"
|
||||||
#include "LegacyModEditDialog.h"
|
#include "LegacyModEditDialog.h"
|
||||||
#include "ModEditDialogCommon.h"
|
#include "ModEditDialogCommon.h"
|
||||||
|
#include "versionselectdialog.h"
|
||||||
|
#include "ProgressDialog.h"
|
||||||
#include "ui_LegacyModEditDialog.h"
|
#include "ui_LegacyModEditDialog.h"
|
||||||
#include <logic/ModList.h>
|
#include "logic/ModList.h"
|
||||||
|
#include "logic/lists/ForgeVersionList.h"
|
||||||
|
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -194,7 +199,39 @@ void LegacyModEditDialog::on_addCoreBtn_clicked()
|
|||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_addForgeBtn_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<ForgeVersion>();
|
||||||
|
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()
|
void LegacyModEditDialog::on_addJarBtn_clicked()
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "logic/LegacyInstance.h"
|
#include "logic/LegacyInstance.h"
|
||||||
|
#include <logic/net/DownloadJob.h>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class LegacyModEditDialog;
|
class LegacyModEditDialog;
|
||||||
@ -64,4 +65,5 @@ private:
|
|||||||
QSharedPointer<ModList> m_jarmods;
|
QSharedPointer<ModList> m_jarmods;
|
||||||
QSharedPointer<ModList> m_texturepacks;
|
QSharedPointer<ModList> m_texturepacks;
|
||||||
LegacyInstance * m_inst;
|
LegacyInstance * m_inst;
|
||||||
|
DownloadJobPtr forgeJob;
|
||||||
};
|
};
|
||||||
|
@ -52,9 +52,6 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="addForgeBtn">
|
<widget class="QPushButton" name="addForgeBtn">
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>MCForge</string>
|
<string>MCForge</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -30,6 +30,7 @@ void ModListView::setModel ( QAbstractItemModel* model )
|
|||||||
auto head = header();
|
auto head = header();
|
||||||
head->setStretchLastSection(false);
|
head->setStretchLastSection(false);
|
||||||
head->setSectionResizeMode(0, QHeaderView::Stretch);
|
head->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
head->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
for(int i = 1; i < head->count(); i++)
|
||||||
|
head->setSectionResizeMode(i, QHeaderView::ResizeToContents);
|
||||||
dropIndicatorPosition();
|
dropIndicatorPosition();
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
#include "MultiMC.h"
|
||||||
#include "OneSixModEditDialog.h"
|
#include "OneSixModEditDialog.h"
|
||||||
#include "ModEditDialogCommon.h"
|
#include "ModEditDialogCommon.h"
|
||||||
#include "ui_OneSixModEditDialog.h"
|
#include "ui_OneSixModEditDialog.h"
|
||||||
#include <logic/ModList.h>
|
#include "logic/ModList.h"
|
||||||
|
#include "logic/OneSixVersion.h"
|
||||||
|
#include "logic/EnabledItemFilter.h"
|
||||||
|
#include "logic/lists/ForgeVersionList.h"
|
||||||
|
#include "gui/versionselectdialog.h"
|
||||||
|
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -29,9 +34,15 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance * inst, QWidget *parent)
|
|||||||
ui(new Ui::OneSixModEditDialog)
|
ui(new Ui::OneSixModEditDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
//TODO: libraries!
|
//libraries!
|
||||||
{
|
{
|
||||||
// yeah... here be the real dragons.
|
m_version = m_inst->getFullVersion();
|
||||||
|
|
||||||
|
auto filter = new EnabledItemFilter(this);
|
||||||
|
filter->setActive(true);
|
||||||
|
filter->setSourceModel(m_version.data());
|
||||||
|
ui->libraryTreeView->setModel(filter);
|
||||||
|
ui->libraryTreeView->installEventFilter( this );
|
||||||
}
|
}
|
||||||
// Loader mods
|
// Loader mods
|
||||||
{
|
{
|
||||||
@ -58,6 +69,17 @@ OneSixModEditDialog::~OneSixModEditDialog()
|
|||||||
delete ui;
|
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 )
|
bool OneSixModEditDialog::loaderListFilter ( QKeyEvent* keyEvent )
|
||||||
{
|
{
|
||||||
switch(keyEvent->key())
|
switch(keyEvent->key())
|
||||||
|
@ -40,12 +40,14 @@ private slots:
|
|||||||
void on_viewResPackBtn_clicked();
|
void on_viewResPackBtn_clicked();
|
||||||
// Questionable: SettingsDialog doesn't need this for some reason?
|
// Questionable: SettingsDialog doesn't need this for some reason?
|
||||||
void on_buttonBox_rejected();
|
void on_buttonBox_rejected();
|
||||||
|
void on_forgeBtn_clicked();
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *ev);
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
bool loaderListFilter( QKeyEvent* ev );
|
bool loaderListFilter( QKeyEvent* ev );
|
||||||
bool resourcePackListFilter( QKeyEvent* ev );
|
bool resourcePackListFilter( QKeyEvent* ev );
|
||||||
private:
|
private:
|
||||||
Ui::OneSixModEditDialog *ui;
|
Ui::OneSixModEditDialog *ui;
|
||||||
|
QSharedPointer<OneSixVersion> m_version;
|
||||||
QSharedPointer<ModList> m_mods;
|
QSharedPointer<ModList> m_mods;
|
||||||
QSharedPointer<ModList> m_resourcepacks;
|
QSharedPointer<ModList> m_resourcepacks;
|
||||||
OneSixInstance * m_inst;
|
OneSixInstance * m_inst;
|
||||||
|
@ -6,15 +6,15 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>543</width>
|
<width>555</width>
|
||||||
<height>423</height>
|
<height>463</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -28,19 +28,15 @@
|
|||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="elideMode">
|
|
||||||
<enum>Qt::ElideNone</enum>
|
|
||||||
</property>
|
|
||||||
<property name="tabsClosable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="libTab">
|
<widget class="QWidget" name="libTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Library</string>
|
<string>Version</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="ModListView" name="jarModsTreeView">
|
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||||
|
<item>
|
||||||
|
<widget class="ModListView" name="libraryTreeView">
|
||||||
<property name="verticalScrollBarPolicy">
|
<property name="verticalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -49,6 +45,105 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Main Class:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="mainClassEdit"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="forgeBtn">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Replace any current custom version with Minecraft Forge</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Install Forge</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="customizeBtn">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Create an customized copy of the base version</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Customize</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="revertBtn">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Revert to original base version</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Revert</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Sunken</enum>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addLibraryBtn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Add new libraries</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Add</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="removeLibraryBtn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Remove selected libraries</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Remove</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_7">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="modTab">
|
<widget class="QWidget" name="modTab">
|
||||||
@ -163,7 +258,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="0">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="autoFillBackground">
|
<property name="autoFillBackground">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
@ -13,88 +13,89 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "taskdialog.h"
|
#include "ProgressDialog.h"
|
||||||
#include "ui_taskdialog.h"
|
#include "ui_ProgressDialog.h"
|
||||||
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
#include "logic/tasks/Task.h"
|
#include "logic/tasks/Task.h"
|
||||||
|
|
||||||
TaskDialog::TaskDialog(QWidget *parent) :
|
ProgressDialog::ProgressDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::TaskDialog)
|
ui(new Ui::ProgressDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
updateSize();
|
updateSize();
|
||||||
|
|
||||||
changeProgress(0);
|
changeProgress(0,100);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskDialog::~TaskDialog()
|
ProgressDialog::~ProgressDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskDialog::updateSize()
|
void ProgressDialog::updateSize()
|
||||||
{
|
{
|
||||||
resize(QSize(480, minimumSizeHint().height()));
|
resize(QSize(480, minimumSizeHint().height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskDialog::exec(Task *task)
|
int ProgressDialog::exec(ProgressProvider *task)
|
||||||
{
|
{
|
||||||
this->task = task;
|
this->task = task;
|
||||||
|
|
||||||
// Connect signals.
|
// Connect signals.
|
||||||
connect(task, SIGNAL(started()), SLOT(onTaskStarted()));
|
connect(task, SIGNAL(started()), SLOT(onTaskStarted()));
|
||||||
connect(task, SIGNAL(failed(QString)), SLOT(onTaskEnded()));
|
connect(task, SIGNAL(failed(QString)), SLOT(onTaskFailed(QString)));
|
||||||
connect(task, SIGNAL(succeeded()), SLOT(onTaskEnded()));
|
connect(task, SIGNAL(succeeded()), SLOT(onTaskSucceeded()));
|
||||||
connect(task, SIGNAL(statusChanged(const QString&)), SLOT(changeStatus(const QString&)));
|
connect(task, SIGNAL(status(QString)), SLOT(changeStatus(const QString&)));
|
||||||
connect(task, SIGNAL(progressChanged(int)), SLOT(changeProgress(int)));
|
connect(task, SIGNAL(progress(qint64,qint64)), SLOT(changeProgress(qint64,qint64)));
|
||||||
|
|
||||||
// this makes sure that the task is started after the dialog is created
|
// this makes sure that the task is started after the dialog is created
|
||||||
QMetaObject::invokeMethod(task, "startTask", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(task, "start", Qt::QueuedConnection);
|
||||||
QDialog::exec();
|
return QDialog::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
Task* TaskDialog::getTask()
|
ProgressProvider* ProgressDialog::getTask()
|
||||||
{
|
{
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskDialog::onTaskStarted()
|
void ProgressDialog::onTaskStarted()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskDialog::onTaskEnded()
|
void ProgressDialog::onTaskFailed(QString failure)
|
||||||
{
|
{
|
||||||
close();
|
reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskDialog::changeStatus(const QString &status)
|
void ProgressDialog::onTaskSucceeded()
|
||||||
|
{
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgressDialog::changeStatus(const QString &status)
|
||||||
{
|
{
|
||||||
ui->statusLabel->setText(status);
|
ui->statusLabel->setText(status);
|
||||||
updateSize();
|
updateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskDialog::changeProgress(int progress)
|
void ProgressDialog::changeProgress(qint64 current, qint64 total)
|
||||||
{
|
{
|
||||||
if (progress < 0)
|
ui->taskProgressBar->setMaximum(total);
|
||||||
progress = 0;
|
ui->taskProgressBar->setValue(current);
|
||||||
else if (progress > 100)
|
|
||||||
progress = 100;
|
|
||||||
|
|
||||||
ui->taskProgressBar->setValue(progress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskDialog::keyPressEvent(QKeyEvent* e)
|
void ProgressDialog::keyPressEvent(QKeyEvent* e)
|
||||||
{
|
{
|
||||||
if (e->key() == Qt::Key_Escape)
|
if (e->key() == Qt::Key_Escape)
|
||||||
return;
|
return;
|
||||||
QDialog::keyPressEvent(e);
|
QDialog::keyPressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskDialog::closeEvent(QCloseEvent* e)
|
void ProgressDialog::closeEvent(QCloseEvent* e)
|
||||||
{
|
{
|
||||||
if (task && task->isRunning())
|
if (task && task->isRunning())
|
||||||
{
|
{
|
@ -18,32 +18,33 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
class Task;
|
class ProgressProvider;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class TaskDialog;
|
class ProgressDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TaskDialog : public QDialog
|
class ProgressDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TaskDialog(QWidget *parent = 0);
|
explicit ProgressDialog(QWidget *parent = 0);
|
||||||
~TaskDialog();
|
~ProgressDialog();
|
||||||
|
|
||||||
void updateSize();
|
void updateSize();
|
||||||
|
|
||||||
void exec(Task* task);
|
int exec(ProgressProvider* task);
|
||||||
|
|
||||||
Task* getTask();
|
ProgressProvider* getTask();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onTaskStarted();
|
void onTaskStarted();
|
||||||
void onTaskEnded();
|
void onTaskFailed(QString failure);
|
||||||
|
void onTaskSucceeded();
|
||||||
|
|
||||||
void changeStatus(const QString& status);
|
void changeStatus(const QString& status);
|
||||||
void changeProgress(int progress);
|
void changeProgress(qint64 current, qint64 total);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
@ -53,9 +54,9 @@ protected:
|
|||||||
virtual void closeEvent(QCloseEvent* e);
|
virtual void closeEvent(QCloseEvent* e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::TaskDialog *ui;
|
Ui::ProgressDialog *ui;
|
||||||
|
|
||||||
Task* task;
|
ProgressProvider* task;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TASKDIALOG_H
|
#endif // TASKDIALOG_H
|
@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>TaskDialog</class>
|
<class>ProgressDialog</class>
|
||||||
<widget class="QDialog" name="TaskDialog">
|
<widget class="QDialog" name="ProgressDialog">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>58</height>
|
<height>68</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
@ -13,6 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "MultiMC.h"
|
||||||
#include "lwjglselectdialog.h"
|
#include "lwjglselectdialog.h"
|
||||||
#include "ui_lwjglselectdialog.h"
|
#include "ui_lwjglselectdialog.h"
|
||||||
|
|
||||||
@ -24,11 +25,12 @@ LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->labelStatus->setVisible(false);
|
ui->labelStatus->setVisible(false);
|
||||||
ui->lwjglListView->setModel(&LWJGLVersionList::get());
|
auto lwjgllist = MMC->lwjgllist();
|
||||||
|
ui->lwjglListView->setModel(lwjgllist);
|
||||||
|
|
||||||
connect(&LWJGLVersionList::get(), SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool)));
|
connect(lwjgllist, SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool)));
|
||||||
connect(&LWJGLVersionList::get(), SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString)));
|
connect(lwjgllist, SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString)));
|
||||||
loadingStateUpdated(LWJGLVersionList::get().isLoading());
|
loadingStateUpdated(lwjgllist->isLoading());
|
||||||
}
|
}
|
||||||
|
|
||||||
LWJGLSelectDialog::~LWJGLSelectDialog()
|
LWJGLSelectDialog::~LWJGLSelectDialog()
|
||||||
@ -38,15 +40,15 @@ LWJGLSelectDialog::~LWJGLSelectDialog()
|
|||||||
|
|
||||||
QString LWJGLSelectDialog::selectedVersion() const
|
QString LWJGLSelectDialog::selectedVersion() const
|
||||||
{
|
{
|
||||||
return LWJGLVersionList::get().data(
|
return MMC->lwjgllist()->data(
|
||||||
ui->lwjglListView->selectionModel()->currentIndex(),
|
ui->lwjglListView->selectionModel()->currentIndex(),
|
||||||
Qt::DisplayRole).toString();
|
Qt::DisplayRole).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LWJGLSelectDialog::on_refreshButton_clicked()
|
void LWJGLSelectDialog::on_refreshButton_clicked()
|
||||||
{
|
{
|
||||||
if (!LWJGLVersionList::get().isLoading())
|
if (!MMC->lwjgllist()->isLoading())
|
||||||
LWJGLVersionList::get().loadList();
|
MMC->lwjgllist()->loadList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LWJGLSelectDialog::loadingStateUpdated(bool loading)
|
void LWJGLSelectDialog::loadingStateUpdated(bool loading)
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#include "gui/settingsdialog.h"
|
#include "gui/settingsdialog.h"
|
||||||
#include "gui/newinstancedialog.h"
|
#include "gui/newinstancedialog.h"
|
||||||
#include "gui/logindialog.h"
|
#include "gui/logindialog.h"
|
||||||
#include "gui/taskdialog.h"
|
#include "gui/ProgressDialog.h"
|
||||||
#include "gui/aboutdialog.h"
|
#include "gui/aboutdialog.h"
|
||||||
#include "gui/versionselectdialog.h"
|
#include "gui/versionselectdialog.h"
|
||||||
#include "gui/lwjglselectdialog.h"
|
#include "gui/lwjglselectdialog.h"
|
||||||
@ -154,14 +154,14 @@ MainWindow::MainWindow ( QWidget *parent )
|
|||||||
// run the things that load and download other things... FIXME: this is NOT the place
|
// run the things that load and download other things... FIXME: this is NOT the place
|
||||||
// FIXME: invisible actions in the background = NOPE.
|
// FIXME: invisible actions in the background = NOPE.
|
||||||
{
|
{
|
||||||
if (!MinecraftVersionList::getMainList().isLoaded())
|
if (!MMC->minecraftlist()->isLoaded())
|
||||||
{
|
{
|
||||||
m_versionLoadTask = MinecraftVersionList::getMainList().getLoadTask();
|
m_versionLoadTask = MMC->minecraftlist()->getLoadTask();
|
||||||
startTask(m_versionLoadTask);
|
startTask(m_versionLoadTask);
|
||||||
}
|
}
|
||||||
if (!LWJGLVersionList::get().isLoaded())
|
if (!MMC->lwjgllist()->isLoaded())
|
||||||
{
|
{
|
||||||
LWJGLVersionList::get().loadList();
|
MMC->lwjgllist()->loadList();
|
||||||
}
|
}
|
||||||
assets_downloader = new OneSixAssets();
|
assets_downloader = new OneSixAssets();
|
||||||
assets_downloader->start();
|
assets_downloader->start();
|
||||||
@ -245,7 +245,7 @@ void MainWindow::instanceActivated ( QModelIndex index )
|
|||||||
|
|
||||||
void MainWindow::on_actionAddInstance_triggered()
|
void MainWindow::on_actionAddInstance_triggered()
|
||||||
{
|
{
|
||||||
if (!MinecraftVersionList::getMainList().isLoaded() &&
|
if (!MMC->minecraftlist()->isLoaded() &&
|
||||||
m_versionLoadTask && m_versionLoadTask->isRunning())
|
m_versionLoadTask && m_versionLoadTask->isRunning())
|
||||||
{
|
{
|
||||||
QEventLoop waitLoop;
|
QEventLoop waitLoop;
|
||||||
@ -479,7 +479,7 @@ void MainWindow::doLogin(const QString& errorMsg)
|
|||||||
{
|
{
|
||||||
UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
|
UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
|
||||||
|
|
||||||
TaskDialog* tDialog = new TaskDialog(this);
|
ProgressDialog* tDialog = new ProgressDialog(this);
|
||||||
LoginTask* loginTask = new LoginTask(uInfo, tDialog);
|
LoginTask* loginTask = new LoginTask(uInfo, tDialog);
|
||||||
connect(loginTask, SIGNAL(succeeded()),SLOT(onLoginComplete()), Qt::QueuedConnection);
|
connect(loginTask, SIGNAL(succeeded()),SLOT(onLoginComplete()), Qt::QueuedConnection);
|
||||||
connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)), Qt::QueuedConnection);
|
connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)), Qt::QueuedConnection);
|
||||||
@ -512,7 +512,7 @@ void MainWindow::onLoginComplete()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TaskDialog *tDialog = new TaskDialog(this);
|
ProgressDialog *tDialog = new ProgressDialog(this);
|
||||||
connect(updateTask, SIGNAL(succeeded()),SLOT(onGameUpdateComplete()));
|
connect(updateTask, SIGNAL(succeeded()),SLOT(onGameUpdateComplete()));
|
||||||
connect(updateTask, SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString)));
|
connect(updateTask, SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString)));
|
||||||
tDialog->exec(updateTask);
|
tDialog->exec(updateTask);
|
||||||
@ -575,7 +575,7 @@ void MainWindow::startTask(Task *task)
|
|||||||
connect(task, SIGNAL(started()), SLOT(taskStart()));
|
connect(task, SIGNAL(started()), SLOT(taskStart()));
|
||||||
connect(task, SIGNAL(succeeded()), SLOT(taskEnd()));
|
connect(task, SIGNAL(succeeded()), SLOT(taskEnd()));
|
||||||
connect(task, SIGNAL(failed(QString)), SLOT(taskEnd()));
|
connect(task, SIGNAL(failed(QString)), SLOT(taskEnd()));
|
||||||
task->startTask();
|
task->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -604,7 +604,7 @@ void MainWindow::on_actionChangeInstMCVersion_triggered()
|
|||||||
VersionSelectDialog vselect(m_selectedInstance->versionList(), this);
|
VersionSelectDialog vselect(m_selectedInstance->versionList(), this);
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
if (vselect.exec() && vselect.selectedVersion())
|
||||||
{
|
{
|
||||||
m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor);
|
m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,13 +18,13 @@
|
|||||||
#include "ui_newinstancedialog.h"
|
#include "ui_newinstancedialog.h"
|
||||||
|
|
||||||
#include "logic/InstanceFactory.h"
|
#include "logic/InstanceFactory.h"
|
||||||
#include "logic/InstanceVersion.h"
|
#include "logic/BaseVersion.h"
|
||||||
#include "logic/lists/IconList.h"
|
#include "logic/lists/IconList.h"
|
||||||
#include "logic/lists/MinecraftVersionList.h"
|
#include "logic/lists/MinecraftVersionList.h"
|
||||||
#include "logic/tasks/Task.h"
|
#include "logic/tasks/Task.h"
|
||||||
|
|
||||||
#include "versionselectdialog.h"
|
#include "versionselectdialog.h"
|
||||||
#include "taskdialog.h"
|
#include "ProgressDialog.h"
|
||||||
#include "IconPickerDialog.h"
|
#include "IconPickerDialog.h"
|
||||||
|
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
@ -48,7 +48,7 @@ NewInstanceDialog::NewInstanceDialog(QWidget *parent) :
|
|||||||
taskDlg->exec(loadTask);
|
taskDlg->exec(loadTask);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
setSelectedVersion(MinecraftVersionList::getMainList().getLatestStable());
|
setSelectedVersion(MMC->minecraftlist()->getLatestStable());
|
||||||
InstIconKey = "infinity";
|
InstIconKey = "infinity";
|
||||||
ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey));
|
ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey));
|
||||||
}
|
}
|
||||||
@ -63,13 +63,13 @@ void NewInstanceDialog::updateDialogState()
|
|||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!instName().isEmpty() && m_selectedVersion);
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!instName().isEmpty() && m_selectedVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewInstanceDialog::setSelectedVersion(InstVersionPtr version)
|
void NewInstanceDialog::setSelectedVersion(BaseVersionPtr version)
|
||||||
{
|
{
|
||||||
m_selectedVersion = version;
|
m_selectedVersion = version;
|
||||||
|
|
||||||
if (m_selectedVersion)
|
if (m_selectedVersion)
|
||||||
{
|
{
|
||||||
ui->versionTextBox->setText(version->name);
|
ui->versionTextBox->setText(version->name());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -89,18 +89,18 @@ QString NewInstanceDialog::iconKey() const
|
|||||||
return InstIconKey;
|
return InstIconKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstVersionPtr NewInstanceDialog::selectedVersion() const
|
BaseVersionPtr NewInstanceDialog::selectedVersion() const
|
||||||
{
|
{
|
||||||
return m_selectedVersion;
|
return m_selectedVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewInstanceDialog::on_btnChangeVersion_clicked()
|
void NewInstanceDialog::on_btnChangeVersion_clicked()
|
||||||
{
|
{
|
||||||
VersionSelectDialog vselect(&MinecraftVersionList::getMainList(), this);
|
VersionSelectDialog vselect(MMC->minecraftlist(), this);
|
||||||
vselect.exec();
|
vselect.exec();
|
||||||
if (vselect.result() == QDialog::Accepted)
|
if (vselect.result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
InstVersionPtr version = vselect.selectedVersion();
|
BaseVersionPtr version = vselect.selectedVersion();
|
||||||
if (version)
|
if (version)
|
||||||
setSelectedVersion(version);
|
setSelectedVersion(version);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#define NEWINSTANCEDIALOG_H
|
#define NEWINSTANCEDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "logic/InstanceVersion.h"
|
#include "logic/BaseVersion.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class NewInstanceDialog;
|
class NewInstanceDialog;
|
||||||
@ -33,13 +33,13 @@ public:
|
|||||||
|
|
||||||
void updateDialogState();
|
void updateDialogState();
|
||||||
|
|
||||||
void setSelectedVersion(InstVersionPtr version);
|
void setSelectedVersion(BaseVersionPtr version);
|
||||||
|
|
||||||
void loadVersionList();
|
void loadVersionList();
|
||||||
|
|
||||||
QString instName() const;
|
QString instName() const;
|
||||||
QString iconKey() const;
|
QString iconKey() const;
|
||||||
InstVersionPtr selectedVersion() const;
|
BaseVersionPtr selectedVersion() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_btnChangeVersion_clicked();
|
void on_btnChangeVersion_clicked();
|
||||||
@ -49,7 +49,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
Ui::NewInstanceDialog *ui;
|
Ui::NewInstanceDialog *ui;
|
||||||
|
|
||||||
InstVersionPtr m_selectedVersion;
|
BaseVersionPtr m_selectedVersion;
|
||||||
QString InstIconKey;
|
QString InstIconKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <gui/taskdialog.h>
|
#include <gui/ProgressDialog.h>
|
||||||
|
|
||||||
#include <logic/InstanceVersion.h>
|
#include <logic/BaseVersion.h>
|
||||||
#include <logic/lists/InstVersionList.h>
|
#include <logic/lists/BaseVersionList.h>
|
||||||
#include <logic/tasks/Task.h>
|
#include <logic/tasks/Task.h>
|
||||||
|
|
||||||
VersionSelectDialog::VersionSelectDialog(InstVersionList *vlist, QWidget *parent) :
|
VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::VersionSelectDialog)
|
ui(new Ui::VersionSelectDialog)
|
||||||
{
|
{
|
||||||
@ -41,11 +41,6 @@ VersionSelectDialog::VersionSelectDialog(InstVersionList *vlist, QWidget *parent
|
|||||||
ui->listView->setModel(m_proxyModel);
|
ui->listView->setModel(m_proxyModel);
|
||||||
ui->listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
ui->listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
ui->listView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
ui->listView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
|
|
||||||
connect(ui->filterSnapshotsCheckbox, SIGNAL(clicked()), SLOT(updateFilterState()));
|
|
||||||
connect(ui->filterMCNostalgiaCheckbox, SIGNAL(clicked()), SLOT(updateFilterState()));
|
|
||||||
|
|
||||||
updateFilterState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VersionSelectDialog::~VersionSelectDialog()
|
VersionSelectDialog::~VersionSelectDialog()
|
||||||
@ -63,17 +58,17 @@ int VersionSelectDialog::exec()
|
|||||||
|
|
||||||
void VersionSelectDialog::loadList()
|
void VersionSelectDialog::loadList()
|
||||||
{
|
{
|
||||||
TaskDialog *taskDlg = new TaskDialog(this);
|
ProgressDialog *taskDlg = new ProgressDialog(this);
|
||||||
Task *loadTask = m_vlist->getLoadTask();
|
Task *loadTask = m_vlist->getLoadTask();
|
||||||
loadTask->setParent(taskDlg);
|
loadTask->setParent(taskDlg);
|
||||||
taskDlg->exec(loadTask);
|
taskDlg->exec(loadTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
InstVersionPtr VersionSelectDialog::selectedVersion() const
|
BaseVersionPtr VersionSelectDialog::selectedVersion() const
|
||||||
{
|
{
|
||||||
auto currentIndex = ui->listView->selectionModel()->currentIndex();
|
auto currentIndex = ui->listView->selectionModel()->currentIndex();
|
||||||
auto variant = m_proxyModel->data(currentIndex, InstVersionList::VersionPointerRole);
|
auto variant = m_proxyModel->data(currentIndex, BaseVersionList::VersionPointerRole);
|
||||||
return variant.value<InstVersionPtr>();
|
return variant.value<BaseVersionPtr>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VersionSelectDialog::on_refreshButton_clicked()
|
void VersionSelectDialog::on_refreshButton_clicked()
|
||||||
@ -81,10 +76,11 @@ void VersionSelectDialog::on_refreshButton_clicked()
|
|||||||
loadList();
|
loadList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VersionSelectDialog::updateFilterState()
|
void VersionSelectDialog::setFilter(int column, QString filter)
|
||||||
{
|
{
|
||||||
m_proxyModel->setFilterKeyColumn(InstVersionList::TypeColumn);
|
m_proxyModel->setFilterKeyColumn(column);
|
||||||
|
m_proxyModel->setFilterFixedString(filter);
|
||||||
|
/*
|
||||||
QStringList filteredTypes;
|
QStringList filteredTypes;
|
||||||
if (!ui->filterSnapshotsCheckbox->isChecked())
|
if (!ui->filterSnapshotsCheckbox->isChecked())
|
||||||
filteredTypes += "Snapshot";
|
filteredTypes += "Snapshot";
|
||||||
@ -96,6 +92,5 @@ void VersionSelectDialog::updateFilterState()
|
|||||||
regexStr = QString("^((?!%1).)*$").arg(filteredTypes.join('|'));
|
regexStr = QString("^((?!%1).)*$").arg(filteredTypes.join('|'));
|
||||||
|
|
||||||
qDebug() << "Filter:" << regexStr;
|
qDebug() << "Filter:" << regexStr;
|
||||||
|
*/
|
||||||
m_proxyModel->setFilterRegExp(regexStr);
|
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include "logic/InstanceVersion.h"
|
#include "logic/BaseVersion.h"
|
||||||
|
|
||||||
class InstVersionList;
|
class BaseVersionList;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -33,7 +33,7 @@ class VersionSelectDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VersionSelectDialog(InstVersionList *vlist, QWidget *parent = 0);
|
explicit VersionSelectDialog(BaseVersionList *vlist, QWidget *parent = 0);
|
||||||
~VersionSelectDialog();
|
~VersionSelectDialog();
|
||||||
|
|
||||||
virtual int exec();
|
virtual int exec();
|
||||||
@ -41,17 +41,16 @@ public:
|
|||||||
//! Starts a task that loads the list.
|
//! Starts a task that loads the list.
|
||||||
void loadList();
|
void loadList();
|
||||||
|
|
||||||
InstVersionPtr selectedVersion() const;
|
BaseVersionPtr selectedVersion() const;
|
||||||
|
|
||||||
|
void setFilter(int column, QString filter);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_refreshButton_clicked();
|
void on_refreshButton_clicked();
|
||||||
|
|
||||||
void updateFilterState();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::VersionSelectDialog *ui;
|
Ui::VersionSelectDialog *ui;
|
||||||
|
|
||||||
InstVersionList *m_vlist;
|
BaseVersionList *m_vlist;
|
||||||
|
|
||||||
QSortFilterProxyModel *m_proxyModel;
|
QSortFilterProxyModel *m_proxyModel;
|
||||||
};
|
};
|
||||||
|
@ -39,75 +39,6 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="filterCheckboxLayout1">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="filterSnapshotsCheckbox">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Show &snapshots?</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="filterMCNostalgiaCheckbox">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Show &Nostalgia?</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "MultiMC.h"
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "BaseInstance_p.h"
|
#include "BaseInstance_p.h"
|
||||||
|
|
||||||
@ -131,9 +132,9 @@ InstanceList *BaseInstance::instList() const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstVersionList *BaseInstance::versionList() const
|
BaseVersionList *BaseInstance::versionList() const
|
||||||
{
|
{
|
||||||
return &MinecraftVersionList::getMainList();
|
return MMC->minecraftlist();
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsObject &BaseInstance::settings() const
|
SettingsObject &BaseInstance::settings() const
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <settingsobject.h>
|
#include <settingsobject.h>
|
||||||
|
|
||||||
#include "inifile.h"
|
#include "inifile.h"
|
||||||
#include "lists/InstVersionList.h"
|
#include "lists/BaseVersionList.h"
|
||||||
|
|
||||||
class QDialog;
|
class QDialog;
|
||||||
class BaseUpdate;
|
class BaseUpdate;
|
||||||
@ -134,7 +134,7 @@ public:
|
|||||||
* \brief Gets a pointer to this instance's version list.
|
* \brief Gets a pointer to this instance's version list.
|
||||||
* \return A pointer to the available version list for this instance.
|
* \return A pointer to the available version list for this instance.
|
||||||
*/
|
*/
|
||||||
virtual InstVersionList *versionList() const;
|
virtual BaseVersionList *versionList() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets this instance's settings object.
|
* \brief Gets this instance's settings object.
|
||||||
|
@ -7,7 +7,5 @@ BaseUpdate::BaseUpdate ( BaseInstance* inst, QObject* parent ) : Task ( parent )
|
|||||||
|
|
||||||
void BaseUpdate::updateDownloadProgress(qint64 current, qint64 total)
|
void BaseUpdate::updateDownloadProgress(qint64 current, qint64 total)
|
||||||
{
|
{
|
||||||
// The progress on the current file is current / total
|
emit progress(current, total);
|
||||||
float currentDLProgress = (float) current / (float) total;
|
|
||||||
setProgress((int)(currentDLProgress * 100)); // convert to percentage
|
|
||||||
}
|
}
|
@ -19,50 +19,27 @@
|
|||||||
/*!
|
/*!
|
||||||
* An abstract base class for versions.
|
* An abstract base class for versions.
|
||||||
*/
|
*/
|
||||||
struct InstVersion
|
struct BaseVersion
|
||||||
{
|
{
|
||||||
/*!
|
|
||||||
* Checks if this version is less (older) than the given version.
|
|
||||||
* \param other The version to compare this one to.
|
|
||||||
* \return True if this version is older than the given version.
|
|
||||||
*/
|
|
||||||
virtual bool operator<(const InstVersion &rhs) const
|
|
||||||
{
|
|
||||||
return timestamp < rhs.timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Checks if this version is greater (newer) than the given version.
|
|
||||||
* \param other The version to compare this one to.
|
|
||||||
* \return True if this version is newer than the given version.
|
|
||||||
*/
|
|
||||||
virtual bool operator>( const InstVersion& rhs ) const
|
|
||||||
{
|
|
||||||
return timestamp > rhs.timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* A string used to identify this version in config files.
|
* A string used to identify this version in config files.
|
||||||
* This should be unique within the version list or shenanigans will occur.
|
* This should be unique within the version list or shenanigans will occur.
|
||||||
*/
|
*/
|
||||||
QString descriptor;
|
virtual QString descriptor() = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* The name of this version as it is displayed to the user.
|
* The name of this version as it is displayed to the user.
|
||||||
* For example: "1.5.1"
|
* For example: "1.5.1"
|
||||||
*/
|
*/
|
||||||
QString name;
|
virtual QString name() = 0;
|
||||||
/*!
|
|
||||||
* Gets the version's timestamp.
|
|
||||||
* This is primarily used for sorting versions in a list.
|
|
||||||
*/
|
|
||||||
qint64 timestamp;
|
|
||||||
|
|
||||||
virtual QString typeString() const
|
/*!
|
||||||
{
|
* This should return a string that describes
|
||||||
return "InstVersion";
|
* the kind of version this is (Stable, Beta, Snapshot, whatever)
|
||||||
}
|
*/
|
||||||
|
virtual QString typeString() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<InstVersion> InstVersionPtr;
|
typedef QSharedPointer<BaseVersion> BaseVersionPtr;
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( InstVersionPtr )
|
Q_DECLARE_METATYPE( BaseVersionPtr )
|
30
logic/EnabledItemFilter.cpp
Normal file
30
logic/EnabledItemFilter.cpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#include "EnabledItemFilter.h"
|
||||||
|
|
||||||
|
EnabledItemFilter::EnabledItemFilter(QObject* parent)
|
||||||
|
:QSortFilterProxyModel(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnabledItemFilter::setActive(bool active)
|
||||||
|
{
|
||||||
|
m_active = active;
|
||||||
|
invalidateFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EnabledItemFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||||
|
{
|
||||||
|
if(!m_active)
|
||||||
|
return true;
|
||||||
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
|
if(sourceModel()->flags(index) & Qt::ItemIsEnabled)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EnabledItemFilter::lessThan(const QModelIndex& left, const QModelIndex& right) const
|
||||||
|
{
|
||||||
|
return QSortFilterProxyModel::lessThan(left, right);
|
||||||
|
}
|
16
logic/EnabledItemFilter.h
Normal file
16
logic/EnabledItemFilter.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
class EnabledItemFilter : public QSortFilterProxyModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
EnabledItemFilter(QObject *parent = 0);
|
||||||
|
void setActive(bool active);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||||
|
private:
|
||||||
|
bool m_active = false;
|
||||||
|
};
|
@ -22,7 +22,7 @@
|
|||||||
#include "LegacyInstance.h"
|
#include "LegacyInstance.h"
|
||||||
#include "OneSixInstance.h"
|
#include "OneSixInstance.h"
|
||||||
#include "NostalgiaInstance.h"
|
#include "NostalgiaInstance.h"
|
||||||
#include "InstanceVersion.h"
|
#include "BaseVersion.h"
|
||||||
#include "MinecraftVersion.h"
|
#include "MinecraftVersion.h"
|
||||||
|
|
||||||
#include "inifile.h"
|
#include "inifile.h"
|
||||||
@ -68,7 +68,7 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InstanceFactory::InstCreateError InstanceFactory::createInstance( BaseInstance*& inst, InstVersionPtr version, const QString& instDir )
|
InstanceFactory::InstCreateError InstanceFactory::createInstance( BaseInstance*& inst, BaseVersionPtr version, const QString& instDir )
|
||||||
{
|
{
|
||||||
QDir rootDir(instDir);
|
QDir rootDir(instDir);
|
||||||
|
|
||||||
@ -89,19 +89,19 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance( BaseInstance*&
|
|||||||
case MinecraftVersion::Legacy:
|
case MinecraftVersion::Legacy:
|
||||||
m_settings->set("InstanceType", "Legacy");
|
m_settings->set("InstanceType", "Legacy");
|
||||||
inst = new LegacyInstance(instDir, m_settings, this);
|
inst = new LegacyInstance(instDir, m_settings, this);
|
||||||
inst->setIntendedVersionId(version->descriptor);
|
inst->setIntendedVersionId(version->descriptor());
|
||||||
inst->setShouldUseCustomBaseJar(false);
|
inst->setShouldUseCustomBaseJar(false);
|
||||||
break;
|
break;
|
||||||
case MinecraftVersion::OneSix:
|
case MinecraftVersion::OneSix:
|
||||||
m_settings->set("InstanceType", "OneSix");
|
m_settings->set("InstanceType", "OneSix");
|
||||||
inst = new OneSixInstance(instDir, m_settings, this);
|
inst = new OneSixInstance(instDir, m_settings, this);
|
||||||
inst->setIntendedVersionId(version->descriptor);
|
inst->setIntendedVersionId(version->descriptor());
|
||||||
inst->setShouldUseCustomBaseJar(false);
|
inst->setShouldUseCustomBaseJar(false);
|
||||||
break;
|
break;
|
||||||
case MinecraftVersion::Nostalgia:
|
case MinecraftVersion::Nostalgia:
|
||||||
m_settings->set("InstanceType", "Nostalgia");
|
m_settings->set("InstanceType", "Nostalgia");
|
||||||
inst = new NostalgiaInstance(instDir, m_settings, this);
|
inst = new NostalgiaInstance(instDir, m_settings, this);
|
||||||
inst->setIntendedVersionId(version->descriptor);
|
inst->setIntendedVersionId(version->descriptor());
|
||||||
inst->setShouldUseCustomBaseJar(false);
|
inst->setShouldUseCustomBaseJar(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
#include "InstanceVersion.h"
|
#include "BaseVersion.h"
|
||||||
|
|
||||||
class InstVersion;
|
class BaseVersion;
|
||||||
class BaseInstance;
|
class BaseInstance;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -61,7 +61,7 @@ public:
|
|||||||
* - InstExists if the given instance directory is already an instance.
|
* - InstExists if the given instance directory is already an instance.
|
||||||
* - CantCreateDir if the given instance directory cannot be created.
|
* - CantCreateDir if the given instance directory cannot be created.
|
||||||
*/
|
*/
|
||||||
InstCreateError createInstance(BaseInstance *&inst, InstVersionPtr version, const QString &instDir);
|
InstCreateError createInstance(BaseInstance *&inst, BaseVersionPtr version, const QString &instDir);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Loads an instance from the given directory.
|
* \brief Loads an instance from the given directory.
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "gui/logindialog.h"
|
#include "gui/logindialog.h"
|
||||||
#include "gui/taskdialog.h"
|
#include "gui/ProgressDialog.h"
|
||||||
#include "gui/consolewindow.h"
|
#include "gui/consolewindow.h"
|
||||||
#include "logic/tasks/LoginTask.h"
|
#include "logic/tasks/LoginTask.h"
|
||||||
#include "logic/MinecraftProcess.h"
|
#include "logic/MinecraftProcess.h"
|
||||||
@ -48,7 +48,7 @@ void InstanceLauncher::doLogin ( const QString& errorMsg )
|
|||||||
{
|
{
|
||||||
UserInfo uInfo {loginDlg->getUsername(), loginDlg->getPassword() };
|
UserInfo uInfo {loginDlg->getUsername(), loginDlg->getPassword() };
|
||||||
|
|
||||||
TaskDialog* tDialog = new TaskDialog ( nullptr );
|
ProgressDialog* tDialog = new ProgressDialog ( nullptr );
|
||||||
LoginTask* loginTask = new LoginTask ( uInfo, tDialog );
|
LoginTask* loginTask = new LoginTask ( uInfo, tDialog );
|
||||||
connect ( loginTask, SIGNAL ( succeeded() ),SLOT ( onLoginComplete() ), Qt::QueuedConnection );
|
connect ( loginTask, SIGNAL ( succeeded() ),SLOT ( onLoginComplete() ), Qt::QueuedConnection );
|
||||||
connect ( loginTask, SIGNAL ( failed ( QString ) ),SLOT ( doLogin ( QString ) ), Qt::QueuedConnection );
|
connect ( loginTask, SIGNAL ( failed ( QString ) ),SLOT ( doLogin ( QString ) ), Qt::QueuedConnection );
|
||||||
|
@ -34,15 +34,15 @@ void LegacyUpdate::lwjglStart()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &list = LWJGLVersionList::get();
|
auto list = MMC->lwjgllist();
|
||||||
if(!list.isLoaded())
|
if(!list->isLoaded())
|
||||||
{
|
{
|
||||||
emitFailed("Too soon! Let the LWJGL list load :)");
|
emitFailed("Too soon! Let the LWJGL list load :)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus("Downloading new LWJGL.");
|
setStatus("Downloading new LWJGL.");
|
||||||
auto version = list.getVersion(lwjglVersion);
|
auto version = list->getVersion(lwjglVersion);
|
||||||
if(!version)
|
if(!version)
|
||||||
{
|
{
|
||||||
emitFailed("Game update failed: the selected LWJGL version is invalid.");
|
emitFailed("Game update failed: the selected LWJGL version is invalid.");
|
||||||
@ -59,7 +59,7 @@ void LegacyUpdate::lwjglStart()
|
|||||||
QNetworkReply * rep = worker->get ( req );
|
QNetworkReply * rep = worker->get ( req );
|
||||||
|
|
||||||
m_reply = QSharedPointer<QNetworkReply> (rep, &QObject::deleteLater);
|
m_reply = QSharedPointer<QNetworkReply> (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(worker, SIGNAL(finished(QNetworkReply*)), SLOT(lwjglFinished(QNetworkReply*)));
|
||||||
//connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(downloadError(QNetworkReply::NetworkError)));
|
//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.setRawHeader("Host", hostname.toLatin1());
|
||||||
req.setHeader(QNetworkRequest::UserAgentHeader, "Wget/1.14 (linux-gnu)");
|
req.setHeader(QNetworkRequest::UserAgentHeader, "Wget/1.14 (linux-gnu)");
|
||||||
QNetworkReply * rep = worker->get(req);
|
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<QNetworkReply> (rep, &QObject::deleteLater);
|
m_reply = QSharedPointer<QNetworkReply> (rep, &QObject::deleteLater);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ void LegacyUpdate::extractLwjgl()
|
|||||||
if (name.contains(nativesDir))
|
if (name.contains(nativesDir))
|
||||||
{
|
{
|
||||||
int lastSlash = name.lastIndexOf('/');
|
int lastSlash = name.lastIndexOf('/');
|
||||||
int lastBackSlash = name.lastIndexOf('/');
|
int lastBackSlash = name.lastIndexOf('\\');
|
||||||
if(lastSlash != -1)
|
if(lastSlash != -1)
|
||||||
name = name.mid(lastSlash+1);
|
name = name.mid(lastSlash+1);
|
||||||
else if(lastBackSlash != -1)
|
else if(lastBackSlash != -1)
|
||||||
@ -232,7 +232,7 @@ void LegacyUpdate::jarStart()
|
|||||||
legacyDownloadJob.reset(dljob);
|
legacyDownloadJob.reset(dljob);
|
||||||
connect(dljob, SIGNAL(succeeded()), SLOT(jarFinished()));
|
connect(dljob, SIGNAL(succeeded()), SLOT(jarFinished()));
|
||||||
connect(dljob, SIGNAL(failed()), SLOT(jarFailed()));
|
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();
|
legacyDownloadJob->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,17 +15,16 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "InstanceVersion.h"
|
#include "BaseVersion.h"
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
struct MinecraftVersion : public InstVersion
|
struct MinecraftVersion : public BaseVersion
|
||||||
{
|
{
|
||||||
// From InstVersion:
|
/*!
|
||||||
/*
|
* Gets the version's timestamp.
|
||||||
QString m_descriptor;
|
* This is primarily used for sorting versions in a list.
|
||||||
QString m_name;
|
|
||||||
qint64 m_timestamp;
|
|
||||||
*/
|
*/
|
||||||
|
qint64 timestamp;
|
||||||
|
|
||||||
/// The URL that this version will be downloaded from. maybe.
|
/// The URL that this version will be downloaded from. maybe.
|
||||||
QString download_url;
|
QString download_url;
|
||||||
@ -44,6 +43,20 @@ struct MinecraftVersion : public InstVersion
|
|||||||
/// is this a snapshot?
|
/// is this a snapshot?
|
||||||
bool is_snapshot = false;
|
bool is_snapshot = false;
|
||||||
|
|
||||||
|
QString m_name;
|
||||||
|
|
||||||
|
QString m_descriptor;
|
||||||
|
|
||||||
|
virtual QString descriptor()
|
||||||
|
{
|
||||||
|
return m_descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QString name()
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
virtual QString typeString() const
|
virtual QString typeString() const
|
||||||
{
|
{
|
||||||
QStringList pre_final;
|
QStringList pre_final;
|
||||||
|
@ -214,6 +214,13 @@ bool OneSixInstance::shouldUpdate() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OneSixInstance::versionIsCustom()
|
||||||
|
{
|
||||||
|
QString verpath_custom = PathCombine(instanceRoot(), "custom.json");
|
||||||
|
QFile versionfile(verpath_custom);
|
||||||
|
return versionfile.exists();
|
||||||
|
}
|
||||||
|
|
||||||
QString OneSixInstance::currentVersionId() const
|
QString OneSixInstance::currentVersionId() const
|
||||||
{
|
{
|
||||||
return intendedVersionId();
|
return intendedVersionId();
|
||||||
@ -224,6 +231,13 @@ bool OneSixInstance::reloadFullVersion()
|
|||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
|
|
||||||
QString verpath = PathCombine(instanceRoot(), "version.json");
|
QString verpath = PathCombine(instanceRoot(), "version.json");
|
||||||
|
{
|
||||||
|
QString verpath_custom = PathCombine(instanceRoot(), "custom.json");
|
||||||
|
QFile versionfile(verpath_custom);
|
||||||
|
if(versionfile.exists())
|
||||||
|
verpath = verpath_custom;
|
||||||
|
}
|
||||||
|
|
||||||
QFile versionfile(verpath);
|
QFile versionfile(verpath);
|
||||||
if(versionfile.exists() && versionfile.open(QIODevice::ReadOnly))
|
if(versionfile.exists() && versionfile.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
@ -264,7 +278,12 @@ bool OneSixInstance::menuActionEnabled ( QString action_name ) const
|
|||||||
|
|
||||||
QString OneSixInstance::getStatusbarDescription()
|
QString OneSixInstance::getStatusbarDescription()
|
||||||
{
|
{
|
||||||
return "One Six : " + intendedVersionId();
|
QString descr = "One Six : " + intendedVersionId();
|
||||||
|
if(versionIsCustom())
|
||||||
|
{
|
||||||
|
descr + " (custom)";
|
||||||
|
}
|
||||||
|
return descr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OneSixInstance::loaderModsDir() const
|
QString OneSixInstance::loaderModsDir() const
|
||||||
|
@ -41,6 +41,8 @@ public:
|
|||||||
bool reloadFullVersion();
|
bool reloadFullVersion();
|
||||||
/// get the current full version info
|
/// get the current full version info
|
||||||
QSharedPointer<OneSixVersion> getFullVersion();
|
QSharedPointer<OneSixVersion> getFullVersion();
|
||||||
|
/// is the current version original, or custom?
|
||||||
|
bool versionIsCustom();
|
||||||
|
|
||||||
virtual QString defaultBaseJar() const;
|
virtual QString defaultBaseJar() const;
|
||||||
virtual QString defaultCustomBaseJar() const;
|
virtual QString defaultCustomBaseJar() const;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "BaseInstance_p.h"
|
#include "BaseInstance_p.h"
|
||||||
#include "OneSixVersion.h"
|
#include "OneSixVersion.h"
|
||||||
|
#include "OneSixLibrary.h"
|
||||||
#include "ModList.h"
|
#include "ModList.h"
|
||||||
|
|
||||||
struct OneSixInstancePrivate: public BaseInstancePrivate
|
struct OneSixInstancePrivate: public BaseInstancePrivate
|
||||||
|
93
logic/OneSixLibrary.cpp
Normal file
93
logic/OneSixLibrary.cpp
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
#include "OneSixLibrary.h"
|
||||||
|
#include "OneSixRule.h"
|
||||||
|
#include "OpSys.h"
|
||||||
|
void OneSixLibrary::finalize()
|
||||||
|
{
|
||||||
|
QStringList parts = m_name.split ( ':' );
|
||||||
|
QString relative = parts[0];
|
||||||
|
relative.replace ( '.','/' );
|
||||||
|
relative += '/' + parts[1] + '/' + parts[2] + '/' + parts[1] + '-' + parts[2];
|
||||||
|
|
||||||
|
if ( !m_is_native )
|
||||||
|
relative += ".jar";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( m_native_suffixes.contains ( currentSystem ) )
|
||||||
|
{
|
||||||
|
relative += "-" + m_native_suffixes[currentSystem] + ".jar";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// really, bad.
|
||||||
|
relative += ".jar";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_decentname = parts[1];
|
||||||
|
m_decentversion = parts[2];
|
||||||
|
m_storage_path = relative;
|
||||||
|
m_download_path = m_base_url + relative;
|
||||||
|
|
||||||
|
if ( m_rules.empty() )
|
||||||
|
{
|
||||||
|
m_is_active = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RuleAction result = Disallow;
|
||||||
|
for ( auto rule: m_rules )
|
||||||
|
{
|
||||||
|
RuleAction temp = rule->apply ( this );
|
||||||
|
if ( temp != Defer )
|
||||||
|
result = temp;
|
||||||
|
}
|
||||||
|
m_is_active = ( result == Allow );
|
||||||
|
}
|
||||||
|
if ( m_is_native )
|
||||||
|
{
|
||||||
|
m_is_active = m_is_active && m_native_suffixes.contains ( currentSystem );
|
||||||
|
m_decenttype = "Native";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_decenttype = "Java";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneSixLibrary::setName ( QString name )
|
||||||
|
{
|
||||||
|
m_name = name;
|
||||||
|
}
|
||||||
|
void OneSixLibrary::setBaseUrl ( QString base_url )
|
||||||
|
{
|
||||||
|
m_base_url = base_url;
|
||||||
|
}
|
||||||
|
void OneSixLibrary::setIsNative()
|
||||||
|
{
|
||||||
|
m_is_native = true;
|
||||||
|
}
|
||||||
|
void OneSixLibrary::addNative ( OpSys os, QString suffix )
|
||||||
|
{
|
||||||
|
m_is_native = true;
|
||||||
|
m_native_suffixes[os] = suffix;
|
||||||
|
}
|
||||||
|
void OneSixLibrary::setRules ( QList< QSharedPointer< Rule > > rules )
|
||||||
|
{
|
||||||
|
m_rules = rules;
|
||||||
|
}
|
||||||
|
bool OneSixLibrary::isActive()
|
||||||
|
{
|
||||||
|
return m_is_active;
|
||||||
|
}
|
||||||
|
bool OneSixLibrary::isNative()
|
||||||
|
{
|
||||||
|
return m_is_native;
|
||||||
|
}
|
||||||
|
QString OneSixLibrary::downloadPath()
|
||||||
|
{
|
||||||
|
return m_download_path;
|
||||||
|
}
|
||||||
|
QString OneSixLibrary::storagePath()
|
||||||
|
{
|
||||||
|
return m_storage_path;
|
||||||
|
}
|
90
logic/OneSixLibrary.h
Normal file
90
logic/OneSixLibrary.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include "OpSys.h"
|
||||||
|
|
||||||
|
class Rule;
|
||||||
|
|
||||||
|
class OneSixLibrary
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// basic values used internally (so far)
|
||||||
|
QString m_name;
|
||||||
|
QString m_base_url;
|
||||||
|
QList<QSharedPointer<Rule> > m_rules;
|
||||||
|
|
||||||
|
// derived values used for real things
|
||||||
|
/// a decent name fit for display
|
||||||
|
QString m_decentname;
|
||||||
|
/// a decent version fit for display
|
||||||
|
QString m_decentversion;
|
||||||
|
/// a decent type fit for display
|
||||||
|
QString m_decenttype;
|
||||||
|
/// where to store the lib locally
|
||||||
|
QString m_storage_path;
|
||||||
|
/// where to download the lib from
|
||||||
|
QString m_download_path;
|
||||||
|
/// is this lib actually active on the current OS?
|
||||||
|
bool m_is_active;
|
||||||
|
/// is the library a native?
|
||||||
|
bool m_is_native;
|
||||||
|
/// native suffixes per OS
|
||||||
|
QMap<OpSys, QString> m_native_suffixes;
|
||||||
|
public:
|
||||||
|
QStringList extract_excludes;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// Constructor
|
||||||
|
OneSixLibrary(QString name)
|
||||||
|
{
|
||||||
|
m_is_native = false;
|
||||||
|
m_is_active = false;
|
||||||
|
m_name = name;
|
||||||
|
m_base_url = "https://s3.amazonaws.com/Minecraft.Download/libraries/";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* finalize the library, processing the input values into derived values and state
|
||||||
|
*
|
||||||
|
* This SHALL be called after all the values are parsed or after any further change.
|
||||||
|
*/
|
||||||
|
void finalize();
|
||||||
|
|
||||||
|
/// Set the library composite name
|
||||||
|
void setName(QString name);
|
||||||
|
/// get a decent-looking name
|
||||||
|
QString name()
|
||||||
|
{
|
||||||
|
return m_decentname;
|
||||||
|
}
|
||||||
|
/// get a decent-looking version
|
||||||
|
QString version()
|
||||||
|
{
|
||||||
|
return m_decentversion;
|
||||||
|
}
|
||||||
|
/// what kind of library is it? (for display)
|
||||||
|
QString type()
|
||||||
|
{
|
||||||
|
return m_decenttype;
|
||||||
|
}
|
||||||
|
/// Set the url base for downloads
|
||||||
|
void setBaseUrl(QString base_url);
|
||||||
|
|
||||||
|
/// Call this to mark the library as 'native' (it's a zip archive with DLLs)
|
||||||
|
void setIsNative();
|
||||||
|
/// Attach a name suffix to the specified OS native
|
||||||
|
void addNative(OpSys os, QString suffix);
|
||||||
|
/// Set the load rules
|
||||||
|
void setRules(QList<QSharedPointer<Rule> > rules);
|
||||||
|
|
||||||
|
/// Returns true if the library should be loaded (or extracted, in case of natives)
|
||||||
|
bool isActive();
|
||||||
|
/// Returns true if the library is native
|
||||||
|
bool isNative();
|
||||||
|
/// Get the URL to download the library from
|
||||||
|
QString downloadPath();
|
||||||
|
/// Get the relative path where the library should be saved
|
||||||
|
QString storagePath();
|
||||||
|
};
|
10
logic/OneSixRule.cpp
Normal file
10
logic/OneSixRule.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include "OneSixRule.h"
|
||||||
|
|
||||||
|
RuleAction RuleAction_fromString(QString name)
|
||||||
|
{
|
||||||
|
if(name == "allow")
|
||||||
|
return Allow;
|
||||||
|
if(name == "disallow")
|
||||||
|
return Disallow;
|
||||||
|
return Defer;
|
||||||
|
}
|
70
logic/OneSixRule.h
Normal file
70
logic/OneSixRule.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <QString>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
class OneSixLibrary;
|
||||||
|
#include "OneSixLibrary.h"
|
||||||
|
|
||||||
|
enum RuleAction
|
||||||
|
{
|
||||||
|
Allow,
|
||||||
|
Disallow,
|
||||||
|
Defer
|
||||||
|
};
|
||||||
|
|
||||||
|
RuleAction RuleAction_fromString(QString);
|
||||||
|
|
||||||
|
class Rule
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
RuleAction m_result;
|
||||||
|
virtual bool applies(OneSixLibrary * parent) = 0;
|
||||||
|
public:
|
||||||
|
Rule(RuleAction result)
|
||||||
|
:m_result(result) {}
|
||||||
|
virtual ~Rule(){};
|
||||||
|
RuleAction apply(OneSixLibrary * parent)
|
||||||
|
{
|
||||||
|
if(applies(parent))
|
||||||
|
return m_result;
|
||||||
|
else
|
||||||
|
return Defer;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class OsRule : public Rule
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// the OS
|
||||||
|
OpSys m_system;
|
||||||
|
// the OS version regexp
|
||||||
|
QString m_version_regexp;
|
||||||
|
protected:
|
||||||
|
virtual bool applies ( OneSixLibrary* )
|
||||||
|
{
|
||||||
|
return (m_system == currentSystem);
|
||||||
|
}
|
||||||
|
OsRule(RuleAction result, OpSys system, QString version_regexp)
|
||||||
|
: Rule(result), m_system(system), m_version_regexp(version_regexp) {}
|
||||||
|
public:
|
||||||
|
static QSharedPointer<OsRule> create(RuleAction result, OpSys system, QString version_regexp)
|
||||||
|
{
|
||||||
|
return QSharedPointer<OsRule> (new OsRule(result, system, version_regexp));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ImplicitRule : public Rule
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
virtual bool applies ( OneSixLibrary* )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ImplicitRule(RuleAction result)
|
||||||
|
: Rule(result) {}
|
||||||
|
public:
|
||||||
|
static QSharedPointer<ImplicitRule> create(RuleAction result)
|
||||||
|
{
|
||||||
|
return QSharedPointer<ImplicitRule> (new ImplicitRule(result));
|
||||||
|
}
|
||||||
|
};
|
@ -28,6 +28,7 @@
|
|||||||
#include "lists/MinecraftVersionList.h"
|
#include "lists/MinecraftVersionList.h"
|
||||||
#include "VersionFactory.h"
|
#include "VersionFactory.h"
|
||||||
#include "OneSixVersion.h"
|
#include "OneSixVersion.h"
|
||||||
|
#include "OneSixLibrary.h"
|
||||||
#include "OneSixInstance.h"
|
#include "OneSixInstance.h"
|
||||||
|
|
||||||
#include "pathutils.h"
|
#include "pathutils.h"
|
||||||
@ -48,7 +49,7 @@ void OneSixUpdate::executeTask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get a pointer to the version object that corresponds to the instance's version.
|
// Get a pointer to the version object that corresponds to the instance's version.
|
||||||
targetVersion = MinecraftVersionList::getMainList().findVersion(intendedVersion).dynamicCast<MinecraftVersion>();
|
targetVersion = MMC->minecraftlist()->findVersion(intendedVersion).dynamicCast<MinecraftVersion>();
|
||||||
if(targetVersion == nullptr)
|
if(targetVersion == nullptr)
|
||||||
{
|
{
|
||||||
// don't do anything if it was invalid
|
// don't do anything if it was invalid
|
||||||
@ -71,44 +72,59 @@ void OneSixUpdate::versionFileStart()
|
|||||||
setStatus("Getting the version files from Mojang.");
|
setStatus("Getting the version files from Mojang.");
|
||||||
|
|
||||||
QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
|
QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
|
||||||
urlstr += targetVersion->descriptor + "/" + targetVersion->descriptor + ".json";
|
urlstr += targetVersion->descriptor() + "/" + targetVersion->descriptor() + ".json";
|
||||||
auto job = new DownloadJob("Version index");
|
auto job = new DownloadJob("Version index");
|
||||||
job->add(QUrl(urlstr));
|
job->add(QUrl(urlstr));
|
||||||
specificVersionDownloadJob.reset(job);
|
specificVersionDownloadJob.reset(job);
|
||||||
connect(specificVersionDownloadJob.data(), SIGNAL(succeeded()), SLOT(versionFileFinished()));
|
connect(specificVersionDownloadJob.data(), SIGNAL(succeeded()), SLOT(versionFileFinished()));
|
||||||
connect(specificVersionDownloadJob.data(), SIGNAL(failed()), SLOT(versionFileFailed()));
|
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();
|
specificVersionDownloadJob->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixUpdate::versionFileFinished()
|
void OneSixUpdate::versionFileFinished()
|
||||||
{
|
{
|
||||||
DownloadPtr DlJob = specificVersionDownloadJob->first();
|
DownloadPtr DlJob = specificVersionDownloadJob->first();
|
||||||
|
OneSixInstance * inst = (OneSixInstance *) m_inst;
|
||||||
|
|
||||||
QString version_id = targetVersion->descriptor;
|
QString version_id = targetVersion->descriptor();
|
||||||
QString inst_dir = m_inst->instanceRoot();
|
QString inst_dir = m_inst->instanceRoot();
|
||||||
// save the version file in $instanceId/version.json
|
// save the version file in $instanceId/version.json
|
||||||
{
|
{
|
||||||
QString version1 = PathCombine(inst_dir, "/version.json");
|
QString version1 = PathCombine(inst_dir, "/version.json");
|
||||||
ensureFilePathExists(version1);
|
ensureFilePathExists(version1);
|
||||||
// FIXME: detect errors here, download to a temp file, swap
|
// FIXME: detect errors here, download to a temp file, swap
|
||||||
QFile vfile1 (version1);
|
QSaveFile vfile1 (version1);
|
||||||
vfile1.open(QIODevice::Truncate | QIODevice::WriteOnly );
|
if(!vfile1.open(QIODevice::Truncate | QIODevice::WriteOnly ))
|
||||||
vfile1.write(DlJob.dynamicCast<ByteArrayDownload>()->m_data);
|
{
|
||||||
vfile1.close();
|
emitFailed("Can't open " + version1 + " for writing.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto data = DlJob.dynamicCast<ByteArrayDownload>()->m_data;
|
||||||
|
qint64 actual = 0;
|
||||||
|
if((actual = vfile1.write(data)) != data.size())
|
||||||
|
{
|
||||||
|
emitFailed("Failed to write into " + version1 + ". Written " + actual + " out of " + data.size() + '.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!vfile1.commit())
|
||||||
|
{
|
||||||
|
emitFailed("Can't commit changes to " + version1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// the version is downloaded safely. update is 'done' at this point
|
// the version is downloaded safely. update is 'done' at this point
|
||||||
m_inst->setShouldUpdate(false);
|
m_inst->setShouldUpdate(false);
|
||||||
// save the version file in versions/$version/$version.json
|
|
||||||
/*
|
// delete any custom version inside the instance (it's no longer relevant, we did an update)
|
||||||
//QString version2 = QString("versions/") + version_id + "/" + version_id + ".json";
|
QString custom = PathCombine(inst_dir, "/custom.json");
|
||||||
//ensurePathExists(version2);
|
QFile finfo(custom);
|
||||||
//QFile vfile2 (version2);
|
if(finfo.exists())
|
||||||
//vfile2.open(QIODevice::Truncate | QIODevice::WriteOnly );
|
{
|
||||||
//vfile2.write(DlJob->m_data);
|
finfo.remove();
|
||||||
//vfile2.close();
|
}
|
||||||
*/
|
inst->reloadFullVersion();
|
||||||
|
|
||||||
jarlibStart();
|
jarlibStart();
|
||||||
}
|
}
|
||||||
@ -155,7 +171,7 @@ void OneSixUpdate::jarlibStart()
|
|||||||
}
|
}
|
||||||
connect(jarlibDownloadJob.data(), SIGNAL(succeeded()), SLOT(jarlibFinished()));
|
connect(jarlibDownloadJob.data(), SIGNAL(succeeded()), SLOT(jarlibFinished()));
|
||||||
connect(jarlibDownloadJob.data(), SIGNAL(failed()), SLOT(jarlibFailed()));
|
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();
|
jarlibDownloadJob->start();
|
||||||
}
|
}
|
||||||
|
@ -1,111 +1,9 @@
|
|||||||
#include "OneSixVersion.h"
|
#include "OneSixVersion.h"
|
||||||
|
#include "OneSixLibrary.h"
|
||||||
|
|
||||||
RuleAction RuleAction_fromString(QString name)
|
QList<QSharedPointer<OneSixLibrary> > OneSixVersion::getActiveNormalLibs()
|
||||||
{
|
{
|
||||||
if(name == "allow")
|
QList<QSharedPointer<OneSixLibrary> > output;
|
||||||
return Allow;
|
|
||||||
if(name == "disallow")
|
|
||||||
return Disallow;
|
|
||||||
return Defer;
|
|
||||||
}
|
|
||||||
|
|
||||||
OpSys OpSys_fromString(QString name)
|
|
||||||
{
|
|
||||||
if(name == "linux")
|
|
||||||
return Os_Linux;
|
|
||||||
if(name == "windows")
|
|
||||||
return Os_Windows;
|
|
||||||
if(name == "osx")
|
|
||||||
return Os_OSX;
|
|
||||||
return Os_Other;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Library::finalize()
|
|
||||||
{
|
|
||||||
QStringList parts = m_name.split ( ':' );
|
|
||||||
QString relative = parts[0];
|
|
||||||
relative.replace ( '.','/' );
|
|
||||||
relative += '/' + parts[1] + '/' + parts[2] + '/' + parts[1] + '-' + parts[2];
|
|
||||||
if ( !m_is_native )
|
|
||||||
relative += ".jar";
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( m_native_suffixes.contains ( currentSystem ) )
|
|
||||||
{
|
|
||||||
relative += "-" + m_native_suffixes[currentSystem] + ".jar";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// really, bad.
|
|
||||||
relative += ".jar";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_storage_path = relative;
|
|
||||||
m_download_path = m_base_url + relative;
|
|
||||||
|
|
||||||
if ( m_rules.empty() )
|
|
||||||
{
|
|
||||||
m_is_active = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RuleAction result = Disallow;
|
|
||||||
for ( auto rule: m_rules )
|
|
||||||
{
|
|
||||||
RuleAction temp = rule->apply ( this );
|
|
||||||
if ( temp != Defer )
|
|
||||||
result = temp;
|
|
||||||
}
|
|
||||||
m_is_active = ( result == Allow );
|
|
||||||
}
|
|
||||||
if ( m_is_native )
|
|
||||||
{
|
|
||||||
m_is_active = m_is_active && m_native_suffixes.contains ( currentSystem );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Library::setName ( QString name )
|
|
||||||
{
|
|
||||||
m_name = name;
|
|
||||||
}
|
|
||||||
void Library::setBaseUrl ( QString base_url )
|
|
||||||
{
|
|
||||||
m_base_url = base_url;
|
|
||||||
}
|
|
||||||
void Library::setIsNative()
|
|
||||||
{
|
|
||||||
m_is_native = true;
|
|
||||||
}
|
|
||||||
void Library::addNative ( OpSys os, QString suffix )
|
|
||||||
{
|
|
||||||
m_is_native = true;
|
|
||||||
m_native_suffixes[os] = suffix;
|
|
||||||
}
|
|
||||||
void Library::setRules ( QList< QSharedPointer< Rule > > rules )
|
|
||||||
{
|
|
||||||
m_rules = rules;
|
|
||||||
}
|
|
||||||
bool Library::isActive()
|
|
||||||
{
|
|
||||||
return m_is_active;
|
|
||||||
}
|
|
||||||
bool Library::isNative()
|
|
||||||
{
|
|
||||||
return m_is_native;
|
|
||||||
}
|
|
||||||
QString Library::downloadPath()
|
|
||||||
{
|
|
||||||
return m_download_path;
|
|
||||||
}
|
|
||||||
QString Library::storagePath()
|
|
||||||
{
|
|
||||||
return m_storage_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList<QSharedPointer<Library> > OneSixVersion::getActiveNormalLibs()
|
|
||||||
{
|
|
||||||
QList<QSharedPointer<Library> > output;
|
|
||||||
for ( auto lib: libraries )
|
for ( auto lib: libraries )
|
||||||
{
|
{
|
||||||
if (lib->isActive() && !lib->isNative())
|
if (lib->isActive() && !lib->isNative())
|
||||||
@ -116,9 +14,9 @@ QList<QSharedPointer<Library> > OneSixVersion::getActiveNormalLibs()
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QSharedPointer<Library> > OneSixVersion::getActiveNativeLibs()
|
QList<QSharedPointer<OneSixLibrary> > OneSixVersion::getActiveNativeLibs()
|
||||||
{
|
{
|
||||||
QList<QSharedPointer<Library> > output;
|
QList<QSharedPointer<OneSixLibrary> > output;
|
||||||
for ( auto lib: libraries )
|
for ( auto lib: libraries )
|
||||||
{
|
{
|
||||||
if (lib->isActive() && lib->isNative())
|
if (lib->isActive() && lib->isNative())
|
||||||
@ -130,3 +28,74 @@ QList<QSharedPointer<Library> > OneSixVersion::getActiveNativeLibs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant OneSixVersion::data(const QModelIndex& index, int role) const
|
||||||
|
{
|
||||||
|
if(!index.isValid())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
int row = index.row();
|
||||||
|
int column = index.column();
|
||||||
|
|
||||||
|
if(row < 0 || row >= libraries.size())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
if(role == Qt::DisplayRole)
|
||||||
|
{
|
||||||
|
switch(column)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return libraries[row]->name();
|
||||||
|
case 1:
|
||||||
|
return libraries[row]->type();
|
||||||
|
case 2:
|
||||||
|
return libraries[row]->version();
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags OneSixVersion::flags(const QModelIndex& index) const
|
||||||
|
{
|
||||||
|
if(!index.isValid())
|
||||||
|
return Qt::NoItemFlags;
|
||||||
|
int row = index.row();
|
||||||
|
if(libraries[row]->isActive())
|
||||||
|
{
|
||||||
|
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Qt::ItemNeverHasChildren;
|
||||||
|
}
|
||||||
|
//return QAbstractListModel::flags(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant OneSixVersion::headerData ( int section, Qt::Orientation orientation, int role ) const
|
||||||
|
{
|
||||||
|
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
|
||||||
|
return QVariant();
|
||||||
|
switch (section)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return QString("Name");
|
||||||
|
case 1:
|
||||||
|
return QString("Type");
|
||||||
|
case 2:
|
||||||
|
return QString("Version");
|
||||||
|
default:
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int OneSixVersion::rowCount(const QModelIndex& parent) const
|
||||||
|
{
|
||||||
|
return libraries.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
int OneSixVersion::columnCount(const QModelIndex& parent) const
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
@ -1,154 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
class OneSixLibrary;
|
||||||
|
|
||||||
class Library;
|
class OneSixVersion : public QAbstractListModel
|
||||||
|
|
||||||
enum OpSys
|
|
||||||
{
|
{
|
||||||
Os_Windows,
|
|
||||||
Os_Linux,
|
|
||||||
Os_OSX,
|
|
||||||
Os_Other
|
|
||||||
};
|
|
||||||
|
|
||||||
OpSys OpSys_fromString(QString);
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
#define currentSystem Os_Windows
|
|
||||||
#else
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
#define currentSystem Os_OSX
|
|
||||||
#else
|
|
||||||
#define currentSystem Os_Linux
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
enum RuleAction
|
|
||||||
{
|
|
||||||
Allow,
|
|
||||||
Disallow,
|
|
||||||
Defer
|
|
||||||
};
|
|
||||||
|
|
||||||
RuleAction RuleAction_fromString(QString);
|
|
||||||
|
|
||||||
class Rule
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
RuleAction m_result;
|
|
||||||
virtual bool applies(Library * parent) = 0;
|
|
||||||
public:
|
public:
|
||||||
Rule(RuleAction result)
|
virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const;
|
||||||
:m_result(result) {}
|
virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const;
|
||||||
virtual ~Rule(){};
|
virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
|
||||||
RuleAction apply(Library * parent)
|
virtual int columnCount ( const QModelIndex& parent ) const;
|
||||||
{
|
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||||
if(applies(parent))
|
|
||||||
return m_result;
|
|
||||||
else
|
|
||||||
return Defer;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
class OsRule : public Rule
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// the OS
|
|
||||||
OpSys m_system;
|
|
||||||
// the OS version regexp
|
|
||||||
QString m_version_regexp;
|
|
||||||
protected:
|
|
||||||
virtual bool applies ( Library* )
|
|
||||||
{
|
|
||||||
return (m_system == currentSystem);
|
|
||||||
}
|
|
||||||
OsRule(RuleAction result, OpSys system, QString version_regexp)
|
|
||||||
: Rule(result), m_system(system), m_version_regexp(version_regexp) {}
|
|
||||||
public:
|
|
||||||
static QSharedPointer<OsRule> create(RuleAction result, OpSys system, QString version_regexp)
|
|
||||||
{
|
|
||||||
return QSharedPointer<OsRule> (new OsRule(result, system, version_regexp));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class ImplicitRule : public Rule
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
virtual bool applies ( Library* )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ImplicitRule(RuleAction result)
|
|
||||||
: Rule(result) {}
|
|
||||||
public:
|
|
||||||
static QSharedPointer<ImplicitRule> create(RuleAction result)
|
|
||||||
{
|
|
||||||
return QSharedPointer<ImplicitRule> (new ImplicitRule(result));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Library
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// basic values used internally (so far)
|
|
||||||
QString m_name;
|
|
||||||
QString m_base_url;
|
|
||||||
QList<QSharedPointer<Rule> > m_rules;
|
|
||||||
|
|
||||||
// derived values used for real things
|
|
||||||
/// where to store the lib locally
|
|
||||||
QString m_storage_path;
|
|
||||||
/// where to download the lib from
|
|
||||||
QString m_download_path;
|
|
||||||
/// is this lib actually active on the current OS?
|
|
||||||
bool m_is_active;
|
|
||||||
/// is the library a native?
|
|
||||||
bool m_is_native;
|
|
||||||
/// native suffixes per OS
|
|
||||||
QMap<OpSys, QString> m_native_suffixes;
|
|
||||||
public:
|
|
||||||
QStringList extract_excludes;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
Library(QString name)
|
|
||||||
{
|
|
||||||
m_is_native = false;
|
|
||||||
m_is_native = false;
|
|
||||||
m_name = name;
|
|
||||||
m_base_url = "https://s3.amazonaws.com/Minecraft.Download/libraries/";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* finalize the library, processing the input values into derived values and state
|
|
||||||
*
|
|
||||||
* This SHALL be called after all the values are parsed or after any further change.
|
|
||||||
*/
|
|
||||||
void finalize();
|
|
||||||
|
|
||||||
/// Set the library composite name
|
|
||||||
void setName(QString name);
|
|
||||||
/// Set the url base for downloads
|
|
||||||
void setBaseUrl(QString base_url);
|
|
||||||
/// Call this to mark the library as 'native' (it's a zip archive with DLLs)
|
|
||||||
void setIsNative();
|
|
||||||
/// Attach a name suffix to the specified OS native
|
|
||||||
void addNative(OpSys os, QString suffix);
|
|
||||||
/// Set the load rules
|
|
||||||
void setRules(QList<QSharedPointer<Rule> > rules);
|
|
||||||
|
|
||||||
/// Returns true if the library should be loaded (or extracted, in case of natives)
|
|
||||||
bool isActive();
|
|
||||||
/// Returns true if the library is native
|
|
||||||
bool isNative();
|
|
||||||
/// Get the URL to download the library from
|
|
||||||
QString downloadPath();
|
|
||||||
/// Get the relative path where the library should be saved
|
|
||||||
QString storagePath();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class OneSixVersion
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/// the ID - determines which jar to use! ACTUALLY IMPORTANT!
|
/// the ID - determines which jar to use! ACTUALLY IMPORTANT!
|
||||||
QString id;
|
QString id;
|
||||||
@ -180,7 +41,7 @@ public:
|
|||||||
QString mainClass;
|
QString mainClass;
|
||||||
|
|
||||||
/// the list of libs - both active and inactive, native and java
|
/// the list of libs - both active and inactive, native and java
|
||||||
QList<QSharedPointer<Library> > libraries;
|
QList<QSharedPointer<OneSixLibrary> > libraries;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
|
FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
|
||||||
@ -203,11 +64,12 @@ public:
|
|||||||
// QList<Rule> rules;
|
// QList<Rule> rules;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OneSixVersion()
|
OneSixVersion()
|
||||||
{
|
{
|
||||||
minimumLauncherVersion = 0xDEADBEEF;
|
minimumLauncherVersion = 0xDEADBEEF;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QSharedPointer<Library> > getActiveNormalLibs();
|
QList<QSharedPointer<OneSixLibrary> > getActiveNormalLibs();
|
||||||
QList<QSharedPointer<Library> > getActiveNativeLibs();
|
QList<QSharedPointer<OneSixLibrary> > getActiveNativeLibs();
|
||||||
};
|
};
|
12
logic/OpSys.cpp
Normal file
12
logic/OpSys.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "OpSys.h"
|
||||||
|
|
||||||
|
OpSys OpSys_fromString(QString name)
|
||||||
|
{
|
||||||
|
if(name == "linux")
|
||||||
|
return Os_Linux;
|
||||||
|
if(name == "windows")
|
||||||
|
return Os_Windows;
|
||||||
|
if(name == "osx")
|
||||||
|
return Os_OSX;
|
||||||
|
return Os_Other;
|
||||||
|
}
|
21
logic/OpSys.h
Normal file
21
logic/OpSys.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <QString>
|
||||||
|
enum OpSys
|
||||||
|
{
|
||||||
|
Os_Windows,
|
||||||
|
Os_Linux,
|
||||||
|
Os_OSX,
|
||||||
|
Os_Other
|
||||||
|
};
|
||||||
|
|
||||||
|
OpSys OpSys_fromString(QString);
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
#define currentSystem Os_Windows
|
||||||
|
#else
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
#define currentSystem Os_OSX
|
||||||
|
#else
|
||||||
|
#define currentSystem Os_Linux
|
||||||
|
#endif
|
||||||
|
#endif
|
@ -1,5 +1,6 @@
|
|||||||
#include "VersionFactory.h"
|
#include "VersionFactory.h"
|
||||||
#include "OneSixVersion.h"
|
#include "OneSixVersion.h"
|
||||||
|
#include "OneSixRule.h"
|
||||||
|
|
||||||
// Library rules (if any)
|
// Library rules (if any)
|
||||||
QList<QSharedPointer<Rule> > FullVersionFactory::parse4rules(QJsonObject & baseObj)
|
QList<QSharedPointer<Rule> > FullVersionFactory::parse4rules(QJsonObject & baseObj)
|
||||||
@ -103,7 +104,7 @@ QSharedPointer<OneSixVersion> FullVersionFactory::parse4(QJsonObject root, QShar
|
|||||||
auto nameVal = libObj.value("name");
|
auto nameVal = libObj.value("name");
|
||||||
if(!nameVal.isString())
|
if(!nameVal.isString())
|
||||||
continue;
|
continue;
|
||||||
QSharedPointer<Library> library(new Library(nameVal.toString()));
|
QSharedPointer<OneSixLibrary> library(new OneSixLibrary(nameVal.toString()));
|
||||||
|
|
||||||
auto urlVal = libObj.value("url");
|
auto urlVal = libObj.value("url");
|
||||||
if(urlVal.isString())
|
if(urlVal.isString())
|
||||||
|
@ -13,33 +13,33 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "logic/lists/InstVersionList.h"
|
#include "logic/lists/BaseVersionList.h"
|
||||||
#include "logic/InstanceVersion.h"
|
#include "logic/BaseVersion.h"
|
||||||
|
|
||||||
InstVersionList::InstVersionList(QObject *parent) :
|
BaseVersionList::BaseVersionList(QObject *parent) :
|
||||||
QAbstractListModel(parent)
|
QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
InstVersionPtr InstVersionList::findVersion( const QString& descriptor )
|
BaseVersionPtr BaseVersionList::findVersion( const QString& descriptor )
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count(); i++)
|
for (int i = 0; i < count(); i++)
|
||||||
{
|
{
|
||||||
if (at(i)->descriptor == descriptor)
|
if (at(i)->descriptor() == descriptor)
|
||||||
return at(i);
|
return at(i);
|
||||||
}
|
}
|
||||||
return InstVersionPtr();
|
return BaseVersionPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
InstVersionPtr InstVersionList::getLatestStable() const
|
BaseVersionPtr BaseVersionList::getLatestStable() const
|
||||||
{
|
{
|
||||||
if (count() <= 0)
|
if (count() <= 0)
|
||||||
return InstVersionPtr();
|
return BaseVersionPtr();
|
||||||
else
|
else
|
||||||
return at(0);
|
return at(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant InstVersionList::data(const QModelIndex &index, int role) const
|
QVariant BaseVersionList::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -48,7 +48,7 @@ QVariant InstVersionList::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
|
|
||||||
InstVersionPtr version = at(index.row());
|
BaseVersionPtr version = at(index.row());
|
||||||
|
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
@ -56,20 +56,17 @@ QVariant InstVersionList::data(const QModelIndex &index, int role) const
|
|||||||
switch (index.column())
|
switch (index.column())
|
||||||
{
|
{
|
||||||
case NameColumn:
|
case NameColumn:
|
||||||
return version->name;
|
return version->name();
|
||||||
|
|
||||||
case TypeColumn:
|
case TypeColumn:
|
||||||
return version->typeString();
|
return version->typeString();
|
||||||
|
|
||||||
case TimeColumn:
|
|
||||||
return version->timestamp;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
return version->descriptor;
|
return version->descriptor();
|
||||||
|
|
||||||
case VersionPointerRole:
|
case VersionPointerRole:
|
||||||
return qVariantFromValue(version);
|
return qVariantFromValue(version);
|
||||||
@ -79,7 +76,7 @@ QVariant InstVersionList::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant InstVersionList::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant BaseVersionList::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
@ -92,9 +89,6 @@ QVariant InstVersionList::headerData(int section, Qt::Orientation orientation, i
|
|||||||
case TypeColumn:
|
case TypeColumn:
|
||||||
return "Type";
|
return "Type";
|
||||||
|
|
||||||
case TimeColumn:
|
|
||||||
return "Time";
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -117,13 +111,13 @@ QVariant InstVersionList::headerData(int section, Qt::Orientation orientation, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstVersionList::rowCount(const QModelIndex &parent) const
|
int BaseVersionList::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
// Return count
|
// Return count
|
||||||
return count();
|
return count();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstVersionList::columnCount(const QModelIndex &parent) const
|
int BaseVersionList::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
@ -20,7 +20,7 @@
|
|||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
|
||||||
#include "logic/InstanceVersion.h"
|
#include "logic/BaseVersion.h"
|
||||||
|
|
||||||
class Task;
|
class Task;
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ class Task;
|
|||||||
* all have a default implementation, but they can be overridden by plugins to
|
* all have a default implementation, but they can be overridden by plugins to
|
||||||
* change the behavior of the list.
|
* change the behavior of the list.
|
||||||
*/
|
*/
|
||||||
class InstVersionList : public QAbstractListModel
|
class BaseVersionList : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
TimeColumn
|
TimeColumn
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit InstVersionList(QObject *parent = 0);
|
explicit BaseVersionList(QObject *parent = 0);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets a task that will reload the version list.
|
* \brief Gets a task that will reload the version list.
|
||||||
@ -71,7 +71,7 @@ public:
|
|||||||
virtual bool isLoaded() = 0;
|
virtual bool isLoaded() = 0;
|
||||||
|
|
||||||
//! Gets the version at the given index.
|
//! Gets the version at the given index.
|
||||||
virtual const InstVersionPtr at(int i) const = 0;
|
virtual const BaseVersionPtr at(int i) const = 0;
|
||||||
|
|
||||||
//! Returns the number of versions in the list.
|
//! Returns the number of versions in the list.
|
||||||
virtual int count() const = 0;
|
virtual int count() const = 0;
|
||||||
@ -90,14 +90,14 @@ public:
|
|||||||
* \return A const pointer to the version with the given descriptor. NULL if
|
* \return A const pointer to the version with the given descriptor. NULL if
|
||||||
* one doesn't exist.
|
* one doesn't exist.
|
||||||
*/
|
*/
|
||||||
virtual InstVersionPtr findVersion(const QString &descriptor);
|
virtual BaseVersionPtr findVersion(const QString &descriptor);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the latest stable version of this instance type.
|
* \brief Gets the latest stable version of this instance type.
|
||||||
* This is the version that will be selected by default.
|
* This is the version that will be selected by default.
|
||||||
* By default, this is simply the first version in the list.
|
* By default, this is simply the first version in the list.
|
||||||
*/
|
*/
|
||||||
virtual InstVersionPtr getLatestStable() const;
|
virtual BaseVersionPtr getLatestStable() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sorts the version list.
|
* Sorts the version list.
|
||||||
@ -117,5 +117,5 @@ protected slots:
|
|||||||
* then copies the versions and sets their parents correctly.
|
* then copies the versions and sets their parents correctly.
|
||||||
* \param versions List of versions whose parents should be set.
|
* \param versions List of versions whose parents should be set.
|
||||||
*/
|
*/
|
||||||
virtual void updateListData(QList<InstVersionPtr > versions) = 0;
|
virtual void updateListData(QList<BaseVersionPtr > versions) = 0;
|
||||||
};
|
};
|
269
logic/lists/ForgeVersionList.cpp
Normal file
269
logic/lists/ForgeVersionList.cpp
Normal file
@ -0,0 +1,269 @@
|
|||||||
|
/* 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 "ForgeVersionList.h"
|
||||||
|
#include <logic/net/DownloadJob.h>
|
||||||
|
#include "MultiMC.h"
|
||||||
|
|
||||||
|
#include <QtNetwork>
|
||||||
|
|
||||||
|
#include <QtXml>
|
||||||
|
|
||||||
|
#include <QRegExp>
|
||||||
|
|
||||||
|
#define JSON_URL "http://files.minecraftforge.net/minecraftforge/json"
|
||||||
|
|
||||||
|
|
||||||
|
ForgeVersionList::ForgeVersionList(QObject* parent): BaseVersionList(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Task *ForgeVersionList::getLoadTask()
|
||||||
|
{
|
||||||
|
return new ForgeListLoadTask(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ForgeVersionList::isLoaded()
|
||||||
|
{
|
||||||
|
return m_loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BaseVersionPtr ForgeVersionList::at(int i) const
|
||||||
|
{
|
||||||
|
return m_vlist.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ForgeVersionList::count() const
|
||||||
|
{
|
||||||
|
return m_vlist.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ForgeVersionList::columnCount(const QModelIndex& parent) const
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ForgeVersionList::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
if (index.row() > count())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
auto version = m_vlist[index.row()].dynamicCast<ForgeVersion>();
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForgeVersionList::updateListData(QList<BaseVersionPtr > versions)
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
m_vlist = versions;
|
||||||
|
m_loaded = true;
|
||||||
|
endResetModel();
|
||||||
|
// NOW SORT!!
|
||||||
|
// sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForgeVersionList::sort()
|
||||||
|
{
|
||||||
|
// NO-OP for now
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ForgeListLoadTask::ForgeListLoadTask(ForgeVersionList* vlist): Task()
|
||||||
|
{
|
||||||
|
m_list = vlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ForgeListLoadTask::executeTask()
|
||||||
|
{
|
||||||
|
auto job = new DownloadJob("Version index");
|
||||||
|
job->add(QUrl(JSON_URL));
|
||||||
|
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)), SIGNAL(progress(qint64,qint64)));
|
||||||
|
listJob->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForgeListLoadTask::list_downloaded()
|
||||||
|
{
|
||||||
|
auto DlJob = listJob->first();
|
||||||
|
auto data = DlJob.dynamicCast<ByteArrayDownload>()->m_data;
|
||||||
|
|
||||||
|
|
||||||
|
QJsonParseError jsonError;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
||||||
|
DlJob.reset();
|
||||||
|
|
||||||
|
if (jsonError.error != QJsonParseError::NoError)
|
||||||
|
{
|
||||||
|
emitFailed("Error parsing version list JSON:" + jsonError.errorString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!jsonDoc.isObject())
|
||||||
|
{
|
||||||
|
emitFailed("Error parsing version list JSON: jsonDoc is not an object");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject root = jsonDoc.object();
|
||||||
|
|
||||||
|
// Now, get the array of versions.
|
||||||
|
if(!root.value("builds").isArray())
|
||||||
|
{
|
||||||
|
emitFailed("Error parsing version list JSON: version list object is missing 'builds' array");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QJsonArray builds = root.value("builds").toArray();
|
||||||
|
|
||||||
|
QList<BaseVersionPtr > tempList;
|
||||||
|
for (int i = 0; i < builds.count(); i++)
|
||||||
|
{
|
||||||
|
// Load the version info.
|
||||||
|
if(!builds[i].isObject())
|
||||||
|
{
|
||||||
|
//FIXME: log this somewhere
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QJsonObject obj = builds[i].toObject();
|
||||||
|
int build_nr = obj.value("build").toDouble(0);
|
||||||
|
if(!build_nr)
|
||||||
|
continue;
|
||||||
|
QJsonArray files = obj.value("files").toArray();
|
||||||
|
QString url, jobbuildver, mcver, buildtype, filename;
|
||||||
|
QString changelog_url, installer_url;
|
||||||
|
bool valid = false;
|
||||||
|
for(int j = 0; j < files.count(); j++)
|
||||||
|
{
|
||||||
|
if(!files[j].isObject())
|
||||||
|
continue;
|
||||||
|
QJsonObject file = files[j].toObject();
|
||||||
|
buildtype = file.value("buildtype").toString();
|
||||||
|
if((buildtype == "client" || buildtype == "universal") && !valid)
|
||||||
|
{
|
||||||
|
mcver = file.value("mcver").toString();
|
||||||
|
url = file.value("url").toString();
|
||||||
|
jobbuildver = file.value("jobbuildver").toString();
|
||||||
|
int lastSlash = url.lastIndexOf('/');
|
||||||
|
filename = url.mid(lastSlash+1);
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
else if(buildtype == "changelog")
|
||||||
|
{
|
||||||
|
QString ext = file.value("ext").toString();
|
||||||
|
if(ext.isEmpty())
|
||||||
|
continue;
|
||||||
|
changelog_url = file.value("url").toString();
|
||||||
|
}
|
||||||
|
else if(buildtype == "installer")
|
||||||
|
{
|
||||||
|
installer_url = file.value("url").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(valid)
|
||||||
|
{
|
||||||
|
// Now, we construct the version object and add it to the list.
|
||||||
|
QSharedPointer<ForgeVersion> fVersion(new ForgeVersion());
|
||||||
|
fVersion->universal_url = url;
|
||||||
|
fVersion->changelog_url = changelog_url;
|
||||||
|
fVersion->installer_url = installer_url;
|
||||||
|
fVersion->jobbuildver = jobbuildver;
|
||||||
|
fVersion->mcver = mcver;
|
||||||
|
fVersion->filename = filename;
|
||||||
|
fVersion->m_buildnr = build_nr;
|
||||||
|
tempList.append(fVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_list->updateListData(tempList);
|
||||||
|
|
||||||
|
emitSucceeded();
|
||||||
|
return;
|
||||||
|
}
|
102
logic/lists/ForgeVersionList.h
Normal file
102
logic/lists/ForgeVersionList.h
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include "BaseVersionList.h"
|
||||||
|
#include "logic/tasks/Task.h"
|
||||||
|
#include "logic/net/DownloadJob.h"
|
||||||
|
|
||||||
|
class ForgeVersion;
|
||||||
|
typedef QSharedPointer<ForgeVersion> ForgeVersionPtr;
|
||||||
|
|
||||||
|
struct ForgeVersion : public BaseVersion
|
||||||
|
{
|
||||||
|
virtual QString descriptor()
|
||||||
|
{
|
||||||
|
return filename;
|
||||||
|
};
|
||||||
|
virtual QString name()
|
||||||
|
{
|
||||||
|
return "Forge " + jobbuildver;
|
||||||
|
};
|
||||||
|
virtual QString typeString() const
|
||||||
|
{
|
||||||
|
if(installer_url.isEmpty())
|
||||||
|
return "Universal";
|
||||||
|
else
|
||||||
|
return "Installer";
|
||||||
|
};
|
||||||
|
|
||||||
|
int m_buildnr = 0;
|
||||||
|
QString universal_url;
|
||||||
|
QString changelog_url;
|
||||||
|
QString installer_url;
|
||||||
|
QString jobbuildver;
|
||||||
|
QString mcver;
|
||||||
|
QString filename;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ForgeVersionList : public BaseVersionList
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
friend class ForgeListLoadTask;
|
||||||
|
|
||||||
|
explicit ForgeVersionList(QObject *parent = 0);
|
||||||
|
|
||||||
|
virtual Task *getLoadTask();
|
||||||
|
virtual bool isLoaded();
|
||||||
|
virtual const BaseVersionPtr at(int i) const;
|
||||||
|
virtual int count() const;
|
||||||
|
virtual void sort();
|
||||||
|
|
||||||
|
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<BaseVersionPtr> m_vlist;
|
||||||
|
|
||||||
|
bool m_loaded;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
virtual void updateListData(QList<BaseVersionPtr > versions);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ForgeListLoadTask : public Task
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ForgeListLoadTask(ForgeVersionList *vlist);
|
||||||
|
|
||||||
|
virtual void executeTask();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void list_downloaded();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
DownloadJobPtr listJob;
|
||||||
|
ForgeVersionList *m_list;
|
||||||
|
};
|
@ -24,14 +24,6 @@
|
|||||||
|
|
||||||
#define RSS_URL "http://sourceforge.net/api/file/index/project-id/58488/mtime/desc/rss"
|
#define RSS_URL "http://sourceforge.net/api/file/index/project-id/58488/mtime/desc/rss"
|
||||||
|
|
||||||
LWJGLVersionList mainVersionList;
|
|
||||||
|
|
||||||
LWJGLVersionList &LWJGLVersionList::get()
|
|
||||||
{
|
|
||||||
return mainVersionList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LWJGLVersionList::LWJGLVersionList(QObject *parent) :
|
LWJGLVersionList::LWJGLVersionList(QObject *parent) :
|
||||||
QAbstractListModel(parent)
|
QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
|
@ -53,8 +53,6 @@ class LWJGLVersionList : public QAbstractListModel
|
|||||||
public:
|
public:
|
||||||
explicit LWJGLVersionList(QObject *parent = 0);
|
explicit LWJGLVersionList(QObject *parent = 0);
|
||||||
|
|
||||||
static LWJGLVersionList &get();
|
|
||||||
|
|
||||||
bool isLoaded() { return m_vlist.length() > 0; }
|
bool isLoaded() { return m_vlist.length() > 0; }
|
||||||
|
|
||||||
const PtrLWJGLVersion getVersion(const QString &versionName);
|
const PtrLWJGLVersion getVersion(const QString &versionName);
|
||||||
|
@ -34,10 +34,8 @@
|
|||||||
#define ASSETS_URLBASE "http://assets.minecraft.net/"
|
#define ASSETS_URLBASE "http://assets.minecraft.net/"
|
||||||
#define MCN_URLBASE "http://sonicrules.org/mcnweb.py"
|
#define MCN_URLBASE "http://sonicrules.org/mcnweb.py"
|
||||||
|
|
||||||
MinecraftVersionList mcVList;
|
|
||||||
|
|
||||||
MinecraftVersionList::MinecraftVersionList(QObject *parent) :
|
MinecraftVersionList::MinecraftVersionList(QObject *parent) :
|
||||||
InstVersionList(parent)
|
BaseVersionList(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -52,7 +50,7 @@ bool MinecraftVersionList::isLoaded()
|
|||||||
return m_loaded;
|
return m_loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
const InstVersionPtr MinecraftVersionList::at(int i) const
|
const BaseVersionPtr MinecraftVersionList::at(int i) const
|
||||||
{
|
{
|
||||||
return m_vlist.at(i);
|
return m_vlist.at(i);
|
||||||
}
|
}
|
||||||
@ -62,11 +60,11 @@ int MinecraftVersionList::count() const
|
|||||||
return m_vlist.count();
|
return m_vlist.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmpVersions(InstVersionPtr first, InstVersionPtr second)
|
bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second)
|
||||||
{
|
{
|
||||||
const InstVersion & left = *first;
|
auto left = first.dynamicCast<MinecraftVersion>();
|
||||||
const InstVersion & right = *second;
|
auto right = second.dynamicCast<MinecraftVersion>();
|
||||||
return left > right;
|
return left->timestamp > right->timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftVersionList::sort()
|
void MinecraftVersionList::sort()
|
||||||
@ -76,7 +74,7 @@ void MinecraftVersionList::sort()
|
|||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
InstVersionPtr MinecraftVersionList::getLatestStable() const
|
BaseVersionPtr MinecraftVersionList::getLatestStable() const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_vlist.length(); i++)
|
for (int i = 0; i < m_vlist.length(); i++)
|
||||||
{
|
{
|
||||||
@ -86,15 +84,10 @@ InstVersionPtr MinecraftVersionList::getLatestStable() const
|
|||||||
return m_vlist.at(i);
|
return m_vlist.at(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return InstVersionPtr();
|
return BaseVersionPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
MinecraftVersionList &MinecraftVersionList::getMainList()
|
void MinecraftVersionList::updateListData(QList<BaseVersionPtr > versions)
|
||||||
{
|
|
||||||
return mcVList;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MinecraftVersionList::updateListData(QList<InstVersionPtr > versions)
|
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_vlist = versions;
|
m_vlist = versions;
|
||||||
@ -214,7 +207,7 @@ void MCVListLoadTask::list_downloaded()
|
|||||||
}
|
}
|
||||||
QJsonArray versions = root.value("versions").toArray();
|
QJsonArray versions = root.value("versions").toArray();
|
||||||
|
|
||||||
QList<InstVersionPtr > tempList;
|
QList<BaseVersionPtr > tempList;
|
||||||
for (int i = 0; i < versions.count(); i++)
|
for (int i = 0; i < versions.count(); i++)
|
||||||
{
|
{
|
||||||
bool is_snapshot = false;
|
bool is_snapshot = false;
|
||||||
@ -280,7 +273,7 @@ void MCVListLoadTask::list_downloaded()
|
|||||||
|
|
||||||
// Now, we construct the version object and add it to the list.
|
// Now, we construct the version object and add it to the list.
|
||||||
QSharedPointer<MinecraftVersion> mcVersion(new MinecraftVersion());
|
QSharedPointer<MinecraftVersion> mcVersion(new MinecraftVersion());
|
||||||
mcVersion->name = mcVersion->descriptor = versionID;
|
mcVersion->m_name = mcVersion->m_descriptor = versionID;
|
||||||
mcVersion->timestamp = versionTime.toMSecsSinceEpoch();
|
mcVersion->timestamp = versionTime.toMSecsSinceEpoch();
|
||||||
mcVersion->download_url = dlUrl;
|
mcVersion->download_url = dlUrl;
|
||||||
mcVersion->is_latest = is_latest;
|
mcVersion->is_latest = is_latest;
|
||||||
@ -293,8 +286,3 @@ void MCVListLoadTask::list_downloaded()
|
|||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: we should have a local cache of the version list and a local cache of version data
|
|
||||||
bool MCVListLoadTask::loadFromVList()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
@ -20,14 +20,14 @@
|
|||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
|
||||||
#include "InstVersionList.h"
|
#include "BaseVersionList.h"
|
||||||
#include "logic/tasks/Task.h"
|
#include "logic/tasks/Task.h"
|
||||||
#include "logic/MinecraftVersion.h"
|
#include "logic/MinecraftVersion.h"
|
||||||
|
|
||||||
class MCVListLoadTask;
|
class MCVListLoadTask;
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
|
||||||
class MinecraftVersionList : public InstVersionList
|
class MinecraftVersionList : public BaseVersionList
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -37,25 +37,19 @@ public:
|
|||||||
|
|
||||||
virtual Task *getLoadTask();
|
virtual Task *getLoadTask();
|
||||||
virtual bool isLoaded();
|
virtual bool isLoaded();
|
||||||
virtual const InstVersionPtr at(int i) const;
|
virtual const BaseVersionPtr at(int i) const;
|
||||||
virtual int count() const;
|
virtual int count() const;
|
||||||
virtual void sort();
|
virtual void sort();
|
||||||
|
|
||||||
virtual InstVersionPtr getLatestStable() const;
|
virtual BaseVersionPtr getLatestStable() const;
|
||||||
|
|
||||||
/*!
|
|
||||||
* Gets the main version list instance.
|
|
||||||
*/
|
|
||||||
static MinecraftVersionList &getMainList();
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<InstVersionPtr > m_vlist;
|
QList<BaseVersionPtr> m_vlist;
|
||||||
|
|
||||||
bool m_loaded;
|
bool m_loaded;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void updateListData(QList<InstVersionPtr > versions);
|
virtual void updateListData(QList<BaseVersionPtr> versions);
|
||||||
};
|
};
|
||||||
|
|
||||||
class MCVListLoadTask : public Task
|
class MCVListLoadTask : public Task
|
||||||
@ -72,9 +66,6 @@ protected slots:
|
|||||||
void list_downloaded();
|
void list_downloaded();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Loads versions from Mojang's official version list.
|
|
||||||
bool loadFromVList();
|
|
||||||
|
|
||||||
QNetworkReply *vlistReply;
|
QNetworkReply *vlistReply;
|
||||||
MinecraftVersionList *m_list;
|
MinecraftVersionList *m_list;
|
||||||
MinecraftVersion *m_currentStable;
|
MinecraftVersion *m_currentStable;
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include "ByteArrayDownload.h"
|
#include "ByteArrayDownload.h"
|
||||||
#include "CacheDownload.h"
|
#include "CacheDownload.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
ByteArrayDownloadPtr DownloadJob::add ( QUrl url )
|
ByteArrayDownloadPtr DownloadJob::add ( QUrl url )
|
||||||
{
|
{
|
||||||
ByteArrayDownloadPtr ptr (new ByteArrayDownload(url));
|
ByteArrayDownloadPtr ptr (new ByteArrayDownload(url));
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "FileDownload.h"
|
#include "FileDownload.h"
|
||||||
#include "CacheDownload.h"
|
#include "CacheDownload.h"
|
||||||
#include "HttpMetaCache.h"
|
#include "HttpMetaCache.h"
|
||||||
|
#include "logic/tasks/ProgressProvider.h"
|
||||||
|
|
||||||
class DownloadJob;
|
class DownloadJob;
|
||||||
typedef QSharedPointer<DownloadJob> DownloadJobPtr;
|
typedef QSharedPointer<DownloadJob> DownloadJobPtr;
|
||||||
@ -12,12 +13,12 @@ typedef QSharedPointer<DownloadJob> DownloadJobPtr;
|
|||||||
/**
|
/**
|
||||||
* A single file for the downloader/cache to process.
|
* A single file for the downloader/cache to process.
|
||||||
*/
|
*/
|
||||||
class DownloadJob : public QObject
|
class DownloadJob : public ProgressProvider
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DownloadJob(QString job_name)
|
explicit DownloadJob(QString job_name)
|
||||||
:QObject(), m_job_name(job_name){};
|
:ProgressProvider(), m_job_name(job_name){};
|
||||||
|
|
||||||
ByteArrayDownloadPtr add(QUrl url);
|
ByteArrayDownloadPtr add(QUrl url);
|
||||||
FileDownloadPtr add(QUrl url, QString rel_target_path);
|
FileDownloadPtr add(QUrl url, QString rel_target_path);
|
||||||
@ -37,6 +38,19 @@ public:
|
|||||||
{
|
{
|
||||||
return downloads.size();
|
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:
|
signals:
|
||||||
void started();
|
void started();
|
||||||
void progress(qint64 current, qint64 total);
|
void progress(qint64 current, qint64 total);
|
||||||
@ -56,5 +70,6 @@ private:
|
|||||||
qint64 total_progress = 0;
|
qint64 total_progress = 0;
|
||||||
int num_succeeded = 0;
|
int num_succeeded = 0;
|
||||||
int num_failed = 0;
|
int num_failed = 0;
|
||||||
|
bool m_running = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
20
logic/tasks/ProgressProvider.h
Normal file
20
logic/tasks/ProgressProvider.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <QObject>
|
||||||
|
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;
|
||||||
|
};
|
@ -16,70 +16,56 @@
|
|||||||
#include "Task.h"
|
#include "Task.h"
|
||||||
|
|
||||||
Task::Task(QObject *parent) :
|
Task::Task(QObject *parent) :
|
||||||
QObject(parent)
|
ProgressProvider(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Task::getStatus() const
|
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;
|
m_status = new_status;
|
||||||
emitStatusChange(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;
|
current = m_progress;
|
||||||
emitProgressChange(progress);
|
total = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Task::startTask()
|
|
||||||
{
|
|
||||||
emitStarted();
|
|
||||||
executeTask();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Task::emitStarted()
|
void Task::start()
|
||||||
{
|
{
|
||||||
running = true;
|
m_running = true;
|
||||||
emit started();
|
emit started();
|
||||||
|
executeTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Task::emitFailed(QString reason)
|
void Task::emitFailed(QString reason)
|
||||||
{
|
{
|
||||||
running = false;
|
m_running = false;
|
||||||
emit failed(reason);
|
emit failed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Task::emitSucceeded()
|
void Task::emitSucceeded()
|
||||||
{
|
{
|
||||||
running = false;
|
m_running = false;
|
||||||
emit succeeded();
|
emit succeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Task::isRunning() const
|
bool Task::isRunning() const
|
||||||
{
|
{
|
||||||
return running;
|
return m_running;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Task::emitStatusChange(const QString &status)
|
|
||||||
{
|
|
||||||
emit statusChanged(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Task::emitProgressChange(int progress)
|
|
||||||
{
|
|
||||||
emit progressChanged(progress);
|
|
||||||
}
|
}
|
||||||
|
@ -13,53 +13,37 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TASK_H
|
#pragma once
|
||||||
#define TASK_H
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include "ProgressProvider.h"
|
||||||
|
|
||||||
class Task : public QObject
|
class Task : public ProgressProvider
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Task(QObject *parent = 0);
|
explicit Task(QObject *parent = 0);
|
||||||
|
|
||||||
QString getStatus() const;
|
virtual QString getStatus() const;
|
||||||
int getProgress() const;
|
virtual void getProgress(qint64& current, qint64& total);
|
||||||
bool isRunning() const;
|
virtual bool isRunning() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void startTask();
|
virtual void start();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void executeTask() = 0;
|
||||||
|
|
||||||
|
virtual void emitSucceeded();
|
||||||
|
virtual void emitFailed(QString reason);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void setStatus(const QString& status);
|
void setStatus(const QString& status);
|
||||||
void setProgress(int progress);
|
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);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void executeTask() = 0;
|
QString m_status;
|
||||||
|
int m_progress = 0;
|
||||||
virtual void emitStarted();
|
bool m_running = false;
|
||||||
virtual void emitFailed(QString reason);
|
|
||||||
virtual void emitSucceeded();
|
|
||||||
|
|
||||||
virtual void emitStatusChange(const QString &status);
|
|
||||||
virtual void emitProgressChange(int progress);
|
|
||||||
|
|
||||||
QString status;
|
|
||||||
int progress;
|
|
||||||
bool running = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TASK_H
|
|
||||||
|
Loading…
Reference in New Issue
Block a user