Skip to content

Commit 8addfd2

Browse files
committed
New android plugin for godot 3.2.2+
1 parent 7da599f commit 8addfd2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1819
-1097
lines changed

.gitignore

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
### Android ###
2+
# Built application files
3+
*.apk
4+
*.aar
5+
*.ap_
6+
*.aab
7+
8+
# Files for the ART/Dalvik VM
9+
*.dex
10+
11+
# Java class files
12+
*.class
13+
14+
# Generated files
15+
bin/
16+
gen/
17+
out/
18+
# Uncomment the following line in case you need and you don't have the release build type files in your app
19+
# release/
20+
21+
# Gradle files
22+
.gradle/
23+
build/
24+
25+
# Local configuration file (sdk path, etc)
26+
local.properties
27+
28+
# Proguard folder generated by Eclipse
29+
proguard/
30+
31+
# Log Files
32+
*.log
33+
34+
# Android Studio Navigation editor temp files
35+
.navigation/
36+
37+
# Android Studio captures folder
38+
captures/
39+
40+
# IntelliJ
41+
*.iml
42+
.idea/workspace.xml
43+
.idea/tasks.xml
44+
.idea/gradle.xml
45+
.idea/assetWizardSettings.xml
46+
.idea/dictionaries
47+
.idea/libraries
48+
# Android Studio 3 in .gitignore file.
49+
.idea/caches
50+
.idea/modules.xml
51+
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
52+
.idea/navEditor.xml
53+
54+
# Keystore files
55+
# Uncomment the following lines if you do not want to check your keystore files in.
56+
#*.jks
57+
#*.keystore

README.md

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Google Play Games Services Plugin for Godot
2-
This is an Android Play Games Services plugin for Godot Game Engine 3.2 and higher.
2+
This is an Android Play Games Services plugin for Godot Game Engine 3.2.2+.
33

44
[![Android](https://img.shields.io/badge/Platform-Android-brightgreen.svg)](https://developer.android.com)
5-
[![Godot](https://img.shields.io/badge/Godot%20Engine-3.2-blue.svg)](https://github.com/godotengine/godot/)
5+
[![Godot](https://img.shields.io/badge/Godot%20Engine-3.2.2-blue.svg)](https://github.com/godotengine/godot/)
66
[![PGS](https://img.shields.io/badge/Play%20Games%20Services-19.0.0-green.svg)](https://developers.google.com/games/services/android/quickstart)
77
[![MIT license](https://img.shields.io/badge/License-MIT-yellowgreen.svg)](https://lbesson.mit-license.org/)
8-
[![Donate](https://img.shields.io/badge/Donate-PayPal-informational.svg)](https://paypal.me/cgisca)
8+
9+
10+
If you want to use the old plugin version visit [Old README file](https://github.com/cgisca/PGSGP/README_OLD.md).
911

1012

1113
### Supported features:
@@ -17,43 +19,51 @@ This is an Android Play Games Services plugin for Godot Game Engine 3.2 and high
1719
- Saved Games
1820

1921
## Getting started
22+
Before using this plugin please follow instructions on [Setting Up Google Play Games Services](https://developers.google.com/games/services/console/enabling) official guide.
2023
### Set up
21-
- Set up the custom build environment for your project and enable it. See [Godot Engine docs](https://docs.godotengine.org/en/latest/getting_started/workflow/export/android_custom_build.html).
22-
- Download and move `android-pgs-plugin` from the current repository into `res://android/` of your godot project.
23-
- After downloading `android-pgs-plugin`, open it and go to `res` -> `values`. Search for `ids.xml` and open it. Replace `PUT_YOUR_APP_ID_HERE` with your Games Services Application ID for the `app_id` resource. (Don't forget to save file)
24-
- In Godot Engine, go to `Project` -> `Project Settings`. Then on the tab `General` go to the `Android` section, and fill the `Modules` part with `org/godotengine/godot/PlayGameServices`. See [Godot Engine docs](
25-
https://docs.godotengine.org/en/latest/tutorials/plugins/android/android_plugin.html#using-it-from-gdscript).
26-
<br/>*Note: If you have already added one plugin to the `Modules` append the current one by separating them with comma (ex: `xx/xx/Module1,org/godotengine/godot/PlayGameServices`)
27-
<br/>*Note 2: If you have already added other plugin that has `meta-data android:name="com.google.android.gms.version"` declared inside it's `AndroidManifest`, remove **below lines** from the `android-pgs-plugin`-> `AndroidManifest.conf` file. (Don't forget to save file after removing below lines)
28-
29-
```xml
30-
<meta-data android:name="com.google.android.gms.version"
31-
android:value="@integer/google_play_services_version" />
24+
- Download `GodotPlayGamesServices.release.aar` and `GodotPlayGamesServices.gdap` from releases section.
25+
- Move the plugin configuration file (`GodotPlayGamesServices.gdap`) and the binary (`GodotPlayGamesServices.release.aar`) downloaded from the previous step to the Godot project's res://android/plugins directory.
26+
- Enable plugin by accessing `Project` -> `Export`, Plugins section. Follow the [image](https://docs.godotengine.org/en/stable/_images/android_export_preset_plugins_section.png).
27+
- Go to res://android/build directory. Add below lines to `AndroidManifest.xml`:
28+
```xml
29+
<meta-data android:name="com.google.android.gms.games.APP_ID"
30+
android:value="@string/app_id" />
31+
32+
<meta-data android:name="com.google.android.gms.version"
33+
android:value="@integer/google_play_services_version"/>
3234
```
35+
- In the same res://android/build directory,(if it is not already created) create `res` -> `values` -> `Strings.xml`. Add below lines to `Strings.xml`:
36+
```xml
37+
<?xml version="1.0" encoding="utf-8"?>
38+
<resources>
39+
<string name="app_id">ADD_YOUR_APP_ID</string>
40+
</resources>
41+
```
42+
Replace ADD_YOUR_APP_ID with the app id that was generated after following instructions on [Setting Up Google Play Games Services](https://developers.google.com/games/services/console/enabling)
3343

34-
### Latest version
35-
Latest version could be found [here (1.2.0)](https://github.com/cgisca/PGSGP/releases/tag/1.2.0).
44+
Check demo project. In order demo project to work, replace <string name="app_id">ADD_YOUR_APP_ID</string> with your own app id, and in Main.gd add your ids for achievements and leaderboards.
3645

3746
### How to use
3847
First step is plugin initialization
3948
```gdscript
4049
var play_games_services
4150
# Check if plugin was added to the project
42-
if Engine.has_singleton("PlayGameServices"):
43-
play_games_services = Engine.get_singleton("PlayGameServices")
51+
if Engine.has_singleton("GodotPlayGamesServices"):
52+
play_games_services = Engine.get_singleton("GodotPlayGamesServices")
4453
45-
# Initialize plugin by calling init method and passing to it get_instance_id() and a boolean to enable/disable displaying game pop-ups
54+
# Initialize plugin by calling init method and passing to it a boolean to enable/disable displaying game pop-ups
4655
47-
var show_popups := true # For example, your game can display a “Welcome back” or an “Achievements unlocked” pop-up. true for enabling it.
4856
var enable_save_games := true # If you want to enable Saved Games functionality. true for enabling it. If enabled, it will require additional Google Drive API permission from the user.
49-
play_games_services.init(get_instance_id(), show_popups, enable_save_games)
57+
play_games_services.init(show_popups)
58+
# For enabling saved games functionality use below initialization instead
59+
# play_games_services.initWithSavedGames(show_popups, "SavedGamesName")
5060
```
5161
After what plugin was initialized you can use supported features
5262
#### Sign-in / Sign out
5363
##### Sign-in
5464

5565
```gdscript
56-
play_games_services.sign_in()
66+
play_games_services.signIn()
5767
5868
# Callbacks:
5969
func _on_sign_in_success(account_id: String) -> void:
@@ -65,7 +75,7 @@ func _on_sign_in_failed(error_code: int) -> void:
6575
```
6676
##### Sign out
6777
```gdscript
68-
play_games_services.sign_out()
78+
play_games_services.signOut()
6979
7080
# Callbacks:
7181
func _on_sign_out_success():
@@ -77,7 +87,7 @@ func _on_sign_out_failed():
7787
#### Achievements
7888
##### Unlock Achievement
7989
```gdscript
80-
play_games_services.unlock_achievement("ACHIEVEMENT_ID")
90+
play_games_services.unlockAchievement("ACHIEVEMENT_ID")
8191
8292
# Callbacks:
8393
func _on_achievement_unlocked(achievement: String):
@@ -89,7 +99,7 @@ func _on_achievement_unlocking_failed(achievement: String):
8999
##### Increment Achievement
90100
```gdscript
91101
var step = 1
92-
play_games_services.increment_achievement("ACHIEVEMENT_ID", step)
102+
play_games_services.incrementAchievement("ACHIEVEMENT_ID", step)
93103
94104
# Callbacks:
95105
func _on_achievement_incremented(achievement: String):
@@ -100,7 +110,7 @@ func _on_achievement_incrementing_failed(achievement: String):
100110
```
101111
##### Reveal Achievement
102112
```gdscript
103-
play_games_services.reveal_achievement("ACHIEVEMENT_ID")
113+
play_games_services.revealAchievement("ACHIEVEMENT_ID")
104114
105115
# Callbacks:
106116
func _on_achievement_revealed(achievement: String):
@@ -111,13 +121,13 @@ func _on_achievement_revealing_failed(achievement: String):
111121
```
112122
##### Show Achievements List
113123
```gdscript
114-
play_games_services.show_achievements()
124+
play_games_services.showAchievements()
115125
```
116126
#### Leaderboards
117127
##### Submit leaderboard score
118128
```gdscript
119129
var score = 1234
120-
play_games_services.submit_leaderboard_score("LEADERBOARD_ID", score)
130+
play_games_services.submitLeaderBoardScore("LEADERBOARD_ID", score)
121131
122132
# Callbacks:
123133
func _on_leaderboard_score_submitted(leaderboard_id: String):
@@ -128,24 +138,17 @@ func _on_leaderboard_score_submitting_failed(leaderboard_id: String):
128138
```
129139
##### Show leaderboard
130140
```gdscript
131-
play_games_services.show_leaderboard("LEADERBOARD_ID")
141+
play_games_services.showLeaderBoard("LEADERBOARD_ID")
132142
133143
134-
play_games_services.show_all_leaderboards()
144+
play_games_services.showAllLeaderBoards()
135145
```
136-
#### Player connection
137-
```gdscript
138-
play_games_services.is_player_connected()
139146

140-
#Callback:
141-
func _on_player_is_already_connected(is_connected: bool):
142-
pass
143-
```
144147
#### Events
145148
##### Submit event
146149
```gdscript
147150
var increment_by := 2
148-
play_games_services.submit_event("EVENT_ID", increment_by)
151+
play_games_services.submitEvent("EVENT_ID", increment_by)
149152
150153
# Callbacks:
151154
func _on_event_submitted(event_id: String):
@@ -157,9 +160,9 @@ func _on_event_submitted_failed(event_id: String):
157160
##### Load events
158161
```gdscript
159162
# Load all events
160-
play_games_services.load_events()
163+
play_games_services.loadEvents()
161164
# Or load events by given ids
162-
play_games_services.load_events_by_id(["EVENT_ID_1", "EVENT_ID_2", ...])
165+
play_games_services.loadEventsById(["EVENT_ID_1", "EVENT_ID_2", ...])
163166
164167
# Callbacks:
165168
# If there is at least one event, following callback will be triggered:
@@ -186,7 +189,7 @@ func _on_events_loading_failed():
186189
#### Player Stats
187190
```gdscript
188191
var force_refresh := true # If true, this call will clear any locally cached data and attempt to fetch the latest data from the server.
189-
play_games_services.load_player_stats(force_refresh)
192+
play_games_services.loadPlayerStats(force_refresh)
190193
191194
# Callbacks:
192195
func _on_player_stats_loaded(stats):
@@ -211,7 +214,7 @@ var data_to_save: Dictionary = {
211214
"height": 1.82,
212215
"is_gamer": true
213216
}
214-
play_games_services.save_snapshot("SNAPSHOT_NAME", to_json(data_to_save), "DESCRIPTION")
217+
play_games_services.saveSnapshot("SNAPSHOT_NAME", to_json(data_to_save), "DESCRIPTION")
215218
216219
# Callbacks:
217220
func _on_game_saved_success():
@@ -222,7 +225,7 @@ func _on_game_saved_fail():
222225
```
223226
##### Load game snapshot
224227
```gdscript
225-
play_games_services.load_snapshot("SNAPSHOT_NAME")
228+
play_games_services.loadSnapshot("SNAPSHOT_NAME")
226229
227230
# Callbacks:
228231
func _on_game_load_success(data):
@@ -240,7 +243,7 @@ func _on_game_load_fail():
240243
var allow_add_button := true
241244
var allow_delete_button := true
242245
var max_saved_games_snapshots := 5
243-
play_games_services.show_saved_games("SNAPSHOT_NAME", allow_add_button, allow_delete_button, max_saved_games_snapshots)
246+
play_games_services.showSavedGames("SNAPSHOT_NAME", allow_add_button, allow_delete_button, max_saved_games_snapshots)
244247
245248
#Godot callback
246249
# If user clicked on add new snapshot button on the screen with all saved snapshots, below callback will be triggered:

0 commit comments

Comments
 (0)