diff options
| -rw-r--r-- | client/menu/about.gd | 1 | ||||
| -rw-r--r-- | client/menu/about.tscn | 1 | ||||
| -rw-r--r-- | client/menu/character.gd | 9 | ||||
| -rw-r--r-- | client/menu/character.tscn | 2 | ||||
| -rw-r--r-- | client/menu/game.gd | 2 | ||||
| -rw-r--r-- | client/menu/main.gd | 2 | ||||
| -rw-r--r-- | client/menu/menu.gd | 29 | 
7 files changed, 28 insertions, 18 deletions
| diff --git a/client/menu/about.gd b/client/menu/about.gd index 1a32255a..d5a688fd 100644 --- a/client/menu/about.gd +++ b/client/menu/about.gd @@ -37,6 +37,7 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>."""  const SOURCE_CODE := "https://codeberg.org/hurrycurry/hurrycurry"  func _ready() -> void: +	super()  	$side/margin/options/first/source.tooltip_text = SOURCE_CODE  var credits := [ diff --git a/client/menu/about.tscn b/client/menu/about.tscn index f809d443..c51f0273 100644 --- a/client/menu/about.tscn +++ b/client/menu/about.tscn @@ -17,6 +17,7 @@ anchor_bottom = 1.0  grow_horizontal = 2  grow_vertical = 2  script = ExtResource("1_0acu0") +support_anim = false  [node name="side" type="PanelContainer" parent="."]  material = ExtResource("1_ai5pk") diff --git a/client/menu/character.gd b/client/menu/character.gd index 6499d19e..4661b222 100644 --- a/client/menu/character.gd +++ b/client/menu/character.gd @@ -52,11 +52,7 @@ func init_map():  			map.set_tile(Vector2i(x,y) - co, gt.call([x,y]), [[x,y-1],[x-1,y],[x,y+1],[x+1,y]].map(gt))  	map.flush() -func _input(_event): -	if Input.is_action_just_pressed("ui_cancel"): -		_on_back_pressed() - -func _on_back_pressed(): +func exit():  	if username_edit.text == "":  		var popup_data := MenuPopup.Data.new()  		popup_data.text = tr("c.error.empty_username") @@ -65,10 +61,9 @@ func _on_back_pressed():  		popup_data.buttons = [accept_button]  		await submenu("res://menu/popup.tscn", popup_data)  		return -	  	Global.set_profile("username", username_edit.text)  	Global.save_profile() -	replace_menu("res://menu/main.tscn") +	super()  func _on_character_back_pressed():  	modify_style(func m(current_style: Dictionary): diff --git a/client/menu/character.tscn b/client/menu/character.tscn index 42d1b764..b4f05fe2 100644 --- a/client/menu/character.tscn +++ b/client/menu/character.tscn @@ -227,4 +227,4 @@ layout_mode = 1  [connection signal="pressed" from="VBoxContainer/Spacer/VBoxContainer/Hairstyle/Forward" to="." method="_on_hairstyle_forward_pressed"]  [connection signal="pressed" from="VBoxContainer/Spacer/VBoxContainer/Character/Back" to="." method="_on_character_back_pressed"]  [connection signal="pressed" from="VBoxContainer/Spacer/VBoxContainer/Character/Forward" to="." method="_on_character_forward_pressed"] -[connection signal="pressed" from="VBoxContainer/bottom_panel/back" to="." method="_on_back_pressed"] +[connection signal="pressed" from="VBoxContainer/bottom_panel/back" to="." method="exit"] diff --git a/client/menu/game.gd b/client/menu/game.gd index 9d05aa5f..889bbbe9 100644 --- a/client/menu/game.gd +++ b/client/menu/game.gd @@ -23,7 +23,7 @@ class_name GameMenu  @onready var chat_preview: ChatPreview = $ChatPreview  func _ready(): -	get_tree().get_root().connect("go_back_requested", open_ingame_menu) +	get_tree().get_root().go_back_requested.connect(open_ingame_menu)  	super()  	transition.set_loading_text(tr("c.menu.game.connecting")) diff --git a/client/menu/main.gd b/client/menu/main.gd index bbc74d29..e66a178b 100644 --- a/client/menu/main.gd +++ b/client/menu/main.gd @@ -35,7 +35,7 @@ func _on_about_pressed():  	submenu("res://menu/about.tscn")  func _on_change_character_pressed(): -	replace_menu("res://menu/character.tscn") +	replace_menu("res://menu/character.tscn", null, "res://menu/main.tscn")  func _on_settings_pressed():  	submenu("res://menu/settings.tscn") diff --git a/client/menu/menu.gd b/client/menu/menu.gd index 756e80c6..f077f947 100644 --- a/client/menu/menu.gd +++ b/client/menu/menu.gd @@ -29,6 +29,7 @@ signal submenu_close()  const transition_scene = preload("res://menu/scene_transition.tscn")  var transition: SceneTransition  var parent_menu: Menu = null +var previous_path = null # : String  var open_since = 0  func _ready(): @@ -40,6 +41,7 @@ func _ready():  	update_parent_menu(self.get_parent())  	if support_anim: anim_setup()  	if auto_anim: _menu_open() +	get_tree().get_root().go_back_requested.connect(exit_maybe)  func anim_setup():  	transition = transition_scene.instantiate() @@ -80,20 +82,24 @@ func _disable_recursive(node: Node, state: bool):  func exit():  	await self._menu_exit() -	get_parent().submenu_close.emit() -	queue_free() +	if previous_path != null: +		replace_menu(previous_path) +	else: +		get_parent().submenu_close.emit() +		queue_free()  func quit():  	await exit()  	get_parent().quit() -func replace_menu(path: String, data_ = null): +func replace_menu(path: String, data_ = null, prev_path = null): # prev_path: String?  	print("Replace menu: ", path)  	if popup != null: await popup.exit()  	_disable_recursive(self, true)  	await _menu_exit() -	var new_popup = load(path).instantiate() +	var new_popup: Menu = load(path).instantiate()  	new_popup.data = data_ +	if prev_path != null: new_popup.previous_path = prev_path  	get_parent().add_child(new_popup)  	if parent_menu != null: parent_menu.popup = new_popup  	queue_free() @@ -132,8 +138,15 @@ func update_parent_menu(node: Node):  	elif node.get_parent() != null: update_parent_menu(node.get_parent())  func _input(_event): -	if popup != null: return -	if Time.get_ticks_msec() - open_since < 100: return  	if Input.is_action_just_pressed("menu"): -		Sound.play_click() -		exit() +		exit_maybe() +	if Input.is_action_just_pressed("reset"): +		exit_maybe() + +func exit_maybe() -> void: +	# Exit menu if all conditions are met +	if popup != null: return +	var time := Time.get_ticks_msec() +	if time - open_since < 100: return +	Sound.play_click() +	exit() | 
