Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions GeolocationWrapper.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ enum geolocation_desired_accuracy_constants {
enum geolocation_error_codes {
ERROR_DENIED = 1 << 0,
ERROR_NETWORK = 1 << 1,
ERROR_HEADING_FAILURE = 1 << 2
ERROR_LOCATION_UNKNOWN = 1 << 3
ERROR_TIMEOUT = 1 << 4
ERROR_UNSUPPORTED = 1 << 5
ERROR_LOCATION_DISABLED = 1 << 6
ERROR_HEADING_FAILURE = 1 << 2,
ERROR_LOCATION_UNKNOWN = 1 << 3,
ERROR_TIMEOUT = 1 << 4,
ERROR_UNSUPPORTED = 1 << 5,
ERROR_LOCATION_DISABLED = 1 << 6,
ERROR_UNKNOWN = 1 << 7
}

Expand Down Expand Up @@ -72,16 +72,16 @@ func _setup_native_plugin():
supported = true

if platform == platforms.iOS:
_geolocation_plugin.connect("authorization_changed", self, "_on_authorization_changed")
_geolocation_plugin.authorization_changed.connect(_on_authorization_changed)

if platform == platforms.android:
get_tree().connect("on_request_permissions_result", self, "_on_godot_android_permissions")
get_tree().on_request_permissions_result.connect(_on_godot_android_permissions)

_geolocation_plugin.connect("error", self, "_on_error")
_geolocation_plugin.connect("log", self, "_on_log")
_geolocation_plugin.connect("location_update", self, "_on_location_update")
_geolocation_plugin.connect("heading_update", self, "_on_heading_update")
_geolocation_plugin.connect("location_capability_result", self, "_on_location_capability_result")
_geolocation_plugin.error.connect(_on_error)
_geolocation_plugin.log.connect(_on_log)
_geolocation_plugin.location_update.connect(_on_location_update)
_geolocation_plugin.heading_update.connect(_on_heading_update)
_geolocation_plugin.location_capability_result.connect(_on_location_capability_result)

else:
_on_log("No singleton")
Expand All @@ -90,9 +90,9 @@ func _setup_native_plugin():

func _on_godot_android_permissions(permission:String, granted:bool):
if _last_android_permission_signal == -1:
_last_android_permission_signal = OS.get_ticks_msec()
_last_android_permission_signal = Time.get_ticks_msec()
else:
var time_diff:int = OS.get_ticks_msec() - _last_android_permission_signal
var time_diff:int = Time.get_ticks_msec() - _last_android_permission_signal
_last_android_permission_signal = -1
if time_diff < 500:
return
Expand Down
2 changes: 1 addition & 1 deletion Location.gd
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ func _to_string():
props.append("timestamp : %d" % [timestamp])
props.append("latitude_string : %s" % [lat_string])
props.append("longitude_string : %s" % [lon_string])
return PoolStringArray(props).join("\n")
return "\n".join(PackedStringArray(props))
10 changes: 5 additions & 5 deletions LocationRequest.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Reference
extends RefCounted

class_name LocationRequest

Expand All @@ -22,7 +22,7 @@ func _request():
if status != geolocation_api.geolocation_authorization_status.PERMISSION_STATUS_ALLOWED:
geolocation_api._on_log("** request permission")
geolocation_api.request_permissions()
var new_status = yield(geolocation_api, "authorization_changed")
var new_status = await geolocation_api.authorization_changed
if new_status != geolocation_api.geolocation_authorization_status.PERMISSION_STATUS_ALLOWED:
error = geolocation_api.geolocation_error_codes.ERROR_DENIED
is_resolved = true
Expand All @@ -31,7 +31,7 @@ func _request():

if geolocation_api.should_check_location_capability():
geolocation_api.request_location_capabilty()
var capable = yield(geolocation_api, "location_capability_result")
var capable = await geolocation_api.location_capability_result
if !capable:
error = geolocation_api.geolocation_error_codes.ERROR_LOCATION_DISABLED
is_resolved = true
Expand All @@ -48,7 +48,7 @@ func _on_location_update(location:Location):
emit_signal("location_update",location)

func _listen_for_error():
error = yield(geolocation_api, "error")
error = await geolocation_api.error
geolocation_api._on_log("** error happend")
if is_resolved:
return # request already resolved error irrelevant
Expand All @@ -58,7 +58,7 @@ func _listen_for_error():
emit_signal("location_update", null) # no location, so send null

func _listen_for_location():
var location = yield(geolocation_api, "location_update")
var location = await geolocation_api.location_update
geolocation_api._on_log("** location received")
if is_resolved:
return # request already resolved with error
Expand Down
6 changes: 3 additions & 3 deletions LocationWatcher.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Reference
extends RefCounted

class_name LocationWatcher

Expand All @@ -17,7 +17,7 @@ func _init(geo_api):
func _make_ready():
# request one location and authorize before when neccessary
var request = geolocation_api.request_location_autopermission()
var location:Location = yield(request,"location_update")
var location:Location = await request.location_update

# location is null when no location could be found (no permission, no connection)
if location == null:
Expand All @@ -39,7 +39,7 @@ func _on_location_update(location:Location):
emit_signal("location_update",location)

func _listen_for_error():
error = yield(geolocation_api, "error")
error = await geolocation_api.error
geolocation_api._on_log("** error happend in watcher")
# stop watcher on error
stop()
Expand Down