Skip to content

Commit 090dc2c

Browse files
zymsbgtStructed
andcommitted
fix(pencil): Anonymous Login button does not turn green after successful anonymous login #81 (#82)
Making the button green which is currently logged in Co-authored-by: Johannes Ebner <Structed@users.noreply.github.com>
1 parent a2a244f commit 090dc2c

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

Scenes/Login.gd

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
extends MarginContainer
22

3+
const color_green = Color(0, 1, 0, 0.5)
4+
const color_white = Color(1, 1, 1, 1)
5+
const color_red = Color(1, 0, 0, 0.5)
36

47
func _ready():
58
var _error = PlayFabManager.client.connect("api_error", self, "_on_api_error")
69
_error = PlayFabManager.client.connect("logged_in", self, "_on_logged_in")
10+
update_login_button_states()
11+
12+
13+
func update_login_button_states():
14+
# Reset button colours
15+
$Login/Login.self_modulate = color_white
16+
$Login/AnonLogin.self_modulate = color_white
17+
18+
if PlayFabManager.client_config.is_logged_in():
19+
match PlayFabManager.client_config.login_type:
20+
PlayFabClientConfig.LoginType.LOGIN_CUSTOM_ID:
21+
$Login/AnonLogin.self_modulate = color_green
22+
PlayFabClientConfig.LoginType.LOGIN_EMAIL:
23+
$Login/Login.self_modulate = color_green
24+
_:
25+
pass # No specific action needed
726

827

928
func _on_Login_pressed():
@@ -43,7 +62,6 @@ func _hide_progess():
4362

4463

4564
func _on_logged_in(login_result: LoginResult):
46-
$Login/Login.self_modulate = Color(0, 1, 0, 0.5)
4765
$Login/Output.hide()
4866
_hide_progess()
4967

@@ -63,7 +81,7 @@ func _on_api_error(api_error_wrapper: ApiErrorWrapper):
6381
for element in error_details[key]:
6482
text += "%s\n" % element
6583

66-
$Login/Login.self_modulate = Color(1, 0, 0, 0.5)
84+
$Login/Login.self_modulate = color_red
6785
$Login/Output.show()
6886
$Login/Output.bbcode_text = text
6987

@@ -74,5 +92,5 @@ func _on_Back_pressed():
7492

7593
func _on_LoggedInBackButton_pressed():
7694
$LoggedIn.hide()
95+
update_login_button_states()
7796
$Login.show()
78-
pass

0 commit comments

Comments
 (0)