Add building icons to build menu

This commit is contained in:
Ategon 2024-09-11 22:40:54 -04:00
parent 8bb05c7400
commit e1753a1587
28 changed files with 423 additions and 17 deletions

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=12 format=3 uid="uid://5ske2hm55rce"] [gd_scene load_steps=14 format=3 uid="uid://5ske2hm55rce"]
[ext_resource type="Theme" uid="uid://d035h7upxrw3h" path="res://theme.tres" id="1_xbn5h"] [ext_resource type="Theme" uid="uid://d035h7upxrw3h" path="res://theme.tres" id="1_xbn5h"]
[ext_resource type="Texture2D" uid="uid://bsrh0u02bckhy" path="res://iso_building.png" id="3_qa5pv"] [ext_resource type="Texture2D" uid="uid://bsrh0u02bckhy" path="res://iso_building.png" id="3_qa5pv"]
[ext_resource type="Texture2D" uid="uid://bvn5lewpp7pmd" path="res://iso_tile.png" id="4_7pks7"] [ext_resource type="Texture2D" uid="uid://bvn5lewpp7pmd" path="res://iso_tile.png" id="4_7pks7"]
[ext_resource type="Texture2D" uid="uid://bdmao1k7ngu2m" path="res://basic_tiles.png" id="4_h72lx"]
[ext_resource type="PackedScene" uid="uid://dykc1mgg5uopw" path="res://components/Cursor/MouseHandler.tscn" id="5_6lpdu"] [ext_resource type="PackedScene" uid="uid://dykc1mgg5uopw" path="res://components/Cursor/MouseHandler.tscn" id="5_6lpdu"]
[ext_resource type="Script" path="res://tile_map.gd" id="5_v47eg"] [ext_resource type="Script" path="res://tile_map.gd" id="5_v47eg"]
[ext_resource type="PackedScene" uid="uid://byyyhq3x8t2d8" path="res://InfoWindow.tscn" id="7_f4xfy"] [ext_resource type="PackedScene" uid="uid://byyyhq3x8t2d8" path="res://InfoWindow.tscn" id="7_f4xfy"]
@ -21,15 +22,27 @@ texture_region_size = Vector2i(18, 20)
1:1/0 = 0 1:1/0 = 0
0:0/0 = 0 0:0/0 = 0
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_w6tof"]
texture = ExtResource("4_h72lx")
1:3/0 = 0
3:3/0 = 0
1:6/0 = 0
3:6/0 = 0
1:7/0 = 0
3:7/0 = 0
1:1/0 = 0
3:1/0 = 0
[sub_resource type="TileSet" id="TileSet_2mye8"] [sub_resource type="TileSet" id="TileSet_2mye8"]
tile_shape = 1 tile_shape = 1
tile_layout = 5 tile_layout = 5
tile_size = Vector2i(16, 8) tile_size = Vector2i(16, 8)
sources/0 = SubResource("TileSetAtlasSource_dxrqb") sources/0 = SubResource("TileSetAtlasSource_dxrqb")
sources/1 = SubResource("TileSetAtlasSource_j7eew") sources/1 = SubResource("TileSetAtlasSource_j7eew")
sources/2 = SubResource("TileSetAtlasSource_w6tof")
[sub_resource type="CircleShape2D" id="CircleShape2D_s8q4l"] [sub_resource type="CircleShape2D" id="CircleShape2D_s8q4l"]
radius = 134.7 radius = 150.083
[node name="Main" type="Node2D"] [node name="Main" type="Node2D"]
@ -52,7 +65,7 @@ layer_5/name = "Layer5"
script = ExtResource("5_v47eg") script = ExtResource("5_v47eg")
[node name="MouseHandler" parent="TileMap" instance=ExtResource("5_6lpdu")] [node name="MouseHandler" parent="TileMap" instance=ExtResource("5_6lpdu")]
position = Vector2(318, 178) position = Vector2(319, 177)
[node name="CollisionShape2D" type="CollisionShape2D" parent="TileMap/MouseHandler"] [node name="CollisionShape2D" type="CollisionShape2D" parent="TileMap/MouseHandler"]
shape = SubResource("CircleShape2D_s8q4l") shape = SubResource("CircleShape2D_s8q4l")
@ -65,10 +78,6 @@ offset = Vector2(50, 150)
[node name="InfoWindow" parent="CanvasLayer" instance=ExtResource("7_f4xfy")] [node name="InfoWindow" parent="CanvasLayer" instance=ExtResource("7_f4xfy")]
[node name="ColorRect" type="ColorRect" parent="CanvasLayer"]
offset_right = 40.0
offset_bottom = 40.0
[node name="BuildingMenu" parent="CanvasLayer" instance=ExtResource("7_hnxcf")] [node name="BuildingMenu" parent="CanvasLayer" instance=ExtResource("7_hnxcf")]
[connection signal="clicked" from="TileMap/MouseHandler" to="TileMap" method="_on_mouse_handler_clicked"] [connection signal="clicked" from="TileMap/MouseHandler" to="TileMap" method="_on_mouse_handler_clicked"]

BIN
basic_tiles.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

34
basic_tiles.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bdmao1k7ngu2m"
path="res://.godot/imported/basic_tiles.png-ab6e820af8e93675a192b178dda8db52.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://basic_tiles.png"
dest_files=["res://.godot/imported/basic_tiles.png-ab6e820af8e93675a192b178dda8db52.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c3t66sxwk078m"
path="res://.godot/imported/essencecompressor.png-a45065e3eea03ba6fb01c8afde8da972.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://parts/buildings/images/essencecompressor.png"
dest_files=["res://.godot/imported/essencecompressor.png-a45065e3eea03ba6fb01c8afde8da972.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dq1nxn0olq4a2"
path="res://.godot/imported/foodgathering.png-64bc2c4bdac412bbc303883b7381019e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://parts/buildings/images/foodgathering.png"
dest_files=["res://.godot/imported/foodgathering.png-64bc2c4bdac412bbc303883b7381019e.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://clqov5mu3bpaw"
path="res://.godot/imported/foodprocessing.png-93b159c111f7b301f0dbec88a0beeca7.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://parts/buildings/images/foodprocessing.png"
dest_files=["res://.godot/imported/foodprocessing.png-93b159c111f7b301f0dbec88a0beeca7.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dyhnvokmhlapt"
path="res://.godot/imported/house.png-1cede27122f87d242275cf359539f076.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://parts/buildings/images/house.png"
dest_files=["res://.godot/imported/house.png-1cede27122f87d242275cf359539f076.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dt43okssvt2ay"
path="res://.godot/imported/quarter.png-6f5b23f21d2704e7f7b52b6cf64e7c7e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://parts/buildings/images/quarter.png"
dest_files=["res://.godot/imported/quarter.png-6f5b23f21d2704e7f7b52b6cf64e7c7e.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dc67sn4g5g2gn"
path="res://.godot/imported/stoneminer.png-4d0191dd1b957fed4add4ef912fef27e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://parts/buildings/images/stoneminer.png"
dest_files=["res://.godot/imported/stoneminer.png-4d0191dd1b957fed4add4ef912fef27e.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bomiraglprech"
path="res://.godot/imported/tents.png-876fae9045d4187edeadba975c811045.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://parts/buildings/images/tents.png"
dest_files=["res://.godot/imported/tents.png-876fae9045d4187edeadba975c811045.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://coq1mt1xvgtth"
path="res://.godot/imported/waterprocessor.png-4300e01b984db021624fc14cf6dcc18f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://parts/buildings/images/waterprocessor.png"
dest_files=["res://.godot/imported/waterprocessor.png-4300e01b984db021624fc14cf6dcc18f.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://csjs5e2nd7iq5"
path="res://.godot/imported/waterpump.png-6d40149963036693705cd9b7988c4f8a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://parts/buildings/images/waterpump.png"
dest_files=["res://.godot/imported/waterpump.png-6d40149963036693705cd9b7988c4f8a.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://gaiht2weca4g"
path="res://.godot/imported/woodcutter.png-af2c78c5fdf0b871c27086af0c335dfa.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://parts/buildings/images/woodcutter.png"
dest_files=["res://.godot/imported/woodcutter.png-af2c78c5fdf0b871c27086af0c335dfa.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

View file

@ -1,7 +1,7 @@
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://d035h7upxrw3h"] [gd_resource type="Theme" load_steps=2 format=3 uid="uid://d035h7upxrw3h"]
[ext_resource type="FontFile" uid="uid://cq86fc0y2nf47" path="res://Qubi.ttf" id="1_fvh8h"] [ext_resource type="FontFile" uid="uid://d0or8uewq7xxw" path="res://Ac437_IBM_BIOS.ttf" id="1_6qau7"]
[resource] [resource]
default_font = ExtResource("1_fvh8h") default_font = ExtResource("1_6qau7")
default_font_size = 8 default_font_size = 5

View file

@ -65,7 +65,7 @@ func _ready():
layer_number = 5 layer_number = 5
print("x- ",x," y- ",y," layer- ",layer_number) print("x- ",x," y- ",y," layer- ",layer_number)
for layer in layer_number: for layer in layer_number:
set_cell(layer, Vector2(x, y), 0, Vector2i(0,0), 0) set_cell(layer, Vector2(x, y), 2, Vector2i(1, 1), 0)
Dic[str(Vector2(x,y))] = { Dic[str(Vector2(x,y))] = {
"Layer": layer_number, "Layer": layer_number,
"Placed": false "Placed": false
@ -79,7 +79,6 @@ func _process(delta):
for y in GridSize: for y in GridSize:
if !Dic[str(Vector2(x,y))].get("Placed"): if !Dic[str(Vector2(x,y))].get("Placed"):
erase_cell(Dic[str(Vector2(x,y))].get("Layer"), Vector2(x,y)) erase_cell(Dic[str(Vector2(x,y))].get("Layer"), Vector2(x,y))
pass
if Dic.has(str(tile)): if Dic.has(str(tile)):
set_cell(Dic[str(tile)].get("Layer"), tile, 1, Vector2i(0,0), 0) set_cell(Dic[str(tile)].get("Layer"), tile, 1, Vector2i(0,0), 0)
@ -97,4 +96,3 @@ func _on_mouse_handler_rclicked():
for y in GridSize: for y in GridSize:
if !Dic[str(Vector2(x,y))].get("Placed"): if !Dic[str(Vector2(x,y))].get("Placed"):
erase_cell(Dic[str(Vector2(x,y))].get("Layer"), Vector2(x,y)) erase_cell(Dic[str(Vector2(x,y))].get("Layer"), Vector2(x,y))
pass

View file

@ -1,4 +1,23 @@
[gd_scene format=3 uid="uid://b7o2i7tgirg64"] [gd_scene load_steps=3 format=3 uid="uid://b7o2i7tgirg64"]
[ext_resource type="Script" path="res://ui/building_icon.gd" id="1_6qgij"]
[ext_resource type="Texture2D" uid="uid://c3t66sxwk078m" path="res://parts/buildings/images/essencecompressor.png" id="1_62uie"]
[node name="BuildingIcon" type="ColorRect"] [node name="BuildingIcon" type="ColorRect"]
custom_minimum_size = Vector2(32, 32) custom_minimum_size = Vector2(32, 32)
script = ExtResource("1_6qgij")
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -24.0
offset_top = -24.0
offset_right = 24.0
offset_bottom = 24.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("1_62uie")

3
ui/building_icon.gd Normal file
View file

@ -0,0 +1,3 @@
extends ColorRect
@onready var texture_rect: TextureRect = $TextureRect

View file

@ -4,7 +4,9 @@ extends Control
$HBoxContainer/BuildingTab, $HBoxContainer/BuildingTab2, $HBoxContainer/BuildingTab3 $HBoxContainer/BuildingTab, $HBoxContainer/BuildingTab2, $HBoxContainer/BuildingTab3
] ]
@onready var building_data = Data.data.buildings.values() @onready var building_data = Data.data.buildings
@onready var buildings = building_data.keys()
@onready var v_box_container: HBoxContainer = $Buildings/VBoxContainer @onready var v_box_container: HBoxContainer = $Buildings/VBoxContainer
@ -33,11 +35,12 @@ func swap_to_tab(index):
else: else:
tabs[i].unselect() tabs[i].unselect()
var buildings = building_data.filter(func(a): return a.type == tabs[index].key) var filtered_buildings = buildings.filter(func(building): return building_data[building].type == tabs[index].key)
for i in range(0, icons.size()): for i in range(0, icons.size()):
if i < buildings.size(): if i < filtered_buildings.size():
icons[i].visible = true icons[i].visible = true
icons[i].texture_rect.texture = Data.data.images[filtered_buildings[i]]
if i > 0: if i > 0:
spacers[i - 1].visible = true spacers[i - 1].visible = true