diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-10-24 18:31:08 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-10-24 18:31:08 +0200 |
commit | a495681453c97578cc4a408d6919c6879524a603 (patch) | |
tree | 649c813cf26370a6ae762038b46c8e5fb075ea64 | |
parent | 6db6465d1b938ec494cd66c9984bff5cc14bde11 (diff) |
next commit
-rw-r--r-- | Game/Client.gd | 17 | ||||
-rw-r--r-- | Game/Selection/selection_rectangle.gd | 6 | ||||
-rw-r--r-- | Stages/Wintermaul/Assets/thumbnail.png | bin | 0 -> 45394 bytes | |||
-rw-r--r-- | Stages/Wintermaul/Assets/thumbnail.png.import | 34 | ||||
-rw-r--r-- | Stages/Wintermaul/HUD.gd | 129 | ||||
-rw-r--r-- | Stages/Wintermaul/HUD.tscn | 8 | ||||
-rw-r--r-- | Stages/Wintermaul/Wintermaul.tscn | 1 | ||||
-rw-r--r-- | Stages/Wintermaul/wintermaul.gd | 6 | ||||
-rw-r--r-- | Towers/Tower.gd | 104 | ||||
-rw-r--r-- | Towers/Tower.tscn | 35 | ||||
-rw-r--r-- | UI/Camera.gd | 47 | ||||
-rw-r--r-- | UI/Lobby.tscn | 23 | ||||
-rw-r--r-- | UI/lobby_theme.tres | 8 | ||||
-rw-r--r-- | project.godot | 10 |
14 files changed, 379 insertions, 49 deletions
diff --git a/Game/Client.gd b/Game/Client.gd index 98a8e6c..f4fd1e6 100644 --- a/Game/Client.gd +++ b/Game/Client.gd @@ -6,6 +6,8 @@ signal stage_state_changed(state: State) @warning_ignore("unused_signal") signal placed_tower(tower: Tower) +signal multi_select_finished + var state: State : set(value): @@ -35,13 +37,13 @@ func place_tower(tower: Tower): tower.owner_id = network_id tower.name = "Tower@" + str(network_id) + "@" + str(Time.get_ticks_usec()) - tower.attack_range = [ - current_stage.map.tile_set.tile_size.x * 2, - current_stage.map.tile_set.tile_size.x * 3, - current_stage.map.tile_set.tile_size.x * 4, - ].pick_random() - tower.attack_power = [1, 2, 3, 4].pick_random() - tower.attack_speed = [1, 2, 3, 4].pick_random() + #tower.attack_range = [ + #current_stage.map.tile_set.tile_size.x * 2, + #current_stage.map.tile_set.tile_size.x * 3, + #current_stage.map.tile_set.tile_size.x * 4, + #].pick_random() + #tower.attack_power = [1, 2, 3, 4].pick_random() + #tower.attack_speed = [1, 2, 3, 4].pick_random() current_stage.place_tower.rpc(inst_to_dict(tower.to_network_data())) @@ -69,6 +71,7 @@ func multi_select(layer: int): selection_area.select.connect(func(nodes): for node in nodes: Client.select_tower(node) + multi_select_finished.emit() ) get_tree().current_scene.add_child(selection_area) diff --git a/Game/Selection/selection_rectangle.gd b/Game/Selection/selection_rectangle.gd index 944372d..40619ba 100644 --- a/Game/Selection/selection_rectangle.gd +++ b/Game/Selection/selection_rectangle.gd @@ -30,11 +30,15 @@ func _process(_delta: float) -> void: queue_redraw() if is_active and Input.is_action_just_released("select"): - for area in get_overlapping_areas(): + var areas = get_overlapping_areas() + for area in areas: if "is_selected" in area.get_parent(): if area.get_parent().owner_id == multiplayer.get_unique_id(): area.get_parent().is_selected = true + if not areas.is_empty(): + Client.multi_select_finished.emit() + size = Vector2.ZERO queue_redraw() diff --git a/Stages/Wintermaul/Assets/thumbnail.png b/Stages/Wintermaul/Assets/thumbnail.png Binary files differnew file mode 100644 index 0000000..42f9567 --- /dev/null +++ b/Stages/Wintermaul/Assets/thumbnail.png diff --git a/Stages/Wintermaul/Assets/thumbnail.png.import b/Stages/Wintermaul/Assets/thumbnail.png.import new file mode 100644 index 0000000..0cef320 --- /dev/null +++ b/Stages/Wintermaul/Assets/thumbnail.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ci7qydmwbanbp" +path="res://.godot/imported/thumbnail.png-a553bc324925dcdfb3e3587d2082a340.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Stages/Wintermaul/Assets/thumbnail.png" +dest_files=["res://.godot/imported/thumbnail.png-a553bc324925dcdfb3e3587d2082a340.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Stages/Wintermaul/HUD.gd b/Stages/Wintermaul/HUD.gd index 6eeb7da..1349bda 100644 --- a/Stages/Wintermaul/HUD.gd +++ b/Stages/Wintermaul/HUD.gd @@ -2,6 +2,15 @@ class_name HUD extends CanvasLayer +var selection_groups := {} +var selected_group := "": + set(value): + redraw_multiselect(selected_group, value) + selected_group = value + redraw_select(selection_groups[selected_group][0].get_hud()) + +signal attack_value_changed(value: int) + @onready var time: Label = %Time @onready var money: Label = %Money @onready var income: Label = %Income @@ -39,25 +48,38 @@ func _ready(): Client.placed_tower.connect(func(tower: Tower): tower.selected.connect(func(): var hud_data = tower.get_hud() - hud_data.name = tower.name - var groups = {"md5:1": [], "md5_2": []} - var selected_group = "md5" + var multi_select_hud_data = TextureRect.new() + multi_select_hud_data.name = tower.name + multi_select_hud_data.modulate = Color(0.5, 0.5, 0.5) + var texture = AtlasTexture.new() + texture.atlas = preload("res://core_outdoor.png") + texture.region = Rect2(400, 432, 32, 48) + multi_select_hud_data.texture = texture + + if not tower.selection_group_id in selection_groups: + selection_groups[tower.selection_group_id] = [] + selection_groups[tower.selection_group_id].append(tower) + multi_select_hud_data.add_to_group(tower.selection_group_id) + # TODO: build groups from current component configurations matches. md5 of property values? # TODO: do in tower.gd at select? + # TODO: probably do here at the selected signal and add to groups var at top if Tower.selected_towers.size() == 1: %SelectionContainer.visible = true %MultiSelectionContainer.visible = false - %SelectionData.add_child(hud_data) - %MultiSelectionList.add_child(hud_data.duplicate()) + redraw_select(hud_data) + %MultiSelectionList.add_child(multi_select_hud_data) elif Tower.selected_towers.size() > 1: - %SelectionContainer.visible = false %MultiSelectionContainer.visible = true - %MultiSelectionList.add_child(hud_data) + %MultiSelectionList.add_child(multi_select_hud_data) + + redraw_multiselect("", selected_group) ) + tower.deselected.connect(func(): if Tower.selected_towers.size() == 0: %SelectionContainer.visible = false @@ -70,10 +92,43 @@ func _ready(): elif Tower.selected_towers.size() == 1: %MultiSelectionContainer.visible = false %SelectionContainer.visible = true + %MultiSelectionList.get_node(NodePath(tower.name)).queue_free() elif Tower.selected_towers.size() > 1: # only remove deselected tower from list - %MultiSelectionList.get_node(NodePath(tower.name)).queue_free() + var node = %MultiSelectionList.get_node_or_null(NodePath(tower.name)) + if node: # when double click selecting in quick succession not found error + node.queue_free() + + if tower.selection_group_id in selection_groups: + selection_groups[tower.selection_group_id].erase(tower) + if selection_groups[tower.selection_group_id].is_empty(): + selection_groups.erase(tower.selection_group_id) + ) + + tower.selection_group_id_changed.connect(func(previous_id: String): + if not tower.selection_group_id in selection_groups: + selection_groups[tower.selection_group_id] = [] + selection_groups[tower.selection_group_id].append(tower) + %MultiSelectionList.get_node(NodePath(tower.name)).add_to_group(tower.selection_group_id) + + selection_groups[previous_id].erase(tower) + if selection_groups[previous_id].is_empty(): + selection_groups.erase(previous_id) + if previous_id == selected_group: + selected_group = tower.selection_group_id + %MultiSelectionList.get_node(NodePath(tower.name)).remove_from_group(previous_id) + + if tower.name == selection_groups[tower.selection_group_id][0].name: + redraw_select(tower.get_hud()) ) + + tower.attack_value_changed.connect(func(value: int): + attack_value_changed.emit(value) + ) + ) + + Client.multi_select_finished.connect(func(): + selected_group = get_ordered_group_keys()[0] ) @@ -83,6 +138,64 @@ func _input(event: InputEvent): if event.is_action_pressed("players_list_toggle"): team_top.visible = not team_top.visible team_bottom.visible = not team_bottom.visible + + if %MultiSelectionContainer.visible and event.is_action_pressed("selection_cycle"): + var keys = get_ordered_group_keys() + var current_idx = keys.find(selected_group) + selected_group = keys[(current_idx + 1) % keys.size()] + + +func redraw_select(hud_data: Control): + for node in %SelectionData.get_children(): + node.queue_free() + + %SelectionData.add_child(hud_data) + + +func redraw_multiselect(previous_group: String, new_group: String): + var idx = 0 + for group_key in get_ordered_group_keys(): + var group = selection_groups[group_key] + for node in group: + var selection_node = %MultiSelectionList.get_node_or_null(NodePath(node.name)) + if selection_node: # when double click selecting in quick succession not found error + %MultiSelectionList.move_child(selection_node, idx) + idx += 1 + + for node in get_tree().get_nodes_in_group(previous_group): + node.modulate = Color(0.5, 0.5, 0.5) + for node in get_tree().get_nodes_in_group(new_group): + node.modulate = Color(1.0, 1.0, 1.0) + + +func get_ordered_group_keys() -> Array: + var keys = selection_groups.keys() + keys.sort_custom(func(a, b): + var group_a = selection_groups[a] + var group_b = selection_groups[b] + + return group_a.size() > group_b.size() + ) + keys.sort_custom(func(a, b): + var group_a = selection_groups[a] + var group_b = selection_groups[b] + var node_a = group_a[0] + var node_b = group_b[0] + + return ( + (node_a.attack_range / 8) + node_a.attack_power + node_a.attack_speed + > + (node_b.attack_range / 8) + node_b.attack_power + node_b.attack_speed + ) + ) + keys.sort_custom(func(a, b): + var group_a = selection_groups[a] + var group_b = selection_groups[b] + + return group_a[0].components.size() > group_b[0].components.size() + ) + + return keys func _on_build_mode_button_gui_input(event: InputEvent) -> void: diff --git a/Stages/Wintermaul/HUD.tscn b/Stages/Wintermaul/HUD.tscn index 024910f..52dde03 100644 --- a/Stages/Wintermaul/HUD.tscn +++ b/Stages/Wintermaul/HUD.tscn @@ -40,6 +40,7 @@ action = &"spawn_unit" events = [SubResource("InputEventAction_t6x4q")] [node name="HUD" type="CanvasLayer"] +visible = false script = ExtResource("1_2bu0v") [node name="Panel" type="PanelContainer" parent="."] @@ -239,8 +240,8 @@ layout_mode = 2 unique_name_in_owner = true custom_minimum_size = Vector2(200, 0) layout_mode = 2 -size_flags_horizontal = 6 -size_flags_stretch_ratio = 2.0 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 100.0 [node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/MultiSelectionContainer"] layout_mode = 2 @@ -258,7 +259,7 @@ last_wrap_alignment = 1 unique_name_in_owner = true custom_minimum_size = Vector2(200, 0) layout_mode = 2 -size_flags_horizontal = 6 +size_flags_horizontal = 10 size_flags_stretch_ratio = 2.0 [node name="SelectionData" type="MarginContainer" parent="MarginContainer/HBoxContainer/SelectionContainer"] @@ -280,6 +281,7 @@ text = "T" unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 10 +size_flags_vertical = 8 size_flags_stretch_ratio = 0.0 [node name="MarginContainer" type="MarginContainer" parent="MarginContainer/HBoxContainer/SpawnBox"] diff --git a/Stages/Wintermaul/Wintermaul.tscn b/Stages/Wintermaul/Wintermaul.tscn index 6cf2d05..bebc79c 100644 --- a/Stages/Wintermaul/Wintermaul.tscn +++ b/Stages/Wintermaul/Wintermaul.tscn @@ -23,6 +23,7 @@ script = ExtResource("1_o88ua") [node name="HUD" parent="." instance=ExtResource("2_v3f6l")] unique_name_in_owner = true +visible = true [node name="Map" type="TileMapLayer" parent="."] unique_name_in_owner = true diff --git a/Stages/Wintermaul/wintermaul.gd b/Stages/Wintermaul/wintermaul.gd index b638c97..9219a29 100644 --- a/Stages/Wintermaul/wintermaul.gd +++ b/Stages/Wintermaul/wintermaul.gd @@ -67,6 +67,12 @@ func _ready(): # initialize lives display update_lives("top", 0) update_lives("bottom", 0) + + %HUD.attack_value_changed.connect(func(value: int): + Network.update_player.rpc(Client.player.id, { + "money": -(value * 10), + }) + ) func _process(_delta: float) -> void: diff --git a/Towers/Tower.gd b/Towers/Tower.gd index 7eb8bf6..2de8216 100644 --- a/Towers/Tower.gd +++ b/Towers/Tower.gd @@ -36,24 +36,43 @@ var mobs_in_range: Array = [] #var selection_area: Area2D +signal selection_group_id_changed(previous_id: String) +@onready var selection_group_id := get_group_id(): + set(value): + var previous_id = selection_group_id + selection_group_id = value + selection_group_id_changed.emit(previous_id) + # rpc owner id @export var owner_id = 1 +signal attack_value_changed(value: int) @export var attack_range: int = 32 @export var attack_power: int = 1 + @export var attack_speed: int = 1 +var speed_base: float = 2.0 -@export var components: Array[TowerComponent] = [] +signal components_changed +@export var components: Array[TowerComponent] = []#: + #set(value): + #components = value + #components_changed.emit() func _ready(): $Range/CollisionShape2D.shape.radius = attack_range - $ShootCooldown.wait_time = attack_speed + $ShootCooldown.wait_time = speed_base / attack_speed %Data.text = "Range: %s - Power: %s - Speed: %s" % [ attack_range, attack_power, attack_speed ] - + + %HUD.visible = false + + components_changed.connect(func(): + selection_group_id = get_group_id() + ) #for component in [ #preload("res://Towers/Components/FrostComponent.gd").new(), @@ -138,6 +157,7 @@ func add_component(component: TowerComponent): var sprite = component.sprite $ComponentsAnchor.add_child(sprite) redraw_components() + components_changed.emit() func remove_component(component_name: String): for component in components: @@ -146,6 +166,7 @@ func remove_component(component_name: String): $ComponentsAnchor.remove_child($ComponentsAnchor.get_node(NodePath(component.name))) break redraw_components() + components_changed.emit() func redraw_components(): for idx in range(components.size()): @@ -176,7 +197,10 @@ func shoot(): func get_hud(): - return %HUD.get_child(0).duplicate() + var data = %HUD.get_child(0).duplicate() + data.name = name + + return data func get_region(): @@ -189,6 +213,19 @@ func get_region(): ) +func get_group_id() -> String: + var string := "" + + string += str(attack_range) + string += str(attack_power) + string += str(attack_speed) + + for component in components: + string += component.name + + return str(components.size()) + string.md5_text() + + func _on_tree_exiting() -> void: is_selected = false @@ -197,7 +234,9 @@ func _on_h_box_container_gui_input(event: InputEvent) -> void: if event.is_action_pressed("select"): get_viewport().set_input_as_handled() - for tower in selected_towers: + var hud: HUD = Client.current_stage.get_node("HUD") + var towers = hud.selection_groups[hud.selected_group].duplicate() + for tower in towers: var found = false for idx in range(tower.components.size()): var component = tower.components[idx] @@ -216,7 +255,9 @@ func _on_h_box_container_2_gui_input(event: InputEvent) -> void: if event.is_action_pressed("select"): get_viewport().set_input_as_handled() - for tower in selected_towers: + var hud: HUD = Client.current_stage.get_node("HUD") + var towers = hud.selection_groups[hud.selected_group].duplicate() + for tower in towers: var found = false for idx in range(tower.components.size()): var component = tower.components[idx] @@ -231,6 +272,57 @@ func _on_h_box_container_2_gui_input(event: InputEvent) -> void: Client.update_tower(tower.get_path(), tower.to_network_data()) +func _on_button_1_pressed() -> void: + if Client.player.money < (attack_range / 8.0) + 10: + return + + var hud: HUD = Client.current_stage.get_node("HUD") + var towers = hud.selection_groups[hud.selected_group].duplicate() + for tower: Tower in towers: + tower.attack_range += 8 + tower.attack_value_changed.emit((attack_range / 8.0) - 1) + tower.get_node("%Data").text = "Range: %s - Power: %s - Speed: %s" % [ + tower.attack_range, tower.attack_power, tower.attack_speed + ] + tower.get_node("%Range/CollisionShape2D").shape.radius = attack_range + tower.selection_group_id = tower.get_group_id() + Client.update_tower(tower.get_path(), tower.to_network_data()) + + +func _on_button_2_pressed() -> void: + if Client.player.money < attack_power * 10: + return + + var hud: HUD = Client.current_stage.get_node("HUD") + var towers = hud.selection_groups[hud.selected_group].duplicate() + for tower: Tower in towers: + tower.attack_power += 1 + tower.attack_value_changed.emit(attack_power - 1) + tower.get_node("%Data").text = "Range: %s - Power: %s - Speed: %s" % [ + tower.attack_range, tower.attack_power, tower.attack_speed + ] + tower.selection_group_id = tower.get_group_id() + Client.update_tower(tower.get_path(), tower.to_network_data()) + + +func _on_button_3_pressed() -> void: + if Client.player.money < attack_speed * 10: + return + + var hud: HUD = Client.current_stage.get_node("HUD") + var towers = hud.selection_groups[hud.selected_group].duplicate() + for tower: Tower in towers: + tower.attack_speed += 1 + tower.attack_value_changed.emit(attack_speed - 1) + tower.get_node("%Data").text = "Range: %s - Power: %s - Speed: %s" % [ + tower.attack_range, tower.attack_power, tower.attack_speed + ] + tower.get_node("%ShootCooldown").wait_time = (speed_base / attack_speed) + tower.selection_group_id = tower.get_group_id() + Client.update_tower(tower.get_path(), tower.to_network_data()) + + + class NetworkData extends Resource: var name: String var owner_id: int diff --git a/Towers/Tower.tscn b/Towers/Tower.tscn index 55ae928..3c5241b 100644 --- a/Towers/Tower.tscn +++ b/Towers/Tower.tscn @@ -52,6 +52,7 @@ position = Vector2(16, 16) shape = SubResource("RectangleShape2D_atm5x") [node name="Range" type="Area2D" parent="."] +unique_name_in_owner = true collision_layer = 0 [node name="CollisionShape2D" type="CollisionShape2D" parent="Range"] @@ -59,6 +60,7 @@ position = Vector2(16, 16) shape = SubResource("CircleShape2D_qa8kt") [node name="ShootCooldown" type="Timer" parent="."] +unique_name_in_owner = true one_shot = true [node name="SelectableArea" parent="." instance=ExtResource("3_57d5u")] @@ -72,25 +74,31 @@ position = Vector2(0, 32) [node name="HUD" type="CanvasLayer" parent="."] unique_name_in_owner = true -visible = false [node name="VBoxContainer" type="VBoxContainer" parent="HUD"] -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -38.0 -offset_top = -25.0 -offset_right = 38.0 -offset_bottom = 25.0 -grow_horizontal = 2 -grow_vertical = 2 +offset_left = 64.0 +offset_right = 140.0 +offset_bottom = 77.0 [node name="Data" type="Label" parent="HUD/VBoxContainer"] unique_name_in_owner = true layout_mode = 2 +[node name="HBoxContainer" type="HBoxContainer" parent="HUD/VBoxContainer"] +layout_mode = 2 + +[node name="Button1" type="Button" parent="HUD/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "+Range" + +[node name="Button2" type="Button" parent="HUD/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "+Power" + +[node name="Button3" type="Button" parent="HUD/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "+Speed" + [node name="Components" type="VBoxContainer" parent="HUD/VBoxContainer"] unique_name_in_owner = true layout_mode = 2 @@ -133,5 +141,8 @@ replication_config = SubResource("SceneReplicationConfig_spp26") [connection signal="hover_enter" from="SelectableArea" to="." method="_on_selectable_area_hover_enter"] [connection signal="hover_exit" from="SelectableArea" to="." method="_on_selectable_area_hover_exit"] [connection signal="select" from="SelectableArea" to="." method="_on_selectable_area_select"] +[connection signal="pressed" from="HUD/VBoxContainer/HBoxContainer/Button1" to="." method="_on_button_1_pressed"] +[connection signal="pressed" from="HUD/VBoxContainer/HBoxContainer/Button2" to="." method="_on_button_2_pressed"] +[connection signal="pressed" from="HUD/VBoxContainer/HBoxContainer/Button3" to="." method="_on_button_3_pressed"] [connection signal="gui_input" from="HUD/VBoxContainer/Components/HBoxContainer" to="." method="_on_h_box_container_gui_input"] [connection signal="gui_input" from="HUD/VBoxContainer/Components/HBoxContainer2" to="." method="_on_h_box_container_2_gui_input"] 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) diff --git a/project.godot b/project.godot index 47191ce..e49f47f 100644 --- a/project.godot +++ b/project.godot @@ -91,6 +91,16 @@ players_list_toggle={ "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":80,"key_label":0,"unicode":112,"location":0,"echo":false,"script":null) ] } +mouse_escape={ +"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":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +selection_cycle={ +"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":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} [layer_names] |