summaryrefslogtreecommitdiff
path: root/UI
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-10-24 18:31:08 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-10-24 18:31:08 +0200
commita495681453c97578cc4a408d6919c6879524a603 (patch)
tree649c813cf26370a6ae762038b46c8e5fb075ea64 /UI
parent6db6465d1b938ec494cd66c9984bff5cc14bde11 (diff)
next commit
Diffstat (limited to 'UI')
-rw-r--r--UI/Camera.gd47
-rw-r--r--UI/Lobby.tscn23
-rw-r--r--UI/lobby_theme.tres8
3 files changed, 66 insertions, 12 deletions
diff --git a/UI/Camera.gd b/UI/Camera.gd
index 926ab36..3009ed2 100644
--- a/UI/Camera.gd
+++ b/UI/Camera.gd
@@ -4,10 +4,14 @@ extends Camera2D
signal zoomed(zoom: Vector2)
-var is_in_drag_mode = false
-var drag_anchor = Vector2.ZERO
+var is_in_drag_mode := false
+var drag_anchor := Vector2.ZERO
-@export var speed = 25
+var is_in_edge_mode := false
+var edge := Vector2.ZERO
+@export var edge_scroll_margin := 4.0
+
+@export var speed := 25
@export_group("Zoom", "zoom")
@export var zoom_min: float = 0.5
@@ -28,6 +32,8 @@ func _ready():
)
zoomed.emit(zoom)
)
+
+ Input.mouse_mode = Input.MOUSE_MODE_CONFINED
func _input(event):
@@ -45,17 +51,52 @@ func _input(event):
zoom = Vector2(new_zoom, new_zoom)
zoomed.emit(zoom)
+
if event.is_action_pressed("camera_drag"):
is_in_drag_mode = true
drag_anchor = get_global_mouse_position()
+ Input.set_default_cursor_shape(Input.CURSOR_MOVE)
elif event.is_action_released("camera_drag"):
is_in_drag_mode = false
+ Input.set_default_cursor_shape(Input.CURSOR_ARROW)
+
+
+ if event is InputEventMouseMotion:
+ is_in_edge_mode = false
+ edge = Vector2.ZERO
+ if get_global_mouse_position().x - edge_scroll_margin <= get_rect().position.x:
+ is_in_edge_mode = true
+ edge += Vector2.LEFT
+ if get_global_mouse_position().y - edge_scroll_margin <= get_rect().position.y:
+ is_in_edge_mode = true
+ edge += Vector2.UP
+ if get_global_mouse_position().x + edge_scroll_margin >= get_rect().end.x:
+ is_in_edge_mode = true
+ edge += Vector2.RIGHT
+ if get_global_mouse_position().y + edge_scroll_margin >= get_rect().end.y:
+ is_in_edge_mode = true
+ edge += Vector2.DOWN
+ edge = edge.normalized()
+
+ if event is InputEventMouseButton and event.is_pressed():
+ Input.mouse_mode = Input.MOUSE_MODE_CONFINED
+ elif event.is_action_pressed("mouse_escape"):
+ Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _process(delta):
if is_in_drag_mode:
set_new_position(global_position + drag_anchor - get_global_mouse_position())
+ if is_in_edge_mode:
+ set_new_position(
+ lerp(
+ global_position,
+ global_position + (edge * speed),
+ speed * delta
+ )
+ )
+
var direction_h = Input.get_axis("ui_left", "ui_right")
var direction_v = Input.get_axis("ui_up", "ui_down")
diff --git a/UI/Lobby.tscn b/UI/Lobby.tscn
index 4cf9a8b..02f32ce 100644
--- a/UI/Lobby.tscn
+++ b/UI/Lobby.tscn
@@ -1,7 +1,8 @@
-[gd_scene load_steps=3 format=3 uid="uid://r45j806p4a74"]
+[gd_scene load_steps=4 format=3 uid="uid://r45j806p4a74"]
[ext_resource type="Script" path="res://UI/lobby.gd" id="1_mm4gt"]
[ext_resource type="Theme" uid="uid://bt84t61hrvoyn" path="res://UI/lobby_theme.tres" id="2_syjfh"]
+[ext_resource type="Texture2D" uid="uid://ci7qydmwbanbp" path="res://Stages/Wintermaul/Assets/thumbnail.png" id="3_8r1n2"]
[node name="Lobby" type="Control"]
layout_mode = 3
@@ -42,10 +43,10 @@ size_flags_horizontal = 3
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/PanelContainer"]
layout_mode = 2
-theme_override_constants/margin_left = 4
-theme_override_constants/margin_top = 4
-theme_override_constants/margin_right = 4
-theme_override_constants/margin_bottom = 4
+theme_override_constants/margin_left = 16
+theme_override_constants/margin_top = 16
+theme_override_constants/margin_right = 16
+theme_override_constants/margin_bottom = 16
[node name="PlayersList" type="VBoxContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/PanelContainer/MarginContainer"]
unique_name_in_owner = true
@@ -74,26 +75,38 @@ theme = ExtResource("2_syjfh")
[node name="MapButton" type="Button" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/Maps"]
layout_mode = 2
+mouse_default_cursor_shape = 2
toggle_mode = true
text = "Wintermaul"
[node name="MapButton2" type="Button" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/Maps"]
layout_mode = 2
+mouse_default_cursor_shape = 2
toggle_mode = true
text = "Squares"
+[node name="TextureRect" type="TextureRect" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer"]
+custom_minimum_size = Vector2(300, 260)
+layout_mode = 2
+texture = ExtResource("3_8r1n2")
+expand_mode = 1
+stretch_mode = 4
+
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 8
+theme = ExtResource("2_syjfh")
[node name="StartButton" type="Button" parent="MarginContainer/VBoxContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
+mouse_default_cursor_shape = 2
text = "Start"
[node name="CancelButton" type="Button" parent="MarginContainer/VBoxContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
+mouse_default_cursor_shape = 2
text = "Cancel"
[connection signal="pressed" from="MarginContainer/VBoxContainer/VBoxContainer/StartButton" to="." method="_on_start_button_pressed"]
diff --git a/UI/lobby_theme.tres b/UI/lobby_theme.tres
index f983c2f..0307ae1 100644
--- a/UI/lobby_theme.tres
+++ b/UI/lobby_theme.tres
@@ -1,16 +1,16 @@
[gd_resource type="Theme" load_steps=3 format=3 uid="uid://bt84t61hrvoyn"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vhn61"]
-content_margin_left = 4.0
+content_margin_left = 8.0
content_margin_top = 4.0
-content_margin_right = 4.0
+content_margin_right = 8.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4s0gx"]
-content_margin_left = 4.0
+content_margin_left = 8.0
content_margin_top = 4.0
-content_margin_right = 4.0
+content_margin_right = 8.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 1)