Merge branch 'feature_onesix_forge' into develop
This commit is contained in:
commit
1bed5e4023
24
.clang-format
Normal file
24
.clang-format
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
UseTab: true
|
||||||
|
IndentWidth: 4
|
||||||
|
TabWidth: 4
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentFunctionDeclarationAfterType: false
|
||||||
|
NamespaceIndentation: None
|
||||||
|
|
||||||
|
BreakBeforeBraces: Allman
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
ColumnLimit: 96
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
|
||||||
|
Standard: Cpp11
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpaceAfterControlStatementKeyword: true
|
||||||
|
|
||||||
|
AlignTrailingComments: true
|
||||||
|
SpacesBeforeTrailingComments: 1
|
148
CMakeLists.txt
148
CMakeLists.txt
@ -147,165 +147,143 @@ ADD_DEFINITIONS(-DLIBGROUPVIEW_STATIC)
|
|||||||
|
|
||||||
################################ FILES ################################
|
################################ FILES ################################
|
||||||
|
|
||||||
######## Headers ########
|
######## Sources and headers ########
|
||||||
SET(MULTIMC_HEADERS
|
SET(MULTIMC_SOURCES
|
||||||
|
# Application base
|
||||||
MultiMC.h
|
MultiMC.h
|
||||||
|
MultiMC.cpp
|
||||||
MultiMCVersion.h
|
MultiMCVersion.h
|
||||||
|
|
||||||
|
# GUI
|
||||||
gui/mainwindow.h
|
gui/mainwindow.h
|
||||||
|
gui/mainwindow.cpp
|
||||||
gui/settingsdialog.h
|
gui/settingsdialog.h
|
||||||
|
gui/settingsdialog.cpp
|
||||||
gui/newinstancedialog.h
|
gui/newinstancedialog.h
|
||||||
|
gui/newinstancedialog.cpp
|
||||||
gui/logindialog.h
|
gui/logindialog.h
|
||||||
|
gui/logindialog.cpp
|
||||||
gui/ProgressDialog.h
|
gui/ProgressDialog.h
|
||||||
|
gui/ProgressDialog.cpp
|
||||||
gui/aboutdialog.h
|
gui/aboutdialog.h
|
||||||
|
gui/aboutdialog.cpp
|
||||||
gui/consolewindow.h
|
gui/consolewindow.h
|
||||||
|
gui/consolewindow.cpp
|
||||||
gui/instancedelegate.h
|
gui/instancedelegate.h
|
||||||
|
gui/instancedelegate.cpp
|
||||||
gui/versionselectdialog.h
|
gui/versionselectdialog.h
|
||||||
|
gui/versionselectdialog.cpp
|
||||||
gui/lwjglselectdialog.h
|
gui/lwjglselectdialog.h
|
||||||
|
gui/lwjglselectdialog.cpp
|
||||||
gui/instancesettings.h
|
gui/instancesettings.h
|
||||||
|
gui/instancesettings.cpp
|
||||||
gui/IconPickerDialog.h
|
gui/IconPickerDialog.h
|
||||||
|
gui/IconPickerDialog.cpp
|
||||||
gui/LegacyModEditDialog.h
|
gui/LegacyModEditDialog.h
|
||||||
|
gui/LegacyModEditDialog.cpp
|
||||||
gui/OneSixModEditDialog.h
|
gui/OneSixModEditDialog.h
|
||||||
|
gui/OneSixModEditDialog.cpp
|
||||||
gui/ModEditDialogCommon.h
|
gui/ModEditDialogCommon.h
|
||||||
|
gui/ModEditDialogCommon.cpp
|
||||||
gui/ModListView.h
|
gui/ModListView.h
|
||||||
|
gui/ModListView.cpp
|
||||||
gui/LabeledToolButton.h
|
gui/LabeledToolButton.h
|
||||||
|
gui/LabeledToolButton.cpp
|
||||||
gui/EditNotesDialog.h
|
gui/EditNotesDialog.h
|
||||||
|
gui/EditNotesDialog.cpp
|
||||||
|
|
||||||
# Base classes and infrastructure
|
# Base classes and infrastructure
|
||||||
logic/BaseVersion.h
|
logic/BaseVersion.h
|
||||||
logic/MinecraftVersion.h
|
logic/MinecraftVersion.h
|
||||||
logic/InstanceFactory.h
|
logic/InstanceFactory.h
|
||||||
|
logic/InstanceFactory.cpp
|
||||||
logic/BaseUpdate.h
|
logic/BaseUpdate.h
|
||||||
|
logic/BaseUpdate.cpp
|
||||||
logic/BaseInstance.h
|
logic/BaseInstance.h
|
||||||
|
logic/BaseInstance.cpp
|
||||||
logic/BaseInstance_p.h
|
logic/BaseInstance_p.h
|
||||||
|
|
||||||
logic/MinecraftProcess.h
|
logic/MinecraftProcess.h
|
||||||
|
logic/MinecraftProcess.cpp
|
||||||
logic/Mod.h
|
logic/Mod.h
|
||||||
|
logic/Mod.cpp
|
||||||
logic/ModList.h
|
logic/ModList.h
|
||||||
|
logic/ModList.cpp
|
||||||
|
|
||||||
# Basic instance launcher for starting from terminal
|
# Basic instance launcher for starting from terminal
|
||||||
logic/InstanceLauncher.h
|
logic/InstanceLauncher.h
|
||||||
|
logic/InstanceLauncher.cpp
|
||||||
|
|
||||||
# network stuffs
|
# network stuffs
|
||||||
logic/net/Download.h
|
logic/net/Download.h
|
||||||
logic/net/FileDownload.h
|
logic/net/FileDownload.h
|
||||||
logic/net/ByteArrayDownload.h
|
|
||||||
logic/net/CacheDownload.h
|
|
||||||
logic/net/DownloadJob.h
|
|
||||||
logic/net/HttpMetaCache.h
|
|
||||||
|
|
||||||
# legacy instances
|
|
||||||
logic/LegacyInstance.h
|
|
||||||
logic/LegacyInstance_p.h
|
|
||||||
logic/LegacyUpdate.h
|
|
||||||
logic/LegacyForge.h
|
|
||||||
|
|
||||||
# 1.6 instances
|
|
||||||
logic/OneSixAssets.h
|
|
||||||
logic/OneSixInstance.h
|
|
||||||
logic/OneSixInstance_p.h
|
|
||||||
logic/OneSixUpdate.h
|
|
||||||
logic/OneSixVersion.h
|
|
||||||
logic/OneSixLibrary.h
|
|
||||||
logic/OneSixRule.h
|
|
||||||
logic/VersionFactory.h
|
|
||||||
logic/OpSys.h
|
|
||||||
|
|
||||||
|
|
||||||
# Nostalgia
|
|
||||||
logic/NostalgiaInstance.h
|
|
||||||
|
|
||||||
# Lists
|
|
||||||
logic/lists/InstanceList.h
|
|
||||||
logic/lists/IconList.h
|
|
||||||
logic/lists/BaseVersionList.h
|
|
||||||
logic/lists/MinecraftVersionList.h
|
|
||||||
logic/lists/LwjglVersionList.h
|
|
||||||
logic/lists/ForgeVersionList.h
|
|
||||||
|
|
||||||
# misc model/view
|
|
||||||
logic/EnabledItemFilter.h
|
|
||||||
|
|
||||||
# Tasks
|
|
||||||
logic/tasks/Task.h
|
|
||||||
logic/tasks/LoginTask.h
|
|
||||||
logic/tasks/ProgressProvider.h
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
######## Sources ########
|
|
||||||
SET(MULTIMC_SOURCES
|
|
||||||
MultiMC.cpp
|
|
||||||
|
|
||||||
gui/mainwindow.cpp
|
|
||||||
gui/settingsdialog.cpp
|
|
||||||
gui/newinstancedialog.cpp
|
|
||||||
gui/logindialog.cpp
|
|
||||||
gui/aboutdialog.cpp
|
|
||||||
gui/consolewindow.cpp
|
|
||||||
gui/instancedelegate.cpp
|
|
||||||
gui/versionselectdialog.cpp
|
|
||||||
gui/lwjglselectdialog.cpp
|
|
||||||
gui/instancesettings.cpp
|
|
||||||
|
|
||||||
gui/ProgressDialog.cpp
|
|
||||||
gui/IconPickerDialog.cpp
|
|
||||||
gui/LegacyModEditDialog.cpp
|
|
||||||
gui/OneSixModEditDialog.cpp
|
|
||||||
gui/ModEditDialogCommon.cpp
|
|
||||||
gui/ModListView.cpp
|
|
||||||
gui/LabeledToolButton.cpp
|
|
||||||
gui/EditNotesDialog.cpp
|
|
||||||
|
|
||||||
# Base classes and infrastructure
|
|
||||||
logic/InstanceFactory.cpp
|
|
||||||
logic/BaseUpdate.cpp
|
|
||||||
logic/BaseInstance.cpp
|
|
||||||
logic/MinecraftProcess.cpp
|
|
||||||
logic/Mod.cpp
|
|
||||||
logic/ModList.cpp
|
|
||||||
|
|
||||||
# Basic instance launcher for starting from terminal
|
|
||||||
logic/InstanceLauncher.cpp
|
|
||||||
|
|
||||||
# network stuffs - to be moved into a depend lib ~_~
|
|
||||||
logic/net/FileDownload.cpp
|
logic/net/FileDownload.cpp
|
||||||
|
logic/net/ByteArrayDownload.h
|
||||||
logic/net/ByteArrayDownload.cpp
|
logic/net/ByteArrayDownload.cpp
|
||||||
|
logic/net/CacheDownload.h
|
||||||
logic/net/CacheDownload.cpp
|
logic/net/CacheDownload.cpp
|
||||||
|
logic/net/DownloadJob.h
|
||||||
logic/net/DownloadJob.cpp
|
logic/net/DownloadJob.cpp
|
||||||
|
logic/net/HttpMetaCache.h
|
||||||
logic/net/HttpMetaCache.cpp
|
logic/net/HttpMetaCache.cpp
|
||||||
|
|
||||||
# legacy instances
|
# legacy instances
|
||||||
|
logic/LegacyInstance.h
|
||||||
logic/LegacyInstance.cpp
|
logic/LegacyInstance.cpp
|
||||||
|
logic/LegacyInstance_p.h
|
||||||
|
logic/LegacyUpdate.h
|
||||||
logic/LegacyUpdate.cpp
|
logic/LegacyUpdate.cpp
|
||||||
|
logic/LegacyForge.h
|
||||||
logic/LegacyForge.cpp
|
logic/LegacyForge.cpp
|
||||||
|
|
||||||
# 1.6 instances
|
# 1.6 instances
|
||||||
|
logic/OneSixAssets.h
|
||||||
logic/OneSixAssets.cpp
|
logic/OneSixAssets.cpp
|
||||||
|
logic/OneSixInstance.h
|
||||||
logic/OneSixInstance.cpp
|
logic/OneSixInstance.cpp
|
||||||
|
logic/OneSixInstance_p.h
|
||||||
|
logic/OneSixUpdate.h
|
||||||
logic/OneSixUpdate.cpp
|
logic/OneSixUpdate.cpp
|
||||||
|
logic/OneSixVersion.h
|
||||||
logic/OneSixVersion.cpp
|
logic/OneSixVersion.cpp
|
||||||
|
logic/OneSixLibrary.h
|
||||||
logic/OneSixLibrary.cpp
|
logic/OneSixLibrary.cpp
|
||||||
|
logic/OneSixRule.h
|
||||||
logic/OneSixRule.cpp
|
logic/OneSixRule.cpp
|
||||||
logic/VersionFactory.cpp
|
logic/OpSys.h
|
||||||
logic/OpSys.cpp
|
logic/OpSys.cpp
|
||||||
|
logic/ForgeInstaller.h
|
||||||
|
logic/ForgeInstaller.cpp
|
||||||
|
|
||||||
# Nostalgia
|
# Nostalgia
|
||||||
|
logic/NostalgiaInstance.h
|
||||||
logic/NostalgiaInstance.cpp
|
logic/NostalgiaInstance.cpp
|
||||||
|
|
||||||
# Lists
|
# Lists
|
||||||
|
logic/lists/InstanceList.h
|
||||||
logic/lists/InstanceList.cpp
|
logic/lists/InstanceList.cpp
|
||||||
|
logic/lists/IconList.h
|
||||||
logic/lists/IconList.cpp
|
logic/lists/IconList.cpp
|
||||||
|
logic/lists/BaseVersionList.h
|
||||||
logic/lists/BaseVersionList.cpp
|
logic/lists/BaseVersionList.cpp
|
||||||
|
logic/lists/MinecraftVersionList.h
|
||||||
logic/lists/MinecraftVersionList.cpp
|
logic/lists/MinecraftVersionList.cpp
|
||||||
|
logic/lists/LwjglVersionList.h
|
||||||
logic/lists/LwjglVersionList.cpp
|
logic/lists/LwjglVersionList.cpp
|
||||||
|
logic/lists/ForgeVersionList.h
|
||||||
logic/lists/ForgeVersionList.cpp
|
logic/lists/ForgeVersionList.cpp
|
||||||
|
|
||||||
# misc model/view
|
# misc model/view
|
||||||
|
logic/EnabledItemFilter.h
|
||||||
logic/EnabledItemFilter.cpp
|
logic/EnabledItemFilter.cpp
|
||||||
|
|
||||||
# Tasks
|
# Tasks
|
||||||
|
logic/tasks/ProgressProvider.h
|
||||||
|
logic/tasks/Task.h
|
||||||
logic/tasks/Task.cpp
|
logic/tasks/Task.cpp
|
||||||
|
logic/tasks/LoginTask.h
|
||||||
logic/tasks/LoginTask.cpp
|
logic/tasks/LoginTask.cpp
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -328,7 +306,7 @@ gui/OneSixModEditDialog.ui
|
|||||||
gui/EditNotesDialog.ui
|
gui/EditNotesDialog.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
set (FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${MULTIMC_SOURCES} ${MULTIMC_UIS} ${MULTIMC_HEADERS})
|
set (FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${MULTIMC_SOURCES} ${MULTIMC_UIS})
|
||||||
|
|
||||||
|
|
||||||
######## Windows resource files ########
|
######## Windows resource files ########
|
||||||
@ -362,7 +340,7 @@ QT5_ADD_RESOURCES(MULTIMC_QRC multimc.qrc)
|
|||||||
|
|
||||||
# Add executable
|
# Add executable
|
||||||
ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32
|
ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32
|
||||||
${MULTIMC_SOURCES} ${MULTIMC_HEADERS} ${MULTIMC_UI} ${MULTIMC_QRC} ${MULTIMC_RCS})
|
${MULTIMC_SOURCES} ${MULTIMC_UI} ${MULTIMC_QRC} ${MULTIMC_RCS})
|
||||||
|
|
||||||
# Link
|
# Link
|
||||||
QT5_USE_MODULES(MultiMC Widgets Network Xml)
|
QT5_USE_MODULES(MultiMC Widgets Network Xml)
|
||||||
|
68
MultiMC.cpp
68
MultiMC.cpp
@ -123,7 +123,7 @@ MultiMC::MultiMC ( int& argc, char** argv )
|
|||||||
initGlobalSettings();
|
initGlobalSettings();
|
||||||
|
|
||||||
// and instances
|
// and instances
|
||||||
m_instances = new InstanceList(m_settings->get("InstanceDir").toString(),this);
|
m_instances.reset(new InstanceList(m_settings->get("InstanceDir").toString(),this));
|
||||||
std::cout << "Loading Instances..." << std::endl;
|
std::cout << "Loading Instances..." << std::endl;
|
||||||
m_instances->loadList();
|
m_instances->loadList();
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ MultiMC::MultiMC ( int& argc, char** argv )
|
|||||||
initHttpMetaCache();
|
initHttpMetaCache();
|
||||||
|
|
||||||
// create the global network manager
|
// create the global network manager
|
||||||
m_qnam = new QNetworkAccessManager(this);
|
m_qnam.reset(new QNetworkAccessManager(this));
|
||||||
|
|
||||||
// Register meta types.
|
// Register meta types.
|
||||||
qRegisterMetaType<LoginResponse>("LoginResponse");
|
qRegisterMetaType<LoginResponse>("LoginResponse");
|
||||||
@ -152,80 +152,59 @@ MultiMC::~MultiMC()
|
|||||||
{
|
{
|
||||||
if(m_mmc_translator)
|
if(m_mmc_translator)
|
||||||
{
|
{
|
||||||
removeTranslator(m_mmc_translator);
|
removeTranslator(m_mmc_translator.data());
|
||||||
delete m_mmc_translator;
|
|
||||||
m_mmc_translator = nullptr;
|
|
||||||
}
|
}
|
||||||
if(m_qt_translator)
|
if(m_qt_translator)
|
||||||
{
|
{
|
||||||
removeTranslator(m_qt_translator);
|
removeTranslator(m_qt_translator.data());
|
||||||
delete m_qt_translator;
|
|
||||||
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_metacache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiMC::initTranslations()
|
void MultiMC::initTranslations()
|
||||||
{
|
{
|
||||||
m_qt_translator = new QTranslator();
|
m_qt_translator.reset(new QTranslator());
|
||||||
if(m_qt_translator->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
if(m_qt_translator->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||||
{
|
{
|
||||||
std::cout
|
std::cout
|
||||||
<< "Loading Qt Language File for "
|
<< "Loading Qt Language File for "
|
||||||
<< QLocale::system().name().toLocal8Bit().constData()
|
<< QLocale::system().name().toLocal8Bit().constData()
|
||||||
<< "...";
|
<< "...";
|
||||||
if(!installTranslator(m_qt_translator))
|
if(!installTranslator(m_qt_translator.data()))
|
||||||
{
|
{
|
||||||
std::cout << " failed.";
|
std::cout << " failed.";
|
||||||
|
m_qt_translator.reset();
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete m_qt_translator;
|
m_qt_translator.reset();
|
||||||
m_qt_translator = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mmc_translator = new QTranslator();
|
m_mmc_translator.reset(new QTranslator());
|
||||||
if(m_mmc_translator->load("mmc_" + QLocale::system().name(), QDir("translations").absolutePath()))
|
if(m_mmc_translator->load("mmc_" + QLocale::system().name(), QDir("translations").absolutePath()))
|
||||||
{
|
{
|
||||||
std::cout
|
std::cout
|
||||||
<< "Loading MMC Language File for "
|
<< "Loading MMC Language File for "
|
||||||
<< QLocale::system().name().toLocal8Bit().constData()
|
<< QLocale::system().name().toLocal8Bit().constData()
|
||||||
<< "...";
|
<< "...";
|
||||||
if(!installTranslator(m_mmc_translator))
|
if(!installTranslator(m_mmc_translator.data()))
|
||||||
{
|
{
|
||||||
std::cout << " failed.";
|
std::cout << " failed.";
|
||||||
|
m_mmc_translator.reset();
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete m_mmc_translator;
|
m_mmc_translator.reset();
|
||||||
m_mmc_translator = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MultiMC::initGlobalSettings()
|
void MultiMC::initGlobalSettings()
|
||||||
{
|
{
|
||||||
m_settings = new INISettingsObject("multimc.cfg", this);
|
m_settings.reset(new INISettingsObject("multimc.cfg", this));
|
||||||
// Updates
|
// Updates
|
||||||
m_settings->registerSetting(new Setting("UseDevBuilds", false));
|
m_settings->registerSetting(new Setting("UseDevBuilds", false));
|
||||||
m_settings->registerSetting(new Setting("AutoUpdate", true));
|
m_settings->registerSetting(new Setting("AutoUpdate", true));
|
||||||
@ -278,7 +257,7 @@ void MultiMC::initGlobalSettings()
|
|||||||
|
|
||||||
void MultiMC::initHttpMetaCache()
|
void MultiMC::initHttpMetaCache()
|
||||||
{
|
{
|
||||||
m_metacache = new HttpMetaCache("metacache");
|
m_metacache.reset(new HttpMetaCache("metacache"));
|
||||||
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());
|
||||||
@ -287,37 +266,38 @@ void MultiMC::initHttpMetaCache()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IconList* MultiMC::icons()
|
QSharedPointer<IconList> MultiMC::icons()
|
||||||
{
|
{
|
||||||
if ( !m_icons )
|
if ( !m_icons )
|
||||||
{
|
{
|
||||||
m_icons = new IconList;
|
m_icons.reset(new IconList);
|
||||||
}
|
}
|
||||||
return m_icons;
|
return m_icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWJGLVersionList* MultiMC::lwjgllist()
|
QSharedPointer<LWJGLVersionList> MultiMC::lwjgllist()
|
||||||
{
|
{
|
||||||
if ( !m_lwjgllist )
|
if ( !m_lwjgllist )
|
||||||
{
|
{
|
||||||
m_lwjgllist = new LWJGLVersionList();
|
m_lwjgllist.reset(new LWJGLVersionList());
|
||||||
}
|
}
|
||||||
return m_lwjgllist;
|
return m_lwjgllist;
|
||||||
}
|
}
|
||||||
ForgeVersionList* MultiMC::forgelist()
|
|
||||||
|
QSharedPointer<ForgeVersionList> MultiMC::forgelist()
|
||||||
{
|
{
|
||||||
if ( !m_forgelist )
|
if ( !m_forgelist )
|
||||||
{
|
{
|
||||||
m_forgelist = new ForgeVersionList();
|
m_forgelist.reset(new ForgeVersionList());
|
||||||
}
|
}
|
||||||
return m_forgelist;
|
return m_forgelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
MinecraftVersionList* MultiMC::minecraftlist()
|
QSharedPointer<MinecraftVersionList> MultiMC::minecraftlist()
|
||||||
{
|
{
|
||||||
if ( !m_minecraftlist )
|
if ( !m_minecraftlist )
|
||||||
{
|
{
|
||||||
m_minecraftlist = new MinecraftVersionList();
|
m_minecraftlist.reset(new MinecraftVersionList());
|
||||||
}
|
}
|
||||||
return m_minecraftlist;
|
return m_minecraftlist;
|
||||||
}
|
}
|
||||||
@ -346,3 +326,5 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "MultiMC.moc"
|
#include "MultiMC.moc"
|
||||||
|
|
||||||
|
|
||||||
|
39
MultiMC.h
39
MultiMC.h
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QSharedPointer>
|
||||||
#include "MultiMCVersion.h"
|
#include "MultiMCVersion.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
@ -33,17 +34,17 @@ public:
|
|||||||
MultiMC ( int& argc, char** argv );
|
MultiMC ( int& argc, char** argv );
|
||||||
virtual ~MultiMC();
|
virtual ~MultiMC();
|
||||||
|
|
||||||
SettingsObject * settings()
|
QSharedPointer<SettingsObject> settings()
|
||||||
{
|
{
|
||||||
return m_settings;
|
return m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
InstanceList * instances()
|
QSharedPointer<InstanceList> instances()
|
||||||
{
|
{
|
||||||
return m_instances;
|
return m_instances;
|
||||||
};
|
};
|
||||||
|
|
||||||
IconList * icons();
|
QSharedPointer<IconList> icons();
|
||||||
|
|
||||||
Status status()
|
Status status()
|
||||||
{
|
{
|
||||||
@ -55,21 +56,21 @@ public:
|
|||||||
return m_version;
|
return m_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkAccessManager * qnam()
|
QSharedPointer<QNetworkAccessManager> qnam()
|
||||||
{
|
{
|
||||||
return m_qnam;
|
return m_qnam;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpMetaCache * metacache()
|
QSharedPointer<HttpMetaCache> metacache()
|
||||||
{
|
{
|
||||||
return m_metacache;
|
return m_metacache;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWJGLVersionList * lwjgllist();
|
QSharedPointer<LWJGLVersionList> lwjgllist();
|
||||||
|
|
||||||
ForgeVersionList * forgelist();
|
QSharedPointer<ForgeVersionList> forgelist();
|
||||||
|
|
||||||
MinecraftVersionList * minecraftlist();
|
QSharedPointer<MinecraftVersionList> minecraftlist();
|
||||||
private:
|
private:
|
||||||
void initGlobalSettings();
|
void initGlobalSettings();
|
||||||
|
|
||||||
@ -77,17 +78,17 @@ private:
|
|||||||
|
|
||||||
void initTranslations();
|
void initTranslations();
|
||||||
private:
|
private:
|
||||||
QTranslator * m_qt_translator = nullptr;
|
QSharedPointer<QTranslator> m_qt_translator;
|
||||||
QTranslator * m_mmc_translator = nullptr;
|
QSharedPointer<QTranslator> m_mmc_translator;
|
||||||
SettingsObject * m_settings = nullptr;
|
QSharedPointer<SettingsObject> m_settings;
|
||||||
InstanceList * m_instances = nullptr;
|
QSharedPointer<InstanceList> m_instances;
|
||||||
IconList * m_icons = nullptr;
|
QSharedPointer<IconList> m_icons;
|
||||||
QNetworkAccessManager * m_qnam = nullptr;
|
QSharedPointer<QNetworkAccessManager> m_qnam;
|
||||||
HttpMetaCache * m_metacache = nullptr;
|
QSharedPointer<HttpMetaCache> m_metacache;
|
||||||
Status m_status = MultiMC::Failed;
|
QSharedPointer<LWJGLVersionList> m_lwjgllist;
|
||||||
LWJGLVersionList * m_lwjgllist = nullptr;
|
QSharedPointer<ForgeVersionList> m_forgelist;
|
||||||
ForgeVersionList * m_forgelist = nullptr;
|
QSharedPointer<MinecraftVersionList> m_minecraftlist;
|
||||||
MinecraftVersionList * m_minecraftlist = nullptr;
|
|
||||||
|
|
||||||
|
Status m_status = MultiMC::Failed;
|
||||||
MultiMCVersion m_version = {VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD};
|
MultiMCVersion m_version = {VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD};
|
||||||
};
|
};
|
@ -39,7 +39,7 @@ IconPickerDialog::IconPickerDialog(QWidget *parent) :
|
|||||||
|
|
||||||
contentsWidget->installEventFilter(this);
|
contentsWidget->installEventFilter(this);
|
||||||
|
|
||||||
contentsWidget->setModel(MMC->icons());
|
contentsWidget->setModel(MMC->icons().data());
|
||||||
|
|
||||||
auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"),QDialogButtonBox::ResetRole);
|
auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"),QDialogButtonBox::ResetRole);
|
||||||
auto buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"),QDialogButtonBox::ResetRole);
|
auto buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"),QDialogButtonBox::ResetRole);
|
||||||
@ -119,7 +119,7 @@ void IconPickerDialog::selectionChanged ( QItemSelection selected, QItemSelectio
|
|||||||
|
|
||||||
int IconPickerDialog::exec ( QString selection )
|
int IconPickerDialog::exec ( QString selection )
|
||||||
{
|
{
|
||||||
IconList * list = MMC->icons();
|
auto list = MMC->icons();
|
||||||
auto contentsWidget = ui->iconView;
|
auto contentsWidget = ui->iconView;
|
||||||
selectedIconKey = selection;
|
selectedIconKey = selection;
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ void LegacyModEditDialog::on_addCoreBtn_clicked()
|
|||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_addForgeBtn_clicked()
|
void LegacyModEditDialog::on_addForgeBtn_clicked()
|
||||||
{
|
{
|
||||||
VersionSelectDialog vselect(MMC->forgelist(), this);
|
VersionSelectDialog vselect(MMC->forgelist().data(), this);
|
||||||
vselect.setFilter(1, m_inst->intendedVersionId());
|
vselect.setFilter(1, m_inst->intendedVersionId());
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
if (vselect.exec() && vselect.selectedVersion())
|
||||||
{
|
{
|
||||||
@ -230,7 +230,6 @@ void LegacyModEditDialog::on_addForgeBtn_clicked()
|
|||||||
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
|
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
|
||||||
m_jarmods->startWatching();
|
m_jarmods->startWatching();
|
||||||
}
|
}
|
||||||
//m_selectedInstance->setIntendedVersionId(->descriptor());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_addJarBtn_clicked()
|
void LegacyModEditDialog::on_addJarBtn_clicked()
|
||||||
|
@ -20,29 +20,37 @@
|
|||||||
#include "logic/OneSixVersion.h"
|
#include "logic/OneSixVersion.h"
|
||||||
#include "logic/EnabledItemFilter.h"
|
#include "logic/EnabledItemFilter.h"
|
||||||
#include "logic/lists/ForgeVersionList.h"
|
#include "logic/lists/ForgeVersionList.h"
|
||||||
|
#include <logic/ForgeInstaller.h>
|
||||||
#include "gui/versionselectdialog.h"
|
#include "gui/versionselectdialog.h"
|
||||||
|
#include "ProgressDialog.h"
|
||||||
|
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance * inst, QWidget *parent):
|
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
||||||
m_inst(inst),
|
: m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog)
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::OneSixModEditDialog)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
// libraries!
|
// libraries!
|
||||||
{
|
|
||||||
m_version = m_inst->getFullVersion();
|
|
||||||
|
|
||||||
auto filter = new EnabledItemFilter(this);
|
m_version = m_inst->getFullVersion();
|
||||||
filter->setActive(true);
|
if (m_version)
|
||||||
filter->setSourceModel(m_version.data());
|
{
|
||||||
ui->libraryTreeView->setModel(filter);
|
main_model = new EnabledItemFilter(this);
|
||||||
|
main_model->setActive(true);
|
||||||
|
main_model->setSourceModel(m_version.data());
|
||||||
|
ui->libraryTreeView->setModel(main_model);
|
||||||
ui->libraryTreeView->installEventFilter(this);
|
ui->libraryTreeView->installEventFilter(this);
|
||||||
|
ui->mainClassEdit->setText(m_version->mainClass);
|
||||||
|
updateVersionControls();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disableVersionControls();
|
||||||
}
|
}
|
||||||
// Loader mods
|
// Loader mods
|
||||||
{
|
{
|
||||||
@ -69,16 +77,119 @@ OneSixModEditDialog::~OneSixModEditDialog()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OneSixModEditDialog::on_forgeBtn_clicked()
|
void OneSixModEditDialog::updateVersionControls()
|
||||||
{
|
{
|
||||||
VersionSelectDialog vselect(MMC->forgelist(), this);
|
bool customVersion = m_inst->versionIsCustom();
|
||||||
vselect.setFilter(1, m_inst->currentVersionId());
|
ui->customizeBtn->setEnabled(!customVersion);
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
ui->revertBtn->setEnabled(customVersion);
|
||||||
|
ui->forgeBtn->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneSixModEditDialog::disableVersionControls()
|
||||||
{
|
{
|
||||||
//m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor());
|
ui->customizeBtn->setEnabled(false);
|
||||||
|
ui->revertBtn->setEnabled(false);
|
||||||
|
ui->forgeBtn->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneSixModEditDialog::on_customizeBtn_clicked()
|
||||||
|
{
|
||||||
|
if (m_inst->customizeVersion())
|
||||||
|
{
|
||||||
|
m_version = m_inst->getFullVersion();
|
||||||
|
main_model->setSourceModel(m_version.data());
|
||||||
|
updateVersionControls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OneSixModEditDialog::on_revertBtn_clicked()
|
||||||
|
{
|
||||||
|
auto reply = QMessageBox::question(
|
||||||
|
this, tr("Revert?"), tr("Do you want to revert the "
|
||||||
|
"version of this instance to its original configuration?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (reply == QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
if (m_inst->revertCustomVersion())
|
||||||
|
{
|
||||||
|
m_version = m_inst->getFullVersion();
|
||||||
|
main_model->setSourceModel(m_version.data());
|
||||||
|
updateVersionControls();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||||
|
{
|
||||||
|
VersionSelectDialog vselect(MMC->forgelist().data(), this);
|
||||||
|
vselect.setFilter(1, m_inst->currentVersionId());
|
||||||
|
if (vselect.exec() && vselect.selectedVersion())
|
||||||
|
{
|
||||||
|
if (m_inst->versionIsCustom())
|
||||||
|
{
|
||||||
|
auto reply = QMessageBox::question(
|
||||||
|
this, tr("Revert?"),
|
||||||
|
tr("This will revert any "
|
||||||
|
"changes you did to the version up to this point. Is that "
|
||||||
|
"OK?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (reply == QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
m_inst->revertCustomVersion();
|
||||||
|
m_inst->customizeVersion();
|
||||||
|
{
|
||||||
|
m_version = m_inst->getFullVersion();
|
||||||
|
main_model->setSourceModel(m_version.data());
|
||||||
|
updateVersionControls();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_inst->customizeVersion();
|
||||||
|
m_version = m_inst->getFullVersion();
|
||||||
|
main_model->setSourceModel(m_version.data());
|
||||||
|
updateVersionControls();
|
||||||
|
}
|
||||||
|
ForgeVersionPtr forgeVersion = vselect.selectedVersion().dynamicCast<ForgeVersion>();
|
||||||
|
if (!forgeVersion)
|
||||||
|
return;
|
||||||
|
auto entry = MMC->metacache()->resolveEntry("minecraftforge", forgeVersion->filename);
|
||||||
|
if (entry->stale)
|
||||||
|
{
|
||||||
|
DownloadJob *fjob = new DownloadJob("Forge download");
|
||||||
|
fjob->add(forgeVersion->installer_url, entry);
|
||||||
|
ProgressDialog dlg(this);
|
||||||
|
dlg.exec(fjob);
|
||||||
|
if (dlg.result() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
// install
|
||||||
|
QString forgePath = entry->getFullPath();
|
||||||
|
ForgeInstaller forge(forgePath, forgeVersion->universal_url);
|
||||||
|
if (!forge.apply(m_version))
|
||||||
|
{
|
||||||
|
// failure notice
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// failed to download forge :/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// install
|
||||||
|
QString forgePath = entry->getFullPath();
|
||||||
|
ForgeInstaller forge(forgePath, forgeVersion->universal_url);
|
||||||
|
if (!forge.apply(m_version))
|
||||||
|
{
|
||||||
|
// failure notice
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool OneSixModEditDialog::loaderListFilter(QKeyEvent *keyEvent)
|
bool OneSixModEditDialog::loaderListFilter(QKeyEvent *keyEvent)
|
||||||
{
|
{
|
||||||
@ -112,7 +223,6 @@ bool OneSixModEditDialog::resourcePackListFilter ( QKeyEvent* keyEvent )
|
|||||||
return QDialog::eventFilter(ui->resPackTreeView, keyEvent);
|
return QDialog::eventFilter(ui->resPackTreeView, keyEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool OneSixModEditDialog::eventFilter(QObject *obj, QEvent *ev)
|
bool OneSixModEditDialog::eventFilter(QObject *obj, QEvent *ev)
|
||||||
{
|
{
|
||||||
if (ev->type() != QEvent::KeyPress)
|
if (ev->type() != QEvent::KeyPress)
|
||||||
@ -134,7 +244,8 @@ void OneSixModEditDialog::on_buttonBox_rejected()
|
|||||||
|
|
||||||
void OneSixModEditDialog::on_addModBtn_clicked()
|
void OneSixModEditDialog::on_addModBtn_clicked()
|
||||||
{
|
{
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, QApplication::translate("LegacyModEditDialog", "Select Loader Mods"));
|
QStringList fileNames = QFileDialog::getOpenFileNames(
|
||||||
|
this, QApplication::translate("LegacyModEditDialog", "Select Loader Mods"));
|
||||||
for (auto filename : fileNames)
|
for (auto filename : fileNames)
|
||||||
{
|
{
|
||||||
m_mods->stopWatching();
|
m_mods->stopWatching();
|
||||||
@ -158,10 +269,10 @@ void OneSixModEditDialog::on_viewModBtn_clicked()
|
|||||||
openDirInDefaultProgram(m_inst->loaderModsDir(), true);
|
openDirInDefaultProgram(m_inst->loaderModsDir(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OneSixModEditDialog::on_addResPackBtn_clicked()
|
void OneSixModEditDialog::on_addResPackBtn_clicked()
|
||||||
{
|
{
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, QApplication::translate("LegacyModEditDialog", "Select Resource Packs"));
|
QStringList fileNames = QFileDialog::getOpenFileNames(
|
||||||
|
this, QApplication::translate("LegacyModEditDialog", "Select Resource Packs"));
|
||||||
for (auto filename : fileNames)
|
for (auto filename : fileNames)
|
||||||
{
|
{
|
||||||
m_resourcepacks->stopWatching();
|
m_resourcepacks->stopWatching();
|
||||||
@ -184,4 +295,3 @@ void OneSixModEditDialog::on_viewResPackBtn_clicked()
|
|||||||
{
|
{
|
||||||
openDirInDefaultProgram(m_inst->resourcePacksDir(), true);
|
openDirInDefaultProgram(m_inst->resourcePacksDir(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <logic/OneSixInstance.h>
|
#include <logic/OneSixInstance.h>
|
||||||
|
|
||||||
|
class EnabledItemFilter;
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class OneSixModEditDialog;
|
class OneSixModEditDialog;
|
||||||
}
|
}
|
||||||
@ -41,6 +42,10 @@ private slots:
|
|||||||
// 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();
|
void on_forgeBtn_clicked();
|
||||||
|
void on_customizeBtn_clicked();
|
||||||
|
void on_revertBtn_clicked();
|
||||||
|
void updateVersionControls();
|
||||||
|
void disableVersionControls();
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *ev);
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
bool loaderListFilter( QKeyEvent* ev );
|
bool loaderListFilter( QKeyEvent* ev );
|
||||||
@ -50,5 +55,6 @@ private:
|
|||||||
QSharedPointer<OneSixVersion> m_version;
|
QSharedPointer<OneSixVersion> m_version;
|
||||||
QSharedPointer<ModList> m_mods;
|
QSharedPointer<ModList> m_mods;
|
||||||
QSharedPointer<ModList> m_resourcepacks;
|
QSharedPointer<ModList> m_resourcepacks;
|
||||||
|
EnabledItemFilter * main_model;
|
||||||
OneSixInstance * m_inst;
|
OneSixInstance * m_inst;
|
||||||
};
|
};
|
||||||
|
@ -55,7 +55,11 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="mainClassEdit"/>
|
<widget class="QLineEdit" name="mainClassEdit">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
@ -85,6 +89,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="revertBtn">
|
<widget class="QPushButton" name="revertBtn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Revert to original base version</string>
|
<string>Revert to original base version</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -26,10 +26,10 @@ LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) :
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->labelStatus->setVisible(false);
|
ui->labelStatus->setVisible(false);
|
||||||
auto lwjgllist = MMC->lwjgllist();
|
auto lwjgllist = MMC->lwjgllist();
|
||||||
ui->lwjglListView->setModel(lwjgllist);
|
ui->lwjglListView->setModel(lwjgllist.data());
|
||||||
|
|
||||||
connect(lwjgllist, SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool)));
|
connect(lwjgllist.data(), SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool)));
|
||||||
connect(lwjgllist, SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString)));
|
connect(lwjgllist.data(), SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString)));
|
||||||
loadingStateUpdated(lwjgllist->isLoading());
|
loadingStateUpdated(lwjgllist->isLoading());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ MainWindow::MainWindow ( QWidget *parent )
|
|||||||
//proxymodel->setDynamicSortFilter ( true );
|
//proxymodel->setDynamicSortFilter ( true );
|
||||||
|
|
||||||
// FIXME: instList should be global-ish, or at least not tied to the main window... maybe the application itself?
|
// FIXME: instList should be global-ish, or at least not tied to the main window... maybe the application itself?
|
||||||
proxymodel->setSourceModel ( MMC->instances() );
|
proxymodel->setSourceModel ( MMC->instances().data() );
|
||||||
proxymodel->sort ( 0 );
|
proxymodel->sort ( 0 );
|
||||||
view->setFrameShape ( QFrame::NoFrame );
|
view->setFrameShape ( QFrame::NoFrame );
|
||||||
view->setModel ( proxymodel );
|
view->setModel ( proxymodel );
|
||||||
@ -149,7 +149,7 @@ MainWindow::MainWindow ( QWidget *parent )
|
|||||||
);
|
);
|
||||||
// model reset -> selection is invalid. All the instance pointers are wrong.
|
// model reset -> selection is invalid. All the instance pointers are wrong.
|
||||||
// FIXME: stop using POINTERS everywhere
|
// FIXME: stop using POINTERS everywhere
|
||||||
connect(MMC->instances() ,SIGNAL(dataIsInvalid()),SLOT(selectionBad()));
|
connect(MMC->instances().data() ,SIGNAL(dataIsInvalid()),SLOT(selectionBad()));
|
||||||
|
|
||||||
// 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.
|
||||||
@ -601,7 +601,7 @@ void MainWindow::on_actionChangeInstMCVersion_triggered()
|
|||||||
if (view->selectionModel()->selectedIndexes().count() < 1)
|
if (view->selectionModel()->selectedIndexes().count() < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
VersionSelectDialog vselect(m_selectedInstance->versionList(), this);
|
VersionSelectDialog vselect(m_selectedInstance->versionList().data(), this);
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
if (vselect.exec() && vselect.selectedVersion())
|
||||||
{
|
{
|
||||||
m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor());
|
m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor());
|
||||||
|
@ -440,7 +440,7 @@
|
|||||||
<string>Meow</string>
|
<string>Meow</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p align="center"><span style=" font-weight:600; color:#ff0004;">Catnatok!</span></p><p align="center">Or just a cat with a ball of yarn?</p><p align="center"><span style=" font-style:italic;">WHO KNOWS?!</span></p><p align="center"><img src=":/icons/instances/tnt"/></p></body></html></string>
|
<string><html><head/><body><p align="center"><span style=" font-weight:600; color:#ff0004;">Catnarok!</span></p><p align="center">Or just a cat with a ball of yarn?</p><p align="center"><span style=" font-style:italic;">WHO KNOWS?!</span></p><p align="center"><img src=":/icons/instances/tnt"/></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -96,7 +96,7 @@ BaseVersionPtr NewInstanceDialog::selectedVersion() const
|
|||||||
|
|
||||||
void NewInstanceDialog::on_btnChangeVersion_clicked()
|
void NewInstanceDialog::on_btnChangeVersion_clicked()
|
||||||
{
|
{
|
||||||
VersionSelectDialog vselect(MMC->minecraftlist(), this);
|
VersionSelectDialog vselect(MMC->minecraftlist().data(), this);
|
||||||
vselect.exec();
|
vselect.exec();
|
||||||
if (vselect.result() == QDialog::Accepted)
|
if (vselect.result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
loadSettings(MMC->settings());
|
loadSettings(MMC->settings().data());
|
||||||
updateCheckboxStuff();
|
updateCheckboxStuff();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ void SettingsDialog::on_maximizedCheckBox_clicked(bool checked)
|
|||||||
|
|
||||||
void SettingsDialog::on_buttonBox_accepted()
|
void SettingsDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
applySettings(MMC->settings());
|
applySettings(MMC->settings().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::applySettings(SettingsObject *s)
|
void SettingsDialog::applySettings(SettingsObject *s)
|
||||||
|
@ -132,7 +132,7 @@ InstanceList *BaseInstance::instList() const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseVersionList *BaseInstance::versionList() const
|
QSharedPointer<BaseVersionList> BaseInstance::versionList() const
|
||||||
{
|
{
|
||||||
return MMC->minecraftlist();
|
return MMC->minecraftlist();
|
||||||
}
|
}
|
||||||
|
@ -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 BaseVersionList *versionList() const;
|
virtual QSharedPointer<BaseVersionList> versionList() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets this instance's settings object.
|
* \brief Gets this instance's settings object.
|
||||||
|
135
logic/ForgeInstaller.cpp
Normal file
135
logic/ForgeInstaller.cpp
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
#include "ForgeInstaller.h"
|
||||||
|
#include "OneSixVersion.h"
|
||||||
|
#include "OneSixLibrary.h"
|
||||||
|
#include "net/HttpMetaCache.h"
|
||||||
|
#include <quazip.h>
|
||||||
|
#include <quazipfile.h>
|
||||||
|
#include <pathutils.h>
|
||||||
|
#include <QStringList>
|
||||||
|
#include "MultiMC.h"
|
||||||
|
|
||||||
|
ForgeInstaller::ForgeInstaller(QString filename, QString universal_url)
|
||||||
|
{
|
||||||
|
QSharedPointer<OneSixVersion> newVersion;
|
||||||
|
m_universal_url = universal_url;
|
||||||
|
|
||||||
|
QuaZip zip(filename);
|
||||||
|
if (!zip.open(QuaZip::mdUnzip))
|
||||||
|
return;
|
||||||
|
|
||||||
|
QuaZipFile file(&zip);
|
||||||
|
|
||||||
|
// read the install profile
|
||||||
|
if (!zip.setCurrentFile("install_profile.json"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
QJsonParseError jsonError;
|
||||||
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
|
return;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(file.readAll(), &jsonError);
|
||||||
|
file.close();
|
||||||
|
if (jsonError.error != QJsonParseError::NoError)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!jsonDoc.isObject())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QJsonObject root = jsonDoc.object();
|
||||||
|
|
||||||
|
auto installVal = root.value("install");
|
||||||
|
auto versionInfoVal = root.value("versionInfo");
|
||||||
|
if (!installVal.isObject() || !versionInfoVal.isObject())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// read the forge version info
|
||||||
|
{
|
||||||
|
newVersion = OneSixVersion::fromJson(versionInfoVal.toObject());
|
||||||
|
if (!newVersion)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject installObj = installVal.toObject();
|
||||||
|
QString libraryName = installObj.value("path").toString();
|
||||||
|
internalPath = installObj.value("filePath").toString();
|
||||||
|
|
||||||
|
// where do we put the library? decode the mojang path
|
||||||
|
OneSixLibrary lib(libraryName);
|
||||||
|
lib.finalize();
|
||||||
|
|
||||||
|
auto cacheentry = MMC->metacache()->resolveEntry("libraries", lib.storagePath());
|
||||||
|
finalPath = "libraries/" + lib.storagePath();
|
||||||
|
if (!ensureFilePathExists(finalPath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!zip.setCurrentFile(internalPath))
|
||||||
|
return;
|
||||||
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
|
return;
|
||||||
|
{
|
||||||
|
QByteArray data = file.readAll();
|
||||||
|
// extract file
|
||||||
|
QSaveFile extraction(finalPath);
|
||||||
|
if (!extraction.open(QIODevice::WriteOnly))
|
||||||
|
return;
|
||||||
|
if (extraction.write(data) != data.size())
|
||||||
|
return;
|
||||||
|
if (!extraction.commit())
|
||||||
|
return;
|
||||||
|
QCryptographicHash md5sum(QCryptographicHash::Md5);
|
||||||
|
md5sum.addData(data);
|
||||||
|
|
||||||
|
cacheentry->stale = false;
|
||||||
|
cacheentry->md5sum = md5sum.result().toHex().constData();
|
||||||
|
MMC->metacache()->updateEntry(cacheentry);
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
m_forge_version = newVersion;
|
||||||
|
realVersionId = m_forge_version->id = installObj.value("minecraft").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ForgeInstaller::apply(QSharedPointer<OneSixVersion> to)
|
||||||
|
{
|
||||||
|
if (!m_forge_version)
|
||||||
|
return false;
|
||||||
|
to->externalUpdateStart();
|
||||||
|
int sliding_insert_window = 0;
|
||||||
|
{
|
||||||
|
// for each library in the version we are adding (except for the blacklisted)
|
||||||
|
QSet<QString> blacklist{"lwjgl", "lwjgl_util", "lwjgl-platform"};
|
||||||
|
for (auto lib : m_forge_version->libraries)
|
||||||
|
{
|
||||||
|
QString libName = lib->name();
|
||||||
|
// if this is the actual forge lib, set an absolute url for the download
|
||||||
|
if (libName.contains("minecraftforge"))
|
||||||
|
{
|
||||||
|
lib->setAbsoluteUrl(m_universal_url);
|
||||||
|
}
|
||||||
|
if (blacklist.contains(libName))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// find an entry that matches this one
|
||||||
|
bool found = false;
|
||||||
|
for (auto tolib : to->libraries)
|
||||||
|
{
|
||||||
|
if (tolib->name() != libName)
|
||||||
|
continue;
|
||||||
|
found = true;
|
||||||
|
// replace lib
|
||||||
|
tolib = lib;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
// add lib
|
||||||
|
to->libraries.insert(sliding_insert_window, lib);
|
||||||
|
sliding_insert_window++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
to->mainClass = m_forge_version->mainClass;
|
||||||
|
to->minecraftArguments = m_forge_version->minecraftArguments;
|
||||||
|
to->processArguments = m_forge_version->processArguments;
|
||||||
|
}
|
||||||
|
to->externalUpdateFinish();
|
||||||
|
return to->toOriginalFile();
|
||||||
|
}
|
25
logic/ForgeInstaller.h
Normal file
25
logic/ForgeInstaller.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <QString>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
class OneSixVersion;
|
||||||
|
|
||||||
|
class ForgeInstaller
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ForgeInstaller(QString filename, QString universal_url);
|
||||||
|
|
||||||
|
bool apply(QSharedPointer<OneSixVersion> to);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// the version, read from the installer
|
||||||
|
QSharedPointer<OneSixVersion> m_forge_version;
|
||||||
|
QString internalPath;
|
||||||
|
QString finalPath;
|
||||||
|
QString realVersionId;
|
||||||
|
QString m_universal_url;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ void LegacyUpdate::lwjglStart()
|
|||||||
|
|
||||||
m_reply = QSharedPointer<QNetworkReply> (rep, &QObject::deleteLater);
|
m_reply = QSharedPointer<QNetworkReply> (rep, &QObject::deleteLater);
|
||||||
connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
|
connect(rep, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
|
||||||
connect(worker, SIGNAL(finished(QNetworkReply*)), SLOT(lwjglFinished(QNetworkReply*)));
|
connect(worker.data(), 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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ void LegacyUpdate::lwjglFinished(QNetworkReply* reply)
|
|||||||
"\nSometimes you have to wait a bit if you download many LWJGL versions in a row. YMMV");
|
"\nSometimes you have to wait a bit if you download many LWJGL versions in a row. YMMV");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto *worker = MMC->qnam();
|
auto worker = MMC->qnam();
|
||||||
//Here i check if there is a cookie for me in the reply and extract it
|
//Here i check if there is a cookie for me in the reply and extract it
|
||||||
QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie>>(reply->header(QNetworkRequest::SetCookieHeader));
|
QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie>>(reply->header(QNetworkRequest::SetCookieHeader));
|
||||||
if(cookies.count() != 0)
|
if(cookies.count() != 0)
|
||||||
|
@ -112,3 +112,6 @@ protected:
|
|||||||
QString m_list_id;
|
QString m_list_id;
|
||||||
QList<Mod> mods;
|
QList<Mod> mods;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,3 +9,4 @@ public:
|
|||||||
explicit NostalgiaInstance(const QString &rootDir, SettingsObject * settings, QObject *parent = 0);
|
explicit NostalgiaInstance(const QString &rootDir, SettingsObject * settings, QObject *parent = 0);
|
||||||
virtual QString getStatusbarDescription();
|
virtual QString getStatusbarDescription();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "OneSixInstance_p.h"
|
#include "OneSixInstance_p.h"
|
||||||
#include "OneSixUpdate.h"
|
#include "OneSixUpdate.h"
|
||||||
#include "MinecraftProcess.h"
|
#include "MinecraftProcess.h"
|
||||||
#include "VersionFactory.h"
|
#include "OneSixVersion.h"
|
||||||
|
|
||||||
#include <setting.h>
|
#include <setting.h>
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
@ -10,7 +10,8 @@
|
|||||||
#include <JlCompress.h>
|
#include <JlCompress.h>
|
||||||
#include <gui/OneSixModEditDialog.h>
|
#include <gui/OneSixModEditDialog.h>
|
||||||
|
|
||||||
OneSixInstance::OneSixInstance ( const QString& rootDir, SettingsObject* setting_obj, QObject* parent )
|
OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *setting_obj,
|
||||||
|
QObject *parent)
|
||||||
: BaseInstance(new OneSixInstancePrivate(), rootDir, setting_obj, parent)
|
: BaseInstance(new OneSixInstancePrivate(), rootDir, setting_obj, parent)
|
||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
@ -104,7 +105,8 @@ MinecraftProcess* OneSixInstance::prepareForLaunch ( QString user, QString sessi
|
|||||||
{
|
{
|
||||||
QString path = "libraries/" + lib->storagePath();
|
QString path = "libraries/" + lib->storagePath();
|
||||||
qDebug() << "Will extract " << path.toLocal8Bit();
|
qDebug() << "Will extract " << path.toLocal8Bit();
|
||||||
if(JlCompress::extractWithExceptions(path, natives_dir_raw, lib->extract_excludes).isEmpty())
|
if (JlCompress::extractWithExceptions(path, natives_dir_raw, lib->extract_excludes)
|
||||||
|
.isEmpty())
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -180,7 +182,6 @@ QSharedPointer< ModList > OneSixInstance::resourcePackList()
|
|||||||
return d->resource_pack_list;
|
return d->resource_pack_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QDialog *OneSixInstance::createModEditDialog(QWidget *parent)
|
QDialog *OneSixInstance::createModEditDialog(QWidget *parent)
|
||||||
{
|
{
|
||||||
return new OneSixModEditDialog(this, parent);
|
return new OneSixModEditDialog(this, parent);
|
||||||
@ -226,6 +227,31 @@ QString OneSixInstance::currentVersionId() const
|
|||||||
return intendedVersionId();
|
return intendedVersionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OneSixInstance::customizeVersion()
|
||||||
|
{
|
||||||
|
if (!versionIsCustom())
|
||||||
|
{
|
||||||
|
auto pathCustom = PathCombine(instanceRoot(), "custom.json");
|
||||||
|
auto pathOrig = PathCombine(instanceRoot(), "version.json");
|
||||||
|
QFile::copy(pathOrig, pathCustom);
|
||||||
|
return reloadFullVersion();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OneSixInstance::revertCustomVersion()
|
||||||
|
{
|
||||||
|
if (versionIsCustom())
|
||||||
|
{
|
||||||
|
auto path = PathCombine(instanceRoot(), "custom.json");
|
||||||
|
QFile::remove(path);
|
||||||
|
return reloadFullVersion();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool OneSixInstance::reloadFullVersion()
|
bool OneSixInstance::reloadFullVersion()
|
||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
@ -238,18 +264,12 @@ bool OneSixInstance::reloadFullVersion()
|
|||||||
verpath = verpath_custom;
|
verpath = verpath_custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile versionfile(verpath);
|
auto version = OneSixVersion::fromFile(verpath);
|
||||||
if(versionfile.exists() && versionfile.open(QIODevice::ReadOnly))
|
|
||||||
{
|
|
||||||
FullVersionFactory fvf;
|
|
||||||
auto version = fvf.parse(versionfile.readAll());
|
|
||||||
versionfile.close();
|
|
||||||
if (version)
|
if (version)
|
||||||
{
|
{
|
||||||
d->version = version;
|
d->version = version;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,3 +320,4 @@ QString OneSixInstance::instanceConfigFolder() const
|
|||||||
{
|
{
|
||||||
return PathCombine(minecraftRoot(), "config");
|
return PathCombine(minecraftRoot(), "config");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,10 @@ public:
|
|||||||
bool reloadFullVersion();
|
bool reloadFullVersion();
|
||||||
/// get the current full version info
|
/// get the current full version info
|
||||||
QSharedPointer<OneSixVersion> getFullVersion();
|
QSharedPointer<OneSixVersion> getFullVersion();
|
||||||
|
/// revert the current custom version back to base
|
||||||
|
bool revertCustomVersion();
|
||||||
|
/// customize the current base version
|
||||||
|
bool customizeVersion();
|
||||||
/// is the current version original, or custom?
|
/// is the current version original, or custom?
|
||||||
bool versionIsCustom();
|
bool versionIsCustom();
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "OneSixLibrary.h"
|
#include "OneSixLibrary.h"
|
||||||
#include "OneSixRule.h"
|
#include "OneSixRule.h"
|
||||||
#include "OpSys.h"
|
#include "OpSys.h"
|
||||||
|
#include <QJsonArray>
|
||||||
void OneSixLibrary::finalize()
|
void OneSixLibrary::finalize()
|
||||||
{
|
{
|
||||||
QStringList parts = m_name.split(':');
|
QStringList parts = m_name.split(':');
|
||||||
@ -26,7 +27,7 @@ void OneSixLibrary::finalize()
|
|||||||
m_decentname = parts[1];
|
m_decentname = parts[1];
|
||||||
m_decentversion = parts[2];
|
m_decentversion = parts[2];
|
||||||
m_storage_path = relative;
|
m_storage_path = relative;
|
||||||
m_download_path = m_base_url + relative;
|
m_download_url = m_base_url + relative;
|
||||||
|
|
||||||
if (m_rules.empty())
|
if (m_rules.empty())
|
||||||
{
|
{
|
||||||
@ -83,11 +84,66 @@ bool OneSixLibrary::isNative()
|
|||||||
{
|
{
|
||||||
return m_is_native;
|
return m_is_native;
|
||||||
}
|
}
|
||||||
QString OneSixLibrary::downloadPath()
|
QString OneSixLibrary::downloadUrl()
|
||||||
{
|
{
|
||||||
return m_download_path;
|
if(m_absolute_url.size())
|
||||||
|
return m_absolute_url;
|
||||||
|
return m_download_url;
|
||||||
}
|
}
|
||||||
QString OneSixLibrary::storagePath()
|
QString OneSixLibrary::storagePath()
|
||||||
{
|
{
|
||||||
return m_storage_path;
|
return m_storage_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OneSixLibrary::setAbsoluteUrl(QString absolute_url)
|
||||||
|
{
|
||||||
|
m_absolute_url = absolute_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OneSixLibrary::absoluteUrl()
|
||||||
|
{
|
||||||
|
return m_absolute_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject OneSixLibrary::toJson()
|
||||||
|
{
|
||||||
|
QJsonObject libRoot;
|
||||||
|
libRoot.insert("name", m_name);
|
||||||
|
if(m_absolute_url.size())
|
||||||
|
libRoot.insert("MMC-absulute_url", m_absolute_url);
|
||||||
|
if(m_base_url != "https://s3.amazonaws.com/Minecraft.Download/libraries/")
|
||||||
|
libRoot.insert("url", m_base_url);
|
||||||
|
if (isNative() && m_native_suffixes.size())
|
||||||
|
{
|
||||||
|
QJsonObject nativeList;
|
||||||
|
auto iter = m_native_suffixes.begin();
|
||||||
|
while (iter != m_native_suffixes.end())
|
||||||
|
{
|
||||||
|
nativeList.insert(OpSys_toString(iter.key()), iter.value());
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
libRoot.insert("natives", nativeList);
|
||||||
|
}
|
||||||
|
if (isNative() && extract_excludes.size())
|
||||||
|
{
|
||||||
|
QJsonArray excludes;
|
||||||
|
QJsonObject extract;
|
||||||
|
for (auto exclude : extract_excludes)
|
||||||
|
{
|
||||||
|
excludes.append(exclude);
|
||||||
|
}
|
||||||
|
extract.insert("exclude", excludes);
|
||||||
|
libRoot.insert("extract", extract);
|
||||||
|
}
|
||||||
|
if (m_rules.size())
|
||||||
|
{
|
||||||
|
QJsonArray allRules;
|
||||||
|
for (auto &rule : m_rules)
|
||||||
|
{
|
||||||
|
QJsonObject ruleObj = rule->toJson();
|
||||||
|
allRules.append(ruleObj);
|
||||||
|
}
|
||||||
|
libRoot.insert("rules", allRules);
|
||||||
|
}
|
||||||
|
return libRoot;
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
#include <QJsonObject>
|
||||||
#include "OpSys.h"
|
#include "OpSys.h"
|
||||||
|
|
||||||
class Rule;
|
class Rule;
|
||||||
@ -12,9 +13,13 @@ class OneSixLibrary
|
|||||||
private:
|
private:
|
||||||
// basic values used internally (so far)
|
// basic values used internally (so far)
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_base_url;
|
QString m_base_url = "https://s3.amazonaws.com/Minecraft.Download/libraries/";
|
||||||
QList<QSharedPointer<Rule> > m_rules;
|
QList<QSharedPointer<Rule> > m_rules;
|
||||||
|
|
||||||
|
// custom values
|
||||||
|
/// absolute URL. takes precedence over m_download_path, if defined
|
||||||
|
QString m_absolute_url;
|
||||||
|
|
||||||
// derived values used for real things
|
// derived values used for real things
|
||||||
/// a decent name fit for display
|
/// a decent name fit for display
|
||||||
QString m_decentname;
|
QString m_decentname;
|
||||||
@ -25,11 +30,11 @@ private:
|
|||||||
/// where to store the lib locally
|
/// where to store the lib locally
|
||||||
QString m_storage_path;
|
QString m_storage_path;
|
||||||
/// where to download the lib from
|
/// where to download the lib from
|
||||||
QString m_download_path;
|
QString m_download_url;
|
||||||
/// is this lib actually active on the current OS?
|
/// is this lib actually active on the current OS?
|
||||||
bool m_is_active;
|
bool m_is_active = false;
|
||||||
/// is the library a native?
|
/// is the library a native?
|
||||||
bool m_is_native;
|
bool m_is_native = false;
|
||||||
/// native suffixes per OS
|
/// native suffixes per OS
|
||||||
QMap<OpSys, QString> m_native_suffixes;
|
QMap<OpSys, QString> m_native_suffixes;
|
||||||
public:
|
public:
|
||||||
@ -39,12 +44,11 @@ public:
|
|||||||
/// Constructor
|
/// Constructor
|
||||||
OneSixLibrary(QString name)
|
OneSixLibrary(QString name)
|
||||||
{
|
{
|
||||||
m_is_native = false;
|
|
||||||
m_is_active = false;
|
|
||||||
m_name = name;
|
m_name = name;
|
||||||
m_base_url = "https://s3.amazonaws.com/Minecraft.Download/libraries/";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonObject toJson();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finalize the library, processing the input values into derived values and state
|
* finalize the library, processing the input values into derived values and state
|
||||||
*
|
*
|
||||||
@ -84,7 +88,11 @@ public:
|
|||||||
/// Returns true if the library is native
|
/// Returns true if the library is native
|
||||||
bool isNative();
|
bool isNative();
|
||||||
/// Get the URL to download the library from
|
/// Get the URL to download the library from
|
||||||
QString downloadPath();
|
QString downloadUrl();
|
||||||
/// Get the relative path where the library should be saved
|
/// Get the relative path where the library should be saved
|
||||||
QString storagePath();
|
QString storagePath();
|
||||||
|
|
||||||
|
/// set an absolute URL for the library. This is an MMC extension.
|
||||||
|
void setAbsoluteUrl(QString absolute_url);
|
||||||
|
QString absoluteUrl();
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,66 @@
|
|||||||
#include "OneSixRule.h"
|
#include "OneSixRule.h"
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonArray>
|
||||||
|
|
||||||
|
QList<QSharedPointer<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules)
|
||||||
|
{
|
||||||
|
QList<QSharedPointer<Rule>> rules;
|
||||||
|
auto rulesVal = objectWithRules.value("rules");
|
||||||
|
if (!rulesVal.isArray())
|
||||||
|
return rules;
|
||||||
|
|
||||||
|
QJsonArray ruleList = rulesVal.toArray();
|
||||||
|
for (auto ruleVal : ruleList)
|
||||||
|
{
|
||||||
|
QSharedPointer<Rule> rule;
|
||||||
|
if (!ruleVal.isObject())
|
||||||
|
continue;
|
||||||
|
auto ruleObj = ruleVal.toObject();
|
||||||
|
auto actionVal = ruleObj.value("action");
|
||||||
|
if (!actionVal.isString())
|
||||||
|
continue;
|
||||||
|
auto action = RuleAction_fromString(actionVal.toString());
|
||||||
|
if (action == Defer)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto osVal = ruleObj.value("os");
|
||||||
|
if (!osVal.isObject())
|
||||||
|
{
|
||||||
|
// add a new implicit action rule
|
||||||
|
rules.append(ImplicitRule::create(action));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto osObj = osVal.toObject();
|
||||||
|
auto osNameVal = osObj.value("name");
|
||||||
|
if (!osNameVal.isString())
|
||||||
|
continue;
|
||||||
|
OpSys requiredOs = OpSys_fromString(osNameVal.toString());
|
||||||
|
QString versionRegex = osObj.value("version").toString();
|
||||||
|
// add a new OS rule
|
||||||
|
rules.append(OsRule::create(action, requiredOs, versionRegex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject ImplicitRule::toJson()
|
||||||
|
{
|
||||||
|
QJsonObject ruleObj;
|
||||||
|
ruleObj.insert("action", m_result == Allow ? QString("allow") : QString("disallow"));
|
||||||
|
return ruleObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject OsRule::toJson()
|
||||||
|
{
|
||||||
|
QJsonObject ruleObj;
|
||||||
|
ruleObj.insert("action", m_result == Allow ? QString("allow") : QString("disallow"));
|
||||||
|
QJsonObject osObj;
|
||||||
|
{
|
||||||
|
osObj.insert("name", OpSys_toString(m_system));
|
||||||
|
osObj.insert("version", m_version_regexp);
|
||||||
|
}
|
||||||
|
ruleObj.insert("os", osObj);
|
||||||
|
return ruleObj;
|
||||||
|
}
|
||||||
|
|
||||||
RuleAction RuleAction_fromString(QString name)
|
RuleAction RuleAction_fromString(QString name)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
|
||||||
class OneSixLibrary;
|
|
||||||
#include "OneSixLibrary.h"
|
#include "OneSixLibrary.h"
|
||||||
|
|
||||||
enum RuleAction
|
enum RuleAction
|
||||||
@ -13,6 +11,7 @@ enum RuleAction
|
|||||||
};
|
};
|
||||||
|
|
||||||
RuleAction RuleAction_fromString(QString);
|
RuleAction RuleAction_fromString(QString);
|
||||||
|
QList<QSharedPointer<Rule>> rulesFromJsonV4(QJsonObject &objectWithRules);
|
||||||
|
|
||||||
class Rule
|
class Rule
|
||||||
{
|
{
|
||||||
@ -23,6 +22,7 @@ public:
|
|||||||
Rule(RuleAction result)
|
Rule(RuleAction result)
|
||||||
:m_result(result) {}
|
:m_result(result) {}
|
||||||
virtual ~Rule(){};
|
virtual ~Rule(){};
|
||||||
|
virtual QJsonObject toJson() = 0;
|
||||||
RuleAction apply(OneSixLibrary * parent)
|
RuleAction apply(OneSixLibrary * parent)
|
||||||
{
|
{
|
||||||
if(applies(parent))
|
if(applies(parent))
|
||||||
@ -47,6 +47,7 @@ protected:
|
|||||||
OsRule(RuleAction result, OpSys system, QString version_regexp)
|
OsRule(RuleAction result, OpSys system, QString version_regexp)
|
||||||
: Rule(result), m_system(system), m_version_regexp(version_regexp) {}
|
: Rule(result), m_system(system), m_version_regexp(version_regexp) {}
|
||||||
public:
|
public:
|
||||||
|
virtual QJsonObject toJson();
|
||||||
static QSharedPointer<OsRule> create(RuleAction result, OpSys system, QString version_regexp)
|
static QSharedPointer<OsRule> create(RuleAction result, OpSys system, QString version_regexp)
|
||||||
{
|
{
|
||||||
return QSharedPointer<OsRule> (new OsRule(result, system, version_regexp));
|
return QSharedPointer<OsRule> (new OsRule(result, system, version_regexp));
|
||||||
@ -63,6 +64,7 @@ protected:
|
|||||||
ImplicitRule(RuleAction result)
|
ImplicitRule(RuleAction result)
|
||||||
: Rule(result) {}
|
: Rule(result) {}
|
||||||
public:
|
public:
|
||||||
|
virtual QJsonObject toJson();
|
||||||
static QSharedPointer<ImplicitRule> create(RuleAction result)
|
static QSharedPointer<ImplicitRule> create(RuleAction result)
|
||||||
{
|
{
|
||||||
return QSharedPointer<ImplicitRule> (new ImplicitRule(result));
|
return QSharedPointer<ImplicitRule> (new ImplicitRule(result));
|
||||||
|
@ -26,15 +26,15 @@
|
|||||||
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "lists/MinecraftVersionList.h"
|
#include "lists/MinecraftVersionList.h"
|
||||||
#include "VersionFactory.h"
|
|
||||||
#include "OneSixVersion.h"
|
#include "OneSixVersion.h"
|
||||||
#include "OneSixLibrary.h"
|
#include "OneSixLibrary.h"
|
||||||
#include "OneSixInstance.h"
|
#include "OneSixInstance.h"
|
||||||
|
|
||||||
#include "pathutils.h"
|
#include "pathutils.h"
|
||||||
|
|
||||||
|
OneSixUpdate::OneSixUpdate(BaseInstance *inst, QObject *parent) : BaseUpdate(inst, parent)
|
||||||
OneSixUpdate::OneSixUpdate(BaseInstance *inst, QObject *parent):BaseUpdate(inst, parent){}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void OneSixUpdate::executeTask()
|
void OneSixUpdate::executeTask()
|
||||||
{
|
{
|
||||||
@ -49,7 +49,8 @@ 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 = MMC->minecraftlist()->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
|
||||||
@ -76,9 +77,11 @@ void OneSixUpdate::versionFileStart()
|
|||||||
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)), SIGNAL(progress(qint64,qint64)));
|
connect(specificVersionDownloadJob.data(), SIGNAL(progress(qint64, qint64)),
|
||||||
|
SIGNAL(progress(qint64, qint64)));
|
||||||
specificVersionDownloadJob->start();
|
specificVersionDownloadJob->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +107,8 @@ void OneSixUpdate::versionFileFinished()
|
|||||||
qint64 actual = 0;
|
qint64 actual = 0;
|
||||||
if ((actual = vfile1.write(data)) != data.size())
|
if ((actual = vfile1.write(data)) != data.size())
|
||||||
{
|
{
|
||||||
emitFailed("Failed to write into " + version1 + ". Written " + actual + " out of " + data.size() + '.');
|
emitFailed("Failed to write into " + version1 + ". Written " + actual + " out of " +
|
||||||
|
data.size() + '.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!vfile1.commit())
|
if (!vfile1.commit())
|
||||||
@ -140,7 +144,8 @@ void OneSixUpdate::jarlibStart()
|
|||||||
bool successful = inst->reloadFullVersion();
|
bool successful = inst->reloadFullVersion();
|
||||||
if (!successful)
|
if (!successful)
|
||||||
{
|
{
|
||||||
emitFailed("Failed to load the version description file (version.json). It might be corrupted, missing or simply too new.");
|
emitFailed("Failed to load the version description file (version.json). It might be "
|
||||||
|
"corrupted, missing or simply too new.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +167,7 @@ void OneSixUpdate::jarlibStart()
|
|||||||
auto metacache = MMC->metacache();
|
auto metacache = MMC->metacache();
|
||||||
for (auto lib : libs)
|
for (auto lib : libs)
|
||||||
{
|
{
|
||||||
QString download_path = lib->downloadPath();
|
QString download_path = lib->downloadUrl();
|
||||||
auto entry = metacache->resolveEntry("libraries", lib->storagePath());
|
auto entry = metacache->resolveEntry("libraries", lib->storagePath());
|
||||||
if (entry->stale)
|
if (entry->stale)
|
||||||
{
|
{
|
||||||
@ -171,7 +176,8 @@ 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)), SIGNAL(progress(qint64,qint64)));
|
connect(jarlibDownloadJob.data(), SIGNAL(progress(qint64, qint64)),
|
||||||
|
SIGNAL(progress(qint64, qint64)));
|
||||||
|
|
||||||
jarlibDownloadJob->start();
|
jarlibDownloadJob->start();
|
||||||
}
|
}
|
||||||
@ -185,4 +191,3 @@ void OneSixUpdate::jarlibFailed()
|
|||||||
{
|
{
|
||||||
emitFailed("Failed to download the binary garbage. Try again. Maybe. IF YOU DARE");
|
emitFailed("Failed to download the binary garbage. Try again. Maybe. IF YOU DARE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,196 @@
|
|||||||
#include "OneSixVersion.h"
|
#include "OneSixVersion.h"
|
||||||
#include "OneSixLibrary.h"
|
#include "OneSixLibrary.h"
|
||||||
|
#include "OneSixRule.h"
|
||||||
|
|
||||||
|
QSharedPointer<OneSixVersion> fromJsonV4(QJsonObject root,
|
||||||
|
QSharedPointer<OneSixVersion> fullVersion)
|
||||||
|
{
|
||||||
|
fullVersion->id = root.value("id").toString();
|
||||||
|
|
||||||
|
fullVersion->mainClass = root.value("mainClass").toString();
|
||||||
|
auto procArgsValue = root.value("processArguments");
|
||||||
|
if (procArgsValue.isString())
|
||||||
|
{
|
||||||
|
fullVersion->processArguments = procArgsValue.toString();
|
||||||
|
QString toCompare = fullVersion->processArguments.toLower();
|
||||||
|
if (toCompare == "legacy")
|
||||||
|
{
|
||||||
|
fullVersion->minecraftArguments = " ${auth_player_name} ${auth_session}";
|
||||||
|
}
|
||||||
|
else if (toCompare == "username_session")
|
||||||
|
{
|
||||||
|
fullVersion->minecraftArguments =
|
||||||
|
"--username ${auth_player_name} --session ${auth_session}";
|
||||||
|
}
|
||||||
|
else if (toCompare == "username_session_version")
|
||||||
|
{
|
||||||
|
fullVersion->minecraftArguments = "--username ${auth_player_name} "
|
||||||
|
"--session ${auth_session} "
|
||||||
|
"--version ${profile_name}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto minecraftArgsValue = root.value("minecraftArguments");
|
||||||
|
if (minecraftArgsValue.isString())
|
||||||
|
{
|
||||||
|
fullVersion->minecraftArguments = minecraftArgsValue.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto minecraftTypeValue = root.value("type");
|
||||||
|
if (minecraftTypeValue.isString())
|
||||||
|
{
|
||||||
|
fullVersion->type = minecraftTypeValue.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
fullVersion->releaseTime = root.value("releaseTime").toString();
|
||||||
|
fullVersion->time = root.value("time").toString();
|
||||||
|
|
||||||
|
// Iterate through the list, if it's a list.
|
||||||
|
auto librariesValue = root.value("libraries");
|
||||||
|
if (!librariesValue.isArray())
|
||||||
|
return fullVersion;
|
||||||
|
|
||||||
|
QJsonArray libList = root.value("libraries").toArray();
|
||||||
|
for (auto libVal : libList)
|
||||||
|
{
|
||||||
|
if (!libVal.isObject())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject libObj = libVal.toObject();
|
||||||
|
|
||||||
|
// Library name
|
||||||
|
auto nameVal = libObj.value("name");
|
||||||
|
if (!nameVal.isString())
|
||||||
|
continue;
|
||||||
|
QSharedPointer<OneSixLibrary> library(new OneSixLibrary(nameVal.toString()));
|
||||||
|
|
||||||
|
auto urlVal = libObj.value("url");
|
||||||
|
if (urlVal.isString())
|
||||||
|
{
|
||||||
|
library->setBaseUrl(urlVal.toString());
|
||||||
|
}
|
||||||
|
auto urlAbsVal = libObj.value("MMC-absulute_url");
|
||||||
|
if (urlAbsVal.isString())
|
||||||
|
{
|
||||||
|
library->setAbsoluteUrl(urlAbsVal.toString());
|
||||||
|
}
|
||||||
|
// Extract excludes (if any)
|
||||||
|
auto extractVal = libObj.value("extract");
|
||||||
|
if (extractVal.isObject())
|
||||||
|
{
|
||||||
|
QStringList excludes;
|
||||||
|
auto extractObj = extractVal.toObject();
|
||||||
|
auto excludesVal = extractObj.value("exclude");
|
||||||
|
if (excludesVal.isArray())
|
||||||
|
{
|
||||||
|
auto excludesList = excludesVal.toArray();
|
||||||
|
for (auto excludeVal : excludesList)
|
||||||
|
{
|
||||||
|
if (excludeVal.isString())
|
||||||
|
excludes.append(excludeVal.toString());
|
||||||
|
}
|
||||||
|
library->extract_excludes = excludes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto nativesVal = libObj.value("natives");
|
||||||
|
if (nativesVal.isObject())
|
||||||
|
{
|
||||||
|
library->setIsNative();
|
||||||
|
auto nativesObj = nativesVal.toObject();
|
||||||
|
auto iter = nativesObj.begin();
|
||||||
|
while (iter != nativesObj.end())
|
||||||
|
{
|
||||||
|
auto osType = OpSys_fromString(iter.key());
|
||||||
|
if (osType == Os_Other)
|
||||||
|
continue;
|
||||||
|
if (!iter.value().isString())
|
||||||
|
continue;
|
||||||
|
library->addNative(osType, iter.value().toString());
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
library->setRules(rulesFromJsonV4(libObj));
|
||||||
|
library->finalize();
|
||||||
|
fullVersion->libraries.append(library);
|
||||||
|
}
|
||||||
|
return fullVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSharedPointer<OneSixVersion> OneSixVersion::fromJson(QJsonObject root)
|
||||||
|
{
|
||||||
|
QSharedPointer<OneSixVersion> readVersion(new OneSixVersion());
|
||||||
|
int launcher_ver = readVersion->minimumLauncherVersion =
|
||||||
|
root.value("minimumLauncherVersion").toDouble();
|
||||||
|
|
||||||
|
// ADD MORE HERE :D
|
||||||
|
if (launcher_ver > 0 && launcher_ver <= 7)
|
||||||
|
return fromJsonV4(root, readVersion);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QSharedPointer<OneSixVersion>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QSharedPointer<OneSixVersion> OneSixVersion::fromFile(QString filepath)
|
||||||
|
{
|
||||||
|
QFile file(filepath);
|
||||||
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
return QSharedPointer<OneSixVersion>();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto data = file.readAll();
|
||||||
|
QJsonParseError jsonError;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
||||||
|
|
||||||
|
if (jsonError.error != QJsonParseError::NoError)
|
||||||
|
{
|
||||||
|
return QSharedPointer<OneSixVersion>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!jsonDoc.isObject())
|
||||||
|
{
|
||||||
|
return QSharedPointer<OneSixVersion>();
|
||||||
|
}
|
||||||
|
QJsonObject root = jsonDoc.object();
|
||||||
|
auto version = fromJson(root);
|
||||||
|
version->original_file = filepath;
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OneSixVersion::toOriginalFile()
|
||||||
|
{
|
||||||
|
if (original_file.isEmpty())
|
||||||
|
return false;
|
||||||
|
QSaveFile file(original_file);
|
||||||
|
if (!file.open(QIODevice::WriteOnly))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// serialize base attributes (those we care about anyway)
|
||||||
|
QJsonObject root;
|
||||||
|
root.insert("minecraftArguments", minecraftArguments);
|
||||||
|
root.insert("mainClass", mainClass);
|
||||||
|
root.insert("minimumLauncherVersion", minimumLauncherVersion);
|
||||||
|
root.insert("time", time);
|
||||||
|
root.insert("id", id);
|
||||||
|
root.insert("type", type);
|
||||||
|
// screw processArguments
|
||||||
|
root.insert("releaseTime", releaseTime);
|
||||||
|
QJsonArray libarray;
|
||||||
|
for(const auto & lib: libraries)
|
||||||
|
{
|
||||||
|
libarray.append(lib->toJson());
|
||||||
|
}
|
||||||
|
if(libarray.count())
|
||||||
|
root.insert("libraries", libarray);
|
||||||
|
QJsonDocument doc(root);
|
||||||
|
file.write(doc.toJson());
|
||||||
|
return file.commit();
|
||||||
|
}
|
||||||
|
|
||||||
QList<QSharedPointer<OneSixLibrary>> OneSixVersion::getActiveNormalLibs()
|
QList<QSharedPointer<OneSixLibrary>> OneSixVersion::getActiveNormalLibs()
|
||||||
{
|
{
|
||||||
@ -27,6 +218,15 @@ QList<QSharedPointer<OneSixLibrary> > OneSixVersion::getActiveNativeLibs()
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OneSixVersion::externalUpdateStart()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneSixVersion::externalUpdateFinish()
|
||||||
|
{
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
QVariant OneSixVersion::data(const QModelIndex &index, int role) const
|
QVariant OneSixVersion::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
@ -72,7 +272,6 @@ Qt::ItemFlags OneSixVersion::flags(const QModelIndex& index) const
|
|||||||
// return QAbstractListModel::flags(index);
|
// return QAbstractListModel::flags(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant OneSixVersion::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant OneSixVersion::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
|
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
|
||||||
|
@ -4,13 +4,33 @@ class OneSixLibrary;
|
|||||||
|
|
||||||
class OneSixVersion : public QAbstractListModel
|
class OneSixVersion : public QAbstractListModel
|
||||||
{
|
{
|
||||||
|
// Things required to implement the Qt list model
|
||||||
public:
|
public:
|
||||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
|
virtual QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
|
int role = Qt::DisplayRole) const;
|
||||||
virtual int columnCount(const QModelIndex &parent) const;
|
virtual int columnCount(const QModelIndex &parent) const;
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
|
||||||
|
// serialization/deserialization
|
||||||
public:
|
public:
|
||||||
|
bool toOriginalFile();
|
||||||
|
static QSharedPointer<OneSixVersion> fromJson(QJsonObject root);
|
||||||
|
static QSharedPointer<OneSixVersion> fromFile(QString filepath);
|
||||||
|
|
||||||
|
public:
|
||||||
|
QList<QSharedPointer<OneSixLibrary>> getActiveNormalLibs();
|
||||||
|
QList<QSharedPointer<OneSixLibrary>> getActiveNativeLibs();
|
||||||
|
// called when something starts/stops messing with the object
|
||||||
|
// FIXME: these are ugly in every possible way.
|
||||||
|
void externalUpdateStart();
|
||||||
|
void externalUpdateFinish();
|
||||||
|
|
||||||
|
// data members
|
||||||
|
public:
|
||||||
|
/// file this was read from. blank, if none
|
||||||
|
QString original_file;
|
||||||
/// the ID - determines which jar to use! ACTUALLY IMPORTANT!
|
/// the ID - determines which jar to use! ACTUALLY IMPORTANT!
|
||||||
QString id;
|
QString id;
|
||||||
/// Last updated time - as a string
|
/// Last updated time - as a string
|
||||||
@ -32,9 +52,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
QString minecraftArguments;
|
QString minecraftArguments;
|
||||||
/**
|
/**
|
||||||
* the minimum launcher version required by this version ... current is 4 (at point of writing)
|
* the minimum launcher version required by this version ... current is 4 (at point of
|
||||||
|
* writing)
|
||||||
*/
|
*/
|
||||||
int minimumLauncherVersion;
|
int minimumLauncherVersion = 0xDEADBEEF;
|
||||||
/**
|
/**
|
||||||
* The main class to load first
|
* The main class to load first
|
||||||
*/
|
*/
|
||||||
@ -58,18 +79,11 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX 10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!"
|
"incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX
|
||||||
|
10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!"
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// QList<Rule> rules;
|
// QList<Rule> rules;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OneSixVersion()
|
|
||||||
{
|
|
||||||
minimumLauncherVersion = 0xDEADBEEF;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QSharedPointer<OneSixLibrary> > getActiveNormalLibs();
|
|
||||||
QList<QSharedPointer<OneSixLibrary> > getActiveNativeLibs();
|
|
||||||
};
|
};
|
||||||
|
@ -10,3 +10,14 @@ OpSys OpSys_fromString(QString name)
|
|||||||
return Os_OSX;
|
return Os_OSX;
|
||||||
return Os_Other;
|
return Os_Other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString OpSys_toString(OpSys name)
|
||||||
|
{
|
||||||
|
switch(name)
|
||||||
|
{
|
||||||
|
case Os_Linux: return "linux";
|
||||||
|
case Os_OSX: return "osx";
|
||||||
|
case Os_Windows: return "windows";
|
||||||
|
default: return "other";
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ enum OpSys
|
|||||||
};
|
};
|
||||||
|
|
||||||
OpSys OpSys_fromString(QString);
|
OpSys OpSys_fromString(QString);
|
||||||
|
QString OpSys_toString(OpSys);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
#define currentSystem Os_Windows
|
#define currentSystem Os_Windows
|
||||||
|
@ -1,196 +0,0 @@
|
|||||||
#include "VersionFactory.h"
|
|
||||||
#include "OneSixVersion.h"
|
|
||||||
#include "OneSixRule.h"
|
|
||||||
|
|
||||||
// Library rules (if any)
|
|
||||||
QList<QSharedPointer<Rule> > FullVersionFactory::parse4rules(QJsonObject & baseObj)
|
|
||||||
{
|
|
||||||
QList<QSharedPointer<Rule> > rules;
|
|
||||||
auto rulesVal = baseObj.value("rules");
|
|
||||||
if(rulesVal.isArray())
|
|
||||||
{
|
|
||||||
QJsonArray ruleList = rulesVal.toArray();
|
|
||||||
for(auto ruleVal : ruleList)
|
|
||||||
{
|
|
||||||
QSharedPointer<Rule> rule;
|
|
||||||
if(!ruleVal.isObject())
|
|
||||||
continue;
|
|
||||||
auto ruleObj = ruleVal.toObject();
|
|
||||||
auto actionVal = ruleObj.value("action");
|
|
||||||
if(!actionVal.isString())
|
|
||||||
continue;
|
|
||||||
auto action = RuleAction_fromString(actionVal.toString());
|
|
||||||
if(action == Defer)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto osVal = ruleObj.value("os");
|
|
||||||
if(!osVal.isObject())
|
|
||||||
{
|
|
||||||
// add a new implicit action rule
|
|
||||||
rules.append(ImplicitRule::create(action));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto osObj = osVal.toObject();
|
|
||||||
auto osNameVal = osObj.value("name");
|
|
||||||
if(!osNameVal.isString())
|
|
||||||
continue;
|
|
||||||
OpSys requiredOs = OpSys_fromString(osNameVal.toString());
|
|
||||||
QString versionRegex = osObj.value("version").toString();
|
|
||||||
// add a new OS rule
|
|
||||||
rules.append(OsRule::create(action, requiredOs, versionRegex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rules;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QSharedPointer<OneSixVersion> FullVersionFactory::parse4(QJsonObject root, QSharedPointer<OneSixVersion> fullVersion)
|
|
||||||
{
|
|
||||||
fullVersion->id = root.value("id").toString();
|
|
||||||
|
|
||||||
fullVersion->mainClass = root.value("mainClass").toString();
|
|
||||||
auto procArgsValue = root.value("processArguments");
|
|
||||||
if(procArgsValue.isString())
|
|
||||||
{
|
|
||||||
fullVersion->processArguments = procArgsValue.toString();
|
|
||||||
QString toCompare = fullVersion->processArguments.toLower();
|
|
||||||
if(toCompare == "legacy")
|
|
||||||
{
|
|
||||||
fullVersion->minecraftArguments = " ${auth_player_name} ${auth_session}";
|
|
||||||
}
|
|
||||||
else if(toCompare == "username_session")
|
|
||||||
{
|
|
||||||
fullVersion->minecraftArguments = "--username ${auth_player_name} --session ${auth_session}";
|
|
||||||
}
|
|
||||||
else if(toCompare == "username_session_version")
|
|
||||||
{
|
|
||||||
fullVersion->minecraftArguments = "--username ${auth_player_name} --session ${auth_session} --version ${profile_name}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto minecraftArgsValue = root.value("minecraftArguments");
|
|
||||||
if(minecraftArgsValue.isString())
|
|
||||||
{
|
|
||||||
fullVersion->minecraftArguments = minecraftArgsValue.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto minecraftTypeValue = root.value("type");
|
|
||||||
if(minecraftTypeValue.isString())
|
|
||||||
{
|
|
||||||
fullVersion->type = minecraftTypeValue.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
fullVersion->releaseTime = root.value("releaseTime").toString();
|
|
||||||
fullVersion->time = root.value("time").toString();
|
|
||||||
|
|
||||||
// Iterate through the list, if it's a list.
|
|
||||||
auto librariesValue = root.value("libraries");
|
|
||||||
if(!librariesValue.isArray())
|
|
||||||
return fullVersion;
|
|
||||||
|
|
||||||
QJsonArray libList = root.value("libraries").toArray();
|
|
||||||
for (auto libVal : libList)
|
|
||||||
{
|
|
||||||
if (!libVal.isObject())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonObject libObj = libVal.toObject();
|
|
||||||
|
|
||||||
// Library name
|
|
||||||
auto nameVal = libObj.value("name");
|
|
||||||
if(!nameVal.isString())
|
|
||||||
continue;
|
|
||||||
QSharedPointer<OneSixLibrary> library(new OneSixLibrary(nameVal.toString()));
|
|
||||||
|
|
||||||
auto urlVal = libObj.value("url");
|
|
||||||
if(urlVal.isString())
|
|
||||||
{
|
|
||||||
library->setBaseUrl(urlVal.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract excludes (if any)
|
|
||||||
auto extractVal = libObj.value("extract");
|
|
||||||
if(extractVal.isObject())
|
|
||||||
{
|
|
||||||
QStringList excludes;
|
|
||||||
auto extractObj = extractVal.toObject();
|
|
||||||
auto excludesVal = extractObj.value("exclude");
|
|
||||||
if(!excludesVal.isArray())
|
|
||||||
goto SKIP_EXTRACTS;
|
|
||||||
auto excludesList = excludesVal.toArray();
|
|
||||||
for(auto excludeVal : excludesList)
|
|
||||||
{
|
|
||||||
if(excludeVal.isString())
|
|
||||||
excludes.append(excludeVal.toString());
|
|
||||||
}
|
|
||||||
library->extract_excludes = excludes;
|
|
||||||
}
|
|
||||||
SKIP_EXTRACTS:
|
|
||||||
|
|
||||||
auto nativesVal = libObj.value("natives");
|
|
||||||
if(nativesVal.isObject())
|
|
||||||
{
|
|
||||||
library->setIsNative();
|
|
||||||
auto nativesObj = nativesVal.toObject();
|
|
||||||
auto iter = nativesObj.begin();
|
|
||||||
while(iter != nativesObj.end())
|
|
||||||
{
|
|
||||||
auto osType = OpSys_fromString(iter.key());
|
|
||||||
if(osType == Os_Other)
|
|
||||||
continue;
|
|
||||||
if(!iter.value().isString())
|
|
||||||
continue;
|
|
||||||
library->addNative(osType, iter.value().toString());
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
library->setRules(parse4rules(libObj));
|
|
||||||
library->finalize();
|
|
||||||
fullVersion->libraries.append(library);
|
|
||||||
}
|
|
||||||
return fullVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
QSharedPointer<OneSixVersion> FullVersionFactory::parse(QByteArray data)
|
|
||||||
{
|
|
||||||
QSharedPointer<OneSixVersion> readVersion(new OneSixVersion());
|
|
||||||
|
|
||||||
QJsonParseError jsonError;
|
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
|
||||||
|
|
||||||
if (jsonError.error != QJsonParseError::NoError)
|
|
||||||
{
|
|
||||||
error_string = QString( "Error reading version file :") + " " + jsonError.errorString();
|
|
||||||
m_error = FullVersionFactory::ParseError;
|
|
||||||
return QSharedPointer<OneSixVersion>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!jsonDoc.isObject())
|
|
||||||
{
|
|
||||||
error_string = "Error reading version file.";
|
|
||||||
m_error = FullVersionFactory::ParseError;
|
|
||||||
return QSharedPointer<OneSixVersion>();
|
|
||||||
}
|
|
||||||
QJsonObject root = jsonDoc.object();
|
|
||||||
|
|
||||||
int launcher_ver = readVersion->minimumLauncherVersion = root.value("minimumLauncherVersion").toDouble();
|
|
||||||
// ADD MORE HERE :D
|
|
||||||
if(launcher_ver > 0 && launcher_ver <= 7)
|
|
||||||
return parse4(root, readVersion);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
error_string = "Version file was for an unrecognized launcher version. RIP";
|
|
||||||
m_error = FullVersionFactory::UnsupportedVersion;
|
|
||||||
return QSharedPointer<OneSixVersion>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FullVersionFactory::FullVersionFactory()
|
|
||||||
{
|
|
||||||
m_error = FullVersionFactory::AllOK;
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <QtCore>
|
|
||||||
|
|
||||||
struct OneSixVersion;
|
|
||||||
class Rule;
|
|
||||||
|
|
||||||
class FullVersionFactory
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum Error
|
|
||||||
{
|
|
||||||
AllOK, // all parsed OK
|
|
||||||
ParseError, // the file was corrupted somehow
|
|
||||||
UnsupportedVersion // the file was meant for a launcher version we don't support (yet)
|
|
||||||
} m_error;
|
|
||||||
QString error_string;
|
|
||||||
|
|
||||||
public:
|
|
||||||
FullVersionFactory();
|
|
||||||
QSharedPointer<OneSixVersion> parse(QByteArray data);
|
|
||||||
private:
|
|
||||||
QSharedPointer<OneSixVersion> parse4(QJsonObject root, QSharedPointer<OneSixVersion> product);
|
|
||||||
QList<QSharedPointer<Rule> > parse4rules(QJsonObject & baseObj);
|
|
||||||
};
|
|
@ -25,10 +25,8 @@
|
|||||||
|
|
||||||
#define JSON_URL "http://files.minecraftforge.net/minecraftforge/json"
|
#define JSON_URL "http://files.minecraftforge.net/minecraftforge/json"
|
||||||
|
|
||||||
|
|
||||||
ForgeVersionList::ForgeVersionList(QObject *parent) : BaseVersionList(parent)
|
ForgeVersionList::ForgeVersionList(QObject *parent) : BaseVersionList(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Task *ForgeVersionList::getLoadTask()
|
Task *ForgeVersionList::getLoadTask()
|
||||||
@ -154,17 +152,17 @@ void ForgeVersionList::sort()
|
|||||||
// NO-OP for now
|
// NO-OP for now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ForgeListLoadTask::ForgeListLoadTask(ForgeVersionList *vlist) : Task()
|
ForgeListLoadTask::ForgeListLoadTask(ForgeVersionList *vlist) : Task()
|
||||||
{
|
{
|
||||||
m_list = vlist;
|
m_list = vlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ForgeListLoadTask::executeTask()
|
void ForgeListLoadTask::executeTask()
|
||||||
{
|
{
|
||||||
auto job = new DownloadJob("Version index");
|
auto job = new DownloadJob("Version index");
|
||||||
job->add(QUrl(JSON_URL));
|
// we do not care if the version is stale or not.
|
||||||
|
auto forgeListEntry = MMC->metacache()->resolveEntry("minecraftforge", "list.json");
|
||||||
|
job->add(QUrl(JSON_URL), forgeListEntry);
|
||||||
listJob.reset(job);
|
listJob.reset(job);
|
||||||
connect(listJob.data(), SIGNAL(succeeded()), SLOT(list_downloaded()));
|
connect(listJob.data(), SIGNAL(succeeded()), SLOT(list_downloaded()));
|
||||||
connect(listJob.data(), SIGNAL(failed()), SLOT(versionFileFailed()));
|
connect(listJob.data(), SIGNAL(failed()), SLOT(versionFileFailed()));
|
||||||
@ -173,14 +171,21 @@ void ForgeListLoadTask::executeTask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ForgeListLoadTask::list_downloaded()
|
void ForgeListLoadTask::list_downloaded()
|
||||||
|
{
|
||||||
|
QByteArray data;
|
||||||
{
|
{
|
||||||
auto DlJob = listJob->first();
|
auto DlJob = listJob->first();
|
||||||
auto data = DlJob.dynamicCast<ByteArrayDownload>()->m_data;
|
auto filename = DlJob.dynamicCast<CacheDownload>()->m_target_path;
|
||||||
|
QFile listFile(filename);
|
||||||
|
if(!listFile.open(QIODevice::ReadOnly))
|
||||||
|
return;
|
||||||
|
data = listFile.readAll();
|
||||||
|
DlJob.reset();
|
||||||
|
}
|
||||||
|
|
||||||
QJsonParseError jsonError;
|
QJsonParseError jsonError;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
||||||
DlJob.reset();
|
|
||||||
|
|
||||||
if (jsonError.error != QJsonParseError::NoError)
|
if (jsonError.error != QJsonParseError::NoError)
|
||||||
{
|
{
|
||||||
@ -199,7 +204,8 @@ void ForgeListLoadTask::list_downloaded()
|
|||||||
// Now, get the array of versions.
|
// Now, get the array of versions.
|
||||||
if (!root.value("builds").isArray())
|
if (!root.value("builds").isArray())
|
||||||
{
|
{
|
||||||
emitFailed("Error parsing version list JSON: version list object is missing 'builds' array");
|
emitFailed(
|
||||||
|
"Error parsing version list JSON: version list object is missing 'builds' array");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonArray builds = root.value("builds").toArray();
|
QJsonArray builds = root.value("builds").toArray();
|
||||||
@ -220,6 +226,7 @@ void ForgeListLoadTask::list_downloaded()
|
|||||||
QJsonArray files = obj.value("files").toArray();
|
QJsonArray files = obj.value("files").toArray();
|
||||||
QString url, jobbuildver, mcver, buildtype, filename;
|
QString url, jobbuildver, mcver, buildtype, filename;
|
||||||
QString changelog_url, installer_url;
|
QString changelog_url, installer_url;
|
||||||
|
QString installer_filename;
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
for (int j = 0; j < files.count(); j++)
|
for (int j = 0; j < files.count(); j++)
|
||||||
{
|
{
|
||||||
@ -246,6 +253,8 @@ void ForgeListLoadTask::list_downloaded()
|
|||||||
else if (buildtype == "installer")
|
else if (buildtype == "installer")
|
||||||
{
|
{
|
||||||
installer_url = file.value("url").toString();
|
installer_url = file.value("url").toString();
|
||||||
|
int lastSlash = installer_url.lastIndexOf('/');
|
||||||
|
installer_filename = installer_url.mid(lastSlash + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (valid)
|
if (valid)
|
||||||
@ -257,7 +266,10 @@ void ForgeListLoadTask::list_downloaded()
|
|||||||
fVersion->installer_url = installer_url;
|
fVersion->installer_url = installer_url;
|
||||||
fVersion->jobbuildver = jobbuildver;
|
fVersion->jobbuildver = jobbuildver;
|
||||||
fVersion->mcver = mcver;
|
fVersion->mcver = mcver;
|
||||||
|
if (installer_filename.isEmpty())
|
||||||
fVersion->filename = filename;
|
fVersion->filename = filename;
|
||||||
|
else
|
||||||
|
fVersion->filename = installer_filename;
|
||||||
fVersion->m_buildnr = build_nr;
|
fVersion->m_buildnr = build_nr;
|
||||||
tempList.append(fVersion);
|
tempList.append(fVersion);
|
||||||
}
|
}
|
||||||
|
@ -33,18 +33,21 @@ struct ForgeVersion : public BaseVersion
|
|||||||
virtual QString descriptor()
|
virtual QString descriptor()
|
||||||
{
|
{
|
||||||
return filename;
|
return filename;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
virtual QString name()
|
virtual QString name()
|
||||||
{
|
{
|
||||||
return "Forge " + jobbuildver;
|
return "Forge " + jobbuildver;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
virtual QString typeString() const
|
virtual QString typeString() const
|
||||||
{
|
{
|
||||||
if (installer_url.isEmpty())
|
if (installer_url.isEmpty())
|
||||||
return "Universal";
|
return "Universal";
|
||||||
else
|
else
|
||||||
return "Installer";
|
return "Installer";
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
int m_buildnr = 0;
|
int m_buildnr = 0;
|
||||||
QString universal_url;
|
QString universal_url;
|
||||||
@ -72,7 +75,8 @@ public:
|
|||||||
virtual BaseVersionPtr getLatestStable() const;
|
virtual BaseVersionPtr getLatestStable() const;
|
||||||
|
|
||||||
virtual QVariant data(const QModelIndex &index, int role) const;
|
virtual QVariant data(const QModelIndex &index, int role) const;
|
||||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
virtual QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
|
int role) const;
|
||||||
virtual int columnCount(const QModelIndex &parent) const;
|
virtual int columnCount(const QModelIndex &parent) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -80,7 +84,8 @@ protected:
|
|||||||
|
|
||||||
bool m_loaded;
|
bool m_loaded;
|
||||||
|
|
||||||
protected slots:
|
protected
|
||||||
|
slots:
|
||||||
virtual void updateListData(QList<BaseVersionPtr> versions);
|
virtual void updateListData(QList<BaseVersionPtr> versions);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -93,7 +98,8 @@ public:
|
|||||||
|
|
||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
|
|
||||||
protected slots:
|
protected
|
||||||
|
slots:
|
||||||
void list_downloaded();
|
void list_downloaded();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -39,9 +39,11 @@ void CacheDownload::start()
|
|||||||
QNetworkReply *rep = worker->get(request);
|
QNetworkReply *rep = worker->get(request);
|
||||||
|
|
||||||
m_reply = QSharedPointer<QNetworkReply>(rep, &QObject::deleteLater);
|
m_reply = QSharedPointer<QNetworkReply>(rep, &QObject::deleteLater);
|
||||||
connect ( rep, SIGNAL ( downloadProgress ( qint64,qint64 ) ), SLOT ( downloadProgress ( qint64,qint64 ) ) );
|
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
|
||||||
|
SLOT(downloadProgress(qint64, qint64)));
|
||||||
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
|
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));
|
||||||
connect ( rep, SIGNAL ( error ( QNetworkReply::NetworkError ) ), SLOT ( downloadError ( QNetworkReply::NetworkError ) ) );
|
connect(rep, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||||
|
SLOT(downloadError(QNetworkReply::NetworkError)));
|
||||||
connect(rep, SIGNAL(readyRead()), SLOT(downloadReadyRead()));
|
connect(rep, SIGNAL(readyRead()), SLOT(downloadReadyRead()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,15 +76,18 @@ void CacheDownload::downloadFinished()
|
|||||||
{
|
{
|
||||||
if (m_output_file.open(QIODevice::ReadOnly))
|
if (m_output_file.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
m_entry->md5sum = QCryptographicHash::hash ( m_output_file.readAll(), QCryptographicHash::Md5 ).toHex().constData();
|
m_entry->md5sum =
|
||||||
|
QCryptographicHash::hash(m_output_file.readAll(), QCryptographicHash::Md5)
|
||||||
|
.toHex()
|
||||||
|
.constData();
|
||||||
m_output_file.close();
|
m_output_file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QFileInfo output_file_info(m_target_path);
|
QFileInfo output_file_info(m_target_path);
|
||||||
|
|
||||||
|
|
||||||
m_entry->etag = m_reply->rawHeader("ETag").constData();
|
m_entry->etag = m_reply->rawHeader("ETag").constData();
|
||||||
m_entry->last_changed_timestamp = output_file_info.lastModified().toUTC().toMSecsSinceEpoch();
|
m_entry->last_changed_timestamp =
|
||||||
|
output_file_info.lastModified().toUTC().toMSecsSinceEpoch();
|
||||||
m_entry->stale = false;
|
m_entry->stale = false;
|
||||||
MMC->metacache()->updateEntry(m_entry);
|
MMC->metacache()->updateEntry(m_entry);
|
||||||
|
|
||||||
|
@ -30,7 +30,8 @@ public:
|
|||||||
MetaEntryPtr getEntry(QString base, QString resource_path);
|
MetaEntryPtr getEntry(QString base, QString resource_path);
|
||||||
|
|
||||||
// get the entry from cache and verify that it isn't stale (within reason)
|
// get the entry from cache and verify that it isn't stale (within reason)
|
||||||
MetaEntryPtr resolveEntry(QString base, QString resource_path, QString expected_etag = QString());
|
MetaEntryPtr resolveEntry(QString base, QString resource_path,
|
||||||
|
QString expected_etag = QString());
|
||||||
|
|
||||||
// add a previously resolved stale entry
|
// add a previously resolved stale entry
|
||||||
bool updateEntry(MetaEntryPtr stale_entry);
|
bool updateEntry(MetaEntryPtr stale_entry);
|
||||||
@ -41,8 +42,10 @@ public:
|
|||||||
void SaveEventually();
|
void SaveEventually();
|
||||||
void Load();
|
void Load();
|
||||||
QString getBasePath(QString base);
|
QString getBasePath(QString base);
|
||||||
public slots:
|
public
|
||||||
|
slots:
|
||||||
void SaveNow();
|
void SaveNow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// create a new stale entry, given the parameters
|
// create a new stale entry, given the parameters
|
||||||
MetaEntryPtr staleEntry(QString base, QString resource_path);
|
MetaEntryPtr staleEntry(QString base, QString resource_path);
|
||||||
|
@ -30,7 +30,7 @@ void LoginTask::executeTask()
|
|||||||
{
|
{
|
||||||
setStatus(tr("Logging in..."));
|
setStatus(tr("Logging in..."));
|
||||||
auto worker = MMC->qnam();
|
auto worker = MMC->qnam();
|
||||||
connect(worker, SIGNAL(finished(QNetworkReply*)), this, SLOT(processNetReply(QNetworkReply*)));
|
connect(worker.data(), SIGNAL(finished(QNetworkReply*)), this, SLOT(processNetReply(QNetworkReply*)));
|
||||||
|
|
||||||
QUrl loginURL("https://login.minecraft.net/");
|
QUrl loginURL("https://login.minecraft.net/");
|
||||||
QNetworkRequest netRequest(loginURL);
|
QNetworkRequest netRequest(loginURL);
|
||||||
|
Loading…
Reference in New Issue
Block a user