Show texture/resource packs when appropriate.

This commit is contained in:
Petr Mrázek
2014-06-08 20:11:09 +02:00
parent 223a7aba7b
commit bf7b070508
10 changed files with 141 additions and 102 deletions

View File

@ -25,6 +25,7 @@
#include "logic/BaseVersionList.h"
#include "logic/auth/MojangAccount.h"
class ModList;
class QDialog;
class QDir;
class Task;
@ -110,6 +111,19 @@ public:
virtual bool shouldUpdate() const = 0;
virtual void setShouldUpdate(bool val) = 0;
////// Mod Lists //////
virtual std::shared_ptr<ModList> resourcePackList()
{
return nullptr;
}
virtual std::shared_ptr<ModList> texturePackList()
{
return nullptr;
}
/// Traits. Normally inside the version, depends on instance implementation.
virtual QSet <QString> traits() = 0;
/// Get the curent base jar of this instance. By default, it's the
/// versions/$version/$version.jar
QString baseJar() const;

View File

@ -31,6 +31,7 @@
#include "gui/pages/LegacyUpgradePage.h"
#include "gui/pages/ModFolderPage.h"
#include "gui/pages/LegacyJarModPage.h"
#include <gui/pages/TexturePackPage.h>
LegacyInstance::LegacyInstance(const QString &rootDir, SettingsObject *settings,
QObject *parent)
@ -50,7 +51,7 @@ QList<BasePage *> LegacyInstance::getPages()
values.append(new LegacyJarModPage(this));
values.append(new ModFolderPage(loaderModList(), "mods", "centralmods", tr("Loader Mods")));
values.append(new ModFolderPage(coreModList(), "coremods", "viewfolder", tr("Core Mods")));
values.append(new ModFolderPage(texturePackList(), "texturepacks", "viewfolder", tr("Texture Packs")));
values.append(new TexturePackPage(this));
return values;
}

View File

@ -80,6 +80,11 @@ public:
return false;
}
virtual QSet<QString> traits()
{
return {"legacy-instance", "texturepacks"};
};
virtual bool shouldUpdate() const override;
virtual void setShouldUpdate(bool val) override;
virtual std::shared_ptr<Task> doUpdate() override;

View File

@ -32,6 +32,8 @@
#include "gui/pagedialog/PageDialog.h"
#include "gui/pages/VersionPage.h"
#include <gui/pages/ModFolderPage.h>
#include <gui/pages/ResourcePackPage.h>
#include <gui/pages/TexturePackPage.h>
OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings,
QObject *parent)
@ -60,8 +62,8 @@ QList<BasePage *> OneSixInstance::getPages()
values.append(new VersionPage(this));
values.append(new ModFolderPage(loaderModList(), "mods", "centralmods", tr("Loader Mods")));
values.append(new ModFolderPage(coreModList(), "coremods", "viewfolder", tr("Core Mods")));
values.append(new ModFolderPage(resourcePackList(), "resourcepacks", "viewfolder", tr("Resource Packs")));
values.append(new ModFolderPage(texturePackList(), "texturepacks", "viewfolder", tr("Texture Packs")));
values.append(new ResourcePackPage(this));
values.append(new TexturePackPage(this));
return values;
}
@ -70,6 +72,17 @@ QString OneSixInstance::dialogTitle()
return tr("Edit Instance (%1)").arg(name());
}
QSet<QString> OneSixInstance::traits()
{
auto version = getFullVersion();
if (!version)
{
return {"version-incomplete"};
}
else
return version->traits;
}
std::shared_ptr<Task> OneSixInstance::doUpdate()
{
return std::shared_ptr<Task>(new OneSixUpdate(this));
@ -234,11 +247,11 @@ bool OneSixInstance::prepareForLaunch(AuthSessionPtr session, QString &launchScr
}
launchScript += "cp " + versionsPath().absoluteFilePath(minecraftjarpath) + "\n";
}
if(!version->mainClass.isEmpty())
if (!version->mainClass.isEmpty())
{
launchScript += "mainClass " + version->mainClass + "\n";
}
if(!version->appletClass.isEmpty())
if (!version->appletClass.isEmpty())
{
launchScript += "appletClass " + version->appletClass + "\n";
}
@ -261,7 +274,7 @@ bool OneSixInstance::prepareForLaunch(AuthSessionPtr session, QString &launchScr
launchScript += "windowTitle " + windowTitle() + "\n";
launchScript += "windowParams " + windowParams + "\n";
}
// legacy auth
{
launchScript += "userName " + session->player_name + "\n";
@ -278,7 +291,7 @@ bool OneSixInstance::prepareForLaunch(AuthSessionPtr session, QString &launchScr
}
launchScript += "natives " + natives_dir.absolutePath() + "\n";
}
// traits. including legacyLaunch and others ;)
for (auto trait : version->traits)
{
@ -398,9 +411,8 @@ void OneSixInstance::reloadVersion()
d->m_flags.remove(VersionBrokenFlag);
emit versionReloaded();
}
catch (VersionIncomplete & error)
catch (VersionIncomplete &error)
{
}
catch (MMCError &error)
{
@ -532,7 +544,6 @@ QString OneSixInstance::texturePacksDir() const
return PathCombine(minecraftRoot(), "texturepacks");
}
QString OneSixInstance::instanceConfigFolder() const
{
return PathCombine(minecraftRoot(), "config");

View File

@ -38,9 +38,11 @@ public:
////// Mod Lists //////
std::shared_ptr<ModList> loaderModList();
std::shared_ptr<ModList> coreModList();
std::shared_ptr<ModList> resourcePackList();
std::shared_ptr<ModList> texturePackList();
std::shared_ptr<ModList> resourcePackList() override;
std::shared_ptr<ModList> texturePackList() override;
virtual QSet<QString> traits();
////// Directories and files //////
QString jarModsDir() const;
QString resourcePacksDir() const;