diff options
| author | nokoe <nokoe@mailbox.org> | 2024-07-13 14:18:58 +0200 | 
|---|---|---|
| committer | nokoe <nokoe@mailbox.org> | 2024-07-13 14:18:58 +0200 | 
| commit | e2f554a8b014707ca09d3297f5e829b014ab5426 (patch) | |
| tree | 3507bc17bf2334c0bdd1b89f43a7f607d0b7b585 /client | |
| parent | 14d731f06dd4e0aa5c6923c2c5ab096b3183a011 (diff) | |
| download | hurrycurry-e2f554a8b014707ca09d3297f5e829b014ab5426.tar hurrycurry-e2f554a8b014707ca09d3297f5e829b014ab5426.tar.bz2 hurrycurry-e2f554a8b014707ca09d3297f5e829b014ab5426.tar.zst | |
add tutorial reset
Diffstat (limited to 'client')
| -rw-r--r-- | client/global.gd | 53 | ||||
| -rw-r--r-- | client/menu/popup_message.gd | 30 | 
2 files changed, 53 insertions, 30 deletions
| diff --git a/client/global.gd b/client/global.gd index a47cff12..2ee550b0 100644 --- a/client/global.gd +++ b/client/global.gd @@ -25,14 +25,15 @@ var default_profile := {  	"username": "Giovanni",  	"character": 0,  	"last_server_url": "", -	# HINTS: -	"has_seen_nametags": false, -	"has_moved": false, -	"has_boosted": false, -	"has_interacted": false, -	"has_rotated": false, -	"has_reset": false, -	"has_zoomed": false +	"hints": { +		"has_seen_nametags": false, +		"has_moved": false, +		"has_boosted": false, +		"has_interacted": false, +		"has_rotated": false, +		"has_reset": false, +		"has_zoomed": false +	}  }  var languages := [tr("System default"), "en", "de"]  var using_joypad := false @@ -56,6 +57,7 @@ var default_settings := {  	"debug_info": ToggleSetting.new(tr("Display debug info (Framerate, etc.)"), false),  	"grass_amount": RangeSetting.new(tr("3D grass amount per grass tile"), 16, 0, 32),  	"setup_complete": ToggleSetting.new(tr("Initial setup complete. (Uncheck and restart to reenter)"), false), +	"tutorial_started": ToggleSetting.new(tr("Tutorial started. (Uncheck and restart to replay)"), false),  	"latch_boost": ToggleSetting.new(tr("Always extend boost to maximum duration"), true)  } @@ -71,17 +73,17 @@ func _ready():  	profile = load_dict("user://profile", default_profile)  	load_settings("user://settings")  	apply_settings() -	 +  	get_viewport().gui_focus_changed.connect(Sound.play_hover_maybe)  	get_viewport().gui_focus_changed.connect(func (node): focused_node = node) -	 +  func _input(event):  	if Input.is_action_just_pressed("fullscreen"):  		Global.set_setting("fullscreen", not Global.get_setting("fullscreen"))  		save_settings()  		update_fullscreen() -	 +  	# Update using_joypad variable  	if event is InputEventMouseButton or event is InputEventKey:  		if using_joypad: @@ -95,7 +97,7 @@ func _input(event):  func apply_settings():  	update_fullscreen()  	update_language() -	 +  	# Anti-aliasing  	match get_setting("aa"):  		0: @@ -114,12 +116,12 @@ func apply_settings():  			get_viewport().msaa_2d = Viewport.MSAA_4X  			get_viewport().msaa_3d = Viewport.MSAA_4X  			get_viewport().screen_space_aa = Viewport.SCREEN_SPACE_AA_DISABLED -	 +  	# Temporal Anti-aliasing  	get_viewport().use_taa = get_setting("taa") -	 +  	emit_signal("settings_changed") -	 +  	# UI scale  	match get_setting("ui_scale"):  		0: @@ -127,6 +129,10 @@ func apply_settings():  		1:  			get_tree().root.content_scale_mode = Window.CONTENT_SCALE_MODE_DISABLED +	if not get_setting("tutorial_started"): +		for k in profile["hints"].keys(): +			set_profile(k, false) +  func update_language():  	var lang_idx: int = get_setting("language")  	var lang = languages[lang_idx] @@ -229,6 +235,23 @@ func set_profile(key: String, value):  		profile[key] = value  		save_profile() + +func set_hint(key: String, value: bool): +	if !profile["hints"].has(key): +		push_error("Tried to set hint \"%s\", which does not yet exist (missing key)" % key) +	if profile["hints"][key] != value: +		if value: +			set_setting("tutorial_started", true) +		profile["hints"][key] = value +		save_profile() + +func get_hint(key: String): +	if profile["hints"].has(key): +		return profile["hints"][key] +	else: +		push_error("Tried to access hint \"%s\", which does not exist (missing key)" % key) +		return null +  static func interpolate(current, target, dt):  	return target + (current - target) * exp(-dt) diff --git a/client/menu/popup_message.gd b/client/menu/popup_message.gd index 266c1f60..1748f59a 100644 --- a/client/menu/popup_message.gd +++ b/client/menu/popup_message.gd @@ -88,38 +88,38 @@ func stop_game_hints():  func _input(_event):  	if Input.is_action_just_pressed("boost"): -		Global.set_profile("has_boosted", true) +		Global.set_hint("has_boosted", true)  	if any_action_just_pressed(["forward", "backwards", "left", "right"]): -		Global.set_profile("has_moved", true) +		Global.set_hint("has_moved", true)  	if any_action_just_pressed(["rotate_left", "rotate_right", "rotate_up", "rotate_down"]): -		if not Global.get_profile("has_reset"): +		if not Global.get_hint("has_reset"):  			reset_timer.start() -		Global.set_profile("has_rotated", true) +		Global.set_hint("has_rotated", true)  	if any_action_just_pressed(["zoom_in", "zoom_out"]): -		Global.set_profile("has_zoomed", true) +		Global.set_hint("has_zoomed", true)  	if Input.is_action_just_pressed("interact"): -		Global.set_profile("has_interacted", true) +		Global.set_hint("has_interacted", true)  	if Input.is_action_just_pressed("reset"): -		Global.set_profile("has_reset", true) +		Global.set_hint("has_reset", true)  func _on_boost_timeout(): -	if not Global.get_profile("has_boosted") and not Global.get_setting("touch_controls"): +	if not Global.get_hint("has_boosted") and not Global.get_setting("touch_controls"):  		display_hint_msg(tr("Press %s to boost") % display_keybind(tr("SHIFT"), "B"))  func _on_move_timeout(): -	if not Global.get_profile("has_moved") and not Global.get_setting("touch_controls"): +	if not Global.get_hint("has_moved") and not Global.get_setting("touch_controls"):  		display_hint_msg(tr("Use %s to move") % display_keybind("WASD", tr("left stick")))  func _on_interact_timeout(): -	if not Global.get_profile("has_interacted") and not Global.get_setting("touch_controls"): +	if not Global.get_hint("has_interacted") and not Global.get_setting("touch_controls"):  		display_hint_msg(tr("Press %s to pick up items and interact with tools") % display_keybind(tr("SPACE"), "A"))  func _on_reset_timeout(): -	if not Global.get_profile("has_reset") and not Global.get_setting("touch_controls"): +	if not Global.get_hint("has_reset") and not Global.get_setting("touch_controls"):  		display_hint_msg(tr("Press %s to reset the camera view") % display_keybind("R", "Y"))  func _on_zoom_timeout(): -	if not Global.get_profile("has_zoomed") and not Global.get_setting("touch_controls"): +	if not Global.get_hint("has_zoomed") and not Global.get_setting("touch_controls"):  		display_hint_msg(tr("Use %s to zoom in/out") % display_keybind(tr("PageUp/PageDown"), "LT/RT"))  func display_keybind(keyboard: String, joypad: String, touch = null) -> String: @@ -136,10 +136,10 @@ func any_action_just_pressed(actions: Array) -> bool:  	return false  func _on_rotate_camera_timeout(): -	if not Global.get_profile("has_rotated") and not Global.get_setting("touch_controls"): +	if not Global.get_hint("has_rotated") and not Global.get_setting("touch_controls"):  		display_hint_msg(tr("Use %s to reset the camera view") % display_keybind(tr("arrow keys"), tr("right stick")))  func _on_nametags_timeout(): -	if not Global.get_profile("has_seen_nametags") and not Global.get_setting("usernames"): -		Global.set_profile("has_seen_nametags", true) +	if not Global.get_hint("has_seen_nametags") and not Global.get_setting("usernames"): +		Global.set_hint("has_seen_nametags", true)  		display_hint_msg(tr("Username tags can be enabled/disabled in the settings")) | 
