Skip to content

Commit

Permalink
Slab Names, clickable Slab name label
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed May 24, 2024
1 parent 499ea1f commit 8b636a8
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 82 deletions.
64 changes: 63 additions & 1 deletion Autoload/ObjectNames.gd → Autoload/Names.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum TYPE {
EXTRA = 696969
}

const NAME_MAPPINGS = {
const things = {
TYPE.EXTRA : {
"ACTIONPOINT" : "Action Point",
"LIGHT" : "Light",
Expand Down Expand Up @@ -267,3 +267,65 @@ const NAME_MAPPINGS = {
"SPELLBOOK_VSN" : "Vision"
}
}

const slabs = {
"HARD": "Impenetrable Rock",
"GOLD": "Gold Seam",
"DIRT": "Earth",
"TORCH_DIRT": "Torch Earth",
"DRAPE_WALL": "Banner Wall",
"TORCH_WALL": "Torch Wall",
"TWINS_WALL": "Twins Wall",
"WOMAN_WALL": "Woman Wall",
"PAIR_WALL": "Pair Wall",
"DAMAGED_WALL": "Damaged Wall",
"PATH": "Dirt Path",
"PRETTY_PATH": "Claimed Area",
"LAVA": "Lava",
"WATER": "Water",
"ENTRANCE_ZONE": "Portal",
"ENTRANCE_WALL": "Portal Wall",
"TREASURY_AREA": "Treasure Room",
"TREASURY_WALL": "Treasure Room Wall",
"BOOK_SHELVES": "Library",
"LIBRARY_WALL": "Library Wall",
"PRISON_AREA": "Prison",
"PRISON_WALL": "Prison Wall",
"TORTURE_AREA": "Torture Chamber",
"TORTURE_WALL": "Torture Chamber Wall",
"TRAINING_AREA": "Training Room",
"TRAINING_WALL": "Training Room Wall",
"HEART_PEDESTAL": "Heart Room",
"HEART_WALL": "Heart Room Wall",
"WORKSHOP_AREA": "Workshop",
"WORKSHOP_WALL": "Workshop Wall",
"SCAVENGE_AREA": "Scavenger Room",
"SCAVENGER_WALL": "Scavenger Room Wall",
"TEMPLE_POOL": "Temple",
"TEMPLE_WALL": "Temple Wall",
"GRAVE_AREA": "Graveyard",
"GRAVE_WALL": "Graveyard Wall",
"HATCHERY": "Hatchery",
"HATCHERY_WALL": "Hatchery Wall",
"LAIR_AREA": "Lair",
"LAIR_WALL": "Lair Wall",
"BARRACK_AREA": "Barracks",
"BARRACK_WALL": "Barracks Wall",
"DOOR_WOODEN": "Wooden Door",
"DOOR_WOODEN2": "Wooden Door",
"DOOR_BRACE": "Braced Door",
"DOOR_BRACE2": "Braced Door",
"DOOR_STEEL": "Iron Door",
"DOOR_STEEL2": "Iron Door",
"DOOR_MAGIC": "Magic Door",
"DOOR_MAGIC2": "Magic Door",
"SLAB50": "Slab 50",
"BRIDGE_FRAME": "Bridge",
"GEMS": "Gems",
"GUARD_AREA": "Guard Post",
"PURPLE_PATH": "Purple Path",
"DOOR_SECRET" : "Secret Door",
"DOOR_SECRET2" : "Secret Door",
"HARD_FLOOR" : "Bedrock",
"AUTOMATIC_WALL" : "Wall Automatic",
};
135 changes: 73 additions & 62 deletions Autoload/Slabs.gd

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Autoload/Things.gd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func fetch_portrait(thing_type, sub_type):


func fetch_name(thing_type, sub_type):
var dictionary_of_names = ObjectNames.NAME_MAPPINGS.get(thing_type)
var dictionary_of_names = Names.things.get(thing_type)
if dictionary_of_names:
var data_structure = data_structure(thing_type)
var sub_type_data = data_structure.get(sub_type)
Expand Down
2 changes: 1 addition & 1 deletion Scenes/AddCustomSlabWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func _on_CustomSlabID_value_changed(value):
var slabName = "Unknown"
value = int(value)
if Slabs.data.has(value):
slabName = Slabs.data[value][Slabs.NAME]
slabName = Slabs.fetch_name(value)
oCustomSlabNameLabel.text = slabName


Expand Down
6 changes: 3 additions & 3 deletions Scenes/CfgLoader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ func load_objects_data(path):
var newEditorTab = Things.GENRE_TO_TAB[newGenre]
Things.DATA_OBJECT[id] = [newName, newSprite, newEditorTab]


func load_terrain_data(path):
var terrain_cfg = Utils.read_dkcfg_file(path)
for section in terrain_cfg:
if section.begins_with("slab"):
var id = int(section)

if id >= 55: # Beyond Slabs.PURPLE_PATH
var slabSection = terrain_cfg[section]

var setName = slabSection.get("Name", "Unknown")
if setName != "Unknown":
setName = Slabs.NAME_MAPPINGS.get(setName, setName.capitalize())
var setName = slabSection.get("Name", "UNKNOWN")

var getBlockFlags = slabSection.get("BlockFlags", [])
if getBlockFlags is String and getBlockFlags == "":
Expand Down
2 changes: 1 addition & 1 deletion Scenes/ImageAsMapDialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func _ready():
# Don't put the junk slabs in
if Slabs.data[slabID][Slabs.EDITOR_TAB] == Slabs.TAB_MAINSLAB:
var buttonID = Button.new()
buttonID.text = Slabs.data[slabID][Slabs.NAME]
buttonID.text = Slabs.fetch_name(slabID)
buttonID.toggle_mode = true
buttonID.group = btnGroup
buttonID.connect("pressed",self,"_on_slab_button_pressed",[buttonID])
Expand Down
2 changes: 2 additions & 0 deletions Scenes/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,8 @@ size_flags_vertical = 3
margin_top = 10.0
margin_right = 276.0
margin_bottom = 31.0
mouse_filter = 1
size_flags_horizontal = 3
text = "Torture Chamber wall"
valign = 1
autowrap = true
Expand Down
9 changes: 7 additions & 2 deletions Scenes/PickSlabWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ onready var oPlaceLockedCheckBox = Nodelist.list["oPlaceLockedCheckBox"]
onready var oConfirmDeleteCustomSlab = Nodelist.list["oConfirmDeleteCustomSlab"]
onready var oAddCustomSlabWindow = Nodelist.list["oAddCustomSlabWindow"]
onready var oOverheadGraphics = Nodelist.list["oOverheadGraphics"]

onready var oSlabNameDisplay = Nodelist.list["oSlabNameDisplay"]

onready var oSelectedRect = $Clippy/SelectedRect
onready var oCenteredLabel = $Clippy/CenteredLabel
Expand Down Expand Up @@ -115,7 +115,8 @@ func add_slabs():
id.set_meta("ID_of_slab", slabID)
id.panelView = Slabs.data[slabID][Slabs.PANEL_VIEW]
id.set_visual(columnArray)
add_child_to_grid(tabs[putIntoTab][GRIDCON_PATH], id, Slabs.data[slabID][Slabs.NAME])
var useName = Slabs.fetch_name(slabID)
add_child_to_grid(tabs[putIntoTab][GRIDCON_PATH], id, useName)

custom_slab_add_new_button()

Expand Down Expand Up @@ -189,6 +190,10 @@ func _on_hovered_over_item(id):
offset = Vector2(id.rect_size.x * 0.5, id.rect_size.y * 0.50)
oCenteredLabel.rect_global_position = id.rect_global_position + offset
oCenteredLabel.get_node("Label").text = id.get_meta("grid_item_text")

if id.has_meta("ID_of_slab"):
var slabID = id.get_meta("ID_of_slab")
oSlabNameDisplay.update_text_with_id(slabID, true)


func current_grid_container():
Expand Down
2 changes: 1 addition & 1 deletion Scenes/ResizeCurrentMapSize.gd
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func _on_SettingsYSizeLine_focus_exited():
func _on_ResizeFillWithID_value_changed(value):
value = int(value)
if Slabs.data.has(value):
oResizeFillWithIDLabel.text = Slabs.data[value][Slabs.NAME]
oResizeFillWithIDLabel.text = Slabs.fetch_name(value)

# for pos in positionsToUpdate.keys():
# var scene = preload('res://t.tscn')
Expand Down
3 changes: 3 additions & 0 deletions Scenes/Selector.gd
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ onready var oSlabSideViewer = Nodelist.list["oSlabSideViewer"]
onready var oAddCustomSlabWindow = Nodelist.list["oAddCustomSlabWindow"]
onready var oDisplaySlxNumbers = Nodelist.list["oDisplaySlxNumbers"]
onready var oOwnerSelection = Nodelist.list["oOwnerSelection"]
onready var oSlabNameDisplay = Nodelist.list["oSlabNameDisplay"]

onready var TILE_SIZE = Constants.TILE_SIZE
onready var SUBTILE_SIZE = Constants.SUBTILE_SIZE
Expand Down Expand Up @@ -295,8 +296,10 @@ func update_cursor_position():
MODE_TILE: position = cursorTile * TILE_SIZE
MODE_SUBTILE: position = cursorSubtile * SUBTILE_SIZE


func moved_to_new_tile():
if mode == MODE_TILE: canPlace = true
oSlabNameDisplay.update_text_with_id(oSelection.cursorOverSlab, false)

func moved_to_new_subtile():
oColumnDetails.update_details()
Expand Down
30 changes: 23 additions & 7 deletions Scenes/SlabNameDisplay.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,30 @@ extends Label
onready var oSelector = Nodelist.list["oSelector"]
onready var oSelection = Nodelist.list["oSelection"]

func _process(delta):
if oSelector.visible == false: return
var display_id_name = false

func _ready():
connect("gui_input", self, "_on_gui_input")


func update_text_with_id(slabID, forceUpdate):
if slabID == null or slabID == -1 or slabID == Slabs.WALL_AUTOMATIC:
return
if oSelector.visible == false and forceUpdate == false: return

var slabID = oSelection.cursorOverSlab
var slabName

var slabName = "Unknown"
if Slabs.data.has(slabID):
slabName = Slabs.data[slabID][Slabs.NAME]
if display_id_name == false:
slabName = Slabs.fetch_name(slabID)
else:
var slabData = Slabs.data.get(slabID)
if slabData:
slabName = slabData[Slabs.NAME]

text = slabName + ' : ' + str(slabID)
#get_parent().self_modulate = Constants.ownerRoomCol[oDataOwnership.get_cell_ownership(oSelector.cursorTile.x,oSelector.cursorTile.y)]

func _on_gui_input(event):
if event is InputEventMouseButton and event.is_pressed():
if event.button_index == BUTTON_LEFT:
display_id_name = !display_id_name
update_text_with_id(oSelection.cursorOverSlab, true)
4 changes: 2 additions & 2 deletions Scenes/ThingDetails.gd
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func light_details(id):
var parentX = id.parentTile - (parentY*M.xSize)
var hoveredCell = oDataSlab.get_cell(parentX,parentY)
if Slabs.data.has(hoveredCell):
value = Slabs.data[hoveredCell][Slabs.NAME]
value = Slabs.fetch_name(hoveredCell)
else:
value = ""
if parentX == 0 and parentY == 0: value = "" # Don't show the text "Impenetrable Rock" for keys
Expand Down Expand Up @@ -132,7 +132,7 @@ func thing_details(id):
var parentX = id.parentTile - (parentY*M.xSize)
var hoveredCell = oDataSlab.get_cell(parentX,parentY)
if Slabs.data.has(hoveredCell):
value = Slabs.data[hoveredCell][Slabs.NAME]
value = Slabs.fetch_name(hoveredCell)
else:
value = ""
if parentX == 0 and parentY == 0: value = "" # Don't show the text "Impenetrable Rock" for keys
Expand Down
2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Slabset="*res://Autoload/Slabset.gd"
Columnset="*res://Autoload/Columnset.gd"
Version="*res://Autoload/Version.gd"
Graphics="*res://Autoload/Graphics.gd"
ObjectNames="*res://Autoload/ObjectNames.gd"
Names="*res://Autoload/Names.gd"

[debug]

Expand Down

0 comments on commit 8b636a8

Please sign in to comment.