Skip to content

Commit

Permalink
room icons use strings
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Jun 3, 2024
1 parent 8016447 commit a2427ff
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
45 changes: 26 additions & 19 deletions Autoload/Slabs.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = [
Expand Down
3 changes: 2 additions & 1 deletion Scenes/ResearchableItem.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Scenes/ScriptGenerator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Scenes/SlabDisplay.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a2427ff

Please sign in to comment.