Fix MMC-15

``mod does not delete from jar''
This commit is contained in:
Petr Mrázek 2013-10-09 23:16:10 +02:00
parent 595943244c
commit eaf0cbeafc
4 changed files with 183 additions and 194 deletions

View File

@ -507,10 +507,11 @@ void MainWindow::onLoginComplete()
} }
else else
{ {
ProgressDialog *tDialog = new ProgressDialog(this); ProgressDialog tDialog(this);
connect(updateTask, SIGNAL(succeeded()), SLOT(onGameUpdateComplete())); connect(updateTask, SIGNAL(succeeded()), SLOT(onGameUpdateComplete()));
connect(updateTask, SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString))); connect(updateTask, SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString)));
tDialog->exec(updateTask); tDialog.exec(updateTask);
delete updateTask;
} }
} }

View File

@ -14,7 +14,8 @@
#define LAUNCHER_FILE "MultiMCLauncher.jar" #define LAUNCHER_FILE "MultiMCLauncher.jar"
LegacyInstance::LegacyInstance(const QString& rootDir, SettingsObject* settings, QObject* parent) LegacyInstance::LegacyInstance(const QString &rootDir, SettingsObject *settings,
QObject *parent)
: BaseInstance(new LegacyInstancePrivate(), rootDir, settings, parent) : BaseInstance(new LegacyInstancePrivate(), rootDir, settings, parent)
{ {
settings->registerSetting(new Setting("NeedsRebuild", true)); settings->registerSetting(new Setting("NeedsRebuild", true));
@ -26,6 +27,7 @@ LegacyInstance::LegacyInstance(const QString& rootDir, SettingsObject* settings,
BaseUpdate *LegacyInstance::doUpdate() BaseUpdate *LegacyInstance::doUpdate()
{ {
auto list = jarModList();
return new LegacyUpdate(this, this); return new LegacyUpdate(this, this);
} }
@ -49,9 +51,8 @@ MinecraftProcess* LegacyInstance::prepareForLaunch(LoginResponse response)
if (settings().get("LaunchMaximized").toBool()) if (settings().get("LaunchMaximized").toBool())
windowSize = "max"; windowSize = "max";
else else
windowSize = QString("%1x%2"). windowSize = QString("%1x%2").arg(settings().get("MinecraftWinWidth").toInt()).arg(
arg(settings().get("MinecraftWinWidth").toInt()). settings().get("MinecraftWinHeight").toInt());
arg(settings().get("MinecraftWinHeight").toInt());
// window title // window title
QString windowTitle; QString windowTitle;
@ -66,7 +67,8 @@ MinecraftProcess* LegacyInstance::prepareForLaunch(LoginResponse response)
args << QString("-Xdock:name=\"%1\"").arg(windowTitle); args << QString("-Xdock:name=\"%1\"").arg(windowTitle);
#endif #endif
QString lwjgl = QDir(MMC->settings()->get("LWJGLDir").toString() + "/" + lwjglVersion()).absolutePath(); QString lwjgl = QDir(MMC->settings()->get("LWJGLDir").toString() + "/" + lwjglVersion())
.absolutePath();
// launcher arguments // launcher arguments
args << QString("-Xms%1m").arg(settings().get("MinMemAlloc").toInt()); args << QString("-Xms%1m").arg(settings().get("MinMemAlloc").toInt());
@ -99,7 +101,6 @@ std::shared_ptr< ModList > LegacyInstance::coreModList()
{ {
d->core_mod_list.reset(new ModList(coreModsDir())); d->core_mod_list.reset(new ModList(coreModsDir()));
} }
else
d->core_mod_list->update(); d->core_mod_list->update();
return d->core_mod_list; return d->core_mod_list;
} }
@ -113,7 +114,6 @@ std::shared_ptr< ModList > LegacyInstance::jarModList()
connect(list, SIGNAL(changed()), SLOT(jarModsChanged())); connect(list, SIGNAL(changed()), SLOT(jarModsChanged()));
d->jar_mod_list.reset(list); d->jar_mod_list.reset(list);
} }
else
d->jar_mod_list->update(); d->jar_mod_list->update();
return d->jar_mod_list; return d->jar_mod_list;
} }
@ -123,7 +123,6 @@ void LegacyInstance::jarModsChanged()
setShouldRebuild(true); setShouldRebuild(true);
} }
std::shared_ptr<ModList> LegacyInstance::loaderModList() std::shared_ptr<ModList> LegacyInstance::loaderModList()
{ {
I_D(LegacyInstance); I_D(LegacyInstance);
@ -131,7 +130,6 @@ std::shared_ptr< ModList > LegacyInstance::loaderModList()
{ {
d->loader_mod_list.reset(new ModList(loaderModsDir())); d->loader_mod_list.reset(new ModList(loaderModsDir()));
} }
else
d->loader_mod_list->update(); d->loader_mod_list->update();
return d->loader_mod_list; return d->loader_mod_list;
} }
@ -143,18 +141,15 @@ std::shared_ptr< ModList > LegacyInstance::texturePackList()
{ {
d->texture_pack_list.reset(new ModList(texturePacksDir())); d->texture_pack_list.reset(new ModList(texturePacksDir()));
} }
else
d->texture_pack_list->update(); d->texture_pack_list->update();
return d->texture_pack_list; 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);
} }
QString LegacyInstance::jarModsDir() const QString LegacyInstance::jarModsDir() const
{ {
return PathCombine(instanceRoot(), "instMods"); return PathCombine(instanceRoot(), "instMods");
@ -204,7 +199,6 @@ QString LegacyInstance::instanceConfigFolder() const
return PathCombine(minecraftRoot(), "config"); return PathCombine(minecraftRoot(), "config");
} }
/* /*
bool LegacyInstance::shouldUpdateCurrentVersion() const bool LegacyInstance::shouldUpdateCurrentVersion() const
{ {
@ -229,7 +223,8 @@ void LegacyInstance::updateCurrentVersion(bool keepCurrent)
if (!keepCurrent) if (!keepCurrent)
{ {
// TODO: Implement GetMinecraftJarVersion function. // TODO: Implement GetMinecraftJarVersion function.
QString newVersion = "Unknown";//javautils::GetMinecraftJarVersion(jar.absoluteFilePath()); QString newVersion =
"Unknown";//javautils::GetMinecraftJarVersion(jar.absoluteFilePath());
setCurrentVersionId(newVersion); setCurrentVersionId(newVersion);
} }
} }

View File

@ -26,13 +26,14 @@
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)
{ {
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); m_watcher = new QFileSystemWatcher(this);
is_watching = false; is_watching = false;
connect(m_watcher,SIGNAL(directoryChanged(QString)), this, SLOT(directoryChanged(QString))); connect(m_watcher, SIGNAL(directoryChanged(QString)), this,
update(); SLOT(directoryChanged(QString)));
} }
void ModList::startWatching() void ModList::startWatching()
@ -53,7 +54,6 @@ void ModList::stopWatching()
QLOG_INFO() << "Failed to stop watching " << m_dir.absolutePath(); QLOG_INFO() << "Failed to stop watching " << m_dir.absolutePath();
} }
bool ModList::update() bool ModList::update()
{ {
if (!isValid()) if (!isValid())
@ -92,7 +92,8 @@ bool ModList::update()
{ {
orderWasInvalid = true; orderWasInvalid = true;
} }
else for(int i = 0; i < mods.size(); i++) else
for (int i = 0; i < mods.size(); i++)
{ {
if (!mods[i].strongCompare(newMods[i])) if (!mods[i].strongCompare(newMods[i]))
{ {
@ -116,7 +117,6 @@ void ModList::directoryChanged ( QString path )
update(); update();
} }
QStringList ModList::readListFile() QStringList ModList::readListFile()
{ {
QStringList stringList; QStringList stringList;
@ -160,7 +160,6 @@ bool ModList::saveListFile()
return false; return false;
} }
bool ModList::isValid() bool ModList::isValid()
{ {
return m_dir.exists() && m_dir.isReadable(); return m_dir.exists() && m_dir.isReadable();
@ -259,7 +258,6 @@ bool ModList::deleteMods ( int first, int last )
return true; return true;
} }
bool ModList::moveModTo(int from, int to) bool ModList::moveModTo(int from, int to)
{ {
if (from < 0 || from >= mods.size()) if (from < 0 || from >= mods.size())
@ -299,7 +297,6 @@ bool ModList::moveModsUp ( int first, int last )
return true; return true;
} }
bool ModList::moveModDown(int from) bool ModList::moveModDown(int from)
{ {
if (from < 0) if (from < 0)
@ -322,7 +319,6 @@ bool ModList::moveModsDown ( int first, int last )
return true; return true;
} }
int ModList::columnCount(const QModelIndex &parent) const int ModList::columnCount(const QModelIndex &parent) const
{ {
return 2; return 2;
@ -370,7 +366,6 @@ QVariant ModList::headerData ( int section, Qt::Orientation orientation, int rol
} }
} }
Qt::ItemFlags ModList::flags(const QModelIndex &index) const Qt::ItemFlags ModList::flags(const QModelIndex &index) const
{ {
Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index); Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
@ -417,7 +412,8 @@ QMimeData* ModList::mimeData ( const QModelIndexList& indexes ) const
data->setText(params.join('|')); data->setText(params.join('|'));
return data; return data;
} }
bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent ) bool ModList::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
const QModelIndex &parent)
{ {
if (action == Qt::IgnoreAction) if (action == Qt::IgnoreAction)
return true; return true;
@ -479,4 +475,3 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r
} }
return false; return false;
} }

View File

@ -168,7 +168,6 @@ std::shared_ptr<ModList> OneSixInstance::loaderModList()
{ {
d->loader_mod_list.reset(new ModList(loaderModsDir())); d->loader_mod_list.reset(new ModList(loaderModsDir()));
} }
else
d->loader_mod_list->update(); d->loader_mod_list->update();
return d->loader_mod_list; return d->loader_mod_list;
} }
@ -180,7 +179,6 @@ std::shared_ptr<ModList> OneSixInstance::resourcePackList()
{ {
d->resource_pack_list.reset(new ModList(resourcePacksDir())); d->resource_pack_list.reset(new ModList(resourcePacksDir()));
} }
else
d->resource_pack_list->update(); d->resource_pack_list->update();
return d->resource_pack_list; return d->resource_pack_list;
} }