Cloud save: more stubs, using Biniax as a sample app

This commit is contained in:
Sergii Pylypenko
2014-07-08 23:44:09 +03:00
parent 8ebcfe4760
commit ed57fac3c9
9 changed files with 145 additions and 7 deletions

View File

@@ -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

View File

@@ -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" );

View File

@@ -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
{

View File

@@ -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 ] = {

View File

@@ -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;

View File

@@ -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();