GH-1011 fetch missing versions when customizing/reverting Minecraft patches

This commit is contained in:
Petr Mrázek 2015-05-28 09:36:58 +02:00
parent f9e186ab70
commit a98e1df10c
4 changed files with 41 additions and 13 deletions

View File

@ -44,6 +44,8 @@
#include "liteloader/LiteLoaderInstaller.h" #include "liteloader/LiteLoaderInstaller.h"
#include "auth/MojangAccountList.h" #include "auth/MojangAccountList.h"
#include "minecraft/Mod.h" #include "minecraft/Mod.h"
#include <minecraft/MinecraftVersion.h>
#include <minecraft/MinecraftVersionList.h>
#include "icons/IconList.h" #include "icons/IconList.h"
@ -224,16 +226,21 @@ void VersionPage::on_changeVersionBtn_clicked()
reloadMinecraftProfile(); reloadMinecraftProfile();
} }
m_inst->setIntendedVersionId(vselect.selectedVersion()->descriptor()); m_inst->setIntendedVersionId(vselect.selectedVersion()->descriptor());
doUpdate();
}
int VersionPage::doUpdate()
{
auto updateTask = m_inst->doUpdate(); auto updateTask = m_inst->doUpdate();
if (!updateTask) if (!updateTask)
{ {
return; return 1;
} }
ProgressDialog tDialog(this); ProgressDialog tDialog(this);
connect(updateTask.get(), SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString))); connect(updateTask.get(), SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString)));
tDialog.exec(updateTask.get()); int ret = tDialog.exec(updateTask.get());
updateButtons(); updateButtons();
return ret;
} }
void VersionPage::on_forgeBtn_clicked() void VersionPage::on_forgeBtn_clicked()
@ -353,6 +360,16 @@ void VersionPage::on_customizeBtn_clicked()
{ {
return; return;
} }
//HACK HACK remove, this is dumb
auto patch = m_version->versionPatch(version);
auto mc = std::dynamic_pointer_cast<MinecraftVersion>(patch);
if(mc && mc->needsUpdate())
{
if(!doUpdate())
{
return;
}
}
if(!m_version->customize(version)) if(!m_version->customize(version))
{ {
// TODO: some error box here // TODO: some error box here
@ -384,6 +401,15 @@ void VersionPage::on_revertBtn_clicked()
{ {
return; return;
} }
auto mcraw = MMC->minecraftlist()->findVersion(m_inst->intendedVersionId());
auto mc = std::dynamic_pointer_cast<MinecraftVersion>(mcraw);
if(mc && mc->needsUpdate())
{
if(!doUpdate())
{
return;
}
}
if(!m_version->revert(version)) if(!m_version->revert(version))
{ {
// TODO: some error box here // TODO: some error box here

View File

@ -69,6 +69,7 @@ private:
int currentRow(); int currentRow();
void updateButtons(int row = -1); void updateButtons(int row = -1);
void preselect(int row = 0); void preselect(int row = 0);
int doUpdate();
protected: protected:
/// FIXME: this shouldn't be necessary! /// FIXME: this shouldn't be necessary!

View File

@ -599,6 +599,7 @@ void MinecraftVersionList::saveCachedList()
QJsonObject entryObj; QJsonObject entryObj;
entryObj.insert("id", mcversion->descriptor()); entryObj.insert("id", mcversion->descriptor());
entryObj.insert("version", mcversion->descriptor());
entryObj.insert("time", mcversion->m_updateTimeString); entryObj.insert("time", mcversion->m_updateTimeString);
entryObj.insert("releaseTime", mcversion->m_releaseTimeString); entryObj.insert("releaseTime", mcversion->m_releaseTimeString);
entryObj.insert("type", mcversion->m_type); entryObj.insert("type", mcversion->m_type);

View File

@ -275,19 +275,19 @@ bool OneSixProfileStrategy::customizePatch(ProfilePatchPtr patch)
{ {
return false; return false;
} }
QSaveFile jsonFile(filename);
if(!jsonFile.open(QIODevice::WriteOnly))
{
return false;
}
auto document = patch->toJson(true);
jsonFile.write(document.toJson());
if(!jsonFile.commit())
{
return false;
}
try try
{ {
QSaveFile jsonFile(filename);
if(!jsonFile.open(QIODevice::WriteOnly))
{
return false;
}
auto document = patch->toJson(true);
jsonFile.write(document.toJson());
if(!jsonFile.commit())
{
return false;
}
load(); load();
} }
catch (VersionIncomplete &error) catch (VersionIncomplete &error)