2013-07-22 05:31:56 +05:30
|
|
|
#pragma once
|
2013-07-25 03:14:00 +05:30
|
|
|
#include <QtCore>
|
2013-07-22 05:31:56 +05:30
|
|
|
|
2013-07-25 03:14:00 +05:30
|
|
|
class Library;
|
|
|
|
|
|
|
|
enum OpSys
|
|
|
|
{
|
|
|
|
Os_Windows,
|
|
|
|
Os_Linux,
|
|
|
|
Os_OSX,
|
|
|
|
Os_Other
|
|
|
|
};
|
|
|
|
|
|
|
|
OpSys OpSys_fromString(QString);
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
#define currentSystem Os_Windows
|
2013-08-07 05:08:18 +05:30
|
|
|
#elif Q_OS_MAC
|
|
|
|
#define currentSystem Os_OSX
|
|
|
|
#else
|
|
|
|
#define currentSystem Os_Linux
|
2013-07-25 03:14:00 +05:30
|
|
|
#endif
|
|
|
|
|
2013-07-27 15:11:45 +05:30
|
|
|
enum RuleAction
|
|
|
|
{
|
|
|
|
Allow,
|
|
|
|
Disallow,
|
|
|
|
Defer
|
|
|
|
};
|
|
|
|
|
|
|
|
RuleAction RuleAction_fromString(QString);
|
|
|
|
|
|
|
|
class Rule
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
RuleAction m_result;
|
|
|
|
virtual bool applies(Library * parent) = 0;
|
|
|
|
public:
|
|
|
|
Rule(RuleAction result)
|
|
|
|
:m_result(result) {}
|
|
|
|
virtual ~Rule(){};
|
|
|
|
RuleAction apply(Library * parent)
|
|
|
|
{
|
|
|
|
if(applies(parent))
|
|
|
|
return m_result;
|
|
|
|
else
|
|
|
|
return Defer;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-07-25 03:14:00 +05:30
|
|
|
class OsRule : public Rule
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
// the OS
|
|
|
|
OpSys m_system;
|
|
|
|
// the OS version regexp
|
|
|
|
QString m_version_regexp;
|
|
|
|
protected:
|
|
|
|
virtual bool applies ( Library* )
|
|
|
|
{
|
|
|
|
return (m_system == currentSystem);
|
|
|
|
}
|
|
|
|
OsRule(RuleAction result, OpSys system, QString version_regexp)
|
|
|
|
: Rule(result), m_system(system), m_version_regexp(version_regexp) {}
|
2013-07-27 15:11:45 +05:30
|
|
|
public:
|
|
|
|
static QSharedPointer<OsRule> create(RuleAction result, OpSys system, QString version_regexp)
|
|
|
|
{
|
|
|
|
return QSharedPointer<OsRule> (new OsRule(result, system, version_regexp));
|
|
|
|
}
|
2013-07-25 03:14:00 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
class ImplicitRule : public Rule
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual bool applies ( Library* )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
ImplicitRule(RuleAction result)
|
|
|
|
: Rule(result) {}
|
2013-07-27 15:11:45 +05:30
|
|
|
public:
|
|
|
|
static QSharedPointer<ImplicitRule> create(RuleAction result)
|
|
|
|
{
|
|
|
|
return QSharedPointer<ImplicitRule> (new ImplicitRule(result));
|
|
|
|
}
|
2013-07-25 03:14:00 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
class Library
|
|
|
|
{
|
2013-07-27 15:11:45 +05:30
|
|
|
private:
|
|
|
|
// basic values used internally (so far)
|
|
|
|
QString m_name;
|
|
|
|
QString m_base_url;
|
|
|
|
QList<QSharedPointer<Rule> > m_rules;
|
|
|
|
|
|
|
|
// derived values used for real things
|
|
|
|
/// where to store the lib locally
|
|
|
|
QString m_storage_path;
|
|
|
|
/// where to download the lib from
|
|
|
|
QString m_download_path;
|
2013-08-05 06:59:50 +05:30
|
|
|
/// is this lib actually active on the current OS?
|
2013-07-27 15:11:45 +05:30
|
|
|
bool m_is_active;
|
2013-08-05 06:59:50 +05:30
|
|
|
/// is the library a native?
|
2013-07-27 15:11:45 +05:30
|
|
|
bool m_is_native;
|
2013-08-05 06:59:50 +05:30
|
|
|
/// native suffixes per OS
|
2013-07-27 15:11:45 +05:30
|
|
|
QMap<OpSys, QString> m_native_suffixes;
|
2013-07-25 03:14:00 +05:30
|
|
|
public:
|
|
|
|
QStringList extract_excludes;
|
|
|
|
|
2013-07-27 15:11:45 +05:30
|
|
|
public:
|
2013-07-28 12:10:15 +05:30
|
|
|
/// Constructor
|
2013-07-27 15:11:45 +05:30
|
|
|
Library(QString name)
|
|
|
|
{
|
|
|
|
m_is_native = false;
|
|
|
|
m_is_native = false;
|
|
|
|
m_name = name;
|
|
|
|
m_base_url = "https://s3.amazonaws.com/Minecraft.Download/libraries/";
|
|
|
|
}
|
|
|
|
|
2013-07-28 12:10:15 +05:30
|
|
|
/**
|
|
|
|
* finalize the library, processing the input values into derived values and state
|
|
|
|
*
|
|
|
|
* This SHALL be called after all the values are parsed or after any further change.
|
|
|
|
*/
|
|
|
|
void finalize();
|
|
|
|
|
2013-08-05 06:59:50 +05:30
|
|
|
/// Set the library composite name
|
|
|
|
void setName(QString name);
|
|
|
|
/// Set the url base for downloads
|
|
|
|
void setBaseUrl(QString base_url);
|
|
|
|
/// Call this to mark the library as 'native' (it's a zip archive with DLLs)
|
|
|
|
void setIsNative();
|
|
|
|
/// Attach a name suffix to the specified OS native
|
|
|
|
void addNative(OpSys os, QString suffix);
|
|
|
|
/// Set the load rules
|
|
|
|
void setRules(QList<QSharedPointer<Rule> > rules);
|
|
|
|
|
|
|
|
/// Returns true if the library should be loaded (or extracted, in case of natives)
|
|
|
|
bool isActive();
|
|
|
|
/// Returns true if the library is native
|
|
|
|
bool isNative();
|
|
|
|
/// Get the URL to download the library from
|
|
|
|
QString downloadPath();
|
|
|
|
/// Get the relative path where the library should be saved
|
|
|
|
QString storagePath();
|
2013-07-25 03:14:00 +05:30
|
|
|
};
|
2013-07-29 04:29:35 +05:30
|
|
|
|
|
|
|
|
|
|
|
class FullVersion
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// the ID - determines which jar to use! ACTUALLY IMPORTANT!
|
|
|
|
QString id;
|
|
|
|
/// Last updated time - as a string
|
|
|
|
QString time;
|
|
|
|
/// Release time - as a string
|
|
|
|
QString releaseTime;
|
|
|
|
/// Release type - "release" or "snapshot"
|
|
|
|
QString type;
|
|
|
|
/**
|
|
|
|
* DEPRECATED: Old versions of the new vanilla launcher used this
|
|
|
|
* ex: "username_session_version"
|
|
|
|
*/
|
|
|
|
QString processArguments;
|
|
|
|
/**
|
|
|
|
* arguments that should be used for launching minecraft
|
|
|
|
*
|
|
|
|
* ex: "--username ${auth_player_name} --session ${auth_session}
|
|
|
|
* --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}"
|
|
|
|
*/
|
|
|
|
QString minecraftArguments;
|
|
|
|
/**
|
|
|
|
* the minimum launcher version required by this version ... current is 4 (at point of writing)
|
|
|
|
*/
|
|
|
|
int minimumLauncherVersion;
|
|
|
|
/**
|
|
|
|
* The main class to load first
|
|
|
|
*/
|
|
|
|
QString mainClass;
|
|
|
|
|
|
|
|
/// the list of libs - both active and inactive, native and java
|
|
|
|
QList<QSharedPointer<Library> > libraries;
|
|
|
|
|
|
|
|
/*
|
|
|
|
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$"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"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!"
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
// QList<Rule> rules;
|
|
|
|
|
|
|
|
public:
|
|
|
|
FullVersion()
|
|
|
|
{
|
|
|
|
minimumLauncherVersion = 0xDEADBEEF;
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<QSharedPointer<Library> > getActiveNormalLibs();
|
|
|
|
QList<QSharedPointer<Library> > getActiveNativeLibs();
|
|
|
|
};
|