Skip to main content

Application

The main application class that manages the launcher’s global state and resources. Class: Application
Header: launcher/Application.h
Inherits: QApplication

Constructor

Application(int& argc, char** argv);
Creates the main application instance with command-line arguments.

Key Methods

settings()
SettingsObject*
Returns the global settings object for the application.
instances()
InstanceList*
Returns the instance list manager containing all Minecraft instances.
accounts()
AccountList*
Returns the account list for managing Minecraft accounts.
network()
QNetworkAccessManager*
Returns the network access manager for HTTP requests.
metacache()
HttpMetaCache*
Returns the HTTP metadata cache for managing downloaded files.
metadataIndex()
Meta::Index*
Returns the metadata index for Minecraft versions and components.

Path Management

root()
const QString&
Returns the root installation directory path.
dataRoot()
const QString&
Returns the data directory path where instances are stored.
javaPath()
const QString
Returns the Java installation path.

Instance Management

bool launch(
    BaseInstance* instance,
    LaunchMode mode = LaunchMode::Normal,
    std::shared_ptr<MinecraftTarget> targetToJoin = nullptr,
    shared_qobject_ptr<MinecraftAccount> accountToUse = nullptr,
    const QString& offlineName = QString()
);
Launches a Minecraft instance with optional server joining and account selection.

Capabilities

enum Capability {
    None = 0,
    SupportsMSA = 1 << 0,        // Microsoft Account support
    SupportsFlame = 1 << 1,      // CurseForge API support
    SupportsGameMode = 1 << 2,   // Linux GameMode support
    SupportsMangoHud = 1 << 3    // MangoHud overlay support
};
Check capabilities with:
const Capabilities caps = APPLICATION->capabilities();
if (caps & Application::SupportsMSA) {
    // Microsoft authentication is available
}

Example Usage

#include "Application.h"

// Access the singleton application instance
auto* app = APPLICATION;

// Get global settings
SettingsObject* settings = app->settings();

// Get instance list
InstanceList* instances = app->instances();

// Launch an instance
BaseInstance* instance = instances->getInstanceById("my_instance");
if (instance) {
    app->launch(instance);
}

BaseInstance

Base class for all Minecraft instances, providing common functionality. Class: BaseInstance
Header: launcher/BaseInstance.h
Inherits: QObject

Constructor

BaseInstance(
    SettingsObject* globalSettings,
    std::unique_ptr<SettingsObject> settings,
    const QString& rootDir
);

Identity and Naming

id()
QString
Returns the unique instance ID.
name()
QString
Returns the display name of the instance.
setName(QString val)
void
Sets the display name of the instance.
windowTitle()
QString
Returns the title used for instance windows.

Path Management

instanceRoot()
QString
Returns the root directory of the instance.
gameRoot()
QString
Returns the game root directory (usually same as instanceRoot).
modsRoot()
QString
Returns the mods directory path (pure virtual, implemented by subclasses).

Status and State

enum class Status {
    Present,  // Instance is valid and present
    Gone      // Instance was removed or invalidated
};
currentStatus()
Status
Returns the current status of the instance.
isRunning()
bool
Returns true if the instance is currently running.

Time Tracking

totalTimePlayed()
int64_t
Returns total playtime in milliseconds.
lastTimePlayed()
int64_t
Returns last session duration in milliseconds.
lastLaunch()
qint64
Returns timestamp of last launch (milliseconds since epoch).
setLastLaunch(qint64 val)
void
Sets the last launch timestamp.

Settings and Configuration

settings()
SettingsObject*
Returns instance-specific settings object.
notes()
QString
Returns user notes for this instance.
setNotes(QString val)
void
Sets user notes for this instance.

Launch Commands

getPreLaunchCommand()
QString
Returns command to execute before launching.
getPostExitCommand()
QString
Returns command to execute after game exits.
getWrapperCommand()
QString
Returns wrapper command for the game process.

Managed Pack Support

Signals

signals:
    void propertiesChanged(BaseInstance* inst);
    void runningStatusChanged(bool running);
    void statusChanged(Status from, Status to);

Example Usage

#include "BaseInstance.h"

BaseInstance* instance = /* ... */;

// Get instance information
qDebug() << "Instance:" << instance->name();
qDebug() << "ID:" << instance->id();
qDebug() << "Path:" << instance->instanceRoot();
qDebug() << "Total playtime:" << instance->totalTimePlayed() / 1000 << "seconds";

// Configure instance
instance->setName("My Survival World");
instance->setNotes("Modded survival with friends");

// Check if it's a managed pack
if (instance->isManagedPack()) {
    qDebug() << "Pack type:" << instance->getManagedPackType();
    qDebug() << "Pack ID:" << instance->getManagedPackID();
}

InstanceList

Manages the collection of all Minecraft instances. Class: InstanceList
Header: launcher/InstanceList.h
Inherits: QAbstractListModel

Constructor

InstanceList(
    SettingsObject* settings,
    const QString& instDir,
    QObject* parent = 0
);

Accessing Instances

at(int i)
BaseInstance*
Returns the instance at the specified index.
count()
int
Returns the total number of instances.
getInstanceById(QString id)
BaseInstance*
Finds an instance by its unique ID. Returns nullptr if not found. O(n) complexity.
getInstanceByManagedName(const QString& managed_name)
BaseInstance*
Finds an instance by its managed pack name. O(n) complexity.

Group Management

getGroups()
QStringList
Returns list of all instance groups.
getInstanceGroup(const InstanceId& id)
GroupId
Returns the group ID for an instance.
setInstanceGroup(const InstanceId& id, GroupId name)
void
Assigns an instance to a group.
deleteGroup(const GroupId& name)
void
Deletes a group (instances remain ungrouped).
renameGroup(const GroupId& src, const GroupId& dst)
void
Renames a group.

Instance Operations

bool trashInstance(const InstanceId& id);
Moves an instance to trash. Can be undone.
bool undoTrashInstance();
Restores the last trashed instance.

Model Roles

enum AdditionalRoles {
    GroupRole = Qt::UserRole,
    InstancePointerRole = 0x34B1CB48,  // Returns BaseInstance*
    InstanceIDRole = 0x34B1CB49        // Returns instance ID
};

Signals

signals:
    void instancesChanged();
    void groupsChanged(QSet<QString> groups);
    void instanceSelectRequest(QString instanceId);

Example Usage

#include "InstanceList.h"
#include "Application.h"

// Get the instance list from the application
InstanceList* list = APPLICATION->instances();

// Iterate through all instances
for (int i = 0; i < list->count(); i++) {
    BaseInstance* inst = list->at(i);
    qDebug() << inst->name() << "-" << inst->id();
}

// Find a specific instance
BaseInstance* inst = list->getInstanceById("my_instance_id");
if (inst) {
    qDebug() << "Found instance:" << inst->name();
}

// Group management
list->setInstanceGroup("my_instance_id", "Modded");
QStringList groups = list->getGroups();

// Trash an instance (can be undone)
if (list->trashInstance("old_instance_id")) {
    qDebug() << "Instance moved to trash";
    
    // Changed your mind? Restore it
    list->undoTrashInstance();
}