diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/game.gd | 2 | ||||
| -rw-r--r-- | client/global.gd | 26 | ||||
| -rw-r--r-- | client/menu/character_menu.gd | 10 | ||||
| -rw-r--r-- | client/menu/character_menu.tscn | 15 | ||||
| -rw-r--r-- | client/menu/ingame_menu.tscn | 1 | 
5 files changed, 44 insertions, 10 deletions
| diff --git a/client/game.gd b/client/game.gd index 48f393e0..74842768 100644 --- a/client/game.gd +++ b/client/game.gd @@ -109,7 +109,7 @@ func _ready():  		t.finish(warn)  	) -	mp.send_join("Blub", 1) +	mp.send_join(Global.username, Global.character)  func _process(delta): diff --git a/client/global.gd b/client/global.gd index c75d12f3..02989b19 100644 --- a/client/global.gd +++ b/client/global.gd @@ -1,5 +1,29 @@  extends Node  var server_url = "" -var character = 1  var error_message = "" + +var character = 1 +var username = "Giovanni" + +func _ready(): +	load_profile() + +func save_profile(): +	print("Save profile") +	var f = FileAccess.open("user://profile", FileAccess.WRITE) +	f.store_line(JSON.stringify({ +		"username": username, +		"character": character +	})) + +func load_profile(): +	# TOCTOU here. Godot docs says its fine. +	if not FileAccess.file_exists("user://profile"): +		print("Skip profile load") +		return +	print("Load profile") +	var f = FileAccess.open("user://profile", FileAccess.READ) +	var ob = JSON.parse_string(f.get_line()) +	username = ob["username"] +	character = ob["character"] diff --git a/client/menu/character_menu.gd b/client/menu/character_menu.gd index 3949b5c0..836dc7c3 100644 --- a/client/menu/character_menu.gd +++ b/client/menu/character_menu.gd @@ -15,5 +15,15 @@  #   extends Control +func _ready(): +	$top_panel/a/username.text = Global.username + +func _notification(what): +	if what == NOTIFICATION_PREDELETE: +		Global.save_profile() +  func _on_back_pressed():  	$SceneTransition.transition_to("res://menu/main_menu.tscn") + +func _on_username_text_changed(new_text): +	Global.username = new_text diff --git a/client/menu/character_menu.tscn b/client/menu/character_menu.tscn index 8f8455b6..8c4d0d96 100644 --- a/client/menu/character_menu.tscn +++ b/client/menu/character_menu.tscn @@ -30,14 +30,14 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.75, 1.75)  [node name="guy" parent="." instance=ExtResource("3_odq7n")] -[node name="Panel" type="Panel" parent="."] +[node name="top_panel" type="Panel" parent="."]  layout_mode = 1  anchors_preset = 10  anchor_right = 1.0  offset_bottom = 113.0  grow_horizontal = 2 -[node name="a" type="VBoxContainer" parent="Panel"] +[node name="a" type="VBoxContainer" parent="top_panel"]  layout_mode = 1  anchors_preset = 5  anchor_left = 0.5 @@ -48,15 +48,15 @@ offset_right = 216.0  offset_bottom = 110.0  grow_horizontal = 2 -[node name="Label" type="Label" parent="Panel/a"] +[node name="Label" type="Label" parent="top_panel/a"]  layout_mode = 2  text = "This Chef is called"  horizontal_alignment = 1 -[node name="LineEdit" type="LineEdit" parent="Panel/a"] +[node name="username" type="LineEdit" parent="top_panel/a"]  layout_mode = 2 -[node name="Panel2" type="Panel" parent="."] +[node name="bottom_panel" type="Panel" parent="."]  layout_mode = 1  anchors_preset = 12  anchor_top = 1.0 @@ -66,7 +66,7 @@ offset_top = -61.0  grow_horizontal = 2  grow_vertical = 0 -[node name="back" type="Button" parent="Panel2"] +[node name="back" type="Button" parent="bottom_panel"]  layout_mode = 1  anchors_preset = 8  anchor_left = 0.5 @@ -86,4 +86,5 @@ text = "Back"  visible = false  layout_mode = 1 -[connection signal="pressed" from="Panel2/back" to="." method="_on_back_pressed"] +[connection signal="text_changed" from="top_panel/a/username" to="." method="_on_username_text_changed"] +[connection signal="pressed" from="bottom_panel/back" to="." method="_on_back_pressed"] diff --git a/client/menu/ingame_menu.tscn b/client/menu/ingame_menu.tscn index 44471db2..f9b0157c 100644 --- a/client/menu/ingame_menu.tscn +++ b/client/menu/ingame_menu.tscn @@ -72,7 +72,6 @@ anchors_preset = 9  anchor_bottom = 1.0  offset_left = -400.0  offset_right = -90.0 -offset_bottom = 4536.0  grow_vertical = 2  [node name="margin" type="MarginContainer" parent="side"] | 
