All kinds of incremental improvements
Redone the instance action toolbar: * Removed all the dead actions * Change icon and Rename are now morphed into a header * Added button for opening the config folder Implemented support for loose files and folders as legacy jar mods Added texture pack support
This commit is contained in:
parent
e3b55067eb
commit
d884f849d6
@ -75,17 +75,18 @@ bool JlCompress::compressFile(QuaZip* zip, QString fileName, QString fileDest) {
|
|||||||
* dunque gli errori di compressione di una sotto cartella sono gli stessi di questa
|
* dunque gli errori di compressione di una sotto cartella sono gli stessi di questa
|
||||||
* funzione.
|
* funzione.
|
||||||
*/
|
*/
|
||||||
bool JlCompress::compressSubDir(QuaZip* zip, QString dir, QString origDir, bool recursive) {
|
bool JlCompress::compressSubDir( QuaZip* parentZip, QString dir, QString parentDir, bool recursive, QSet<QString>& added )
|
||||||
|
{
|
||||||
// zip: oggetto dove aggiungere il file
|
// zip: oggetto dove aggiungere il file
|
||||||
// dir: cartella reale corrente
|
// dir: cartella reale corrente
|
||||||
// origDir: cartella reale originale
|
// origDir: cartella reale originale
|
||||||
// (path(dir)-path(origDir)) = path interno all'oggetto zip
|
// (path(dir)-path(origDir)) = path interno all'oggetto zip
|
||||||
|
|
||||||
// Controllo l'apertura dello zip
|
// Controllo l'apertura dello zip
|
||||||
if (!zip) return false;
|
if (!parentZip ) return false;
|
||||||
if (zip->getMode()!=QuaZip::mdCreate &&
|
if ( parentZip->getMode()!=QuaZip::mdCreate &&
|
||||||
zip->getMode()!=QuaZip::mdAppend &&
|
parentZip->getMode()!=QuaZip::mdAppend &&
|
||||||
zip->getMode()!=QuaZip::mdAdd) return false;
|
parentZip->getMode()!=QuaZip::mdAdd) return false;
|
||||||
|
|
||||||
// Controllo la cartella
|
// Controllo la cartella
|
||||||
QDir directory(dir);
|
QDir directory(dir);
|
||||||
@ -95,24 +96,28 @@ bool JlCompress::compressSubDir(QuaZip* zip, QString dir, QString origDir, bool
|
|||||||
if (recursive) {
|
if (recursive) {
|
||||||
// Per ogni sotto cartella
|
// Per ogni sotto cartella
|
||||||
QFileInfoList files = directory.entryInfoList(QDir::AllDirs|QDir::NoDotAndDotDot);
|
QFileInfoList files = directory.entryInfoList(QDir::AllDirs|QDir::NoDotAndDotDot);
|
||||||
Q_FOREACH (QFileInfo file, files) {
|
Q_FOREACH (QFileInfo file, files)
|
||||||
|
{
|
||||||
// Comprimo la sotto cartella
|
// Comprimo la sotto cartella
|
||||||
if(!compressSubDir(zip,file.absoluteFilePath(),origDir,recursive)) return false;
|
if(!compressSubDir( parentZip,file.absoluteFilePath(),parentDir,recursive,added)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per ogni file nella cartella
|
// Per ogni file nella cartella
|
||||||
QFileInfoList files = directory.entryInfoList(QDir::Files);
|
QFileInfoList files = directory.entryInfoList(QDir::Files);
|
||||||
QDir origDirectory(origDir);
|
QDir origDirectory( parentDir );
|
||||||
Q_FOREACH (QFileInfo file, files) {
|
Q_FOREACH (QFileInfo file, files)
|
||||||
|
{
|
||||||
// Se non e un file o e il file compresso che sto creando
|
// Se non e un file o e il file compresso che sto creando
|
||||||
if(!file.isFile()||file.absoluteFilePath()==zip->getZipName()) continue;
|
if(!file.isFile()||file.absoluteFilePath()==parentZip->getZipName()) continue;
|
||||||
|
|
||||||
// Creo il nome relativo da usare all'interno del file compresso
|
// Creo il nome relativo da usare all'interno del file compresso
|
||||||
QString filename = origDirectory.relativeFilePath(file.absoluteFilePath());
|
QString filename = origDirectory.relativeFilePath(file.absoluteFilePath());
|
||||||
|
|
||||||
// Comprimo il file
|
// Comprimo il file
|
||||||
if (!compressFile(zip,file.absoluteFilePath(),filename)) return false;
|
if (!compressFile( parentZip,file.absoluteFilePath(),filename))
|
||||||
|
return false;
|
||||||
|
added.insert(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -290,9 +295,10 @@ bool JlCompress::compressDir(QString fileCompressed, QString dir, bool recursive
|
|||||||
QFile::remove(fileCompressed);
|
QFile::remove(fileCompressed);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
QSet<QString> added;
|
||||||
// Aggiungo i file e le sotto cartelle
|
// Aggiungo i file e le sotto cartelle
|
||||||
if (!compressSubDir(&zip,dir,dir,recursive)) {
|
if (!compressSubDir(&zip,dir,dir,recursive, added))
|
||||||
|
{
|
||||||
QFile::remove(fileCompressed);
|
QFile::remove(fileCompressed);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
class QUAZIP_EXPORT JlCompress {
|
class QUAZIP_EXPORT JlCompress {
|
||||||
private:
|
private:
|
||||||
|
/// Remove some files.
|
||||||
|
/**
|
||||||
|
\param listFile The list of files to remove.
|
||||||
|
\return true if success, false otherwise.
|
||||||
|
*/
|
||||||
|
static bool removeFile(QStringList listFile);
|
||||||
|
public:
|
||||||
/// Compress a single file.
|
/// Compress a single file.
|
||||||
/**
|
/**
|
||||||
\param zip Opened zip to compress the file to.
|
\param zip Opened zip to compress the file to.
|
||||||
@ -34,7 +41,7 @@ private:
|
|||||||
files.
|
files.
|
||||||
\return true if success, false otherwise.
|
\return true if success, false otherwise.
|
||||||
*/
|
*/
|
||||||
static bool compressSubDir(QuaZip* parentZip, QString dir, QString parentDir, bool recursive = true);
|
static bool compressSubDir( QuaZip* parentZip, QString dir, QString parentDir, bool recursive, QSet< QString >& added );
|
||||||
/// Extract a single file.
|
/// Extract a single file.
|
||||||
/**
|
/**
|
||||||
\param zip The opened zip archive to extract from.
|
\param zip The opened zip archive to extract from.
|
||||||
@ -43,14 +50,7 @@ private:
|
|||||||
\return true if success, false otherwise.
|
\return true if success, false otherwise.
|
||||||
*/
|
*/
|
||||||
static bool extractFile(QuaZip* zip, QString fileName, QString fileDest);
|
static bool extractFile(QuaZip* zip, QString fileName, QString fileDest);
|
||||||
/// Remove some files.
|
|
||||||
/**
|
|
||||||
\param listFile The list of files to remove.
|
|
||||||
\return true if success, false otherwise.
|
|
||||||
*/
|
|
||||||
static bool removeFile(QStringList listFile);
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// copy data from inFile to outFile
|
/// copy data from inFile to outFile
|
||||||
static bool copyData(QIODevice &inFile, QIODevice &outFile);
|
static bool copyData(QIODevice &inFile, QIODevice &outFile);
|
||||||
/// Compress a single file.
|
/// Compress a single file.
|
||||||
|
@ -35,18 +35,29 @@ LegacyModEditDialog::LegacyModEditDialog( LegacyInstance* inst, QWidget* parent
|
|||||||
m_mods = m_inst->loaderModList();
|
m_mods = m_inst->loaderModList();
|
||||||
m_coremods = m_inst->coreModList();
|
m_coremods = m_inst->coreModList();
|
||||||
m_jarmods = m_inst->jarModList();
|
m_jarmods = m_inst->jarModList();
|
||||||
|
m_texturepacks = m_inst->texturePackList();
|
||||||
|
|
||||||
ui->jarModsTreeView->setModel(m_jarmods.data());
|
ui->jarModsTreeView->setModel(m_jarmods.data());
|
||||||
ui->coreModsTreeView->setModel(m_coremods.data());
|
ui->coreModsTreeView->setModel(m_coremods.data());
|
||||||
ui->mlModTreeView->setModel(m_mods.data());
|
ui->mlModTreeView->setModel(m_mods.data());
|
||||||
|
ui->texPackTreeView->setModel(m_texturepacks.data());
|
||||||
|
|
||||||
ui->jarModsTreeView->installEventFilter( this );
|
ui->jarModsTreeView->installEventFilter( this );
|
||||||
ui->coreModsTreeView->installEventFilter( this );
|
ui->coreModsTreeView->installEventFilter( this );
|
||||||
ui->mlModTreeView->installEventFilter( this );
|
ui->mlModTreeView->installEventFilter( this );
|
||||||
|
ui->texPackTreeView->installEventFilter( this );
|
||||||
|
m_mods->startWatching();
|
||||||
|
m_coremods->startWatching();
|
||||||
|
m_jarmods->startWatching();
|
||||||
|
m_texturepacks->startWatching();
|
||||||
}
|
}
|
||||||
|
|
||||||
LegacyModEditDialog::~LegacyModEditDialog()
|
LegacyModEditDialog::~LegacyModEditDialog()
|
||||||
{
|
{
|
||||||
|
m_mods->stopWatching();
|
||||||
|
m_coremods->stopWatching();
|
||||||
|
m_jarmods->stopWatching();
|
||||||
|
m_texturepacks->stopWatching();
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +127,22 @@ bool LegacyModEditDialog::loaderListFilter ( QKeyEvent* keyEvent )
|
|||||||
return QDialog::eventFilter( ui->mlModTreeView, keyEvent );
|
return QDialog::eventFilter( ui->mlModTreeView, keyEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LegacyModEditDialog::texturePackListFilter ( QKeyEvent* keyEvent )
|
||||||
|
{
|
||||||
|
switch(keyEvent->key())
|
||||||
|
{
|
||||||
|
case Qt::Key_Delete:
|
||||||
|
on_rmTexPackBtn_clicked();
|
||||||
|
return true;
|
||||||
|
case Qt::Key_Plus:
|
||||||
|
on_addTexPackBtn_clicked();
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QDialog::eventFilter( ui->texPackTreeView, keyEvent );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LegacyModEditDialog::eventFilter ( QObject* obj, QEvent* ev )
|
bool LegacyModEditDialog::eventFilter ( QObject* obj, QEvent* ev )
|
||||||
{
|
{
|
||||||
@ -130,6 +157,8 @@ bool LegacyModEditDialog::eventFilter ( QObject* obj, QEvent* ev )
|
|||||||
return coreListFilter(keyEvent);
|
return coreListFilter(keyEvent);
|
||||||
if(obj == ui->mlModTreeView)
|
if(obj == ui->mlModTreeView)
|
||||||
return loaderListFilter(keyEvent);
|
return loaderListFilter(keyEvent);
|
||||||
|
if(obj == ui->texPackTreeView)
|
||||||
|
return loaderListFilter(keyEvent);
|
||||||
return QDialog::eventFilter( obj, ev );
|
return QDialog::eventFilter( obj, ev );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +168,9 @@ void LegacyModEditDialog::on_addCoreBtn_clicked()
|
|||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Core Mods");
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Core Mods");
|
||||||
for(auto filename:fileNames)
|
for(auto filename:fileNames)
|
||||||
{
|
{
|
||||||
|
m_coremods->stopWatching();
|
||||||
m_coremods->installMod(QFileInfo(filename));
|
m_coremods->installMod(QFileInfo(filename));
|
||||||
|
m_coremods->startWatching();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_addForgeBtn_clicked()
|
void LegacyModEditDialog::on_addForgeBtn_clicked()
|
||||||
@ -151,7 +182,9 @@ void LegacyModEditDialog::on_addJarBtn_clicked()
|
|||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Jar Mods");
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Jar Mods");
|
||||||
for(auto filename:fileNames)
|
for(auto filename:fileNames)
|
||||||
{
|
{
|
||||||
|
m_jarmods->stopWatching();
|
||||||
m_jarmods->installMod(QFileInfo(filename));
|
m_jarmods->installMod(QFileInfo(filename));
|
||||||
|
m_jarmods->startWatching();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_addModBtn_clicked()
|
void LegacyModEditDialog::on_addModBtn_clicked()
|
||||||
@ -159,12 +192,20 @@ void LegacyModEditDialog::on_addModBtn_clicked()
|
|||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Loader Mods");
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Loader Mods");
|
||||||
for(auto filename:fileNames)
|
for(auto filename:fileNames)
|
||||||
{
|
{
|
||||||
|
m_mods->stopWatching();
|
||||||
m_mods->installMod(QFileInfo(filename));
|
m_mods->installMod(QFileInfo(filename));
|
||||||
|
m_mods->startWatching();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_addTexPackBtn_clicked()
|
void LegacyModEditDialog::on_addTexPackBtn_clicked()
|
||||||
{
|
{
|
||||||
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Texture Packs");
|
||||||
|
for(auto filename:fileNames)
|
||||||
|
{
|
||||||
|
m_texturepacks->stopWatching();
|
||||||
|
m_texturepacks->installMod(QFileInfo(filename));
|
||||||
|
m_texturepacks->startWatching();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lastfirst (QModelIndexList & list, int & first, int & last)
|
bool lastfirst (QModelIndexList & list, int & first, int & last)
|
||||||
@ -209,7 +250,9 @@ void LegacyModEditDialog::on_rmCoreBtn_clicked()
|
|||||||
|
|
||||||
if(!lastfirst(list, first, last))
|
if(!lastfirst(list, first, last))
|
||||||
return;
|
return;
|
||||||
|
m_coremods->stopWatching();
|
||||||
m_coremods->deleteMods(first, last);
|
m_coremods->deleteMods(first, last);
|
||||||
|
m_coremods->startWatching();
|
||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_rmJarBtn_clicked()
|
void LegacyModEditDialog::on_rmJarBtn_clicked()
|
||||||
{
|
{
|
||||||
@ -218,7 +261,9 @@ void LegacyModEditDialog::on_rmJarBtn_clicked()
|
|||||||
|
|
||||||
if(!lastfirst(list, first, last))
|
if(!lastfirst(list, first, last))
|
||||||
return;
|
return;
|
||||||
|
m_jarmods->stopWatching();
|
||||||
m_jarmods->deleteMods(first, last);
|
m_jarmods->deleteMods(first, last);
|
||||||
|
m_jarmods->startWatching();
|
||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_rmModBtn_clicked()
|
void LegacyModEditDialog::on_rmModBtn_clicked()
|
||||||
{
|
{
|
||||||
@ -227,11 +272,20 @@ void LegacyModEditDialog::on_rmModBtn_clicked()
|
|||||||
|
|
||||||
if(!lastfirst(list, first, last))
|
if(!lastfirst(list, first, last))
|
||||||
return;
|
return;
|
||||||
|
m_mods->stopWatching();
|
||||||
m_mods->deleteMods(first, last);
|
m_mods->deleteMods(first, last);
|
||||||
|
m_mods->startWatching();
|
||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_rmTexPackBtn_clicked()
|
void LegacyModEditDialog::on_rmTexPackBtn_clicked()
|
||||||
{
|
{
|
||||||
|
int first, last;
|
||||||
|
auto list = ui->texPackTreeView->selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
if(!lastfirst(list, first, last))
|
||||||
|
return;
|
||||||
|
m_texturepacks->stopWatching();
|
||||||
|
m_texturepacks->deleteMods(first, last);
|
||||||
|
m_texturepacks->startWatching();
|
||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_viewCoreBtn_clicked()
|
void LegacyModEditDialog::on_viewCoreBtn_clicked()
|
||||||
{
|
{
|
||||||
@ -243,7 +297,7 @@ void LegacyModEditDialog::on_viewModBtn_clicked()
|
|||||||
}
|
}
|
||||||
void LegacyModEditDialog::on_viewTexPackBtn_clicked()
|
void LegacyModEditDialog::on_viewTexPackBtn_clicked()
|
||||||
{
|
{
|
||||||
//openDirInDefaultProgram(m_inst->mlModsDir(), true);
|
openDirInDefaultProgram(m_inst->texturePackDir(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ protected:
|
|||||||
bool jarListFilter( QKeyEvent* ev );
|
bool jarListFilter( QKeyEvent* ev );
|
||||||
bool coreListFilter( QKeyEvent* ev );
|
bool coreListFilter( QKeyEvent* ev );
|
||||||
bool loaderListFilter( QKeyEvent* ev );
|
bool loaderListFilter( QKeyEvent* ev );
|
||||||
|
bool texturePackListFilter( QKeyEvent* ev );
|
||||||
private:
|
private:
|
||||||
Ui::LegacyModEditDialog *ui;
|
Ui::LegacyModEditDialog *ui;
|
||||||
QSharedPointer<ModList> m_mods;
|
QSharedPointer<ModList> m_mods;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="jarTab">
|
<widget class="QWidget" name="jarTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -261,7 +261,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Reset</set>
|
<set>QDialogButtonBox::Close</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
#include "osutils.h"
|
#include "osutils.h"
|
||||||
#include "userutils.h"
|
#include "userutils.h"
|
||||||
@ -58,6 +60,8 @@
|
|||||||
#include "logic/OneSixUpdate.h"
|
#include "logic/OneSixUpdate.h"
|
||||||
#include "logic/lists/MinecraftVersionList.h"
|
#include "logic/lists/MinecraftVersionList.h"
|
||||||
#include "logic/lists/LwjglVersionList.h"
|
#include "logic/lists/LwjglVersionList.h"
|
||||||
|
#include <logic/IconListModel.h>
|
||||||
|
#include <logic/LegacyInstance.h>
|
||||||
|
|
||||||
#include "instancemodel.h"
|
#include "instancemodel.h"
|
||||||
#include "instancedelegate.h"
|
#include "instancedelegate.h"
|
||||||
@ -70,9 +74,12 @@ MainWindow::MainWindow ( QWidget *parent ) :
|
|||||||
{
|
{
|
||||||
ui->setupUi ( this );
|
ui->setupUi ( this );
|
||||||
|
|
||||||
|
// Set the selected instance to null
|
||||||
|
m_selectedInstance = nullptr;
|
||||||
// Set active instance to null.
|
// Set active instance to null.
|
||||||
m_activeInst = NULL;
|
m_activeInst = nullptr;
|
||||||
|
// the rename label is inside the rename tool button
|
||||||
|
renameLabel = nullptr;
|
||||||
// Create the widget
|
// Create the widget
|
||||||
view = new KCategorizedView ( ui->centralWidget );
|
view = new KCategorizedView ( ui->centralWidget );
|
||||||
drawer = new KCategoryDrawer ( view );
|
drawer = new KCategoryDrawer ( view );
|
||||||
@ -118,12 +125,14 @@ MainWindow::MainWindow ( QWidget *parent ) :
|
|||||||
// restoreGeometry(settings->getConfig().value("MainWindowGeometry", saveGeometry()).toByteArray());
|
// restoreGeometry(settings->getConfig().value("MainWindowGeometry", saveGeometry()).toByteArray());
|
||||||
// restoreState(settings->getConfig().value("MainWindowState", saveState()).toByteArray());
|
// restoreState(settings->getConfig().value("MainWindowState", saveState()).toByteArray());
|
||||||
view->setModel ( proxymodel );
|
view->setModel ( proxymodel );
|
||||||
connect(view, SIGNAL(doubleClicked(const QModelIndex &)),
|
connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(instanceActivated(const QModelIndex &)));
|
||||||
this, SLOT(instanceActivated(const QModelIndex &)));
|
auto selectionmodel = view->selectionModel();
|
||||||
|
connect(
|
||||||
connect(view, SIGNAL(clicked(const QModelIndex &)),
|
selectionmodel,
|
||||||
this, SLOT(instanceChanged(const QModelIndex &)));
|
SIGNAL(currentChanged(const QModelIndex &,const QModelIndex &)),
|
||||||
|
this,
|
||||||
|
SLOT(instanceChanged(const QModelIndex &,const QModelIndex &))
|
||||||
|
);
|
||||||
// Load the instances. FIXME: this is not the place I'd say.
|
// Load the instances. FIXME: this is not the place I'd say.
|
||||||
instList.loadList();
|
instList.loadList();
|
||||||
|
|
||||||
@ -242,31 +251,32 @@ void MainWindow::on_actionAddInstance_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionChangeInstIcon_triggered()
|
void MainWindow::on_actionChangeInstIcon_triggered()
|
||||||
{
|
{
|
||||||
BaseInstance* inst = selectedInstance();
|
if(!m_selectedInstance)
|
||||||
if(!inst)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IconPickerDialog dlg(this);
|
IconPickerDialog dlg(this);
|
||||||
dlg.exec(selectedInstance()->iconKey());
|
dlg.exec(m_selectedInstance->iconKey());
|
||||||
if(dlg.result() == QDialog::Accepted)
|
if(dlg.result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
selectedInstance()->setIconKey(dlg.selectedIconKey);
|
m_selectedInstance->setIconKey(dlg.selectedIconKey);
|
||||||
|
IconList * iconListModel = IconList::instance();
|
||||||
|
auto ico =iconListModel->getIcon(dlg.selectedIconKey);
|
||||||
|
ui->actionChangeInstIcon->setIcon(ico);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionChangeInstGroup_triggered()
|
void MainWindow::on_actionChangeInstGroup_triggered()
|
||||||
{
|
{
|
||||||
BaseInstance* inst = selectedInstance();
|
if(!m_selectedInstance)
|
||||||
if(!inst)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QString name ( inst->group() );
|
QString name ( m_selectedInstance->group() );
|
||||||
name = QInputDialog::getText ( this, tr ( "Group name" ), tr ( "Enter a new group name." ),
|
name = QInputDialog::getText ( this, tr ( "Group name" ), tr ( "Enter a new group name." ),
|
||||||
QLineEdit::Normal, name, &ok );
|
QLineEdit::Normal, name, &ok );
|
||||||
if(ok)
|
if(ok)
|
||||||
inst->setGroup(name);
|
m_selectedInstance->setGroup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -286,6 +296,16 @@ void MainWindow::on_actionViewCentralModsFolder_triggered()
|
|||||||
openDirInDefaultProgram ( globalSettings->get ( "CentralModsDir" ).toString() , true);
|
openDirInDefaultProgram ( globalSettings->get ( "CentralModsDir" ).toString() , true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionConfig_Folder_triggered()
|
||||||
|
{
|
||||||
|
if(m_selectedInstance)
|
||||||
|
{
|
||||||
|
QString str = m_selectedInstance->instanceConfigFolder();
|
||||||
|
openDirInDefaultProgram ( QDir(str).absolutePath() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionCheckUpdate_triggered()
|
void MainWindow::on_actionCheckUpdate_triggered()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -322,14 +342,13 @@ void MainWindow::on_mainToolBar_visibilityChanged ( bool )
|
|||||||
|
|
||||||
void MainWindow::on_actionDeleteInstance_triggered()
|
void MainWindow::on_actionDeleteInstance_triggered()
|
||||||
{
|
{
|
||||||
BaseInstance* inst = selectedInstance();
|
if (m_selectedInstance)
|
||||||
if (inst)
|
|
||||||
{
|
{
|
||||||
int response = QMessageBox::question(this, "CAREFUL",
|
int response = QMessageBox::question(this, "CAREFUL",
|
||||||
QString("This is permanent! Are you sure?\nAbout to delete: ") + inst->name());
|
QString("This is permanent! Are you sure?\nAbout to delete: ") + m_selectedInstance->name());
|
||||||
if (response == QMessageBox::Yes)
|
if (response == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
QDir(inst->instanceRoot()).removeRecursively();
|
QDir(m_selectedInstance->instanceRoot()).removeRecursively();
|
||||||
instList.loadList();
|
instList.loadList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,38 +356,38 @@ void MainWindow::on_actionDeleteInstance_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionRenameInstance_triggered()
|
void MainWindow::on_actionRenameInstance_triggered()
|
||||||
{
|
{
|
||||||
BaseInstance* inst = selectedInstance();
|
if(m_selectedInstance)
|
||||||
if(inst)
|
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QString name ( inst->name() );
|
QString name ( m_selectedInstance->name() );
|
||||||
name = QInputDialog::getText ( this, tr ( "Instance name" ), tr ( "Enter a new instance name." ),
|
name = QInputDialog::getText ( this, tr ( "Instance name" ), tr ( "Enter a new instance name." ),
|
||||||
QLineEdit::Normal, name, &ok );
|
QLineEdit::Normal, name, &ok );
|
||||||
|
|
||||||
if (name.length() > 0)
|
if (name.length() > 0)
|
||||||
{
|
{
|
||||||
if(ok && name.length() && name.length() <= 25)
|
if(ok && name.length() && name.length() <= 25)
|
||||||
inst->setName(name);
|
m_selectedInstance->setName(name);
|
||||||
|
//ui->actionRenameInstance->setText(name);
|
||||||
|
setRenameText(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionViewSelectedInstFolder_triggered()
|
void MainWindow::on_actionViewSelectedInstFolder_triggered()
|
||||||
{
|
{
|
||||||
BaseInstance* inst = selectedInstance();
|
if(m_selectedInstance)
|
||||||
if(inst)
|
|
||||||
{
|
{
|
||||||
QString str = inst->instanceRoot();
|
QString str = m_selectedInstance->instanceRoot();
|
||||||
openDirInDefaultProgram ( QDir(str).absolutePath() );
|
openDirInDefaultProgram ( QDir(str).absolutePath() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionEditInstMods_triggered()
|
void MainWindow::on_actionEditInstMods_triggered()
|
||||||
{
|
{
|
||||||
BaseInstance* inst = selectedInstance();
|
if (m_selectedInstance)
|
||||||
if (inst)
|
|
||||||
{
|
{
|
||||||
auto dialog = inst->createModEditDialog(this);
|
auto dialog = m_selectedInstance->createModEditDialog(this);
|
||||||
if(dialog)
|
if(dialog)
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
dialog->deleteLater();
|
dialog->deleteLater();
|
||||||
@ -394,30 +413,9 @@ void MainWindow::on_instanceView_customContextMenuRequested ( const QPoint &pos
|
|||||||
instContextMenu->exec ( view->mapToGlobal ( pos ) );
|
instContextMenu->exec ( view->mapToGlobal ( pos ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseInstance* MainWindow::selectedInstance()
|
|
||||||
{
|
|
||||||
QAbstractItemView * iv = view;
|
|
||||||
auto smodel = iv->selectionModel();
|
|
||||||
QModelIndex mindex;
|
|
||||||
if(smodel->hasSelection())
|
|
||||||
{
|
|
||||||
auto rows = smodel->selectedRows();
|
|
||||||
mindex = rows.at(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mindex.isValid())
|
|
||||||
{
|
|
||||||
return (BaseInstance *) mindex.data(InstanceModel::InstancePointerRole).value<void *>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionLaunchInstance_triggered()
|
void MainWindow::on_actionLaunchInstance_triggered()
|
||||||
{
|
{
|
||||||
BaseInstance* inst = selectedInstance();
|
if(m_selectedInstance)
|
||||||
if(inst)
|
|
||||||
{
|
{
|
||||||
doLogin();
|
doLogin();
|
||||||
}
|
}
|
||||||
@ -425,7 +423,7 @@ void MainWindow::on_actionLaunchInstance_triggered()
|
|||||||
|
|
||||||
void MainWindow::doLogin(const QString& errorMsg)
|
void MainWindow::doLogin(const QString& errorMsg)
|
||||||
{
|
{
|
||||||
if (!selectedInstance())
|
if (!m_selectedInstance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LoginDialog* loginDlg = new LoginDialog(this, errorMsg);
|
LoginDialog* loginDlg = new LoginDialog(this, errorMsg);
|
||||||
@ -438,7 +436,7 @@ void MainWindow::doLogin(const QString& errorMsg)
|
|||||||
LoginTask* loginTask = new LoginTask(uInfo, tDialog);
|
LoginTask* loginTask = new LoginTask(uInfo, tDialog);
|
||||||
connect(loginTask, SIGNAL(succeeded()),SLOT(onLoginComplete()), Qt::QueuedConnection);
|
connect(loginTask, SIGNAL(succeeded()),SLOT(onLoginComplete()), Qt::QueuedConnection);
|
||||||
connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)), Qt::QueuedConnection);
|
connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)), Qt::QueuedConnection);
|
||||||
m_activeInst = selectedInstance();
|
m_activeInst = m_selectedInstance;
|
||||||
tDialog->exec(loginTask);
|
tDialog->exec(loginTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -534,27 +532,24 @@ void MainWindow::on_actionChangeInstMCVersion_triggered()
|
|||||||
if (view->selectionModel()->selectedIndexes().count() < 1)
|
if (view->selectionModel()->selectedIndexes().count() < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BaseInstance *inst = selectedInstance();
|
VersionSelectDialog vselect(m_selectedInstance->versionList(), this);
|
||||||
|
|
||||||
VersionSelectDialog vselect(inst->versionList(), this);
|
|
||||||
if (vselect.exec() && vselect.selectedVersion())
|
if (vselect.exec() && vselect.selectedVersion())
|
||||||
{
|
{
|
||||||
inst->setIntendedVersionId(vselect.selectedVersion()->descriptor);
|
m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionChangeInstLWJGLVersion_triggered()
|
void MainWindow::on_actionChangeInstLWJGLVersion_triggered()
|
||||||
{
|
{
|
||||||
BaseInstance *inst = selectedInstance();
|
if (!m_selectedInstance)
|
||||||
|
|
||||||
if (!inst)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LWJGLSelectDialog lselect(this);
|
LWJGLSelectDialog lselect(this);
|
||||||
lselect.exec();
|
lselect.exec();
|
||||||
if (lselect.result() == QDialog::Accepted)
|
if (lselect.result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
|
LegacyInstance * linst = (LegacyInstance *) m_selectedInstance;
|
||||||
|
linst->setLWJGLVersion(lselect.selectedVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,14 +558,60 @@ void MainWindow::on_actionInstanceSettings_triggered()
|
|||||||
if (view->selectionModel()->selectedIndexes().count() < 1)
|
if (view->selectionModel()->selectedIndexes().count() < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BaseInstance *inst = selectedInstance();
|
InstanceSettings settings(&m_selectedInstance->settings(), this);
|
||||||
SettingsObject *s;
|
|
||||||
s = &inst->settings();
|
|
||||||
InstanceSettings settings(s, this);
|
|
||||||
settings.setWindowTitle(QString("Instance settings"));
|
settings.setWindowTitle(QString("Instance settings"));
|
||||||
settings.exec();
|
settings.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::instanceChanged(QModelIndex idx) {
|
void MainWindow::setRenameText ( QString text )
|
||||||
ui->instanceToolBar->setEnabled(idx.isValid());
|
{
|
||||||
|
ui->actionRenameInstance->setText(text);
|
||||||
|
// FIXME: too much bullshit.
|
||||||
|
/*
|
||||||
|
QToolButton * toolbtn = (QToolButton *) ui->instanceToolBar->widgetForAction(ui->actionRenameInstance);
|
||||||
|
QLayout *layout = toolbtn->layout();
|
||||||
|
if(!layout)
|
||||||
|
{
|
||||||
|
layout = new QHBoxLayout();
|
||||||
|
renameLabel = new QLabel();
|
||||||
|
renameLabel->setWordWrap(true);
|
||||||
|
renameLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
layout->addWidget(renameLabel);
|
||||||
|
toolbtn->setText(" ");
|
||||||
|
toolbtn->setLayout(layout);
|
||||||
|
toolbtn->setMinimumWidth(120);
|
||||||
|
toolbtn->setMinimumHeight(renameLabel->minsize().height());
|
||||||
|
}
|
||||||
|
if(renameLabel)
|
||||||
|
renameLabel->setText(text);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::instanceChanged( const QModelIndex& current, const QModelIndex& previous )
|
||||||
|
{
|
||||||
|
QString iconKey = "infinity";
|
||||||
|
|
||||||
|
if(current.isValid() && nullptr != (m_selectedInstance = (BaseInstance *) current.data(InstanceModel::InstancePointerRole).value<void *>()))
|
||||||
|
{
|
||||||
|
ui->instanceToolBar->setEnabled(true);
|
||||||
|
iconKey = m_selectedInstance->iconKey();
|
||||||
|
//ui->actionRenameInstance->setText(m_selectedInstance->name());
|
||||||
|
setRenameText(m_selectedInstance->name());
|
||||||
|
ui->actionChangeInstLWJGLVersion->setEnabled(m_selectedInstance->menuActionEnabled("actionChangeInstLWJGLVersion"));
|
||||||
|
ui->actionEditInstMods->setEnabled(m_selectedInstance->menuActionEnabled("actionEditInstMods"));
|
||||||
|
statusBar()->clearMessage();
|
||||||
|
statusBar()->showMessage(m_selectedInstance->getStatusbarDescription());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
statusBar()->clearMessage();
|
||||||
|
ui->instanceToolBar->setEnabled(false);
|
||||||
|
//ui->actionRenameInstance->setText("Rename Instance");
|
||||||
|
setRenameText("Rename Instance");
|
||||||
|
}
|
||||||
|
|
||||||
|
IconList * iconListModel = IconList::instance();
|
||||||
|
auto ico =iconListModel->getIcon(iconKey);
|
||||||
|
ui->actionChangeInstIcon->setIcon(ico);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "logic/tasks/LoginTask.h"
|
#include "logic/tasks/LoginTask.h"
|
||||||
#include "logic/BaseInstance.h"
|
#include "logic/BaseInstance.h"
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
class InstanceModel;
|
class InstanceModel;
|
||||||
class InstanceProxyModel;
|
class InstanceProxyModel;
|
||||||
class KCategorizedView;
|
class KCategorizedView;
|
||||||
@ -39,11 +40,6 @@ class MainWindow : public QMainWindow
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
/*!
|
|
||||||
* The currently selected instance.
|
|
||||||
*/
|
|
||||||
Q_PROPERTY(BaseInstance* selectedInstance READ selectedInstance STORED false)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = 0);
|
explicit MainWindow(QWidget *parent = 0);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
@ -54,8 +50,6 @@ public:
|
|||||||
void openWebPage(QUrl url);
|
void openWebPage(QUrl url);
|
||||||
|
|
||||||
|
|
||||||
BaseInstance *selectedInstance();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionAbout_triggered();
|
void on_actionAbout_triggered();
|
||||||
|
|
||||||
@ -67,6 +61,8 @@ private slots:
|
|||||||
|
|
||||||
void on_actionViewInstanceFolder_triggered();
|
void on_actionViewInstanceFolder_triggered();
|
||||||
|
|
||||||
|
void on_actionConfig_Folder_triggered();
|
||||||
|
|
||||||
void on_actionViewSelectedInstFolder_triggered();
|
void on_actionViewSelectedInstFolder_triggered();
|
||||||
|
|
||||||
void on_actionRefresh_triggered();
|
void on_actionRefresh_triggered();
|
||||||
@ -116,7 +112,7 @@ private slots:
|
|||||||
public slots:
|
public slots:
|
||||||
void instanceActivated ( QModelIndex );
|
void instanceActivated ( QModelIndex );
|
||||||
|
|
||||||
void instanceChanged ( QModelIndex );
|
void instanceChanged (const QModelIndex & current,const QModelIndex & previous);
|
||||||
|
|
||||||
void startTask(Task *task);
|
void startTask(Task *task);
|
||||||
|
|
||||||
@ -124,7 +120,7 @@ public slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *ev);
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
|
void setRenameText(QString text);
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
KCategoryDrawer * drawer;
|
KCategoryDrawer * drawer;
|
||||||
@ -135,6 +131,9 @@ private:
|
|||||||
MinecraftProcess *proc;
|
MinecraftProcess *proc;
|
||||||
ConsoleWindow *console;
|
ConsoleWindow *console;
|
||||||
OneSixAssets *assets_downloader;
|
OneSixAssets *assets_downloader;
|
||||||
|
QLabel * renameLabel;
|
||||||
|
|
||||||
|
BaseInstance *m_selectedInstance;
|
||||||
|
|
||||||
// A pointer to the instance we are actively doing stuff with.
|
// A pointer to the instance we are actively doing stuff with.
|
||||||
// This is set when the user launches an instance and is used to refer to that
|
// This is set when the user launches an instance and is used to refer to that
|
||||||
|
@ -45,6 +45,12 @@
|
|||||||
<property name="allowedAreas">
|
<property name="allowedAreas">
|
||||||
<set>Qt::TopToolBarArea</set>
|
<set>Qt::TopToolBarArea</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonIconOnly</enum>
|
||||||
|
</property>
|
||||||
|
<property name="floatable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<attribute name="toolBarArea">
|
<attribute name="toolBarArea">
|
||||||
<enum>TopToolBarArea</enum>
|
<enum>TopToolBarArea</enum>
|
||||||
</attribute>
|
</attribute>
|
||||||
@ -74,6 +80,15 @@
|
|||||||
<property name="allowedAreas">
|
<property name="allowedAreas">
|
||||||
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea</set>
|
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>80</width>
|
||||||
|
<height>80</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonIconOnly</enum>
|
||||||
|
</property>
|
||||||
<property name="floatable">
|
<property name="floatable">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -83,22 +98,19 @@
|
|||||||
<attribute name="toolBarBreak">
|
<attribute name="toolBarBreak">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<addaction name="actionChangeInstIcon"/>
|
||||||
|
<addaction name="actionRenameInstance"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="actionLaunchInstance"/>
|
<addaction name="actionLaunchInstance"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionRenameInstance"/>
|
|
||||||
<addaction name="actionChangeInstGroup"/>
|
|
||||||
<addaction name="actionChangeInstIcon"/>
|
|
||||||
<addaction name="actionChangeInstMCVersion"/>
|
|
||||||
<addaction name="actionChangeInstLWJGLVersion"/>
|
|
||||||
<addaction name="actionEditInstNotes"/>
|
<addaction name="actionEditInstNotes"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="actionChangeInstGroup"/>
|
||||||
<addaction name="actionEditInstMods"/>
|
|
||||||
<addaction name="actionManageInstSaves"/>
|
|
||||||
<addaction name="actionRebuildInstJar"/>
|
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionInstanceSettings"/>
|
<addaction name="actionInstanceSettings"/>
|
||||||
<addaction name="actionMakeDesktopShortcut"/>
|
<addaction name="actionChangeInstLWJGLVersion"/>
|
||||||
|
<addaction name="actionEditInstMods"/>
|
||||||
<addaction name="actionViewSelectedInstFolder"/>
|
<addaction name="actionViewSelectedInstFolder"/>
|
||||||
|
<addaction name="actionConfig_Folder"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionDeleteInstance"/>
|
<addaction name="actionDeleteInstance"/>
|
||||||
</widget>
|
</widget>
|
||||||
@ -256,7 +268,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionRenameInstance">
|
<action name="actionRenameInstance">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Rename</string>
|
<string>Instance Name</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Rename the selected instance.</string>
|
<string>Rename the selected instance.</string>
|
||||||
@ -280,6 +292,10 @@
|
|||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../multimc.qrc">
|
||||||
|
<normaloff>:/icons/instances/infinity</normaloff>:/icons/instances/infinity</iconset>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Change Icon</string>
|
<string>Change Icon</string>
|
||||||
</property>
|
</property>
|
||||||
@ -291,9 +307,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionEditInstNotes">
|
<action name="actionEditInstNotes">
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Edit Notes</string>
|
<string>Edit Notes</string>
|
||||||
</property>
|
</property>
|
||||||
@ -385,26 +398,9 @@
|
|||||||
<string>Change the version of LWJGL for the selected instance to use.</string>
|
<string>Change the version of LWJGL for the selected instance to use.</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionRebuildInstJar">
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Rebuild Jar</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Reinstall the mods for the selected instance.</string>
|
|
||||||
</property>
|
|
||||||
<property name="statusTip">
|
|
||||||
<string>Reinstall the mods for the selected instance.</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionViewSelectedInstFolder">
|
<action name="actionViewSelectedInstFolder">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>View Folder</string>
|
<string>Instance Folder</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Open the selected instance's root folder in a file browser.</string>
|
<string>Open the selected instance's root folder in a file browser.</string>
|
||||||
@ -424,6 +420,14 @@
|
|||||||
<string>Delete the selected instance.</string>
|
<string>Delete the selected instance.</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionConfig_Folder">
|
||||||
|
<property name="text">
|
||||||
|
<string>Config Folder</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Open the instance's config folder</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -149,6 +149,14 @@ public:
|
|||||||
|
|
||||||
/// create a mod edit dialog for the instance
|
/// create a mod edit dialog for the instance
|
||||||
virtual QDialog * createModEditDialog ( QWidget* parent ) = 0;
|
virtual QDialog * createModEditDialog ( QWidget* parent ) = 0;
|
||||||
|
|
||||||
|
/// is a particular action enabled with this instance selected?
|
||||||
|
virtual bool menuActionEnabled(QString action_name) const = 0;
|
||||||
|
|
||||||
|
virtual QString getStatusbarDescription() = 0;
|
||||||
|
|
||||||
|
/// FIXME: this really should be elsewhere...
|
||||||
|
virtual QString instanceConfigFolder() const = 0;
|
||||||
signals:
|
signals:
|
||||||
/*!
|
/*!
|
||||||
* \brief Signal emitted when properties relevant to the instance view change
|
* \brief Signal emitted when properties relevant to the instance view change
|
||||||
|
@ -127,6 +127,19 @@ QSharedPointer< ModList > LegacyInstance::loaderModList()
|
|||||||
return d->loader_mod_list;
|
return d->loader_mod_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSharedPointer< ModList > LegacyInstance::texturePackList()
|
||||||
|
{
|
||||||
|
I_D(LegacyInstance);
|
||||||
|
if(!d->texture_pack_list)
|
||||||
|
{
|
||||||
|
d->texture_pack_list.reset(new ModList(texturePackDir()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
d->texture_pack_list->update();
|
||||||
|
return d->texture_pack_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QDialog * LegacyInstance::createModEditDialog ( QWidget* parent )
|
QDialog * LegacyInstance::createModEditDialog ( QWidget* parent )
|
||||||
{
|
{
|
||||||
return new LegacyModEditDialog(this, parent);
|
return new LegacyModEditDialog(this, parent);
|
||||||
@ -168,6 +181,10 @@ QString LegacyInstance::resourceDir() const
|
|||||||
{
|
{
|
||||||
return PathCombine(minecraftRoot(), "resources");
|
return PathCombine(minecraftRoot(), "resources");
|
||||||
}
|
}
|
||||||
|
QString LegacyInstance::texturePackDir() const
|
||||||
|
{
|
||||||
|
return PathCombine(minecraftRoot(), "texturepacks");
|
||||||
|
}
|
||||||
|
|
||||||
QString LegacyInstance::runnableJar() const
|
QString LegacyInstance::runnableJar() const
|
||||||
{
|
{
|
||||||
@ -178,6 +195,13 @@ QString LegacyInstance::modListFile() const
|
|||||||
{
|
{
|
||||||
return PathCombine(instanceRoot(), "modlist");
|
return PathCombine(instanceRoot(), "modlist");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString LegacyInstance::instanceConfigFolder() const
|
||||||
|
{
|
||||||
|
return PathCombine(minecraftRoot(), "config");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
bool LegacyInstance::shouldUpdateCurrentVersion() const
|
bool LegacyInstance::shouldUpdateCurrentVersion() const
|
||||||
{
|
{
|
||||||
@ -285,3 +309,15 @@ QString LegacyInstance::defaultCustomBaseJar() const
|
|||||||
return PathCombine(binDir(), "mcbackup.jar");
|
return PathCombine(binDir(), "mcbackup.jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LegacyInstance::menuActionEnabled ( QString action_name ) const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString LegacyInstance::getStatusbarDescription()
|
||||||
|
{
|
||||||
|
if(shouldUpdate())
|
||||||
|
return "Legacy : " + currentVersionId() + " -> " + intendedVersionId();
|
||||||
|
else
|
||||||
|
return "Legacy : " + currentVersionId();
|
||||||
|
}
|
||||||
|
@ -22,14 +22,17 @@ public:
|
|||||||
QSharedPointer<ModList> jarModList();
|
QSharedPointer<ModList> jarModList();
|
||||||
QSharedPointer<ModList> coreModList();
|
QSharedPointer<ModList> coreModList();
|
||||||
QSharedPointer<ModList> loaderModList();
|
QSharedPointer<ModList> loaderModList();
|
||||||
|
QSharedPointer<ModList> texturePackList();
|
||||||
|
|
||||||
////// Directories //////
|
////// Directories //////
|
||||||
QString savesDir() const;
|
QString savesDir() const;
|
||||||
|
QString texturePackDir() const;
|
||||||
QString jarModsDir() const;
|
QString jarModsDir() const;
|
||||||
QString binDir() const;
|
QString binDir() const;
|
||||||
QString mlModsDir() const;
|
QString mlModsDir() const;
|
||||||
QString coreModsDir() const;
|
QString coreModsDir() const;
|
||||||
QString resourceDir() const;
|
QString resourceDir() const;
|
||||||
|
virtual QString instanceConfigFolder() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Whether or not the instance's minecraft.jar needs to be rebuilt.
|
* Whether or not the instance's minecraft.jar needs to be rebuilt.
|
||||||
@ -61,6 +64,9 @@ public:
|
|||||||
virtual QString defaultBaseJar() const;
|
virtual QString defaultBaseJar() const;
|
||||||
virtual QString defaultCustomBaseJar() const;
|
virtual QString defaultCustomBaseJar() const;
|
||||||
|
|
||||||
|
bool menuActionEnabled ( QString action_name ) const;
|
||||||
|
virtual QString getStatusbarDescription();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void jarModsChanged();
|
virtual void jarModsChanged();
|
||||||
};
|
};
|
@ -12,4 +12,5 @@ struct LegacyInstancePrivate: public BaseInstancePrivate
|
|||||||
QSharedPointer<ModList> jar_mod_list;
|
QSharedPointer<ModList> jar_mod_list;
|
||||||
QSharedPointer<ModList> core_mod_list;
|
QSharedPointer<ModList> core_mod_list;
|
||||||
QSharedPointer<ModList> loader_mod_list;
|
QSharedPointer<ModList> loader_mod_list;
|
||||||
|
QSharedPointer<ModList> texture_pack_list;
|
||||||
};
|
};
|
@ -271,7 +271,15 @@ bool LegacyUpdate::MergeZipFiles( QuaZip* into, QFileInfo from, QSet< QString >&
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!zipOutFile.open(QIODevice::WriteOnly, QuaZipNewInfo(fileInsideMod.getActualFileName())))
|
/*
|
||||||
|
QuaZipFileInfo old_info;
|
||||||
|
fileInsideMod.getFileInfo(&old_info);
|
||||||
|
*/
|
||||||
|
QuaZipNewInfo info_out(fileInsideMod.getActualFileName());
|
||||||
|
/*
|
||||||
|
info_out.externalAttr = old_info.externalAttr;
|
||||||
|
*/
|
||||||
|
if(!zipOutFile.open(QIODevice::WriteOnly, info_out))
|
||||||
{
|
{
|
||||||
fileInsideMod.close();
|
fileInsideMod.close();
|
||||||
return false;
|
return false;
|
||||||
@ -369,31 +377,32 @@ void LegacyUpdate::ModTheJar()
|
|||||||
}
|
}
|
||||||
else if (mod.type() == Mod::MOD_SINGLEFILE)
|
else if (mod.type() == Mod::MOD_SINGLEFILE)
|
||||||
{
|
{
|
||||||
zipOut.close();
|
auto filename = mod.filename();
|
||||||
QFile::remove(runnableJar.filePath());
|
if(!JlCompress::compressFile(&zipOut, filename.absoluteFilePath(), filename.fileName()))
|
||||||
emitFailed("Loose files are NOT supported as jar mods.");
|
|
||||||
return;
|
|
||||||
/*
|
|
||||||
wxFileName destFileName = modFileName;
|
|
||||||
destFileName.MakeRelativeTo(m_inst->GetInstModsDir().GetFullPath());
|
|
||||||
wxString destFile = destFileName.GetFullPath();
|
|
||||||
|
|
||||||
if (addedFiles.count(destFile) == 0)
|
|
||||||
{
|
{
|
||||||
wxFFileInputStream input(modFileName.GetFullPath());
|
zipOut.close();
|
||||||
zipOut.PutNextEntry(destFile);
|
QFile::remove(runnableJar.filePath());
|
||||||
zipOut.Write(input);
|
emitFailed("Failed to add " + filename.fileName() + " to the jar");
|
||||||
|
return;
|
||||||
addedFiles.insert(destFile);
|
|
||||||
}
|
}
|
||||||
*/
|
addedFiles.insert(filename.fileName());
|
||||||
|
qDebug() << "Adding file " << filename.fileName() << " from " << filename.absoluteFilePath();
|
||||||
}
|
}
|
||||||
else if (mod.type() == Mod::MOD_FOLDER)
|
else if (mod.type() == Mod::MOD_FOLDER)
|
||||||
{
|
{
|
||||||
zipOut.close();
|
auto filename = mod.filename();
|
||||||
QFile::remove(runnableJar.filePath());
|
QString what_to_zip = filename.absoluteFilePath();
|
||||||
emitFailed("Folders are NOT supported as jar mods.");
|
QDir dir(what_to_zip);
|
||||||
return;
|
dir.cdUp();
|
||||||
|
QString parent_dir = dir.absolutePath();
|
||||||
|
if(!JlCompress::compressSubDir(&zipOut, what_to_zip, parent_dir, true, addedFiles))
|
||||||
|
{
|
||||||
|
zipOut.close();
|
||||||
|
QFile::remove(runnableJar.filePath());
|
||||||
|
emitFailed("Failed to add " + filename.fileName() + " to the jar");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qDebug() << "Adding folder " << filename.fileName() << " from " << filename.absoluteFilePath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
#include <QFileSystemWatcher>
|
||||||
|
|
||||||
ModList::ModList ( const QString& dir, const QString& list_file )
|
ModList::ModList ( const QString& dir, const QString& list_file )
|
||||||
: QAbstractListModel(), m_dir(dir), m_list_file(list_file)
|
: QAbstractListModel(), m_dir(dir), m_list_file(list_file)
|
||||||
@ -28,9 +29,31 @@ ModList::ModList ( const QString& dir, const QString& list_file )
|
|||||||
m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs | QDir::NoSymLinks);
|
m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs | QDir::NoSymLinks);
|
||||||
m_dir.setSorting(QDir::Name);
|
m_dir.setSorting(QDir::Name);
|
||||||
m_list_id = QUuid::createUuid().toString();
|
m_list_id = QUuid::createUuid().toString();
|
||||||
|
m_watcher = new QFileSystemWatcher(this);
|
||||||
|
is_watching = false;
|
||||||
|
connect(m_watcher,SIGNAL(directoryChanged(QString)), this, SLOT(directoryChanged(QString)));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModList::startWatching()
|
||||||
|
{
|
||||||
|
is_watching = m_watcher->addPath(m_dir.absolutePath());
|
||||||
|
if(is_watching)
|
||||||
|
qDebug() << "Started watching " << m_dir.absolutePath();
|
||||||
|
else
|
||||||
|
qDebug() << "Failed to start watching " << m_dir.absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModList::stopWatching()
|
||||||
|
{
|
||||||
|
is_watching = !m_watcher->removePath(m_dir.absolutePath());
|
||||||
|
if(!is_watching)
|
||||||
|
qDebug() << "Stopped watching " << m_dir.absolutePath();
|
||||||
|
else
|
||||||
|
qDebug() << "Failed to stop watching " << m_dir.absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ModList::update()
|
bool ModList::update()
|
||||||
{
|
{
|
||||||
if (!isValid())
|
if (!isValid())
|
||||||
@ -88,6 +111,12 @@ bool ModList::update()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModList::directoryChanged ( QString path )
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList ModList::readListFile()
|
QStringList ModList::readListFile()
|
||||||
{
|
{
|
||||||
QStringList stringList;
|
QStringList stringList;
|
||||||
@ -333,11 +362,11 @@ QVariant ModList::headerData ( int section, Qt::Orientation orientation, int rol
|
|||||||
switch (section)
|
switch (section)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return QString("Mod Name");
|
return QString("Name");
|
||||||
case 1:
|
case 1:
|
||||||
return QString("Mod Version");
|
return QString("Version");
|
||||||
case 2:
|
case 2:
|
||||||
return QString("MC Version");
|
return QString("Minecraft");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,6 +441,9 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r
|
|||||||
// files dropped from outside?
|
// files dropped from outside?
|
||||||
if(data->hasUrls())
|
if(data->hasUrls())
|
||||||
{
|
{
|
||||||
|
bool was_watching = is_watching;
|
||||||
|
if(was_watching)
|
||||||
|
stopWatching();
|
||||||
auto urls = data->urls();
|
auto urls = data->urls();
|
||||||
for(auto url: urls)
|
for(auto url: urls)
|
||||||
{
|
{
|
||||||
@ -422,6 +454,8 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r
|
|||||||
installMod(filename, row);
|
installMod(filename, row);
|
||||||
qDebug() << "installing: " << filename;
|
qDebug() << "installing: " << filename;
|
||||||
}
|
}
|
||||||
|
if(was_watching)
|
||||||
|
startWatching();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(data->hasText())
|
else if(data->hasText())
|
||||||
@ -446,305 +480,3 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
ModList::ModList(const QString &dir)
|
|
||||||
: modsFolder(dir)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ModList::update(bool quickLoad)
|
|
||||||
{
|
|
||||||
bool listChanged = false;
|
|
||||||
|
|
||||||
// Check for mods in the list whose files do not exist and remove them from the list.
|
|
||||||
// If doing a quickLoad, erase the whole list.
|
|
||||||
for (size_t i = 0; i < size(); i++)
|
|
||||||
{
|
|
||||||
if (quickLoad || !at(i).GetFileName().FileExists())
|
|
||||||
{
|
|
||||||
erase(begin() + i);
|
|
||||||
i--;
|
|
||||||
listChanged = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add any mods in the mods folder that aren't already in the list.
|
|
||||||
if (LoadModListFromDir(QString(), quickLoad))
|
|
||||||
listChanged = true;
|
|
||||||
|
|
||||||
return listChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ModList::LoadModListFromDir(const QString& loadFrom, bool quickLoad)
|
|
||||||
{
|
|
||||||
QString dir(loadFrom.isEmpty() ? modsFolder : loadFrom);
|
|
||||||
|
|
||||||
QDir modDir(dir);
|
|
||||||
if (!modDir.exists())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
bool listChanged = false;
|
|
||||||
|
|
||||||
auto list = modDir.entryInfoList(QDir::Readable|QDir::NoDotAndDotDot, QDir::Name);
|
|
||||||
for(auto currentFile: list)
|
|
||||||
{
|
|
||||||
if (currentFile.isFile())
|
|
||||||
{
|
|
||||||
if (quickLoad || FindByFilename(currentFile.absoluteFilePath()) == nullptr)
|
|
||||||
{
|
|
||||||
Mod mod(currentFile.absoluteFilePath());
|
|
||||||
push_back(mod);
|
|
||||||
listChanged = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (currentFile.isDir())
|
|
||||||
{
|
|
||||||
if (LoadModListFromDir(currentFile.absoluteFilePath()))
|
|
||||||
listChanged = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return listChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
Mod *ModList::FindByFilename(const QString& filename)
|
|
||||||
{
|
|
||||||
// Search the list for a mod with the given filename.
|
|
||||||
for (auto iter = begin(); iter != end(); ++iter)
|
|
||||||
{
|
|
||||||
if (iter->GetFileName() == QFileInfo(filename))
|
|
||||||
return &(*iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If nothing is found, return nullptr.
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ModList::FindIndexByFilename(const QString& filename)
|
|
||||||
{
|
|
||||||
// Search the list for a mod with the given filename.
|
|
||||||
int i = 0;
|
|
||||||
for (auto iter = begin(); iter != end(); ++iter, i++)
|
|
||||||
{
|
|
||||||
if (iter->GetFileName() == QFileInfo(filename))
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If nothing is found, return nullptr.
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Mod* ModList::FindByID(const QString& modID, const QString& modVersion)
|
|
||||||
{
|
|
||||||
// Search the list for a mod that matches
|
|
||||||
for (auto iter = begin(); iter != end(); ++iter)
|
|
||||||
{
|
|
||||||
QString ID = iter->GetModID();
|
|
||||||
QString version = iter->GetModVersion();
|
|
||||||
if ( ID == modID && version == modVersion)
|
|
||||||
return &(*iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If nothing is found, return nullptr.
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModList::LoadFromFile(const QString& file)
|
|
||||||
{
|
|
||||||
if (!wxFileExists(file))
|
|
||||||
return;
|
|
||||||
|
|
||||||
wxFFileInputStream inputStream(file);
|
|
||||||
wxArrayString modListFile = ReadAllLines(inputStream);
|
|
||||||
|
|
||||||
for (wxArrayString::iterator iter = modListFile.begin(); iter != modListFile.end(); iter++)
|
|
||||||
{
|
|
||||||
// Normalize the path to the instMods dir.
|
|
||||||
wxFileName modFile(*iter);
|
|
||||||
modFile.Normalize(wxPATH_NORM_ALL, modsFolder);
|
|
||||||
modFile.MakeRelativeTo();
|
|
||||||
// if the file is gone, do not load it
|
|
||||||
if(!modFile.Exists())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FindByFilename(modFile.GetFullPath()) == nullptr)
|
|
||||||
{
|
|
||||||
push_back(Mod(modFile));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModList::SaveToFile(const QString& file)
|
|
||||||
{
|
|
||||||
QString text;
|
|
||||||
for (iterator iter = begin(); iter != end(); ++iter)
|
|
||||||
{
|
|
||||||
wxFileName modFile = iter->GetFileName();
|
|
||||||
modFile.MakeRelativeTo(modsFolder);
|
|
||||||
text.append(modFile.GetFullPath());
|
|
||||||
text.append("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
wxTempFileOutputStream out(file);
|
|
||||||
WriteAllText(out, text);
|
|
||||||
out.Commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ModList::InsertMod(size_t index, const QString &filename, const QString& saveToFile)
|
|
||||||
{
|
|
||||||
QFileInfo source(filename);
|
|
||||||
QFileInfo dest(PathCombine(modsFolder, source.fileName()));
|
|
||||||
|
|
||||||
if (source != dest)
|
|
||||||
{
|
|
||||||
QFile::copy(source.absoluteFilePath(), dest.absoluteFilePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
int oldIndex = FindIndexByFilename(dest.absoluteFilePath());
|
|
||||||
|
|
||||||
if (oldIndex != -1)
|
|
||||||
{
|
|
||||||
erase(begin() + oldIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index >= size())
|
|
||||||
push_back(Mod(dest));
|
|
||||||
else
|
|
||||||
insert(begin() + index, Mod(dest));
|
|
||||||
|
|
||||||
if (!saveToFile.isEmpty())
|
|
||||||
SaveToFile(saveToFile);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ModList::DeleteMod(size_t index, const QString& saveToFile)
|
|
||||||
{
|
|
||||||
Mod *mod = &at(index);
|
|
||||||
if(mod->GetModType() == Mod::MOD_FOLDER)
|
|
||||||
{
|
|
||||||
QDir dir(mod->GetFileName().absoluteFilePath());
|
|
||||||
if(dir.removeRecursively())
|
|
||||||
{
|
|
||||||
erase(begin() + index);
|
|
||||||
|
|
||||||
if (!saveToFile.isEmpty())
|
|
||||||
SaveToFile(saveToFile);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// wxLogError(_("Failed to delete mod."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (QFile(mod->GetFileName().absoluteFilePath()).remove())
|
|
||||||
{
|
|
||||||
erase(begin() + index);
|
|
||||||
|
|
||||||
if (!saveToFile.isEmpty())
|
|
||||||
SaveToFile(saveToFile);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// wxLogError(_("Failed to delete mod."));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool JarModList::InsertMod(size_t index, const QString &filename, const QString& saveToFile)
|
|
||||||
{
|
|
||||||
QString saveFile = saveToFile;
|
|
||||||
if (saveToFile.isEmpty())
|
|
||||||
saveFile = m_inst->GetModListFile().GetFullPath();
|
|
||||||
|
|
||||||
if (ModList::InsertMod(index, filename, saveFile))
|
|
||||||
{
|
|
||||||
m_inst->setLWJGLVersion(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool JarModList::DeleteMod(size_t index, const QString& saveToFile)
|
|
||||||
{
|
|
||||||
QString saveFile = saveToFile;
|
|
||||||
if (saveToFile.IsEmpty())
|
|
||||||
saveFile = m_inst->GetModListFile().GetFullPath();
|
|
||||||
|
|
||||||
if (ModList::DeleteMod(index, saveFile))
|
|
||||||
{
|
|
||||||
m_inst->SetNeedsRebuild();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool JarModList::UpdateModList(bool quickLoad)
|
|
||||||
{
|
|
||||||
if (ModList::UpdateModList(quickLoad))
|
|
||||||
{
|
|
||||||
m_inst->SetNeedsRebuild();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FolderModList::LoadModListFromDir(const QString& loadFrom, bool quickLoad)
|
|
||||||
{
|
|
||||||
QString dir(loadFrom.IsEmpty() ? modsFolder : loadFrom);
|
|
||||||
|
|
||||||
if (!wxDirExists(dir))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
bool listChanged = false;
|
|
||||||
wxDir modDir(dir);
|
|
||||||
|
|
||||||
if (!modDir.IsOpened())
|
|
||||||
{
|
|
||||||
wxLogError(_("Failed to open directory: ") + dir);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString currentFile;
|
|
||||||
if (modDir.GetFirst(¤tFile))
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
wxFileName modFile(Path::Combine(dir, currentFile));
|
|
||||||
|
|
||||||
if (wxFileExists(modFile.GetFullPath()) || wxDirExists(modFile.GetFullPath()))
|
|
||||||
{
|
|
||||||
if (quickLoad || FindByFilename(modFile.GetFullPath()) == nullptr)
|
|
||||||
{
|
|
||||||
Mod mod(modFile.GetFullPath());
|
|
||||||
push_back(mod);
|
|
||||||
listChanged = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (modDir.GetNext(¤tFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
return listChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ModNameSort (const Mod & i,const Mod & j)
|
|
||||||
{
|
|
||||||
if(i.GetModType() == j.GetModType())
|
|
||||||
return (i.GetName().toLower() < j.GetName().toLower());
|
|
||||||
return (i.GetModType() < j.GetModType());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FolderModList::UpdateModList ( bool quickLoad )
|
|
||||||
{
|
|
||||||
bool changed = ModList::UpdateModList(quickLoad);
|
|
||||||
std::sort(begin(),end(),ModNameSort);
|
|
||||||
return changed;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
@ -15,9 +15,10 @@ class BaseInstance;
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
#include "Mod.h"
|
#include "Mod.h"
|
||||||
|
|
||||||
|
class QFileSystemWatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A legacy mod list.
|
* A legacy mod list.
|
||||||
* Backed by a folder.
|
* Backed by a folder.
|
||||||
@ -86,6 +87,9 @@ public:
|
|||||||
/// what drop actions do we support?
|
/// what drop actions do we support?
|
||||||
virtual Qt::DropActions supportedDropActions() const;
|
virtual Qt::DropActions supportedDropActions() const;
|
||||||
|
|
||||||
|
void startWatching();
|
||||||
|
void stopWatching();
|
||||||
|
|
||||||
virtual bool isValid();
|
virtual bool isValid();
|
||||||
|
|
||||||
QDir dir()
|
QDir dir()
|
||||||
@ -95,10 +99,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
QStringList readListFile();
|
QStringList readListFile();
|
||||||
bool saveListFile();
|
bool saveListFile();
|
||||||
|
private slots:
|
||||||
|
void directoryChanged(QString path);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
protected:
|
protected:
|
||||||
|
QFileSystemWatcher * m_watcher;
|
||||||
|
bool is_watching;
|
||||||
QDir m_dir;
|
QDir m_dir;
|
||||||
QString m_list_file;
|
QString m_list_file;
|
||||||
QString m_list_id;
|
QString m_list_id;
|
||||||
|
@ -6,6 +6,12 @@ NostalgiaInstance::NostalgiaInstance ( const QString& rootDir, SettingsObject* s
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString NostalgiaInstance::getStatusbarDescription()
|
||||||
|
{
|
||||||
|
return "Nostalgia : " + intendedVersionId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ADD MORE
|
ADD MORE
|
||||||
IF REQUIRED
|
IF REQUIRED
|
||||||
|
@ -7,4 +7,5 @@ class NostalgiaInstance : public OneSixInstance
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit NostalgiaInstance(const QString &rootDir, SettingsObject * settings, QObject *parent = 0);
|
explicit NostalgiaInstance(const QString &rootDir, SettingsObject * settings, QObject *parent = 0);
|
||||||
|
virtual QString getStatusbarDescription();
|
||||||
};
|
};
|
||||||
|
@ -226,3 +226,22 @@ QString OneSixInstance::defaultCustomBaseJar() const
|
|||||||
{
|
{
|
||||||
return PathCombine(instanceRoot(), "custom.jar");
|
return PathCombine(instanceRoot(), "custom.jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OneSixInstance::menuActionEnabled ( QString action_name ) const
|
||||||
|
{
|
||||||
|
if(action_name == "actionChangeInstLWJGLVersion")
|
||||||
|
return false;
|
||||||
|
if(action_name == "actionEditInstMods")
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OneSixInstance::getStatusbarDescription()
|
||||||
|
{
|
||||||
|
return "One Six : " + intendedVersionId();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OneSixInstance::instanceConfigFolder() const
|
||||||
|
{
|
||||||
|
return PathCombine(minecraftRoot(), "config");
|
||||||
|
}
|
||||||
|
@ -32,6 +32,11 @@ public:
|
|||||||
|
|
||||||
virtual QString defaultBaseJar() const;
|
virtual QString defaultBaseJar() const;
|
||||||
virtual QString defaultCustomBaseJar() const;
|
virtual QString defaultCustomBaseJar() const;
|
||||||
|
|
||||||
|
virtual bool menuActionEnabled ( QString action_name ) const;
|
||||||
|
virtual QString getStatusbarDescription();
|
||||||
|
virtual QString instanceConfigFolder() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList processMinecraftArgs( QString user, QString session );
|
QStringList processMinecraftArgs( QString user, QString session );
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user