[gd_scene format=3 uid="uid://dlbuo46n6q238"]

[ext_resource type="Theme" uid="uid://dx26d6py3n8xi" path="res://resources/main_ui_theme.tres" id="1_wmt4g"]
[ext_resource type="AudioStream" uid="uid://b7dgmblbcm0cj" path="res://assets/music/menu_theme.OGG" id="2_0dhhe"]
[ext_resource type="Texture2D" uid="uid://b47b6tt142b25" path="res://assets/sprites/main_menu.BMP" id="3_xgjk6"]
[ext_resource type="AudioStream" uid="uid://5ndo4w06umsa" path="res://assets/sounds/SE020.WAV" id="4_somrw"]
[ext_resource type="AudioStream" uid="uid://d1hacs4t5qni1" path="res://assets/sounds/SE015.WAV" id="5_ybnw1"]
[ext_resource type="Texture2D" uid="uid://8kr4vmvhu03p" path="res://assets/sprites/menu_selector_flame.BMP" id="6_5jfhr"]

[sub_resource type="AtlasTexture" id="AtlasTexture_wu84c"]
atlas = ExtResource("3_xgjk6")
region = Rect2(0, 0, 800, 400)

[sub_resource type="AtlasTexture" id="AtlasTexture_8ln24"]
atlas = ExtResource("3_xgjk6")
region = Rect2(0, 600, 800, 348)

[sub_resource type="AtlasTexture" id="AtlasTexture_a8gd2"]
atlas = ExtResource("3_xgjk6")
region = Rect2(800, 0, 745, 745)

[sub_resource type="AtlasTexture" id="AtlasTexture_bqqt6"]
atlas = ExtResource("3_xgjk6")
region = Rect2(-1, 995, 800, 43)

[sub_resource type="AtlasTexture" id="AtlasTexture_rtw2f"]
atlas = ExtResource("3_xgjk6")
region = Rect2(0, 950, 800, 45)

[sub_resource type="AtlasTexture" id="AtlasTexture_oa1go"]
atlas = ExtResource("3_xgjk6")
region = Rect2(800, 744, 515, 210)

[sub_resource type="GDScript" id="GDScript_hover"]
resource_name = "ButtonHoverSFX"
script/source = "extends VBoxContainer

@onready var hover_sfx: AudioStreamPlayer = $HoverSFX
@onready var left_indicator: Control = %LeftIndicator
@onready var right_indicator: Control = %RightIndicator
@onready var click_sfx: AudioStreamPlayer = $ClickSFX

func _ready() -> void:
	for child in get_children():
		if child is TextureButton:
			child.mouse_entered.connect(_on_button_hovered.bind(child))
			child.mouse_exited.connect(_on_button_unhovered)
			child.pressed.connect(_on_button_clicked)

func _on_button_hovered(button: TextureButton) -> void:
	hover_sfx.play()
	var button_center := button.global_position + button.size / 2.0
	left_indicator.global_position = Vector2(button.global_position.x, button_center.y)
	right_indicator.global_position = Vector2(button.global_position.x + button.size.x, button_center.y)
	left_indicator.visible = true
	right_indicator.visible = true

func _on_button_unhovered() -> void:
	left_indicator.visible = false
	right_indicator.visible = false
	
func _on_button_clicked() -> void:
	click_sfx.play()
"

[sub_resource type="AtlasTexture" id="AtlasTexture_tbmy8"]
atlas = ExtResource("3_xgjk6")
region = Rect2(1550, 0, 330, 50)

[sub_resource type="AtlasTexture" id="AtlasTexture_jk1qb"]
atlas = ExtResource("3_xgjk6")
region = Rect2(1550, 300, 330, 50)

[sub_resource type="GDScript" id="GDScript_bqqt6"]
resource_name = "StartButton"
script/source = "extends TextureButton

const COMBAT_SCENE = preload(\"res://scenes/views/battle_view.tscn\")
const UNIT_SCENE = preload(\"res://prefabs/unit.tscn\")
const PLAYER_ALLEGIANCE = preload(\"res://resources/allegiance_types/player_allegiance.tres\")
const ENEMY_ALLEGIANCE = preload(\"res://resources/allegiance_types/enemy_allegiance.tres\")

func _pressed() -> void:
	await get_tree().create_timer(0.2).timeout
	var combat_instance := COMBAT_SCENE.instantiate()
	var combat_map: CombatMap = combat_instance.find_child(\"CombatMap\")

	var player_unit: Unit = UNIT_SCENE.instantiate()
	player_unit.stat_template = UnitStats.new()
	player_unit.info_template = UnitInfo.new()
	player_unit.info_template.name = \"Putit\"
	player_unit.allegiance_template = PLAYER_ALLEGIANCE
	combat_map.deploy_unit(player_unit, Vector2i(3, 3))

	var enemy_unit: Unit = UNIT_SCENE.instantiate()
	enemy_unit.stat_template = UnitStats.new()
	enemy_unit.info_template = UnitInfo.new()
	enemy_unit.info_template.name = \"Putit\"
	enemy_unit.allegiance_template = ENEMY_ALLEGIANCE
	combat_map.deploy_unit(enemy_unit, Vector2i(6, 3))

	var tree := get_tree()
	var root := tree.root
	var current_scene := tree.current_scene
	root.remove_child(current_scene)
	current_scene.queue_free()
	root.add_child(combat_instance)
	tree.current_scene = combat_instance
"

[sub_resource type="AtlasTexture" id="AtlasTexture_5dd4i"]
atlas = ExtResource("3_xgjk6")
region = Rect2(1550, 60, 330, 50)

[sub_resource type="AtlasTexture" id="AtlasTexture_lgwnu"]
atlas = ExtResource("3_xgjk6")
region = Rect2(1550, 360, 330, 50)

[sub_resource type="AtlasTexture" id="AtlasTexture_flqon"]
atlas = ExtResource("3_xgjk6")
region = Rect2(1550, 120, 330, 50)

[sub_resource type="AtlasTexture" id="AtlasTexture_rcqid"]
atlas = ExtResource("3_xgjk6")
region = Rect2(1550, 420, 330, 50)

[sub_resource type="AtlasTexture" id="AtlasTexture_1ajci"]
atlas = ExtResource("3_xgjk6")
region = Rect2(1550, 180, 330, 50)

[sub_resource type="AtlasTexture" id="AtlasTexture_7b55j"]
atlas = ExtResource("3_xgjk6")
region = Rect2(1550, 480, 330, 50)

[sub_resource type="AtlasTexture" id="AtlasTexture_5pajh"]
atlas = ExtResource("3_xgjk6")
region = Rect2(1550, 240, 330, 50)

[sub_resource type="AtlasTexture" id="AtlasTexture_j7ex8"]
atlas = ExtResource("3_xgjk6")
region = Rect2(1550, 540, 330, 50)

[sub_resource type="GDScript" id="GDScript_wu84c"]
resource_name = "ExitButton"
script/source = "extends TextureButton

func _pressed():
	await get_tree().create_timer(0.2).timeout
	get_tree().quit(0)
"

[sub_resource type="AtlasTexture" id="AtlasTexture_tcusk"]
atlas = ExtResource("3_xgjk6")
region = Rect2(1320, 746, 25, 22)

[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_8ln24"]
blend_mode = 1

[sub_resource type="AtlasTexture" id="AtlasTexture_8egab"]
atlas = ExtResource("6_5jfhr")
region = Rect2(0, 0, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_gw5y6"]
atlas = ExtResource("6_5jfhr")
region = Rect2(140, 0, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_svtp6"]
atlas = ExtResource("6_5jfhr")
region = Rect2(280, 0, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_1dfpl"]
atlas = ExtResource("6_5jfhr")
region = Rect2(420, 0, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_qywvv"]
atlas = ExtResource("6_5jfhr")
region = Rect2(0, 140, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_3wgol"]
atlas = ExtResource("6_5jfhr")
region = Rect2(140, 140, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_1acrt"]
atlas = ExtResource("6_5jfhr")
region = Rect2(280, 140, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_vr8o3"]
atlas = ExtResource("6_5jfhr")
region = Rect2(420, 140, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_1a85y"]
atlas = ExtResource("6_5jfhr")
region = Rect2(0, 280, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_hl5e0"]
atlas = ExtResource("6_5jfhr")
region = Rect2(140, 280, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_engjn"]
atlas = ExtResource("6_5jfhr")
region = Rect2(280, 280, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_6h3lr"]
atlas = ExtResource("6_5jfhr")
region = Rect2(420, 280, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_dj67d"]
atlas = ExtResource("6_5jfhr")
region = Rect2(0, 420, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_6vcge"]
atlas = ExtResource("6_5jfhr")
region = Rect2(140, 420, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_ip0br"]
atlas = ExtResource("6_5jfhr")
region = Rect2(280, 420, 140, 140)

[sub_resource type="AtlasTexture" id="AtlasTexture_xyero"]
atlas = ExtResource("6_5jfhr")
region = Rect2(420, 420, 140, 140)

[sub_resource type="SpriteFrames" id="SpriteFrames_tcusk"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_8egab")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gw5y6")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_svtp6")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1dfpl")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qywvv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3wgol")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1acrt")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vr8o3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1a85y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hl5e0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_engjn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_6h3lr")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dj67d")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_6vcge")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ip0br")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xyero")
}],
"loop": true,
"name": &"default",
"speed": 10.0
}]

[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_rtw2f"]
blend_mode = 1

[sub_resource type="AtlasTexture" id="AtlasTexture_hstxw"]

[node name="MainMenu" type="Control" unique_id=528000941]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_wmt4g")

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="." unique_id=1976575731]
stream = ExtResource("2_0dhhe")
autoplay = true
parameters/looping = true

[node name="Background" type="Control" parent="." unique_id=801579001]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="Top" type="TextureRect" parent="Background" unique_id=2030397311]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 400.0
grow_horizontal = 2
texture = SubResource("AtlasTexture_wu84c")

[node name="Bottom" type="TextureRect" parent="Background" unique_id=736979824]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -348.0
grow_horizontal = 2
grow_vertical = 0
texture = SubResource("AtlasTexture_8ln24")

[node name="MagicCircle" type="TextureRect" parent="Background" unique_id=1610277203]
self_modulate = Color(1, 1, 1, 0.6156863)
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -72.5
offset_bottom = 72.5
grow_horizontal = 2
grow_vertical = 2
texture = SubResource("AtlasTexture_a8gd2")

[node name="BottomBorder" type="TextureRect" parent="Background" unique_id=2048064934]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -45.0
grow_horizontal = 2
grow_vertical = 0
texture = SubResource("AtlasTexture_bqqt6")

[node name="TopBorder" type="TextureRect" parent="Background" unique_id=812827884]
layout_mode = 0
offset_right = 800.0
offset_bottom = 45.0
texture = SubResource("AtlasTexture_rtw2f")

[node name="Logo" type="TextureRect" parent="Background" unique_id=815631332]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.5
anchor_right = 0.5
offset_left = -257.5
offset_top = 50.0
offset_right = 257.5
offset_bottom = 210.0
grow_horizontal = 2
texture = SubResource("AtlasTexture_oa1go")

[node name="Buttons" type="VBoxContainer" parent="." unique_id=1869378860]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.29375
anchor_top = 0.5566667
anchor_right = 0.70625
anchor_bottom = 1.0
offset_left = 1.5258789e-05
offset_bottom = -55.0
grow_horizontal = 2
grow_vertical = 0
alignment = 1
script = SubResource("GDScript_hover")
metadata/_edit_use_anchors_ = true

[node name="HoverSFX" type="AudioStreamPlayer" parent="Buttons" unique_id=256435189]
stream = ExtResource("4_somrw")

[node name="ClickSFX" type="AudioStreamPlayer" parent="Buttons" unique_id=2129807302]
stream = ExtResource("5_ybnw1")

[node name="StartButton" type="TextureButton" parent="Buttons" unique_id=973041905]
layout_mode = 2
size_flags_horizontal = 4
texture_normal = SubResource("AtlasTexture_tbmy8")
texture_hover = SubResource("AtlasTexture_jk1qb")
script = SubResource("GDScript_bqqt6")

[node name="LoadButton" type="TextureButton" parent="Buttons" unique_id=2075751086]
layout_mode = 2
size_flags_horizontal = 4
texture_normal = SubResource("AtlasTexture_5dd4i")
texture_hover = SubResource("AtlasTexture_lgwnu")

[node name="EushullyButton" type="TextureButton" parent="Buttons" unique_id=412756984]
layout_mode = 2
size_flags_horizontal = 4
texture_normal = SubResource("AtlasTexture_flqon")
texture_hover = SubResource("AtlasTexture_rcqid")

[node name="OptionsButton" type="TextureButton" parent="Buttons" unique_id=1002907774]
layout_mode = 2
size_flags_horizontal = 4
texture_normal = SubResource("AtlasTexture_1ajci")
texture_hover = SubResource("AtlasTexture_7b55j")

[node name="ExitButton" type="TextureButton" parent="Buttons" unique_id=286651369]
layout_mode = 2
size_flags_horizontal = 4
texture_normal = SubResource("AtlasTexture_5pajh")
texture_hover = SubResource("AtlasTexture_j7ex8")
script = SubResource("GDScript_wu84c")

[node name="LeftIndicator" type="Control" parent="." unique_id=100000001]
unique_name_in_owner = true
visible = false
anchors_preset = 0
offset_right = 50.0
offset_bottom = 50.0

[node name="Sprite2D" type="Sprite2D" parent="LeftIndicator" unique_id=1510731086]
position = Vector2(0, 15)
texture = SubResource("AtlasTexture_tcusk")

[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="LeftIndicator" unique_id=1906133697]
material = SubResource("CanvasItemMaterial_8ln24")
scale = Vector2(0.75, 0.75)
sprite_frames = SubResource("SpriteFrames_tcusk")
autoplay = "default"
frame = 12
frame_progress = 0.23836201

[node name="RightIndicator" type="Control" parent="." unique_id=100000002]
unique_name_in_owner = true
visible = false
anchors_preset = 0
offset_right = 50.0
offset_bottom = 50.0

[node name="Sprite2D" type="Sprite2D" parent="RightIndicator" unique_id=979863490]
position = Vector2(0, 15)
texture = SubResource("AtlasTexture_tcusk")

[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="RightIndicator" unique_id=1047794140]
material = SubResource("CanvasItemMaterial_rtw2f")
scale = Vector2(0.75, 0.75)
sprite_frames = SubResource("SpriteFrames_tcusk")
autoplay = "default"
frame = 12
frame_progress = 0.23836201

[node name="TextureRect" type="TextureRect" parent="." unique_id=968381019]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
texture = SubResource("AtlasTexture_hstxw")
