From da78e7f2872159862b9f1b6c465a912c4868f371 Mon Sep 17 00:00:00 2001 From: Sch1nken Date: Sat, 23 Mar 2024 16:18:30 +0100 Subject: [PATCH] Overhauled camera --- CameraPivot.gd | 77 ++++++++ Game.tscn | 24 ++- Globals/GameData.gd | 2 - Globals/GameSettings.gd | 6 + InsectTiles/BuildGhost.gd | 3 + Multiplayer/LobbyInfo.gd | 2 +- Multiplayer/Multiplayer.gd | 13 +- Networking/Networking.gd | 21 +++ Networking/Networking.tscn | 5 +- Networking/WSClient/multiplayer_client.gd | 2 +- Testbed/Table.tres | 4 +- .../wood_table_001_diff_4k.jpg.import | 10 +- Tile/Tile.gd | 3 + {Testbed => UI/Rules}/Rules.gd | 20 ++- {Testbed => UI/Rules}/Rules.tscn | 2 +- UI/Settings/Settings.gd | 40 +++++ UI/Settings/Settings.tscn | 165 ++++++++++++++++++ UI/join_menu.gd | 6 +- main_menu.gd => UI/main_menu.gd | 17 +- main_menu.tscn => UI/main_menu.tscn | 23 +-- project.godot | 11 +- 21 files changed, 385 insertions(+), 71 deletions(-) create mode 100644 CameraPivot.gd create mode 100644 Globals/GameSettings.gd create mode 100644 Networking/Networking.gd rename {Testbed => UI/Rules}/Rules.gd (76%) rename {Testbed => UI/Rules}/Rules.tscn (99%) create mode 100644 UI/Settings/Settings.gd create mode 100644 UI/Settings/Settings.tscn rename main_menu.gd => UI/main_menu.gd (77%) rename main_menu.tscn => UI/main_menu.tscn (91%) diff --git a/CameraPivot.gd b/CameraPivot.gd new file mode 100644 index 0000000..2c28813 --- /dev/null +++ b/CameraPivot.gd @@ -0,0 +1,77 @@ +extends Node3D + +@onready var azimuth_pivot = $AzimuthPivot + +@onready var spring_arm_3d = $AzimuthPivot/SpringArm3D + +var zoom_tween: Tween + +var min_zoom_distance: float = 2.0 +var max_zoom_distance: float = 10.0 + +var min_camera_angle: float = 15.0 +var max_camera_angle: float = 75.0 + +var rotating: bool = false +var rotate_2d_position: Vector2 = Vector2.ZERO +var rotate_2d_position_old: Vector2 = Vector2.ZERO +var old_y_rotation: float = 0.0 +var old_x_rotation: float = 0.0 + +@onready var camera = $AzimuthPivot/SpringArm3D/Camera + +var world_distance_limit: float = 25.0 + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + if Input.is_action_just_pressed("zoom_camera_in"): + if zoom_tween != null: + zoom_tween.kill() + zoom_tween = get_tree().create_tween() + var new_dist = clamp(spring_arm_3d.spring_length / 1.2, min_zoom_distance, max_zoom_distance) + zoom_tween.tween_property(spring_arm_3d, "spring_length", new_dist, 0.25) + #spring_arm_3d.spring_length -= 0.5 + if Input.is_action_just_pressed("zoom_camera_out"): + if zoom_tween != null: + zoom_tween.kill() + zoom_tween = get_tree().create_tween() + var new_dist = clamp(spring_arm_3d.spring_length * 1.2, min_zoom_distance, max_zoom_distance) + zoom_tween.tween_property(spring_arm_3d, "spring_length", new_dist, 0.25) + #spring_arm_3d.spring_length += 0.5 + + if Input.is_action_just_pressed("rotate_camera"): + rotating = true + # get screen position of cursor? + rotate_2d_position = get_viewport().get_mouse_position() + rotate_2d_position_old = get_viewport().get_mouse_position() + old_y_rotation = rotation.y + old_x_rotation = azimuth_pivot.rotation.x + if Input.is_action_just_released("rotate_camera"): + rotating = false + + if rotating: + rotate_2d_position = get_viewport().get_mouse_position() + var mouse_diff = rotate_2d_position - rotate_2d_position_old + rotation.y = old_y_rotation - mouse_diff.x * 0.005 + azimuth_pivot.rotation.x = old_x_rotation - mouse_diff.y * 0.005 + pass + + if Input.is_action_pressed("camera_left"): + position -= transform.basis.x * 0.2 + if Input.is_action_pressed("camera_right"): + position += transform.basis.x * 0.2 + + if Input.is_action_pressed("camera_up"): + position -= transform.basis.z * 0.2 + if Input.is_action_pressed("camera_down"): + position += transform.basis.z * 0.2 + + if position.length() > world_distance_limit: + position = position.normalized() * world_distance_limit + + + + if azimuth_pivot.rotation_degrees.x > -min_camera_angle: + azimuth_pivot.rotation_degrees.x = -min_camera_angle + if azimuth_pivot.rotation_degrees.x < -max_camera_angle: + azimuth_pivot.rotation_degrees.x = -max_camera_angle diff --git a/Game.tscn b/Game.tscn index d7e70cc..5763ba0 100644 --- a/Game.tscn +++ b/Game.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=22 format=3 uid="uid://bx0bbrwdr0h40"] [ext_resource type="Script" path="res://Game.gd" id="1_dgt1j"] -[ext_resource type="Script" path="res://Misc/RTSCamera3D.gd" id="1_dtmfo"] +[ext_resource type="Script" path="res://CameraPivot.gd" id="2_71xp1"] [ext_resource type="Script" path="res://HexGrid3D/HexGrid3D.gd" id="2_suxca"] [ext_resource type="Script" path="res://GameEndChecker.gd" id="2_ufkw3"] [ext_resource type="Material" uid="uid://dv2oo7hlc5nyy" path="res://Testbed/Table.tres" id="5_u4p4p"] @@ -11,8 +11,8 @@ [ext_resource type="Texture2D" uid="uid://d2i5vboeyq8qx" path="res://UI/hex_white.svg" id="11_cl0he"] [ext_resource type="Script" path="res://GameOverMenu.gd" id="11_ffmss"] [ext_resource type="Script" path="res://MenuButtons.gd" id="11_urihv"] +[ext_resource type="PackedScene" uid="uid://8ffmln680deh" path="res://UI/Rules/Rules.tscn" id="12_g7rxm"] [ext_resource type="Script" path="res://TurnTexture.gd" id="12_kjwp8"] -[ext_resource type="PackedScene" uid="uid://8ffmln680deh" path="res://Testbed/Rules.tscn" id="12_xhim1"] [sub_resource type="PlaneMesh" id="PlaneMesh_cu5ir"] material = ExtResource("5_u4p4p") @@ -36,10 +36,8 @@ fog_light_color = Color(0, 0, 0, 1) fog_density = 0.3 [sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_41x5h"] -dof_blur_far_enabled = true dof_blur_far_distance = 15.0 dof_blur_far_transition = 10.0 -dof_blur_near_enabled = true [sub_resource type="Gradient" id="Gradient_pctcs"] interpolation_mode = 2 @@ -61,10 +59,18 @@ modulate_color = Color(1, 1, 1, 0.639216) [node name="Game" type="Node3D"] script = ExtResource("1_dgt1j") -[node name="Camera3D" type="Camera3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 0.5, 0.866025, 0, -0.866025, 0.5, 0, 6, 5) -script = ExtResource("1_dtmfo") -edge_panning_enabled = false +[node name="CameraPivot" type="Node3D" parent="."] +script = ExtResource("2_71xp1") + +[node name="AzimuthPivot" type="Node3D" parent="CameraPivot"] +transform = Transform3D(1, 0, 0, 0, 0.374607, 0.927184, 0, -0.927184, 0.374607, 0, 0, 0) + +[node name="SpringArm3D" type="SpringArm3D" parent="CameraPivot/AzimuthPivot"] +collision_mask = 0 +spring_length = 7.0 + +[node name="Camera" type="Camera3D" parent="CameraPivot/AzimuthPivot/SpringArm3D"] +current = true [node name="GameEndChecker" type="Node" parent="."] script = ExtResource("2_ufkw3") @@ -253,7 +259,7 @@ text = "Menu" layout_mode = 2 text = "Rules" -[node name="Rules" parent="." instance=ExtResource("12_xhim1")] +[node name="Rules" parent="." instance=ExtResource("12_g7rxm")] visible = false [node name="GameOverMenu" type="CanvasLayer" parent="."] diff --git a/Globals/GameData.gd b/Globals/GameData.gd index 753ac92..bf7303b 100644 --- a/Globals/GameData.gd +++ b/Globals/GameData.gd @@ -1,7 +1,5 @@ extends Node -const WEBSOCKET_ENDPOINT: String = "wss://dev.bytesandpieces.xyz:9088" - # By default, peer_id is 1. This should make everything work flawless for local hotseat var peer_id: int = 1 diff --git a/Globals/GameSettings.gd b/Globals/GameSettings.gd new file mode 100644 index 0000000..c1cc952 --- /dev/null +++ b/Globals/GameSettings.gd @@ -0,0 +1,6 @@ +extends Node + +const DEFAULT_LOBBY_ENDPOITN: String = "wss://dev.bytesandpieces.xyz:9088" + + +var LOBBY_ENDPOINT: String = "wss://dev.bytesandpieces.xyz:9088" diff --git a/InsectTiles/BuildGhost.gd b/InsectTiles/BuildGhost.gd index 9d0b800..438405b 100644 --- a/InsectTiles/BuildGhost.gd +++ b/InsectTiles/BuildGhost.gd @@ -14,6 +14,9 @@ func _ready() -> void: else: hexagon_small.set_surface_override_material(0, resource.material_white.duplicate()) + if is_black: + hexagon_small.rotation.y = PI + var mat: StandardMaterial3D = hexagon_small.get_surface_override_material(0) mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA mat.albedo_color.a = 0.5 diff --git a/Multiplayer/LobbyInfo.gd b/Multiplayer/LobbyInfo.gd index ab0fbc8..b6dca80 100644 --- a/Multiplayer/LobbyInfo.gd +++ b/Multiplayer/LobbyInfo.gd @@ -24,5 +24,5 @@ func _process(delta): func _on_button_pressed(): - WSClient.stop() + #WSClient.stop() get_tree().change_scene_to_file("res://main_menu.tscn") diff --git a/Multiplayer/Multiplayer.gd b/Multiplayer/Multiplayer.gd index f5df305..10f7397 100644 --- a/Multiplayer/Multiplayer.gd +++ b/Multiplayer/Multiplayer.gd @@ -23,7 +23,7 @@ func _mp_peer_disconnected(id: int) -> void: # Display message that other end terminated the connection # 1 is always the server # So we better get going back to the main menu? - WSClient.close() + #WSClient.close() get_tree().change_scene_to_file("res://main_menu.tscn") # Maybe just display a "server close return @@ -32,11 +32,13 @@ func _log(msg): print(msg) func _mp_server_connected(): - _log("[Multiplayer] Server connected (I am %d)" % WSClient.rtc_mp.get_unique_id()) + pass + #_log("[Multiplayer] Server connected (I am %d)" % WSClient.rtc_mp.get_unique_id()) #pass_initial_playerdata.rpc_id(1, multiplayer.get_unique_id(), GameState.player_name) func _mp_server_disconnect(): - _log("[Multiplayer] Server disconnected (I am %d)" % WSClient.rtc_mp.get_unique_id()) + pass + #_log("[Multiplayer] Server disconnected (I am %d)" % WSClient.rtc_mp.get_unique_id()) #get_tree().change_scene_to_file("res://main_menu.tscn") func _mp_peer_connected(id: int): @@ -47,11 +49,6 @@ func _mp_peer_connected(id: int): @onready var lobby_info = $LobbyInfo - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - @rpc("any_peer", "call_local") func load_game() -> void: # Hide menu diff --git a/Networking/Networking.gd b/Networking/Networking.gd new file mode 100644 index 0000000..847b395 --- /dev/null +++ b/Networking/Networking.gd @@ -0,0 +1,21 @@ +extends Node + +func create_enet_server(port: int) -> void: + # use timer to send udp broadcast packets to notify other LAN clients + pass + +func connect_with_webrtc() -> void: + pass + +func connect_with_enet() -> void: + pass + +func lan_mode() -> void: + pass + +func online_mode() -> void: + pass + +func offline_mode() -> void: + multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new() + pass diff --git a/Networking/Networking.tscn b/Networking/Networking.tscn index 5fdbee8..b073f97 100644 --- a/Networking/Networking.tscn +++ b/Networking/Networking.tscn @@ -1,3 +1,6 @@ -[gd_scene format=3 uid="uid://cigm5ol2f8b4b"] +[gd_scene load_steps=2 format=3 uid="uid://cigm5ol2f8b4b"] + +[ext_resource type="Script" path="res://Networking/Networking.gd" id="1_y8syy"] [node name="Networking" type="Node"] +script = ExtResource("1_y8syy") diff --git a/Networking/WSClient/multiplayer_client.gd b/Networking/WSClient/multiplayer_client.gd index ba20927..588c637 100644 --- a/Networking/WSClient/multiplayer_client.gd +++ b/Networking/WSClient/multiplayer_client.gd @@ -60,7 +60,7 @@ func _connected(id, use_mesh): if use_mesh: rtc_mp.create_mesh(id) elif id == 1: - rtc_mp.create_server() + rtc_mp.create_servertp() else: rtc_mp.create_client(id) multiplayer.multiplayer_peer = rtc_mp diff --git a/Testbed/Table.tres b/Testbed/Table.tres index e5c4778..87172d1 100644 --- a/Testbed/Table.tres +++ b/Testbed/Table.tres @@ -11,9 +11,9 @@ shader = ExtResource("1_edhah") shader_parameter/albedo = Color(1, 1, 1, 1) shader_parameter/distance_fade_min = 0.0 shader_parameter/distance_fade_max = 0.0 -shader_parameter/roughness = 0.5 +shader_parameter/roughness = 0.8 shader_parameter/metallic_texture_channel = null -shader_parameter/specular = 0.5 +shader_parameter/specular = 0.6 shader_parameter/metallic = 0.5 shader_parameter/uv1_scale = Vector3(1, 1, 1) shader_parameter/uv1_offset = Vector3(0, 0, 0) diff --git a/Testbed/textures/wood_table_001_diff_4k.jpg.import b/Testbed/textures/wood_table_001_diff_4k.jpg.import index 42b065c..7eedec8 100644 --- a/Testbed/textures/wood_table_001_diff_4k.jpg.import +++ b/Testbed/textures/wood_table_001_diff_4k.jpg.import @@ -3,21 +3,19 @@ importer="texture" type="CompressedTexture2D" uid="uid://cilgpyanfb3a8" -path.s3tc="res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.s3tc.ctex" -path.etc2="res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.etc2.ctex" +path="res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.ctex" metadata={ -"imported_formats": ["s3tc_bptc", "etc2_astc"], -"vram_texture": true +"vram_texture": false } [deps] source_file="res://Testbed/textures/wood_table_001_diff_4k.jpg" -dest_files=["res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.s3tc.ctex", "res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.etc2.ctex"] +dest_files=["res://.godot/imported/wood_table_001_diff_4k.jpg-e80b891959669a4b412f9ae52dcbed08.ctex"] [params] -compress/mode=2 +compress/mode=0 compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 diff --git a/Tile/Tile.gd b/Tile/Tile.gd index a351398..ea5e94c 100644 --- a/Tile/Tile.gd +++ b/Tile/Tile.gd @@ -65,6 +65,9 @@ func _ready() -> void: mat.next_pass = hover_shader.duplicate() + if is_black: + hexagon_small.rotation.y = PI + GameEvents.insect_selected.connect(_on_insect_selected) GameEvents.insect_placed.connect(_on_insect_placed) GameEvents.insect_placement_cancelled.connect(_on_insect_placement_cancelled, CONNECT_DEFERRED) diff --git a/Testbed/Rules.gd b/UI/Rules/Rules.gd similarity index 76% rename from Testbed/Rules.gd rename to UI/Rules/Rules.gd index 196eca5..bd1bc6e 100644 --- a/Testbed/Rules.gd +++ b/UI/Rules/Rules.gd @@ -19,7 +19,7 @@ func show_panel() -> void: var tween = get_tree().create_tween() tween.set_parallel(true) tween.tween_method(tween_blur, 0.0, 1.0, 0.5).set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_IN_OUT) - tween.tween_property(margin_container2, "position:y", 0.0, 0.5).set_trans(Tween.TRANS_SPRING).set_ease(Tween.EASE_OUT) + tween.tween_property(margin_container2, "position:y", 0.0, 0.5).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT) # Called when the node enters the scene tree for the first time. func _ready(): @@ -30,11 +30,6 @@ func tween_blur(val: float) -> void: mat.set_shader_parameter("lod", val) pass -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - - func _on_button_pressed(label: NodePath, category: String = ""): for child in margin_container.get_children(): child.visible = false @@ -44,10 +39,17 @@ func _on_button_pressed(label: NodePath, category: String = ""): # hacky general.get_node(label).visible = true +func hide_panel() -> void: + var tween = get_tree().create_tween() + tween.set_parallel(true) + tween.tween_method(tween_blur, 1.0, 0.0, 0.5).set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_IN_OUT) + tween.tween_property(margin_container2, "position:y", 700, 0.5).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_IN) + + tween.finished.connect(_on_panel_hidden) -func _on_ant_pressed(extra_arg_0, extra_arg_1): - pass # Replace with function body. +func _on_panel_hidden() -> void: + visible = false func _on_close_button_pressed(): - visible = false + hide_panel() diff --git a/Testbed/Rules.tscn b/UI/Rules/Rules.tscn similarity index 99% rename from Testbed/Rules.tscn rename to UI/Rules/Rules.tscn index 426574e..dfacfca 100644 --- a/Testbed/Rules.tscn +++ b/UI/Rules/Rules.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://8ffmln680deh"] -[ext_resource type="Script" path="res://Testbed/Rules.gd" id="1_qbtgw"] +[ext_resource type="Script" path="res://UI/Rules/Rules.gd" id="1_qbtgw"] [ext_resource type="Shader" path="res://Testbed/UIBlur.gdshader" id="2_ux84o"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_h3smw"] diff --git a/UI/Settings/Settings.gd b/UI/Settings/Settings.gd new file mode 100644 index 0000000..bfe7719 --- /dev/null +++ b/UI/Settings/Settings.gd @@ -0,0 +1,40 @@ +extends Control + +@onready var panel_container = $PanelContainer +@onready var margin_container2 = $Pivot/MarginContainer + +var mat: ShaderMaterial + +func show_panel() -> void: + margin_container2.position.y = 700 + mat.set_shader_parameter("lod", 0) + + visible = true + + var tween = get_tree().create_tween() + tween.set_parallel(true) + tween.tween_method(tween_blur, 0.0, 1.0, 0.5).set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_IN_OUT) + tween.tween_property(margin_container2, "position:y", 0.0, 0.5).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT) + +# Called when the node enters the scene tree for the first time. +func _ready(): + mat = panel_container.material + pass # Replace with function body. + +func tween_blur(val: float) -> void: + mat.set_shader_parameter("lod", val) + pass + +func hide_panel() -> void: + var tween = get_tree().create_tween() + tween.set_parallel(true) + tween.tween_method(tween_blur, 1.0, 0.0, 0.5).set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_IN_OUT) + tween.tween_property(margin_container2, "position:y", 700, 0.5).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_IN) + + tween.finished.connect(_on_panel_hidden) + +func _on_panel_hidden() -> void: + visible = false + +func _on_cancel_pressed(): + hide_panel() diff --git a/UI/Settings/Settings.tscn b/UI/Settings/Settings.tscn new file mode 100644 index 0000000..bbe939c --- /dev/null +++ b/UI/Settings/Settings.tscn @@ -0,0 +1,165 @@ +[gd_scene load_steps=4 format=3 uid="uid://cua6l3r0yh82y"] + +[ext_resource type="Script" path="res://UI/Settings/Settings.gd" id="1_bxt58"] +[ext_resource type="Shader" path="res://Testbed/UIBlur.gdshader" id="1_gnf7a"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_2dtbe"] +shader = ExtResource("1_gnf7a") +shader_parameter/lod = 1.0 + +[node name="Settings" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_bxt58") + +[node name="PanelContainer" type="PanelContainer" parent="."] +self_modulate = Color(1, 1, 1, 0.392157) +material = SubResource("ShaderMaterial_2dtbe") +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Pivot" 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="MarginContainer" type="MarginContainer" parent="Pivot"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 50 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 50 +theme_override_constants/margin_bottom = 50 + +[node name="PanelContainer" type="PanelContainer" parent="Pivot/MarginContainer"] +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="Pivot/MarginContainer/PanelContainer"] +layout_mode = 2 +theme_override_constants/margin_left = 15 +theme_override_constants/margin_top = 15 +theme_override_constants/margin_right = 15 +theme_override_constants/margin_bottom = 15 + +[node name="VBoxContainer" type="VBoxContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer"] +layout_mode = 2 + +[node name="TabContainer" type="TabContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="General" type="PanelContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer"] +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/General"] +layout_mode = 2 +theme_override_constants/margin_left = 15 +theme_override_constants/margin_top = 15 +theme_override_constants/margin_right = 15 +theme_override_constants/margin_bottom = 15 + +[node name="General" type="VBoxContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/General/MarginContainer"] +layout_mode = 2 + +[node name="VBoxContainer" type="HBoxContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/General/MarginContainer/General"] +layout_mode = 2 +theme_override_constants/separation = 15 + +[node name="Label" type="Label" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/General/MarginContainer/General/VBoxContainer"] +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 +text = "Lobby Server URL" + +[node name="LineEdit" type="LineEdit" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/General/MarginContainer/General/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Button" type="Button" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/General/MarginContainer/General/VBoxContainer"] +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 +text = "Reset to default" + +[node name="Graphics" type="PanelContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer"] +visible = false +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/Graphics"] +layout_mode = 2 +theme_override_constants/margin_left = 15 +theme_override_constants/margin_top = 15 +theme_override_constants/margin_right = 15 +theme_override_constants/margin_bottom = 15 + +[node name="General" type="VBoxContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/Graphics/MarginContainer"] +layout_mode = 2 + +[node name="VBoxContainer" type="HBoxContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/Graphics/MarginContainer/General"] +layout_mode = 2 +theme_override_constants/separation = 15 + +[node name="Label" type="Label" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/Graphics/MarginContainer/General/VBoxContainer"] +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 +text = "Depth of Field Blur" + +[node name="LineEdit" type="CheckButton" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/Graphics/MarginContainer/General/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Controls" type="PanelContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer"] +visible = false +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/Controls"] +layout_mode = 2 +theme_override_constants/margin_left = 15 +theme_override_constants/margin_top = 15 +theme_override_constants/margin_right = 15 +theme_override_constants/margin_bottom = 15 + +[node name="General" type="VBoxContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/Controls/MarginContainer"] +layout_mode = 2 + +[node name="VBoxContainer" type="HBoxContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/Controls/MarginContainer/General"] +layout_mode = 2 +theme_override_constants/separation = 15 + +[node name="Label" type="Label" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/Controls/MarginContainer/General/VBoxContainer"] +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 +text = "Camera Rotation Speed" + +[node name="SpinBox" type="SpinBox" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/TabContainer/Controls/MarginContainer/General/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +alignment = 2 + +[node name="VBoxContainer" type="HBoxContainer" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="Save" type="Button" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Save" + +[node name="Cancel" type="Button" parent="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Cancel" + +[connection signal="pressed" from="Pivot/MarginContainer/PanelContainer/MarginContainer/VBoxContainer/VBoxContainer/Cancel" to="." method="_on_cancel_pressed"] diff --git a/UI/join_menu.gd b/UI/join_menu.gd index 4b225fe..e1a1031 100644 --- a/UI/join_menu.gd +++ b/UI/join_menu.gd @@ -3,7 +3,8 @@ extends Control @onready var lobby_code_input = $PanelContainer/MarginContainer/VBoxContainer/HBoxContainer/LobbyCodeInput func _ready(): - WSClient.lobby_joined.connect(_on_lobby_joined) + #WSClient.lobby_joined.connect(_on_lobby_joined) + pass func _on_lobby_joined(lobby: String) -> void: GameData.lobby_code = lobby @@ -18,4 +19,5 @@ func _on_back_button_pressed(): func _on_connect_button_pressed(): GameData.is_player_black = true - WSClient.start(GameData.WEBSOCKET_ENDPOINT, lobby_code_input.text, false) + #WSClient.start(GameData.WEBSOCKET_ENDPOINT, lobby_code_input.text, false) + pass diff --git a/main_menu.gd b/UI/main_menu.gd similarity index 77% rename from main_menu.gd rename to UI/main_menu.gd index 9b179b8..e28a13c 100644 --- a/main_menu.gd +++ b/UI/main_menu.gd @@ -4,6 +4,7 @@ extends Control @onready var lan_button = $PanelContainer/MarginContainer/VBoxContainer/LANButton @onready var rules = $Rules +@onready var settings = $Settings # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -18,10 +19,7 @@ func _on_lobby_joined(lobby: String) -> void: GameData.lobby_code = lobby get_tree().change_scene_to_file("res://Multiplayer/Multiplayer.tscn") - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass + func _on_host_button_pressed(): GameData.is_player_black = false @@ -37,23 +35,22 @@ func _on_exit_button_pressed(): func _on_rules_button_pressed(): - # https://bacon.bytesandpieces.xyz/swarm/ - #OS.shell_open("https://www.ultraboardgames.com/hive/game-rules.php") rules.show_panel() - pass # Replace with function body. func _on_online_button_pressed(): - #GameData.is_player_black = false - #WSClient.start(GameData.WEBSOCKET_ENDPOINT, "", false) pass # Replace with function body. func _on_online_button_2_pressed(): get_tree().change_scene_to_file("res://UI/join_menu.tscn") - pass # Replace with function body. func _on_local_button_pressed(): GameData.is_hot_seat = true get_tree().change_scene_to_file("res://Game.tscn") + + +func _on_settings_button_pressed(): + settings.show_panel() + pass # Replace with function body. diff --git a/main_menu.tscn b/UI/main_menu.tscn similarity index 91% rename from main_menu.tscn rename to UI/main_menu.tscn index 78dc4d6..dcca085 100644 --- a/main_menu.tscn +++ b/UI/main_menu.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=5 format=3 uid="uid://dogu37xma5vsp"] +[gd_scene load_steps=6 format=3 uid="uid://dogu37xma5vsp"] -[ext_resource type="Script" path="res://main_menu.gd" id="1_q3q3u"] +[ext_resource type="Script" path="res://UI/main_menu.gd" id="1_q3q3u"] [ext_resource type="Script" path="res://DisconnectInfo.gd" id="2_2fkdc"] -[ext_resource type="PackedScene" uid="uid://8ffmln680deh" path="res://Testbed/Rules.tscn" id="2_7qmw6"] +[ext_resource type="PackedScene" uid="uid://8ffmln680deh" path="res://UI/Rules/Rules.tscn" id="2_7qmw6"] +[ext_resource type="PackedScene" uid="uid://cua6l3r0yh82y" path="res://UI/Settings/Settings.tscn" id="3_2m2r5"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_47fa1"] bg_color = Color(0, 0, 0, 1) @@ -17,6 +18,7 @@ grow_vertical = 2 script = ExtResource("1_q3q3u") [node name="PanelContainer" type="PanelContainer" parent="."] +custom_minimum_size = Vector2(300, 0) layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 @@ -69,16 +71,13 @@ text = "Multiplayer" [node name="LocalButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] layout_mode = 2 -text = "Local (Hotseat)" +text = "Local" [node name="OnlineButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] layout_mode = 2 +disabled = true text = "Online" -[node name="OnlineButton2" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] -layout_mode = 2 -text = "Online (Join)" - [node name="LANButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] layout_mode = 2 disabled = true @@ -89,7 +88,6 @@ layout_mode = 2 [node name="SettingsButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"] layout_mode = 2 -disabled = true text = "Settings" [node name="HSeparator3" type="HSeparator" parent="PanelContainer/MarginContainer/VBoxContainer"] @@ -107,6 +105,10 @@ text = "Exit" visible = false layout_mode = 1 +[node name="Settings" parent="." instance=ExtResource("3_2m2r5")] +visible = false +layout_mode = 1 + [node name="DisconnectInfo" type="Control" parent="."] visible = false layout_mode = 1 @@ -151,9 +153,8 @@ text = "Ok" [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/SingleplayerButton" to="." method="_on_rules_button_pressed"] [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/LocalButton" to="." method="_on_local_button_pressed"] [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/OnlineButton" to="." method="_on_online_button_pressed"] -[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/OnlineButton2" to="." method="_on_online_button_2_pressed"] [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/LANButton" to="." method="_on_rules_button_pressed"] -[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/SettingsButton" to="." method="_on_rules_button_pressed"] +[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/SettingsButton" to="." method="_on_settings_button_pressed"] [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/RulesButton" to="." method="_on_rules_button_pressed"] [connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/ExitButton" to="." method="_on_exit_button_pressed"] [connection signal="pressed" from="DisconnectInfo/PanelContainer/MarginContainer/VBoxContainer/Button" to="DisconnectInfo" method="_on_button_pressed"] diff --git a/project.godot b/project.godot index 9d9e4e8..99581fb 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="Swarm" -run/main_scene="res://main_menu.tscn" +run/main_scene="res://UI/main_menu.tscn" config/features=PackedStringArray("4.2", "Mobile") config/icon="res://icon.svg" @@ -65,17 +65,12 @@ zoom_camera_out={ } rotate_camera={ "deadzone": 0.5, -"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"canceled":false,"pressed":false,"double_click":false,"script":null) -] -} -drag_camera={ -"deadzone": 0.5, -"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":3,"canceled":false,"pressed":false,"double_click":false,"script":null) +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":4,"position":Vector2(138, 8),"global_position":Vector2(142, 49),"factor":1.0,"button_index":3,"canceled":false,"pressed":true,"double_click":false,"script":null) ] } deselect_tile={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null) +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(106, 15),"global_position":Vector2(110, 56),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null) ] } select_tile={