Skip to content

Instantly share code, notes, and snippets.

@Turupawn
Last active January 16, 2018 01:44
Show Gist options
  • Save Turupawn/587af4443e57e98bcbcbf53414eae1c8 to your computer and use it in GitHub Desktop.
Save Turupawn/587af4443e57e98bcbcbf53414eae1c8 to your computer and use it in GitHub Desktop.
Modio Create Example
#include "modio.h"
int main(void)
{
modio::Instance modio_instance(7, "e91c01b8882f4affeddd56c96111977b");
volatile static bool finished = false;
auto wait = [&]()
{
while (!finished)
{
modio_instance.sleep(10);
modioProcess();
}
};
auto finish = [&]()
{
finished = true;
};
if(modio_instance.isLoggedIn())
{
// The Mod Creator helps setting up the fields before creating a Mod
modio::ModCreator mod_creator;
mod_creator.setLogoPath("ModExample/logo.png");
mod_creator.setName("Example Mod Test30");
mod_creator.setHomepage("http://www.webpage.com");
mod_creator.setSummary("Mod added via the SDK examples. Mod added via the SDK examples. Mod added via the SDK examples. Mod added via the SDK examples. Mod added via the SDK examples. Mod added via the SDK examples.");
mod_creator.addTag("Easy");
mod_creator.addTag("Medium");
mod_creator.setDescription("This mod description was added via the SDK examples. This mod description was added via the SDK examples.");
mod_creator.setMetadataBlob("Optional metadata");
mod_creator.setVisible(MODIO_PUBLIC);
std::cout <<"Creating mod..." << std::endl;
// Now we can create the new mod. Remember, this mod wont have a Modfile right away, you should be adding one after the mod was created successfully
modio_instance.addMod(mod_creator, [&](const modio::Response& response, const modio::Mod& mod)
{
std::cout << "On mod get response: " << response.code << std::endl;
if(response.code == 201)
{
std::cout << "Mod created successfully" << std::endl;
// The Modfile Creator helps us setting up the modfile fields and the mod directory that will be zipped and uploaded
modio::ModfileCreator modfile_creator;
modfile_creator.setPath("ModExample/modfile/");
modfile_creator.setVersion("v1.1.0");
modfile_creator.setChangelog("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");
modfile_creator.setActive(true);
std::cout << "Uploading modfile..." << std::endl;
modio_instance.addModfile(mod.id, modfile_creator, [&](const modio::Response& response, const modio::Modfile& modfile)
{
std::cout << "Add Modfile response: " << response.code << std::endl;
if(response.code == 201)
{
std::cout << "Modfile added successfully!" << std::endl;
}
finish();
});
}else
{
finish();
}
});
wait();
}
std::cout << "Process finished" << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment