diff --git a/global/event_bus.gd b/global/event_bus.gd index 16fcc51..9d43f2f 100644 --- a/global/event_bus.gd +++ b/global/event_bus.gd @@ -3,6 +3,7 @@ extends Node signal population_update(count:int) signal receive_data_from_browser(args) signal set_structure(structure:Structure) +signal structure_unlocked(structure:Structure) var current_scene = null diff --git a/global/globals.gd b/global/globals.gd index dbbb39b..e2c23c3 100644 --- a/global/globals.gd +++ b/global/globals.gd @@ -26,4 +26,8 @@ func set_structure(structure:Structure) -> void: # Emit the signal to notify other nodes EventBus.set_structure.emit(structure) + +# Used when a new structure is unlocked +func structure_unlocked(structure:Structure) ->void: + EventBus.structure_unlocked.emit(structure) diff --git a/mission/unit_1.02/unlock_buildings.tres b/mission/unit_1.02/unlock_buildings.tres index f3341d6..27f0dec 100644 --- a/mission/unit_1.02/unlock_buildings.tres +++ b/mission/unit_1.02/unlock_buildings.tres @@ -9,7 +9,7 @@ script = ExtResource("1_objective") type = 0 target_count = 3 current_count = 0 -description = "Build 3 Type A houses to unlock all building types" +description = "Build 3 Fountains to unlock all homes!" completed = false structure = ExtResource("2_hfe31") diff --git a/scenes/sticky_builder.tscn b/scenes/sticky_builder.tscn index 9cab0e6..79dc069 100644 --- a/scenes/sticky_builder.tscn +++ b/scenes/sticky_builder.tscn @@ -32,11 +32,8 @@ layout_mode = 2 [node name="Roads" type="MenuButton" parent="Panel/VBoxContainer/Row_1_HBoxContainer"] layout_mode = 2 -tooltip_text = "Residential Structures" +tooltip_text = "Roads" icon = ExtResource("6_46yqr") -item_count = 1 -popup/item_0/text = "Residential" -popup/item_0/id = 0 script = ExtResource("2_sqdls") [node name="Residential" type="MenuButton" parent="Panel/VBoxContainer/Row_1_HBoxContainer"] @@ -61,7 +58,7 @@ filter_type = 2 [node name="Industrial" type="MenuButton" parent="Panel/VBoxContainer/Row_2_HBoxContainer2"] layout_mode = 2 -tooltip_text = "Residential Structures" +tooltip_text = "Industrial Structures" icon = ExtResource("4_ebilp") item_count = 1 popup/item_0/text = "Residential" @@ -74,14 +71,14 @@ layout_mode = 2 [node name="Power" type="MenuButton" parent="Panel/VBoxContainer/Row_3_HBoxContainer3"] layout_mode = 2 -tooltip_text = "Commercial Structures" +tooltip_text = "Power Structures" icon = ExtResource("6_r3beh") script = ExtResource("2_sqdls") filter_type = 6 [node name="Landscape" type="MenuButton" parent="Panel/VBoxContainer/Row_3_HBoxContainer3"] layout_mode = 2 -tooltip_text = "Commercial Structures" +tooltip_text = "Landscaping" icon = ExtResource("5_46yqr") script = ExtResource("2_sqdls") filter_type = 5 diff --git a/scenes/ui/sticky_builder/pop-up-menu-generator.gd b/scenes/ui/sticky_builder/pop-up-menu-generator.gd index ab3e7cd..01c692f 100644 --- a/scenes/ui/sticky_builder/pop-up-menu-generator.gd +++ b/scenes/ui/sticky_builder/pop-up-menu-generator.gd @@ -15,7 +15,10 @@ func _ready(): # Add to group for easy refreshing of all structure menus add_to_group("structure_menus") + + EventBus.structure_unlocked.connect(_on_structure_unlock) + # Load icons (you'll need to create or find these icons) _lock_icon = load("res://sprites/sticky_builder_icons/lock.png") if ResourceLoader.exists("res://sprites/sticky_builder_icons/lock.png") else null if(_lock_icon): @@ -60,6 +63,8 @@ func _populate_menu(): popup.clear() var current_size_category = -1 + var menu_item_to_structure_index = {} # Map menu item IDs to structure indices + var current_item_id = 0 for i in range(_structures.size()): var structure = _structures[i] @@ -67,6 +72,7 @@ func _populate_menu(): if structure.size_category != current_size_category: if i > 0: popup.add_separator() + current_item_id += 1 current_size_category = structure.size_category # Add size category header (optional) @@ -107,16 +113,24 @@ func _populate_menu(): if not structure.unlocked: if _lock_icon: popup.add_icon_item(_lock_icon, item_text) - popup.set_item_disabled(popup.item_count - 1, true) + popup.set_item_disabled(current_item_id, true) + menu_item_to_structure_index[current_item_id] = i + current_item_id += 1 else: - popup.add_item(item_text, i) + var icon = load(structure.icon) if ResourceLoader.exists(structure.icon) else null + popup.add_icon_item(icon, item_text) + menu_item_to_structure_index[current_item_id] = i + current_item_id += 1 + + # Store the mapping for use in _on_item_selected + set_meta("menu_item_to_structure_index", menu_item_to_structure_index) # Handle the menu item selection func _on_item_selected(id: int): - if id >= 0 and id < _structures.size(): - var selected_structure = _structures[id] - # Get the original structure index in the builder's structure array - var structure_resource_path = selected_structure.resource_path + var menu_item_to_structure_index = get_meta("menu_item_to_structure_index", {}) + if id in menu_item_to_structure_index: + var structure_index = menu_item_to_structure_index[id] + var selected_structure = _structures[structure_index] Globals.set_structure(selected_structure) # Consume the input event to prevent it from reaching the game get_viewport().set_input_as_handled() @@ -178,3 +192,6 @@ func _unhandled_input(event: InputEvent) -> void: get_viewport().set_input_as_handled() if event is InputEventMouseButton: event.pressed = false + +func _on_structure_unlock(structure:Structure)->void: + refresh() diff --git a/scripts/builder.gd b/scripts/builder.gd index 2679990..d86c159 100644 --- a/scripts/builder.gd +++ b/scripts/builder.gd @@ -578,8 +578,13 @@ func action_clear_selection(): # Toggle between structures to build func action_structure_toggle(structure:Structure): - var found_index = _structures.find(structure) - if not found_index: + var found_index = -1 + for i in range(_structures.size()): + if _structures[i].resource_path == structure.resource_path: + found_index = i + break + + if found_index == -1: print("No structure found!") else: index = found_index diff --git a/scripts/building_selector.gd b/scripts/building_selector.gd index 87639af..366c20c 100644 --- a/scripts/building_selector.gd +++ b/scripts/building_selector.gd @@ -166,7 +166,7 @@ func _create_filter_buttons(): # Get unique structure types var structure_types = {} for structure in builder.get_structures(): - if structure.type == Structure.StructureType.TERRAIN: + if structure.type == Structure.StructureType.LANDSCAPE: structure_types["Ground"] = true else: structure_types["Buildings"] = true @@ -216,14 +216,14 @@ func _create_option_buttons(): if current_filter != "All": match current_filter: "Ground": - if structure.type != Structure.StructureType.TERRAIN: + if structure.type != Structure.StructureType.LANDSCAPE: continue "Buildings": - if structure.type == Structure.StructureType.TERRAIN: + if structure.type == Structure.StructureType.LANDSCAPE: continue # Add to appropriate list - if structure.type == Structure.StructureType.TERRAIN: + if structure.type == Structure.StructureType.LANDSCAPE: ground_structures.append(structure) else: building_structures.append(structure) diff --git a/scripts/mission/mission_loader.gd b/scripts/mission/mission_loader.gd index b797ea7..0e49d4b 100644 --- a/scripts/mission/mission_loader.gd +++ b/scripts/mission/mission_loader.gd @@ -93,6 +93,8 @@ func _unlock_starting_structures(structure_paths: Array) -> void: if structure_path == possible_path: structure.unlocked = true found_match = true + # Let the rest of the game know a structure has been unlocked + Globals.structure_unlocked(structure) break if found_match: diff --git a/scripts/mission/mission_manager.gd b/scripts/mission/mission_manager.gd index 067ec6a..77dfa41 100644 --- a/scripts/mission/mission_manager.gd +++ b/scripts/mission/mission_manager.gd @@ -864,6 +864,7 @@ func _handle_structure_unlocking(mission): if "unlocked" in structure: structure.unlocked = true unlocked_structures.append(structure) + Globals.structure_unlocked(structure) found = true if not found: print("[Unlock] No match found for item_path: ", item_path) diff --git a/scripts/structure.gd b/scripts/structure.gd index 8eb9d74..a947c1e 100644 --- a/scripts/structure.gd +++ b/scripts/structure.gd @@ -39,6 +39,10 @@ enum SizeCategory { @export_subgroup("Visual") @export var selector_scale:float = 1.0 # Scale factor for the selector when this structure is selected +@export var thumbnail: String = "Thumbnail" # Display for player +@export var icon: String = "" # Small version of thumbnail. I know thumbnail should be small... But I messed up already so here we are xD. + + @export_subgroup("Game Progression") @export var unlocked:bool = false # Whether this structure is available to the player @@ -48,7 +52,3 @@ enum SizeCategory { @export_subgroup("Game Progression") @export var description: String = "Description" # Whether this structure is available to the player - - -@export_subgroup("Game Progression") -@export var thumbnail: String = "Thumbnail" # Whether this structure is available to the player diff --git a/sprites/updated/power-plant.png b/sprites/updated/power-plant.png deleted file mode 100644 index acdbe0b..0000000 Binary files a/sprites/updated/power-plant.png and /dev/null differ diff --git a/sprites/updated/power-plant.png.import b/sprites/updated/power-plant.png.import deleted file mode 100644 index 7293f39..0000000 --- a/sprites/updated/power-plant.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://3wvmf0xvpx53" -path="res://.godot/imported/power-plant.png-ab18836cf433027f79b47cfc0a22f79a.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sprites/updated/power-plant.png" -dest_files=["res://.godot/imported/power-plant.png-ab18836cf433027f79b47cfc0a22f79a.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/sprites/updated/store.png b/sprites/updated/store.png index 2212a5d..aa0d06a 100644 Binary files a/sprites/updated/store.png and b/sprites/updated/store.png differ diff --git a/structures/building-garage.tres b/structures/building-garage.tres index a325528..8037f06 100644 --- a/structures/building-garage.tres +++ b/structures/building-garage.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 0.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/garage.png" +icon = "res://sprites/updated/icon/garage_icon.png" unlocked = false spawn_builder = true description = "Garage" -thumbnail = "res://sprites/updated/garage.png" diff --git a/structures/building-small-a.tres b/structures/building-small-a.tres index e4bff39..e6234c7 100644 --- a/structures/building-small-a.tres +++ b/structures/building-small-a.tres @@ -14,7 +14,8 @@ population_count = 1 kW_usage = 1.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/building-small-a.png" +icon = "res://sprites/updated/icon/building-small-a_icon.png" unlocked = false -spawn_builder = false +spawn_builder = true description = "A small residential building that can house 1 person. Perfect for getting your city started!" -thumbnail = "res://sprites/updated/building-small-a.png" diff --git a/structures/building-small-b.tres b/structures/building-small-b.tres index c756e25..1ed7495 100644 --- a/structures/building-small-b.tres +++ b/structures/building-small-b.tres @@ -7,14 +7,15 @@ script = ExtResource("2_a2t3e") title = "Medium Residential" type = 1 -price = 60 +price = 100 size_category = 1 model = ExtResource("1_klt7o") population_count = 10 kW_usage = 1.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/building-small-b.png" +icon = "res://sprites/updated/icon/building-small-b_icon.png" unlocked = false -spawn_builder = false +spawn_builder = true description = "A slightly larger residential building that can house 1 person. A good upgrade from the basic house!" -thumbnail = "res://sprites/updated/building-small-b.png" diff --git a/structures/building-small-c.tres b/structures/building-small-c.tres index 3734cb0..adf91c0 100644 --- a/structures/building-small-c.tres +++ b/structures/building-small-c.tres @@ -7,14 +7,15 @@ script = ExtResource("2_rkiq0") title = "Large Residential" type = 1 -price = 70 +price = 200 size_category = 2 model = ExtResource("1_6yyww") population_count = 20 kW_usage = 1.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/building-small-c.png" +icon = "res://sprites/updated/icon/building-small-c_icon.png" unlocked = false spawn_builder = true description = "A spacious multi-story apartment complex that comfortably houses 5 citizens, providing efficient population growth for your expanding city." -thumbnail = "res://sprites/updated/building-small-c.png" diff --git a/structures/grass-trees-tall.tres b/structures/grass-trees-tall.tres index bd4f176..0164f2b 100644 --- a/structures/grass-trees-tall.tres +++ b/structures/grass-trees-tall.tres @@ -7,14 +7,15 @@ script = ExtResource("2_b2sah") title = "Tall Trees" type = 5 -price = 25 +price = 50 size_category = 0 model = ExtResource("1_nbdd1") population_count = 0 kW_usage = 0.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/grass-trees-tall.png" +icon = "res://sprites/updated/icon/grass-trees-tall_icon.png" unlocked = false spawn_builder = false description = "A lush area featuring small trees that provides shade, clean air, and a pleasant atmosphere for nearby residents." -thumbnail = "res://sprites/updated/grass-trees-tall.png" diff --git a/structures/grass-trees.tres b/structures/grass-trees.tres index 65cb0bc..67cc01b 100644 --- a/structures/grass-trees.tres +++ b/structures/grass-trees.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 0.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/grass-trees.png" +icon = "res://sprites/updated/icon/grass-trees_icon.png" unlocked = false spawn_builder = false description = "Some cool trees and grass!" -thumbnail = "res://sprites/updated/grass-trees.png" diff --git a/structures/grass.tres b/structures/grass.tres index 1a94807..5bc2aec 100644 --- a/structures/grass.tres +++ b/structures/grass.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 0.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/grass.png" +icon = "res://sprites/updated/icon/grass_icon.png" unlocked = false spawn_builder = false description = "Some lush green grass!" -thumbnail = "res://sprites/residential/grass.png" diff --git a/structures/pavement-fountain.tres b/structures/pavement-fountain.tres index 594f841..e0bab0a 100644 --- a/structures/pavement-fountain.tres +++ b/structures/pavement-fountain.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 0.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/fountain.png" +icon = "res://sprites/updated/icon/fountain_icon.png" unlocked = false spawn_builder = false description = "A beautiful centerpiece that adds charm to your city while providing citizens with a place to relax and socialize." -thumbnail = "res://sprites/updated/fountain.png" diff --git a/structures/pavement.tres b/structures/pavement.tres index a9a05a8..7208693 100644 --- a/structures/pavement.tres +++ b/structures/pavement.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 0.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/icon/pavement_icon.png" +icon = "res://sprites/updated/icon/pavement_icon.png" unlocked = false spawn_builder = false description = "A pedestrian-friendly surface that creates walkable areas and enhances the appearance of your city spaces." -thumbnail = "res://sprites/updated/pavement.png" diff --git a/structures/power-plant.tres b/structures/power-plant.tres index 1c0c4d3..b7d33a8 100644 --- a/structures/power-plant.tres +++ b/structures/power-plant.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 0.0 kW_production = 40.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/power_plant.png" +icon = "res://sprites/updated/icon/power_plant_icon.png" unlocked = false spawn_builder = false description = "A power-generating facility that produces electricity to keep your city's buildings operational and citizens happy. Produces 40 kW of energy." -thumbnail = "res://sprites/updated/power-plant.png" diff --git a/structures/road-corner.tres b/structures/road-corner.tres index d5bdb85..3caf740 100644 --- a/structures/road-corner.tres +++ b/structures/road-corner.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 0.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/roads/road-corner.png" +icon = "res://sprites/roads/icon/road-corner_icon.png" unlocked = false spawn_builder = false description = "A gently curved road section that helps create more natural and flowing city layouts." -thumbnail = "res://sprites/roads/road-corner.png" diff --git a/structures/road-intersection.tres b/structures/road-intersection.tres index aceb932..17e14d9 100644 --- a/structures/road-intersection.tres +++ b/structures/road-intersection.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 0.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/roads/intersection.png" +icon = "res://sprites/roads/icon/intersection_icon.png" unlocked = false spawn_builder = false description = "A crucial junction where roads meet, allowing traffic to flow in multiple directions throughout your city." -thumbnail = "res://sprites/updated/road-intersection.png" diff --git a/structures/road-split.tres b/structures/road-split.tres index 8ba76a5..48f4113 100644 --- a/structures/road-split.tres +++ b/structures/road-split.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 0.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/road-split.png" +icon = "res://sprites/updated/icon/road-split_icon.png" unlocked = false spawn_builder = false description = "Road Split" -thumbnail = "res://sprites/updated/road-split.png" diff --git a/structures/road-straight-lightposts.tres b/structures/road-straight-lightposts.tres index 5eb7373..7612135 100644 --- a/structures/road-straight-lightposts.tres +++ b/structures/road-straight-lightposts.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 0.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/icon/road-straight-light_icon.png" +icon = "res://sprites/updated/icon/road-straight-light_icon.png" unlocked = false spawn_builder = false description = "An illuminated road segment that provides safety and visibility for your citizens at night." -thumbnail = "res://sprites/updated/road-straight-light.png" diff --git a/structures/road-straight.tres b/structures/road-straight.tres index 2d573ae..ea3e015 100644 --- a/structures/road-straight.tres +++ b/structures/road-straight.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 0.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/road-straight.png" +icon = "res://sprites/updated/icon/road-straight_icon.png" unlocked = false spawn_builder = false description = "A basic road for connecting parts of your city." -thumbnail = "res://sprites/updated/road-straight.png" diff --git a/structures/store.tres b/structures/store.tres index 249202e..cb5e0a9 100644 --- a/structures/store.tres +++ b/structures/store.tres @@ -14,7 +14,8 @@ population_count = 0 kW_usage = 1.0 kW_production = 0.0 selector_scale = 2.8 +thumbnail = "res://sprites/updated/store.png" +icon = "res://sprites/updated/icon/store_icon.png" unlocked = false spawn_builder = true description = "A commercial building where citizens can purchase goods, providing essential services while generating income for your city." -thumbnail = "res://sprites/updated/store.png"