From a2427ff4ff6eff7258e077a3cd0bd6fb3df41408 Mon Sep 17 00:00:00 2001 From: rainlizard <15337628+rainlizard@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:20:27 +1000 Subject: [PATCH] room icons use strings --- Autoload/Slabs.gd | 45 ++++++++++++++++++++++---------------- Scenes/ResearchableItem.gd | 3 ++- Scenes/ScriptGenerator.gd | 5 +++-- Scenes/SlabDisplay.gd | 5 +++-- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/Autoload/Slabs.gd b/Autoload/Slabs.gd index 92894235..35ee42ac 100644 --- a/Autoload/Slabs.gd +++ b/Autoload/Slabs.gd @@ -197,6 +197,11 @@ func fetch_name(slabID): else: return getName +func fetch_idname(slabID): + var slabData = data.get(slabID) + if slabData: + return slabData[NAME] + return "" var data = { 00: ["HARD", BLOCK_SLAB, BITMASK_BLOCK, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 0 @@ -259,25 +264,27 @@ var data = { var icons = { - BARRACKS: preload("res://dk_images/room_64/armory_std.png"), - BRIDGE: preload("res://dk_images/room_64/bridge_std.png"), - GRAVEYARD: preload("res://dk_images/room_64/graveyard_std.png"), - GUARD_POST: preload("res://dk_images/room_64/grdpost_std.png"), - HATCHERY: preload("res://dk_images/room_64/hatchery_std.png"), - LAIR: preload("res://dk_images/room_64/lair_std.png"), - PRISON: preload("res://dk_images/room_64/prison_std.png"), - LIBRARY: preload("res://dk_images/room_64/research_std.png"), - SCAVENGER_ROOM: preload("res://dk_images/room_64/scavenge_std.png"), - TEMPLE: preload("res://dk_images/room_64/temple_std.png"), - TORTURE_CHAMBER: preload("res://dk_images/room_64/torture_std.png"), - TRAINING_ROOM: preload("res://dk_images/room_64/training_std.png"), - TREASURE_ROOM: preload("res://dk_images/room_64/treasury_std.png"), - WORKSHOP: preload("res://dk_images/room_64/workshop_std.png"), - WOODEN_DOOR_2: preload("res://dk_images/trapdoor_64/door_pers_wood_std.png"), - BRACED_DOOR_2: preload("res://dk_images/trapdoor_64/door_pers_braced_std.png"), - IRON_DOOR_2: preload("res://dk_images/trapdoor_64/door_pers_iron_std.png"), - MAGIC_DOOR_2: preload("res://dk_images/trapdoor_64/door_pers_magic_std.png"), - DUNGEON_HEART: preload("res://dk_images/crucials/anim0949/r1frame01.png"), +"BARRACK_AREA": preload("res://dk_images/room_64/armory_std.png"), +"BRIDGE_FRAME": preload("res://dk_images/room_64/bridge_std.png"), +"GRAVE_AREA": preload("res://dk_images/room_64/graveyard_std.png"), +"GUARD_AREA": preload("res://dk_images/room_64/grdpost_std.png"), +"HATCHERY": preload("res://dk_images/room_64/hatchery_std.png"), +"LAIR_AREA": preload("res://dk_images/room_64/lair_std.png"), +"PRISON_AREA": preload("res://dk_images/room_64/prison_std.png"), +"BOOK_SHELVES": preload("res://dk_images/room_64/research_std.png"), +"SCAVENGE_AREA": preload("res://dk_images/room_64/scavenge_std.png"), +"TEMPLE_POOL": preload("res://dk_images/room_64/temple_std.png"), +"TORTURE_AREA": preload("res://dk_images/room_64/torture_std.png"), +"TRAINING_AREA": preload("res://dk_images/room_64/training_std.png"), +"TREASURY_AREA": preload("res://dk_images/room_64/treasury_std.png"), +"WORKSHOP_AREA": preload("res://dk_images/room_64/workshop_std.png"), +"DOOR_WOODEN2": preload("res://dk_images/trapdoor_64/door_pers_wood_std.png"), +"DOOR_BRACE2": preload("res://dk_images/trapdoor_64/door_pers_braced_std.png"), +"DOOR_STEEL2": preload("res://dk_images/trapdoor_64/door_pers_iron_std.png"), +"DOOR_MAGIC2": preload("res://dk_images/trapdoor_64/door_pers_magic_std.png"), +"HEART_PEDESTAL": preload("res://dk_images/crucials/anim0949/r1frame01.png"), +"DOOR_SECRET": preload("res://extra_images/secret_door.png"), +"DOOR_SECRET2": preload("res://extra_images/secret_door.png"), } var slabOrder = [ diff --git a/Scenes/ResearchableItem.gd b/Scenes/ResearchableItem.gd index a5a6fdfd..561a83b0 100644 --- a/Scenes/ResearchableItem.gd +++ b/Scenes/ResearchableItem.gd @@ -40,7 +40,8 @@ func set_magic_texture(subtype): func set_room_texture(slabID): var oTextureRectIcon = $"HBoxContainer/TextureRectIcon" - oTextureRectIcon.texture = Slabs.icons[slabID] + var slabName = Slabs.fetch_idname(slabID) + oTextureRectIcon.texture = Slabs.icons.get(slabName, null) var storeSeconds = 0 # used for caculating total time of all nodes diff --git a/Scenes/ScriptGenerator.gd b/Scenes/ScriptGenerator.gd index e825556c..89ba9d50 100644 --- a/Scenes/ScriptGenerator.gd +++ b/Scenes/ScriptGenerator.gd @@ -231,10 +231,11 @@ func initialize_rooms_available(): var functionVariable = i[1] var defaultAvailability = i[2] - if Slabs.icons.has(slabID): + var slabName = Slabs.fetch_idname(slabID) + if Slabs.icons.has(slabName): var id = scnAvailableButton.instance() id.hint_tooltip = Slabs.data[slabID][Slabs.NAME] + ' availability' - id.get_node("IconTextureRect").texture = Slabs.icons[slabID] + id.get_node("IconTextureRect").texture = Slabs.icons.get(slabName, null) id.set_meta("variable", functionVariable) id.set_meta("ID", slabID) id.get_node("%TextEditableLabel").editable = false diff --git a/Scenes/SlabDisplay.gd b/Scenes/SlabDisplay.gd index 1b064314..319cf795 100644 --- a/Scenes/SlabDisplay.gd +++ b/Scenes/SlabDisplay.gd @@ -19,8 +19,9 @@ func set_visual(columnArray): var slabID = get_meta("ID_of_slab") $AspectRatioContainer/Icon.texture = null - if Slabs.icons.has(slabID): - $AspectRatioContainer/Icon.texture = Slabs.icons[slabID] + var slabName = Slabs.fetch_idname(slabID) + if Slabs.icons.has(slabName): + $AspectRatioContainer/Icon.texture = Slabs.icons.get(slabName, null) if Slabs.is_door(slabID) == false: $AspectRatioContainer.anchor_top -= 0.05 $AspectRatioContainer.anchor_bottom -= 0.05