Station panel
This commit is contained in:
parent
0337749b5a
commit
84bf97c22d
@ -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"]
|
||||
|
||||
@ -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")
|
||||
|
||||
47
scenes/station_panel.tscn
Normal file
47
scenes/station_panel.tscn
Normal file
@ -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"]
|
||||
@ -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)
|
||||
|
||||
16
scripts/station.gd
Normal file
16
scripts/station.gd
Normal file
@ -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)
|
||||
1
scripts/station.gd.uid
Normal file
1
scripts/station.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dfueb8qi64ld1
|
||||
28
scripts/station_panel.gd
Normal file
28
scripts/station_panel.gd
Normal file
@ -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
|
||||
1
scripts/station_panel.gd.uid
Normal file
1
scripts/station_panel.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dyf8rbm4f8kmu
|
||||
Loading…
x
Reference in New Issue
Block a user