Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Modfiles

Ahmed Castro edited this page Feb 4, 2018 · 31 revisions

getModfile

void getModfile(u32 mod_id, u32 modfile_id, const std::function<void(const modio::Response& response, const modio::Modfile& modfile)>& callback);

API endpoint used: Get Mod File

Get a file.

Function parameters

Name Type Description
mod_id u32 Mod's unique identifier.
modfile_id u32 Modfiles's unique identifier.
callback const std::function<void(const modio::Response& response, const modio::Modfile& modfile)>& Function called once the process finished.

Callback parameters

Name Type Description
response const modio::Response& response Response object that contains the mod.io response status.
modfile const modio::Modfile& Resulting Modfile object.

Example:

modio_instance.getModfile(mod_id, modfile_id, [&](const modio::Response& response, const modio::Modfile& modfile)
{
  if(response.code == 200)
  {
    //Modfile successfully added
  }
});

addModfile

void Instance::addModfile(u32 mod_id, modio::ModfileCreator& modfile_creator, const std::function<void(const modio::Response& response, const modio::Modfile& modfile)>& callback)

API endpoint used: Add Mod File

Uploads a file to a corresponding mod.

Function parameters

Name Type Description
mod_id u32 Mod's unique identifier.
modfile_creator modio::ModfileCreator& ModfileCreator object containing the data that will be added.
callback const std::function<void(const modio::Response& response, const modio::Modfile& modfile)>& Function called once the process finished.

Callback parameters

Name Type Description
response const modio::Response& response Response object that contains the mod.io response status.
modfile const modio::Modfile& Resulting Modfile object.

Example:

modio::ModfileCreator modfile_creator;
modfile_creator.setModfilePath("ModExample/modfile/");
modfile_creator.setModfileVersion("v1.1.0");
modfile_creator.setModfileChangelog("This is a change log, this is a changelog , this is a changelog , this is a changelog , this is a changelog , this is a changelog, this is a changelog , this is a changelog , this is a changelog");

modio_instance.addModfile(requested_mod.id, modfile_creator, [&](const modio::Response& response, const modio::Modfile& modfile)
{
  if(response.code == 201)
  {
    //Modfile successfully added
  }
});

editModfile

void Instance::editModfile(u32 mod_id, u32 modfile_id, modio::ModfileEditor& modfile_editor, const std::function<void(const modio::Response& response, const modio::Modfile& modfile)>& callback)

API endpoint used: Edit Mod File

Updates the details of a corresponding modfile. Only the changelog and active fields are editable. If you want to update another field, you should add a new modfile instead.

Function parameters

Name Type Description
mod_id u32 Mod's unique identifier.
modfile_id u32 Modfile's unique identifier.
modfile_editor modio::ModfileEditor& ModfileEditor object containing the data that will be edited.
callback const std::function<void(const modio::Response& response, const modio::Modfile& modfile)>& Function called once the process finished.

Callback parameters

Name Type Description
response const modio::Response& Response object that contains the mod.io response status.
modfile const modio::Modfile& Resulting Modfile object.

Example

modio::ModfileEditor modfile_editor;
modfile_editor.setModfileActive(true);
modfile_editor.setModfileChangelog("Stuff was changed on this mod via the examples.");

mod.editModfile(requested_mod.id, requested_mod.modfile.id, modfile_editor, [&](const modio::Response& response, const modio::Modfile& modfile)
{
  if(response.code == 200)
  {
    //Modfile successfully edited
  }
});

installModfile

void Instance::installModfile(modio::Modfile modfile, const std::string& destination_path, const std::function<void(const modio::Response& response)>& callback)

Downloads and decompress a mod file into a provided directory.

Function parameters

Name Type Description
modfile modio::Modfile modfile Modfile object to be downloaded.
destination_path const std::string& destination_path Directory where the modfile will be installed.
callback const std::function<void(const modio::Response& response)>& Function called once the process finished.

Callback parameteres

Name Type Description
response const modio::Response& Response object that contains the mod.io response status.

Examples

modio_instance.installModfile(requested_mod.modfile, "mods_dir/modfile", [&](const modio::Response& response)
{
  if(response.code == 200)
  {
    //Modfile successfully installed
  }
});

getModfileState

u32 Instance::getModfileState(u32 modfile_id)

Returns the current state of the downloads. See all the possible Modfile states returned.

Function parameters

Name Type Description
modfile_id u32 Modfile unique identifier.

getModfileDownloadPercentage

double Instance::getModfileDownloadPercentage(u32 modfile_id)

Returns the current percentage of the modfile downloaded. Returns -1 if the modfile is not being currently downloaded.

Function parameters

Name Type Description
modfile_id u32 Modfile unique identifier.

uninstallModfile

bool uninstallModfile(u32 modfile_id)

Removes the locally installed modfile folder.

Function parameters

Name Type Description
modfile_id u32 Modfile unique identifier.

getInstalledModfileIds

std::vector<u32> getInstalledModfileIds()

Returns a std::vector containing the ids of the modfiles installed locally.

Contents

Clone this wiki locally