work on gardens
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://d140vaq4rv050"
|
||||
path="res://.godot/imported/bonus_star_back.png-1a31385f6a404813463a589049db29af.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/gardens/buttons/bonus_star_back.png"
|
||||
dest_files=["res://.godot/imported/bonus_star_back.png-1a31385f6a404813463a589049db29af.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
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c7vj26vvj4sou"
|
||||
path="res://.godot/imported/bonus_star_front.png-3e78f234da7dfd55acdb52aa1aa92a5d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/gardens/buttons/bonus_star_front.png"
|
||||
dest_files=["res://.godot/imported/bonus_star_front.png-3e78f234da7dfd55acdb52aa1aa92a5d.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
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bovwkvchretal"
|
||||
path="res://.godot/imported/boss_dot_back.png-33af95cc762562f8e5857de926a6a811.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/gardens/buttons/boss_dot_back.png"
|
||||
dest_files=["res://.godot/imported/boss_dot_back.png-33af95cc762562f8e5857de926a6a811.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
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bus15py545mkl"
|
||||
path="res://.godot/imported/boss_dot_front.png-9f1800ed5be3d139aabad923966d3e17.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/gardens/buttons/boss_dot_front.png"
|
||||
dest_files=["res://.godot/imported/boss_dot_front.png-9f1800ed5be3d139aabad923966d3e17.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
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://mccudns02j77"
|
||||
path="res://.godot/imported/lesson_dot_back.png-2734ad405180951457ef069bffaa33f2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/gardens/buttons/lesson_dot_back.png"
|
||||
dest_files=["res://.godot/imported/lesson_dot_back.png-2734ad405180951457ef069bffaa33f2.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
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://drryj0dlw5amd"
|
||||
path="res://.godot/imported/lesson_dot_front.png-8ea7bac514c13b9b6a8f36afb21c8144.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/gardens/buttons/lesson_dot_front.png"
|
||||
dest_files=["res://.godot/imported/lesson_dot_front.png-8ea7bac514c13b9b6a8f36afb21c8144.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
|
||||
@@ -0,0 +1,72 @@
|
||||
@tool
|
||||
extends Control
|
||||
|
||||
const flower_path_model: = "res://assets/gardens/flowers/Plant_%02d_%02d_%s.png"
|
||||
const background_path_model: = "res://assets/gardens/gardens/garden_%02d_open.png"
|
||||
const lesson_button_texture: = preload("res://assets/gardens/buttons/lesson_dot_front.png")
|
||||
|
||||
@onready var flower_controls: Array[TextureRect] = [
|
||||
%Flower1,
|
||||
%Flower2,
|
||||
%Flower3,
|
||||
%Flower4,
|
||||
%Flower5,
|
||||
]
|
||||
@onready var background: = %Background
|
||||
@onready var lesson_button_controls: Array[TextureRect] = [
|
||||
%Button1,
|
||||
%Button2,
|
||||
%Button3,
|
||||
%Button4,
|
||||
]
|
||||
|
||||
|
||||
@export var garden_layout: GardenLayout:
|
||||
set = set_garden_layout
|
||||
|
||||
|
||||
func get_button_size() -> Vector2:
|
||||
return lesson_button_texture.get_size()
|
||||
|
||||
|
||||
func set_garden_layout(p_garden_layout: GardenLayout) -> void:
|
||||
garden_layout = p_garden_layout
|
||||
set_flowers(garden_layout.flowers)
|
||||
set_background(garden_layout.color)
|
||||
set_lesson_buttons(garden_layout.lesson_buttons)
|
||||
|
||||
|
||||
func set_flowers(p_flowers: Array[GardenLayout.Flower]) -> void:
|
||||
for flower_control in flower_controls:
|
||||
flower_control.texture = null
|
||||
for i in p_flowers.size():
|
||||
if i >= flower_controls.size():
|
||||
break
|
||||
var flower: = p_flowers[i]
|
||||
var flower_control: = flower_controls[i]
|
||||
flower_control.texture = load(flower_path_model % [flower.color+1, flower.type+1, "Large"])
|
||||
flower_control.position = flower.position
|
||||
flower_control.size = Vector2.ZERO
|
||||
|
||||
|
||||
func set_lesson_buttons(p_lesson_buttons: Array[GardenLayout.LessonButton]) -> void:
|
||||
for lesson_button_control in lesson_button_controls:
|
||||
lesson_button_control.texture = null
|
||||
for i in p_lesson_buttons.size():
|
||||
if i >= lesson_button_controls.size():
|
||||
break
|
||||
var lesson_button: = p_lesson_buttons[i]
|
||||
var lesson_button_control: = lesson_button_controls[i]
|
||||
lesson_button_control.texture = lesson_button_texture
|
||||
lesson_button_control.position = lesson_button.position
|
||||
lesson_button_control.size = Vector2.ZERO
|
||||
|
||||
|
||||
func set_background(p_color: int) -> void:
|
||||
if not background:
|
||||
return
|
||||
background.texture = load(background_path_model % [p_color+1])
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_garden_layout(garden_layout)
|
||||
@@ -0,0 +1,119 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://mf4fc4l3dkrn"]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/gardens/garden.gd" id="1_5owem"]
|
||||
[ext_resource type="Script" path="res://resources/gardens/garden_layout.gd" id="2_8g7o4"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5kildofgmthb" path="res://assets/gardens/gardens/garden_01_open.png" id="3_p7iv3"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfkmukbjgra7d" path="res://assets/gardens/flowers/Plant_03_01_Large.png" id="3_qrxjm"]
|
||||
[ext_resource type="Texture2D" uid="uid://drryj0dlw5amd" path="res://assets/gardens/buttons/lesson_dot_front.png" id="5_bd2im"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pwltf"]
|
||||
script = ExtResource("2_8g7o4")
|
||||
color = 0
|
||||
flowers_export = Array[Dictionary]([{
|
||||
"color": 2,
|
||||
"position": Vector2i(500, 0),
|
||||
"type": 0
|
||||
}])
|
||||
lesson_buttons_export = Array[Dictionary]([{
|
||||
"path_out_position": Vector2i(0, 0),
|
||||
"position": Vector2i(0, 0)
|
||||
}])
|
||||
is_first_or_last = 1
|
||||
|
||||
[node name="Garden" type="Control"]
|
||||
custom_minimum_size = Vector2(2400, 2.08165e-12)
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_5owem")
|
||||
garden_layout = SubResource("Resource_pwltf")
|
||||
|
||||
[node name="Background" type="TextureRect" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("3_p7iv3")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="Flowers" type="Control" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Flower1" type="TextureRect" parent="Flowers"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_left = 500.0
|
||||
offset_right = 668.0
|
||||
offset_bottom = 229.0
|
||||
texture = ExtResource("3_qrxjm")
|
||||
|
||||
[node name="Flower2" type="TextureRect" parent="Flowers"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="Flower3" type="TextureRect" parent="Flowers"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="Flower4" type="TextureRect" parent="Flowers"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="Flower5" type="TextureRect" parent="Flowers"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="Buttons" type="Control" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Button1" type="TextureRect" parent="Buttons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_right = 100.0
|
||||
offset_bottom = 100.0
|
||||
texture = ExtResource("5_bd2im")
|
||||
|
||||
[node name="Button2" type="TextureRect" parent="Buttons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_left = 500.0
|
||||
offset_right = 668.0
|
||||
offset_bottom = 229.0
|
||||
|
||||
[node name="Button3" type="TextureRect" parent="Buttons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_left = 500.0
|
||||
offset_right = 668.0
|
||||
offset_bottom = 229.0
|
||||
|
||||
[node name="Button4" type="TextureRect" parent="Buttons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_left = 500.0
|
||||
offset_right = 668.0
|
||||
offset_bottom = 229.0
|
||||
@@ -0,0 +1,89 @@
|
||||
@tool
|
||||
extends Resource
|
||||
class_name GardenLayout
|
||||
|
||||
|
||||
class Flower:
|
||||
var color: = 0
|
||||
var type: = 0
|
||||
var position: = Vector2i.ZERO
|
||||
|
||||
func _init(p_color: int, p_type: int, p_position: Vector2i) -> void:
|
||||
color = p_color
|
||||
type = p_type
|
||||
position = p_position
|
||||
|
||||
static func from_dict(d: Dictionary) -> Flower:
|
||||
return Flower.new(d.color, d.type, d.position)
|
||||
|
||||
func to_dict() -> Dictionary:
|
||||
return {
|
||||
color = color,
|
||||
type = type,
|
||||
position = position,
|
||||
}
|
||||
|
||||
|
||||
class LessonButton:
|
||||
var position: = Vector2i.ZERO
|
||||
var path_out_position: = Vector2i.ZERO
|
||||
|
||||
func _init(p_position: Vector2i, p_path_out_position: Vector2i) -> void:
|
||||
position = p_position
|
||||
path_out_position = p_path_out_position
|
||||
|
||||
static func from_dict(d: Dictionary) -> LessonButton:
|
||||
return LessonButton.new(d.position, d.path_out_position)
|
||||
|
||||
func to_dict() -> Dictionary:
|
||||
return {
|
||||
position = position,
|
||||
path_out_position = path_out_position
|
||||
}
|
||||
|
||||
|
||||
enum FirstOrLast {
|
||||
First,
|
||||
Neither,
|
||||
Last
|
||||
}
|
||||
|
||||
|
||||
@export var color: = 0
|
||||
var flowers: Array[Flower] = []:
|
||||
set = set_flowers
|
||||
@export var flowers_export: Array[Dictionary] = []:
|
||||
set = set_flowers_export
|
||||
var lesson_buttons: Array[LessonButton] = []:
|
||||
set = set_lesson_buttons
|
||||
@export var lesson_buttons_export: Array[Dictionary] = []:
|
||||
set = set_lesson_buttons_export
|
||||
@export var is_first_or_last: = FirstOrLast.Neither
|
||||
|
||||
|
||||
func set_flowers_export(p_flowers_export: Array[Dictionary]) -> void:
|
||||
flowers_export = p_flowers_export
|
||||
flowers.clear()
|
||||
for flower_dict in flowers_export:
|
||||
flowers.append(Flower.from_dict(flower_dict))
|
||||
|
||||
|
||||
func set_flowers(p_flowers: Array[Flower]) -> void:
|
||||
flowers = p_flowers
|
||||
flowers_export.clear()
|
||||
for flower in flowers:
|
||||
flowers_export.append(flower.to_dict())
|
||||
|
||||
|
||||
func set_lesson_buttons_export(p_lesson_buttons_export: Array[Dictionary]) -> void:
|
||||
lesson_buttons_export = p_lesson_buttons_export
|
||||
lesson_buttons.clear()
|
||||
for lesson_button_dict in lesson_buttons_export:
|
||||
lesson_buttons.append(LessonButton.from_dict(lesson_button_dict))
|
||||
|
||||
|
||||
func set_lesson_buttons(p_lesson_buttons: Array[LessonButton]) -> void:
|
||||
lesson_buttons = p_lesson_buttons
|
||||
lesson_buttons_export.clear()
|
||||
for lesson_button in lesson_buttons:
|
||||
lesson_buttons_export.append(lesson_button.to_dict())
|
||||
@@ -1,133 +0,0 @@
|
||||
@tool
|
||||
extends Resource
|
||||
class_name GardensLayout
|
||||
|
||||
|
||||
class Flower:
|
||||
var color: = 0
|
||||
var type: = 0
|
||||
var position: = Vector2i.ZERO
|
||||
|
||||
func _init(p_color: int, p_type: int, p_position: Vector2i) -> void:
|
||||
color = p_color
|
||||
type = p_type
|
||||
position = p_position
|
||||
|
||||
static func from_dict(d: Dictionary) -> Flower:
|
||||
return Flower.new(d.color, d.type, d.position)
|
||||
|
||||
func to_dict() -> Dictionary:
|
||||
return {
|
||||
color = color,
|
||||
type = type,
|
||||
position = position,
|
||||
}
|
||||
|
||||
|
||||
class LessonButton:
|
||||
var is_boss: = false
|
||||
var position: = Vector2i.ZERO
|
||||
|
||||
func _init(p_is_boss: int, p_position: Vector2i) -> void:
|
||||
is_boss = p_is_boss
|
||||
position = p_position
|
||||
|
||||
static func from_dict(d: Dictionary) -> LessonButton:
|
||||
return LessonButton.new(d.is_boss, d.position)
|
||||
|
||||
func to_dict() -> Dictionary:
|
||||
return {
|
||||
is_boss = is_boss,
|
||||
position = position,
|
||||
}
|
||||
|
||||
|
||||
class PathMiddle:
|
||||
var position: = Vector2i.ZERO
|
||||
|
||||
func _init(p_position: Vector2i) -> void:
|
||||
position = p_position
|
||||
|
||||
static func from_dict(d: Dictionary) -> PathMiddle:
|
||||
return PathMiddle.new(d.position)
|
||||
|
||||
func to_dict() -> Dictionary:
|
||||
return {
|
||||
position = position,
|
||||
}
|
||||
|
||||
|
||||
enum FirstOrLast {
|
||||
First,
|
||||
Neither,
|
||||
Last
|
||||
}
|
||||
|
||||
|
||||
class Garden:
|
||||
var color: = 0
|
||||
var flowers: Array[Flower] = []
|
||||
var lesson_buttons: Array[LessonButton] = []
|
||||
var path_middles: Array[PathMiddle] = []
|
||||
var is_first_or_last: = FirstOrLast.Neither
|
||||
|
||||
func _init(p_color: int, p_flowers: Array[Flower], p_lesson_buttons: Array[LessonButton],
|
||||
p_path_middles: Array[PathMiddle], p_is_first_or_last: FirstOrLast) -> void:
|
||||
color = p_color
|
||||
flowers = p_flowers
|
||||
lesson_buttons = p_lesson_buttons
|
||||
path_middles = p_path_middles
|
||||
is_first_or_last = p_is_first_or_last
|
||||
|
||||
|
||||
static func from_dict(d: Dictionary) -> Garden:
|
||||
var flowers: Array[Flower] = []
|
||||
for flower_dict in d.flowers:
|
||||
flowers.append(Flower.from_dict(flower_dict))
|
||||
var lesson_buttons: Array[LessonButton] = []
|
||||
for lesson_button_dict in d.lesson_buttons:
|
||||
lesson_buttons.append(LessonButton.from_dict(lesson_button_dict))
|
||||
var path_middles: Array[PathMiddle] = []
|
||||
for path_middle_dict in d.path_middles:
|
||||
path_middles.append(PathMiddle.from_dict(path_middle_dict))
|
||||
return Garden.new(d.color, flowers, lesson_buttons, path_middles, d.is_first_or_last)
|
||||
|
||||
|
||||
func to_dict() -> Dictionary:
|
||||
var flowers_dict: Array[Dictionary] = []
|
||||
for flower in flowers:
|
||||
flowers_dict.append(flower.to_dict())
|
||||
var lesson_buttons_dict: Array[Dictionary] = []
|
||||
for lesson_button in lesson_buttons:
|
||||
lesson_buttons_dict.append(lesson_button.to_dict())
|
||||
var path_middles_dict: Array[Dictionary] = []
|
||||
for path_middle in path_middles:
|
||||
path_middles_dict.append(path_middle.to_dict())
|
||||
return {
|
||||
color = color,
|
||||
flowers = flowers_dict,
|
||||
lesson_buttons = lesson_buttons_dict,
|
||||
path_middles = path_middles_dict,
|
||||
is_first_or_last = is_first_or_last
|
||||
}
|
||||
|
||||
|
||||
@export var gardens_export: Array[Dictionary] = []:
|
||||
set = set_gardens_export
|
||||
var gardens: Array[Garden] = []:
|
||||
set = set_gardens
|
||||
|
||||
|
||||
func set_gardens_export(p_gardens_export: Array[Dictionary]) -> void:
|
||||
gardens_export = p_gardens_export
|
||||
gardens.clear()
|
||||
for garden_dict in gardens_export:
|
||||
gardens.append(Garden.from_dict(garden_dict))
|
||||
|
||||
|
||||
func set_gardens(p_gardens: Array[Garden]) -> void:
|
||||
gardens = p_gardens
|
||||
gardens_export.clear()
|
||||
for garden in gardens:
|
||||
gardens_export.append(garden.to_dict())
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
@tool
|
||||
extends Control
|
||||
|
||||
const garden_scene: = preload("res://resources/gardens/garden.tscn")
|
||||
|
||||
@export var gardens_layout: Array[GardenLayout]:
|
||||
set = set_gardens_layout
|
||||
|
||||
@onready var garden_parent: = %GardenParent
|
||||
|
||||
|
||||
func set_gardens_layout(p_gardens_layout: Array[GardenLayout]) -> void:
|
||||
gardens_layout = p_gardens_layout
|
||||
add_gardens()
|
||||
if garden_parent:
|
||||
await get_tree().process_frame
|
||||
set_up_path()
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
$ScrollContainer/Line2D.position.x = - $ScrollContainer.scroll_horizontal
|
||||
|
||||
|
||||
func add_gardens() -> void:
|
||||
if not garden_parent:
|
||||
return
|
||||
for child in garden_parent.get_children():
|
||||
child.queue_free()
|
||||
for garden_layout in gardens_layout:
|
||||
var garden: = garden_scene.instantiate()
|
||||
garden_parent.add_child(garden)
|
||||
garden.garden_layout = garden_layout
|
||||
|
||||
|
||||
func set_up_path() -> void:
|
||||
if not garden_parent:
|
||||
return
|
||||
var curve: = Curve2D.new()
|
||||
for i in gardens_layout.size():
|
||||
var garden_layout: = gardens_layout[i]
|
||||
var garden_control: = garden_parent.get_child(i)
|
||||
for lesson_button in garden_layout.lesson_buttons:
|
||||
var point_position: Vector2 = garden_parent.position + garden_control.position + Vector2(lesson_button.position)
|
||||
point_position += garden_control.get_button_size() / 2
|
||||
var point_in_position: = Vector2.ZERO
|
||||
if curve.point_count > 1:
|
||||
point_in_position = curve.get_point_position(curve.point_count - 1) + curve.get_point_out(curve.point_count - 1) - point_position
|
||||
curve.add_point(point_position, point_in_position, lesson_button.path_out_position)
|
||||
$ScrollContainer/Line2D.points = curve.get_baked_points()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_gardens_layout(gardens_layout)
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user