Skip to content

Commit

Permalink
Added support for FBInstant.postSessionScore() (#72)
Browse files Browse the repository at this point in the history
* Updated to 6.3 and added postSessionScore() support
  • Loading branch information
britzl authored May 27, 2019
1 parent 60f7e2c commit 2fcfdf2
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 26 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,17 @@ Each entry in the ```players``` table has the following values:
* ```photo``` (string) - URL to a photo of the user


### fbinstant.post_session_score(score)
Posts the player's best score for the session to Facebook.

**PARAMETERS**
* ```score``` (number) - An integer value representing the player's best score in a session.


### fbinstant.get_players()
Get the players in the current context.


## Platform functions

### fbinstant.get_platform()
Expand Down
1 change: 1 addition & 0 deletions apitester/overview/overview.gui_script
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function init(self)
fbinstant.on_payments_ready(function()
dirtylarry.button("payments").set_visible(true)
end)
fbinstant.post_session_score(12345)
end

function on_message(self, message_id, message, sender)
Expand Down
34 changes: 34 additions & 0 deletions bundle_resources/web/fbapp-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"instant_games": {
"custom_update_templates": {
"first_place": {
"example": "Player X just became the first place!"
}
},
"surfaceable_stats": {
"rank": {
"priority": 1,
"order": 1,
"label": {
"localizations": {
"en_US": "Rank",
},
"fallback": "Rank"
},
"values": {
"0": "Unranked",
"1": "Bronze",
"2": "Silver",
"3": "Gold"
}
}
},
"orientation": "PORTRAIT",
"override_web_orientation": "PORTRAIT",
"navigation_menu_version": "NAV_FLOATING",
"match_player_config": {
"min_context_size": 2,
"max_context_size": 20
}
}
}
2 changes: 2 additions & 0 deletions fbinstant/include/fbinstant.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ extern "C" {
void FBInstant_PlatformPurchaseAsync(OnPurchaseResponseCallback callback, const char* productId, const char* developerPayload);
void FBInstant_PlatformGetPurchasesAsync(OnPurchasesCallback callback);
void FBInstant_PlatformConsumePurchaseAsync(OnPurchaseConsumedCallback callback, const char* purchaseToken);

void FBInstant_PlatformPostSessionScore(const int score);
}

#endif
2 changes: 1 addition & 1 deletion fbinstant/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</head>

<body oncontextmenu="return false;">
<script src="https://connect.facebook.net/en_US/fbinstant.6.2.js"></script>
<script src="https://connect.facebook.net/en_US/fbinstant.6.3.js"></script>
<div id="fb-root"></div>
<div id="app-container" class="canvas-app-container">
<canvas id="canvas" class="canvas-app-canvas" tabindex="1" width="{{display.width}}" height="{{display.height}}"></canvas>
Expand Down
8 changes: 8 additions & 0 deletions fbinstant/lib/web/library_fbinstant.js
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,14 @@ var FBInstantLibrary = {
});
},


// =====================================
// PostSessionScore
// =====================================
FBInstant_PlatformPostSessionScore: function(score) {
FBInstant.postSessionScore(score);
},

};

autoAddDeps(FBInstantLibrary, "$Context");
Expand Down
16 changes: 16 additions & 0 deletions fbinstant/src/fbinstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,20 @@ static int FBInstant_ConsumePurchaseAsync(lua_State* L) {



// ===============================================
// POST SESSION SCORE
// ===============================================
static int FBInstant_PostSessionScore(lua_State* L) {
int top = lua_gettop(L);

const int sessionScore = luaL_checknumber(L, 1);
FBInstant_PlatformPostSessionScore(sessionScore);

assert(top == lua_gettop(L));
return 0;
}


static const luaL_reg Module_methods[] = {
// lifecycle functions
{"initialize", FBInstant_InitializeAsync},
Expand Down Expand Up @@ -1752,6 +1766,8 @@ static const luaL_reg Module_methods[] = {
{"get_entry_point", FBInstant_GetEntryPointAsync},
{"set_session_data", FBInstant_SetSessionData},

{"post_session_score", FBInstant_PostSessionScore},

// player functions
{"get_player", FBInstant_GetPlayer},
{"get_player_data", FBInstant_GetPlayerDataAsync},
Expand Down
7 changes: 6 additions & 1 deletion fbinstant/utils/mock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fbinstant.LEADERBOARDS = {}
fbinstant.PRODUCTS = {}

local function get_self()
return _G["__dm_script_instance__"]
return _G[3700146495]
end
--------------------------------
--------------- LIFECYCLE
Expand Down Expand Up @@ -737,3 +737,8 @@ function fbinstant.consume_purchase(purchase_token, callback)
end
callback(get_self(), false)
end


function fbinstant.post_session_score(score)
print("post_session_score", score)
end
3 changes: 2 additions & 1 deletion game.project
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[project]
title = XOXO
dependencies = https://github.com/britzl/gooey/archive/6.5.0.zip,https://github.com/britzl/monarch/archive/2.13.0.zip
bundle_resources = /bundle/
bundle_resources = /bundle_resources
bundle_exclude_resources =

[bootstrap]
main_collection = /tictactoe/tictactoe.collectionc
Expand Down
54 changes: 31 additions & 23 deletions tictactoe/tictactoe.appmanifest
Original file line number Diff line number Diff line change
@@ -1,69 +1,77 @@
# App manifest generated Fri Mar 08 2019 13:30:50 GMT+0100 (Central European Standard Time)
# Settings: Physics2D,Physics3D,Record,Profiler,Gameroom,Sound
# App manifest generated Mon May 27 2019 13:56:07 GMT+0200 (Central European Summer Time)
# Settings: Physics2D,Physics3D,Record,Profiler,Facebook,Gameroom,Sound
platforms:
x86_64-osx:
context:
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","sound","tremolo"]
excludeSymbols: ["ProfilerExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","facebookext","sound","tremolo"]
excludeSymbols: ["ProfilerExt","FacebookExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
libs: ["physics_null","record_null","profilerext_null","sound_null"]
linkFlags: []

x86_64-linux:
context:
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","sound","tremolo"]
excludeSymbols: ["ProfilerExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","facebookext","sound","tremolo"]
excludeSymbols: ["ProfilerExt","FacebookExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
libs: ["physics_null","record_null","profilerext_null","sound_null"]
linkFlags: []

js-web:
context:
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","sound","tremolo"]
excludeJsLibs: []
excludeSymbols: ["ProfilerExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","facebookext","sound","tremolo"]
excludeJsLibs: ["facebook"]
excludeSymbols: ["ProfilerExt","FacebookExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
libs: ["physics_null","record_null","profilerext_null","sound_null"]
linkFlags: []

wasm-web:
context:
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","sound","tremolo"]
excludeJsLibs: []
excludeSymbols: ["ProfilerExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","facebookext","sound","tremolo"]
excludeJsLibs: ["facebook"]
excludeSymbols: ["ProfilerExt","FacebookExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
libs: ["physics_null","record_null","profilerext_null","sound_null"]
linkFlags: []

x86-win32:
context:
excludeLibs: ["libphysics","libLinearMath","libBulletDynamics","libBulletCollision","libBox2D","librecord","vpx","libprofilerext","gameroomext","libsound","libtremolo"]
excludeSymbols: ["ProfilerExt","GameroomExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
excludeLibs: ["libphysics","libLinearMath","libBulletDynamics","libBulletCollision","libBox2D","librecord","vpx","libprofilerext","libfacebookext.lib","gameroomext","libsound","libtremolo"]
excludeSymbols: ["ProfilerExt","FacebookExt","GameroomExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
libs: ["libphysics_null.lib","librecord_null.lib","libprofilerext_null.lib","libsound_null.lib"]
linkFlags: []

x86_64-win32:
context:
excludeLibs: ["libphysics","libLinearMath","libBulletDynamics","libBulletCollision","libBox2D","librecord","vpx","libprofilerext","gameroomext","libsound","libtremolo"]
excludeSymbols: ["ProfilerExt","GameroomExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
excludeLibs: ["libphysics","libLinearMath","libBulletDynamics","libBulletCollision","libBox2D","librecord","vpx","libprofilerext","libfacebookext.lib","gameroomext","libsound","libtremolo"]
excludeSymbols: ["ProfilerExt","FacebookExt","GameroomExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
libs: ["libphysics_null.lib","librecord_null.lib","libprofilerext_null.lib","libsound_null.lib"]
linkFlags: []

armv7-android:
context:
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","sound","tremolo"]
excludeJars: []
excludeSymbols: ["ProfilerExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","facebookext","sound","tremolo"]
excludeJars: ["(.*)/facebooksdk.jar","(.*)/facebook_android.jar"]
excludeSymbols: ["ProfilerExt","FacebookExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
libs: ["physics_null","record_null","profilerext_null","sound_null"]
linkFlags: []

arm64-android:
context:
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","facebookext","sound","tremolo"]
excludeJars: ["(.*)/facebooksdk.jar","(.*)/facebook_android.jar"]
excludeSymbols: ["ProfilerExt","FacebookExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
libs: ["physics_null","record_null","profilerext_null","sound_null"]
linkFlags: []

armv7-ios:
context:
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","sound","tremolo"]
excludeSymbols: ["ProfilerExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","facebookext","sound","tremolo"]
excludeSymbols: ["ProfilerExt","FacebookExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
libs: ["physics_null","record_null","profilerext_null","sound_null"]
linkFlags: []

arm64-ios:
context:
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","sound","tremolo"]
excludeSymbols: ["ProfilerExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
excludeLibs: ["physics","LinearMath","BulletDynamics","BulletCollision","Box2D","record","vpx","profilerext","facebookext","sound","tremolo"]
excludeSymbols: ["ProfilerExt","FacebookExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
libs: ["physics_null","record_null","profilerext_null","sound_null"]
linkFlags: []

0 comments on commit 2fcfdf2

Please sign in to comment.