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

Modfiles (C compatible)

Ahmed Castro edited this page Sep 28, 2018 · 25 revisions

modioGetAllModfiles

void modioGetAllModfiles(void* object, u32 mod_id, ModioFilterCreator filter, void (*callback)(void* object, ModioResponse response, ModioModfile modfiles[], u32 modfiles_size));

Wrapped by: Modfiles#getallmodfiles

API endpoint used: Get All Modfiles

Browse modfiles on mod.io, can be filtered using the ModioFilterCreator.

Function parameters

Name Type Description
object void* Context parameter.
mod_id u32 Mod's unique identifier.
filter ModioFilterCreator* ModioFilterCreator object to be customized.
callback void (*callback)(void* object, ModioResponse response, ModioModfile modfiles[], u32 modfiles_size) Function called once the process finished.

Callback parameters

Name Type Description
object void* Context parameter.
response ModioResponse ModioResponse object that contains the mod.io response status.
modfiles ModioModfile* ModioModfile array containing the returned mods.
modfiles_size u32 Modfiles array size.

Example

void onGetAllModfiles(void* object, ModioResponse response, ModioModfile modfiles[], u32 modfiles_size)
{
  if(response.code == 200)
  {
    //Modfiles retrieved successfully
  }
}

[...]

ModioFilterCreator filter;
modioInitFilter(&filter);
modioSetFilterLimit(&filter,3);

modioGetAllModfiles(NULL, mod_id, filter, &onGetAllModfiles);

modioGetModfile

void modioGetModfile(void* object, u32 mod_id, u32 modfile_id, void (*callback)(void* object, ModioResponse response, ModioModfile modfile));

C++ wrapper: Modfiles#getmodfile

API endpoint used: Get Mod File

Get a file.

Function parameters

Name Type Description
object void* Context parameter.
mod_id u32 Mod's unique identifier.
modfile_id u32 Modfile's unique identifier.
callback void (*callback)(void* object, ModioResponse response, ModioModfile modfile) Function called once the process finished.

Callback parameters

Name Type Description
object void* Context parameter.
response ModioResponse ModioResponse object that contains the mod.io response status.
modfile ModioModfile Resulting ModioModfile object.

Example:

void onGetModfile(void* object, ModioResponse response, ModioModfile modfile)
{
  if(response.code == 200)
  {
    //Modfile retrieved successfully
  }
}

[...]

modioGetModfile(NULL, mod_id, modfile_id, &onGetModfile);

modioAddModfile

void modioAddModfile(void* object, u32 mod_id, ModioModfileCreator* modfile_creator, void (*callback)
(void* object, ModioResponse response, const ModioModfile& modfile));

C++ wrapper: Modfiles#addmodfile

API endpoint used: Add Mod File

Uploads a file to a corresponding mod.

Function parameters

Name Type Description
object void* Context parameter.
mod_id u32 Mod's unique identifier.
modfile_creator ModioModfileCreator* ModioModfileCreator object containing the data that will be added.
callback void (*callback) (void* object, ModioResponse response, const ModioModfile& modfile) Function called once the process finished.

Callback parameters

Name Type Description
object void* Context parameter.
response ModioResponse ModioResponse object that contains the mod.io response status.
modfile const modio::Modfile& Resulting ModioModfile object.

Example:

void onModfileAdded(void* object, ModioResponse response, ModioModfile modfile)
{
  if(response.code == 201)
  {
    //Modfile added successfully
  }
}

[...]

ModioModfileCreator modfile_creator;
modioInitModfileCreator(&modfile_creator);
modioSetModfilePath(&modfile_creator, "ModExample/modfile/");
modioSetModfileVersion(&modfile_creator, "v1.1.0");
modioSetModfileChangelog(&modfile_creator, "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");

modioAddModfile(NULL, mod.id, modfile_creator, &onModfileAdded);

modioEditModfile

void modioEditModfile(void* object, u32 mod_id, u32 modfile_id, ModioModfileEditor* modfile_editor, void (*callback)(void* object, ModioResponse response, const ModioModfile& modfile));

C++ wrapper: Modfiles#editmodfile

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
object void* Mod's unique identifier.
mod_id u32 Mod's unique identifier.
modfile_id u32 Modfile's unique identifier.
modfile_editor ModioModfileEditor* ModioModfileEditor object containing the data that will be edited.
callback void (*callback)(void* object, ModioResponse response, const ModioModfile& modfile) Function called once the process finished.

Callback parameters

Name Type Description
object void* Mod's unique identifier.
response ModioResponse ModioResponse object that contains the mod.io response status.
modfile const ModioModfile& Resulting ModioModfile object.

Example

void onModfileEdited(void* object, ModioResponse response, ModioModfile modfile)
{
  if(response.code == 200)
  {
    //Modfile edited successfully
  }
}

[...]

ModioModfileEditor modfile_editor;
modioInitModfileEditor(&modfile_editor);
modioSetModfileActive(&modfile_editor,false);
modioSetModfileChangelog(&modfile_editor,(char*)"Stuff was changed on this mod via the examples.");

modioEditModfile(NULL, mod.id, modfile.id, modfile_editor, &onModfileEdited);

modioDeleteModfile

void modioDeleteModfile(void* object, u32 mod_id, u32 modfile_id, void (*callback)(void* object, ModioResponse response));

C++ wrapper: Modfiles#deletemodfile

API endpoint used: Delete Mod File

Delete a modfile.

Function parameters

Name Type Description
object void* Mod's unique identifier.
mod_id u32 Mod's unique identifier.
modfile_id u32 Modfile's unique identifier.
callback void (*callback)(void* object, ModioResponse response) Function called once the process finished.

Callback parameters

Name Type Description
object void* Mod's unique identifier.
response ModioResponse ModioResponse object that contains the mod.io response status.

Example

void onDeleteModfile(void* object, ModioResponse response, ModioModfile modfile)
{
  if(response.code == 204)
  {
    //Modfile deleted successfully
  }
}

[...]

modioDeleteModfile(NULL, mod.id, modfile.id, &onDeleteModfile);

Contents

Clone this wiki locally