From 84bf97c22de29186959286c99be58a25adb57078 Mon Sep 17 00:00:00 2001 From: Tirith Date: Thu, 13 Nov 2025 16:56:09 +0100 Subject: [PATCH] Station panel --- scenes/galaxy.tscn | 27 ++++++++++++++++++++- scenes/station.tscn | 13 +++++++++- scenes/station_panel.tscn | 47 ++++++++++++++++++++++++++++++++++++ scripts/star.gd | 1 + scripts/station.gd | 16 ++++++++++++ scripts/station.gd.uid | 1 + scripts/station_panel.gd | 28 +++++++++++++++++++++ scripts/station_panel.gd.uid | 1 + 8 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 scenes/station_panel.tscn create mode 100644 scripts/station.gd create mode 100644 scripts/station.gd.uid create mode 100644 scripts/station_panel.gd create mode 100644 scripts/station_panel.gd.uid diff --git a/scenes/galaxy.tscn b/scenes/galaxy.tscn index dc88a3d..ee2eb8f 100644 --- a/scenes/galaxy.tscn +++ b/scenes/galaxy.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://b1vxl6rs5odt1"] +[gd_scene load_steps=11 format=3 uid="uid://b1vxl6rs5odt1"] [ext_resource type="Script" uid="uid://cts6e8xmnqsax" path="res://scripts/galaxy.gd" id="1_jxn3g"] [ext_resource type="PackedScene" uid="uid://bbgymc0drqpbx" path="res://scenes/ui/time_display.tscn" id="3_fmtwf"] @@ -9,6 +9,7 @@ [ext_resource type="PackedScene" uid="uid://dgxm8txsiukwf" path="res://scenes/planet_panel.tscn" id="7_xhm0b"] [ext_resource type="PackedScene" uid="uid://c405r414rsut2" path="res://scenes/top_panel.tscn" id="8_0pfb5"] [ext_resource type="PackedScene" uid="uid://bitiuqh8lb0ga" path="res://scenes/tech_panel.tscn" id="9_lwv00"] +[ext_resource type="PackedScene" uid="uid://bhh7tjhvj1ihl" path="res://scenes/station_panel.tscn" id="10_ntfcv"] [node name="Galaxy" type="Node2D"] script = ExtResource("1_jxn3g") @@ -86,3 +87,27 @@ offset_left = -1031.4401 offset_top = -379.12006 offset_right = -375.44006 offset_bottom = -203.12006 + +[node name="StationPanel" parent="UI" instance=ExtResource("10_ntfcv")] +visible = false +offset_left = 989.0 +offset_top = 158.0 +offset_right = 1633.0 +offset_bottom = 727.0 + +[node name="Label" parent="UI/StationPanel" index="0"] +offset_right = 636.0 + +[node name="Button" parent="UI/StationPanel" index="1"] +offset_left = 205.0 +offset_top = 216.0 +offset_right = 442.0 +offset_bottom = 363.0 + +[node name="Button2" parent="UI/StationPanel" index="2"] +offset_left = 607.0 +offset_top = 9.0 +offset_right = 636.0 +offset_bottom = 40.0 + +[editable path="UI/StationPanel"] diff --git a/scenes/station.tscn b/scenes/station.tscn index 31457c4..10075f5 100644 --- a/scenes/station.tscn +++ b/scenes/station.tscn @@ -1,9 +1,20 @@ -[gd_scene load_steps=2 format=3 uid="uid://bhuvrdvcm6exi"] +[gd_scene load_steps=4 format=3 uid="uid://bhuvrdvcm6exi"] +[ext_resource type="Script" uid="uid://dfueb8qi64ld1" path="res://scripts/station.gd" id="1_0r0hh"] [ext_resource type="Texture2D" uid="uid://c1npf2gngyyxp" path="res://assets/buildings/starbase.png" id="1_rod8h"] +[sub_resource type="CircleShape2D" id="CircleShape2D_0r0hh"] +radius = 5.332485 + [node name="Station" type="Node2D"] +script = ExtResource("1_0r0hh") [node name="Sprite2D" type="Sprite2D" parent="."] scale = Vector2(0.023437498, 0.023437498) texture = ExtResource("1_rod8h") + +[node name="Area2D" type="Area2D" parent="Sprite2D"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Sprite2D/Area2D"] +scale = Vector2(48.695583, 47.76953) +shape = SubResource("CircleShape2D_0r0hh") diff --git a/scenes/station_panel.tscn b/scenes/station_panel.tscn new file mode 100644 index 0000000..cd7e283 --- /dev/null +++ b/scenes/station_panel.tscn @@ -0,0 +1,47 @@ +[gd_scene load_steps=3 format=3 uid="uid://bhh7tjhvj1ihl"] + +[ext_resource type="Script" uid="uid://dyf8rbm4f8kmu" path="res://scripts/station_panel.gd" id="1_jmmgu"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_sr7ii"] +bg_color = Color(0.18077528, 0.6776919, 0.6938374, 0.24313726) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 + +[node name="StationPanel" type="Panel"] +offset_right = 809.0 +offset_bottom = 858.0 +theme_override_styles/panel = SubResource("StyleBoxFlat_sr7ii") +script = ExtResource("1_jmmgu") + +[node name="Label" type="Label" parent="."] +layout_mode = 0 +offset_left = 19.0 +offset_top = 12.0 +offset_right = 798.0 +offset_bottom = 35.0 +text = "Nazwa stacji" +horizontal_alignment = 1 + +[node name="Button" type="Button" parent="."] +layout_mode = 0 +offset_left = 287.0 +offset_top = 220.0 +offset_right = 524.0 +offset_bottom = 367.0 +text = "Zbuduj fregatę" + +[node name="Button2" type="Button" parent="."] +layout_mode = 0 +offset_left = 770.0 +offset_top = 8.0 +offset_right = 799.0 +offset_bottom = 39.0 +text = "X" + +[connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"] diff --git a/scripts/star.gd b/scripts/star.gd index bf18264..d493e91 100644 --- a/scripts/star.gd +++ b/scripts/star.gd @@ -50,6 +50,7 @@ func capture_system(player_name: String) -> void: # Dodaj stację kosmiczną obok gwiazdy var station = station_scene.instantiate() + station.sname = "Stacja kosmiczna" station.position = position + Vector2(35, 0) # obok gwiazdy label.add_theme_color_override("font_color", Color(0.788, 0.332, 0.196, 1.0)) get_parent().add_child(station) diff --git a/scripts/station.gd b/scripts/station.gd new file mode 100644 index 0000000..e9dd354 --- /dev/null +++ b/scripts/station.gd @@ -0,0 +1,16 @@ +extends Node2D +class_name Station + + +# --- Timery --- +var sname: String = "Stacja noName" + + +func _ready(): + var area = $Sprite2D/Area2D + area.connect("input_event", Callable(self, "_on_area_input")) + +func _on_area_input(viewport, event, shape_idx): + if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed: + var panel = get_tree().root.get_node("Galaxy/UI/StationPanel") + panel.show_for_station(self) diff --git a/scripts/station.gd.uid b/scripts/station.gd.uid new file mode 100644 index 0000000..c899ce7 --- /dev/null +++ b/scripts/station.gd.uid @@ -0,0 +1 @@ +uid://dfueb8qi64ld1 diff --git a/scripts/station_panel.gd b/scripts/station_panel.gd new file mode 100644 index 0000000..9f44c01 --- /dev/null +++ b/scripts/station_panel.gd @@ -0,0 +1,28 @@ +extends Panel + + +var dragging := false +var drag_offset := Vector2.ZERO + +func _gui_input(event): + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_LEFT: + if event.pressed: + # Kliknięto na panel → zaczynamy drag + dragging = true + drag_offset = get_local_mouse_position() + else: + # Zwolniono przycisk → kończymy drag + dragging = false + elif event is InputEventMouseMotion and dragging: + # Przesuwamy panel względem pozycji myszy + position += event.relative + + +func show_for_station(station): + self.visible = true + #planet_name_label.text = planet.name + + +func _on_button_2_pressed() -> void: + self.visible = false diff --git a/scripts/station_panel.gd.uid b/scripts/station_panel.gd.uid new file mode 100644 index 0000000..e136224 --- /dev/null +++ b/scripts/station_panel.gd.uid @@ -0,0 +1 @@ +uid://dyf8rbm4f8kmu