NOISSUE stop referring to the minecraft profile as 'version'

This commit is contained in:
Petr Mrázek 2016-03-13 20:57:01 +01:00
parent 010e07eb45
commit fb9dfcb951
11 changed files with 87 additions and 85 deletions

View File

@ -114,11 +114,11 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent)
reloadMinecraftProfile();
m_version = m_inst->getMinecraftProfile();
if (m_version)
m_profile = m_inst->getMinecraftProfile();
if (m_profile)
{
auto proxy = new IconProxy(ui->packageView);
proxy->setSourceModel(m_version.get());
proxy->setSourceModel(m_profile.get());
ui->packageView->setModel(proxy);
ui->packageView->installEventFilter(this);
ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection);
@ -151,7 +151,7 @@ void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &
return;
}
int row = current.row();
auto patch = m_version->versionPatch(row);
auto patch = m_profile->versionPatch(row);
auto severity = patch->getProblemSeverity();
switch(severity)
{
@ -232,7 +232,7 @@ void VersionPage::on_removeBtn_clicked()
if (ui->packageView->currentIndex().isValid())
{
// FIXME: use actual model, not reloading.
if (!m_version->remove(ui->packageView->currentIndex().row()))
if (!m_profile->remove(ui->packageView->currentIndex().row()))
{
QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file"));
}
@ -251,7 +251,7 @@ void VersionPage::on_modBtn_clicked()
void VersionPage::on_jarmodBtn_clicked()
{
bool nagShown = false;
if (!m_version->hasTrait("legacyLaunch") && !m_version->hasTrait("alphaLaunch"))
if (!m_profile->hasTrait("legacyLaunch") && !m_profile->hasTrait("alphaLaunch"))
{
// not legacy launch... nag
auto seenNag = MMC->settings()->get("JarModNagSeen").toBool();
@ -273,7 +273,7 @@ void VersionPage::on_jarmodBtn_clicked()
auto list = GuiUtil::BrowseForFiles("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), MMC->settings()->get("CentralModsDir").toString(), this->parentWidget());
if(!list.empty())
{
m_version->installJarMods(list);
m_profile->installJarMods(list);
if(nagShown)
{
MMC->settings()->set("JarModNagSeen", QVariant(true));
@ -286,7 +286,7 @@ void VersionPage::on_resetOrderBtn_clicked()
{
try
{
m_version->resetOrder();
m_profile->resetOrder();
}
catch (Exception &e)
{
@ -299,7 +299,7 @@ void VersionPage::on_moveUpBtn_clicked()
{
try
{
m_version->move(currentRow(), MinecraftProfile::MoveUp);
m_profile->move(currentRow(), MinecraftProfile::MoveUp);
}
catch (Exception &e)
{
@ -312,7 +312,7 @@ void VersionPage::on_moveDownBtn_clicked()
{
try
{
m_version->move(currentRow(), MinecraftProfile::MoveDown);
m_profile->move(currentRow(), MinecraftProfile::MoveDown);
}
catch (Exception &e)
{
@ -338,7 +338,7 @@ void VersionPage::on_changeVersionBtn_clicked()
return;
}
if (!m_version->isVanilla())
if (!m_profile->isVanilla())
{
auto result = CustomMessageBox::selectable(
this, tr("Are you sure?"),
@ -349,7 +349,7 @@ void VersionPage::on_changeVersionBtn_clicked()
if (result != QMessageBox::Ok)
return;
m_version->revertToVanilla();
m_profile->revertToVanilla();
reloadMinecraftProfile();
}
m_inst->setIntendedVersionId(vselect.selectedVersion()->descriptor());
@ -382,7 +382,7 @@ void VersionPage::on_forgeBtn_clicked()
ProgressDialog dialog(this);
dialog.execWithTask(
ForgeInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
preselect(m_version->rowCount(QModelIndex())-1);
preselect(m_profile->rowCount(QModelIndex())-1);
}
}
@ -399,7 +399,7 @@ void VersionPage::on_liteloaderBtn_clicked()
ProgressDialog dialog(this);
dialog.execWithTask(
LiteLoaderInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
preselect(m_version->rowCount(QModelIndex())-1);
preselect(m_profile->rowCount(QModelIndex())-1);
}
}
@ -415,15 +415,15 @@ void VersionPage::preselect(int row)
{
row = 0;
}
if(row >= m_version->rowCount(QModelIndex()))
if(row >= m_profile->rowCount(QModelIndex()))
{
row = m_version->rowCount(QModelIndex()) - 1;
row = m_profile->rowCount(QModelIndex()) - 1;
}
if(row < 0)
{
return;
}
auto model_index = m_version->index(row);
auto model_index = m_profile->index(row);
ui->packageView->selectionModel()->select(model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
updateButtons(row);
}
@ -432,7 +432,7 @@ void VersionPage::updateButtons(int row)
{
if(row == -1)
row = currentRow();
auto patch = m_version->versionPatch(row);
auto patch = m_profile->versionPatch(row);
if (!patch)
{
ui->removeBtn->setDisabled(true);
@ -468,7 +468,7 @@ ProfilePatchPtr VersionPage::current()
{
return nullptr;
}
return m_version->versionPatch(row);
return m_profile->versionPatch(row);
}
int VersionPage::currentRow()
@ -488,7 +488,7 @@ void VersionPage::on_customizeBtn_clicked()
return;
}
//HACK HACK remove, this is dumb
auto patch = m_version->versionPatch(version);
auto patch = m_profile->versionPatch(version);
auto mc = std::dynamic_pointer_cast<MinecraftVersion>(patch);
if(mc && mc->needsUpdate())
{
@ -497,7 +497,7 @@ void VersionPage::on_customizeBtn_clicked()
return;
}
}
if(!m_version->customize(version))
if(!m_profile->customize(version))
{
// TODO: some error box here
}
@ -537,7 +537,7 @@ void VersionPage::on_revertBtn_clicked()
return;
}
}
if(!m_version->revertToBase(version))
if(!m_profile->revertToBase(version))
{
// TODO: some error box here
}

View File

@ -80,7 +80,7 @@ protected:
private:
Ui::VersionPage *ui;
std::shared_ptr<MinecraftProfile> m_version;
std::shared_ptr<MinecraftProfile> m_profile;
OneSixInstance *m_inst;
int currentIdx = 0;
BasePageContainer * m_container = nullptr;

View File

@ -58,11 +58,11 @@ bool MinecraftVersion::isMinecraftVersion()
return true;
}
void MinecraftVersion::applyFileTo(MinecraftProfile *version)
void MinecraftVersion::applyFileTo(MinecraftProfile *profile)
{
if(m_versionSource == Local && getVersionFile())
{
getVersionFile()->applyTo(version);
getVersionFile()->applyTo(profile);
}
else
{
@ -149,12 +149,12 @@ ProblemSeverity MinecraftVersion::getProblemSeverity()
return ProfilePatch::getProblemSeverity();
}
void MinecraftVersion::applyTo(MinecraftProfile *version)
void MinecraftVersion::applyTo(MinecraftProfile *profile)
{
// do we have this one cached?
if (m_versionSource == Local)
{
applyFileTo(version);
applyFileTo(profile);
return;
}
// if not builtin, do not proceed any further.
@ -163,12 +163,12 @@ void MinecraftVersion::applyTo(MinecraftProfile *version)
throw VersionIncomplete(QObject::tr(
"Minecraft version %1 could not be applied: version files are missing.").arg(m_descriptor));
}
version->applyMinecraftVersion(m_descriptor);
version->applyMainClass(m_mainClass);
version->applyAppletClass(m_appletClass);
version->applyMinecraftArguments(" ${auth_player_name} ${auth_session}"); // all builtin versions are legacy
version->applyMinecraftVersionType(m_type);
version->applyTraits(m_traits);
profile->applyMinecraftVersion(m_descriptor);
profile->applyMainClass(m_mainClass);
profile->applyAppletClass(m_appletClass);
profile->applyMinecraftArguments(" ${auth_player_name} ${auth_session}"); // all builtin versions are legacy
profile->applyMinecraftVersionType(m_type);
profile->applyTraits(m_traits);
}
int MinecraftVersion::getOrder()

View File

@ -40,7 +40,7 @@ public: /* methods */
virtual QString typeString() const override;
virtual bool hasJarMods() override;
virtual bool isMinecraftVersion() override;
virtual void applyTo(MinecraftProfile *version) override;
virtual void applyTo(MinecraftProfile *profile) override;
virtual int getOrder() override;
virtual void setOrder(int order) override;
virtual QList<JarmodPtr> getJarMods() override;
@ -86,7 +86,7 @@ public: /* methods */
virtual ProblemSeverity getProblemSeverity() override;
private: /* methods */
void applyFileTo(MinecraftProfile *version);
void applyFileTo(MinecraftProfile *profile);
protected: /* data */
VersionSource m_versionSource = Builtin;

View File

@ -47,7 +47,7 @@ class ProfilePatch
{
public:
virtual ~ProfilePatch(){};
virtual void applyTo(MinecraftProfile *version) = 0;
virtual void applyTo(MinecraftProfile *profile) = 0;
virtual bool isMinecraftVersion() = 0;
virtual bool hasJarMods() = 0;

View File

@ -22,9 +22,9 @@ bool VersionFile::hasJarMods()
return !jarMods.isEmpty();
}
void VersionFile::applyTo(MinecraftProfile *version)
void VersionFile::applyTo(MinecraftProfile *profile)
{
auto theirVersion = version->getMinecraftVersion();
auto theirVersion = profile->getMinecraftVersion();
if (!theirVersion.isNull() && !mcVersion.isNull())
{
if (QRegExp(mcVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(theirVersion) == -1)
@ -32,22 +32,22 @@ void VersionFile::applyTo(MinecraftProfile *version)
throw MinecraftVersionMismatch(fileId, mcVersion, theirVersion);
}
}
version->applyMinecraftVersion(id);
version->applyMainClass(mainClass);
version->applyAppletClass(appletClass);
version->applyMinecraftArguments(minecraftArguments);
profile->applyMinecraftVersion(id);
profile->applyMainClass(mainClass);
profile->applyAppletClass(appletClass);
profile->applyMinecraftArguments(minecraftArguments);
if (isMinecraftVersion())
{
version->applyMinecraftVersionType(type);
profile->applyMinecraftVersionType(type);
}
version->applyMinecraftAssets(assets);
version->applyTweakers(addTweakers);
profile->applyMinecraftAssets(assets);
profile->applyTweakers(addTweakers);
version->applyJarMods(jarMods);
version->applyTraits(traits);
profile->applyJarMods(jarMods);
profile->applyTraits(traits);
for (auto library : libraries)
{
version->applyLibrary(library);
profile->applyLibrary(library);
}
}

View File

@ -23,7 +23,7 @@ class VersionFile : public ProfilePatch
friend class MojangVersionFormat;
friend class OneSixVersionFormat;
public: /* methods */
virtual void applyTo(MinecraftProfile *version) override;
virtual void applyTo(MinecraftProfile *profile) override;
virtual bool isMinecraftVersion() override;
virtual bool hasJarMods() override;
virtual int getOrder() override

View File

@ -122,7 +122,7 @@ bool OneSixFTBInstance::providesVersionFile() const
void OneSixFTBInstance::createProfile()
{
m_version.reset(new MinecraftProfile(new FTBProfileStrategy(this)));
m_profile.reset(new MinecraftProfile(new FTBProfileStrategy(this)));
}
std::shared_ptr<Task> OneSixFTBInstance::createUpdateTask()

View File

@ -50,7 +50,7 @@ void OneSixInstance::init()
void OneSixInstance::createProfile()
{
m_version.reset(new MinecraftProfile(new OneSixProfileStrategy(this)));
m_profile.reset(new MinecraftProfile(new OneSixProfileStrategy(this)));
}
QSet<QString> OneSixInstance::traits()
@ -61,8 +61,10 @@ QSet<QString> OneSixInstance::traits()
return {"version-incomplete"};
}
else
{
return version->getTraits();
}
}
std::shared_ptr<Task> OneSixInstance::createUpdateTask()
{
@ -95,8 +97,8 @@ QString replaceTokensIn(QString text, QMap<QString, QString> with)
QStringList OneSixInstance::processMinecraftArgs(AuthSessionPtr session)
{
QString args_pattern = m_version->getMinecraftArguments();
for (auto tweaker : m_version->getTweakers())
QString args_pattern = m_profile->getMinecraftArguments();
for (auto tweaker : m_profile->getTweakers())
{
args_pattern += " --tweakClass " + tweaker;
}
@ -111,9 +113,9 @@ QStringList OneSixInstance::processMinecraftArgs(AuthSessionPtr session)
// blatant self-promotion.
token_mapping["profile_name"] = token_mapping["version_name"] = "MultiMC5";
if(m_version->isVanilla())
if(m_profile->isVanilla())
{
token_mapping["version_type"] = m_version->getMinecraftVersionType();
token_mapping["version_type"] = m_profile->getMinecraftVersionType();
}
else
{
@ -123,14 +125,14 @@ QStringList OneSixInstance::processMinecraftArgs(AuthSessionPtr session)
QString absRootDir = QDir(minecraftRoot()).absolutePath();
token_mapping["game_directory"] = absRootDir;
QString absAssetsDir = QDir("assets/").absolutePath();
token_mapping["game_assets"] = AssetsUtils::reconstructAssets(m_version->getMinecraftAssets()).absolutePath();
token_mapping["game_assets"] = AssetsUtils::reconstructAssets(m_profile->getMinecraftAssets()).absolutePath();
token_mapping["user_properties"] = session->serializeUserProperties();
token_mapping["user_type"] = session->user_type;
// 1.7.3+ assets tokens
token_mapping["assets_root"] = absAssetsDir;
token_mapping["assets_index_name"] = m_version->getMinecraftAssets();
token_mapping["assets_index_name"] = m_profile->getMinecraftAssets();
QStringList parts = args_pattern.split(' ', QString::SkipEmptyParts);
for (int i = 0; i < parts.length(); i++)
@ -147,7 +149,7 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
auto pixmap = icon.pixmap(128, 128);
pixmap.save(FS::PathCombine(minecraftRoot(), "icon.png"), "PNG");
if (!m_version)
if (!m_profile)
return nullptr;
for(auto & mod: loaderModList()->allMods())
@ -172,14 +174,14 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
launchScript += "coremod " + coremod.filename().completeBaseName() + "\n";;
}
for(auto & jarmod: m_version->getJarMods())
for(auto & jarmod: m_profile->getJarMods())
{
launchScript += "jarmod " + jarmod->originalName + " (" + jarmod->name + ")\n";
}
// libraries and class path.
{
auto libs = m_version->getLibraries();
auto libs = m_profile->getLibraries();
for (auto lib : libs)
{
launchScript += "cp " + QFileInfo(lib->storagePath()).absoluteFilePath() + "\n";
@ -191,16 +193,16 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
}
else
{
QString relpath = m_version->getMinecraftVersion() + "/" + m_version->getMinecraftVersion() + ".jar";
QString relpath = m_profile->getMinecraftVersion() + "/" + m_profile->getMinecraftVersion() + ".jar";
launchScript += "cp " + versionsPath().absoluteFilePath(relpath) + "\n";
}
}
auto mainClass = m_version->getMainClass();
auto mainClass = m_profile->getMainClass();
if (!mainClass.isEmpty())
{
launchScript += "mainClass " + mainClass + "\n";
}
auto appletClass = m_version->getAppletClass();
auto appletClass = m_profile->getAppletClass();
if (!appletClass.isEmpty())
{
launchScript += "appletClass " + appletClass + "\n";
@ -234,7 +236,7 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
// native libraries (mostly LWJGL)
{
QDir natives_dir(FS::PathCombine(instanceRoot(), "natives/"));
for (auto native : m_version->getNativeLibraries())
for (auto native : m_profile->getNativeLibraries())
{
QFileInfo finfo(native->storagePath());
launchScript += "ext " + finfo.absoluteFilePath() + "\n";
@ -243,7 +245,7 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
}
// traits. including legacyLaunch and others ;)
for (auto trait : m_version->getTraits())
for (auto trait : m_profile->getTraits())
{
launchScript += "traits " + trait + "\n";
}
@ -313,9 +315,9 @@ std::shared_ptr<Task> OneSixInstance::createJarModdingTask()
}
virtual void executeTask()
{
std::shared_ptr<MinecraftProfile> version = m_inst->getMinecraftProfile();
auto profile = m_inst->getMinecraftProfile();
// nuke obsolete stripped jar(s) if needed
QString version_id = version->getMinecraftVersion();
QString version_id = profile->getMinecraftVersion();
QString strippedPath = version_id + "/" + version_id + "-stripped.jar";
QFile strippedJar(strippedPath);
if(strippedJar.exists())
@ -431,7 +433,7 @@ bool OneSixInstance::setIntendedVersionId(QString version)
QList< Mod > OneSixInstance::getJarMods() const
{
QList<Mod> mods;
for (auto jarmod : m_version->getJarMods())
for (auto jarmod : m_profile->getJarMods())
{
QString filePath = jarmodsPath().absoluteFilePath(jarmod->name);
mods.push_back(Mod(QFileInfo(filePath)));
@ -463,7 +465,7 @@ void OneSixInstance::reloadProfile()
{
try
{
m_version->reload();
m_profile->reload();
unsetFlag(VersionBrokenFlag);
emit versionReloaded();
}
@ -472,7 +474,7 @@ void OneSixInstance::reloadProfile()
}
catch (Exception &error)
{
m_version->clear();
m_profile->clear();
setFlag(VersionBrokenFlag);
// TODO: rethrow to show some error message(s)?
emit versionReloaded();
@ -482,13 +484,13 @@ void OneSixInstance::reloadProfile()
void OneSixInstance::clearProfile()
{
m_version->clear();
m_profile->clear();
emit versionReloaded();
}
std::shared_ptr<MinecraftProfile> OneSixInstance::getMinecraftProfile() const
{
return m_version;
return m_profile;
}
QDir OneSixInstance::librariesPath() const

View File

@ -101,7 +101,7 @@ private:
QStringList processMinecraftArgs(AuthSessionPtr account);
protected:
std::shared_ptr<MinecraftProfile> m_version;
std::shared_ptr<MinecraftProfile> m_profile;
mutable std::shared_ptr<ModList> m_loader_mod_list;
mutable std::shared_ptr<ModList> m_core_mod_list;
mutable std::shared_ptr<ModList> m_resource_pack_list;

View File

@ -87,8 +87,8 @@ void OneSixUpdate::assetIndexStart()
{
setStatus(tr("Updating assets index..."));
OneSixInstance *inst = (OneSixInstance *)m_inst;
std::shared_ptr<MinecraftProfile> version = inst->getMinecraftProfile();
QString assetName = version->getMinecraftAssets();
auto profile = inst->getMinecraftProfile();
QString assetName = profile->getMinecraftAssets();
QUrl indexUrl = "http://" + URLConstants::AWS_DOWNLOAD_INDEXES + assetName + ".json";
QString localPath = assetName + ".json";
auto job = new NetJob(tr("Asset index for %1").arg(inst->name()));
@ -113,8 +113,8 @@ void OneSixUpdate::assetIndexFinished()
qDebug() << m_inst->name() << ": Finished asset index download";
OneSixInstance *inst = (OneSixInstance *)m_inst;
std::shared_ptr<MinecraftProfile> version = inst->getMinecraftProfile();
QString assetName = version->getMinecraftAssets();
auto profile = inst->getMinecraftProfile();
QString assetName = profile->getMinecraftAssets();
QString asset_fname = "assets/indexes/" + assetName + ".json";
if (!AssetsUtils::loadAssetsIndexJson(asset_fname, &index))
@ -190,10 +190,10 @@ void OneSixUpdate::jarlibStart()
}
// Build a list of URLs that will need to be downloaded.
std::shared_ptr<MinecraftProfile> version = inst->getMinecraftProfile();
std::shared_ptr<MinecraftProfile> profile = inst->getMinecraftProfile();
// minecraft.jar for this version
{
QString version_id = version->getMinecraftVersion();
QString version_id = profile->getMinecraftVersion();
QString localPath = version_id + "/" + version_id + ".jar";
QString urlstr = "http://" + URLConstants::AWS_DOWNLOAD_VERSIONS + localPath;
@ -207,8 +207,8 @@ void OneSixUpdate::jarlibStart()
jarlibDownloadJob.reset(job);
}
auto libs = version->getNativeLibraries();
libs.append(version->getLibraries());
auto libs = profile->getNativeLibraries();
libs.append(profile->getLibraries());
auto metacache = ENV.metacache();
QList<ForgeXzDownloadPtr> ForgeLibs;
@ -289,9 +289,9 @@ void OneSixUpdate::jarlibStart()
void OneSixUpdate::jarlibFinished()
{
OneSixInstance *inst = (OneSixInstance *)m_inst;
std::shared_ptr<MinecraftProfile> version = inst->getMinecraftProfile();
std::shared_ptr<MinecraftProfile> profile = inst->getMinecraftProfile();
if (version->hasTrait("legacyFML"))
if (profile->hasTrait("legacyFML"))
{
fmllibsStart();
}
@ -313,7 +313,7 @@ void OneSixUpdate::fmllibsStart()
{
// Get the mod list
OneSixInstance *inst = (OneSixInstance *)m_inst;
std::shared_ptr<MinecraftProfile> fullversion = inst->getMinecraftProfile();
std::shared_ptr<MinecraftProfile> profile = inst->getMinecraftProfile();
bool forge_present = false;
QString version = inst->intendedVersionId();
@ -328,7 +328,7 @@ void OneSixUpdate::fmllibsStart()
// determine if we need some libs for FML or forge
setStatus(tr("Checking for FML libraries..."));
forge_present = (fullversion->versionPatch("net.minecraftforge") != nullptr);
forge_present = (profile->versionPatch("net.minecraftforge") != nullptr);
// we don't...
if (!forge_present)
{