C++ Buy Now Button
From J2Play
On the gameplay splash screen, when the game has expired, or wherever you would like the option to unlock the full game to be made available, you will want to display a 'Buy Now' button that calls the j2play API:
Playground::SwitchToStoreTab();
This will pause the current game, taking the user directly to the Store to allow them to purchase/unlock the full game.
After the user switches back to your game, the App will call your msgResume() function. This function, if the Trial key is still in use should call the j2play api CGDKInstance::GetInstance()->getDRMKey(); function to query to see if a key exists and try to apply it using the ArmAccess api InstallKey() function as follows:
typedef bool (__stdcall *InstallKeyFn)(const char *name, const char *code);
void CAppGameFrameWnd::msgResume()
{
int success=false;
std::string codeString = CGDKInstance::GetInstance()->getUserDRMKey();
if(codeString==null)
return;
HINSTANCE libInst=LoadLibrary("ArmAccess.DLL");
if (!libInst) return 0; /* Couldn't load library */
InstallKeyFn InstallKey=(InstallKeyFn)GetProcAddress(libInst, "InstallKey");
if (InstallKey==0) returnvalue=0; /* Couldn't find function */
else success=InstallKey("Permanent", codestring);
}
Armadillo Example
typedef bool (__stdcall *InstallKeyFn)(const char *name, const char *code);
int InstallArmadilloCode(const char *name, const char *codestring) {
int returnvalue=0;
HINSTANCE libInst=LoadLibrary("ArmAccess.DLL");
if (!libInst) return 0; /* Couldn't load library */
/* Substitute the typedefs above for functions other than InstallKey */
InstallKeyFn InstallKey=(InstallKeyFn)GetProcAddress(libInst, "InstallKey");
if (InstallKey==0) returnvalue=0; /* Couldn't find function */
else returnvalue=InstallKey(name, codestring);
FreeLibrary(libInst); /* Not needed for the virtual ArmAccess.DLL, but it won't hurt anything. */
return returnvalue;
};
After calling the “Playground::SwitchToStoreTab()” function the game will switch to the buy page for that game.
