Overhauled camera

This commit is contained in:
Sch1nken 2024-03-23 16:18:30 +01:00
parent 5fe8f22ccb
commit da78e7f287
21 changed files with 385 additions and 71 deletions

77
CameraPivot.gd Normal file
View file

@ -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

View file

@ -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="."]

View file

@ -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

6
Globals/GameSettings.gd Normal file
View file

@ -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"

View file

@ -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

View file

@ -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")

View file

@ -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

21
Networking/Networking.gd Normal file
View file

@ -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

View file

@ -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")

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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()

View file

@ -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"]

40
UI/Settings/Settings.gd Normal file
View file

@ -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()

165
UI/Settings/Settings.tscn Normal file
View file

@ -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"]

View file

@ -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

View file

@ -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.

View file

@ -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"]

View file

@ -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={