backup push
This commit is contained in:
199
fnal/api/siwg.api
Normal file
199
fnal/api/siwg.api
Normal file
@@ -0,0 +1,199 @@
|
||||
- name: siwg
|
||||
type: table
|
||||
desc: Functions and constants for interacting with Google Services (SIWG) APIs
|
||||
|
||||
members:
|
||||
|
||||
#*****************************************************************************************************
|
||||
|
||||
- name: is_supported
|
||||
type: function
|
||||
desc: Check if Google Services are available & ready on the device.
|
||||
|
||||
returns:
|
||||
- name: is_supported
|
||||
type: boolean
|
||||
desc: Status of Google Services on the device.
|
||||
|
||||
examples:
|
||||
- desc: |-
|
||||
```lua
|
||||
if siwg then
|
||||
local is_supported = siwg.is_supported()
|
||||
end
|
||||
```
|
||||
|
||||
#*****************************************************************************************************
|
||||
|
||||
- name: login
|
||||
type: function
|
||||
desc: Login to SIWG using a button.
|
||||
|
||||
examples:
|
||||
- desc: |-
|
||||
Log in to SIWG using a button:
|
||||
```lua
|
||||
if siwg then
|
||||
siwg.login()
|
||||
end
|
||||
```
|
||||
|
||||
#*****************************************************************************************************
|
||||
|
||||
- name: silent_login
|
||||
type: function
|
||||
desc: Silent login to SIWG.
|
||||
|
||||
This function is trying to retrieve the currently signed-in player’s account.
|
||||
|
||||
[icon:attention] By default login methods request `GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN`.
|
||||
But if you use Disk, we have to request extra scope `Drive.SCOPE_APPFOLDER`.
|
||||
Or if you use ID token, we have to request ID token with provided client_id.
|
||||
If so it causes the first time silent sign-in to fail, except for users who
|
||||
have already signed in successfully on a different device. Turn off SIWG
|
||||
features you don't want to use in `game.project`.
|
||||
|
||||
examples:
|
||||
- desc: |-
|
||||
```lua
|
||||
function init(self)
|
||||
if siwg then
|
||||
siwg.silent_login()
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
#*****************************************************************************************************
|
||||
|
||||
- name: logout
|
||||
type: function
|
||||
desc: Logout from SIWG
|
||||
|
||||
examples:
|
||||
- desc: |-
|
||||
```lua
|
||||
if siwg then
|
||||
siwg.logout()
|
||||
end
|
||||
```
|
||||
|
||||
#*****************************************************************************************************
|
||||
|
||||
- name: get_display_name
|
||||
type: function
|
||||
desc: Get the current SIWG player display name.
|
||||
|
||||
returns:
|
||||
- name: name
|
||||
type: string
|
||||
desc: The player's display name.
|
||||
|
||||
examples:
|
||||
- desc: |-
|
||||
```lua
|
||||
if siwg then
|
||||
local name = siwg.get_display_name()
|
||||
end
|
||||
```
|
||||
|
||||
#*****************************************************************************************************
|
||||
|
||||
- name: get_id
|
||||
type: function
|
||||
desc: Get the current SIWG player id.
|
||||
|
||||
returns:
|
||||
- name: id
|
||||
type: string
|
||||
desc: The player ID.
|
||||
|
||||
examples:
|
||||
- desc: |-
|
||||
```lua
|
||||
if siwg then
|
||||
local id = siwg.get_id()
|
||||
end
|
||||
```
|
||||
|
||||
#*****************************************************************************************************
|
||||
|
||||
- name: get_id_token
|
||||
type: function
|
||||
desc: Get the current SIWG player id token. Available only if "siwg.client_id" is configured in game.project
|
||||
and "siwg.request_id_token = 1".
|
||||
|
||||
returns:
|
||||
- name: id_token
|
||||
type: string
|
||||
desc: The player ID token.
|
||||
|
||||
examples:
|
||||
- desc: |-
|
||||
```lua
|
||||
if siwg then
|
||||
local id_token = siwg.get_id_token()
|
||||
end
|
||||
```
|
||||
|
||||
#*****************************************************************************************************
|
||||
|
||||
- name: get_server_auth_code
|
||||
type: function
|
||||
desc: Returns a one-time server auth code to send to your web server which can be exchanged for access token
|
||||
|
||||
returns:
|
||||
- name: server_auth_code
|
||||
type: string
|
||||
desc: The server auth code for logged in account.
|
||||
|
||||
examples:
|
||||
- desc: |-
|
||||
```lua
|
||||
if siwg then
|
||||
local server_auth_code = siwg.get_server_auth_code()
|
||||
end
|
||||
```
|
||||
|
||||
#*****************************************************************************************************
|
||||
|
||||
- name: is_logged_in
|
||||
type: function
|
||||
desc: Check if a user is logged in currently.
|
||||
|
||||
returns:
|
||||
- name: is_loggedin
|
||||
type: boolean
|
||||
desc: Current login state.
|
||||
|
||||
examples:
|
||||
- desc: |-
|
||||
```lua
|
||||
if siwg then
|
||||
local is_loggedin = siwg.is_logged_in()
|
||||
end
|
||||
```
|
||||
|
||||
#*****************************************************************************************************
|
||||
|
||||
- name: MSG_SIGN_IN
|
||||
type: number
|
||||
desc: The message type that SIWG sends when finishing the asynchronous operation
|
||||
after calling `siwg.login()`
|
||||
|
||||
- name: MSG_SILENT_SIGN_IN
|
||||
type: number
|
||||
desc: The message type that SIWG sends when finishing the asynchronous operation
|
||||
after calling `siwg.silent_login()`
|
||||
|
||||
- name: MSG_SIGN_OUT
|
||||
type: number
|
||||
desc: The message type that SIWG sends when finishing the asynchronous operation
|
||||
after calling `siwg.logout()`
|
||||
|
||||
- name: STATUS_SUCCESS
|
||||
type: number
|
||||
desc: An operation success.
|
||||
|
||||
- name: STATUS_FAILED
|
||||
type: number
|
||||
desc: An operation failed. Check the error field in the massage table.
|
1
fnal/ext.manifest
Normal file
1
fnal/ext.manifest
Normal file
@@ -0,0 +1 @@
|
||||
name: FNAL
|
7
fnal/manifests/android/AndroidManifest.xml
Normal file
7
fnal/manifests/android/AndroidManifest.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="{{android.package}}">
|
||||
<uses-sdk android:minSdkVersion="{{android.minimum_sdk_version}}" android:targetSdkVersion="{{android.target_sdk_version}}" />
|
||||
<application>
|
||||
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\{{siwg.app_id}}" />
|
||||
</application>
|
||||
</manifest>
|
6
fnal/manifests/android/build.gradle
Normal file
6
fnal/manifests/android/build.gradle
Normal file
@@ -0,0 +1,6 @@
|
||||
dependencies {
|
||||
// https://developers.google.com/android/guides/setup#split
|
||||
implementation 'com.google.android.gms:play-services-base:17.5.0'
|
||||
implementation 'com.google.android.gms:play-services-auth:18.1.0'
|
||||
implementation 'com.google.android.gms:play-services-games:20.0.1'
|
||||
}
|
80
fnal/src/fnal.cpp
Normal file
80
fnal/src/fnal.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#define EXTENSION_NAME FNAL
|
||||
#define LIB_NAME "FNAL"
|
||||
#define MODULE_NAME "fnal"
|
||||
|
||||
// include the Defold SDK
|
||||
#include <dmsdk/sdk.h>
|
||||
#include <string.h>
|
||||
#include <easyhttpcpp/EasyHttp.h>
|
||||
|
||||
static int FNAL_Log(lua_State* L)
|
||||
{
|
||||
// The number of expected items to be on the Lua stack
|
||||
// once this struct goes out of scope
|
||||
DM_LUA_STACK_CHECK(L, 1);
|
||||
|
||||
// Check and get parameter string from stack
|
||||
char* str = (char*)luaL_checkstring(L, 1);
|
||||
|
||||
// Reverse the string
|
||||
int len = strlen(str);
|
||||
for(int i = 0; i < len / 2; i++) {
|
||||
const char a = str[i];
|
||||
const char b = str[len - i - 1];
|
||||
str[i] = b;
|
||||
str[len - i - 1] = a;
|
||||
}
|
||||
|
||||
// Put the reverse string on the stack
|
||||
lua_pushstring(L, str);
|
||||
|
||||
// Return 1 item
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Functions exposed to Lua
|
||||
static const luaL_reg FNAL_Methods[] =
|
||||
{
|
||||
{"log", FNAL_Log},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static void LuaInit(lua_State* L)
|
||||
{
|
||||
int top = lua_gettop(L);
|
||||
luaL_register(L, MODULE_NAME, FNAL_Methods);
|
||||
lua_pop(L, 1);
|
||||
assert(top == lua_gettop(L));
|
||||
}
|
||||
|
||||
dmExtension::Result AppInitializeFNAL(dmExtension::AppParams* params)
|
||||
{
|
||||
dmLogInfo("[FNAL] Registered Extension!");
|
||||
return dmExtension::RESULT_OK;
|
||||
}
|
||||
|
||||
dmExtension::Result AppFinalizeFNAL(dmExtension::AppParams* params)
|
||||
{
|
||||
return dmExtension::RESULT_OK;
|
||||
}
|
||||
|
||||
dmExtension::Result InitializeFNAL(dmExtension::Params* params)
|
||||
{
|
||||
dmLogInfo("[FNAL] Initializing Extension...");
|
||||
return dmExtension::RESULT_OK;
|
||||
}
|
||||
|
||||
dmExtension::Result UpdateFNAL(dmExtension::Params* params)
|
||||
{
|
||||
return dmExtension::RESULT_OK;
|
||||
}
|
||||
|
||||
dmExtension::Result FinalizeFNAL(dmExtension::Params* params)
|
||||
{
|
||||
dmLogInfo("[FNAL] Finalizing Extension...");
|
||||
return dmExtension::RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DM_DECLARE_EXTENSION(EXTENSION_NAME, LIB_NAME, AppInitializeFNAL, AppFinalizeFNAL, InitializeFNAL, UpdateFNAL, 0, FinalizeFNAL)
|
Reference in New Issue
Block a user