Skip to content

Commit 8b636a8

Browse files
committed
Slab Names, clickable Slab name label
1 parent 499ea1f commit 8b636a8

13 files changed

+181
-82
lines changed

Autoload/ObjectNames.gd renamed to Autoload/Names.gd

+63-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ enum TYPE {
1818
EXTRA = 696969
1919
}
2020

21-
const NAME_MAPPINGS = {
21+
const things = {
2222
TYPE.EXTRA : {
2323
"ACTIONPOINT" : "Action Point",
2424
"LIGHT" : "Light",
@@ -267,3 +267,65 @@ const NAME_MAPPINGS = {
267267
"SPELLBOOK_VSN" : "Vision"
268268
}
269269
}
270+
271+
const slabs = {
272+
"HARD": "Impenetrable Rock",
273+
"GOLD": "Gold Seam",
274+
"DIRT": "Earth",
275+
"TORCH_DIRT": "Torch Earth",
276+
"DRAPE_WALL": "Banner Wall",
277+
"TORCH_WALL": "Torch Wall",
278+
"TWINS_WALL": "Twins Wall",
279+
"WOMAN_WALL": "Woman Wall",
280+
"PAIR_WALL": "Pair Wall",
281+
"DAMAGED_WALL": "Damaged Wall",
282+
"PATH": "Dirt Path",
283+
"PRETTY_PATH": "Claimed Area",
284+
"LAVA": "Lava",
285+
"WATER": "Water",
286+
"ENTRANCE_ZONE": "Portal",
287+
"ENTRANCE_WALL": "Portal Wall",
288+
"TREASURY_AREA": "Treasure Room",
289+
"TREASURY_WALL": "Treasure Room Wall",
290+
"BOOK_SHELVES": "Library",
291+
"LIBRARY_WALL": "Library Wall",
292+
"PRISON_AREA": "Prison",
293+
"PRISON_WALL": "Prison Wall",
294+
"TORTURE_AREA": "Torture Chamber",
295+
"TORTURE_WALL": "Torture Chamber Wall",
296+
"TRAINING_AREA": "Training Room",
297+
"TRAINING_WALL": "Training Room Wall",
298+
"HEART_PEDESTAL": "Heart Room",
299+
"HEART_WALL": "Heart Room Wall",
300+
"WORKSHOP_AREA": "Workshop",
301+
"WORKSHOP_WALL": "Workshop Wall",
302+
"SCAVENGE_AREA": "Scavenger Room",
303+
"SCAVENGER_WALL": "Scavenger Room Wall",
304+
"TEMPLE_POOL": "Temple",
305+
"TEMPLE_WALL": "Temple Wall",
306+
"GRAVE_AREA": "Graveyard",
307+
"GRAVE_WALL": "Graveyard Wall",
308+
"HATCHERY": "Hatchery",
309+
"HATCHERY_WALL": "Hatchery Wall",
310+
"LAIR_AREA": "Lair",
311+
"LAIR_WALL": "Lair Wall",
312+
"BARRACK_AREA": "Barracks",
313+
"BARRACK_WALL": "Barracks Wall",
314+
"DOOR_WOODEN": "Wooden Door",
315+
"DOOR_WOODEN2": "Wooden Door",
316+
"DOOR_BRACE": "Braced Door",
317+
"DOOR_BRACE2": "Braced Door",
318+
"DOOR_STEEL": "Iron Door",
319+
"DOOR_STEEL2": "Iron Door",
320+
"DOOR_MAGIC": "Magic Door",
321+
"DOOR_MAGIC2": "Magic Door",
322+
"SLAB50": "Slab 50",
323+
"BRIDGE_FRAME": "Bridge",
324+
"GEMS": "Gems",
325+
"GUARD_AREA": "Guard Post",
326+
"PURPLE_PATH": "Purple Path",
327+
"DOOR_SECRET" : "Secret Door",
328+
"DOOR_SECRET2" : "Secret Door",
329+
"HARD_FLOOR" : "Bedrock",
330+
"AUTOMATIC_WALL" : "Wall Automatic",
331+
};

Autoload/Slabs.gd

+73-62
Large diffs are not rendered by default.

Autoload/Things.gd

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func fetch_portrait(thing_type, sub_type):
7272

7373

7474
func fetch_name(thing_type, sub_type):
75-
var dictionary_of_names = ObjectNames.NAME_MAPPINGS.get(thing_type)
75+
var dictionary_of_names = Names.things.get(thing_type)
7676
if dictionary_of_names:
7777
var data_structure = data_structure(thing_type)
7878
var sub_type_data = data_structure.get(sub_type)

Scenes/AddCustomSlabWindow.gd

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func _on_CustomSlabID_value_changed(value):
7272
var slabName = "Unknown"
7373
value = int(value)
7474
if Slabs.data.has(value):
75-
slabName = Slabs.data[value][Slabs.NAME]
75+
slabName = Slabs.fetch_name(value)
7676
oCustomSlabNameLabel.text = slabName
7777

7878

Scenes/CfgLoader.gd

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ func load_objects_data(path):
6565
var newEditorTab = Things.GENRE_TO_TAB[newGenre]
6666
Things.DATA_OBJECT[id] = [newName, newSprite, newEditorTab]
6767

68+
6869
func load_terrain_data(path):
6970
var terrain_cfg = Utils.read_dkcfg_file(path)
7071
for section in terrain_cfg:
7172
if section.begins_with("slab"):
7273
var id = int(section)
74+
7375
if id >= 55: # Beyond Slabs.PURPLE_PATH
7476
var slabSection = terrain_cfg[section]
7577

76-
var setName = slabSection.get("Name", "Unknown")
77-
if setName != "Unknown":
78-
setName = Slabs.NAME_MAPPINGS.get(setName, setName.capitalize())
78+
var setName = slabSection.get("Name", "UNKNOWN")
7979

8080
var getBlockFlags = slabSection.get("BlockFlags", [])
8181
if getBlockFlags is String and getBlockFlags == "":

Scenes/ImageAsMapDialog.gd

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func _ready():
2424
# Don't put the junk slabs in
2525
if Slabs.data[slabID][Slabs.EDITOR_TAB] == Slabs.TAB_MAINSLAB:
2626
var buttonID = Button.new()
27-
buttonID.text = Slabs.data[slabID][Slabs.NAME]
27+
buttonID.text = Slabs.fetch_name(slabID)
2828
buttonID.toggle_mode = true
2929
buttonID.group = btnGroup
3030
buttonID.connect("pressed",self,"_on_slab_button_pressed",[buttonID])

Scenes/Main.tscn

+2
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,8 @@ size_flags_vertical = 3
12331233
margin_top = 10.0
12341234
margin_right = 276.0
12351235
margin_bottom = 31.0
1236+
mouse_filter = 1
1237+
size_flags_horizontal = 3
12361238
text = "Torture Chamber wall"
12371239
valign = 1
12381240
autowrap = true

Scenes/PickSlabWindow.gd

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ onready var oPlaceLockedCheckBox = Nodelist.list["oPlaceLockedCheckBox"]
1515
onready var oConfirmDeleteCustomSlab = Nodelist.list["oConfirmDeleteCustomSlab"]
1616
onready var oAddCustomSlabWindow = Nodelist.list["oAddCustomSlabWindow"]
1717
onready var oOverheadGraphics = Nodelist.list["oOverheadGraphics"]
18-
18+
onready var oSlabNameDisplay = Nodelist.list["oSlabNameDisplay"]
1919

2020
onready var oSelectedRect = $Clippy/SelectedRect
2121
onready var oCenteredLabel = $Clippy/CenteredLabel
@@ -115,7 +115,8 @@ func add_slabs():
115115
id.set_meta("ID_of_slab", slabID)
116116
id.panelView = Slabs.data[slabID][Slabs.PANEL_VIEW]
117117
id.set_visual(columnArray)
118-
add_child_to_grid(tabs[putIntoTab][GRIDCON_PATH], id, Slabs.data[slabID][Slabs.NAME])
118+
var useName = Slabs.fetch_name(slabID)
119+
add_child_to_grid(tabs[putIntoTab][GRIDCON_PATH], id, useName)
119120

120121
custom_slab_add_new_button()
121122

@@ -189,6 +190,10 @@ func _on_hovered_over_item(id):
189190
offset = Vector2(id.rect_size.x * 0.5, id.rect_size.y * 0.50)
190191
oCenteredLabel.rect_global_position = id.rect_global_position + offset
191192
oCenteredLabel.get_node("Label").text = id.get_meta("grid_item_text")
193+
194+
if id.has_meta("ID_of_slab"):
195+
var slabID = id.get_meta("ID_of_slab")
196+
oSlabNameDisplay.update_text_with_id(slabID, true)
192197

193198

194199
func current_grid_container():

Scenes/ResizeCurrentMapSize.gd

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func _on_SettingsYSizeLine_focus_exited():
143143
func _on_ResizeFillWithID_value_changed(value):
144144
value = int(value)
145145
if Slabs.data.has(value):
146-
oResizeFillWithIDLabel.text = Slabs.data[value][Slabs.NAME]
146+
oResizeFillWithIDLabel.text = Slabs.fetch_name(value)
147147

148148
# for pos in positionsToUpdate.keys():
149149
# var scene = preload('res://t.tscn')

Scenes/Selector.gd

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ onready var oSlabSideViewer = Nodelist.list["oSlabSideViewer"]
3737
onready var oAddCustomSlabWindow = Nodelist.list["oAddCustomSlabWindow"]
3838
onready var oDisplaySlxNumbers = Nodelist.list["oDisplaySlxNumbers"]
3939
onready var oOwnerSelection = Nodelist.list["oOwnerSelection"]
40+
onready var oSlabNameDisplay = Nodelist.list["oSlabNameDisplay"]
4041

4142
onready var TILE_SIZE = Constants.TILE_SIZE
4243
onready var SUBTILE_SIZE = Constants.SUBTILE_SIZE
@@ -295,8 +296,10 @@ func update_cursor_position():
295296
MODE_TILE: position = cursorTile * TILE_SIZE
296297
MODE_SUBTILE: position = cursorSubtile * SUBTILE_SIZE
297298

299+
298300
func moved_to_new_tile():
299301
if mode == MODE_TILE: canPlace = true
302+
oSlabNameDisplay.update_text_with_id(oSelection.cursorOverSlab, false)
300303

301304
func moved_to_new_subtile():
302305
oColumnDetails.update_details()

Scenes/SlabNameDisplay.gd

+23-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,30 @@ extends Label
22
onready var oSelector = Nodelist.list["oSelector"]
33
onready var oSelection = Nodelist.list["oSelection"]
44

5-
func _process(delta):
6-
if oSelector.visible == false: return
5+
var display_id_name = false
6+
7+
func _ready():
8+
connect("gui_input", self, "_on_gui_input")
9+
10+
11+
func update_text_with_id(slabID, forceUpdate):
12+
if slabID == null or slabID == -1 or slabID == Slabs.WALL_AUTOMATIC:
13+
return
14+
if oSelector.visible == false and forceUpdate == false: return
715

8-
var slabID = oSelection.cursorOverSlab
16+
var slabName
917

10-
var slabName = "Unknown"
11-
if Slabs.data.has(slabID):
12-
slabName = Slabs.data[slabID][Slabs.NAME]
18+
if display_id_name == false:
19+
slabName = Slabs.fetch_name(slabID)
20+
else:
21+
var slabData = Slabs.data.get(slabID)
22+
if slabData:
23+
slabName = slabData[Slabs.NAME]
1324

1425
text = slabName + ' : ' + str(slabID)
15-
#get_parent().self_modulate = Constants.ownerRoomCol[oDataOwnership.get_cell_ownership(oSelector.cursorTile.x,oSelector.cursorTile.y)]
26+
27+
func _on_gui_input(event):
28+
if event is InputEventMouseButton and event.is_pressed():
29+
if event.button_index == BUTTON_LEFT:
30+
display_id_name = !display_id_name
31+
update_text_with_id(oSelection.cursorOverSlab, true)

Scenes/ThingDetails.gd

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func light_details(id):
9090
var parentX = id.parentTile - (parentY*M.xSize)
9191
var hoveredCell = oDataSlab.get_cell(parentX,parentY)
9292
if Slabs.data.has(hoveredCell):
93-
value = Slabs.data[hoveredCell][Slabs.NAME]
93+
value = Slabs.fetch_name(hoveredCell)
9494
else:
9595
value = ""
9696
if parentX == 0 and parentY == 0: value = "" # Don't show the text "Impenetrable Rock" for keys
@@ -132,7 +132,7 @@ func thing_details(id):
132132
var parentX = id.parentTile - (parentY*M.xSize)
133133
var hoveredCell = oDataSlab.get_cell(parentX,parentY)
134134
if Slabs.data.has(hoveredCell):
135-
value = Slabs.data[hoveredCell][Slabs.NAME]
135+
value = Slabs.fetch_name(hoveredCell)
136136
else:
137137
value = ""
138138
if parentX == 0 and parentY == 0: value = "" # Don't show the text "Impenetrable Rock" for keys

project.godot

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Slabset="*res://Autoload/Slabset.gd"
7070
Columnset="*res://Autoload/Columnset.gd"
7171
Version="*res://Autoload/Version.gd"
7272
Graphics="*res://Autoload/Graphics.gd"
73-
ObjectNames="*res://Autoload/ObjectNames.gd"
73+
Names="*res://Autoload/Names.gd"
7474

7575
[debug]
7676

0 commit comments

Comments
 (0)