Skip to content

Instantly share code, notes, and snippets.

@02JanDal
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 02JanDal/ad6aeac6bba1dac4cc6b to your computer and use it in GitHub Desktop.
Save 02JanDal/ad6aeac6bba1dac4cc6b to your computer and use it in GitHub Desktop.
MultiLaunch design Doc/Ideas

Basic building blocks

Utilities

BaseConfigObject is an abstract class for classes that save some sort of configuration, settings or similar to disk. It handles periodic saving (if there're changes).

Tasks

Task is the base class for all tasks, it contains information about the state of the task (started/running/finished/success/failure), error message, status message etc., including related signals. Other tasks will inherit from this, and implement at least the pure virtual run() method.

GroupedTask is a task that consists of several subtasks. When run, all subtasks will be executed, with a specified number of them run concurrently.

A ThreadTask wraps a normal Task, and runs it in a separate thread.

ProgressDialog and ProgressWidget take a Task and show information about it using a label and a progress bar.

Game-specific tasks

JavaLaunchTask has a launch script (think the launch script in MultiMC)

MinecraftAuthTask is the task generated from a MinecraftAuthComponent, which does the actual work.

Network and file cache

FileCache handles the application-global file cache, for caching of downloads etc. It provides getters/setters for FileCache::Entrys, which in turn contain information about the file stored. Entries are references by a group and an id, the group could be "factorio/archives", and the id "0.10.5.zip". The FileCache also handles invalidation of cache entries.

NetworkTask is an abstract Task that handles connecting QNetworkReply signals to the ones of the Task. It also handles redirects etc.

RawDownloadTask is a task that downloads something and yields the result as a raw byte array.

CachedDownloadTask also downloads a single file, but stores it to disk and registers it with the FileCache, using the group and id given to the constructor.

Models

ContainerModel is an application-global model of all containers.

ComponentModel exposes all components contained within a single container.

Components

BaseComponent is an abstract class that is the base for all components. It provides several virtual methods, some pure, for querying things like name, version, parent etc. It also keeps track of it's parent component as well as the container it is contained within. Not shown in the current diagram are functions for loading/saving the component from/to a JSON object, query functions like isImplicit (= not saved, usually used for children of a BaseCompoundComponent), isUserVisible etc.

BaseCompoundComponent is the base class for all components that are made up of several others. It's mainly for keeping things organized in a tree-like structure, which is flattened by the container when required.

Game specific components

JavaLibraryComponent is a compound component that takes a maven identifier, and is made up of one ClasspathComponent and one FileDownloadComponent.

MinecraftComponent does the same, but takes only a version for the wanted version of Minecraft.

ClasspathComponent is a component that specifies a file to add to the classpath for Java-based games.

FileDownloadComponent specifies a file that needs to be downloaded, thus returning a CachedDownloadTask in the getUpdateTask method.

FactorioComponent takes a download URL and is made up of a FileDownloadComponent and a RunnableComponent

RunnableComponent specifies a file that can be run.

MinecraftAuthComponent checks if there exists an active and valid Minecraft account, prompting the user if not.

Containers

Container is a rather lightweight class that handles one directory on disk. It is made up of one or more Components, with at least one that is a "root component", which decides which other components may be added.

Aspects

Aspects are the part that transform a list of component into a list of tasks for a specific stage. They all inherit from the BaseAspect interface, and have to reimplement a single pure virtual method, where they are given the container as well as a Stage for which to generate tasks. They then iterate through all components in the container, and if they find one which they know what to do with at the current stage, they add a Task for that to the list, which is then returned.

FileDownloadAspect gathers all FileDownloadComponents, and if the stage is Download, it generates a CachedDownloadTasks for all of them.

Game-specific aspects

JavaLaunchAspect gathers ClasspathComponents etc. and generates a launchscript for a JavaLaunchTask.

MinecraftAspect gathers the MinecraftAuthComponent and generates the MinecraftAuthTask.

container.json

{
  "name": "MinecraftTest",
  "components": [
    {
      "id": "Minecraft.Minecraft",
      "version": "1.8.1"
    },
    {
      "id": "Java.Classpath",
      "identifier": "net.minecraftforge:forge:42.42.42"
    },
    {
      "id": "Java.Arguments",
      "arguments": "-Xmx=2048M"
    }
  ]
}

This would generate the following component tree:

How would saving settings be done?

There'd be a base class similar to BaseAspect, but for generating a list of either config pages, or just config entries. So those "config aspects" would iterate through the list of components, and generate config pages/entries for those that need it. The entries would contain pointers back to the component, for doing the actual changes.

All states and how they transition

Launching Minecraft

Before the following happens, UpdateCheck stages etc. have already been gone through. Not all aspects generate tasks for each stage. The iteration through all components by each task are not shown.

At the Launch stage, the JavaLaunchAspect gathers info about the classpath components, and JVM arguments, and creates from them a launchscript for the JavaLaunchTask.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment