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 Dec 3, 2017 · 31 revisions

modioAddModfile

void addModfile(u32 mod_id, modio::ModfileHandler& modfile_handler, 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_handler modio::ModfileHandler& ModioModfileHandler 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 ModioResponse object that contains the mod.io response status.
modfile const modio::Modfile& Resulting ModioModfile object.

Example:

modio::ModfileHandler modfile_handler;
modfile_handler.setModfilePath("ModExample/modfile/");
modfile_handler.setModfileVersion("v1.1.0");
modfile_handler.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");

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

modioEditModfile

void editModfile(u32 mod_id, u32 modfile_id, modio::ModfileHandler& modfile_handler, 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 uinique identifier.
modfile_id u32 Modfile's unique identifier.
modfile_handler modio::ModfileHandler& ModioModfileHandler 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& ModioResponse object that contains the mod.io response status.
modfile const modio::Modfile& Resulting ModioModfile object.

Example

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

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

modioInstallModfile

void modioInstallModfile(ModioModfile *modfile, char* destination_path, void (*callback)(ModioResponse* response, char* path))
void installModfile(modio::Modfile modfile, const std::string& destination_path, const std::function<void(const modio::Response& response, const std::string& path)>& callback)

Downloads and decompress a mod file into a provided directory.

Function parameters

Name Type Description
modfile modio::Modfile modfile ModioModfile 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, const std::string& path)>& Function called once the process finished.

Callback parameteres

Name Type Description
response const modio::Response& ModioResponse object that contains the mod.io response status.
path const std::string& Path where the modfile was installed.

Examples

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

modioGetModfileState

u32 getModfileState(u32 modfile_id)

Returns the current state of the downloads.

Function parameters

Name Type Description
modfile_id u32 Modfile unique identifier.

Possible modfile states

Name Value Description
MODIO_MODFILE_NOT_INSTALLED 0 The modfile is not installed.
MODIO_MODFILE_INSTALLED 1 The modfile is installed.
MODIO_MODFILE_INSTALLING 2 The modfile is being installed.

modioGetModfileDownloadPercentage

double 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.

Contents

Clone this wiki locally