Skip to content

Commit 5714cd1

Browse files
committed
wip terrain.cfg loading, wip compare creature stats window
1 parent 4fc48f6 commit 5714cd1

File tree

4 files changed

+280
-15
lines changed

4 files changed

+280
-15
lines changed

Autoload/Slabs.gd

+6-8
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ enum {
8181
GEMS = 52,
8282
GUARD_POST = 53,
8383
PURPLE_PATH = 54,
84-
# PURPLE_PATH2 = 55,
85-
# PURPLE_PATH3 = 56,
86-
# PURPLE_PATH4 = 57,
8784
# 58 doesn't exist within 1304 entries
8885
WALL_AUTOMATIC = 999,
8986
}
@@ -263,11 +260,6 @@ IRON_DOOR_2,
263260
MAGIC_DOOR_2,
264261
PORTAL,
265262
DUNGEON_HEART,
266-
267-
#PURPLE_PATH2,
268-
#PURPLE_PATH3,
269-
#PURPLE_PATH4,
270-
271263
EARTH_WITH_TORCH,
272264
WALL_WITH_TORCH,
273265
WALL_WITH_BANNER,
@@ -303,3 +295,9 @@ func is_door(slabID):
303295
if data[slabID][BITMASK_TYPE] == BITMASK_DOOR1 or data[slabID][BITMASK_TYPE] == BITMASK_DOOR2:
304296
return true
305297
return false
298+
299+
var NAME_MAPPINGS = {
300+
"DOOR_SECRET" : "Secret Door",
301+
"DOOR_SECRET2" : "Secret Door",
302+
"HARD_FLOOR" : "Hard Floor",
303+
}

Scenes/CfgLoader.gd

+44-6
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,53 @@ func load_objects_data(path):
5757
var id = int(section)
5858
if id == 0: continue
5959
if id >= 136 or id in [100, 101, 102, 103, 104, 105]: # Dummy Boxes should be overwritten
60-
var data = objects_cfg[section]
61-
var newName = data["Name"]
62-
var animID = data["AnimationID"]
60+
var objSection = objects_cfg[section]
61+
var newName = objSection["Name"]
62+
var animID = objSection["AnimationID"]
6363
var newSprite = get_sprite(animID, newName)
64-
var newGenre = data.get("Genre", null)
64+
var newGenre = objSection.get("Genre", null)
6565
var newEditorTab = Things.GENRE_TO_TAB[newGenre]
6666
Things.DATA_OBJECT[id] = [newName, newSprite, newEditorTab]
6767

68+
func load_terrain_data(path):
69+
var terrain_cfg = Utils.read_dkcfg_file(path)
70+
for section in terrain_cfg:
71+
if section.begins_with("slab"):
72+
var id = int(section)
73+
if id >= 55: # Beyond Slabs.PURPLE_PATH
74+
var slabSection = terrain_cfg[section]
75+
76+
var setName = slabSection.get("Name", "Unknown")
77+
if setName != "Unknown":
78+
setName = Slabs.NAME_MAPPINGS.get(setName, setName.capitalize())
79+
80+
# BlockFlagsHeight
81+
# BlockHealthIndex
82+
# BlockFlags
83+
# NoBlockFlags #; Possible (no)block flags are: VALUABLE, IS_ROOM, UNEXPLORED, DIGGABLE, FILLED, IS_DOOR, and TAGGED_VALUABLE.
84+
# FillStyle # ; The type of terrain this slab fills adjacent slabs with if possible. 1 = Lava. 2 = Water.
85+
# Category # ; 0 = Unclaimed. 1 = Diggable dirt. 2 = Claimed path. 3 = Fortified wall. 4 = Room interior. 5 = Obstacle.
86+
# SlbID
87+
# Indestructible # ; If set to 1 the slab cannot be dug, is immune to vandalizing and eruption effect.
88+
# Wibble # ; The amount of distortion the slab has in normal view. The higher the value, the less distortion there is.
89+
# Animated
90+
# IsSafeLand
91+
# IsDiggable
92+
# IsOwnable
93+
# WlbType
94+
95+
Slabs.data[id] = [
96+
setName,
97+
Slabs.BLOCK_SLAB,
98+
Slabs.BITMASK_BLOCK,
99+
Slabs.PANEL_TOP_VIEW,
100+
0,
101+
Slabs.TAB_MAINSLAB,
102+
Slabs.WIBBLE_ON,
103+
Slabs.REMEMBER_PATH,
104+
Slabs.NOT_OWNABLE,
105+
]
106+
68107

69108
func load_creatures_data(path):
70109
var creature_cfg = Utils.read_dkcfg_file(path)
@@ -101,8 +140,7 @@ func load_trapdoor_data(path):
101140
Things.DATA_TRAP[id] = [newName, newSprite, Things.TAB_TRAP]
102141
Things.LIST_OF_BOXES[crateName] = [trapOrDoor, id]
103142

104-
func load_terrain_data(path):
105-
var terrain_cfg = Utils.read_dkcfg_file(path)
143+
106144

107145

108146
func get_sprite(first_priority, second_priority):

Scenes/CompareCreatureStats.gd

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
extends WindowDialog
2+
onready var oGame = Nodelist.list["oGame"]
3+
onready var oSortCreaStatsGrid = Nodelist.list["oSortCreaStatsGrid"]
4+
onready var oStatsOptionButton = Nodelist.list["oStatsOptionButton"]
5+
6+
7+
var all_creature_data = {}
8+
9+
var list_data = []
10+
var selected_labels = []
11+
12+
func _ready():
13+
for i in 10:
14+
yield(get_tree(),'idle_frame')
15+
16+
var CODETIME_START = OS.get_ticks_msec()
17+
var listOfCfgs = Utils.get_filetype_in_directory(oGame.GAME_DIRECTORY.plus_file("creatrs"), "CFG")
18+
for path in listOfCfgs:
19+
var aaa = Utils.read_dkcfg_file(path)
20+
all_creature_data[path.get_file()] = aaa
21+
#print(creature_data)
22+
23+
print('Codetime: ' + str(OS.get_ticks_msec() - CODETIME_START) + 'ms')
24+
25+
populate_optionbutton()
26+
27+
28+
# Default selection
29+
oStatsOptionButton.select(2)
30+
_on_StatsOptionButton_item_selected(2)
31+
32+
Utils.popup_centered(self)
33+
34+
func _on_StatsOptionButton_item_selected(index):
35+
update_list()
36+
37+
func update_list():
38+
for file in all_creature_data:
39+
for section in all_creature_data[file]:
40+
if section == "attributes":
41+
var getName = all_creature_data[file][section].get("Name")
42+
var getHealth = all_creature_data[file][section].get("Health")
43+
44+
list_data.append([getName, getHealth])
45+
46+
list_data.sort_custom(self, "sort_list")
47+
48+
for i in list_data:
49+
add_entry(i[0], i[1], Color(0.5,0.5,0.5))
50+
51+
52+
func sort_list(a, b):
53+
return int(a[1]) < int(b[1])
54+
55+
func add_entry(string1, value, fontColor):
56+
var addLabel1 = Label.new()
57+
addLabel1.text = string1
58+
oSortCreaStatsGrid.add_child(addLabel1)
59+
addLabel1.set("custom_colors/font_color", fontColor)
60+
addLabel1.mouse_filter = Control.MOUSE_FILTER_PASS
61+
62+
var addLabel2 = Label.new()
63+
addLabel2.text = str(value)
64+
oSortCreaStatsGrid.add_child(addLabel2)
65+
addLabel2.set("custom_colors/font_color", fontColor)
66+
addLabel2.mouse_filter = Control.MOUSE_FILTER_PASS
67+
68+
addLabel1.size_flags_horizontal = Control.SIZE_EXPAND_FILL
69+
addLabel2.size_flags_horizontal = Control.SIZE_EXPAND_FILL
70+
71+
addLabel1.connect("mouse_entered", self, "_on_label_mouse_entered", [addLabel1, addLabel2])
72+
addLabel2.connect("mouse_entered", self, "_on_label_mouse_entered", [addLabel1, addLabel2])
73+
74+
addLabel1.connect("mouse_exited", self, "_on_label_mouse_exited", [addLabel1, addLabel2])
75+
addLabel2.connect("mouse_exited", self, "_on_label_mouse_exited", [addLabel1, addLabel2])
76+
77+
addLabel1.connect("gui_input", self, "_on_label_gui_input", [addLabel1, addLabel2])
78+
addLabel2.connect("gui_input", self, "_on_label_gui_input", [addLabel1, addLabel2])
79+
80+
func _on_label_mouse_entered(l1,l2):
81+
if [l1, l2] in selected_labels:
82+
pass
83+
else:
84+
l1.set("custom_colors/font_color", Color(1,1,1))
85+
l2.set("custom_colors/font_color", Color(1,1,1))
86+
87+
func _on_label_mouse_exited(l1,l2):
88+
if [l1, l2] in selected_labels:
89+
pass
90+
else:
91+
l1.set("custom_colors/font_color", Color(0.5,0.5,0.5))
92+
l2.set("custom_colors/font_color", Color(0.5,0.5,0.5))
93+
94+
func _on_label_gui_input(event, l1, l2):
95+
if event is InputEventMouseButton and event.pressed and event.button_index == BUTTON_LEFT:
96+
if [l1, l2] in selected_labels:
97+
selected_labels.erase([l1, l2])
98+
l1.set("custom_colors/font_color", Color(0.5, 0.5, 0.5))
99+
l2.set("custom_colors/font_color", Color(0.5, 0.5, 0.5))
100+
else:
101+
selected_labels.append([l1, l2])
102+
l1.set("custom_colors/font_color", Color(1, 1, 1))
103+
l2.set("custom_colors/font_color", Color(1, 1, 1))
104+
105+
func _on_NameStatsButton_pressed():
106+
pass # Replace with function body.
107+
108+
109+
110+
111+
112+
func _on_RightStatsButton_pressed():
113+
var next_index = oStatsOptionButton.selected + 1
114+
while next_index < oStatsOptionButton.get_item_count() and oStatsOptionButton.get_item_text(next_index) == "":
115+
next_index += 1
116+
if next_index >= oStatsOptionButton.get_item_count():
117+
next_index = 0
118+
while next_index < oStatsOptionButton.selected and oStatsOptionButton.get_item_text(next_index) == "":
119+
next_index += 1
120+
oStatsOptionButton.selected = next_index
121+
122+
func _on_LeftStatsButton_pressed():
123+
var prev_index = oStatsOptionButton.selected - 1
124+
while prev_index >= 0 and oStatsOptionButton.get_item_text(prev_index) == "":
125+
prev_index -= 1
126+
if prev_index < 0:
127+
prev_index = oStatsOptionButton.get_item_count() - 1
128+
while prev_index > oStatsOptionButton.selected and oStatsOptionButton.get_item_text(prev_index) == "":
129+
prev_index -= 1
130+
oStatsOptionButton.selected = prev_index
131+
132+
133+
func populate_optionbutton():
134+
var items_checked = 0
135+
for file in all_creature_data:
136+
items_checked+=1
137+
for section in all_creature_data[file]:
138+
if items_checked == 1:
139+
for blah in all_creature_data[file][section].keys():
140+
oStatsOptionButton.add_item(blah)
141+
oStatsOptionButton.add_separator()

Scenes/Main.tscn

+89-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=190 format=2]
1+
[gd_scene load_steps=191 format=2]
22

33
[ext_resource path="res://Scenes/SlabStyle.gd" type="Script" id=1]
44
[ext_resource path="res://Scenes/SlabPlacement.gd" type="Script" id=2]
@@ -169,6 +169,7 @@
169169
[ext_resource path="res://Scenes/ThreadedSaveUndo.gd" type="Script" id=167]
170170
[ext_resource path="res://Scenes/Guidelines.gd" type="Script" id=168]
171171
[ext_resource path="res://Scenes/CfgLoader.gd" type="Script" id=169]
172+
[ext_resource path="res://Scenes/CompareCreatureStats.gd" type="Script" id=170]
172173

173174
[sub_resource type="CubeMesh" id=2]
174175
size = Vector3( 1, 1, 1 )
@@ -6800,6 +6801,89 @@ allow_reselect = true
68006801
auto_height = true
68016802
script = ExtResource( 65 )
68026803

6804+
[node name="SortCreatureStats" type="WindowDialog" parent="Ui/UiSystem"]
6805+
visible = true
6806+
margin_left = 1704.0
6807+
margin_top = -1832.0
6808+
margin_right = 2053.0
6809+
margin_bottom = -886.0
6810+
rect_min_size = Vector2( 281, 296 )
6811+
mouse_filter = 1
6812+
window_title = "Compare Creature Stats"
6813+
resizable = true
6814+
script = ExtResource( 170 )
6815+
6816+
[node name="MarginContainer" type="MarginContainer" parent="Ui/UiSystem/SortCreatureStats"]
6817+
anchor_right = 1.0
6818+
anchor_bottom = 1.0
6819+
mouse_filter = 1
6820+
size_flags_horizontal = 3
6821+
size_flags_vertical = 3
6822+
custom_constants/margin_right = 20
6823+
custom_constants/margin_top = 20
6824+
custom_constants/margin_left = 20
6825+
custom_constants/margin_bottom = 20
6826+
6827+
[node name="VBoxContainer" type="VBoxContainer" parent="Ui/UiSystem/SortCreatureStats/MarginContainer"]
6828+
margin_left = 20.0
6829+
margin_top = 20.0
6830+
margin_right = 329.0
6831+
margin_bottom = 926.0
6832+
size_flags_horizontal = 3
6833+
size_flags_vertical = 3
6834+
6835+
[node name="HBoxContainer" type="HBoxContainer" parent="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer"]
6836+
margin_right = 309.0
6837+
margin_bottom = 27.0
6838+
6839+
[node name="LeftStatsButton" type="Button" parent="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/HBoxContainer"]
6840+
margin_right = 27.0
6841+
margin_bottom = 27.0
6842+
rect_min_size = Vector2( 27, 27 )
6843+
size_flags_horizontal = 0
6844+
text = "<"
6845+
6846+
[node name="StatsOptionButton" type="OptionButton" parent="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/HBoxContainer"]
6847+
margin_left = 31.0
6848+
margin_right = 278.0
6849+
margin_bottom = 27.0
6850+
size_flags_horizontal = 3
6851+
text = "Sections"
6852+
6853+
[node name="RightStatsButton" type="Button" parent="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/HBoxContainer"]
6854+
margin_left = 282.0
6855+
margin_right = 309.0
6856+
margin_bottom = 27.0
6857+
rect_min_size = Vector2( 27, 27 )
6858+
size_flags_horizontal = 0
6859+
text = ">"
6860+
6861+
[node name="ScrollContainer" type="ScrollContainer" parent="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer"]
6862+
anchor_right = 1.0
6863+
anchor_bottom = 1.0
6864+
size_flags_horizontal = 3
6865+
size_flags_vertical = 3
6866+
6867+
[node name="SortCreaStatsGrid" type="GridContainer" parent="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/ScrollContainer"]
6868+
anchor_right = 1.0
6869+
anchor_bottom = 1.0
6870+
size_flags_horizontal = 3
6871+
size_flags_vertical = 3
6872+
custom_constants/hseparation = 20
6873+
columns = 2
6874+
6875+
[node name="HBoxContainer2" type="HBoxContainer" parent="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer"]
6876+
margin_top = 879.0
6877+
margin_right = 309.0
6878+
margin_bottom = 906.0
6879+
6880+
[node name="NameStatsButton" type="Button" parent="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/HBoxContainer2"]
6881+
margin_right = 100.0
6882+
margin_bottom = 27.0
6883+
rect_min_size = Vector2( 100, 0 )
6884+
size_flags_horizontal = 2
6885+
text = "Name"
6886+
68036887
[node name="MapCoordinatesWindow" type="WindowDialog" parent="Ui/UiSystem"]
68046888
visible = true
68056889
margin_left = -1480.0
@@ -7556,6 +7640,10 @@ script = SubResource( 20 )
75567640
[connection signal="pressed" from="Ui/UiSystem/ResizeCurrentMapSize/MarginContainer/VBoxContainer/ResizeApplyButton" to="Ui/UiSystem/ResizeCurrentMapSize" method="_on_ResizeApplyButton_pressed"]
75577641
[connection signal="visibility_changed" from="Ui/UiSystem/GridDataWindow" to="Game2D/AnalyzeGrids" method="_on_GridDataWindow_visibility_changed"]
75587642
[connection signal="visibility_changed" from="Ui/UiSystem/ActionPointListWindow" to="Ui/UiSystem/ActionPointListWindow/MarginContainer/VBoxContainer/ScrollContainer/ActionPointList" method="_on_ActionPointListWindow_visibility_changed"]
7643+
[connection signal="pressed" from="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/HBoxContainer/LeftStatsButton" to="Ui/UiSystem/SortCreatureStats" method="_on_LeftStatsButton_pressed"]
7644+
[connection signal="item_selected" from="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/HBoxContainer/StatsOptionButton" to="Ui/UiSystem/SortCreatureStats" method="_on_StatsOptionButton_item_selected"]
7645+
[connection signal="pressed" from="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/HBoxContainer/RightStatsButton" to="Ui/UiSystem/SortCreatureStats" method="_on_RightStatsButton_pressed"]
7646+
[connection signal="pressed" from="Ui/UiSystem/SortCreatureStats/MarginContainer/VBoxContainer/HBoxContainer2/NameStatsButton" to="Ui/UiSystem/SortCreatureStats" method="_on_NameStatsButton_pressed"]
75597647
[connection signal="visibility_changed" from="Ui/UiSystem/MapCoordinatesWindow" to="Ui/UiSystem/MapCoordinatesWindow" method="_on_MapCoordinatesWindow_visibility_changed"]
75607648
[connection signal="gui_input" from="Ui/UiSystem/MapCoordinatesWindow/MarginContainer/VBoxContainer/LandviewAspectRatioContainer/LandviewImage" to="Ui/UiSystem/MapCoordinatesWindow" method="_on_LandviewImage_gui_input"]
75617649
[connection signal="resized" from="Ui/UiSystem/MapCoordinatesWindow/MarginContainer/VBoxContainer/LandviewAspectRatioContainer/LandviewImage" to="Ui/UiSystem/MapCoordinatesWindow" method="_on_LandviewImage_resized"]

0 commit comments

Comments
 (0)