2017-01-08 03:58:05 +00:00
|
|
|
/* Copyright 2013-2017 MultiMC Contributors
|
2013-11-04 01:53:05 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2013-07-22 00:01:56 +00:00
|
|
|
#pragma once
|
2014-01-24 17:12:02 +00:00
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QList>
|
2013-10-05 23:13:40 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2016-03-07 01:01:28 +00:00
|
|
|
#include "Library.h"
|
2017-03-27 01:34:39 +00:00
|
|
|
#include "ProfilePatch.h"
|
2017-03-12 22:19:45 +00:00
|
|
|
#include "BaseVersion.h"
|
2016-03-21 01:19:23 +00:00
|
|
|
#include "MojangDownloadInfo.h"
|
2014-01-24 17:12:02 +00:00
|
|
|
|
2015-09-05 16:46:57 +00:00
|
|
|
#include "multimc_logic_export.h"
|
|
|
|
|
2015-01-27 21:31:07 +00:00
|
|
|
class ProfileStrategy;
|
2014-01-24 17:12:02 +00:00
|
|
|
class OneSixInstance;
|
2013-07-28 22:59:35 +00:00
|
|
|
|
2015-09-05 16:46:57 +00:00
|
|
|
|
|
|
|
class MULTIMC_LOGIC_EXPORT MinecraftProfile : public QAbstractListModel
|
2013-07-28 22:59:35 +00:00
|
|
|
{
|
2014-01-24 17:12:02 +00:00
|
|
|
Q_OBJECT
|
2015-01-27 21:31:07 +00:00
|
|
|
|
2013-09-15 22:54:39 +00:00
|
|
|
public:
|
2015-01-27 21:31:07 +00:00
|
|
|
explicit MinecraftProfile(ProfileStrategy *strategy);
|
2016-08-19 07:04:58 +00:00
|
|
|
virtual ~MinecraftProfile();
|
2015-01-27 21:31:07 +00:00
|
|
|
|
|
|
|
void setStrategy(ProfileStrategy * strategy);
|
|
|
|
ProfileStrategy *strategy();
|
2014-01-24 17:12:02 +00:00
|
|
|
|
2015-09-26 02:04:09 +00:00
|
|
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
|
|
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
virtual int columnCount(const QModelIndex &parent) const override;
|
|
|
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
|
2013-09-22 02:21:36 +00:00
|
|
|
|
2015-01-27 21:31:07 +00:00
|
|
|
/// is this version unchanged by the user?
|
2014-04-23 00:27:40 +00:00
|
|
|
bool isVanilla();
|
2015-01-27 21:31:07 +00:00
|
|
|
|
|
|
|
/// remove any customizations on top of whatever 'vanilla' means
|
2014-04-23 00:27:40 +00:00
|
|
|
bool revertToVanilla();
|
2015-01-27 21:31:07 +00:00
|
|
|
|
|
|
|
/// install more jar mods
|
2014-05-19 00:22:09 +00:00
|
|
|
void installJarMods(QStringList selectedFiles);
|
2015-01-27 21:31:07 +00:00
|
|
|
|
2017-08-06 22:46:29 +00:00
|
|
|
/// install more jar mods
|
|
|
|
void installCustomJar(QString selectedFile);
|
|
|
|
|
2015-01-27 21:31:07 +00:00
|
|
|
/// DEPRECATED, remove ASAP
|
|
|
|
int getFreeOrderNumber();
|
|
|
|
|
2014-03-14 18:51:56 +00:00
|
|
|
enum MoveDirection { MoveUp, MoveDown };
|
2015-01-27 21:31:07 +00:00
|
|
|
/// move patch file # up or down the list
|
2014-03-14 18:51:56 +00:00
|
|
|
void move(const int index, const MoveDirection direction);
|
|
|
|
|
2015-01-27 21:31:07 +00:00
|
|
|
/// remove patch file # - including files/records
|
2014-02-01 13:52:21 +00:00
|
|
|
bool remove(const int index);
|
2015-01-27 21:31:07 +00:00
|
|
|
|
|
|
|
/// remove patch file by id - including files/records
|
2014-03-30 22:19:43 +00:00
|
|
|
bool remove(const QString id);
|
2014-02-01 13:52:21 +00:00
|
|
|
|
2015-05-17 21:38:28 +00:00
|
|
|
bool customize(int index);
|
|
|
|
|
2015-09-26 02:04:09 +00:00
|
|
|
bool revertToBase(int index);
|
2015-05-17 21:38:28 +00:00
|
|
|
|
2015-01-27 21:31:07 +00:00
|
|
|
void resetOrder();
|
|
|
|
|
|
|
|
/// reload all profile patches from storage, clear the profile and apply the patches
|
|
|
|
void reload();
|
|
|
|
|
|
|
|
/// clear the profile
|
|
|
|
void clear();
|
|
|
|
|
2015-05-31 17:59:07 +00:00
|
|
|
/// apply the patches. Catches all the errors and returns true/false for success/failure
|
2016-03-18 14:02:54 +00:00
|
|
|
bool reapplyPatches();
|
2015-05-31 17:59:07 +00:00
|
|
|
|
2016-03-18 14:02:54 +00:00
|
|
|
public: /* application of profile variables from patches */
|
2016-03-12 23:23:45 +00:00
|
|
|
void applyMinecraftVersion(const QString& id);
|
|
|
|
void applyMainClass(const QString& mainClass);
|
|
|
|
void applyAppletClass(const QString& appletClass);
|
2016-03-13 01:28:55 +00:00
|
|
|
void applyMinecraftArguments(const QString& minecraftArguments);
|
2016-03-12 23:23:45 +00:00
|
|
|
void applyMinecraftVersionType(const QString& type);
|
2016-03-21 01:19:23 +00:00
|
|
|
void applyMinecraftAssets(MojangAssetIndexInfo::Ptr assets);
|
2016-03-12 23:23:45 +00:00
|
|
|
void applyTraits(const QSet<QString> &traits);
|
|
|
|
void applyTweakers(const QStringList &tweakers);
|
2017-04-17 20:51:30 +00:00
|
|
|
void applyJarMods(const QList<LibraryPtr> &jarMods);
|
2017-04-21 20:23:00 +00:00
|
|
|
void applyMods(const QList<LibraryPtr> &jarMods);
|
2016-03-13 01:28:55 +00:00
|
|
|
void applyLibrary(LibraryPtr library);
|
2017-04-13 07:28:25 +00:00
|
|
|
void applyMainJar(LibraryPtr jar);
|
2016-03-18 14:02:54 +00:00
|
|
|
void applyProblemSeverity(ProblemSeverity severity);
|
2015-01-27 21:31:07 +00:00
|
|
|
|
2016-03-21 01:19:23 +00:00
|
|
|
public: /* getters for profile variables */
|
2016-03-12 23:23:45 +00:00
|
|
|
QString getMinecraftVersion() const;
|
|
|
|
QString getMainClass() const;
|
|
|
|
QString getAppletClass() const;
|
|
|
|
QString getMinecraftVersionType() const;
|
2016-03-21 01:19:23 +00:00
|
|
|
MojangAssetIndexInfo::Ptr getMinecraftAssets() const;
|
2016-03-12 23:23:45 +00:00
|
|
|
QString getMinecraftArguments() const;
|
|
|
|
const QSet<QString> & getTraits() const;
|
|
|
|
const QStringList & getTweakers() const;
|
2017-04-17 20:51:30 +00:00
|
|
|
const QList<LibraryPtr> & getJarMods() const;
|
2016-03-12 23:23:45 +00:00
|
|
|
const QList<LibraryPtr> & getLibraries() const;
|
2017-04-06 21:31:23 +00:00
|
|
|
const QList<LibraryPtr> & getNativeLibraries() const;
|
2017-04-13 07:28:25 +00:00
|
|
|
const LibraryPtr getMainJar() const;
|
|
|
|
void getLibraryFiles(const QString & architecture, QStringList & jars, QStringList & nativeJars, const QString & overridePath,
|
|
|
|
const QString & tempPath) const;
|
2016-03-12 23:23:45 +00:00
|
|
|
bool hasTrait(const QString & trait) const;
|
2016-03-18 14:02:54 +00:00
|
|
|
ProblemSeverity getProblemSeverity() const;
|
2014-01-24 17:12:02 +00:00
|
|
|
|
2016-03-12 23:23:45 +00:00
|
|
|
public:
|
2015-01-27 21:31:07 +00:00
|
|
|
/// get the profile patch by id
|
|
|
|
ProfilePatchPtr versionPatch(const QString &id);
|
|
|
|
|
|
|
|
/// get the profile patch by index
|
|
|
|
ProfilePatchPtr versionPatch(int index);
|
|
|
|
|
|
|
|
/// save the current patch order
|
|
|
|
void saveCurrentOrder() const;
|
|
|
|
|
|
|
|
/// Remove all the patches
|
|
|
|
void clearPatches();
|
|
|
|
|
|
|
|
/// Add the patch object to the internal list of patches
|
|
|
|
void appendPatch(ProfilePatchPtr patch);
|
|
|
|
|
2016-03-18 14:02:54 +00:00
|
|
|
private: /* data */
|
|
|
|
/// the version of Minecraft - jar to use
|
|
|
|
QString m_minecraftVersion;
|
2014-05-09 23:53:32 +00:00
|
|
|
|
2013-07-28 22:59:35 +00:00
|
|
|
/// Release type - "release" or "snapshot"
|
2016-03-18 14:02:54 +00:00
|
|
|
QString m_minecraftVersionType;
|
2016-03-12 23:23:45 +00:00
|
|
|
|
2013-12-08 06:12:53 +00:00
|
|
|
/// Assets type - "legacy" or a version ID
|
2016-03-21 01:19:23 +00:00
|
|
|
MojangAssetIndexInfo::Ptr m_minecraftAssets;
|
2016-03-12 23:23:45 +00:00
|
|
|
|
2013-07-28 22:59:35 +00:00
|
|
|
/**
|
|
|
|
* arguments that should be used for launching minecraft
|
2013-09-22 02:21:36 +00:00
|
|
|
*
|
2013-07-28 22:59:35 +00:00
|
|
|
* ex: "--username ${auth_player_name} --session ${auth_session}
|
|
|
|
* --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}"
|
|
|
|
*/
|
2016-03-18 14:02:54 +00:00
|
|
|
QString m_minecraftArguments;
|
2016-03-12 23:23:45 +00:00
|
|
|
|
|
|
|
/// A list of all tweaker classes
|
2016-03-18 14:02:54 +00:00
|
|
|
QStringList m_tweakers;
|
2016-03-12 23:23:45 +00:00
|
|
|
|
|
|
|
/// The main class to load first
|
2016-03-18 14:02:54 +00:00
|
|
|
QString m_mainClass;
|
2016-03-12 23:23:45 +00:00
|
|
|
|
|
|
|
/// The applet class, for some very old minecraft releases
|
2016-03-18 14:02:54 +00:00
|
|
|
QString m_appletClass;
|
2015-01-27 21:31:07 +00:00
|
|
|
|
2016-03-13 01:28:55 +00:00
|
|
|
/// the list of libraries
|
2016-03-18 14:02:54 +00:00
|
|
|
QList<LibraryPtr> m_libraries;
|
2014-09-06 16:16:56 +00:00
|
|
|
|
2017-04-13 07:28:25 +00:00
|
|
|
/// the main jar
|
|
|
|
LibraryPtr m_mainJar;
|
|
|
|
|
2017-04-06 21:31:23 +00:00
|
|
|
/// the list of libraries
|
|
|
|
QList<LibraryPtr> m_nativeLibraries;
|
|
|
|
|
2014-04-23 00:27:40 +00:00
|
|
|
/// traits, collected from all the version files (version files can only add)
|
2016-03-18 14:02:54 +00:00
|
|
|
QSet<QString> m_traits;
|
2014-04-23 00:27:40 +00:00
|
|
|
|
|
|
|
/// A list of jar mods. version files can add those.
|
2017-04-17 20:51:30 +00:00
|
|
|
QList<LibraryPtr> m_jarMods;
|
2016-03-18 14:02:54 +00:00
|
|
|
|
2017-04-21 20:23:00 +00:00
|
|
|
/// the list of mods
|
|
|
|
QList<LibraryPtr> m_mods;
|
|
|
|
|
2017-03-27 01:34:39 +00:00
|
|
|
ProblemSeverity m_problemSeverity = ProblemSeverity::None;
|
2013-09-22 02:21:36 +00:00
|
|
|
|
2013-07-28 22:59:35 +00:00
|
|
|
/*
|
|
|
|
FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
|
|
|
|
|
|
|
|
"rules": [
|
|
|
|
{
|
|
|
|
"action": "allow"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"action": "disallow",
|
|
|
|
"os": {
|
|
|
|
"name": "osx",
|
|
|
|
"version": "^10\\.5\\.\\d$"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
2013-09-22 02:21:36 +00:00
|
|
|
"incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX
|
|
|
|
10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!"
|
2013-07-28 22:59:35 +00:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
// QList<Rule> rules;
|
2016-03-18 14:02:54 +00:00
|
|
|
|
|
|
|
/// list of attached profile patches
|
|
|
|
QList<ProfilePatchPtr> m_patches;
|
|
|
|
|
|
|
|
/// strategy used for profile operations
|
2015-01-27 21:31:07 +00:00
|
|
|
ProfileStrategy *m_strategy = nullptr;
|
2013-09-15 22:54:39 +00:00
|
|
|
};
|