PlanetPanel

This commit is contained in:
Tomasz Boruc 2025-11-06 18:42:11 +01:00
parent e8a1d440ab
commit 569632864a
21 changed files with 487 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://7gwlw2q5ertv"
path="res://.godot/imported/aluminium_ore_mine.png-b32cd3523d9f6a328de1afc0dec49cb3.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/buildings/aluminium_ore_mine.png"
dest_files=["res://.godot/imported/aluminium_ore_mine.png-b32cd3523d9f6a328de1afc0dec49cb3.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://defwms48gviqo"
path="res://.godot/imported/copper_mine.png-218770f80c4ee2dac5e9ec1da1ec9429.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/buildings/copper_mine.png"
dest_files=["res://.godot/imported/copper_mine.png-218770f80c4ee2dac5e9ec1da1ec9429.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bgkx2cmq5mtty"
path="res://.godot/imported/iron_mine.png-09adb0fa3f8dadf1dfed9052fe7c29e0.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/buildings/iron_mine.png"
dest_files=["res://.godot/imported/iron_mine.png-09adb0fa3f8dadf1dfed9052fe7c29e0.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cun726xgsf2cg"
path="res://.godot/imported/residential_zone.png-0f8f4018500f1fd66cc8c1b44bbbf0e8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/buildings/residential_zone.png"
dest_files=["res://.godot/imported/residential_zone.png-0f8f4018500f1fd66cc8c1b44bbbf0e8.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dkm0usj4jbsov"
path="res://.godot/imported/terraforming_center.png-83d765ac435dcb20ed04d79d1d7e9356.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/buildings/terraforming_center.png"
dest_files=["res://.godot/imported/terraforming_center.png-83d765ac435dcb20ed04d79d1d7e9356.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b12lik2ltw8cq"
path="res://.godot/imported/uran_mine.png-bc7e69bc553b2b86d0576f9aa8503c75.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/buildings/uran_mine.png"
dest_files=["res://.godot/imported/uran_mine.png-bc7e69bc553b2b86d0576f9aa8503c75.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://kqib5i82svhh"
path="res://.godot/imported/water_purifier.png-4e2ccc6c76f7b28b9ee2ba073aa00478.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/buildings/water_purifier.png"
dest_files=["res://.godot/imported/water_purifier.png-4e2ccc6c76f7b28b9ee2ba073aa00478.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

View File

@ -6,7 +6,7 @@
"cost": {"iron": 500, "carbon": 200, "uranium": 50}, "cost": {"iron": 500, "carbon": 200, "uranium": 50},
"bonuses": {"biosfere": 0.1}, "bonuses": {"biosfere": 0.1},
"build_time": 15.0, "build_time": 15.0,
"texture": "res://assets/buildings/fusion_plant.png", "texture": "res://assets/buildings/aluminium_ore_mine.png",
"required_tech": "fusion_power" "required_tech": "fusion_power"
} }
} }

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://b1vxl6rs5odt1"] [gd_scene load_steps=8 format=3 uid="uid://b1vxl6rs5odt1"]
[ext_resource type="Script" uid="uid://cts6e8xmnqsax" path="res://scripts/galaxy.gd" id="1_jxn3g"] [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"] [ext_resource type="PackedScene" uid="uid://bbgymc0drqpbx" path="res://scenes/ui/time_display.tscn" id="3_fmtwf"]
@ -6,6 +6,7 @@
[ext_resource type="Script" uid="uid://b4cmg63daeo7g" path="res://scripts/camera_2d.gd" id="4_5xxpo"] [ext_resource type="Script" uid="uid://b4cmg63daeo7g" path="res://scripts/camera_2d.gd" id="4_5xxpo"]
[ext_resource type="Texture2D" uid="uid://baxj0b3uih6jx" path="res://assets/background/Nebulas/n1.png" id="5_kdehn"] [ext_resource type="Texture2D" uid="uid://baxj0b3uih6jx" path="res://assets/background/Nebulas/n1.png" id="5_kdehn"]
[ext_resource type="Script" uid="uid://dpwk3ruw8mx6k" path="res://scripts/background.gd" id="6_xhm0b"] [ext_resource type="Script" uid="uid://dpwk3ruw8mx6k" path="res://scripts/background.gd" id="6_xhm0b"]
[ext_resource type="PackedScene" uid="uid://dgxm8txsiukwf" path="res://scenes/planet_panel.tscn" id="7_xhm0b"]
[node name="Galaxy" type="Node2D"] [node name="Galaxy" type="Node2D"]
script = ExtResource("1_jxn3g") script = ExtResource("1_jxn3g")
@ -47,3 +48,22 @@ z_index = -10
position = Vector2(456, 416) position = Vector2(456, 416)
texture = ExtResource("5_kdehn") texture = ExtResource("5_kdehn")
script = ExtResource("6_xhm0b") script = ExtResource("6_xhm0b")
[node name="UI" type="CanvasLayer" parent="."]
offset = Vector2(50, 50)
transform = Transform2D(1, 0, 0, 1, 50, 50)
[node name="PlanetPanel" parent="UI" instance=ExtResource("7_xhm0b")]
visible = false
anchors_preset = 0
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
offset_left = 790.0
offset_top = 14.0
offset_right = 1090.0
offset_bottom = 398.0
grow_vertical = 1
size_flags_horizontal = 4
size_flags_vertical = 4

79
scenes/planet_panel.tscn Normal file
View File

@ -0,0 +1,79 @@
[gd_scene load_steps=4 format=3 uid="uid://dgxm8txsiukwf"]
[ext_resource type="Script" uid="uid://bqhq0i52dt5lc" path="res://scripts/planet_panel.gd" id="1_b1d0p"]
[ext_resource type="FontFile" uid="uid://chk8jrn2ighpx" path="res://assets/fonts/main_font.ttf" id="2_sqypy"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_sqypy"]
bg_color = Color(0.69411767, 0.32156864, 0.08235294, 0.37254903)
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color(0.7988825, 0.55350196, 0.19976625, 1)
corner_radius_top_left = 2
corner_radius_top_right = 2
corner_radius_bottom_right = 2
corner_radius_bottom_left = 2
[node name="PlanetPanel" type="Panel"]
anchors_preset = -1
anchor_left = 0.499
anchor_top = 0.37300003
anchor_right = 0.499
anchor_bottom = 0.37300003
offset_left = -574.848
offset_top = -241.70401
offset_right = -274.84802
offset_bottom = 255.29599
grow_vertical = 2
size_flags_horizontal = 0
size_flags_vertical = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_sqypy")
script = ExtResource("1_b1d0p")
[node name="Name_Label" type="Label" parent="."]
layout_mode = 0
offset_left = 5.0
offset_top = 3.0
offset_right = 296.0
offset_bottom = 19.0
theme_override_fonts/font = ExtResource("2_sqypy")
theme_override_font_sizes/font_size = 11
text = "Nazwa planety"
horizontal_alignment = 1
[node name="Info_Label" type="Label" parent="."]
layout_mode = 0
offset_left = 5.0
offset_top = 23.0
offset_right = 297.0
offset_bottom = 58.0
theme_override_fonts/font = ExtResource("2_sqypy")
theme_override_font_sizes/font_size = 8
text = "Informacje o planecie..."
autowrap_mode = 2
[node name="Buildings" type="GridContainer" parent="."]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 15.0
offset_top = -56.0
offset_right = -11.0
offset_bottom = -8.0
grow_horizontal = 2
grow_vertical = 0
columns = 7
[node name="Button" type="Button" parent="."]
layout_mode = 0
offset_left = 279.0
offset_top = 1.0
offset_right = 298.0
offset_bottom = 20.0
theme_override_font_sizes/font_size = 7
text = "X"
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]

View File

@ -33,8 +33,8 @@ var BUILDINGS = {
"bonuses": { "bonuses": {
}, },
"build_time": 500.0, "build_time": 20.0,
"texture": "res://assets/buildings/water_purifier.png", "texture": "res://assets/buildings/copper_mine.png",
"required_tech": null "required_tech": null
}, },
"uran_mine": { "uran_mine": {
@ -46,7 +46,7 @@ var BUILDINGS = {
}, },
"build_time": 5.0, "build_time": 5.0,
"texture": "res://assets/buildings/water_purifier.png", "texture": "res://assets/buildings/uran_mine.png",
"required_tech": null "required_tech": null
}, },
"residential_zone": { "residential_zone": {
@ -58,7 +58,7 @@ var BUILDINGS = {
"resource": null, "resource": null,
"cost": {"iron": 80, "carbon": 40}, "cost": {"iron": 80, "carbon": 40},
"build_time": 5.0, "build_time": 5.0,
"texture": "res://assets/buildings/water_purifier.png", "texture": "res://assets/buildings/residential_zone.png",
"required_tech": null "required_tech": null
}, },
"terraforming_center": { "terraforming_center": {
@ -70,7 +70,7 @@ var BUILDINGS = {
"resource": null, "resource": null,
"cost": {"iron": 80, "carbon": 40}, "cost": {"iron": 80, "carbon": 40},
"build_time": 5.0, "build_time": 5.0,
"texture": "res://assets/buildings/water_purifier.png", "texture": "res://assets/buildings/terraforming_center.png",
"required_tech": null "required_tech": null
} }
} }
@ -81,7 +81,7 @@ func _ready():
func _load_mod_buildings(): func _load_mod_buildings():
var mod_path = "res://mods/buildings.json" var mod_path = "res://mods/buildings1.json"
if not FileAccess.file_exists(mod_path): if not FileAccess.file_exists(mod_path):
print("Brak pliku modów: ", mod_path) print("Brak pliku modów: ", mod_path)

View File

@ -43,9 +43,9 @@ func _ready():
# Testowanie funkcji # Testowanie funkcji
print("Lista budynków na planecie:", buildings) #print("Lista budynków na planecie:", buildings)
var data = BuildingsList.BUILDINGS["iron_mine"] #var data = BuildingsList.BUILDINGS["iron_mine"]
print(data.name, data.cost) #print(data.name, data.cost)
func _process(delta): func _process(delta):
@ -79,17 +79,22 @@ func _on_area_input(viewport, event, shape_idx):
func _on_mouse_exited(): func _on_mouse_exited():
info_label.visible = false info_label.visible = false
func _on_mouse_click(): func _on_mouse_click():
colonize() if not is_colonized:
colonize()
else:
var panel = get_tree().root.get_node("Galaxy/UI/PlanetPanel")
panel.show_for_planet(self)
func colonize(): func colonize():
if is_colonized == false: if is_colonized == false:
is_colonized = true is_colonized = true
label.add_theme_color_override("font_color", Color(0.0, 0.454, 0.0, 1.0)) label.add_theme_color_override("font_color", Color(0.0, 0.454, 0.0, 1.0))
add_building("iron_mine") #add_building("iron_mine")
add_building("water_purifier") #add_building("water_purifier")
add_building("terraforming_center") #add_building("terraforming_center")
add_building("aluminium_ore_mine") #add_building("aluminium_ore_mine")
population = 100 population = 100
print_data() print_data()

86
scripts/planet_panel.gd Normal file
View File

@ -0,0 +1,86 @@
extends Panel
@onready var name_label = $Name_Label
@onready var info_label = $Info_Label
@onready var buildings_container = $Buildings
var planet: Planet = null
func _process(delta: float) -> void:
_update_info()
func show_for_planet(p: Planet):
planet = p
name_label.text = p.pname
_update_info()
_create_building_buttons()
show()
func hide_panel():
hide()
planet = null
func _update_info():
if not planet:
return
# Tekst informacji wzorowany na print_data z Planet.gd
var text = "🌍 %s\n" % planet.pname
text += "Biosfera: %.2f\n" % planet.biosfere
text += "Zasobność surowców: %.2f\n" % planet.res_rich
text += "Limit populacji: %s\n" % GameData.format_number(planet.max_pop)
text += "Populacja: %d\n" % int(planet.population)
text += "Status: %s\n" % ("Skolonizowana" if planet.is_colonized else "Nieskolonizowana")
# Surowce
var has_any_resource = false
for key in planet.resources.keys():
var res = planet.resources[key]
if res.has("exist") and res["exist"]:
if not has_any_resource:
text += "Zasoby:\n"
has_any_resource = true
var display_name = tr(key)
text += "%s: %.2f +(%s)\n" % [
display_name,
round(res.get("amount",0)*100)/100.0,
planet.check_growth()
]
# Budynki
if planet.buildings.size() > 0:
text += "Budynki na planecie:\n"
for b in planet.buildings:
var data = BuildingsList.BUILDINGS[b.id]
var status = tr("Under construction") if b.is_building else tr("ready")
text += "- %s [%s]\n" % [tr(data.name), status]
info_label.text = text
func _create_building_buttons():
# Usuń stare przyciski
for child in buildings_container.get_children():
child.queue_free()
# Tworzymy nowe przyciski dla wszystkich budynków w definicjach
for b_id in BuildingsList.BUILDINGS.keys():
var b_data = BuildingsList.BUILDINGS[b_id]
var btn = TextureButton.new()
btn.texture_normal = load(b_data.texture)
btn.scale = Vector2(0.22,0.22)
#btn.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT_COVERED
# Możesz ustawić skalowanie lub minimalny rozmiar:
btn.connect("pressed", Callable(self, "_on_building_pressed").bind(b_id))
buildings_container.add_child(btn)
func _on_building_pressed(b_id):
if not planet:
return
planet.add_building(b_id)
_update_info()
func _on_button_pressed() -> void:
hide_panel()

View File

@ -0,0 +1 @@
uid://bqhq0i52dt5lc