Cloud save: more stubs, using Biniax as a sample app
This commit is contained in:
@@ -29,7 +29,8 @@ public class CloudSave implements GameHelper.GameHelperListener {
|
||||
|
||||
MainActivity parent;
|
||||
|
||||
/** Constructs a BaseGameActivity with default client (GamesClient). */
|
||||
// ===== Public API =====
|
||||
|
||||
public CloudSave(MainActivity p)
|
||||
{
|
||||
Log.i("SDL", "CloudSave: initializing");
|
||||
@@ -51,6 +52,32 @@ public class CloudSave implements GameHelper.GameHelperListener {
|
||||
mHelper.onStop();
|
||||
}
|
||||
|
||||
public boolean save(String filename, String description, String imageFile)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean load (String filename)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public class loadDialogResult
|
||||
{
|
||||
public boolean status = false;
|
||||
public String filename = "";
|
||||
}
|
||||
|
||||
public loadDialogResult loadDialog(String filename, String dialogTitle)
|
||||
{
|
||||
loadDialogResult res = new loadDialogResult();
|
||||
res.status = false;
|
||||
res.filename = "";
|
||||
return res;
|
||||
}
|
||||
|
||||
// ===== Private API =====
|
||||
|
||||
public void onActivityResult(int request, int response, Intent data) {
|
||||
mHelper.onActivityResult(request, response, data);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ CompatibilityHacksForceScreenUpdate=n
|
||||
|
||||
# Application does not call SDL_Flip() or SDL_UpdateRects() after mouse click (ScummVM and all Amiga emulators do that) -
|
||||
# force screen update by moving mouse cursor a little after each click (y) or (n)
|
||||
CompatibilityHacksForceScreenUpdateMouseClick=y
|
||||
CompatibilityHacksForceScreenUpdateMouseClick=n
|
||||
|
||||
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
|
||||
CompatibilityHacksStaticInit=n
|
||||
@@ -259,3 +259,4 @@ AdmobBannerSize=
|
||||
|
||||
# Google Play Game Services application ID, required for cloud saves to work
|
||||
GooglePlayGameServicesId=520035027247
|
||||
|
||||
|
||||
@@ -702,6 +702,20 @@ BNX_INT16 gameSession( BNX_GAME *game )
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( inpKeySave() )
|
||||
{
|
||||
if ( game->mode != cModeMultiplayer && game->ingame == BNX_TRUE )
|
||||
{
|
||||
saveGame( &Game );
|
||||
}
|
||||
}
|
||||
else if ( inpKeyLoad() )
|
||||
{
|
||||
if ( game->mode != cModeMultiplayer && game->ingame == BNX_TRUE )
|
||||
{
|
||||
loadGame( &Game );
|
||||
}
|
||||
}
|
||||
|
||||
if ( game->ingame == BNX_TRUE )
|
||||
{
|
||||
@@ -1237,6 +1251,7 @@ BNX_BOOL saveGame( BNX_GAME *game )
|
||||
sysFPut16( game->level_count, file );
|
||||
|
||||
fclose( file );
|
||||
SDL_ANDROID_CloudSave( sysGetFullFileName( csSaveGameName ) );
|
||||
|
||||
return BNX_TRUE;
|
||||
}
|
||||
@@ -1247,6 +1262,8 @@ BNX_BOOL loadGame( BNX_GAME *game )
|
||||
BNX_INT32 i;
|
||||
BNX_INT32 j;
|
||||
|
||||
SDL_ANDROID_CloudLoad( sysGetFullFileName( csSaveGameName ) );
|
||||
|
||||
if ( sysGetFileLen( sysGetFullFileName( csSaveGameName ) ) != cSaveFileSize )
|
||||
return BNX_FALSE;
|
||||
file = fopen( sysGetFullFileName( csSaveGameName ), "rb" );
|
||||
|
||||
@@ -291,6 +291,11 @@ void gfxRenderGame( BNX_GAME *game )
|
||||
/* RENDER CLEARS LEFT */
|
||||
sprintf( text, " %02d", game->clears );
|
||||
gfxPrintText( cGfxClearsTX, cGfxClearsTY, text );
|
||||
|
||||
sprintf( text, "SAVE" );
|
||||
gfxPrintText( _BNX_BOXES[ cGfxIndSave ].x1, _BNX_BOXES[ cGfxIndSave ].y1, text );
|
||||
sprintf( text, "LOAD" );
|
||||
gfxPrintText( _BNX_BOXES[ cGfxIndLoad ].x1, _BNX_BOXES[ cGfxIndLoad ].y1, text );
|
||||
}
|
||||
else if ( game->mode == cModeRealtime )
|
||||
{
|
||||
@@ -308,6 +313,11 @@ void gfxRenderGame( BNX_GAME *game )
|
||||
/* RENDER CLEARS LEFT */
|
||||
sprintf( text, " %02d", game->clears );
|
||||
gfxPrintText( cGfxClearsAX, cGfxClearsAY, text );
|
||||
|
||||
sprintf( text, "SAVE" );
|
||||
gfxPrintText( _BNX_BOXES[ cGfxIndSave ].x1, _BNX_BOXES[ cGfxIndSave ].y1, text );
|
||||
sprintf( text, "LOAD" );
|
||||
gfxPrintText( _BNX_BOXES[ cGfxIndLoad ].x1, _BNX_BOXES[ cGfxIndLoad ].y1, text );
|
||||
}
|
||||
|
||||
/* PARTICLES */
|
||||
@@ -362,9 +372,9 @@ void gfxRenderGame( BNX_GAME *game )
|
||||
break;
|
||||
}
|
||||
}
|
||||
gfxPrintText( _BNX_BOXES[ cGfxIndEscape ].x1, _BNX_BOXES[ cGfxIndEscape ].y1, "EXIT" );
|
||||
}
|
||||
|
||||
|
||||
prevIngame = game->ingame;
|
||||
prevClears = game->clears;
|
||||
}
|
||||
@@ -499,6 +509,8 @@ void gfxRenderHelp( BNX_INT16 *line )
|
||||
y += cGfxHelpDY;
|
||||
}
|
||||
*line = l;
|
||||
|
||||
gfxPrintText( _BNX_BOXES[ cGfxIndEscape ].x1, _BNX_BOXES[ cGfxIndEscape ].y1, "EXIT" );
|
||||
}
|
||||
|
||||
void gfxRenderHof( BNX_HALL *hof, BNX_INT16 hofview )
|
||||
@@ -568,6 +580,8 @@ void gfxRenderHof( BNX_HALL *hof, BNX_INT16 hofview )
|
||||
}
|
||||
count ++;
|
||||
|
||||
gfxPrintText( _BNX_BOXES[ cGfxIndEscape ].x1, _BNX_BOXES[ cGfxIndEscape ].y1, "EXIT" );
|
||||
|
||||
gfxUpdateParticles();
|
||||
gfxRenderParticles();
|
||||
}
|
||||
@@ -919,6 +933,14 @@ void gfxGetVirtualKey( BNX_GAME *game, BNX_INP *inp )
|
||||
{
|
||||
inp->keyB = BNX_TRUE;
|
||||
}
|
||||
else if ( gfxInBox( inp->mouseX, inp->mouseY, &(_BNX_BOXES[ cGfxIndSave ]) ) == BNX_TRUE )
|
||||
{
|
||||
inp->keySave = BNX_TRUE;
|
||||
}
|
||||
else if ( gfxInBox( inp->mouseX, inp->mouseY, &(_BNX_BOXES[ cGfxIndLoad ]) ) == BNX_TRUE )
|
||||
{
|
||||
inp->keyLoad = BNX_TRUE;
|
||||
}
|
||||
/* Try to detect Ingame Space press */
|
||||
else
|
||||
{
|
||||
|
||||
@@ -67,7 +67,8 @@ GRAPHICS CONSTANTS
|
||||
|
||||
#define cGfxScoreX 30
|
||||
#define cGfxScoreY 54
|
||||
#define cGfxBestX 330
|
||||
#define cGfxBestX 230
|
||||
#define cGfxBestY 54
|
||||
#define cGfxBestY 54
|
||||
#define cGfxScore1X 30
|
||||
#define cGfxScore1Y 28
|
||||
@@ -154,6 +155,8 @@ enum {
|
||||
cGfxIndEscape,
|
||||
cGfxIndSpaceR,
|
||||
cGfxIndSpaceT,
|
||||
cGfxIndSave,
|
||||
cGfxIndLoad,
|
||||
cGfxIndMax,
|
||||
};
|
||||
typedef struct BNX_BOX
|
||||
@@ -165,10 +168,12 @@ typedef struct BNX_BOX
|
||||
} BNX_BOX;
|
||||
|
||||
static BNX_BOX _BNX_BOXES[ cGfxIndMax ] = {
|
||||
{ 18, 128, 656, 588 },
|
||||
{ 715, 0, 800, 40 },
|
||||
{ 18, 128, 656, 588 },
|
||||
{ 730, 0, 800, 60 },
|
||||
{ 680, 310, 780, 380 },
|
||||
{ 680, 515, 780, 580 }
|
||||
{ 680, 515, 780, 580 },
|
||||
{ 430, cGfxScoreY, 530, cGfxScoreY + 50 },
|
||||
{ 530, cGfxScoreY, 630, cGfxScoreY + 50 },
|
||||
};
|
||||
|
||||
static BNX_BOX _BNX_MENU_BOXES[ cMaxOptions ] = {
|
||||
|
||||
@@ -53,6 +53,8 @@ BNX_BOOL inpInit()
|
||||
_Inp.keyB = BNX_FALSE;
|
||||
_Inp.keyQuit = BNX_FALSE;
|
||||
_Inp.keyDel = BNX_FALSE;
|
||||
_Inp.keySave = BNX_FALSE;
|
||||
_Inp.keyLoad = BNX_FALSE;
|
||||
|
||||
_Inp.mousePress = BNX_FALSE;
|
||||
_Inp.mouseX = 0;
|
||||
@@ -310,6 +312,28 @@ BNX_BOOL inpKeyDel()
|
||||
return BNX_FALSE;
|
||||
}
|
||||
|
||||
BNX_BOOL inpKeySave()
|
||||
{
|
||||
if ( _Inp.keySave == BNX_TRUE )
|
||||
{
|
||||
_Inp.keySave = BNX_FALSE;
|
||||
return BNX_TRUE;
|
||||
}
|
||||
|
||||
return BNX_FALSE;
|
||||
}
|
||||
|
||||
BNX_BOOL inpKeyLoad()
|
||||
{
|
||||
if ( _Inp.keyLoad == BNX_TRUE )
|
||||
{
|
||||
_Inp.keyLoad = BNX_FALSE;
|
||||
return BNX_TRUE;
|
||||
}
|
||||
|
||||
return BNX_FALSE;
|
||||
}
|
||||
|
||||
BNX_BOOL inpExit()
|
||||
{
|
||||
return _Inp.keyQuit;
|
||||
|
||||
@@ -58,6 +58,8 @@ typedef struct BNX_INP
|
||||
BNX_BOOL keyC;
|
||||
BNX_BOOL keyQuit;
|
||||
BNX_BOOL keyDel;
|
||||
BNX_BOOL keySave;
|
||||
BNX_BOOL keyLoad;
|
||||
|
||||
BNX_BOOL mousePress;
|
||||
BNX_INT16 mouseX;
|
||||
@@ -93,6 +95,8 @@ BNX_BOOL inpKeyA();
|
||||
BNX_BOOL inpKeyB();
|
||||
BNX_BOOL inpKeyC();
|
||||
BNX_BOOL inpKeyDel();
|
||||
BNX_BOOL inpKeySave();
|
||||
BNX_BOOL inpKeyLoad();
|
||||
BNX_BOOL inpExit();
|
||||
|
||||
char inpGetChar();
|
||||
|
||||
@@ -93,6 +93,29 @@ extern DECLSPEC int SDLCALL SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec);
|
||||
/* Close audio recording device, SDL_Init(SDL_INIT_AUDIO) has to be done before calling this function. */
|
||||
extern DECLSPEC void SDLCALL SDL_ANDROID_CloseAudioRecording(void);
|
||||
|
||||
/*
|
||||
Save the file to the cloud, filename must be already present on disk.
|
||||
This function will block, until user signs in to the cloud account, and presses Save button.
|
||||
Description and imageFile may be NULL.
|
||||
Returns 1 if save succeeded, 0 if user aborted sign-in, or there was no network available.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_CloudSave(const char * filename, const char * description, const char * imageFile);
|
||||
|
||||
/*
|
||||
Load the specified file from the cloud.
|
||||
This function will block, until user signs in to the cloud account.
|
||||
Returns 1 if load succeeded, 0 if user aborted sign-in, or there was no network available.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_CloudLoad(const char *filename);
|
||||
|
||||
/*
|
||||
Show the file loading dialog, to allow user to pick up a file from the cloud.
|
||||
This function will block, until user signs in to the cloud account, and selects a file.
|
||||
The resulting filename is written to the filename buffer, which must be 512 bytes or more.
|
||||
dialogTitle may be NULL.
|
||||
Returns 1 if load succeeded, 0 if user aborted sign-in, or there was no network available.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ANDROID_CloudLoadDialog(char *filename, int len, const char *dialogTitle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -467,6 +467,21 @@ int SDLCALL SDL_ANDROID_RequestNewAdvertisement(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SDLCALL SDL_ANDROID_CloudSave(const char * filename, const char * description, const char * imageFile)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDLCALL SDL_ANDROID_CloudLoad(const char *filename)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDLCALL SDL_ANDROID_CloudLoadDialog(char *filename, int len, const char *dialogTitle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Dummy callback for SDL2 to satisfy linker
|
||||
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
|
||||
void SDL_Android_Init(JNIEnv* env, jclass cls)
|
||||
|
||||
Reference in New Issue
Block a user