-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from mint-choc-chip-skyblade/feat/tracker/map-ui
Implement a basic reusable Map node for changing scenes
- Loading branch information
Showing
14 changed files
with
246 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
extends Node | ||
|
||
|
||
@onready var current_scene: Node = $CurrentScene | ||
|
||
|
||
func _ready() -> void: | ||
Messenger.transition_scene.connect(_on_transition_root_scene) | ||
|
||
|
||
func _on_transition_root_scene(scene: PackedScene) -> void: | ||
var next_scene := scene.instantiate() | ||
var prev_scene := current_scene.get_child(0) | ||
if prev_scene: | ||
prev_scene.queue_free() | ||
|
||
current_scene.add_child(next_scene) | ||
Messenger.transitioned_scene.emit() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://bidhkqygbohc" | ||
path="res://.godot/imported/skyloft.png-a9b93c32edea3815085410cb6a1c50dd.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://assets/images/skyloft.png" | ||
dest_files=["res://.godot/imported/skyloft.png-a9b93c32edea3815085410cb6a1c50dd.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://bq13h60eeg7bw" | ||
path="res://.godot/imported/ss-map.png-6da2b8cf834318882b6eb66b6748ab36.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://assets/images/ss-map.png" | ||
dest_files=["res://.godot/imported/ss-map.png-6da2b8cf834318882b6eb66b6748ab36.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=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,9 @@ | ||
[gd_resource type="AudioBusLayout" format=3 uid="uid://0grn00ls457b"] | ||
|
||
[resource] | ||
bus/1/name = &"SFX" | ||
bus/1/solo = false | ||
bus/1/mute = false | ||
bus/1/bypass_fx = false | ||
bus/1/volume_db = 0.0 | ||
bus/1/send = &"Master" |
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 |
---|---|---|
@@ -1,3 +1,11 @@ | ||
[gd_scene format=3 uid="uid://if1s7c1cbddo"] | ||
[gd_scene load_steps=3 format=3 uid="uid://if1s7c1cbddo"] | ||
|
||
[ext_resource type="Script" path="res://Game.gd" id="1_rn7ya"] | ||
[ext_resource type="PackedScene" uid="uid://bjly5ntj2jhfn" path="res://scenes/maps/world.tscn" id="1_tsgx8"] | ||
|
||
[node name="Game" type="Node"] | ||
script = ExtResource("1_rn7ya") | ||
|
||
[node name="CurrentScene" type="Node" parent="."] | ||
|
||
[node name="World" parent="CurrentScene" instance=ExtResource("1_tsgx8")] |
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,58 @@ | ||
@tool | ||
extends CanvasLayer | ||
class_name Map | ||
|
||
|
||
# child_scene specifies the target that this scene | ||
# will transition into when entered. | ||
@export_file var child_scene: String | ||
# parent_scene specifies the target parent that | ||
# this scene will transition to when exited. | ||
@export_file var parent_scene: String | ||
|
||
|
||
# interactable_area is the child interaction zone for this node. | ||
# | ||
# When an interaction occurs within this area, the node should act. | ||
@onready var interactable_area: Area2D = find_child("Area2D") | ||
|
||
|
||
func _ready() -> void: | ||
# if we have a child_scene and an interactable area, listen to events | ||
if child_scene && interactable_area: | ||
interactable_area.connect("input_event", _on_area_2d_input_event) | ||
|
||
|
||
func _get_configuration_warnings() -> PackedStringArray: | ||
var warnings = [] | ||
|
||
if child_scene && !interactable_area: | ||
warnings.append("Map's with a child_scene must have an Area2D") | ||
|
||
# Returning an empty array means "no warning". | ||
return warnings | ||
|
||
|
||
func _on_area_2d_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void: | ||
if event.is_action_pressed("zoom_in"): | ||
open_child_map() | ||
|
||
|
||
func _input(event: InputEvent) -> void: | ||
if event.is_action("zoom_out"): | ||
close_child_map() | ||
|
||
|
||
|
||
func close_child_map() -> void: | ||
if !parent_scene: | ||
return | ||
|
||
Messenger.transition_scene.emit(load(parent_scene)) | ||
|
||
|
||
func open_child_map() -> void: | ||
if !child_scene: | ||
return | ||
|
||
Messenger.transition_scene.emit(load(child_scene)) |
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,6 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://bjeedodu068xb"] | ||
|
||
[ext_resource type="Script" path="res://scenes/maps/Map.gd" id="1_wjh8i"] | ||
|
||
[node name="Map" type="CanvasLayer"] | ||
script = ExtResource("1_wjh8i") |
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,21 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://cmugiqudyuot6"] | ||
|
||
[ext_resource type="Texture2D" uid="uid://bidhkqygbohc" path="res://assets/images/skyloft.png" id="1_vyvj7"] | ||
[ext_resource type="Script" path="res://scenes/maps/Map.gd" id="2_5nb6n"] | ||
|
||
[node name="Skyloft" type="Node"] | ||
|
||
[node name="Map" type="CanvasLayer" parent="."] | ||
script = ExtResource("2_5nb6n") | ||
parent_scene = "res://scenes/maps/world.tscn" | ||
|
||
[node name="TextureRect" type="TextureRect" parent="."] | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
texture = ExtResource("1_vyvj7") | ||
expand_mode = 1 | ||
stretch_mode = 5 | ||
metadata/_edit_lock_ = true |
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,30 @@ | ||
[gd_scene load_steps=4 format=3 uid="uid://bjly5ntj2jhfn"] | ||
|
||
[ext_resource type="Texture2D" uid="uid://bq13h60eeg7bw" path="res://assets/images/ss-map.png" id="1_uijf8"] | ||
[ext_resource type="Script" path="res://scenes/maps/Map.gd" id="2_c7043"] | ||
|
||
[sub_resource type="CircleShape2D" id="CircleShape2D_lsvye"] | ||
radius = 96.421 | ||
|
||
[node name="World" type="Node"] | ||
|
||
[node name="TextureRect" type="TextureRect" parent="."] | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
texture = ExtResource("1_uijf8") | ||
expand_mode = 1 | ||
stretch_mode = 5 | ||
|
||
[node name="Skyloft" type="CanvasLayer" parent="."] | ||
script = ExtResource("2_c7043") | ||
child_scene = "res://scenes/maps/skyloft/skyloft.tscn" | ||
|
||
[node name="Area2D" type="Area2D" parent="Skyloft"] | ||
position = Vector2(640, 333) | ||
metadata/_edit_lock_ = true | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Skyloft/Area2D"] | ||
shape = SubResource("CircleShape2D_lsvye") |
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,4 @@ | ||
extends Node | ||
|
||
signal transition_scene(scene: PackedScene) | ||
signal transitioned_scene |
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