|
@@ -12,6 +12,9 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
GooglePlayGamesManager._internal();
|
|
GooglePlayGamesManager._internal();
|
|
|
|
|
|
|
|
|
|
+ // Feature flag to enable/disable Google Play Games Services
|
|
|
|
|
+ static const bool _isEnabled = false; // Set to true to enable Google Play Games
|
|
|
|
|
+
|
|
|
bool _isInitialized = false;
|
|
bool _isInitialized = false;
|
|
|
bool _isSignedIn = false;
|
|
bool _isSignedIn = false;
|
|
|
String? _playerId;
|
|
String? _playerId;
|
|
@@ -34,6 +37,11 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
/// Initialize Google Play Games Services
|
|
/// Initialize Google Play Games Services
|
|
|
Future<bool> initialize() async {
|
|
Future<bool> initialize() async {
|
|
|
|
|
+ if (!_isEnabled) {
|
|
|
|
|
+ print('Google Play Games Services is disabled via feature flag');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (_isInitialized) return true;
|
|
if (_isInitialized) return true;
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -53,6 +61,11 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
/// Sign in to Google Play Games
|
|
/// Sign in to Google Play Games
|
|
|
Future<bool> signIn() async {
|
|
Future<bool> signIn() async {
|
|
|
|
|
+ if (!_isEnabled) {
|
|
|
|
|
+ print('Google Play Games Services is disabled via feature flag');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!_isInitialized) {
|
|
if (!_isInitialized) {
|
|
|
await initialize();
|
|
await initialize();
|
|
|
}
|
|
}
|
|
@@ -100,6 +113,9 @@ class GooglePlayGamesManager {
|
|
|
/// Check if signed in
|
|
/// Check if signed in
|
|
|
bool get isSignedIn => _isSignedIn;
|
|
bool get isSignedIn => _isSignedIn;
|
|
|
|
|
|
|
|
|
|
+ /// Check if Google Play Games is enabled via feature flag
|
|
|
|
|
+ bool get isEnabled => _isEnabled;
|
|
|
|
|
+
|
|
|
/// Get player ID
|
|
/// Get player ID
|
|
|
String? get playerId => _playerId;
|
|
String? get playerId => _playerId;
|
|
|
|
|
|
|
@@ -108,6 +124,11 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
/// Submit score to leaderboard
|
|
/// Submit score to leaderboard
|
|
|
Future<bool> submitScore(String leaderboardId, int score) async {
|
|
Future<bool> submitScore(String leaderboardId, int score) async {
|
|
|
|
|
+ if (!_isEnabled) {
|
|
|
|
|
+ print('Google Play Games Services is disabled via feature flag');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!_isSignedIn) {
|
|
if (!_isSignedIn) {
|
|
|
print('Not signed in to Google Play Games');
|
|
print('Not signed in to Google Play Games');
|
|
|
return false;
|
|
return false;
|
|
@@ -130,6 +151,11 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
/// Show leaderboards
|
|
/// Show leaderboards
|
|
|
Future<void> showLeaderboards() async {
|
|
Future<void> showLeaderboards() async {
|
|
|
|
|
+ if (!_isEnabled) {
|
|
|
|
|
+ print('Google Play Games Services is disabled via feature flag');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!_isSignedIn) {
|
|
if (!_isSignedIn) {
|
|
|
print('Not signed in to Google Play Games');
|
|
print('Not signed in to Google Play Games');
|
|
|
return;
|
|
return;
|
|
@@ -144,6 +170,11 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
/// Show specific leaderboard
|
|
/// Show specific leaderboard
|
|
|
Future<void> showLeaderboard(String leaderboardId) async {
|
|
Future<void> showLeaderboard(String leaderboardId) async {
|
|
|
|
|
+ if (!_isEnabled) {
|
|
|
|
|
+ print('Google Play Games Services is disabled via feature flag');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!_isSignedIn) {
|
|
if (!_isSignedIn) {
|
|
|
print('Not signed in to Google Play Games');
|
|
print('Not signed in to Google Play Games');
|
|
|
return;
|
|
return;
|
|
@@ -160,6 +191,11 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
/// Unlock achievement
|
|
/// Unlock achievement
|
|
|
Future<bool> unlockAchievement(String achievementId) async {
|
|
Future<bool> unlockAchievement(String achievementId) async {
|
|
|
|
|
+ if (!_isEnabled) {
|
|
|
|
|
+ print('Google Play Games Services is disabled via feature flag');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!_isSignedIn) {
|
|
if (!_isSignedIn) {
|
|
|
print('Not signed in to Google Play Games');
|
|
print('Not signed in to Google Play Games');
|
|
|
return false;
|
|
return false;
|
|
@@ -181,6 +217,11 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
/// Increment achievement (for incremental achievements)
|
|
/// Increment achievement (for incremental achievements)
|
|
|
Future<bool> incrementAchievement(String achievementId, int steps) async {
|
|
Future<bool> incrementAchievement(String achievementId, int steps) async {
|
|
|
|
|
+ if (!_isEnabled) {
|
|
|
|
|
+ print('Google Play Games Services is disabled via feature flag');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!_isSignedIn) {
|
|
if (!_isSignedIn) {
|
|
|
print('Not signed in to Google Play Games');
|
|
print('Not signed in to Google Play Games');
|
|
|
return false;
|
|
return false;
|
|
@@ -203,6 +244,11 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
/// Show achievements
|
|
/// Show achievements
|
|
|
Future<void> showAchievements() async {
|
|
Future<void> showAchievements() async {
|
|
|
|
|
+ if (!_isEnabled) {
|
|
|
|
|
+ print('Google Play Games Services is disabled via feature flag');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!_isSignedIn) {
|
|
if (!_isSignedIn) {
|
|
|
print('Not signed in to Google Play Games');
|
|
print('Not signed in to Google Play Games');
|
|
|
return;
|
|
return;
|
|
@@ -217,6 +263,8 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
/// Check achievement-related milestones for bubble popping
|
|
/// Check achievement-related milestones for bubble popping
|
|
|
Future<void> checkBubbleAchievements(int totalBubbles) async {
|
|
Future<void> checkBubbleAchievements(int totalBubbles) async {
|
|
|
|
|
+ if (!_isEnabled) return;
|
|
|
|
|
+
|
|
|
if (!_isSignedIn) return;
|
|
if (!_isSignedIn) return;
|
|
|
|
|
|
|
|
// First bubble achievement
|
|
// First bubble achievement
|
|
@@ -242,6 +290,8 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
/// Check zen mode achievements
|
|
/// Check zen mode achievements
|
|
|
Future<void> checkZenModeAchievements(double sessionTime) async {
|
|
Future<void> checkZenModeAchievements(double sessionTime) async {
|
|
|
|
|
+ if (!_isEnabled) return;
|
|
|
|
|
+
|
|
|
if (!_isSignedIn) return;
|
|
if (!_isSignedIn) return;
|
|
|
|
|
|
|
|
// Zen master achievement (10 minutes in zen mode)
|
|
// Zen master achievement (10 minutes in zen mode)
|
|
@@ -252,6 +302,8 @@ class GooglePlayGamesManager {
|
|
|
|
|
|
|
|
/// Check score-based achievements
|
|
/// Check score-based achievements
|
|
|
Future<void> checkScoreAchievements(int score, double timeToReachScore) async {
|
|
Future<void> checkScoreAchievements(int score, double timeToReachScore) async {
|
|
|
|
|
+ if (!_isEnabled) return;
|
|
|
|
|
+
|
|
|
if (!_isSignedIn) return;
|
|
if (!_isSignedIn) return;
|
|
|
|
|
|
|
|
// Speed demon achievement (reach 1000 points in under 2 minutes)
|
|
// Speed demon achievement (reach 1000 points in under 2 minutes)
|
|
@@ -267,6 +319,8 @@ class GooglePlayGamesManager {
|
|
|
required int totalBubblesPopped,
|
|
required int totalBubblesPopped,
|
|
|
required double sessionLength,
|
|
required double sessionLength,
|
|
|
}) async {
|
|
}) async {
|
|
|
|
|
+ if (!_isEnabled) return;
|
|
|
|
|
+
|
|
|
if (!_isSignedIn) return;
|
|
if (!_isSignedIn) return;
|
|
|
|
|
|
|
|
// Submit to appropriate leaderboards
|
|
// Submit to appropriate leaderboards
|