Skip to content

Commit

Permalink
Resize Map now updates every slab on the map
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Apr 25, 2024
1 parent 877cd1b commit b2f49d0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
16 changes: 8 additions & 8 deletions Scenes/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6427,8 +6427,8 @@ visible = true
margin_left = 1264.0
margin_top = -2160.0
margin_right = 1668.0
margin_bottom = -1937.0
rect_min_size = Vector2( 404, 223 )
margin_bottom = -1982.0
rect_min_size = Vector2( 404, 178 )
mouse_filter = 1
window_title = "Resize map"
resizable = true
Expand All @@ -6449,7 +6449,7 @@ custom_constants/margin_bottom = 20
margin_left = 20.0
margin_top = 20.0
margin_right = 384.0
margin_bottom = 203.0
margin_bottom = 158.0

[node name="HBoxContainer" type="HBoxContainer" parent="Ui/UiSystem/ResizeCurrentMapSize/MarginContainer/VBoxContainer"]
margin_right = 364.0
Expand Down Expand Up @@ -6603,21 +6603,21 @@ pressed = true
text = "Apply border"

[node name="Label" type="Label" parent="Ui/UiSystem/ResizeCurrentMapSize/MarginContainer/VBoxContainer"]
margin_top = 107.0
margin_top = 62.0
margin_right = 364.0
margin_bottom = 152.0
margin_bottom = 107.0
size_flags_vertical = 10
custom_colors/font_color = Color( 1, 0.85098, 0.603922, 1 )
text = "Resizing still needs testing, it may break your map so please keep a backup."
text = "Every slab on the map will be automatically updated when you resize."
align = 1
valign = 1
autowrap = true

[node name="ResizeApplyButton" type="Button" parent="Ui/UiSystem/ResizeCurrentMapSize/MarginContainer/VBoxContainer"]
margin_left = 107.0
margin_top = 156.0
margin_top = 111.0
margin_right = 257.0
margin_bottom = 183.0
margin_bottom = 138.0
rect_min_size = Vector2( 150, 0 )
size_flags_horizontal = 6
size_flags_vertical = 8
Expand Down
2 changes: 1 addition & 1 deletion Scenes/OpenMap.gd
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func start():
#for i in 200:
# yield(get_tree(), "idle_frame")
#oCurrentMap.clear_map()
open_map("D:/Dungeon Keeper/levels/personal/map00002.slb")
open_map("D:/Dungeon Keeper/levels/personal/map00056.slb")
pass
else:
# initialize a cleared map
Expand Down
22 changes: 15 additions & 7 deletions Scenes/ResizeCurrentMapSize.gd
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,20 @@ func _on_ResizeApplyButton_pressed():
oBuffers.resize_all_data_structures(newWidth, newHeight)
remove_outside_instances(newWidth, newHeight)

# var positionsToUpdate = get_positions_to_update(newWidth, newHeight, previousWidth, previousHeight)
# var removeBorder = remove_old_borders(newWidth, newHeight, previousWidth, previousHeight)
# var addBorder = add_new_borders(newWidth, newHeight)
# for pos in removeBorder:
# positionsToUpdate[pos] = true
# for pos in addBorder:
# positionsToUpdate[pos] = true
var positionsToUpdate = get_positions_to_update(newWidth, newHeight, previousWidth, previousHeight)
var removeBorder = remove_old_borders(newWidth, newHeight, previousWidth, previousHeight)
var addBorder = add_new_borders(newWidth, newHeight)
for pos in removeBorder:
positionsToUpdate[pos] = true
for pos in addBorder:
positionsToUpdate[pos] = true

update_editor_appearance()

oOverheadGraphics.update_full_overhead_map(oOverheadGraphics.SINGLE_THREADED)

# I need to update every slab on the map, it's bugged otherwise, it clears a diagonal streak of objects for some reason.

var shapePositionArray = []
for ySlab in range(0, M.ySize):
for xSlab in range(0, M.xSize):
Expand Down Expand Up @@ -143,3 +145,9 @@ func _on_ResizeFillWithID_value_changed(value):
value = int(value)
if Slabs.data.has(value):
oResizeFillWithIDLabel.text = Slabs.data[value][Slabs.NAME]

# for pos in positionsToUpdate.keys():
# var scene = preload('res://t.tscn')
# var id = scene.instance()
# id.position = Vector2((pos.x*96)+48, (pos.y*96)+48)
# oInstances.add_child(id)

0 comments on commit b2f49d0

Please sign in to comment.