From c84c22944ca8ef67d8015be1ce7211850836769b Mon Sep 17 00:00:00 2001 From: psychowolf960 <119869367+psychowolf960@users.noreply.github.com> Date: Fri, 3 May 2024 20:57:16 +0200 Subject: [PATCH] Fixes --- .godot/editor/create_recent.Node | 5 +- .godot/editor/editor_layout.cfg | 10 +-- ...state-1a75c62674f0e88c69acf03f4897b8b1.cfg | 6 +- ...lding-1a75c62674f0e88c69acf03f4897b8b1.cfg | 4 +- .godot/editor/project_metadata.cfg | 4 +- .godot/editor/script_editor_cache.cfg | 6 +- scenes/mainmenu.tscn | 46 ++++++++---- scripts/mainmenu.gd | 74 ++++++++++++------- 8 files changed, 95 insertions(+), 60 deletions(-) diff --git a/.godot/editor/create_recent.Node b/.godot/editor/create_recent.Node index d2a827d..b5c2372 100644 --- a/.godot/editor/create_recent.Node +++ b/.godot/editor/create_recent.Node @@ -1,4 +1,6 @@ +Panel HBoxContainer +VBoxContainer TextureRect TextureButton Label @@ -9,7 +11,4 @@ Button SpinBox RayCast2D Timer -VBoxContainer Node2D -Panel -MarginContainer diff --git a/.godot/editor/editor_layout.cfg b/.godot/editor/editor_layout.cfg index f6474ae..03c0afe 100644 --- a/.godot/editor/editor_layout.cfg +++ b/.godot/editor/editor_layout.cfg @@ -4,7 +4,7 @@ dock_1_selected_tab_idx=0 dock_2_selected_tab_idx=0 dock_3_selected_tab_idx=0 dock_4_selected_tab_idx=0 -dock_5_selected_tab_idx=1 +dock_5_selected_tab_idx=0 dock_6_selected_tab_idx=0 dock_7_selected_tab_idx=0 dock_8_selected_tab_idx=0 @@ -13,7 +13,7 @@ dock_split_2=196 dock_split_3=0 dock_hsplit_1=0 dock_hsplit_2=270 -dock_hsplit_3=-270 +dock_hsplit_3=-284 dock_hsplit_4=0 dock_filesystem_split=0 dock_filesystem_display_mode=0 @@ -32,13 +32,13 @@ current_scene="res://scenes/mainmenu.tscn" center_split_offset=-288 selected_default_debugger_tab_idx=0 selected_main_editor_idx=2 -selected_bottom_panel_item=1 +selected_bottom_panel_item=0 [ScriptEditor] -open_scripts=["res://scripts/mainmenu.gd", "res://scenes/MarginContainer2.gd", "res://scripts/player.gd"] +open_scripts=["res://scripts/gamemanager.gd", "res://scripts/mainmenu.gd", "res://scenes/MarginContainer2.gd", "res://scripts/player.gd"] selected_script="res://scripts/mainmenu.gd" -open_help=[] +open_help=["Vector2"] script_split_offset=70 list_split_offset=0 diff --git a/.godot/editor/mainmenu.tscn-editstate-1a75c62674f0e88c69acf03f4897b8b1.cfg b/.godot/editor/mainmenu.tscn-editstate-1a75c62674f0e88c69acf03f4897b8b1.cfg index 6c3b6bf..7f66a8b 100644 --- a/.godot/editor/mainmenu.tscn-editstate-1a75c62674f0e88c69acf03f4897b8b1.cfg +++ b/.godot/editor/mainmenu.tscn-editstate-1a75c62674f0e88c69acf03f4897b8b1.cfg @@ -8,7 +8,7 @@ Anim={ "grid_snap_active": false, "grid_step": Vector2(8, 8), "grid_visibility": 1, -"ofs": Vector2(-260.112, -361.511), +"ofs": Vector2(-189.871, -207.983), "primary_grid_step": Vector2i(8, 8), "show_edit_locks": true, "show_guides": true, @@ -32,7 +32,7 @@ Anim={ "snap_rotation_step": 0.261799, "snap_scale": false, "snap_scale_step": 0.1, -"zoom": 0.793701 +"zoom": 0.66742 } 3D={ "fov": 70.01, @@ -172,4 +172,4 @@ Anim={ "zfar": 4000.01, "znear": 0.05 } -selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17095/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@61/@VBoxContainer@62/@PanelContainer@109/MainScreen/@CanvasItemEditor@9461/@VSplitContainer@9280/@HSplitContainer@9282/@HSplitContainer@9284/@Control@9285/@SubViewportContainer@9286/@SubViewport@9287/mainmenu/MarginContainer2")]) +selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17095/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@61/@VBoxContainer@62/@PanelContainer@109/MainScreen/@CanvasItemEditor@9461/@VSplitContainer@9280/@HSplitContainer@9282/@HSplitContainer@9284/@Control@9285/@SubViewportContainer@9286/@SubViewport@9287/mainmenu/MarginContainer2/HBoxContainer")]) diff --git a/.godot/editor/mainmenu.tscn-folding-1a75c62674f0e88c69acf03f4897b8b1.cfg b/.godot/editor/mainmenu.tscn-folding-1a75c62674f0e88c69acf03f4897b8b1.cfg index afe089b..173edaf 100644 --- a/.godot/editor/mainmenu.tscn-folding-1a75c62674f0e88c69acf03f4897b8b1.cfg +++ b/.godot/editor/mainmenu.tscn-folding-1a75c62674f0e88c69acf03f4897b8b1.cfg @@ -1,5 +1,5 @@ [folding] -node_unfolds=[NodePath("MarginContainer"), PackedStringArray("Layout", "Layout/Transform"), NodePath("MarginContainer/Panel"), PackedStringArray("Layout", "Layout/Container Sizing", "Layout/Transform", "Theme"), NodePath("MarginContainer/Panel/VBoxContainer"), PackedStringArray("Layout"), NodePath("MarginContainer2"), PackedStringArray("Layout", "Layout/Transform", "Localization"), NodePath("MarginContainer2/World1"), PackedStringArray("Layout", "Layout/Transform", "Layout/Container Sizing"), NodePath("MarginContainer2/World1/Label"), PackedStringArray("Layout", "Layout/Transform", "Theme Overrides", "Theme Overrides/fonts", "Theme Overrides/font_sizes", "Theme Overrides/styles", "theme_override_styles/normal"), NodePath("MarginContainer2/World1/TextureRect"), PackedStringArray("Theme", "Layout"), NodePath("MarginContainer2/World4"), PackedStringArray("Theme", "Visibility"), NodePath("MarginContainer2/World2"), PackedStringArray("Layout")] -resource_unfolds=["res://scenes/mainmenu.tscn::Theme_45hd1", PackedStringArray(), "res://scenes/mainmenu.tscn::StyleBoxFlat_2rwsq", PackedStringArray(), "res://scenes/mainmenu.tscn::StyleBoxFlat_8c08p", PackedStringArray("Border Width", "Expand Margins")] +node_unfolds=[NodePath("MarginContainer"), PackedStringArray("Layout", "Layout/Transform"), NodePath("MarginContainer/Panel"), PackedStringArray("Layout", "Layout/Container Sizing", "Layout/Transform", "Theme"), NodePath("MarginContainer/Panel/VBoxContainer"), PackedStringArray("Layout"), NodePath("MarginContainer2"), PackedStringArray("Layout", "Layout/Transform", "Localization"), NodePath("MarginContainer2/HBoxContainer"), PackedStringArray("Layout", "Localization", "Layout/Transform", "Layout/Container Sizing"), NodePath("MarginContainer2/HBoxContainer/World1"), PackedStringArray("Layout", "Layout/Transform", "Layout/Container Sizing", "Localization", "Focus"), NodePath("MarginContainer2/HBoxContainer/World1/Label2"), PackedStringArray("Layout", "Layout/Transform", "Theme Overrides", "Theme Overrides/fonts", "Theme Overrides/font_sizes", "Theme Overrides/styles", "theme_override_styles/normal"), NodePath("MarginContainer2/HBoxContainer/World1/Label1"), PackedStringArray("Theme", "Layout"), NodePath("MarginContainer2/HBoxContainer/World4"), PackedStringArray("Theme", "Visibility"), NodePath("MarginContainer2/HBoxContainer/World2"), PackedStringArray("Layout"), NodePath("MarginContainer2/Panel"), PackedStringArray("Layout", "Layout/Container Sizing", "Layout/Transform", "Theme", "Theme Overrides", "Theme Overrides/styles", "theme_override_styles/panel", "Localization")] +resource_unfolds=["res://scenes/mainmenu.tscn::Theme_45hd1", PackedStringArray(), "res://scenes/mainmenu.tscn::StyleBoxFlat_2rwsq", PackedStringArray(), "res://scenes/mainmenu.tscn::StyleBoxFlat_8c08p", PackedStringArray("Border Width", "Expand Margins"), "res://scenes/mainmenu.tscn::StyleBoxFlat_llkcd", PackedStringArray("Border Width", "Expand Margins")] nodes_folded=[] diff --git a/.godot/editor/project_metadata.cfg b/.godot/editor/project_metadata.cfg index 7029bfa..194e2ba 100644 --- a/.godot/editor/project_metadata.cfg +++ b/.godot/editor/project_metadata.cfg @@ -14,7 +14,7 @@ run_reload_scripts=true [recent_files] scenes=["res://scenes/mainmenu.tscn", "res://scenes/level1.tscn", "res://scenes/player.tscn", "res://scenes/game.tscn", "res://scenes/optionsmenu.tscn", "res://scenes/slime.tscn", "res://scenes/coin.tscn", "res://mainmenu.tscn", "res://slime.tscn"] -scripts=["res://scenes/MarginContainer2.gd", "res://scripts/player.gd", "res://mainmenu.gd", "Node", "res://scripts/killzone.gd", "res://scenes/optionsmenu.gd", "res://scripts/gamemanager.gd", "res://slime.gd", "res://scripts/coin.gd", "res://scripts/game_manager.gd"] +scripts=["res://scripts/gamemanager.gd", "Vector2", "res://scenes/MarginContainer2.gd", "res://scripts/player.gd", "res://mainmenu.gd", "Node", "res://scripts/killzone.gd", "res://scenes/optionsmenu.gd", "res://slime.gd", "res://scripts/coin.gd"] [linked_properties] @@ -55,7 +55,7 @@ last_selected_language="GDScript" [color_picker] -recent_presets=PackedColorArray(0.409567, 0.586235, 0.964558, 1, 0.181615, 0.374112, 0.837668, 1, 0.398291, 0.628022, 0.796577, 1, 0.840567, 0.833517, 0, 1, 0.835294, 0.835294, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0.6, 0.151276, 0.151276, 0.151276, 1) +recent_presets=PackedColorArray(0.181615, 0.374112, 0.837668, 1, 0.398291, 0.628022, 0.796577, 1, 0.840567, 0.833517, 0, 1, 0.835294, 0.835294, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0.6, 0.151276, 0.151276, 0.151276, 1, 0.6, 0.6, 0.6, 0.305882, 0.122252, 0.122252, 0.122252, 0.305882) [scripts_panel] diff --git a/.godot/editor/script_editor_cache.cfg b/.godot/editor/script_editor_cache.cfg index ae8bd18..15d3c38 100644 --- a/.godot/editor/script_editor_cache.cfg +++ b/.godot/editor/script_editor_cache.cfg @@ -109,11 +109,11 @@ state={ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 0, +"column": 42, "folded_lines": Array[int]([]), "h_scroll_position": 0, -"row": 25, -"scroll_position": 5.0, +"row": 66, +"scroll_position": 60.8, "selection": false, "syntax_highlighter": "GDScript" } diff --git a/scenes/mainmenu.tscn b/scenes/mainmenu.tscn index f2d3e2b..598d2ac 100644 --- a/scenes/mainmenu.tscn +++ b/scenes/mainmenu.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://cedft3vy5hg68"] +[gd_scene load_steps=9 format=3 uid="uid://cedft3vy5hg68"] [ext_resource type="Script" path="res://scripts/mainmenu.gd" id="1_qj2ne"] [ext_resource type="FontFile" uid="uid://dbjl1e6kdxpl6" path="res://assets/fonts/PixelOperator8.ttf" id="2_h05dh"] @@ -30,6 +30,10 @@ expand_margin_top = 5.0 expand_margin_right = 5.0 expand_margin_bottom = 5.0 +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_llkcd"] +bg_color = Color(0.121569, 0.121569, 0.121569, 0.305882) +expand_margin_top = 10.0 + [node name="mainmenu" type="Control"] layout_mode = 3 anchors_preset = 15 @@ -92,18 +96,23 @@ layout_mode = 1 anchors_preset = 5 anchor_left = 0.5 anchor_right = 0.5 -offset_left = -243.345 +offset_left = -539.0 offset_top = 30.0 -offset_right = -29.345 -offset_bottom = 184.0 +offset_right = -6.0 +offset_bottom = 203.0 grow_horizontal = 2 scale = Vector2(2, 2) script = ExtResource("3_rb1ce") -[node name="World1" type="Control" parent="MarginContainer2"] +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer2"] +layout_mode = 2 +size_flags_horizontal = 4 + +[node name="World1" type="Control" parent="MarginContainer2/HBoxContainer"] +y_sort_enabled = true layout_mode = 2 -[node name="Label" type="Label" parent="MarginContainer2/World1"] +[node name="Label2" type="Label" parent="MarginContainer2/HBoxContainer/World1"] layout_mode = 1 anchors_preset = 5 anchor_left = 0.5 @@ -117,7 +126,7 @@ theme_override_font_sizes/font_size = 24 theme_override_styles/normal = SubResource("StyleBoxFlat_8c08p") text = "World 1" -[node name="TextureRect" type="TextureRect" parent="MarginContainer2/World1"] +[node name="Label1" type="TextureRect" parent="MarginContainer2/HBoxContainer/World1"] layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 @@ -134,10 +143,10 @@ texture = ExtResource("3_tlb1w") expand_mode = 1 stretch_mode = 5 -[node name="World4" type="Control" parent="MarginContainer2"] +[node name="World4" type="Control" parent="MarginContainer2/HBoxContainer"] layout_mode = 2 -[node name="Label" type="Label" parent="MarginContainer2/World4"] +[node name="Level4" type="Label" parent="MarginContainer2/HBoxContainer/World4"] layout_mode = 1 anchors_preset = 5 anchor_left = 0.5 @@ -150,7 +159,7 @@ theme_override_fonts/font = ExtResource("2_h05dh") theme_override_font_sizes/font_size = 24 text = "World 4" -[node name="TextureRect" type="TextureRect" parent="MarginContainer2/World4"] +[node name="Level5" type="TextureRect" parent="MarginContainer2/HBoxContainer/World4"] layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 @@ -167,10 +176,10 @@ texture = ExtResource("3_tlb1w") expand_mode = 1 stretch_mode = 5 -[node name="World2" type="Control" parent="MarginContainer2"] +[node name="World2" type="Control" parent="MarginContainer2/HBoxContainer"] layout_mode = 2 -[node name="Label" type="Label" parent="MarginContainer2/World2"] +[node name="Label" type="Label" parent="MarginContainer2/HBoxContainer/World2"] layout_mode = 1 anchors_preset = 5 anchor_left = 0.5 @@ -183,7 +192,7 @@ theme_override_fonts/font = ExtResource("2_h05dh") theme_override_font_sizes/font_size = 24 text = "World 2" -[node name="TextureRect" type="TextureRect" parent="MarginContainer2/World2"] +[node name="TextureRect" type="TextureRect" parent="MarginContainer2/HBoxContainer/World2"] layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 @@ -200,10 +209,10 @@ texture = ExtResource("3_tlb1w") expand_mode = 1 stretch_mode = 5 -[node name="World3" type="Control" parent="MarginContainer2"] +[node name="World3" type="Control" parent="MarginContainer2/HBoxContainer"] layout_mode = 2 -[node name="Label" type="Label" parent="MarginContainer2/World3"] +[node name="Label" type="Label" parent="MarginContainer2/HBoxContainer/World3"] layout_mode = 1 anchors_preset = 5 anchor_left = 0.5 @@ -216,7 +225,7 @@ theme_override_fonts/font = ExtResource("2_h05dh") theme_override_font_sizes/font_size = 24 text = "World 3" -[node name="TextureRect" type="TextureRect" parent="MarginContainer2/World3"] +[node name="TextureRect" type="TextureRect" parent="MarginContainer2/HBoxContainer/World3"] layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 @@ -233,6 +242,11 @@ texture = ExtResource("3_tlb1w") expand_mode = 1 stretch_mode = 5 +[node name="Panel" type="Panel" parent="MarginContainer2"] +layout_mode = 2 +size_flags_vertical = 0 +theme_override_styles/panel = SubResource("StyleBoxFlat_llkcd") + [connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Play" to="." method="_on_play_pressed"] [connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Options" to="." method="_on_options_pressed"] [connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Exit" to="." method="_on_exit_pressed"] diff --git a/scripts/mainmenu.gd b/scripts/mainmenu.gd index cb96108..2838c92 100644 --- a/scripts/mainmenu.gd +++ b/scripts/mainmenu.gd @@ -1,16 +1,17 @@ extends Control -class World: +class World extends Control: var label: String var x: int func _init(initial_label: String): self.label = initial_label self.x = 0 -@onready var world_1 = $MarginContainer2/World1 -@onready var world_4 = $MarginContainer2/World4 -@onready var world_2 = $MarginContainer2/World2 -@onready var world_3 = $MarginContainer2/World3 + +@onready var world_1 = $MarginContainer2/HBoxContainer/World1 +@onready var world_4 = $MarginContainer2/HBoxContainer/World4 +@onready var world_2 = $MarginContainer2/HBoxContainer/World2 +@onready var world_3 = $MarginContainer2/HBoxContainer/World3 var middle_index: int var animation_duration: float @@ -20,30 +21,50 @@ func animate_sliding(direction: String): if direction == "right": _start_animation_right() -@onready var worlds = [world_1, world_2, world_3, world_4] -var world_indices = {world_1: 1, world_2: 2, world_3: 3, world_4: 4} +@onready var worlds = [] +var world_indices = {} + var animation_in_progress = false +func _ready(): + var world_1_obj = World.new("World 1") + var world_2_obj = World.new("World 2") + var world_3_obj = World.new("World 3") + var world_4_obj = World.new("World 4") + + world_1.add_child(world_1_obj) + world_2.add_child(world_2_obj) + world_3.add_child(world_3_obj) + world_4.add_child(world_4_obj) + + worlds.append(world_1_obj) + worlds.append(world_2_obj) + worlds.append(world_3_obj) + worlds.append(world_4_obj) + + world_indices[world_1_obj] = 1 + world_indices[world_2_obj] = 2 + world_indices[world_3_obj] = 3 + world_indices[world_4_obj] = 4 + func _start_animation_right(): animation_in_progress = true - for world in worlds: - if world_indices[world] == 4: - world_indices[world] = 1 - else: - world_indices[world] += 1 - for world in worlds: - if world_indices[world] == 1: - world.rect_position = Vector2(-185, 0) - world.show() - elif world_indices[world] == 2: - world.rect_position = Vector2(0, 0) - world.show() - elif world_indices[world] == 3: - world.rect_position = Vector2(185, 0) - world.show() - elif world_indices[world] == 4: - world.rect_position = Vector2(185, 0) - world.hide() + var hbox = $MarginContainer2/HBoxContainer + var temp_worlds = worlds.duplicate() + for i in range(temp_worlds.size()): + if world_indices[temp_worlds[i]] == 4: + world_indices[temp_worlds[i]] = 1 + else: + world_indices[temp_worlds[i]] += 1 + for i in range(temp_worlds.size()): + if world_indices[temp_worlds[i]] == 1: + hbox.move_child(temp_worlds[i].get_parent(), 0) + elif world_indices[temp_worlds[i]] == 2: + hbox.move_child(temp_worlds[i].get_parent(), 1) + elif world_indices[temp_worlds[i]] == 3: + hbox.move_child(temp_worlds[i].get_parent(), 2) + elif world_indices[temp_worlds[i]] == 4: + hbox.move_child(temp_worlds[i].get_parent(), 3) animation_in_progress = false func _on_play_pressed(): @@ -61,5 +82,6 @@ func _input(event: InputEvent): print("gay") animate_sliding("right") elif Input.is_action_just_pressed("ui_left") and not animation_in_progress: + print(world_indices) print("work") - animate_sliding("left") + print(worlds)