Overworld map loading
This commit is contained in:
@@ -26,6 +26,7 @@ QUEST="*res://scenes/Singletons/Quest.tscn"
|
|||||||
SCENE_MANAGER="*res://scripts/Singleton/SceneManager.gd"
|
SCENE_MANAGER="*res://scripts/Singleton/SceneManager.gd"
|
||||||
UI="*res://scenes/Singletons/UI.tscn"
|
UI="*res://scenes/Singletons/UI.tscn"
|
||||||
VN="*res://scripts/Singleton/VN.gd"
|
VN="*res://scripts/Singleton/VN.gd"
|
||||||
|
LOAD="*res://scenes/Singletons/Load.tscn"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://tmbx2kit0jyq"]
|
[gd_scene load_steps=2 format=3 uid="uid://tmbx2kit0jyq"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://pcncoc6wum4q" path="res://scripts/Scene/OverworldScene.gd" id="1_rfscu"]
|
[ext_resource type="Script" uid="uid://pcncoc6wum4q" path="res://scripts/Scene/OverworldScene.gd" id="1_rfscu"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dx6fv8n4jl5ku" path="res://scenes/Maps/TestMap/TestMap.tscn" id="2_puia7"]
|
|
||||||
|
|
||||||
[node name="Overworld" type="Node3D"]
|
[node name="Overworld" type="Node3D"]
|
||||||
script = ExtResource("1_rfscu")
|
script = ExtResource("1_rfscu")
|
||||||
|
|
||||||
[node name="Some-map" parent="." instance=ExtResource("2_puia7")]
|
[node name="Map" type="Node3D" parent="."]
|
||||||
|
3
scenes/Singletons/Load.tscn
Normal file
3
scenes/Singletons/Load.tscn
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dr2o6ymwbwxm1"]
|
||||||
|
|
||||||
|
[node name="Load" type="Node"]
|
@@ -11,11 +11,10 @@ script = ExtResource("1_pcsq6")
|
|||||||
|
|
||||||
[node name="MainMenu" type="Button" parent="."]
|
[node name="MainMenu" type="Button" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Prototype Main Menub"
|
text = "Prototype Main Menu"
|
||||||
|
|
||||||
[node name="OverworldOption" type="HBoxContainer" parent="."]
|
[node name="OverworldOption" type="HBoxContainer" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 0
|
|
||||||
size_flags_vertical = 0
|
size_flags_vertical = 0
|
||||||
|
|
||||||
[node name="Overworld" type="Button" parent="OverworldOption"]
|
[node name="Overworld" type="Button" parent="OverworldOption"]
|
||||||
@@ -24,6 +23,7 @@ text = "Prototype Overworld"
|
|||||||
|
|
||||||
[node name="MapDropdown" type="OptionButton" parent="OverworldOption"]
|
[node name="MapDropdown" type="OptionButton" parent="OverworldOption"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
[node name="Quests" type="Button" parent="."]
|
[node name="Quests" type="Button" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
@@ -41,7 +41,7 @@ layout_mode = 2
|
|||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="QuestList" type="ItemList" parent="VBoxContainer/HBoxContainer"]
|
[node name="QuestList" type="ItemList" parent="VBoxContainer/HBoxContainer"]
|
||||||
custom_minimum_size = Vector2(250, 0)
|
custom_minimum_size = Vector2(100, 0)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 0
|
size_flags_horizontal = 0
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
@@ -70,7 +70,7 @@ layout_mode = 2
|
|||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="QuestObjectiveList" type="ItemList" parent="VBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer"]
|
[node name="QuestObjectiveList" type="ItemList" parent="VBoxContainer/HBoxContainer/Control/VBoxContainer/HBoxContainer"]
|
||||||
custom_minimum_size = Vector2(150, 0)
|
custom_minimum_size = Vector2(110, 0)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
item_count = 2
|
item_count = 2
|
||||||
item_0/text = "Quest Objective 1"
|
item_0/text = "Quest Objective 1"
|
||||||
|
@@ -8,7 +8,7 @@ anchors_preset = 12
|
|||||||
anchor_top = 1.0
|
anchor_top = 1.0
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
offset_top = -140.0
|
offset_top = -60.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
theme = ExtResource("1_wx4lp")
|
theme = ExtResource("1_wx4lp")
|
||||||
|
@@ -1 +1,25 @@
|
|||||||
class_name OverworldScene extends Node3D
|
class_name OverworldScene extends Node3D
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
_updateMap()
|
||||||
|
|
||||||
|
OVERWORLD.mapChanged.connect(_onMapChanged)
|
||||||
|
|
||||||
|
func _exit_tree() -> void:
|
||||||
|
OVERWORLD.mapChanged.disconnect(_onMapChanged)
|
||||||
|
|
||||||
|
func _updateMap() -> void:
|
||||||
|
# Remove all children
|
||||||
|
for child in $Map.get_children():
|
||||||
|
child.queue_free()
|
||||||
|
$Map.remove_child(child)
|
||||||
|
|
||||||
|
# Load the new map
|
||||||
|
if not OVERWORLD.MAPS.has(OVERWORLD.currentMap):
|
||||||
|
return
|
||||||
|
var map = load(OVERWORLD.MAPS[OVERWORLD.currentMap])
|
||||||
|
var mapInstance = map.instantiate()
|
||||||
|
$Map.add_child(mapInstance)
|
||||||
|
|
||||||
|
func _onMapChanged(mapHandle:String, mapScene:String) -> void:
|
||||||
|
_updateMap()
|
||||||
|
1
scripts/Singleton/Load.gd
Normal file
1
scripts/Singleton/Load.gd
Normal file
@@ -0,0 +1 @@
|
|||||||
|
class_name LoadManager extends Node
|
1
scripts/Singleton/Load.gd.uid
Normal file
1
scripts/Singleton/Load.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://whqkvjhckgb0
|
@@ -1,13 +1,16 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
const MAPS:Dictionary[String, String] = {
|
const MAPS:Dictionary[String, String] = {
|
||||||
"TestMap": "res://scenes/Maps/TestMap.tscn"
|
"TestMap": "res://scenes/Maps/TestMap/TestMap.tscn"
|
||||||
};
|
};
|
||||||
|
|
||||||
var currentMap:String = "";
|
var currentMap:String = "";
|
||||||
|
|
||||||
|
signal mapChanged(mapHandle:String, mapScene:String);
|
||||||
|
|
||||||
func setMap(map:String) -> void:
|
func setMap(map:String) -> void:
|
||||||
if MAPS.has(map):
|
assert(MAPS.has(map), "Map not found: " + map)
|
||||||
currentMap = map
|
if currentMap == map:
|
||||||
else:
|
return
|
||||||
push_error("Map not found: " + map)
|
currentMap = map
|
||||||
|
mapChanged.emit(map, MAPS[map])
|
@@ -16,6 +16,14 @@ func _ready() -> void:
|
|||||||
$OverworldOption/MapDropdown.add_item(map, i);
|
$OverworldOption/MapDropdown.add_item(map, i);
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
|
|
||||||
|
func _exit_tree() -> void:
|
||||||
|
$MainMenu.disconnect("pressed", _on_MainMenu_pressed);
|
||||||
|
$OverworldOption/Overworld.disconnect("pressed", _on_Overworld_pressed);
|
||||||
|
$Quests.disconnect("pressed", _on_Quests_pressed);
|
||||||
|
$Cutscene.disconnect("pressed", _on_Custscene_pressed);
|
||||||
|
$Cooking.disconnect("pressed", _on_Cooking_pressed);
|
||||||
|
$Battle.disconnect("pressed", _on_Battle_pressed);
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if Input.is_action_just_pressed("debug"):
|
if Input.is_action_just_pressed("debug"):
|
||||||
print("Debug key pressed")
|
print("Debug key pressed")
|
||||||
|
@@ -23,6 +23,11 @@ func _ready() -> void:
|
|||||||
questObjectiveList.item_selected.connect(_onQuestObjectiveSelected)
|
questObjectiveList.item_selected.connect(_onQuestObjectiveSelected)
|
||||||
QUEST.questUpdated.connect(_onQuestUpdated)
|
QUEST.questUpdated.connect(_onQuestUpdated)
|
||||||
|
|
||||||
|
func _exit_tree() -> void:
|
||||||
|
questList.item_selected.disconnect(_onQuestSelected)
|
||||||
|
closeButton.pressed.disconnect(_onCloseClicked)
|
||||||
|
questObjectiveList.item_selected.disconnect(_onQuestObjectiveSelected)
|
||||||
|
QUEST.questUpdated.disconnect(_onQuestUpdated)
|
||||||
|
|
||||||
func setQuest(questKey = null):
|
func setQuest(questKey = null):
|
||||||
if questKey == null || questKey == -1:
|
if questKey == null || questKey == -1:
|
||||||
|
@@ -1,19 +1,25 @@
|
|||||||
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://dm7ee4aqjr2dl"]
|
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://dm7ee4aqjr2dl"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_linbi"]
|
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_linbi"]
|
||||||
texture_margin_left = 14.0
|
texture_margin_left = 2.0
|
||||||
texture_margin_top = 14.0
|
texture_margin_top = 2.0
|
||||||
texture_margin_right = 14.0
|
texture_margin_right = 2.0
|
||||||
texture_margin_bottom = 14.0
|
texture_margin_bottom = 2.0
|
||||||
axis_stretch_horizontal = 1
|
axis_stretch_horizontal = 1
|
||||||
axis_stretch_vertical = 1
|
axis_stretch_vertical = 1
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
Button/font_sizes/font_size = 12
|
Button/font_sizes/font_size = 12
|
||||||
|
ItemList/font_sizes/font_size = 12
|
||||||
Label/constants/shadow_offset_y = 1
|
Label/constants/shadow_offset_y = 1
|
||||||
Label/font_sizes/font_size = 12
|
Label/font_sizes/font_size = 12
|
||||||
MarginContainer/constants/margin_bottom = 8
|
MarginContainer/constants/margin_bottom = 2
|
||||||
MarginContainer/constants/margin_left = 8
|
MarginContainer/constants/margin_left = 2
|
||||||
MarginContainer/constants/margin_right = 8
|
MarginContainer/constants/margin_right = 2
|
||||||
MarginContainer/constants/margin_top = 8
|
MarginContainer/constants/margin_top = 2
|
||||||
PanelContainer/styles/panel = SubResource("StyleBoxTexture_linbi")
|
PanelContainer/styles/panel = SubResource("StyleBoxTexture_linbi")
|
||||||
|
RichTextLabel/font_sizes/bold_font_size = 12
|
||||||
|
RichTextLabel/font_sizes/bold_italics_font_size = 12
|
||||||
|
RichTextLabel/font_sizes/italics_font_size = 12
|
||||||
|
RichTextLabel/font_sizes/mono_font_size = 12
|
||||||
|
RichTextLabel/font_sizes/normal_font_size = 12
|
||||||
|
Reference in New Issue
Block a user