Permalink
Browse files

download methods upgrades

  • Loading branch information...
Turupawn committed Mar 2, 2018
1 parent 3069b25 commit 2f10465f5b4a6792b1378634a72f659aabca7961
@@ -0,0 +1,79 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
]
},
{
"name": "Linux",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},
{
"name": "Win32",
"includePath": [
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/include/*",
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/atlmfc/include/*",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/winrt",
"${workspaceRoot}",
"${workspaceRoot}/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/include/*",
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.12.25827/atlmfc/include/*",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/winrt",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 3
}
View
@@ -0,0 +1,27 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "${workspaceRoot}/build.bat",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true",
"/t:build"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
// Reveal the output only if unrecognized errors occur.
"reveal": "silent"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
}
]
}
View
@@ -0,0 +1,2 @@
cd build
msbuild modio.sln
@@ -35,7 +35,7 @@ int main(void)
std::cout <<"Installing mod..." << std::endl;
modio_instance.installModfile(mod_id, "../mods_dir/modfile", [&](const modio::Response& response)
modio_instance.installMod(mod_id, [&](const modio::Response& response)
{
std::cout << "Install Modfile response: " << response.code << std::endl;
View
@@ -3,6 +3,7 @@
#include "Utility.h"
#include "Globals.h"
#include "ModioUtility.h"
namespace modio
{
@@ -13,8 +14,10 @@ namespace modio
bool checkIfModIsStillInstalled(std::string path, u32 mod_id);
bool checkIfModfileIsStillInstalled(std::string path, u32 modfile_id);
void updateInstalledModsJson();
void checkForInstalledModsUpdates();
std::string getInstalledModfilePath(u32 modfile_id);
std::string getInstalledModPath(u32 mod_id);
void updateModCache(u32 mod_id);
}
#endif
View
@@ -5,6 +5,7 @@
namespace modio
{
void onGetInstalledMods(void* object, ModioResponse response, ModioMod* mods, u32 mods_size);
void onModfileChangedEvent(void* object, ModioResponse response);
void onModUpdateEvent(void* object, ModioResponse response, ModioMod modio_mod);
void onGetAllEventsPoll(void* object, ModioResponse response, ModioEvent* events_array, u32 events_array_size);
@@ -13,6 +13,7 @@
#include "c++/schemas/Game.h"
#include "c++/schemas/GameTagOption.h"
#include "c++/schemas/Image.h"
#include "c++/schemas/InstalledMod.h"
#include "c++/schemas/Media.h"
#include "c++/schemas/MetadataKVP.h"
#include "c++/schemas/Mod.h"
@@ -103,13 +104,14 @@ namespace modio
void getUserModfiles(modio::FilterCreator& filter, const std::function<void(const modio::Response& response, const std::vector<modio::Modfile> & modfiles)>& callback);
//Downloads Methods
void installModfile(u32 mod_id, const std::string& destination_path, const std::function<void(const modio::Response& response)>& callback);
void installMod(u32 mod_id, const std::function<void(const modio::Response& response)>& callback);
bool uninstallModfile(u32 modfile_id);
std::vector<u32> getInstalledModfileIds();
u32 getModfileState(u32 modfile_id);
void pauseCurrentDownload();
void resumeCurrentDownload();
double getModfileDownloadPercentage(u32 modfile_id);
std::vector<modio::InstalledMod> getInstalledMods();
//Dependencies Methods
void getAllModDependencies(u32 mod_id, const std::function<void(const modio::Response& response, const std::vector<modio::Dependency> & mods)>& callback);
@@ -15,6 +15,7 @@ namespace modio
std::string thumb_64x64;
std::string thumb_128x128;
std::string thumb_256x256;
int x;
void initialize(ModioIcon Icon);
json toJson();
@@ -0,0 +1,25 @@
#ifndef MODIO_INSTALLEDMOD_H
#define MODIO_INSTALLEDMOD_H
#include "Utility.h"
#include "Globals.h"
#include "c/schemas/ModioInstalledMod.h"
#include "c++/schemas/Mod.h"
namespace modio
{
class InstalledMod
{
public:
u32 mod_id;
u32 modfile_id;
u32 updated_at;
std::string path;
Mod mod;
void initialize(ModioInstalledMod installed_mod);
json toJson();
};
}
#endif
View
@@ -79,6 +79,7 @@ extern "C"
typedef struct ModioHeader ModioHeader;
typedef struct ModioIcon ModioIcon;
typedef struct ModioImage ModioImage;
typedef struct ModioInstalledMod ModioInstalledMod;
typedef struct ModioLogo ModioLogo;
typedef struct ModioMedia ModioMedia;
typedef struct ModioMetadataKVP ModioMetadataKVP;
@@ -369,6 +370,15 @@ extern "C"
u32 game_tag_option_array_size;
};
struct ModioInstalledMod
{
u32 mod_id;
u32 modfile_id;
u32 updated_at;
char* path;
ModioMod mod;
};
//General Methods
void MODIO_DLL modioInit(u32 environment, u32 game_id, char* api_key);
//void MODIO_DLL init(int game_id, char* api_key, char* root_path);
@@ -500,7 +510,7 @@ extern "C"
void MODIO_DLL modioSetAllowBackgroundDownloadsConfig(u32 option);
//Downloads Methods
void MODIO_DLL modioInstallMod(void* object, u32 mod_id, char* destination_path, void (*callback)(void* object, ModioResponse response));
void MODIO_DLL modioInstallMod(void* object, u32 mod_id, void (*callback)(void* object, ModioResponse response));
bool MODIO_DLL modioUninstallModfile(u32 modfile_id);
bool MODIO_DLL modioUninstallMod(u32 mod_id);
u32 MODIO_DLL modioGetInstalledModfilesCount();
@@ -509,6 +519,8 @@ extern "C"
void MODIO_DLL modioPauseCurrentDownload();
void MODIO_DLL modioResumeCurrentDownload();
double MODIO_DLL modioGetModfileDownloadPercentage(u32 modfile_id);
void MODIO_DLL modioGetInstalledMods(ModioInstalledMod* installed_mods);
u32 MODIO_DLL modioGetInstalledModsSize();
//Dependencies Methods
void MODIO_DLL modioGetAllModDependencies(void* object, u32 mod_id, void(*callback)(void* object, ModioResponse response, ModioDependency* dependencies_array, u32 dependencies_array_size));
@@ -5,6 +5,7 @@
#include "wrappers/MinizipWrapper.h"
#include "Globals.h"
#include "c/ModioC.h"
#include "c/schemas/ModioInstalledMod.h"
#include "c/methods/callbacks/DownloadsCallbacks.h"
#endif
@@ -0,0 +1,17 @@
#ifndef MODIO_MODIOINSTALLEDMOD_H
#define MODIO_MODIOINSTALLEDMOD_H
#include "dependencies/json/json.hpp"
#include "Utility.h"
#include "c/ModioC.h"
#include "c/schemas/ModioMod.h"
using json = nlohmann::json;
extern "C"
{
void modioInitInstalledMod(ModioInstalledMod* installed_mod, json image_json);
void modioFreeInstalledMod(ModioInstalledMod* installed_mod);
}
#endif
View
@@ -75,7 +75,7 @@ namespace modio
ifs.close();
for (auto& it : installed_mods_json["mods"])
{
if(it["id"] == mod_json["id"] && it["path"] == path)
if(it["mod_id"] == mod_json["id"] && it["path"] == path)
{
return;
}
@@ -143,6 +143,23 @@ namespace modio
}
}
void checkForInstalledModsUpdates()
{
ModioFilterCreator filter;
modioInitFilter(&filter);
u32 installed_mods_size = modioGetInstalledModsSize();
ModioInstalledMod* modio_installed_mods = new ModioInstalledMod[installed_mods_size];
modioGetInstalledMods(modio_installed_mods);
for (u32 i = 0; i<(u32)installed_mods_size; i++)
{
modioAddFilterInField(&filter, "id", (char*)modio::toString(modio_installed_mods[i].mod_id).c_str());
}
modioGetMods(NULL, filter, &onGetInstalledMods);
delete[] modio_installed_mods;
}
std::string getInstalledModPath(u32 mod_id)
{
std::ifstream installed_mod_file(modio::getModIODirectory() + "installed_mods.json");
Oops, something went wrong.

0 comments on commit 2f10465

Please sign in to comment.