added firebase and rudimentary leaderboard support
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
@tool
|
||||
class_name FirebaseRemoteConfig
|
||||
extends Node
|
||||
|
||||
const RemoteConfigFunctionId = "getRemoteConfig"
|
||||
|
||||
signal remote_config_received(config)
|
||||
signal remote_config_error(error)
|
||||
|
||||
var _project_config = {}
|
||||
var _headers : PackedStringArray = [
|
||||
]
|
||||
var _auth : Dictionary
|
||||
|
||||
func _set_config(config_json : Dictionary) -> void:
|
||||
_project_config = config_json # This may get confusing, hoping the variable name makes it easier to understand
|
||||
|
||||
func _on_FirebaseAuth_login_succeeded(auth_result : Dictionary) -> void:
|
||||
_auth = auth_result
|
||||
|
||||
func _on_FirebaseAuth_token_refresh_succeeded(auth_result : Dictionary) -> void:
|
||||
_auth = auth_result
|
||||
|
||||
func _on_FirebaseAuth_logout() -> void:
|
||||
_auth = {}
|
||||
|
||||
func get_remote_config() -> void:
|
||||
var function_task = Firebase.Functions.execute("getRemoteConfig", HTTPClient.METHOD_GET, {}, {}) as FunctionTask
|
||||
var result = await function_task.task_finished
|
||||
Firebase._print("Config request result: " + str(result))
|
||||
if result.has("error"):
|
||||
remote_config_error.emit(result)
|
||||
return
|
||||
|
||||
var config = RemoteConfig.new(result)
|
||||
remote_config_received.emit(config)
|
||||
@@ -0,0 +1 @@
|
||||
uid://xqngri5s6yc5
|
||||
@@ -0,0 +1,7 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://5xa6ulbllkjk"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/godot-firebase/remote_config/firebase_remote_config.gd" id="1_wx4ds"]
|
||||
|
||||
[node name="FirebaseRemoteConfig" type="HTTPRequest"]
|
||||
use_threads = true
|
||||
script = ExtResource("1_wx4ds")
|
||||
14
addons/godot-firebase/remote_config/remote_config.gd
Normal file
14
addons/godot-firebase/remote_config/remote_config.gd
Normal file
@@ -0,0 +1,14 @@
|
||||
class_name RemoteConfig
|
||||
extends RefCounted
|
||||
|
||||
var default_config = {}
|
||||
|
||||
func _init(values : Dictionary) -> void:
|
||||
default_config = values
|
||||
|
||||
func get_value(key : String) -> Variant:
|
||||
if default_config.has(key):
|
||||
return default_config[key]
|
||||
|
||||
Firebase._printerr("Remote config does not contain key: " + key)
|
||||
return null
|
||||
1
addons/godot-firebase/remote_config/remote_config.gd.uid
Normal file
1
addons/godot-firebase/remote_config/remote_config.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bqimgkjkven2l
|
||||
Reference in New Issue
Block a user