diff options
Diffstat (limited to 'UI')
| -rw-r--r-- | UI/Assets/Enjl-Starry Space Background/background_1.png | bin | 0 -> 1360 bytes | |||
| -rw-r--r-- | UI/Assets/Enjl-Starry Space Background/background_1.png.import | 34 | ||||
| -rw-r--r-- | UI/Assets/Enjl-Starry Space Background/background_2.png | bin | 0 -> 1031 bytes | |||
| -rw-r--r-- | UI/Assets/Enjl-Starry Space Background/background_2.png.import | 34 | ||||
| -rw-r--r-- | UI/Assets/Enjl-Starry Space Background/background_3.png | bin | 0 -> 1069 bytes | |||
| -rw-r--r-- | UI/Assets/Enjl-Starry Space Background/background_3.png.import | 34 | ||||
| -rw-r--r-- | UI/Assets/Enjl-Starry Space Background/background_4.png | bin | 0 -> 1357 bytes | |||
| -rw-r--r-- | UI/Assets/Enjl-Starry Space Background/background_4.png.import | 34 | ||||
| -rw-r--r-- | UI/Lobby.tscn | 44 | ||||
| -rw-r--r-- | UI/Start.gd | 16 | ||||
| -rw-r--r-- | UI/Start.tscn | 44 | ||||
| -rw-r--r-- | UI/hp_bar.gd | 19 | ||||
| -rw-r--r-- | UI/lobby.gd | 44 | ||||
| -rw-r--r-- | UI/lobby_setting.gd | 26 | ||||
| -rw-r--r-- | UI/lobby_setting.tscn | 17 | ||||
| -rw-r--r-- | UI/spawn_button.gd | 19 | 
16 files changed, 347 insertions, 18 deletions
| diff --git a/UI/Assets/Enjl-Starry Space Background/background_1.png b/UI/Assets/Enjl-Starry Space Background/background_1.pngBinary files differ new file mode 100644 index 0000000..0c5f4db --- /dev/null +++ b/UI/Assets/Enjl-Starry Space Background/background_1.png diff --git a/UI/Assets/Enjl-Starry Space Background/background_1.png.import b/UI/Assets/Enjl-Starry Space Background/background_1.png.import new file mode 100644 index 0000000..2f8173b --- /dev/null +++ b/UI/Assets/Enjl-Starry Space Background/background_1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://kwgx33awj4y2" +path="res://.godot/imported/background_1.png-7e438384413b8871a8afa17dff70ac05.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/Assets/Enjl-Starry Space Background/background_1.png" +dest_files=["res://.godot/imported/background_1.png-7e438384413b8871a8afa17dff70ac05.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/UI/Assets/Enjl-Starry Space Background/background_2.png b/UI/Assets/Enjl-Starry Space Background/background_2.pngBinary files differ new file mode 100644 index 0000000..a235905 --- /dev/null +++ b/UI/Assets/Enjl-Starry Space Background/background_2.png diff --git a/UI/Assets/Enjl-Starry Space Background/background_2.png.import b/UI/Assets/Enjl-Starry Space Background/background_2.png.import new file mode 100644 index 0000000..00385eb --- /dev/null +++ b/UI/Assets/Enjl-Starry Space Background/background_2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cp5mtdbyy8omw" +path="res://.godot/imported/background_2.png-cb39a76cad6a4a776cf02a04592ad83f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/Assets/Enjl-Starry Space Background/background_2.png" +dest_files=["res://.godot/imported/background_2.png-cb39a76cad6a4a776cf02a04592ad83f.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/UI/Assets/Enjl-Starry Space Background/background_3.png b/UI/Assets/Enjl-Starry Space Background/background_3.pngBinary files differ new file mode 100644 index 0000000..4b27ae0 --- /dev/null +++ b/UI/Assets/Enjl-Starry Space Background/background_3.png diff --git a/UI/Assets/Enjl-Starry Space Background/background_3.png.import b/UI/Assets/Enjl-Starry Space Background/background_3.png.import new file mode 100644 index 0000000..09c2e7f --- /dev/null +++ b/UI/Assets/Enjl-Starry Space Background/background_3.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://br8j56w0tahv3" +path="res://.godot/imported/background_3.png-f4ce54baeff343ebed337e7f45439d89.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/Assets/Enjl-Starry Space Background/background_3.png" +dest_files=["res://.godot/imported/background_3.png-f4ce54baeff343ebed337e7f45439d89.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/UI/Assets/Enjl-Starry Space Background/background_4.png b/UI/Assets/Enjl-Starry Space Background/background_4.pngBinary files differ new file mode 100644 index 0000000..b40730a --- /dev/null +++ b/UI/Assets/Enjl-Starry Space Background/background_4.png diff --git a/UI/Assets/Enjl-Starry Space Background/background_4.png.import b/UI/Assets/Enjl-Starry Space Background/background_4.png.import new file mode 100644 index 0000000..353d5cd --- /dev/null +++ b/UI/Assets/Enjl-Starry Space Background/background_4.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://iu0tc1luyuhv" +path="res://.godot/imported/background_4.png-d90a2b266e3c1dbc29f3ad6c557346d3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/Assets/Enjl-Starry Space Background/background_4.png" +dest_files=["res://.godot/imported/background_4.png-d90a2b266e3c1dbc29f3ad6c557346d3.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/UI/Lobby.tscn b/UI/Lobby.tscn index 6c7f1f7..08055de 100644 --- a/UI/Lobby.tscn +++ b/UI/Lobby.tscn @@ -1,6 +1,8 @@ -[gd_scene load_steps=9 format=3 uid="uid://r45j806p4a74"] +[gd_scene load_steps=12 format=3 uid="uid://r45j806p4a74"]  [ext_resource type="Script" path="res://UI/lobby.gd" id="1_mm4gt"] +[ext_resource type="Texture2D" uid="uid://kwgx33awj4y2" path="res://UI/Assets/Enjl-Starry Space Background/background_1.png" id="2_0pdjl"] +[ext_resource type="PackedScene" uid="uid://dslebs7aarkoa" path="res://UI/panel_background_blue.tscn" id="2_1qhg6"]  [ext_resource type="Theme" uid="uid://bt84t61hrvoyn" path="res://UI/lobby_theme.tres" id="2_syjfh"]  [ext_resource type="PackedScene" uid="uid://bl65jllb3e2py" path="res://Stages/Wintermaul/Wintermaul.tscn" id="3_3hc3h"]  [ext_resource type="Texture2D" uid="uid://ci7qydmwbanbp" path="res://Stages/Wintermaul/Assets/thumbnail.png" id="3_8r1n2"] @@ -9,6 +11,8 @@  [ext_resource type="PackedScene" uid="uid://jxy7fj7yymfl" path="res://Stages/TinySwords/WintermaulTinySwords.tscn" id="5_hnsfx"]  [ext_resource type="Texture2D" uid="uid://cujvoqsqfrl4a" path="res://Stages/Wintermaul2/Assets/thumbnail.png" id="5_j23oc"] +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_fm6m2"] +  [node name="Lobby" type="Control"]  layout_mode = 3  anchors_preset = 15 @@ -18,6 +22,33 @@ grow_horizontal = 2  grow_vertical = 2  script = ExtResource("1_mm4gt") +[node name="Background" 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="ColorRect" type="ColorRect" parent="Background"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 1) + +[node name="TextureRect" type="TextureRect" parent="Background"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("2_0pdjl") +stretch_mode = 1 +  [node name="MarginContainer" type="MarginContainer" parent="."]  layout_mode = 1  anchors_preset = 15 @@ -45,6 +76,10 @@ theme_override_constants/separation = 32  [node name="PanelContainer" type="PanelContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer"]  layout_mode = 2  size_flags_horizontal = 3 +theme_override_styles/panel = SubResource("StyleBoxEmpty_fm6m2") + +[node name="PanelBackgroundBlue" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/PanelContainer" instance=ExtResource("2_1qhg6")] +layout_mode = 2  [node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/PanelContainer"]  layout_mode = 2 @@ -85,6 +120,7 @@ toggle_mode = true  text = "Wintermaul"  metadata/map_scene = ExtResource("3_3hc3h")  metadata/thumbnail = ExtResource("3_8r1n2") +metadata/settings = ["starting_lives", "starting_money", "starting_income"]  [node name="MapButton2" type="Button" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer/Maps"]  layout_mode = 2 @@ -117,6 +153,12 @@ texture = ExtResource("3_8r1n2")  expand_mode = 1  stretch_mode = 4 +[node name="Settings" type="VBoxContainer" parent="MarginContainer/VBoxContainer/CenterContainer/HBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_vertical = 0 +theme_override_constants/separation = 0 +  [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer"]  layout_mode = 2  size_flags_horizontal = 8 diff --git a/UI/Start.gd b/UI/Start.gd index c9a0342..fbfa8db 100644 --- a/UI/Start.gd +++ b/UI/Start.gd @@ -2,13 +2,16 @@ extends Control  func _ready(): +	multiplayer.peer_connected.connect(_on_peer_connected) +	multiplayer.peer_disconnected.connect(_on_peer_disconnected) +	  	if OS.has_environment("USER"):  		%Name.text = OS.get_environment("USER")  	elif OS.has_environment("USERNAME"):  		%Name.text = OS.get_environment("USERNAME") -func get_ip(): +func get_ip() -> String:  	var ip := "127.0.0.1"  	if %IP.text:  		ip = %IP.text @@ -16,13 +19,14 @@ func get_ip():  	return ip -func get_port(): +func get_port() -> int:  	var port := 1234  	if %Port.text: -		port = %Port.text +		port = int(%Port.text)  	return port +  func _on_host_pressed() -> void:  	Client.player.username = %Name.text  	Network.host_game(get_port()) @@ -33,3 +37,9 @@ func _on_join_pressed() -> void:  	Client.player.username = %Name.text  	Network.join_game(get_ip(), get_port())  	get_tree().change_scene_to_file("res://UI/Lobby.tscn") + + +func _on_peer_connected(id): +	Network._on_peer_connected(id) +func _on_peer_disconnected(id): +	Network._on_peer_disconnected(id) diff --git a/UI/Start.tscn b/UI/Start.tscn index b85d869..64b789d 100644 --- a/UI/Start.tscn +++ b/UI/Start.tscn @@ -1,6 +1,8 @@ -[gd_scene load_steps=2 format=3 uid="uid://bcbxer883ygg7"] +[gd_scene load_steps=4 format=3 uid="uid://bcbxer883ygg7"]  [ext_resource type="Script" path="res://UI/Start.gd" id="1_h1h6c"] +[ext_resource type="Theme" uid="uid://c7f1ftrx53ag1" path="res://theme.tres" id="1_uriow"] +[ext_resource type="Texture2D" uid="uid://kwgx33awj4y2" path="res://UI/Assets/Enjl-Starry Space Background/background_1.png" id="2_fxy5w"]  [node name="Start" type="Control"]  layout_mode = 3 @@ -9,8 +11,36 @@ anchor_right = 1.0  anchor_bottom = 1.0  grow_horizontal = 2  grow_vertical = 2 +theme = ExtResource("1_uriow")  script = ExtResource("1_h1h6c") +[node name="Background" 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="ColorRect" type="ColorRect" parent="Background"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 1) + +[node name="TextureRect" type="TextureRect" parent="Background"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("2_fxy5w") +stretch_mode = 1 +  [node name="CenterContainer" type="CenterContainer" parent="."]  layout_mode = 1  anchors_preset = 15 @@ -22,29 +52,28 @@ grow_vertical = 2  [node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]  layout_mode = 2 -[node name="Name" type="TextEdit" parent="CenterContainer/VBoxContainer"] +[node name="Name" type="LineEdit" parent="CenterContainer/VBoxContainer"]  unique_name_in_owner = true -custom_minimum_size = Vector2(0, 50) +custom_minimum_size = Vector2(150, 0)  layout_mode = 2  placeholder_text = "Name"  [node name="Host" type="Button" parent="CenterContainer/VBoxContainer"]  unique_name_in_owner = true  layout_mode = 2 +mouse_default_cursor_shape = 2  theme_override_font_sizes/font_size = 24  text = "Host" -[node name="IP" type="TextEdit" parent="CenterContainer/VBoxContainer"] +[node name="IP" type="LineEdit" parent="CenterContainer/VBoxContainer"]  unique_name_in_owner = true -custom_minimum_size = Vector2(150, 50)  layout_mode = 2  size_flags_vertical = 3  theme_override_font_sizes/font_size = 18  placeholder_text = "Join IP" -[node name="Port" type="TextEdit" parent="CenterContainer/VBoxContainer"] +[node name="Port" type="LineEdit" parent="CenterContainer/VBoxContainer"]  unique_name_in_owner = true -custom_minimum_size = Vector2(150, 50)  layout_mode = 2  size_flags_vertical = 3  theme_override_font_sizes/font_size = 18 @@ -53,6 +82,7 @@ placeholder_text = "Host&Join Port"  [node name="Join" type="Button" parent="CenterContainer/VBoxContainer"]  unique_name_in_owner = true  layout_mode = 2 +mouse_default_cursor_shape = 2  theme_override_font_sizes/font_size = 24  text = "Join" diff --git a/UI/hp_bar.gd b/UI/hp_bar.gd index 9df85e8..bb18bf2 100644 --- a/UI/hp_bar.gd +++ b/UI/hp_bar.gd @@ -25,11 +25,30 @@ func set_value(value):  		visible = true +func show_numbers(value: float): +	# TODO: factor out to scene +	 +	var label = Label.new() +	label.text = str(value) +	label.position.x = randf_range(0.0, size.x) +	label.position.y = -size.y*5 +	label.add_theme_font_size_override("font_size", 8) +	add_child(label) +	 +	var tween = create_tween() +	tween.tween_property(label, "position", Vector2(label.position.x, label.position.y - size.y), 0.25) +	tween.tween_property(label, "self_modulate", Color(1, 1, 1, 0), 0.25) +	await tween.finished +	label.queue_free() + +  func _on_health_bar_value_changed(value: float) -> void:  	if not $ImmediateDamageTimer.is_stopped():  		$ImmediateDamageBar.value = $HealthBar.value + value_difference  	$ImmediateDamageTimer.start() +	 +	show_numbers(value_difference)  func _on_immediate_damage_timer_timeout() -> void: diff --git a/UI/lobby.gd b/UI/lobby.gd index 26a7b97..f7d8405 100644 --- a/UI/lobby.gd +++ b/UI/lobby.gd @@ -5,6 +5,8 @@ signal joined  var current_map_idx := 0 +var settings := {} +  @onready var list: VBoxContainer = %PlayersList @@ -34,6 +36,8 @@ func _ready() -> void:  	update_players()  	multiplayer.peer_disconnected.connect(remove_player) +	multiplayer.peer_connected.connect(_on_peer_connected) +	multiplayer.peer_disconnected.connect(_on_peer_disconnected)  	# reset map texture for clean load  	%Thumbnail.texture = null @@ -66,6 +70,12 @@ func remove_player(id):  	list.remove_child(list.get_node(str(id))) +func _on_peer_connected(id): +	Network._on_peer_connected(id) +func _on_peer_disconnected(id): +	Network._on_peer_disconnected(id) + +  func _on_start_button_pressed() -> void:  	start.rpc() @@ -77,8 +87,13 @@ func _on_cancel_button_pressed() -> void:  @rpc("authority", "call_local")  func start(): -	var scene = %Maps.get_child(current_map_idx).get_meta("map_scene") -	get_tree().change_scene_to_packed(scene) +	var packed_scene = %Maps.get_child(current_map_idx).get_meta("map_scene") +	var scene = packed_scene.instantiate() +	 +	for setting in settings: +		scene[setting] = settings[setting] +	 +	Client.change_scene_to_instance(scene)  @rpc("authority", "call_local") @@ -91,5 +106,30 @@ func set_map(index: int):  	var node = %Maps.get_child(index)  	var thumbnail = node.get_meta("thumbnail") +	# settings +	for child in %Settings.get_children(): +		child.queue_free() +	if node.get_meta("settings"): +		var scene = node.get_meta("map_scene").instantiate() +		for setting in node.get_meta("settings", []): +			settings[setting] = scene[setting] +			var control = preload("res://UI/lobby_setting.tscn").instantiate() +			control.label = setting +			control.value = settings[setting] +			control.disabled = !multiplayer.is_server() +			if multiplayer.is_server(): +				control.value_changed.connect(func(value): +					set_setting.rpc(setting, value) +				) +			%Settings.add_child(control) +	  	node.add_theme_color_override("font_color", Color(1.0, 1.0, 1.0, 1.0))  	%Thumbnail.texture = thumbnail + + +@rpc("authority", "call_local") +func set_setting(key: String, value: Variant): +	settings[key] = value +	 +	if not multiplayer.is_server(): +		%Settings.get_node(key).value = value diff --git a/UI/lobby_setting.gd b/UI/lobby_setting.gd new file mode 100644 index 0000000..a5b9e7e --- /dev/null +++ b/UI/lobby_setting.gd @@ -0,0 +1,26 @@ +extends HBoxContainer + + +signal value_changed(value: String) + +var label := "": +	set(value): +		$Label.text = str(value) +		name = str(value) +	get(): +		return $Label.text + +var value: Variant = "": +	set(value): +		$TextEdit.text = str(value) +	get(): +		return $TextEdit.text + +var disabled := false: +	set(value): +		disabled = value +		$TextEdit.editable = !disabled + + +func _on_text_edit_text_changed(new_text: String) -> void: +	value_changed.emit(new_text) diff --git a/UI/lobby_setting.tscn b/UI/lobby_setting.tscn new file mode 100644 index 0000000..8c462b4 --- /dev/null +++ b/UI/lobby_setting.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=2 format=3 uid="uid://fgqkxat8pwjk"] + +[ext_resource type="Script" path="res://UI/lobby_setting.gd" id="1_ntovh"] + +[node name="LobbySetting" type="HBoxContainer"] +size_flags_vertical = 2 +script = ExtResource("1_ntovh") + +[node name="Label" type="Label" parent="."] +layout_mode = 2 +text = "Setting" + +[node name="TextEdit" type="LineEdit" parent="."] +layout_mode = 2 +text = "5" + +[connection signal="text_changed" from="TextEdit" to="." method="_on_text_edit_text_changed"] diff --git a/UI/spawn_button.gd b/UI/spawn_button.gd index 3051dfb..70ff3f5 100644 --- a/UI/spawn_button.gd +++ b/UI/spawn_button.gd @@ -5,6 +5,10 @@ extends TextureButton  @export var sprite_sheet: SpriteFrames  @export var cost := 5 +@export var hp := 5 +@export var speed := 100 + +@export var unit_resource: UnitResource  func _ready(): @@ -14,11 +18,16 @@ func _ready():  func _on_pressed() -> void:  	var unit = preload("res://Units/Unit.tscn").instantiate() as Unit -	if texture: -		unit.get_node("Sprite2D").texture = texture -		unit.get_node("Sprite2D").scale = Vector2(32,32) / texture.get_size() +	#if texture: +		#unit.get_node("Sprite2D").texture = texture +		#unit.get_node("Sprite2D").scale = Vector2(32,32) / texture.get_size() +	 +	#if sprite_sheet: +		#unit.get_node("AnimatedSprite2D").sprite_frames = sprite_sheet -	if sprite_sheet: -		unit.get_node("AnimatedSprite2D").sprite_frames = sprite_sheet +	unit.unit_resource = unit_resource +	#unit.hp = hp +	#unit.base_speed = speed +	#unit.additional_data = {"cost": cost}  	Client.spawn_unit(unit, Client.current_stage.get_spawn(), Client.current_stage.get_overwrite_target()) | 
