#pragma once

#include <windows.h>

#define HELPER_VER 3
#define HELPER_API __stdcall
#define HELPER_DLL "enbhelper.dll"


struct HelperFuncs
{
	DWORD version;
	// version = 1
	bool (HELPER_API *getTime)(float &time);
	bool (HELPER_API *getCustomShaderConstants1)(float *vectors); //each vector is 4 floats, 8 vectors total, so 32 floats
	// version = 2
	bool (HELPER_API *getWeatherTransition)(float& t);
	bool (HELPER_API *getCurrentWeatherId)(DWORD& id);
	bool (HELPER_API *getUpcomingWeatherId)(DWORD& id);
	// version = 3
	bool (HELPER_API *getFrameTimeMilliseconds)(DWORD& ms);
};

#ifdef HELPER_COMPILATION

bool HELPER_API helperInit(HelperFuncs& funcs);
bool HELPER_API helperUninit();

#else

extern bool (HELPER_API *helperInit)(HelperFuncs& funcs);
extern bool (HELPER_API *helperUninit)();
extern HelperFuncs	g_HelperFuncs;
extern HMODULE g_HelperModule;

__forceinline bool helperLoad(char *fullpath, char *filename)
{
	g_HelperModule = LoadLibraryA(fullpath);
	if (GetModuleHandleA(filename) != g_HelperModule) return false;
	helperInit = (bool (HELPER_API *)(HelperFuncs&))GetProcAddress(g_HelperModule, "helperInit");
	helperUninit = (bool (HELPER_API *)())GetProcAddress(g_HelperModule, "helperUninit");
	return (helperInit && helperUninit);
}

__forceinline void helperUnload()
{
	if (g_HelperModule) FreeLibrary(g_HelperModule);
}

#endif