-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
273 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
extends Window | ||
|
||
@export var label: RichTextLabel | ||
@export var previous_button: Button | ||
@export var next_button: Button | ||
|
||
## The current stage of the tutorial. | ||
## | ||
## Note that these values are saved via [SaveGame], so be careful about backwards compatibility! | ||
enum Stage { | ||
INITIAL = 0, | ||
SHIP_CONTROLS = 1, | ||
LAND_ON_PLANET = 2, | ||
OPEN_GALAXY_MAP = 3, | ||
HYPERJUMP = 4, | ||
FINAL = 1000, | ||
} | ||
|
||
var _stage: Stage = Stage.INITIAL: | ||
set(value): | ||
if _stage == value: | ||
return | ||
|
||
_stage = value | ||
self._update() | ||
|
||
func _ready() -> void: | ||
self._update() | ||
|
||
func _update() -> void: | ||
self.previous_button.visible = self._stage != Stage.INITIAL | ||
self.next_button.text = "DONE" if self._stage == Stage.FINAL else "NEXT" | ||
|
||
match self._stage: | ||
Stage.INITIAL: | ||
self.label.text = """\ | ||
Welcome to your new ship! This tutorial will guide you through the basics of ship control, navigation, and interstellar travel. Let's begin!""" | ||
|
||
Stage.SHIP_CONTROLS: | ||
var control_scheme := UserPreferences.control_scheme | ||
var thrust_key := self._get_action_binding("thrust") | ||
var turn_left_key := self._get_action_binding("turn_left") | ||
var turn_right_key := self._get_action_binding("turn_right") | ||
var fire_key := self._get_action_binding("fire") | ||
|
||
var movement_text: String | ||
match UserPreferences.control_scheme: | ||
UserPreferences.ControlScheme.RELATIVE: | ||
movement_text = """\ | ||
- [color=yellow]{thrust_key}[/color]: Thrust forward | ||
- [color=yellow]{turn_left_key}[/color]/[color=yellow]{turn_right_key}[/color]: Turn left/right""".format({ | ||
"thrust_key": thrust_key, | ||
"turn_left_key": turn_left_key, | ||
"turn_right_key": turn_right_key | ||
}) | ||
|
||
UserPreferences.ControlScheme.ABSOLUTE: | ||
movement_text = """\ | ||
- [color=yellow]Arrow keys[/color]: Move in any direction""" | ||
|
||
self.label.text = """\ | ||
To maneuver your ship: | ||
{movement_text} | ||
- [color=yellow]{fire_key}[/color]: Fire weapons | ||
Try moving and firing to get familiar with the controls.""".format({ | ||
"movement_text": movement_text, | ||
"fire_key": fire_key | ||
}) | ||
|
||
Stage.LAND_ON_PLANET: | ||
var cycle_landing_target_key := self._get_action_binding("cycle_landing_target") | ||
var land_key := self._get_action_binding("land") | ||
|
||
self.label.text = """\ | ||
Stop at ports to refuel, trade, and obtain missions: | ||
1. Click or press [color=yellow]{cycle_key}[/color] to target a planet, moon, or space station. | ||
2. Approach your selected port and slow down. | ||
3. Press [color=yellow]{land_key}[/color] to land. | ||
Try landing on Earth now.""".format({ | ||
"cycle_key": cycle_landing_target_key, | ||
"land_key": land_key | ||
}) | ||
|
||
Stage.OPEN_GALAXY_MAP: | ||
var toggle_galaxy_map_key := self._get_action_binding("toggle_galaxy_map") | ||
|
||
self.label.text = """\ | ||
The galaxy awaits you beyond Sol! You can use the galaxy map to navigate: | ||
1. Press [color=yellow]{map_key}[/color] to open the map. | ||
2. Click a system to set as destination. | ||
3. Click the X or press [color=yellow]{map_key}[/color] to close the map. | ||
Select the neighboring system Thalassa from the galaxy map.""".format({ | ||
"map_key": toggle_galaxy_map_key | ||
}) | ||
|
||
Stage.HYPERJUMP: | ||
var jump_key := self._get_action_binding("jump") | ||
|
||
self.label.text = """\ | ||
Now that you have selected Thalassa, you can initiate a hyperspace jump. | ||
Press [color=yellow]{jump_key}[/color] to make the jump to Thalassa now.""".format({ | ||
"jump_key": jump_key | ||
}) | ||
|
||
Stage.FINAL: | ||
var toggle_tutorial_key := self._get_action_binding("toggle_tutorial") | ||
|
||
self.label.text = """\ | ||
Congratulations, you're ready to head out on your own! Explore, trade, and complete missions as you travel the galaxy—and don't forget to refuel your hyperdrive! | ||
Good luck, pilot.""".format({ | ||
"toggle_tutorial_key": toggle_tutorial_key | ||
}) | ||
|
||
func _on_close_requested() -> void: | ||
self.hide() | ||
|
||
func _input(event: InputEvent) -> void: | ||
if event.is_action_pressed("toggle_tutorial"): | ||
self.get_viewport().set_input_as_handled() | ||
self.hide() | ||
|
||
func _get_action_binding(action: StringName) -> String: | ||
return InputMap.action_get_events(action)[0].as_text() | ||
|
||
## See [SaveGame]. | ||
func save_to_dict() -> Dictionary: | ||
var result := {} | ||
result["stage"] = self._stage | ||
result["visible"] = self.visible | ||
return result | ||
|
||
## See [SaveGame]. | ||
func load_from_dict(dict: Dictionary) -> void: | ||
self._stage = dict["stage"] | ||
self.visible = dict["visible"] | ||
|
||
func _on_previous_button_pressed() -> void: | ||
assert(self._stage != Stage.INITIAL, "Previous button should not be clickable when on initial tutorial stage") | ||
|
||
var stages := Stage.values() | ||
var index := stages.find(self._stage) | ||
|
||
assert(index != -1, "Could not find current tutorial stage") | ||
self._stage = stages[index - 1] | ||
|
||
func _on_next_button_pressed() -> void: | ||
if self._stage == Stage.FINAL: | ||
self.hide() | ||
return | ||
|
||
var stages := Stage.values() | ||
var index := stages.find(self._stage) | ||
|
||
assert(index != -1, "Could not find current tutorial stage") | ||
self._stage = stages[index + 1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://dasi6qq5tfc10"] | ||
|
||
[ext_resource type="Script" path="res://mechanics/tutorial/tutorial_window.gd" id="1_v4ja5"] | ||
[ext_resource type="Material" uid="uid://cs5s3tb7vagsi" path="res://screens/shared_ui/premultiplied_canvas_material.tres" id="2_7hvyq"] | ||
|
||
[node name="TutorialWindow" type="Window" node_paths=PackedStringArray("label", "previous_button", "next_button") groups=["saveable"]] | ||
transparent_bg = true | ||
title = "Tutorial" | ||
position = Vector2i(250, 100) | ||
size = Vector2i(570, 200) | ||
transparent = true | ||
script = ExtResource("1_v4ja5") | ||
label = NodePath("MarginContainer/VBoxContainer/RichTextLabel") | ||
previous_button = NodePath("MarginContainer/VBoxContainer/HBoxContainer/PreviousButton") | ||
next_button = NodePath("MarginContainer/VBoxContainer/HBoxContainer/NextButton") | ||
|
||
[node name="MarginContainer" type="MarginContainer" parent="."] | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
theme_override_constants/margin_top = 0 | ||
theme_override_constants/margin_right = 0 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="RichTextLabel" type="RichTextLabel" parent="MarginContainer/VBoxContainer"] | ||
material = ExtResource("2_7hvyq") | ||
layout_mode = 2 | ||
size_flags_vertical = 3 | ||
bbcode_enabled = true | ||
text = "Welcome to your new ship! Let's get you acquainted with the basic controls." | ||
|
||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
size_flags_vertical = 8 | ||
alignment = 2 | ||
|
||
[node name="PreviousButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] | ||
layout_mode = 2 | ||
text = "PREVIOUS" | ||
|
||
[node name="NextButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] | ||
layout_mode = 2 | ||
size_flags_horizontal = 8 | ||
size_flags_vertical = 8 | ||
text = "NEXT" | ||
|
||
[node name="Padding" type="Control" parent="MarginContainer/VBoxContainer/HBoxContainer"] | ||
custom_minimum_size = Vector2(2, 2.08165e-12) | ||
layout_mode = 2 | ||
|
||
[connection signal="close_requested" from="." to="." method="_on_close_requested"] | ||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/PreviousButton" to="." method="_on_previous_button_pressed"] | ||
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/NextButton" to="." method="_on_next_button_pressed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.